commit 29f1f5824909cc91325fd45105a82d1006f5e176 from: Omar Polo date: Mon Dec 13 18:03:33 2021 UTC update qid and fid structs + docs I've finally made up my mind regarding the qid and fid handling. fids are fine as they currently are, I've just added some comments to don't forget the meaning of the iomode and fd fields. The values KFIO_W/R are new and will be soon used by the (soon to be added) Topen call. qids keep the current semantics, but loose some fields that I've added when I wasn't sure yet. To reiterate: a qid is a directory file descriptor plus an optional path. If path is empty, the qid refers to the directory, otherwise to that file in the current directory, c.f. openat(3). This makes implementing Topen easier: for instance, if fid1 and fid2 are backed by the same qid, a Topen on fid1 doesn't need to alter fid1->qid, and so fid2 is still fine. The reference counting on qids ensures that we end up closing all the directories fd. commit - 148895f4f26017f5219f2033d6e061ef950a78dc commit + 29f1f5824909cc91325fd45105a82d1006f5e176 blob - de3e8f6710a859dbc37ab900ca0f0c48f728cdf1 blob + 02e7afb62c665b9b27d4a9a0bc732ac78acac977 --- client.c +++ client.c @@ -45,9 +45,7 @@ struct qid { int refcount; - int dir; int fd; - char fpath[PATH_MAX+1]; STAILQ_ENTRY(qid) entries; @@ -56,7 +54,21 @@ struct qid { STAILQ_HEAD(fidhead, fid) fids; struct fid { uint32_t fid; + + /* + * 0 when the fid was not yet opened for I/O otherwise set to + * the bitwise or of KFIO_R for read and KFIO_W for write + */ +#define KFIO_W 0x02 +#define KFIO_R 0x04 int iomode; + + /* + * if iomode is set, this fid was opened and fd represents its + * file descriptor. + */ + int fd; + struct qid *qid; STAILQ_ENTRY(fid) entries; };