summaryrefslogtreecommitdiff
path: root/lib9p/include
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2024-10-07 18:04:03 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2024-10-07 18:04:03 -0600
commit9c7f19c46d8fb58b6bcfe0d1d026c05657ffba96 (patch)
tree70c52d35473757bc2c72ecc5295ff90c9c05067d /lib9p/include
parent62e8081e0ac4a4c170bc536303f7a9bd3e91fd7b (diff)
wip
Diffstat (limited to 'lib9p/include')
-rw-r--r--lib9p/include/lib9p/srv.h62
1 files changed, 35 insertions, 27 deletions
diff --git a/lib9p/include/lib9p/srv.h b/lib9p/include/lib9p/srv.h
index c56ee3f..11c1fac 100644
--- a/lib9p/include/lib9p/srv.h
+++ b/lib9p/include/lib9p/srv.h
@@ -34,59 +34,67 @@ static inline int lib9p_srv_acknowledge_flush(struct lib9p_srv_ctx *ctx) {
/* vtables you must implement *************************************************/
+struct lib9p_srv_file;
+struct lib9p_srv_io;
+
struct lib9p_srv_file_vtable {
/* all */
- 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);
+ struct lib9p_srv_io *(*io )(struct lib9p_srv_ctx *, struct lib9p_srv_file *,
+ lib9p_o_t flags);
+ struct lib9p_stat (*stat )(struct lib9p_srv_ctx *, struct lib9p_srv_file *);
+ void (*wstat )(struct lib9p_srv_ctx *, struct lib9p_srv_file *,
+ struct lib9p_stat new);
+ void (*remove )(struct lib9p_srv_ctx *, struct lib9p_srv_file *);
+ void (*free )(struct lib9p_srv_ctx *, struct lib9p_srv_file *); /* optional */
/* dir */
- struct lib9p_srv_file (*dopen )(struct lib9p_srv_ctx *ctx, void *impl,
+ struct lib9p_srv_file *(*dopen )(struct lib9p_srv_ctx *, struct lib9p_srv_file *,
char *childname);
- struct lib9p_srv_file (*dcreate)(struct lib9p_srv_ctx *ctx, void *impl,
+ struct lib9p_srv_file *(*dcreate)(struct lib9p_srv_ctx *, struct lib9p_srv_file *,
char *childname,
lib9p_dm_t perm, lib9p_o_t flags);
};
struct lib9p_srv_io_dir_vtable {
- size_t (*readdir)(struct lib9p_srv_ctx *ctx, void *impl,
- struct lib9p_stat *buf, size_t count,
- size_t offset);
+ size_t (*readdir)(struct lib9p_srv_ctx *, struct lib9p_srv_io_dir *,
+ struct lib9p_stat *buf, size_t count,
+ size_t offset);
};
struct lib9p_srv_io_file_vtable {
- 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);
+ uint32_t (*pread )(struct lib9p_srv_ctx *, struct lib9p_srv_io_file *,
+ void *buf, uint32_t count,
+ uint64_t offset);
+ uint32_t (*pwrite )(struct lib9p_srv_ctx *, struct lib9p_srv_io_file *,
+ void *buf, uint32_t count,
+ uint64_t offset);
};
/* objects you'll deal with ***************************************************/
struct lib9p_srv_file {
- struct lib9p_srv_file_vtable vtable;
+ struct lib9p_srv_file_vtable *vtable;
+
+ /* Managed by srv.c */
+ struct lib9p_srv_file *_parent_dir;
+ struct lib9p_srv_file *_refcount;
- struct lib9p_srv_file *parent_dir;
- void *impldata;
+ /* This is where your implementation data goes. */
+ char data[0];
};
struct lib9p_srv_io {
union {
- struct lib9p_srv_io_dir_vtable dir;
- struct lib9p_srv_io_file_vtable file;
+ 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;
+ /* This is where your implementation data goes. */
+ char data[0];
};
/* main server entrypoints ****************************************************/
@@ -95,9 +103,9 @@ 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_ctx *ctx, char *treename);
- struct lib9p_srv_file (*rootdir)(struct lib9p_srv_ctx *ctx, char *treename);
+ int sockfd;
+ void /*TODO*/ (*auth )(struct lib9p_srv_ctx *, char *treename); /* optional */
+ struct lib9p_srv_file *(*rootdir)(struct lib9p_srv_ctx *, char *treename);
/* For internal use */
_lib9p_srv_reqch_t _reqch;