diff options
Diffstat (limited to 'lib9p/include')
-rw-r--r-- | lib9p/include/lib9p/9p.generated.h | 8 | ||||
-rw-r--r-- | lib9p/include/lib9p/9p.h | 10 | ||||
-rw-r--r-- | lib9p/include/lib9p/srv.h | 12 |
3 files changed, 18 insertions, 12 deletions
diff --git a/lib9p/include/lib9p/9p.generated.h b/lib9p/include/lib9p/9p.generated.h index 5b98ba8..da4a578 100644 --- a/lib9p/include/lib9p/9p.generated.h +++ b/lib9p/include/lib9p/9p.generated.h @@ -153,15 +153,15 @@ typedef uint32_t lib9p_fid_t; #endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */ #if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u struct lib9p_d { - uint32_t len; - char *dat; + uint32_t len; + [[gnu::nonstring]] char *dat; }; #endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */ #if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u struct lib9p_s { - uint16_t len; - char *utf8; + uint16_t len; + [[gnu::nonstring]] char *utf8; }; #endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */ diff --git a/lib9p/include/lib9p/9p.h b/lib9p/include/lib9p/9p.h index 24bae2b..d4764a2 100644 --- a/lib9p/include/lib9p/9p.h +++ b/lib9p/include/lib9p/9p.h @@ -24,6 +24,12 @@ const char *lib9p_version_str(enum lib9p_version); const char *lib9p_msgtype_str(enum lib9p_version, enum lib9p_msg_type); +struct lib9p_s lib9p_str(char *s); +struct lib9p_s lib9p_strn(char *s, size_t maxlen); +struct lib9p_s lib9p_str_slice(struct lib9p_s s, uint16_t beg, uint16_t end); +#define lib9p_str_sliceleft(s, beg) lib9p_str_slice(s, beg, (s).len) +bool lib9p_str_eq(struct lib9p_s a, struct lib9p_s b); + /* ctx ************************************************************************/ struct lib9p_ctx { @@ -35,7 +41,7 @@ struct lib9p_ctx { #ifdef CONFIG_9P_ENABLE_9P2000_u uint32_t err_num; #endif - char err_msg[CONFIG_9P_MAX_ERR_SIZE]; + [[gnu::nonstring]] char err_msg[CONFIG_9P_MAX_ERR_SIZE]; }; void lib9p_ctx_clear_error(struct lib9p_ctx *ctx); @@ -55,7 +61,7 @@ int lib9p_errorf(struct lib9p_ctx *ctx, uint32_t linux_errno, char const *fmt, . * * Return how much space the message will take when unmarshaled. This * number may be larger than net_bytes due to (1) struct padding, (2) - * nul-terminator bytes for strings. + * array pointers. * * Emits an error (return -1, set ctx->err_num and ctx->err_msg) if * either the message type is unknown, or if net_bytes is too short diff --git a/lib9p/include/lib9p/srv.h b/lib9p/include/lib9p/srv.h index eb0e4f4..55cf5db 100644 --- a/lib9p/include/lib9p/srv.h +++ b/lib9p/include/lib9p/srv.h @@ -1,6 +1,6 @@ /* lib9p/srv.h - 9P server * - * Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com> + * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> * SPDX-License-Identifier: AGPL-3.0-or-later */ @@ -22,7 +22,7 @@ CR_CHAN_DECLARE(_lib9p_srv_flushch, bool) struct lib9p_srv_ctx { struct lib9p_ctx basectx; uint32_t uid; - char *uname; + struct lib9p_s uname; BEGIN_PRIVATE(LIB9P_SRV_H) _lib9p_srv_flushch_t _flushch; @@ -67,9 +67,9 @@ struct lib9p_srv_file_vtable { /* directories - base */ implements_lib9p_srv_file *(*dopen )(implements_lib9p_srv_file *, struct lib9p_srv_ctx *, - char *childname); + struct lib9p_s childname); implements_lib9p_srv_file *(*dcreate)(implements_lib9p_srv_file *, struct lib9p_srv_ctx *, - char *childname, + struct lib9p_s childname, lib9p_dm_t perm, lib9p_o_t flags); /* directories - once opened */ @@ -95,8 +95,8 @@ 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 */ - implements_lib9p_srv_file *(*rootdir)(struct lib9p_srv_ctx *, char *treename); + void /*TODO*/ (*auth )(struct lib9p_srv_ctx *, struct lib9p_s treename); /* optional */ + implements_lib9p_srv_file *(*rootdir)(struct lib9p_srv_ctx *, struct lib9p_s treename); /* For internal use */ BEGIN_PRIVATE(LIB9P_SRV_H) |