summaryrefslogtreecommitdiff
path: root/lib9p/include
diff options
context:
space:
mode:
Diffstat (limited to 'lib9p/include')
-rw-r--r--lib9p/include/lib9p/srv.h81
1 files changed, 41 insertions, 40 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;