summaryrefslogtreecommitdiff
path: root/lib9p/include
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2024-10-17 14:31:03 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2024-10-17 14:31:03 -0600
commitf132dab76a07473d41e14f5f4fb1857a3229ec6a (patch)
tree621a8f1ae6cb15d360cd47c0bccd08a1c2226f4e /lib9p/include
parenta1fb6a6103cc7d38d54270bcdb9779982d329c9e (diff)
libmisc
Diffstat (limited to 'lib9p/include')
-rw-r--r--lib9p/include/lib9p/9p.generated.h2
-rw-r--r--lib9p/include/lib9p/9p.h2
-rw-r--r--lib9p/include/lib9p/srv.h38
3 files changed, 19 insertions, 23 deletions
diff --git a/lib9p/include/lib9p/9p.generated.h b/lib9p/include/lib9p/9p.generated.h
index 584960c..ca7ca07 100644
--- a/lib9p/include/lib9p/9p.generated.h
+++ b/lib9p/include/lib9p/9p.generated.h
@@ -184,8 +184,6 @@ enum lib9p_msg_type { /* uint8_t */
#endif /* defined(CONFIG_9P_ENABLE_9P2000_e) */
};
-const char *lib9p_msg_type_str(enum lib9p_msg_type);
-
#if defined(CONFIG_9P_ENABLE_9P2000) || defined(CONFIG_9P_ENABLE_9P2000_e) || defined(CONFIG_9P_ENABLE_9P2000_u)
struct lib9p_msg_Tversion {
lib9p_tag_t tag;
diff --git a/lib9p/include/lib9p/9p.h b/lib9p/include/lib9p/9p.h
index e7ddb15..a99cd5d 100644
--- a/lib9p/include/lib9p/9p.h
+++ b/lib9p/include/lib9p/9p.h
@@ -56,6 +56,8 @@ static bool lib9p_ctx_has_error(struct lib9p_ctx *ctx) {
return ctx->err_msg[0];
}
+const char *lib9p_msg_type_str(struct lib9p_ctx *, enum lib9p_msg_type);
+
/** Assert that a `struct lib9p_stat` object looks valid. */
static inline void lib9p_assert_stat(struct lib9p_stat stat) {
assert( ((bool)(stat.file_mode & LIB9P_DM_DIR )) == ((bool)(stat.file_qid.type & LIB9P_QT_DIR )) );
diff --git a/lib9p/include/lib9p/srv.h b/lib9p/include/lib9p/srv.h
index 91663e7..797695c 100644
--- a/lib9p/include/lib9p/srv.h
+++ b/lib9p/include/lib9p/srv.h
@@ -10,6 +10,7 @@
#include <libcr/coroutine.h>
#include <libcr_ipc/rpc.h>
#include <libcr_ipc/chan.h>
+#include <libmisc/net.h>
#include <lib9p/9p.h>
@@ -38,50 +39,48 @@ static inline int lib9p_srv_acknowledge_flush(struct lib9p_srv_ctx *ctx) {
return -1;
}
-/* vtables you must implement *************************************************/
+/* interface definitions ******************************************************/
struct lib9p_srv_file;
struct lib9p_srv_file_vtable {
/* all - resource management */
- struct lib9p_srv_file *(*clone )(struct lib9p_srv_ctx *, struct lib9p_srv_file *);
- void (*free )(struct lib9p_srv_ctx *, struct lib9p_srv_file *);
+ struct lib9p_srv_file *(*clone )(struct lib9p_srv_file *, struct lib9p_srv_ctx *);
+ void (*free )(struct lib9p_srv_file *, struct lib9p_srv_ctx *);
/* all - syscalls */
- uint32_t (*io )(struct lib9p_srv_ctx *, struct lib9p_srv_file *,
+ uint32_t (*io )(struct lib9p_srv_file *, struct lib9p_srv_ctx *,
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 (*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_ctx *, struct lib9p_srv_file *);
+ void (*remove )(struct lib9p_srv_file *, struct lib9p_srv_ctx *);
/* directories - base */
- struct lib9p_srv_file *(*dopen )(struct lib9p_srv_ctx *, struct lib9p_srv_file *,
+ struct lib9p_srv_file *(*dopen )(struct lib9p_srv_file *, struct lib9p_srv_ctx *,
char *childname);
- struct lib9p_srv_file *(*dcreate)(struct lib9p_srv_ctx *, struct lib9p_srv_file *,
+ struct lib9p_srv_file *(*dcreate)(struct 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_ctx *, struct lib9p_srv_file *,
+ 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 */
/* non-directories - once opened */
- uint32_t (*pread )(struct lib9p_srv_ctx *, struct lib9p_srv_file *,
+ 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_ctx *, struct lib9p_srv_file *,
+ uint32_t (*pwrite )(struct lib9p_srv_file *, struct lib9p_srv_ctx *,
void *buf,
uint32_t byte_count,
uint64_t byte_offset);
};
-/* objects you'll deal with ***************************************************/
-
-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(). */
@@ -90,11 +89,8 @@ struct lib9p_srv_file {
/* 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 */
- struct lib9p_srv_file *_refcount;
-
- /* This is where your implementation data goes. */
- char data[0];
-};
+ unsigned int _refcount;
+} implements_lib9p_srv_file;
/* main server entrypoints ****************************************************/
@@ -119,7 +115,7 @@ struct lib9p_srv {
* @errno LINUX_ERANGE R-message does not fit into max_msg_size
*/
-__attribute__ ((noreturn)) void lib9p_srv_read_cr(struct lib9p_srv *srv, struct libnet_listener *listener);
+__attribute__ ((noreturn)) void lib9p_srv_read_cr(struct lib9p_srv *srv, implements_net_listener *listener);
COROUTINE lib9p_srv_write_cr(void *_srv);
#endif /* _LIB9P_SRV_H_ */