diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-10-05 21:14:39 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-10-05 21:14:39 -0600 |
commit | cb108cfecb78c01ae8a2957ca5a32b58f9ddc4aa (patch) | |
tree | 686450953fb9e6c5c7e6e7b0a4d3385bb798ff2d /lib9p/include | |
parent | 41dd5694f46247805c161a4120c8c0364f2ee9c0 (diff) |
lib9p: srv: clean up
Diffstat (limited to 'lib9p/include')
-rw-r--r-- | lib9p/include/lib9p/srv.h | 64 |
1 files changed, 36 insertions, 28 deletions
diff --git a/lib9p/include/lib9p/srv.h b/lib9p/include/lib9p/srv.h index 55bcba0..c56ee3f 100644 --- a/lib9p/include/lib9p/srv.h +++ b/lib9p/include/lib9p/srv.h @@ -7,26 +7,27 @@ #include <lib9p/9p.h> -CR_RPC_DECLARE(_lib9p_srv_reqch, struct lib9p_req *, bool) +/* context ********************************************************************/ + CR_CHAN_DECLARE(_lib9p_srv_flushch, bool) -struct lib9p_srv_reqctx { - struct lib9p_ctx *base; +struct lib9p_srv_ctx { + struct lib9p_ctx basectx; uint32_t uid; char *uname; _lib9p_srv_flushch_t _flushch; }; -static inline bool lib9p_srv_flush_requested(struct lib9p_srv_reqctx *ctx) { +static inline bool lib9p_srv_flush_requested(struct lib9p_srv_ctx *ctx) { assert(ctx); return _lib9p_srv_flushch_can_send(&ctx->_flushch); } -static inline int lib9p_srv_acknowledge_flush(struct lib9p_srv_reqctx *ctx) { +static inline int lib9p_srv_acknowledge_flush(struct lib9p_srv_ctx *ctx) { assert(ctx); assert(_lib9p_srv_flushch_can_send(&ctx->_flushch)); - lib9p_error(ctx->base, LINUX_ECANCELED, "request canceled by flush"); + lib9p_error(&ctx->basectx, LINUX_ECANCELED, "request canceled by flush"); _lib9p_srv_flushch_send(&ctx->_flushch, true); return -1; } @@ -35,31 +36,35 @@ static inline int lib9p_srv_acknowledge_flush(struct lib9p_srv_reqctx *ctx) { struct lib9p_srv_file_vtable { /* all */ - struct lib9p_srv_io (*io )(struct lib9p_srv_reqctx *ctx, void *impldata, - lib9p_o_t flags); - struct lib9p_stat (*stat )(struct lib9p_srv_reqctx *ctx, void *impldata); - void (*wstat )(struct lib9p_srv_reqctx *ctx, void *impldata, - struct lib9p_stat new); - void (*remove )(struct lib9p_srv_reqctx *ctx, void *impldata); - void (*free )(struct lib9p_srv_reqctx *ctx, void *impldata); + struct lib9p_srv_io (*io )(struct lib9p_srv_ctx *ctx, void *impl, + lib9p_o_t flags); + struct lib9p_stat (*stat )(struct lib9p_srv_ctx *ctx, void *impl); + void (*wstat )(struct lib9p_srv_ctx *ctx, void *impl, + struct lib9p_stat new); + void (*remove )(struct lib9p_srv_ctx *ctx, void *impl); + void (*free )(struct lib9p_srv_ctx *ctx, void *impl); /* dir */ - struct lib9p_srv_file (*openchild )(struct lib9p_srv_reqctx *ctx, void *impldata, - char *childname); - struct lib9p_srv_file (*createchild)(struct lib9p_srv_reqctx *ctx, void *impldata, - char *childname, lib9p_dm_t perm, lib9p_o_t flags); + struct lib9p_srv_file (*dopen )(struct lib9p_srv_ctx *ctx, void *impl, + char *childname); + struct lib9p_srv_file (*dcreate)(struct lib9p_srv_ctx *ctx, void *impl, + char *childname, + lib9p_dm_t perm, lib9p_o_t flags); }; struct lib9p_srv_io_dir_vtable { - size_t (*readdir )(struct lib9p_srv_reqctx *ctx, void *impldata, - struct lib9p_stat *buf, size_t count, size_t offset); + size_t (*readdir)(struct lib9p_srv_ctx *ctx, void *impl, + struct lib9p_stat *buf, size_t count, + size_t offset); }; struct lib9p_srv_io_file_vtable { - uint32_t (*pread )(struct lib9p_srv_reqctx *ctx, void *impldata, - void *buf, uint32_t count, uint64_t offset); - uint32_t (*pwrite )(struct lib9p_srv_reqctx *ctx, void *impldata, - void *buf, uint32_t count, uint64_t offset); + uint32_t (*pread )(struct lib9p_srv_ctx *ctx, void *impl, + void *buf, uint32_t count, + uint64_t offset); + uint32_t (*pwrite )(struct lib9p_srv_ctx *ctx, void *impl, + void *buf, uint32_t count, + uint64_t offset); }; /* objects you'll deal with ***************************************************/ @@ -84,20 +89,23 @@ struct lib9p_srv_io { void *impldata; }; -/******************************************************************************/ +/* main server entrypoints ****************************************************/ + +CR_RPC_DECLARE(_lib9p_srv_reqch, struct _lib9p_srv_req *, bool) struct lib9p_srv { /* Things you provide */ - int sockfd; - void /*TODO*/ (*auth)(struct lib9p_srv_reqctx *ctx, char *treename); - struct lib9p_srv_file (*rootdir)(struct lib9p_srv_reqctx *ctx, char *treename); + int sockfd; + void /*TODO*/ (*auth )(struct lib9p_srv_ctx *ctx, char *treename); + struct lib9p_srv_file (*rootdir)(struct lib9p_srv_ctx *ctx, char *treename); /* For internal use */ - _lib9p_srv_reqch_t _reqch; + _lib9p_srv_reqch_t _reqch; }; /** * Will just close the connection if a T-message has a size[4] <7. + * * @errno LINUX_EMSGSIZE T-message has size[4] bigger than max_msg_size * @errno LINUX_EDOM Tversion specified an impossibly small max_msg_size * @errno LINUX_EOPNOTSUPP T-message has an R-message type, or an unrecognized T-message type |