summaryrefslogtreecommitdiff
path: root/lib9p
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2024-10-26 02:58:42 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2024-10-26 02:58:42 -0600
commit7f3507b606b0f5c0c44cc59eb27e87575cf87701 (patch)
tree7a94f620d7bb5920916f17139dcf37a2b68b065d /lib9p
parent1dad21650eb6fb3a4b9bba6c0ddd1402930163e2 (diff)
conventions: Don't have 2 ways to spell "implements_foo"
Stop defining "struct foo" as a synonym for "implements_foo".
Diffstat (limited to 'lib9p')
-rw-r--r--lib9p/include/lib9p/srv.h81
-rw-r--r--lib9p/srv.c24
2 files changed, 53 insertions, 52 deletions
diff --git a/lib9p/include/lib9p/srv.h b/lib9p/include/lib9p/srv.h
index b9669d5..072925f 100644
--- a/lib9p/include/lib9p/srv.h
+++ b/lib9p/include/lib9p/srv.h
@@ -41,65 +41,66 @@ static inline int lib9p_srv_acknowledge_flush(struct lib9p_srv_ctx *ctx) {
/* interface definitions ******************************************************/
-struct lib9p_srv_file;
+struct lib9p_srv_file_vtable;
+
+struct __lib9p_srv_file;
+typedef struct __lib9p_srv_file {
+ struct lib9p_srv_file_vtable *vtable;
+
+ /* Managed by srv.c, but should be cloned by ->vtable->clone(). */
+ struct __lib9p_srv_file *_parent_dir; /* clone this
+
+ /* Managed by srv.c, but should be initialized to 0 by ->vtable->clone(). */
+ /* ref type 1: an entry in fidmap
+ * ref type 2: ->_parent_dir of another file */
+ unsigned int _refcount;
+} implements_lib9p_srv_file;
struct lib9p_srv_file_vtable {
/* all - resource management */
- struct lib9p_srv_file *(*clone )(struct lib9p_srv_file *, struct lib9p_srv_ctx *);
- void (*free )(struct lib9p_srv_file *, struct lib9p_srv_ctx *);
+ implements_lib9p_srv_file *(*clone )(implements_lib9p_srv_file *, struct lib9p_srv_ctx *);
+ void (*free )(implements_lib9p_srv_file *, struct lib9p_srv_ctx *);
/* all - syscalls */
- uint32_t (*io )(struct lib9p_srv_file *, struct lib9p_srv_ctx *,
- lib9p_o_t flags);
- struct lib9p_stat (*stat )(struct lib9p_srv_file *, struct lib9p_srv_ctx *);
- void (*wstat )(struct lib9p_srv_file *, struct lib9p_srv_ctx *,
- struct lib9p_stat new);
- void (*remove )(struct lib9p_srv_file *, struct lib9p_srv_ctx *);
+ uint32_t (*io )(implements_lib9p_srv_file *, struct lib9p_srv_ctx *,
+ lib9p_o_t flags);
+ struct lib9p_stat (*stat )(implements_lib9p_srv_file *, struct lib9p_srv_ctx *);
+ void (*wstat )(implements_lib9p_srv_file *, struct lib9p_srv_ctx *,
+ struct lib9p_stat new);
+ void (*remove )(implements_lib9p_srv_file *, struct lib9p_srv_ctx *);
/* directories - base */
- struct lib9p_srv_file *(*dopen )(struct lib9p_srv_file *, struct lib9p_srv_ctx *,
- char *childname);
- struct lib9p_srv_file *(*dcreate)(struct lib9p_srv_file *, struct lib9p_srv_ctx *,
- char *childname,
- lib9p_dm_t perm, lib9p_o_t flags);
+ implements_lib9p_srv_file *(*dopen )(implements_lib9p_srv_file *, struct lib9p_srv_ctx *,
+ char *childname);
+ implements_lib9p_srv_file *(*dcreate)(implements_lib9p_srv_file *, struct lib9p_srv_ctx *,
+ char *childname,
+ lib9p_dm_t perm, lib9p_o_t flags);
/* directories - once opened */
- size_t /* <- obj cnt */(*dread )(struct lib9p_srv_file *, struct lib9p_srv_ctx *,
- uint8_t *buf,
- uint32_t byte_count, /* <- num bytes */
- size_t obj_offset); /* <- starting at this object */
+ size_t /* <- obj cnt */ (*dread )(implements_lib9p_srv_file *, struct lib9p_srv_ctx *,
+ uint8_t *buf,
+ uint32_t byte_count, /* <- num bytes */
+ size_t obj_offset); /* <- starting at this object */
/* non-directories - once opened */
- uint32_t (*pread )(struct lib9p_srv_file *, struct lib9p_srv_ctx *,
- void *buf,
- uint32_t byte_count,
- uint64_t byte_offset);
- uint32_t (*pwrite )(struct lib9p_srv_file *, struct lib9p_srv_ctx *,
- void *buf,
- uint32_t byte_count,
- uint64_t byte_offset);
+ uint32_t (*pread )(implements_lib9p_srv_file *, struct lib9p_srv_ctx *,
+ void *buf,
+ uint32_t byte_count,
+ uint64_t byte_offset);
+ uint32_t (*pwrite )(implements_lib9p_srv_file *, struct lib9p_srv_ctx *,
+ void *buf,
+ uint32_t byte_count,
+ uint64_t byte_offset);
};
-typedef struct lib9p_srv_file {
- struct lib9p_srv_file_vtable *vtable;
-
- /* Managed by srv.c, but should be cloned by ->vtable->clone(). */
- struct lib9p_srv_file *_parent_dir; /* clone this
-
- /* Managed by srv.c, but should be initialized to 0 by ->vtable->clone(). */
- /* ref type 1: an entry in fidmap
- * ref type 2: ->_parent_dir of another file */
- unsigned int _refcount;
-} implements_lib9p_srv_file;
-
/* main server entrypoints ****************************************************/
CR_RPC_DECLARE(_lib9p_srv_reqch, struct _lib9p_srv_req *, bool)
struct lib9p_srv {
/* Things you provide */
- void /*TODO*/ (*auth )(struct lib9p_srv_ctx *, char *treename); /* optional */
- struct lib9p_srv_file *(*rootdir)(struct lib9p_srv_ctx *, char *treename);
+ void /*TODO*/ (*auth )(struct lib9p_srv_ctx *, char *treename); /* optional */
+ implements_lib9p_srv_file *(*rootdir)(struct lib9p_srv_ctx *, char *treename);
/* For internal use */
_lib9p_srv_reqch_t _reqch;
diff --git a/lib9p/srv.c b/lib9p/srv.c
index 83a6555..43676a8 100644
--- a/lib9p/srv.c
+++ b/lib9p/srv.c
@@ -28,10 +28,10 @@
#define FIDFLAG_OPEN (FIDFLAG_OPEN_R|FIDFLAG_OPEN_W)
struct _srv_fidinfo {
- struct lib9p_srv_file *file;
- uint8_t flags;
- size_t dir_idx;
- uint32_t dir_off;
+ implements_lib9p_srv_file *file;
+ uint8_t flags;
+ size_t dir_idx;
+ uint32_t dir_off;
};
#define NAME fidmap
@@ -65,7 +65,7 @@ struct _srv_conn {
struct _srv_sess {
/* immutable */
- struct _srv_conn *parent_conn;
+ struct _srv_conn *parent_conn;
enum lib9p_version version;
uint32_t max_msg_size;
uint32_t rerror_overhead;
@@ -407,7 +407,7 @@ static inline bool util_check_perm(struct lib9p_srv_ctx *ctx, struct lib9p_stat
return mode & action;
}
-static inline bool util_release(struct lib9p_srv_ctx *ctx, struct lib9p_srv_file *file) {
+static inline bool util_release(struct lib9p_srv_ctx *ctx, implements_lib9p_srv_file *file) {
assert(file);
file->_refcount--;
if (file->_refcount == 0) {
@@ -564,7 +564,7 @@ static void handle_Tattach(struct _lib9p_srv_req *ctx,
return;
}
- struct lib9p_srv_file *rootdir = srv->rootdir(&ctx->ctx, req->aname.utf8);
+ implements_lib9p_srv_file *rootdir = srv->rootdir(&ctx->ctx, req->aname.utf8);
assert((rootdir == NULL) == lib9p_ctx_has_error(&ctx->ctx.basectx));
if (lib9p_ctx_has_error(&ctx->ctx.basectx))
return;
@@ -623,7 +623,7 @@ static void handle_Twalk(struct _lib9p_srv_req *ctx,
return;
}
- struct lib9p_srv_file *dir = fidinfo->file;
+ implements_lib9p_srv_file *dir = fidinfo->file;
if (req->newfid != req->fid) {
dir = VCALL(dir, clone, &ctx->ctx);
assert((dir == NULL) == lib9p_ctx_has_error(&ctx->ctx.basectx));
@@ -635,7 +635,7 @@ static void handle_Twalk(struct _lib9p_srv_req *ctx,
resp->wqid = (struct lib9p_qid *)(&resp[1]);
for (resp->nwqid = 0; resp->nwqid < req->nwname; resp->nwqid++) {
- struct lib9p_srv_file *member;
+ implements_lib9p_srv_file *member;
if (strcmp(req->wname[resp->nwqid].utf8, "..") == 0) {
member = dir->_parent_dir;
} else {
@@ -727,7 +727,7 @@ static void handle_Topen(struct _lib9p_srv_req *ctx,
/* Variables. */
lib9p_o_t reqmode = req->mode;
uint8_t fidflags = fidinfo->flags;
- struct lib9p_srv_file *file = fidinfo->file;
+ implements_lib9p_srv_file *file = fidinfo->file;
/* Check permissions. */
if (reqmode & LIB9P_O_RCLOSE) {
@@ -811,7 +811,7 @@ static void handle_Tread(struct _lib9p_srv_req *ctx,
}
/* Variables. */
- struct lib9p_srv_file *file = fidinfo->file;
+ implements_lib9p_srv_file *file = fidinfo->file;
resp->data.dat = (char *)(&resp[1]);
/* Do it. */
@@ -864,7 +864,7 @@ static void handle_Twrite(struct _lib9p_srv_req *ctx,
}
/* Variables. */
- struct lib9p_srv_file *file = fidinfo->file;
+ implements_lib9p_srv_file *file = fidinfo->file;
/* Do it. */
resp->count = VCALL(file, pwrite, &ctx->ctx, req->data.dat, req->data.len, req->offset);