commit 4e93fcbdc7c7ffcbe977bc051ac8ea2a34bae4fe from: Omar Polo date: Mon Jan 17 15:10:40 2022 UTC 9pclib: add wstat support commit - d33c93c4c8ccc67d3f0b9aaaa37c450dc5ea36a2 commit + 4e93fcbdc7c7ffcbe977bc051ac8ea2a34bae4fe blob - c9cc93ca244ecef5eedfab354ec8bc7c3ce57f98 blob + d53ac475b40fa93e409221ea11b457252ba56a35 --- lib/9pclib.c +++ lib/9pclib.c @@ -20,11 +20,12 @@ #include #include -#include "9pclib.h" #include "kami.h" #include "log.h" #include "utils.h" +#include "9pclib.h" + uint16_t iota_tag; struct evbuffer *evb; @@ -67,7 +68,10 @@ write_str(uint16_t len, const char *str) void write_str_auto(const char *str) { - write_str(strlen(str), str); + if (str == NULL) + write_16(0); + else + write_str(strlen(str), str); } void @@ -240,7 +244,43 @@ tstat(uint32_t fid) { /* fid[4] */ write_hdr_auto(sizeof(fid), Tstat); + write_fid(fid); +} + +void +twstat(uint32_t fid, const struct np_stat *st) +{ + uint32_t len; + + /* fid[4] stat[n] */ + len = sizeof(fid) + NPSTATSIZ(0, 0, 0, 0); + if (st->name != NULL) + len += strlen(st->name); + if (st->uid != NULL) + len += strlen(st->uid); + if (st->gid != NULL) + len += strlen(st->gid); + if (st->muid != NULL) + len += strlen(st->muid); + + write_hdr_auto(len, Twstat); write_fid(fid); + write_16(st->type); + write_32(st->dev); + + write_64(st->qid.path); + write_32(st->qid.vers); + write_8(st->qid.type); + + write_32(st->mode); + write_32(st->atime); + write_32(st->mtime); + write_64(st->length); + + write_str_auto(st->name); + write_str_auto(st->uid); + write_str_auto(st->gid); + write_str_auto(st->muid); } void blob - 9952a8b55f1c826652ef1bd543c9218344942d47 blob + f5d1a177175502208a1af2732267108c99978d9d --- lib/9pclib.h +++ lib/9pclib.h @@ -48,6 +48,7 @@ void tcreate(uint32_t, const char *, uint32_t, uint8 void tread(uint32_t, uint64_t, uint32_t); void twrite(uint32_t, uint64_t, const void *, uint32_t); void tstat(uint32_t); +void twstat(uint32_t, const struct np_stat *); void tremove(uint32_t); #endif