diff options
Diffstat (limited to 'lib9p/include')
-rw-r--r-- | lib9p/include/lib9p/9p.generated.h | 4 | ||||
-rw-r--r-- | lib9p/include/lib9p/9p.h | 1 | ||||
-rw-r--r-- | lib9p/include/lib9p/srv.h | 72 |
3 files changed, 72 insertions, 5 deletions
diff --git a/lib9p/include/lib9p/9p.generated.h b/lib9p/include/lib9p/9p.generated.h index f093aa1..135cf8a 100644 --- a/lib9p/include/lib9p/9p.generated.h +++ b/lib9p/include/lib9p/9p.generated.h @@ -81,12 +81,12 @@ typedef uint8_t lib9p_o_t; struct lib9p_d { uint32_t len; - uint8_t *dat; + char *dat; }; struct lib9p_s { uint16_t len; - uint8_t *utf8; + char *utf8; }; struct lib9p_qid { diff --git a/lib9p/include/lib9p/9p.h b/lib9p/include/lib9p/9p.h index 8e57a86..b96c938 100644 --- a/lib9p/include/lib9p/9p.h +++ b/lib9p/include/lib9p/9p.h @@ -19,6 +19,7 @@ struct lib9p_ctx; enum lib9p_version lib9p_ctx_version(struct lib9p_ctx *); uint32_t lib9p_ctx_max_msg_size(struct lib9p_ctx *); +bool lib9p_ctx_has_error(struct lib9p_ctx *); /** Write an static error into ctx, return -1. */ int lib9p_error(struct lib9p_ctx *ctx, uint32_t linux_errno, char const *msg); diff --git a/lib9p/include/lib9p/srv.h b/lib9p/include/lib9p/srv.h index 9220bd9..11894ea 100644 --- a/lib9p/include/lib9p/srv.h +++ b/lib9p/include/lib9p/srv.h @@ -4,11 +4,77 @@ #include <libcr/coroutine.h> #include <libcr_ipc/chan.h> -struct lib9p_req; +#include <lib9p/9p.h> + +/* vtables you must implement *************************************************/ + +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_reqcggtx *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); + + /* 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_io_dir_vtable { + size_t (*readdir )(struct lib9p_srv_reqctx *ctx, void *impldata, + 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); +}; + +/* objects you'll deal with ***************************************************/ + +struct lib9p_srv_reqctx { + struct lib9p_ctx ctx; + uint32_t uid; + char *uname; +}; + +struct lib9p_srv_file { + struct lib9p_srv_file_vtable vtable; + + struct lib9p_srv_file *parent_dir; + void *impldata; +}; + +struct lib9p_srv_io { + union { + struct lib9p_srv_io_dir_vtable dir; + struct lib9p_srv_io_file_vtable file; + } vtable; + + struct lib9p_srv_file *file; + struct lib9p_qid qid; + uint32_t iounit; + + void *impldata; +}; + +/******************************************************************************/ struct lib9p_srv { - int sockfd; - cr_chan_t(struct lib9p_req *) reqch; + /* 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); + + /* For internal use */ + cr_chan_t(struct lib9p_req *) reqch; }; /** |