diff options
Diffstat (limited to 'lib9p/9p.generated.c')
-rw-r--r-- | lib9p/9p.generated.c | 5238 |
1 files changed, 0 insertions, 5238 deletions
diff --git a/lib9p/9p.generated.c b/lib9p/9p.generated.c deleted file mode 100644 index 6726084..0000000 --- a/lib9p/9p.generated.c +++ /dev/null @@ -1,5238 +0,0 @@ -/* Generated by `lib9p/proto.gen lib9p/idl/2002-9P2000.9p lib9p/idl/2003-9P2000.p9p.9p lib9p/idl/2005-9P2000.u.9p lib9p/idl/2010-9P2000.L.9p lib9p/idl/2012-9P2000.e.9p`. DO NOT EDIT! */ - -#include <stdbool.h> -#include <stddef.h> /* for size_t */ -#include <inttypes.h> /* for PRI* macros */ -#include <string.h> /* for memset() */ - -#include <libmisc/assert.h> - -#include <lib9p/9p.h> - -#include "internal.h" - -/* utilities ******************************************************************/ -#if CONFIG_9P_ENABLE_9P2000 - #define _is_ver_9P2000(v) (v == LIB9P_VER_9P2000) -#else - #define _is_ver_9P2000(v) false -#endif -#if CONFIG_9P_ENABLE_9P2000_L - #define _is_ver_9P2000_L(v) (v == LIB9P_VER_9P2000_L) -#else - #define _is_ver_9P2000_L(v) false -#endif -#if CONFIG_9P_ENABLE_9P2000_e - #define _is_ver_9P2000_e(v) (v == LIB9P_VER_9P2000_e) -#else - #define _is_ver_9P2000_e(v) false -#endif -#if CONFIG_9P_ENABLE_9P2000_p9p - #define _is_ver_9P2000_p9p(v) (v == LIB9P_VER_9P2000_p9p) -#else - #define _is_ver_9P2000_p9p(v) false -#endif -#if CONFIG_9P_ENABLE_9P2000_u - #define _is_ver_9P2000_u(v) (v == LIB9P_VER_9P2000_u) -#else - #define _is_ver_9P2000_u(v) false -#endif - -/** - * is_ver(ctx, ver) is essentially `(ctx->version == LIB9P_VER_##ver)`, but - * compiles correctly (to `false`) even if `LIB9P_VER_##ver` isn't defined - * (because `!CONFIG_9P_ENABLE_##ver`). This is useful when `||`ing - * several version checks together. - */ -#define is_ver(ctx, ver) _is_ver_##ver((ctx)->version) - -/* strings ********************************************************************/ - -const char *const _lib9p_table_ver_name[LIB9P_VER_NUM] = { - [LIB9P_VER_unknown] = "unknown", -#if CONFIG_9P_ENABLE_9P2000 - [LIB9P_VER_9P2000] = "9P2000", -#endif /* CONFIG_9P_ENABLE_9P2000 */ -#if CONFIG_9P_ENABLE_9P2000_L - [LIB9P_VER_9P2000_L] = "9P2000.L", -#endif /* CONFIG_9P_ENABLE_9P2000_L */ -#if CONFIG_9P_ENABLE_9P2000_e - [LIB9P_VER_9P2000_e] = "9P2000.e", -#endif /* CONFIG_9P_ENABLE_9P2000_e */ -#if CONFIG_9P_ENABLE_9P2000_p9p - [LIB9P_VER_9P2000_p9p] = "9P2000.p9p", -#endif /* CONFIG_9P_ENABLE_9P2000_p9p */ -#if CONFIG_9P_ENABLE_9P2000_u - [LIB9P_VER_9P2000_u] = "9P2000.u", -#endif /* CONFIG_9P_ENABLE_9P2000_u */ -}; - -#define _MSG_NAME(typ) [LIB9P_TYP_##typ] = #typ -const char *const _lib9p_table_msg_name[LIB9P_VER_NUM][0x100] = { - [LIB9P_VER_unknown] = { - _MSG_NAME(Tversion), - _MSG_NAME(Rversion), - _MSG_NAME(Rerror), - }, -#if CONFIG_9P_ENABLE_9P2000 - [LIB9P_VER_9P2000] = { - _MSG_NAME(Tversion), - _MSG_NAME(Rversion), - _MSG_NAME(Tauth), - _MSG_NAME(Rauth), - _MSG_NAME(Tattach), - _MSG_NAME(Rattach), - _MSG_NAME(Rerror), - _MSG_NAME(Tflush), - _MSG_NAME(Rflush), - _MSG_NAME(Twalk), - _MSG_NAME(Rwalk), - _MSG_NAME(Topen), - _MSG_NAME(Ropen), - _MSG_NAME(Tcreate), - _MSG_NAME(Rcreate), - _MSG_NAME(Tread), - _MSG_NAME(Rread), - _MSG_NAME(Twrite), - _MSG_NAME(Rwrite), - _MSG_NAME(Tclunk), - _MSG_NAME(Rclunk), - _MSG_NAME(Tremove), - _MSG_NAME(Rremove), - _MSG_NAME(Tstat), - _MSG_NAME(Rstat), - _MSG_NAME(Twstat), - _MSG_NAME(Rwstat), - }, -#endif /* CONFIG_9P_ENABLE_9P2000 */ -#if CONFIG_9P_ENABLE_9P2000_L - [LIB9P_VER_9P2000_L] = { - _MSG_NAME(Rlerror), - _MSG_NAME(Tstatfs), - _MSG_NAME(Rstatfs), - _MSG_NAME(Tlopen), - _MSG_NAME(Rlopen), - _MSG_NAME(Tlcreate), - _MSG_NAME(Rlcreate), - _MSG_NAME(Tsymlink), - _MSG_NAME(Rsymlink), - _MSG_NAME(Tmknod), - _MSG_NAME(Rmknod), - _MSG_NAME(Trename), - _MSG_NAME(Rrename), - _MSG_NAME(Treadlink), - _MSG_NAME(Rreadlink), - _MSG_NAME(Tgetattr), - _MSG_NAME(Rgetattr), - _MSG_NAME(Tsetattr), - _MSG_NAME(Rsetattr), - _MSG_NAME(Txattrwalk), - _MSG_NAME(Rxattrwalk), - _MSG_NAME(Txattrcreate), - _MSG_NAME(Rxattrcreate), - _MSG_NAME(Treaddir), - _MSG_NAME(Rreaddir), - _MSG_NAME(Tfsync), - _MSG_NAME(Rfsync), - _MSG_NAME(Tlock), - _MSG_NAME(Rlock), - _MSG_NAME(Tgetlock), - _MSG_NAME(Rgetlock), - _MSG_NAME(Tlink), - _MSG_NAME(Rlink), - _MSG_NAME(Tmkdir), - _MSG_NAME(Rmkdir), - _MSG_NAME(Trenameat), - _MSG_NAME(Rrenameat), - _MSG_NAME(Tunlinkat), - _MSG_NAME(Runlinkat), - _MSG_NAME(Tversion), - _MSG_NAME(Rversion), - _MSG_NAME(Tauth), - _MSG_NAME(Rauth), - _MSG_NAME(Tattach), - _MSG_NAME(Rattach), - _MSG_NAME(Rerror), - _MSG_NAME(Tflush), - _MSG_NAME(Rflush), - _MSG_NAME(Twalk), - _MSG_NAME(Rwalk), - _MSG_NAME(Tread), - _MSG_NAME(Rread), - _MSG_NAME(Twrite), - _MSG_NAME(Rwrite), - _MSG_NAME(Tclunk), - _MSG_NAME(Rclunk), - _MSG_NAME(Tremove), - _MSG_NAME(Rremove), - }, -#endif /* CONFIG_9P_ENABLE_9P2000_L */ -#if CONFIG_9P_ENABLE_9P2000_e - [LIB9P_VER_9P2000_e] = { - _MSG_NAME(Tversion), - _MSG_NAME(Rversion), - _MSG_NAME(Tauth), - _MSG_NAME(Rauth), - _MSG_NAME(Tattach), - _MSG_NAME(Rattach), - _MSG_NAME(Rerror), - _MSG_NAME(Tflush), - _MSG_NAME(Rflush), - _MSG_NAME(Twalk), - _MSG_NAME(Rwalk), - _MSG_NAME(Topen), - _MSG_NAME(Ropen), - _MSG_NAME(Tcreate), - _MSG_NAME(Rcreate), - _MSG_NAME(Tread), - _MSG_NAME(Rread), - _MSG_NAME(Twrite), - _MSG_NAME(Rwrite), - _MSG_NAME(Tclunk), - _MSG_NAME(Rclunk), - _MSG_NAME(Tremove), - _MSG_NAME(Rremove), - _MSG_NAME(Tstat), - _MSG_NAME(Rstat), - _MSG_NAME(Twstat), - _MSG_NAME(Rwstat), - _MSG_NAME(Tsession), - _MSG_NAME(Rsession), - _MSG_NAME(Tsread), - _MSG_NAME(Rsread), - _MSG_NAME(Tswrite), - _MSG_NAME(Rswrite), - }, -#endif /* CONFIG_9P_ENABLE_9P2000_e */ -#if CONFIG_9P_ENABLE_9P2000_p9p - [LIB9P_VER_9P2000_p9p] = { - _MSG_NAME(Topenfd), - _MSG_NAME(Ropenfd), - _MSG_NAME(Tversion), - _MSG_NAME(Rversion), - _MSG_NAME(Tauth), - _MSG_NAME(Rauth), - _MSG_NAME(Tattach), - _MSG_NAME(Rattach), - _MSG_NAME(Rerror), - _MSG_NAME(Tflush), - _MSG_NAME(Rflush), - _MSG_NAME(Twalk), - _MSG_NAME(Rwalk), - _MSG_NAME(Topen), - _MSG_NAME(Ropen), - _MSG_NAME(Tcreate), - _MSG_NAME(Rcreate), - _MSG_NAME(Tread), - _MSG_NAME(Rread), - _MSG_NAME(Twrite), - _MSG_NAME(Rwrite), - _MSG_NAME(Tclunk), - _MSG_NAME(Rclunk), - _MSG_NAME(Tremove), - _MSG_NAME(Rremove), - _MSG_NAME(Tstat), - _MSG_NAME(Rstat), - _MSG_NAME(Twstat), - _MSG_NAME(Rwstat), - }, -#endif /* CONFIG_9P_ENABLE_9P2000_p9p */ -#if CONFIG_9P_ENABLE_9P2000_u - [LIB9P_VER_9P2000_u] = { - _MSG_NAME(Tversion), - _MSG_NAME(Rversion), - _MSG_NAME(Tauth), - _MSG_NAME(Rauth), - _MSG_NAME(Tattach), - _MSG_NAME(Rattach), - _MSG_NAME(Rerror), - _MSG_NAME(Tflush), - _MSG_NAME(Rflush), - _MSG_NAME(Twalk), - _MSG_NAME(Rwalk), - _MSG_NAME(Topen), - _MSG_NAME(Ropen), - _MSG_NAME(Tcreate), - _MSG_NAME(Rcreate), - _MSG_NAME(Tread), - _MSG_NAME(Rread), - _MSG_NAME(Twrite), - _MSG_NAME(Rwrite), - _MSG_NAME(Tclunk), - _MSG_NAME(Rclunk), - _MSG_NAME(Tremove), - _MSG_NAME(Rremove), - _MSG_NAME(Tstat), - _MSG_NAME(Rstat), - _MSG_NAME(Twstat), - _MSG_NAME(Rwstat), - }, -#endif /* CONFIG_9P_ENABLE_9P2000_u */ -}; - -/* bitmasks *******************************************************************/ - -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -static const lib9p_dm_t dm_masks[LIB9P_VER_NUM] = { -#if CONFIG_9P_ENABLE_9P2000 - [LIB9P_VER_9P2000] = 0b11101100000000000000000111111111, -#endif /* CONFIG_9P_ENABLE_9P2000 */ -#if CONFIG_9P_ENABLE_9P2000_L - [LIB9P_VER_9P2000_L] = 0b00000000000000000000000000000000, -#endif /* CONFIG_9P_ENABLE_9P2000_L */ -#if CONFIG_9P_ENABLE_9P2000_e - [LIB9P_VER_9P2000_e] = 0b11101100000000000000000111111111, -#endif /* CONFIG_9P_ENABLE_9P2000_e */ -#if CONFIG_9P_ENABLE_9P2000_p9p - [LIB9P_VER_9P2000_p9p] = 0b11101100000000000000000111111111, -#endif /* CONFIG_9P_ENABLE_9P2000_p9p */ -#if CONFIG_9P_ENABLE_9P2000_u - [LIB9P_VER_9P2000_u] = 0b11101100101111000000000111111111, -#endif /* CONFIG_9P_ENABLE_9P2000_u */ -}; - -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -static const lib9p_qt_t qt_masks[LIB9P_VER_NUM] = { -#if CONFIG_9P_ENABLE_9P2000 - [LIB9P_VER_9P2000] = 0b11101100, -#endif /* CONFIG_9P_ENABLE_9P2000 */ -#if CONFIG_9P_ENABLE_9P2000_L - [LIB9P_VER_9P2000_L] = 0b11101100, -#endif /* CONFIG_9P_ENABLE_9P2000_L */ -#if CONFIG_9P_ENABLE_9P2000_e - [LIB9P_VER_9P2000_e] = 0b11101100, -#endif /* CONFIG_9P_ENABLE_9P2000_e */ -#if CONFIG_9P_ENABLE_9P2000_p9p - [LIB9P_VER_9P2000_p9p] = 0b11101100, -#endif /* CONFIG_9P_ENABLE_9P2000_p9p */ -#if CONFIG_9P_ENABLE_9P2000_u - [LIB9P_VER_9P2000_u] = 0b11101110, -#endif /* CONFIG_9P_ENABLE_9P2000_u */ -}; - -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -static const lib9p_o_t o_masks[LIB9P_VER_NUM] = { -#if CONFIG_9P_ENABLE_9P2000 - [LIB9P_VER_9P2000] = 0b01010011, -#endif /* CONFIG_9P_ENABLE_9P2000 */ -#if CONFIG_9P_ENABLE_9P2000_L - [LIB9P_VER_9P2000_L] = 0b00000000, -#endif /* CONFIG_9P_ENABLE_9P2000_L */ -#if CONFIG_9P_ENABLE_9P2000_e - [LIB9P_VER_9P2000_e] = 0b01010011, -#endif /* CONFIG_9P_ENABLE_9P2000_e */ -#if CONFIG_9P_ENABLE_9P2000_p9p - [LIB9P_VER_9P2000_p9p] = 0b01010011, -#endif /* CONFIG_9P_ENABLE_9P2000_p9p */ -#if CONFIG_9P_ENABLE_9P2000_u - [LIB9P_VER_9P2000_u] = 0b01010011, -#endif /* CONFIG_9P_ENABLE_9P2000_u */ -}; - -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000_L -static const lib9p_lo_t lo_masks[LIB9P_VER_NUM] = { -#if CONFIG_9P_ENABLE_9P2000 - [LIB9P_VER_9P2000] = 0b00000000000000000000000000000000, -#endif /* CONFIG_9P_ENABLE_9P2000 */ - [LIB9P_VER_9P2000_L] = 0b00000000000111111111111111000011, -#if CONFIG_9P_ENABLE_9P2000_e - [LIB9P_VER_9P2000_e] = 0b00000000000000000000000000000000, -#endif /* CONFIG_9P_ENABLE_9P2000_e */ -#if CONFIG_9P_ENABLE_9P2000_p9p - [LIB9P_VER_9P2000_p9p] = 0b00000000000000000000000000000000, -#endif /* CONFIG_9P_ENABLE_9P2000_p9p */ -#if CONFIG_9P_ENABLE_9P2000_u - [LIB9P_VER_9P2000_u] = 0b00000000000000000000000000000000, -#endif /* CONFIG_9P_ENABLE_9P2000_u */ -}; - -static const lib9p_mode_t mode_masks[LIB9P_VER_NUM] = { -#if CONFIG_9P_ENABLE_9P2000 - [LIB9P_VER_9P2000] = 0b00000000000000000000000000000000, -#endif /* CONFIG_9P_ENABLE_9P2000 */ - [LIB9P_VER_9P2000_L] = 0b00000000000000001111111111111111, -#if CONFIG_9P_ENABLE_9P2000_e - [LIB9P_VER_9P2000_e] = 0b00000000000000000000000000000000, -#endif /* CONFIG_9P_ENABLE_9P2000_e */ -#if CONFIG_9P_ENABLE_9P2000_p9p - [LIB9P_VER_9P2000_p9p] = 0b00000000000000000000000000000000, -#endif /* CONFIG_9P_ENABLE_9P2000_p9p */ -#if CONFIG_9P_ENABLE_9P2000_u - [LIB9P_VER_9P2000_u] = 0b00000000000000000000000000000000, -#endif /* CONFIG_9P_ENABLE_9P2000_u */ -}; - -static const lib9p_getattr_t getattr_masks[LIB9P_VER_NUM] = { -#if CONFIG_9P_ENABLE_9P2000 - [LIB9P_VER_9P2000] = 0b0000000000000000000000000000000000000000000000000000000000000000, -#endif /* CONFIG_9P_ENABLE_9P2000 */ - [LIB9P_VER_9P2000_L] = 0b0000000000000000000000000000000000000000000000000011111111111111, -#if CONFIG_9P_ENABLE_9P2000_e - [LIB9P_VER_9P2000_e] = 0b0000000000000000000000000000000000000000000000000000000000000000, -#endif /* CONFIG_9P_ENABLE_9P2000_e */ -#if CONFIG_9P_ENABLE_9P2000_p9p - [LIB9P_VER_9P2000_p9p] = 0b0000000000000000000000000000000000000000000000000000000000000000, -#endif /* CONFIG_9P_ENABLE_9P2000_p9p */ -#if CONFIG_9P_ENABLE_9P2000_u - [LIB9P_VER_9P2000_u] = 0b0000000000000000000000000000000000000000000000000000000000000000, -#endif /* CONFIG_9P_ENABLE_9P2000_u */ -}; - -static const lib9p_setattr_t setattr_masks[LIB9P_VER_NUM] = { -#if CONFIG_9P_ENABLE_9P2000 - [LIB9P_VER_9P2000] = 0b00000000000000000000000000000000, -#endif /* CONFIG_9P_ENABLE_9P2000 */ - [LIB9P_VER_9P2000_L] = 0b00000000000000000000000111111111, -#if CONFIG_9P_ENABLE_9P2000_e - [LIB9P_VER_9P2000_e] = 0b00000000000000000000000000000000, -#endif /* CONFIG_9P_ENABLE_9P2000_e */ -#if CONFIG_9P_ENABLE_9P2000_p9p - [LIB9P_VER_9P2000_p9p] = 0b00000000000000000000000000000000, -#endif /* CONFIG_9P_ENABLE_9P2000_p9p */ -#if CONFIG_9P_ENABLE_9P2000_u - [LIB9P_VER_9P2000_u] = 0b00000000000000000000000000000000, -#endif /* CONFIG_9P_ENABLE_9P2000_u */ -}; - -static const lib9p_lock_flags_t lock_flags_masks[LIB9P_VER_NUM] = { -#if CONFIG_9P_ENABLE_9P2000 - [LIB9P_VER_9P2000] = 0b00000000000000000000000000000000, -#endif /* CONFIG_9P_ENABLE_9P2000 */ - [LIB9P_VER_9P2000_L] = 0b00000000000000000000000000000011, -#if CONFIG_9P_ENABLE_9P2000_e - [LIB9P_VER_9P2000_e] = 0b00000000000000000000000000000000, -#endif /* CONFIG_9P_ENABLE_9P2000_e */ -#if CONFIG_9P_ENABLE_9P2000_p9p - [LIB9P_VER_9P2000_p9p] = 0b00000000000000000000000000000000, -#endif /* CONFIG_9P_ENABLE_9P2000_p9p */ -#if CONFIG_9P_ENABLE_9P2000_u - [LIB9P_VER_9P2000_u] = 0b00000000000000000000000000000000, -#endif /* CONFIG_9P_ENABLE_9P2000_u */ -}; -#endif /* CONFIG_9P_ENABLE_9P2000_L */ - -/* validate_* *****************************************************************/ - -#define VALIDATE_NET_BYTES(n) \ - if (__builtin_add_overflow(net_offset, n, &net_offset)) \ - /* If needed-net-size overflowed uint32_t, then \ - * there's no way that actual-net-size will live up to \ - * that. */ \ - return lib9p_error(ctx, LINUX_EBADMSG, "message is too short for content"); \ - if (net_offset > net_size) \ - return lib9p_errorf(ctx, LINUX_EBADMSG, "message is too short for content (%"PRIu32" > %"PRIu32") @ %d", net_offset, net_size, __LINE__); -#define VALIDATE_NET_UTF8(n) \ - { \ - size_t len = n; \ - VALIDATE_NET_BYTES(len); \ - if (!is_valid_utf8_without_nul(&net_bytes[net_offset-len], len)) \ - return lib9p_error(ctx, LINUX_EBADMSG, "message contains invalid UTF-8"); \ - } -#define RESERVE_HOST_BYTES(n) \ - if (__builtin_add_overflow(host_size, n, &host_size)) \ - /* If needed-host-size overflowed ssize_t, then there's \ - * no way that actual-net-size will live up to \ - * that. */ \ - return lib9p_error(ctx, LINUX_EBADMSG, "message is too short for content"); -#define GET_U8LE(off) (net_bytes[off]) -#define GET_U16LE(off) uint16le_decode(&net_bytes[off]) -#define GET_U32LE(off) uint32le_decode(&net_bytes[off]) -#define GET_U64LE(off) uint64le_decode(&net_bytes[off]) -#define LAST_U8LE() GET_U8LE(net_offset-1) -#define LAST_U16LE() GET_U16LE(net_offset-2) -#define LAST_U32LE() GET_U32LE(net_offset-4) -#define LAST_U64LE() GET_U64LE(net_offset-8) - -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -static ssize_t validate_stat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes, uint32_t *ret_net_size) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_stat); - uint32_t offsetof_stat_size = net_offset + 0; - uint32_t offsetof_kern_type = net_offset + 2; - uint32_t offsetof_file_qid_type = net_offset + 8; - VALIDATE_NET_BYTES(21); - if (GET_U8LE(offsetof_file_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, - GET_U8LE(offsetof_file_qid_type) & ~qt_masks[ctx->version]); - uint32_t offsetof_file_mode = net_offset + 0; - VALIDATE_NET_BYTES(22); - VALIDATE_NET_UTF8(LAST_U16LE()); - VALIDATE_NET_BYTES(2); - VALIDATE_NET_UTF8(LAST_U16LE()); - VALIDATE_NET_BYTES(2); - VALIDATE_NET_UTF8(LAST_U16LE()); - VALIDATE_NET_BYTES(2); - VALIDATE_NET_UTF8(LAST_U16LE()); -#if CONFIG_9P_ENABLE_9P2000_u - if (is_ver(ctx, 9P2000_u)) { - VALIDATE_NET_BYTES(2); - VALIDATE_NET_UTF8(LAST_U16LE()); - VALIDATE_NET_BYTES(12); - } -#endif /* CONFIG_9P_ENABLE_9P2000_u */ - uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_stat_size) != (uint32_t)(offsetof_end - offsetof_kern_type)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "stat->stat_size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_stat_size), (uint32_t)(offsetof_end - offsetof_kern_type)); - if (GET_U32LE(offsetof_file_mode) & ~dm_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in dm bitfield: %#08"PRIx32, - GET_U32LE(offsetof_file_mode) & ~dm_masks[ctx->version]); - if (ret_net_size) - *ret_net_size = net_offset; - return (ssize_t)host_size; -} - -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -static ssize_t validate_Tversion(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Tversion); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - VALIDATE_NET_BYTES(13); - VALIDATE_NET_UTF8(LAST_U16LE()); - uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tversion->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(100)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tversion->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(100)); - return (ssize_t)host_size; -} - -static ssize_t validate_Rversion(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rversion); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - VALIDATE_NET_BYTES(13); - VALIDATE_NET_UTF8(LAST_U16LE()); - uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rversion->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(101)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rversion->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(101)); - return (ssize_t)host_size; -} - -static ssize_t validate_Tauth(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Tauth); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - VALIDATE_NET_BYTES(13); - VALIDATE_NET_UTF8(LAST_U16LE()); - VALIDATE_NET_BYTES(2); - VALIDATE_NET_UTF8(LAST_U16LE()); -#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u - if (( is_ver(ctx, 9P2000_L) || is_ver(ctx, 9P2000_u) )) { - VALIDATE_NET_BYTES(4); - } -#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ - uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tauth->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(102)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tauth->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(102)); - return (ssize_t)host_size; -} - -static ssize_t validate_Rauth(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rauth); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_aqid_type = net_offset + 7; - VALIDATE_NET_BYTES(20); - if (GET_U8LE(offsetof_aqid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, - GET_U8LE(offsetof_aqid_type) & ~qt_masks[ctx->version]); - uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rauth->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(103)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rauth->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(103)); - return (ssize_t)host_size; -} - -static ssize_t validate_Tattach(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Tattach); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - VALIDATE_NET_BYTES(17); - VALIDATE_NET_UTF8(LAST_U16LE()); - VALIDATE_NET_BYTES(2); - VALIDATE_NET_UTF8(LAST_U16LE()); -#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u - if (( is_ver(ctx, 9P2000_L) || is_ver(ctx, 9P2000_u) )) { - VALIDATE_NET_BYTES(4); - } -#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ - uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tattach->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(104)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tattach->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(104)); - return (ssize_t)host_size; -} - -static ssize_t validate_Rattach(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rattach); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_qid_type = net_offset + 7; - VALIDATE_NET_BYTES(20); - if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, - GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]); - uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rattach->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(105)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rattach->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(105)); - return (ssize_t)host_size; -} - -static ssize_t validate_Rerror(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rerror); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - VALIDATE_NET_BYTES(9); - VALIDATE_NET_UTF8(LAST_U16LE()); -#if CONFIG_9P_ENABLE_9P2000_u - if (is_ver(ctx, 9P2000_u)) { - VALIDATE_NET_BYTES(4); - } -#endif /* CONFIG_9P_ENABLE_9P2000_u */ - uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rerror->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(107)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rerror->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(107)); - return (ssize_t)host_size; -} - -static ssize_t validate_Tflush(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Tflush); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_end = net_offset + 9; - VALIDATE_NET_BYTES(9); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tflush->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(108)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tflush->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(108)); - return (ssize_t)host_size; -} - -static ssize_t validate_Rflush(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rflush); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_end = net_offset + 7; - VALIDATE_NET_BYTES(7); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rflush->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(109)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rflush->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(109)); - return (ssize_t)host_size; -} - -static ssize_t validate_Twalk(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Twalk); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_nwname = net_offset + 15; - VALIDATE_NET_BYTES(17); - for (uint16_t i = 0, cnt = LAST_U16LE(); i < cnt; i++) { - RESERVE_HOST_BYTES(sizeof(struct lib9p_s)); - VALIDATE_NET_BYTES(2); - VALIDATE_NET_UTF8(LAST_U16LE()); - } - uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Twalk->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(110)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Twalk->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(110)); - if ((uint16_t)GET_U16LE(offsetof_nwname) > (uint16_t)(16)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Twalk->nwname value is too large: %"PRIu16" > %"PRIu16, - (uint16_t)GET_U16LE(offsetof_nwname), (uint16_t)(16)); - return (ssize_t)host_size; -} - -static ssize_t validate_Rwalk(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rwalk); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_nwqid = net_offset + 7; - VALIDATE_NET_BYTES(9); - for (uint16_t i = 0, cnt = LAST_U16LE(); i < cnt; i++) { - RESERVE_HOST_BYTES(sizeof(struct lib9p_qid)); - uint32_t offsetof_wqid_type = net_offset + 0; - VALIDATE_NET_BYTES(13); - if (GET_U8LE(offsetof_wqid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, - GET_U8LE(offsetof_wqid_type) & ~qt_masks[ctx->version]); - } - uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rwalk->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(111)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rwalk->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(111)); - if ((uint16_t)GET_U16LE(offsetof_nwqid) > (uint16_t)(16)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rwalk->nwqid value is too large: %"PRIu16" > %"PRIu16, - (uint16_t)GET_U16LE(offsetof_nwqid), (uint16_t)(16)); - return (ssize_t)host_size; -} - -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -static ssize_t validate_Topen(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Topen); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_mode = net_offset + 11; - uint32_t offsetof_end = net_offset + 12; - VALIDATE_NET_BYTES(12); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Topen->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(112)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Topen->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(112)); - if (GET_U8LE(offsetof_mode) & ~o_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in o bitfield: %#02"PRIx8, - GET_U8LE(offsetof_mode) & ~o_masks[ctx->version]); - return (ssize_t)host_size; -} - -static ssize_t validate_Ropen(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Ropen); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_qid_type = net_offset + 7; - VALIDATE_NET_BYTES(20); - if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, - GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]); - uint32_t offsetof_end = net_offset + 4; - VALIDATE_NET_BYTES(4); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Ropen->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(113)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Ropen->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(113)); - return (ssize_t)host_size; -} - -static ssize_t validate_Tcreate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Tcreate); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - VALIDATE_NET_BYTES(13); - VALIDATE_NET_UTF8(LAST_U16LE()); - uint32_t offsetof_perm = net_offset + 0; - uint32_t offsetof_mode = net_offset + 4; - uint32_t offsetof_end = net_offset + 5; - VALIDATE_NET_BYTES(5); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tcreate->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(114)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tcreate->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(114)); - if (GET_U32LE(offsetof_perm) & ~dm_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in dm bitfield: %#08"PRIx32, - GET_U32LE(offsetof_perm) & ~dm_masks[ctx->version]); - if (GET_U8LE(offsetof_mode) & ~o_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in o bitfield: %#02"PRIx8, - GET_U8LE(offsetof_mode) & ~o_masks[ctx->version]); - return (ssize_t)host_size; -} - -static ssize_t validate_Rcreate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rcreate); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_qid_type = net_offset + 7; - VALIDATE_NET_BYTES(20); - if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, - GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]); - uint32_t offsetof_end = net_offset + 4; - VALIDATE_NET_BYTES(4); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rcreate->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(115)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rcreate->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(115)); - return (ssize_t)host_size; -} - -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -static ssize_t validate_Tread(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Tread); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_offset = net_offset + 11; - uint32_t offsetof_count = net_offset + 19; - uint32_t offsetof_end = net_offset + 23; - VALIDATE_NET_BYTES(23); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tread->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(116)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tread->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(116)); - if ((uint64_t)GET_U64LE(offsetof_offset) > (uint64_t)(INT64_MAX)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tread->offset value is too large: %"PRIu64" > %"PRIu64, - (uint64_t)GET_U64LE(offsetof_offset), (uint64_t)(INT64_MAX)); - if ((uint32_t)GET_U32LE(offsetof_count) > (uint32_t)(INT32_MAX)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tread->count value is too large: %"PRIu32" > %"PRIu32, - (uint32_t)GET_U32LE(offsetof_count), (uint32_t)(INT32_MAX)); - return (ssize_t)host_size; -} - -static ssize_t validate_Rread(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rread); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_count = net_offset + 7; - VALIDATE_NET_BYTES(11); - VALIDATE_NET_BYTES(LAST_U32LE()); - uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rread->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(117)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rread->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(117)); - if ((uint32_t)GET_U32LE(offsetof_count) > (uint32_t)(INT32_MAX)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rread->count value is too large: %"PRIu32" > %"PRIu32, - (uint32_t)GET_U32LE(offsetof_count), (uint32_t)(INT32_MAX)); - return (ssize_t)host_size; -} - -static ssize_t validate_Twrite(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Twrite); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_offset = net_offset + 11; - uint32_t offsetof_count = net_offset + 19; - VALIDATE_NET_BYTES(23); - VALIDATE_NET_BYTES(LAST_U32LE()); - uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Twrite->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(118)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Twrite->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(118)); - if ((uint64_t)GET_U64LE(offsetof_offset) > (uint64_t)(INT64_MAX)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Twrite->offset value is too large: %"PRIu64" > %"PRIu64, - (uint64_t)GET_U64LE(offsetof_offset), (uint64_t)(INT64_MAX)); - if ((uint32_t)GET_U32LE(offsetof_count) > (uint32_t)(INT32_MAX)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Twrite->count value is too large: %"PRIu32" > %"PRIu32, - (uint32_t)GET_U32LE(offsetof_count), (uint32_t)(INT32_MAX)); - return (ssize_t)host_size; -} - -static ssize_t validate_Rwrite(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rwrite); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_count = net_offset + 7; - uint32_t offsetof_end = net_offset + 11; - VALIDATE_NET_BYTES(11); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rwrite->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(119)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rwrite->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(119)); - if ((uint32_t)GET_U32LE(offsetof_count) > (uint32_t)(INT32_MAX)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rwrite->count value is too large: %"PRIu32" > %"PRIu32, - (uint32_t)GET_U32LE(offsetof_count), (uint32_t)(INT32_MAX)); - return (ssize_t)host_size; -} - -static ssize_t validate_Tclunk(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Tclunk); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_end = net_offset + 11; - VALIDATE_NET_BYTES(11); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tclunk->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(120)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tclunk->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(120)); - return (ssize_t)host_size; -} - -static ssize_t validate_Rclunk(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rclunk); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_end = net_offset + 7; - VALIDATE_NET_BYTES(7); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rclunk->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(121)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rclunk->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(121)); - return (ssize_t)host_size; -} - -static ssize_t validate_Tremove(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Tremove); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_end = net_offset + 11; - VALIDATE_NET_BYTES(11); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tremove->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(122)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tremove->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(122)); - return (ssize_t)host_size; -} - -static ssize_t validate_Rremove(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rremove); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_end = net_offset + 7; - VALIDATE_NET_BYTES(7); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rremove->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(123)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rremove->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(123)); - return (ssize_t)host_size; -} - -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -static ssize_t validate_Tstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Tstat); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_end = net_offset + 11; - VALIDATE_NET_BYTES(11); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tstat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(124)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tstat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(124)); - return (ssize_t)host_size; -} - -static ssize_t validate_Rstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rstat); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_nstat = net_offset + 7; - uint32_t offsetof_stat = net_offset + 9; - uint32_t offsetof_stat_stat_size = net_offset + 9; - uint32_t offsetof_stat_kern_type = net_offset + 11; - uint32_t offsetof_stat_file_qid_type = net_offset + 17; - VALIDATE_NET_BYTES(30); - if (GET_U8LE(offsetof_stat_file_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, - GET_U8LE(offsetof_stat_file_qid_type) & ~qt_masks[ctx->version]); - uint32_t offsetof_stat_file_mode = net_offset + 0; - VALIDATE_NET_BYTES(22); - VALIDATE_NET_UTF8(LAST_U16LE()); - VALIDATE_NET_BYTES(2); - VALIDATE_NET_UTF8(LAST_U16LE()); - VALIDATE_NET_BYTES(2); - VALIDATE_NET_UTF8(LAST_U16LE()); - VALIDATE_NET_BYTES(2); - VALIDATE_NET_UTF8(LAST_U16LE()); -#if CONFIG_9P_ENABLE_9P2000_u - if (is_ver(ctx, 9P2000_u)) { - VALIDATE_NET_BYTES(2); - VALIDATE_NET_UTF8(LAST_U16LE()); - VALIDATE_NET_BYTES(12); - } -#endif /* CONFIG_9P_ENABLE_9P2000_u */ - uint32_t offsetof_stat_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_stat_stat_size) != (uint32_t)(offsetof_stat_end - offsetof_stat_kern_type)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rstat->stat.stat_size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_stat_stat_size), (uint32_t)(offsetof_stat_end - offsetof_stat_kern_type)); - if (GET_U32LE(offsetof_stat_file_mode) & ~dm_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in dm bitfield: %#08"PRIx32, - GET_U32LE(offsetof_stat_file_mode) & ~dm_masks[ctx->version]); - uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rstat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(125)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rstat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(125)); - if ((uint32_t)GET_U32LE(offsetof_nstat) != (uint32_t)(offsetof_end - offsetof_stat)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rstat->nstat value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_nstat), (uint32_t)(offsetof_end - offsetof_stat)); - return (ssize_t)host_size; -} - -static ssize_t validate_Twstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Twstat); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_nstat = net_offset + 11; - uint32_t offsetof_stat = net_offset + 13; - uint32_t offsetof_stat_stat_size = net_offset + 13; - uint32_t offsetof_stat_kern_type = net_offset + 15; - uint32_t offsetof_stat_file_qid_type = net_offset + 21; - VALIDATE_NET_BYTES(34); - if (GET_U8LE(offsetof_stat_file_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, - GET_U8LE(offsetof_stat_file_qid_type) & ~qt_masks[ctx->version]); - uint32_t offsetof_stat_file_mode = net_offset + 0; - VALIDATE_NET_BYTES(22); - VALIDATE_NET_UTF8(LAST_U16LE()); - VALIDATE_NET_BYTES(2); - VALIDATE_NET_UTF8(LAST_U16LE()); - VALIDATE_NET_BYTES(2); - VALIDATE_NET_UTF8(LAST_U16LE()); - VALIDATE_NET_BYTES(2); - VALIDATE_NET_UTF8(LAST_U16LE()); -#if CONFIG_9P_ENABLE_9P2000_u - if (is_ver(ctx, 9P2000_u)) { - VALIDATE_NET_BYTES(2); - VALIDATE_NET_UTF8(LAST_U16LE()); - VALIDATE_NET_BYTES(12); - } -#endif /* CONFIG_9P_ENABLE_9P2000_u */ - uint32_t offsetof_stat_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_stat_stat_size) != (uint32_t)(offsetof_stat_end - offsetof_stat_kern_type)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Twstat->stat.stat_size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_stat_stat_size), (uint32_t)(offsetof_stat_end - offsetof_stat_kern_type)); - if (GET_U32LE(offsetof_stat_file_mode) & ~dm_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in dm bitfield: %#08"PRIx32, - GET_U32LE(offsetof_stat_file_mode) & ~dm_masks[ctx->version]); - uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Twstat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(126)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Twstat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(126)); - if ((uint32_t)GET_U32LE(offsetof_nstat) != (uint32_t)(offsetof_end - offsetof_stat)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Twstat->nstat value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_nstat), (uint32_t)(offsetof_end - offsetof_stat)); - return (ssize_t)host_size; -} - -static ssize_t validate_Rwstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rwstat); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_end = net_offset + 7; - VALIDATE_NET_BYTES(7); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rwstat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(127)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rwstat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(127)); - return (ssize_t)host_size; -} - -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000_p9p -static ssize_t validate_Topenfd(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Topenfd); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_mode = net_offset + 11; - uint32_t offsetof_end = net_offset + 12; - VALIDATE_NET_BYTES(12); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Topenfd->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(98)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Topenfd->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(98)); - if (GET_U8LE(offsetof_mode) & ~o_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in o bitfield: %#02"PRIx8, - GET_U8LE(offsetof_mode) & ~o_masks[ctx->version]); - return (ssize_t)host_size; -} - -static ssize_t validate_Ropenfd(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Ropenfd); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_qid_type = net_offset + 7; - VALIDATE_NET_BYTES(20); - if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, - GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]); - uint32_t offsetof_end = net_offset + 8; - VALIDATE_NET_BYTES(8); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Ropenfd->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(99)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Ropenfd->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(99)); - return (ssize_t)host_size; -} - -#endif /* CONFIG_9P_ENABLE_9P2000_p9p */ -#if CONFIG_9P_ENABLE_9P2000_L -static ssize_t validate_Rlerror(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rlerror); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_end = net_offset + 11; - VALIDATE_NET_BYTES(11); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rlerror->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(7)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rlerror->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(7)); - return (ssize_t)host_size; -} - -static ssize_t validate_Tstatfs(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Tstatfs); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_end = net_offset + 11; - VALIDATE_NET_BYTES(11); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tstatfs->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(8)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tstatfs->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(8)); - return (ssize_t)host_size; -} - -static ssize_t validate_Rstatfs(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rstatfs); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_end = net_offset + 67; - VALIDATE_NET_BYTES(67); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rstatfs->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(9)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rstatfs->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(9)); - return (ssize_t)host_size; -} - -static ssize_t validate_Tlopen(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Tlopen); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_flags = net_offset + 11; - uint32_t offsetof_end = net_offset + 15; - VALIDATE_NET_BYTES(15); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tlopen->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(12)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tlopen->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(12)); - if (GET_U32LE(offsetof_flags) & ~lo_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in lo bitfield: %#08"PRIx32, - GET_U32LE(offsetof_flags) & ~lo_masks[ctx->version]); - return (ssize_t)host_size; -} - -static ssize_t validate_Rlopen(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rlopen); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_qid_type = net_offset + 7; - VALIDATE_NET_BYTES(20); - if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, - GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]); - uint32_t offsetof_end = net_offset + 4; - VALIDATE_NET_BYTES(4); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rlopen->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(13)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rlopen->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(13)); - return (ssize_t)host_size; -} - -static ssize_t validate_Tlcreate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Tlcreate); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - VALIDATE_NET_BYTES(13); - VALIDATE_NET_UTF8(LAST_U16LE()); - uint32_t offsetof_flags = net_offset + 0; - uint32_t offsetof_mode = net_offset + 4; - uint32_t offsetof_end = net_offset + 12; - VALIDATE_NET_BYTES(12); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tlcreate->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(14)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tlcreate->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(14)); - if (GET_U32LE(offsetof_flags) & ~lo_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in lo bitfield: %#08"PRIx32, - GET_U32LE(offsetof_flags) & ~lo_masks[ctx->version]); - if (GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in mode bitfield: %#08"PRIx32, - GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]); - return (ssize_t)host_size; -} - -static ssize_t validate_Rlcreate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rlcreate); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_qid_type = net_offset + 7; - VALIDATE_NET_BYTES(20); - if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, - GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]); - uint32_t offsetof_end = net_offset + 4; - VALIDATE_NET_BYTES(4); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rlcreate->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(15)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rlcreate->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(15)); - return (ssize_t)host_size; -} - -static ssize_t validate_Tsymlink(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Tsymlink); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - VALIDATE_NET_BYTES(13); - VALIDATE_NET_UTF8(LAST_U16LE()); - VALIDATE_NET_BYTES(2); - VALIDATE_NET_UTF8(LAST_U16LE()); - uint32_t offsetof_end = net_offset + 4; - VALIDATE_NET_BYTES(4); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tsymlink->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(16)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tsymlink->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(16)); - return (ssize_t)host_size; -} - -static ssize_t validate_Rsymlink(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rsymlink); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_qid_type = net_offset + 7; - VALIDATE_NET_BYTES(20); - if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, - GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]); - uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rsymlink->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(17)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rsymlink->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(17)); - return (ssize_t)host_size; -} - -static ssize_t validate_Tmknod(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Tmknod); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - VALIDATE_NET_BYTES(13); - VALIDATE_NET_UTF8(LAST_U16LE()); - uint32_t offsetof_mode = net_offset + 0; - uint32_t offsetof_end = net_offset + 16; - VALIDATE_NET_BYTES(16); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tmknod->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(18)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tmknod->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(18)); - if (GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in mode bitfield: %#08"PRIx32, - GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]); - return (ssize_t)host_size; -} - -static ssize_t validate_Rmknod(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rmknod); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_qid_type = net_offset + 7; - VALIDATE_NET_BYTES(20); - if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, - GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]); - uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rmknod->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(19)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rmknod->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(19)); - return (ssize_t)host_size; -} - -static ssize_t validate_Trename(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Trename); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - VALIDATE_NET_BYTES(17); - VALIDATE_NET_UTF8(LAST_U16LE()); - uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Trename->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(20)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Trename->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(20)); - return (ssize_t)host_size; -} - -static ssize_t validate_Rrename(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rrename); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_end = net_offset + 7; - VALIDATE_NET_BYTES(7); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rrename->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(21)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rrename->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(21)); - return (ssize_t)host_size; -} - -static ssize_t validate_Treadlink(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Treadlink); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_end = net_offset + 11; - VALIDATE_NET_BYTES(11); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Treadlink->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(22)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Treadlink->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(22)); - return (ssize_t)host_size; -} - -static ssize_t validate_Rreadlink(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rreadlink); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - VALIDATE_NET_BYTES(9); - VALIDATE_NET_UTF8(LAST_U16LE()); - uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rreadlink->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(23)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rreadlink->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(23)); - return (ssize_t)host_size; -} - -static ssize_t validate_Tgetattr(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Tgetattr); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_request_mask = net_offset + 11; - uint32_t offsetof_end = net_offset + 19; - VALIDATE_NET_BYTES(19); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tgetattr->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(24)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tgetattr->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(24)); - if (GET_U64LE(offsetof_request_mask) & ~getattr_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in getattr bitfield: %#016"PRIx64, - GET_U64LE(offsetof_request_mask) & ~getattr_masks[ctx->version]); - return (ssize_t)host_size; -} - -static ssize_t validate_Rgetattr(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rgetattr); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_valid = net_offset + 7; - uint32_t offsetof_qid_type = net_offset + 15; - VALIDATE_NET_BYTES(28); - if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, - GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]); - uint32_t offsetof_mode = net_offset + 0; - uint32_t offsetof_end = net_offset + 132; - VALIDATE_NET_BYTES(132); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rgetattr->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(25)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rgetattr->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(25)); - if (GET_U64LE(offsetof_valid) & ~getattr_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in getattr bitfield: %#016"PRIx64, - GET_U64LE(offsetof_valid) & ~getattr_masks[ctx->version]); - if (GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in mode bitfield: %#08"PRIx32, - GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]); - return (ssize_t)host_size; -} - -static ssize_t validate_Tsetattr(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Tsetattr); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_valid = net_offset + 11; - uint32_t offsetof_mode = net_offset + 15; - uint32_t offsetof_end = net_offset + 67; - VALIDATE_NET_BYTES(67); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tsetattr->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(26)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tsetattr->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(26)); - if (GET_U32LE(offsetof_valid) & ~setattr_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in setattr bitfield: %#08"PRIx32, - GET_U32LE(offsetof_valid) & ~setattr_masks[ctx->version]); - if (GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in mode bitfield: %#08"PRIx32, - GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]); - return (ssize_t)host_size; -} - -static ssize_t validate_Rsetattr(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rsetattr); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_end = net_offset + 7; - VALIDATE_NET_BYTES(7); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rsetattr->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(27)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rsetattr->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(27)); - return (ssize_t)host_size; -} - -static ssize_t validate_Txattrwalk(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Txattrwalk); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - VALIDATE_NET_BYTES(17); - VALIDATE_NET_UTF8(LAST_U16LE()); - uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Txattrwalk->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(30)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Txattrwalk->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(30)); - return (ssize_t)host_size; -} - -static ssize_t validate_Rxattrwalk(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rxattrwalk); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_end = net_offset + 15; - VALIDATE_NET_BYTES(15); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rxattrwalk->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(31)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rxattrwalk->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(31)); - return (ssize_t)host_size; -} - -static ssize_t validate_Txattrcreate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Txattrcreate); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - VALIDATE_NET_BYTES(13); - VALIDATE_NET_UTF8(LAST_U16LE()); - uint32_t offsetof_end = net_offset + 12; - VALIDATE_NET_BYTES(12); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Txattrcreate->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(32)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Txattrcreate->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(32)); - return (ssize_t)host_size; -} - -static ssize_t validate_Rxattrcreate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rxattrcreate); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_end = net_offset + 7; - VALIDATE_NET_BYTES(7); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rxattrcreate->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(33)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rxattrcreate->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(33)); - return (ssize_t)host_size; -} - -static ssize_t validate_Treaddir(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Treaddir); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_end = net_offset + 23; - VALIDATE_NET_BYTES(23); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Treaddir->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(40)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Treaddir->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(40)); - return (ssize_t)host_size; -} - -static ssize_t validate_Rreaddir(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rreaddir); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - VALIDATE_NET_BYTES(11); - VALIDATE_NET_BYTES(LAST_U32LE()); - uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rreaddir->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(41)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rreaddir->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(41)); - return (ssize_t)host_size; -} - -static ssize_t validate_Tfsync(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Tfsync); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_end = net_offset + 15; - VALIDATE_NET_BYTES(15); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tfsync->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(50)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tfsync->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(50)); - return (ssize_t)host_size; -} - -static ssize_t validate_Rfsync(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rfsync); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_end = net_offset + 7; - VALIDATE_NET_BYTES(7); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rfsync->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(51)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rfsync->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(51)); - return (ssize_t)host_size; -} - -static ssize_t validate_Tlock(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Tlock); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_flags = net_offset + 12; - VALIDATE_NET_BYTES(38); - VALIDATE_NET_UTF8(LAST_U16LE()); - uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tlock->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(52)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tlock->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(52)); - if (GET_U32LE(offsetof_flags) & ~lock_flags_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in lock_flags bitfield: %#08"PRIx32, - GET_U32LE(offsetof_flags) & ~lock_flags_masks[ctx->version]); - return (ssize_t)host_size; -} - -static ssize_t validate_Rlock(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rlock); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_end = net_offset + 8; - VALIDATE_NET_BYTES(8); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rlock->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(53)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rlock->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(53)); - return (ssize_t)host_size; -} - -static ssize_t validate_Tgetlock(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Tgetlock); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - VALIDATE_NET_BYTES(34); - VALIDATE_NET_UTF8(LAST_U16LE()); - uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tgetlock->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(54)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tgetlock->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(54)); - return (ssize_t)host_size; -} - -static ssize_t validate_Rgetlock(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rgetlock); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - VALIDATE_NET_BYTES(30); - VALIDATE_NET_UTF8(LAST_U16LE()); - uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rgetlock->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(55)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rgetlock->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(55)); - return (ssize_t)host_size; -} - -static ssize_t validate_Tlink(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Tlink); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - VALIDATE_NET_BYTES(17); - VALIDATE_NET_UTF8(LAST_U16LE()); - uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tlink->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(70)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tlink->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(70)); - return (ssize_t)host_size; -} - -static ssize_t validate_Rlink(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rlink); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_end = net_offset + 7; - VALIDATE_NET_BYTES(7); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rlink->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(71)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rlink->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(71)); - return (ssize_t)host_size; -} - -static ssize_t validate_Tmkdir(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Tmkdir); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - VALIDATE_NET_BYTES(13); - VALIDATE_NET_UTF8(LAST_U16LE()); - uint32_t offsetof_mode = net_offset + 0; - uint32_t offsetof_end = net_offset + 8; - VALIDATE_NET_BYTES(8); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tmkdir->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(72)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tmkdir->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(72)); - if (GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in mode bitfield: %#08"PRIx32, - GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]); - return (ssize_t)host_size; -} - -static ssize_t validate_Rmkdir(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rmkdir); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_qid_type = net_offset + 7; - VALIDATE_NET_BYTES(20); - if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, - GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]); - uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rmkdir->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(73)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rmkdir->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(73)); - return (ssize_t)host_size; -} - -static ssize_t validate_Trenameat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Trenameat); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - VALIDATE_NET_BYTES(13); - VALIDATE_NET_UTF8(LAST_U16LE()); - VALIDATE_NET_BYTES(6); - VALIDATE_NET_UTF8(LAST_U16LE()); - uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Trenameat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(74)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Trenameat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(74)); - return (ssize_t)host_size; -} - -static ssize_t validate_Rrenameat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rrenameat); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_end = net_offset + 7; - VALIDATE_NET_BYTES(7); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rrenameat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(75)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rrenameat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(75)); - return (ssize_t)host_size; -} - -static ssize_t validate_Tunlinkat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Tunlinkat); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - VALIDATE_NET_BYTES(13); - VALIDATE_NET_UTF8(LAST_U16LE()); - uint32_t offsetof_end = net_offset + 4; - VALIDATE_NET_BYTES(4); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tunlinkat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(76)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tunlinkat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(76)); - return (ssize_t)host_size; -} - -static ssize_t validate_Runlinkat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Runlinkat); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_end = net_offset + 7; - VALIDATE_NET_BYTES(7); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Runlinkat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(77)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Runlinkat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(77)); - return (ssize_t)host_size; -} - -#endif /* CONFIG_9P_ENABLE_9P2000_L */ -#if CONFIG_9P_ENABLE_9P2000_e -static ssize_t validate_Tsession(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Tsession); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_end = net_offset + 15; - VALIDATE_NET_BYTES(15); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tsession->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(150)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tsession->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(150)); - return (ssize_t)host_size; -} - -static ssize_t validate_Rsession(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rsession); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_end = net_offset + 7; - VALIDATE_NET_BYTES(7); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rsession->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(151)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rsession->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(151)); - return (ssize_t)host_size; -} - -static ssize_t validate_Tsread(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Tsread); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - VALIDATE_NET_BYTES(13); - for (uint16_t i = 0, cnt = LAST_U16LE(); i < cnt; i++) { - RESERVE_HOST_BYTES(sizeof(struct lib9p_s)); - VALIDATE_NET_BYTES(2); - VALIDATE_NET_UTF8(LAST_U16LE()); - } - uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tsread->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(152)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tsread->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(152)); - return (ssize_t)host_size; -} - -static ssize_t validate_Rsread(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rsread); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - VALIDATE_NET_BYTES(11); - VALIDATE_NET_BYTES(LAST_U32LE()); - uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rsread->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(153)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rsread->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(153)); - return (ssize_t)host_size; -} - -static ssize_t validate_Tswrite(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Tswrite); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - VALIDATE_NET_BYTES(13); - for (uint16_t i = 0, cnt = LAST_U16LE(); i < cnt; i++) { - RESERVE_HOST_BYTES(sizeof(struct lib9p_s)); - VALIDATE_NET_BYTES(2); - VALIDATE_NET_UTF8(LAST_U16LE()); - } - VALIDATE_NET_BYTES(4); - VALIDATE_NET_BYTES(LAST_U32LE()); - uint32_t offsetof_end = net_offset + 0; - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tswrite->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(154)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tswrite->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(154)); - return (ssize_t)host_size; -} - -static ssize_t validate_Rswrite(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { - uint32_t net_offset = 0; - ssize_t host_size = sizeof(struct lib9p_msg_Rswrite); - uint32_t offsetof_size = net_offset + 0; - uint32_t offsetof_typ = net_offset + 4; - uint32_t offsetof_end = net_offset + 11; - VALIDATE_NET_BYTES(11); - if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rswrite->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, - (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); - if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(155)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rswrite->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, - (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(155)); - return (ssize_t)host_size; -} -#endif /* CONFIG_9P_ENABLE_9P2000_e */ - -/* unmarshal_* ****************************************************************/ - -#define UNMARSHAL_BYTES(ctx, data_lvalue, len) \ - data_lvalue = (char *)&net_bytes[net_offset]; \ - net_offset += len; -#define UNMARSHAL_U8LE(ctx, val_lvalue) \ - val_lvalue = net_bytes[net_offset]; \ - net_offset += 1; -#define UNMARSHAL_U16LE(ctx, val_lvalue) \ - val_lvalue = uint16le_decode(&net_bytes[net_offset]); \ - net_offset += 2; -#define UNMARSHAL_U32LE(ctx, val_lvalue) \ - val_lvalue = uint32le_decode(&net_bytes[net_offset]); \ - net_offset += 4; -#define UNMARSHAL_U64LE(ctx, val_lvalue) \ - val_lvalue = uint64le_decode(&net_bytes[net_offset]); \ - net_offset += 8; - -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -static void unmarshal_stat([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_stat *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 2; - UNMARSHAL_U16LE(ctx, out->kern_type); - UNMARSHAL_U32LE(ctx, out->kern_dev); - UNMARSHAL_U8LE(ctx, out->file_qid.type); - UNMARSHAL_U32LE(ctx, out->file_qid.vers); - UNMARSHAL_U64LE(ctx, out->file_qid.path); - UNMARSHAL_U32LE(ctx, out->file_mode); - UNMARSHAL_U32LE(ctx, out->file_atime); - UNMARSHAL_U32LE(ctx, out->file_mtime); - UNMARSHAL_U64LE(ctx, out->file_size); - UNMARSHAL_U16LE(ctx, out->file_name.len); - UNMARSHAL_BYTES(ctx, out->file_name.utf8, out->file_name.len); - UNMARSHAL_U16LE(ctx, out->file_owner_uid.len); - UNMARSHAL_BYTES(ctx, out->file_owner_uid.utf8, out->file_owner_uid.len); - UNMARSHAL_U16LE(ctx, out->file_owner_gid.len); - UNMARSHAL_BYTES(ctx, out->file_owner_gid.utf8, out->file_owner_gid.len); - UNMARSHAL_U16LE(ctx, out->file_last_modified_uid.len); - UNMARSHAL_BYTES(ctx, out->file_last_modified_uid.utf8, out->file_last_modified_uid.len); -#if CONFIG_9P_ENABLE_9P2000_u - if (is_ver(ctx, 9P2000_u)) { - UNMARSHAL_U16LE(ctx, out->file_extension.len); - UNMARSHAL_BYTES(ctx, out->file_extension.utf8, out->file_extension.len); - UNMARSHAL_U32LE(ctx, out->file_owner_n_uid); - UNMARSHAL_U32LE(ctx, out->file_owner_n_gid); - UNMARSHAL_U32LE(ctx, out->file_last_modified_n_uid); - } -#endif /* CONFIG_9P_ENABLE_9P2000_u */ -} - -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -static void unmarshal_Tversion([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Tversion *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->max_msg_size); - UNMARSHAL_U16LE(ctx, out->version.len); - UNMARSHAL_BYTES(ctx, out->version.utf8, out->version.len); -} - -static void unmarshal_Rversion([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rversion *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->max_msg_size); - UNMARSHAL_U16LE(ctx, out->version.len); - UNMARSHAL_BYTES(ctx, out->version.utf8, out->version.len); -} - -static void unmarshal_Tauth([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Tauth *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->afid); - UNMARSHAL_U16LE(ctx, out->uname.len); - UNMARSHAL_BYTES(ctx, out->uname.utf8, out->uname.len); - UNMARSHAL_U16LE(ctx, out->aname.len); - UNMARSHAL_BYTES(ctx, out->aname.utf8, out->aname.len); -#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u - if (( is_ver(ctx, 9P2000_L) || is_ver(ctx, 9P2000_u) )) { - UNMARSHAL_U32LE(ctx, out->n_uid); - } -#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ -} - -static void unmarshal_Rauth([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rauth *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U8LE(ctx, out->aqid.type); - UNMARSHAL_U32LE(ctx, out->aqid.vers); - UNMARSHAL_U64LE(ctx, out->aqid.path); -} - -static void unmarshal_Tattach([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Tattach *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->fid); - UNMARSHAL_U32LE(ctx, out->afid); - UNMARSHAL_U16LE(ctx, out->uname.len); - UNMARSHAL_BYTES(ctx, out->uname.utf8, out->uname.len); - UNMARSHAL_U16LE(ctx, out->aname.len); - UNMARSHAL_BYTES(ctx, out->aname.utf8, out->aname.len); -#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u - if (( is_ver(ctx, 9P2000_L) || is_ver(ctx, 9P2000_u) )) { - UNMARSHAL_U32LE(ctx, out->n_uid); - } -#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ -} - -static void unmarshal_Rattach([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rattach *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U8LE(ctx, out->qid.type); - UNMARSHAL_U32LE(ctx, out->qid.vers); - UNMARSHAL_U64LE(ctx, out->qid.path); -} - -static void unmarshal_Rerror([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rerror *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U16LE(ctx, out->ename.len); - UNMARSHAL_BYTES(ctx, out->ename.utf8, out->ename.len); -#if CONFIG_9P_ENABLE_9P2000_u - if (is_ver(ctx, 9P2000_u)) { - UNMARSHAL_U32LE(ctx, out->errno); - } -#endif /* CONFIG_9P_ENABLE_9P2000_u */ -} - -static void unmarshal_Tflush([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Tflush *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U16LE(ctx, out->oldtag); -} - -static void unmarshal_Rflush([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rflush *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); -} - -static void unmarshal_Twalk([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Twalk *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->fid); - UNMARSHAL_U32LE(ctx, out->newfid); - UNMARSHAL_U16LE(ctx, out->nwname); - out->wname = extra; - extra += sizeof(out->wname[0]) * out->nwname; - for (uint16_t i = 0; i < out->nwname; i++) { - UNMARSHAL_U16LE(ctx, out->wname[i].len); - UNMARSHAL_BYTES(ctx, out->wname[i].utf8, out->wname[i].len); - } -} - -static void unmarshal_Rwalk([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rwalk *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U16LE(ctx, out->nwqid); - out->wqid = extra; - extra += sizeof(out->wqid[0]) * out->nwqid; - for (uint16_t i = 0; i < out->nwqid; i++) { - UNMARSHAL_U8LE(ctx, out->wqid[i].type); - UNMARSHAL_U32LE(ctx, out->wqid[i].vers); - UNMARSHAL_U64LE(ctx, out->wqid[i].path); - } -} - -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -static void unmarshal_Topen([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Topen *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->fid); - UNMARSHAL_U8LE(ctx, out->mode); -} - -static void unmarshal_Ropen([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Ropen *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U8LE(ctx, out->qid.type); - UNMARSHAL_U32LE(ctx, out->qid.vers); - UNMARSHAL_U64LE(ctx, out->qid.path); - UNMARSHAL_U32LE(ctx, out->iounit); -} - -static void unmarshal_Tcreate([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Tcreate *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->fid); - UNMARSHAL_U16LE(ctx, out->name.len); - UNMARSHAL_BYTES(ctx, out->name.utf8, out->name.len); - UNMARSHAL_U32LE(ctx, out->perm); - UNMARSHAL_U8LE(ctx, out->mode); -} - -static void unmarshal_Rcreate([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rcreate *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U8LE(ctx, out->qid.type); - UNMARSHAL_U32LE(ctx, out->qid.vers); - UNMARSHAL_U64LE(ctx, out->qid.path); - UNMARSHAL_U32LE(ctx, out->iounit); -} - -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -static void unmarshal_Tread([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Tread *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->fid); - UNMARSHAL_U64LE(ctx, out->offset); - UNMARSHAL_U32LE(ctx, out->count); -} - -static void unmarshal_Rread([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rread *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->count); - UNMARSHAL_BYTES(ctx, out->data, out->count); -} - -static void unmarshal_Twrite([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Twrite *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->fid); - UNMARSHAL_U64LE(ctx, out->offset); - UNMARSHAL_U32LE(ctx, out->count); - UNMARSHAL_BYTES(ctx, out->data, out->count); -} - -static void unmarshal_Rwrite([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rwrite *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->count); -} - -static void unmarshal_Tclunk([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Tclunk *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->fid); -} - -static void unmarshal_Rclunk([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rclunk *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); -} - -static void unmarshal_Tremove([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Tremove *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->fid); -} - -static void unmarshal_Rremove([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rremove *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); -} - -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -static void unmarshal_Tstat([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Tstat *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->fid); -} - -static void unmarshal_Rstat([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rstat *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - net_offset += 2; - net_offset += 2; - UNMARSHAL_U16LE(ctx, out->stat.kern_type); - UNMARSHAL_U32LE(ctx, out->stat.kern_dev); - UNMARSHAL_U8LE(ctx, out->stat.file_qid.type); - UNMARSHAL_U32LE(ctx, out->stat.file_qid.vers); - UNMARSHAL_U64LE(ctx, out->stat.file_qid.path); - UNMARSHAL_U32LE(ctx, out->stat.file_mode); - UNMARSHAL_U32LE(ctx, out->stat.file_atime); - UNMARSHAL_U32LE(ctx, out->stat.file_mtime); - UNMARSHAL_U64LE(ctx, out->stat.file_size); - UNMARSHAL_U16LE(ctx, out->stat.file_name.len); - UNMARSHAL_BYTES(ctx, out->stat.file_name.utf8, out->stat.file_name.len); - UNMARSHAL_U16LE(ctx, out->stat.file_owner_uid.len); - UNMARSHAL_BYTES(ctx, out->stat.file_owner_uid.utf8, out->stat.file_owner_uid.len); - UNMARSHAL_U16LE(ctx, out->stat.file_owner_gid.len); - UNMARSHAL_BYTES(ctx, out->stat.file_owner_gid.utf8, out->stat.file_owner_gid.len); - UNMARSHAL_U16LE(ctx, out->stat.file_last_modified_uid.len); - UNMARSHAL_BYTES(ctx, out->stat.file_last_modified_uid.utf8, out->stat.file_last_modified_uid.len); -#if CONFIG_9P_ENABLE_9P2000_u - if (is_ver(ctx, 9P2000_u)) { - UNMARSHAL_U16LE(ctx, out->stat.file_extension.len); - UNMARSHAL_BYTES(ctx, out->stat.file_extension.utf8, out->stat.file_extension.len); - UNMARSHAL_U32LE(ctx, out->stat.file_owner_n_uid); - UNMARSHAL_U32LE(ctx, out->stat.file_owner_n_gid); - UNMARSHAL_U32LE(ctx, out->stat.file_last_modified_n_uid); - } -#endif /* CONFIG_9P_ENABLE_9P2000_u */ -} - -static void unmarshal_Twstat([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Twstat *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->fid); - net_offset += 2; - net_offset += 2; - UNMARSHAL_U16LE(ctx, out->stat.kern_type); - UNMARSHAL_U32LE(ctx, out->stat.kern_dev); - UNMARSHAL_U8LE(ctx, out->stat.file_qid.type); - UNMARSHAL_U32LE(ctx, out->stat.file_qid.vers); - UNMARSHAL_U64LE(ctx, out->stat.file_qid.path); - UNMARSHAL_U32LE(ctx, out->stat.file_mode); - UNMARSHAL_U32LE(ctx, out->stat.file_atime); - UNMARSHAL_U32LE(ctx, out->stat.file_mtime); - UNMARSHAL_U64LE(ctx, out->stat.file_size); - UNMARSHAL_U16LE(ctx, out->stat.file_name.len); - UNMARSHAL_BYTES(ctx, out->stat.file_name.utf8, out->stat.file_name.len); - UNMARSHAL_U16LE(ctx, out->stat.file_owner_uid.len); - UNMARSHAL_BYTES(ctx, out->stat.file_owner_uid.utf8, out->stat.file_owner_uid.len); - UNMARSHAL_U16LE(ctx, out->stat.file_owner_gid.len); - UNMARSHAL_BYTES(ctx, out->stat.file_owner_gid.utf8, out->stat.file_owner_gid.len); - UNMARSHAL_U16LE(ctx, out->stat.file_last_modified_uid.len); - UNMARSHAL_BYTES(ctx, out->stat.file_last_modified_uid.utf8, out->stat.file_last_modified_uid.len); -#if CONFIG_9P_ENABLE_9P2000_u - if (is_ver(ctx, 9P2000_u)) { - UNMARSHAL_U16LE(ctx, out->stat.file_extension.len); - UNMARSHAL_BYTES(ctx, out->stat.file_extension.utf8, out->stat.file_extension.len); - UNMARSHAL_U32LE(ctx, out->stat.file_owner_n_uid); - UNMARSHAL_U32LE(ctx, out->stat.file_owner_n_gid); - UNMARSHAL_U32LE(ctx, out->stat.file_last_modified_n_uid); - } -#endif /* CONFIG_9P_ENABLE_9P2000_u */ -} - -static void unmarshal_Rwstat([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rwstat *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); -} - -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000_p9p -static void unmarshal_Topenfd([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Topenfd *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->fid); - UNMARSHAL_U8LE(ctx, out->mode); -} - -static void unmarshal_Ropenfd([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Ropenfd *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U8LE(ctx, out->qid.type); - UNMARSHAL_U32LE(ctx, out->qid.vers); - UNMARSHAL_U64LE(ctx, out->qid.path); - UNMARSHAL_U32LE(ctx, out->iounit); - UNMARSHAL_U32LE(ctx, out->unixfd); -} - -#endif /* CONFIG_9P_ENABLE_9P2000_p9p */ -#if CONFIG_9P_ENABLE_9P2000_L -static void unmarshal_Rlerror([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rlerror *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->ecode); -} - -static void unmarshal_Tstatfs([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Tstatfs *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->fid); -} - -static void unmarshal_Rstatfs([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rstatfs *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->type); - UNMARSHAL_U32LE(ctx, out->bsize); - UNMARSHAL_U64LE(ctx, out->blocks); - UNMARSHAL_U64LE(ctx, out->bfree); - UNMARSHAL_U64LE(ctx, out->bavail); - UNMARSHAL_U64LE(ctx, out->files); - UNMARSHAL_U64LE(ctx, out->ffree); - UNMARSHAL_U64LE(ctx, out->fsid); - UNMARSHAL_U32LE(ctx, out->namelen); -} - -static void unmarshal_Tlopen([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Tlopen *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->fid); - UNMARSHAL_U32LE(ctx, out->flags); -} - -static void unmarshal_Rlopen([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rlopen *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U8LE(ctx, out->qid.type); - UNMARSHAL_U32LE(ctx, out->qid.vers); - UNMARSHAL_U64LE(ctx, out->qid.path); - UNMARSHAL_U32LE(ctx, out->iounit); -} - -static void unmarshal_Tlcreate([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Tlcreate *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->fid); - UNMARSHAL_U16LE(ctx, out->name.len); - UNMARSHAL_BYTES(ctx, out->name.utf8, out->name.len); - UNMARSHAL_U32LE(ctx, out->flags); - UNMARSHAL_U32LE(ctx, out->mode); - UNMARSHAL_U32LE(ctx, out->gid); -} - -static void unmarshal_Rlcreate([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rlcreate *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U8LE(ctx, out->qid.type); - UNMARSHAL_U32LE(ctx, out->qid.vers); - UNMARSHAL_U64LE(ctx, out->qid.path); - UNMARSHAL_U32LE(ctx, out->iounit); -} - -static void unmarshal_Tsymlink([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Tsymlink *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->fid); - UNMARSHAL_U16LE(ctx, out->name.len); - UNMARSHAL_BYTES(ctx, out->name.utf8, out->name.len); - UNMARSHAL_U16LE(ctx, out->symtgt.len); - UNMARSHAL_BYTES(ctx, out->symtgt.utf8, out->symtgt.len); - UNMARSHAL_U32LE(ctx, out->gid); -} - -static void unmarshal_Rsymlink([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rsymlink *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U8LE(ctx, out->qid.type); - UNMARSHAL_U32LE(ctx, out->qid.vers); - UNMARSHAL_U64LE(ctx, out->qid.path); -} - -static void unmarshal_Tmknod([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Tmknod *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->dfid); - UNMARSHAL_U16LE(ctx, out->name.len); - UNMARSHAL_BYTES(ctx, out->name.utf8, out->name.len); - UNMARSHAL_U32LE(ctx, out->mode); - UNMARSHAL_U32LE(ctx, out->major); - UNMARSHAL_U32LE(ctx, out->minor); - UNMARSHAL_U32LE(ctx, out->gid); -} - -static void unmarshal_Rmknod([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rmknod *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U8LE(ctx, out->qid.type); - UNMARSHAL_U32LE(ctx, out->qid.vers); - UNMARSHAL_U64LE(ctx, out->qid.path); -} - -static void unmarshal_Trename([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Trename *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->fid); - UNMARSHAL_U32LE(ctx, out->dfid); - UNMARSHAL_U16LE(ctx, out->name.len); - UNMARSHAL_BYTES(ctx, out->name.utf8, out->name.len); -} - -static void unmarshal_Rrename([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rrename *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); -} - -static void unmarshal_Treadlink([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Treadlink *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->fid); -} - -static void unmarshal_Rreadlink([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rreadlink *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U16LE(ctx, out->target.len); - UNMARSHAL_BYTES(ctx, out->target.utf8, out->target.len); -} - -static void unmarshal_Tgetattr([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Tgetattr *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->fid); - UNMARSHAL_U64LE(ctx, out->request_mask); -} - -static void unmarshal_Rgetattr([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rgetattr *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U64LE(ctx, out->valid); - UNMARSHAL_U8LE(ctx, out->qid.type); - UNMARSHAL_U32LE(ctx, out->qid.vers); - UNMARSHAL_U64LE(ctx, out->qid.path); - UNMARSHAL_U32LE(ctx, out->mode); - UNMARSHAL_U32LE(ctx, out->uid); - UNMARSHAL_U32LE(ctx, out->gid); - UNMARSHAL_U64LE(ctx, out->nlink); - UNMARSHAL_U64LE(ctx, out->rdev); - UNMARSHAL_U64LE(ctx, out->filesize); - UNMARSHAL_U64LE(ctx, out->blksize); - UNMARSHAL_U64LE(ctx, out->blocks); - UNMARSHAL_U64LE(ctx, out->atime_sec); - UNMARSHAL_U64LE(ctx, out->atime_nsec); - UNMARSHAL_U64LE(ctx, out->mtime_sec); - UNMARSHAL_U64LE(ctx, out->mtime_nsec); - UNMARSHAL_U64LE(ctx, out->ctime_sec); - UNMARSHAL_U64LE(ctx, out->ctime_nsec); - UNMARSHAL_U64LE(ctx, out->btime_sec); - UNMARSHAL_U64LE(ctx, out->btime_nsec); - UNMARSHAL_U64LE(ctx, out->gen); - UNMARSHAL_U64LE(ctx, out->data_version); -} - -static void unmarshal_Tsetattr([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Tsetattr *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->fid); - UNMARSHAL_U32LE(ctx, out->valid); - UNMARSHAL_U32LE(ctx, out->mode); - UNMARSHAL_U32LE(ctx, out->uid); - UNMARSHAL_U32LE(ctx, out->gid); - UNMARSHAL_U64LE(ctx, out->filesize); - UNMARSHAL_U64LE(ctx, out->atime_sec); - UNMARSHAL_U64LE(ctx, out->atime_nsec); - UNMARSHAL_U64LE(ctx, out->mtime_sec); - UNMARSHAL_U64LE(ctx, out->mtime_nsec); -} - -static void unmarshal_Rsetattr([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rsetattr *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); -} - -static void unmarshal_Txattrwalk([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Txattrwalk *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->fid); - UNMARSHAL_U32LE(ctx, out->newfid); - UNMARSHAL_U16LE(ctx, out->name.len); - UNMARSHAL_BYTES(ctx, out->name.utf8, out->name.len); -} - -static void unmarshal_Rxattrwalk([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rxattrwalk *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U64LE(ctx, out->attr_size); -} - -static void unmarshal_Txattrcreate([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Txattrcreate *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->fid); - UNMARSHAL_U16LE(ctx, out->name.len); - UNMARSHAL_BYTES(ctx, out->name.utf8, out->name.len); - UNMARSHAL_U64LE(ctx, out->attr_size); - UNMARSHAL_U32LE(ctx, out->flags); -} - -static void unmarshal_Rxattrcreate([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rxattrcreate *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); -} - -static void unmarshal_Treaddir([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Treaddir *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->fid); - UNMARSHAL_U64LE(ctx, out->offset); - UNMARSHAL_U32LE(ctx, out->count); -} - -static void unmarshal_Rreaddir([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rreaddir *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->count); - UNMARSHAL_BYTES(ctx, out->data, out->count); -} - -static void unmarshal_Tfsync([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Tfsync *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->fid); - UNMARSHAL_U32LE(ctx, out->datasync); -} - -static void unmarshal_Rfsync([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rfsync *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); -} - -static void unmarshal_Tlock([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Tlock *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->fid); - UNMARSHAL_U8LE(ctx, out->type); - UNMARSHAL_U32LE(ctx, out->flags); - UNMARSHAL_U64LE(ctx, out->start); - UNMARSHAL_U64LE(ctx, out->length); - UNMARSHAL_U32LE(ctx, out->proc_id); - UNMARSHAL_U16LE(ctx, out->client_id.len); - UNMARSHAL_BYTES(ctx, out->client_id.utf8, out->client_id.len); -} - -static void unmarshal_Rlock([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rlock *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U8LE(ctx, out->status); -} - -static void unmarshal_Tgetlock([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Tgetlock *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->fid); - UNMARSHAL_U8LE(ctx, out->type); - UNMARSHAL_U64LE(ctx, out->start); - UNMARSHAL_U64LE(ctx, out->length); - UNMARSHAL_U32LE(ctx, out->proc_id); - UNMARSHAL_U16LE(ctx, out->client_id.len); - UNMARSHAL_BYTES(ctx, out->client_id.utf8, out->client_id.len); -} - -static void unmarshal_Rgetlock([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rgetlock *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U8LE(ctx, out->type); - UNMARSHAL_U64LE(ctx, out->start); - UNMARSHAL_U64LE(ctx, out->length); - UNMARSHAL_U32LE(ctx, out->proc_id); - UNMARSHAL_U16LE(ctx, out->client_id.len); - UNMARSHAL_BYTES(ctx, out->client_id.utf8, out->client_id.len); -} - -static void unmarshal_Tlink([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Tlink *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->dfid); - UNMARSHAL_U32LE(ctx, out->fid); - UNMARSHAL_U16LE(ctx, out->name.len); - UNMARSHAL_BYTES(ctx, out->name.utf8, out->name.len); -} - -static void unmarshal_Rlink([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rlink *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); -} - -static void unmarshal_Tmkdir([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Tmkdir *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->dfid); - UNMARSHAL_U16LE(ctx, out->name.len); - UNMARSHAL_BYTES(ctx, out->name.utf8, out->name.len); - UNMARSHAL_U32LE(ctx, out->mode); - UNMARSHAL_U32LE(ctx, out->gid); -} - -static void unmarshal_Rmkdir([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rmkdir *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U8LE(ctx, out->qid.type); - UNMARSHAL_U32LE(ctx, out->qid.vers); - UNMARSHAL_U64LE(ctx, out->qid.path); -} - -static void unmarshal_Trenameat([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Trenameat *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->olddirfid); - UNMARSHAL_U16LE(ctx, out->oldname.len); - UNMARSHAL_BYTES(ctx, out->oldname.utf8, out->oldname.len); - UNMARSHAL_U32LE(ctx, out->newdirfid); - UNMARSHAL_U16LE(ctx, out->newname.len); - UNMARSHAL_BYTES(ctx, out->newname.utf8, out->newname.len); -} - -static void unmarshal_Rrenameat([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rrenameat *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); -} - -static void unmarshal_Tunlinkat([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Tunlinkat *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->dirfd); - UNMARSHAL_U16LE(ctx, out->name.len); - UNMARSHAL_BYTES(ctx, out->name.utf8, out->name.len); - UNMARSHAL_U32LE(ctx, out->flags); -} - -static void unmarshal_Runlinkat([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Runlinkat *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); -} - -#endif /* CONFIG_9P_ENABLE_9P2000_L */ -#if CONFIG_9P_ENABLE_9P2000_e -static void unmarshal_Tsession([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Tsession *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U64LE(ctx, out->key); -} - -static void unmarshal_Rsession([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rsession *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); -} - -static void unmarshal_Tsread([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Tsread *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->fid); - UNMARSHAL_U16LE(ctx, out->nwname); - out->wname = extra; - extra += sizeof(out->wname[0]) * out->nwname; - for (uint16_t i = 0; i < out->nwname; i++) { - UNMARSHAL_U16LE(ctx, out->wname[i].len); - UNMARSHAL_BYTES(ctx, out->wname[i].utf8, out->wname[i].len); - } -} - -static void unmarshal_Rsread([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rsread *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->count); - UNMARSHAL_BYTES(ctx, out->data, out->count); -} - -static void unmarshal_Tswrite([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Tswrite *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->fid); - UNMARSHAL_U16LE(ctx, out->nwname); - out->wname = extra; - extra += sizeof(out->wname[0]) * out->nwname; - for (uint16_t i = 0; i < out->nwname; i++) { - UNMARSHAL_U16LE(ctx, out->wname[i].len); - UNMARSHAL_BYTES(ctx, out->wname[i].utf8, out->wname[i].len); - } - UNMARSHAL_U32LE(ctx, out->count); - UNMARSHAL_BYTES(ctx, out->data, out->count); -} - -static void unmarshal_Rswrite([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { - struct lib9p_msg_Rswrite *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; - uint32_t net_offset = 0; - net_offset += 4; - net_offset += 1; - UNMARSHAL_U16LE(ctx, out->tag); - UNMARSHAL_U32LE(ctx, out->count); -} -#endif /* CONFIG_9P_ENABLE_9P2000_e */ - -/* marshal_* ******************************************************************/ - -#define MARSHAL_BYTES_ZEROCOPY(ctx, data, len) \ - if (ret->net_iov[ret->net_iov_cnt-1].iov_len) \ - ret->net_iov_cnt++; \ - ret->net_iov[ret->net_iov_cnt-1].iov_base = data; \ - ret->net_iov[ret->net_iov_cnt-1].iov_len = len; \ - ret->net_iov_cnt++; -#define MARSHAL_BYTES(ctx, data, len) \ - if (!ret->net_iov[ret->net_iov_cnt-1].iov_base) \ - ret->net_iov[ret->net_iov_cnt-1].iov_base = &ret->net_copied[ret->net_copied_size]; \ - memcpy(&ret->net_copied[ret->net_copied_size], data, len); \ - ret->net_copied_size += len; \ - ret->net_iov[ret->net_iov_cnt-1].iov_len += len; -#define MARSHAL_U8LE(ctx, val) \ - if (!ret->net_iov[ret->net_iov_cnt-1].iov_base) \ - ret->net_iov[ret->net_iov_cnt-1].iov_base = &ret->net_copied[ret->net_copied_size]; \ - ret->net_copied[ret->net_copied_size] = val; \ - ret->net_copied_size += 1; \ - ret->net_iov[ret->net_iov_cnt-1].iov_len += 1; -#define MARSHAL_U16LE(ctx, val) \ - if (!ret->net_iov[ret->net_iov_cnt-1].iov_base) \ - ret->net_iov[ret->net_iov_cnt-1].iov_base = &ret->net_copied[ret->net_copied_size]; \ - uint16le_encode(&ret->net_copied[ret->net_copied_size], val); \ - ret->net_copied_size += 2; \ - ret->net_iov[ret->net_iov_cnt-1].iov_len += 2; -#define MARSHAL_U32LE(ctx, val) \ - if (!ret->net_iov[ret->net_iov_cnt-1].iov_base) \ - ret->net_iov[ret->net_iov_cnt-1].iov_base = &ret->net_copied[ret->net_copied_size]; \ - uint32le_encode(&ret->net_copied[ret->net_copied_size], val); \ - ret->net_copied_size += 4; \ - ret->net_iov[ret->net_iov_cnt-1].iov_len += 4; -#define MARSHAL_U64LE(ctx, val) \ - if (!ret->net_iov[ret->net_iov_cnt-1].iov_base) \ - ret->net_iov[ret->net_iov_cnt-1].iov_base = &ret->net_copied[ret->net_copied_size]; \ - uint64le_encode(&ret->net_copied[ret->net_copied_size], val); \ - ret->net_copied_size += 8; \ - ret->net_iov[ret->net_iov_cnt-1].iov_len += 8; - -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -static bool marshal_stat(struct lib9p_ctx *ctx, struct lib9p_stat *val, struct _marshal_ret *ret) { - uint32_t needed_size = 49 + val->file_name.len + val->file_owner_uid.len + val->file_owner_gid.len + val->file_last_modified_uid.len; -#if CONFIG_9P_ENABLE_9P2000_u - if is_ver(ctx, 9P2000_u) { - needed_size += 14 + val->file_extension.len; - } -#endif /* CONFIG_9P_ENABLE_9P2000_u */ - if (needed_size > ctx->max_msg_size) { - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_kern_type = 2; - MARSHAL_U16LE(ctx, offsetof_end - offsetof_kern_type); - MARSHAL_U16LE(ctx, val->kern_type); - MARSHAL_U32LE(ctx, val->kern_dev); - MARSHAL_U8LE(ctx, val->file_qid.type & qt_masks[ctx->version]); - MARSHAL_U32LE(ctx, val->file_qid.vers); - MARSHAL_U64LE(ctx, val->file_qid.path); - MARSHAL_U32LE(ctx, val->file_mode & dm_masks[ctx->version]); - MARSHAL_U32LE(ctx, val->file_atime); - MARSHAL_U32LE(ctx, val->file_mtime); - MARSHAL_U64LE(ctx, val->file_size); - MARSHAL_U16LE(ctx, val->file_name.len); - MARSHAL_BYTES(ctx, val->file_name.utf8, val->file_name.len); - MARSHAL_U16LE(ctx, val->file_owner_uid.len); - MARSHAL_BYTES(ctx, val->file_owner_uid.utf8, val->file_owner_uid.len); - MARSHAL_U16LE(ctx, val->file_owner_gid.len); - MARSHAL_BYTES(ctx, val->file_owner_gid.utf8, val->file_owner_gid.len); - MARSHAL_U16LE(ctx, val->file_last_modified_uid.len); - MARSHAL_BYTES(ctx, val->file_last_modified_uid.utf8, val->file_last_modified_uid.len); -#if CONFIG_9P_ENABLE_9P2000_u - if (is_ver(ctx, 9P2000_u)) { - MARSHAL_U16LE(ctx, val->file_extension.len); - MARSHAL_BYTES(ctx, val->file_extension.utf8, val->file_extension.len); - MARSHAL_U32LE(ctx, val->file_owner_n_uid); - MARSHAL_U32LE(ctx, val->file_owner_n_gid); - MARSHAL_U32LE(ctx, val->file_last_modified_n_uid); - } -#endif /* CONFIG_9P_ENABLE_9P2000_u */ - return false; -} - -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -static bool marshal_Tversion(struct lib9p_ctx *ctx, struct lib9p_msg_Tversion *val, struct _marshal_ret *ret) { - uint32_t needed_size = 13 + val->version.len; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Tversion", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 100); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->max_msg_size); - MARSHAL_U16LE(ctx, val->version.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->version.utf8, val->version.len); - return false; -} - -static bool marshal_Rversion(struct lib9p_ctx *ctx, struct lib9p_msg_Rversion *val, struct _marshal_ret *ret) { - uint32_t needed_size = 13 + val->version.len; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rversion", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 101); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->max_msg_size); - MARSHAL_U16LE(ctx, val->version.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->version.utf8, val->version.len); - return false; -} - -static bool marshal_Tauth(struct lib9p_ctx *ctx, struct lib9p_msg_Tauth *val, struct _marshal_ret *ret) { - uint32_t needed_size = 15 + val->uname.len + val->aname.len; -#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u - if ( is_ver(ctx, 9P2000_L) || is_ver(ctx, 9P2000_u) ) { - needed_size += 4; - } -#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Tauth", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 102); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->afid); - MARSHAL_U16LE(ctx, val->uname.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->uname.utf8, val->uname.len); - MARSHAL_U16LE(ctx, val->aname.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->aname.utf8, val->aname.len); -#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u - if (( is_ver(ctx, 9P2000_L) || is_ver(ctx, 9P2000_u) )) { - MARSHAL_U32LE(ctx, val->n_uid); - } -#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ - return false; -} - -static bool marshal_Rauth(struct lib9p_ctx *ctx, struct lib9p_msg_Rauth *val, struct _marshal_ret *ret) { - uint32_t needed_size = 20; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rauth", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 103); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U8LE(ctx, val->aqid.type & qt_masks[ctx->version]); - MARSHAL_U32LE(ctx, val->aqid.vers); - MARSHAL_U64LE(ctx, val->aqid.path); - return false; -} - -static bool marshal_Tattach(struct lib9p_ctx *ctx, struct lib9p_msg_Tattach *val, struct _marshal_ret *ret) { - uint32_t needed_size = 19 + val->uname.len + val->aname.len; -#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u - if ( is_ver(ctx, 9P2000_L) || is_ver(ctx, 9P2000_u) ) { - needed_size += 4; - } -#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Tattach", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 104); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->fid); - MARSHAL_U32LE(ctx, val->afid); - MARSHAL_U16LE(ctx, val->uname.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->uname.utf8, val->uname.len); - MARSHAL_U16LE(ctx, val->aname.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->aname.utf8, val->aname.len); -#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u - if (( is_ver(ctx, 9P2000_L) || is_ver(ctx, 9P2000_u) )) { - MARSHAL_U32LE(ctx, val->n_uid); - } -#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ - return false; -} - -static bool marshal_Rattach(struct lib9p_ctx *ctx, struct lib9p_msg_Rattach *val, struct _marshal_ret *ret) { - uint32_t needed_size = 20; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rattach", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 105); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U8LE(ctx, val->qid.type & qt_masks[ctx->version]); - MARSHAL_U32LE(ctx, val->qid.vers); - MARSHAL_U64LE(ctx, val->qid.path); - return false; -} - -static bool marshal_Rerror(struct lib9p_ctx *ctx, struct lib9p_msg_Rerror *val, struct _marshal_ret *ret) { - uint32_t needed_size = 9 + val->ename.len; -#if CONFIG_9P_ENABLE_9P2000_u - if is_ver(ctx, 9P2000_u) { - needed_size += 4; - } -#endif /* CONFIG_9P_ENABLE_9P2000_u */ - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rerror", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 107); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U16LE(ctx, val->ename.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->ename.utf8, val->ename.len); -#if CONFIG_9P_ENABLE_9P2000_u - if (is_ver(ctx, 9P2000_u)) { - MARSHAL_U32LE(ctx, val->errno); - } -#endif /* CONFIG_9P_ENABLE_9P2000_u */ - return false; -} - -static bool marshal_Tflush(struct lib9p_ctx *ctx, struct lib9p_msg_Tflush *val, struct _marshal_ret *ret) { - uint32_t needed_size = 9; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Tflush", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 108); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U16LE(ctx, val->oldtag); - return false; -} - -static bool marshal_Rflush(struct lib9p_ctx *ctx, struct lib9p_msg_Rflush *val, struct _marshal_ret *ret) { - uint32_t needed_size = 7; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rflush", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 109); - MARSHAL_U16LE(ctx, val->tag); - return false; -} - -static bool marshal_Twalk(struct lib9p_ctx *ctx, struct lib9p_msg_Twalk *val, struct _marshal_ret *ret) { - uint32_t needed_size = 17; - for (uint16_t i = 0; i < val->nwname; i++) { - needed_size += 2 + val->wname[i].len; - } - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Twalk", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 110); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->fid); - MARSHAL_U32LE(ctx, val->newfid); - MARSHAL_U16LE(ctx, val->nwname); - for (uint16_t i = 0; i < val->nwname; i++) { - MARSHAL_U16LE(ctx, val->wname[i].len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->wname[i].utf8, val->wname[i].len); - } - return false; -} - -static bool marshal_Rwalk(struct lib9p_ctx *ctx, struct lib9p_msg_Rwalk *val, struct _marshal_ret *ret) { - uint32_t needed_size = 9 + (val->nwqid)*13; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rwalk", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 111); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U16LE(ctx, val->nwqid); - for (uint16_t i = 0; i < val->nwqid; i++) { - MARSHAL_U8LE(ctx, val->wqid[i].type & qt_masks[ctx->version]); - MARSHAL_U32LE(ctx, val->wqid[i].vers); - MARSHAL_U64LE(ctx, val->wqid[i].path); - } - return false; -} - -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -static bool marshal_Topen(struct lib9p_ctx *ctx, struct lib9p_msg_Topen *val, struct _marshal_ret *ret) { - uint32_t needed_size = 12; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Topen", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 112); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->fid); - MARSHAL_U8LE(ctx, val->mode & o_masks[ctx->version]); - return false; -} - -static bool marshal_Ropen(struct lib9p_ctx *ctx, struct lib9p_msg_Ropen *val, struct _marshal_ret *ret) { - uint32_t needed_size = 24; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Ropen", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 113); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U8LE(ctx, val->qid.type & qt_masks[ctx->version]); - MARSHAL_U32LE(ctx, val->qid.vers); - MARSHAL_U64LE(ctx, val->qid.path); - MARSHAL_U32LE(ctx, val->iounit); - return false; -} - -static bool marshal_Tcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Tcreate *val, struct _marshal_ret *ret) { - uint32_t needed_size = 18 + val->name.len; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Tcreate", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 114); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->fid); - MARSHAL_U16LE(ctx, val->name.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->name.utf8, val->name.len); - MARSHAL_U32LE(ctx, val->perm & dm_masks[ctx->version]); - MARSHAL_U8LE(ctx, val->mode & o_masks[ctx->version]); - return false; -} - -static bool marshal_Rcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Rcreate *val, struct _marshal_ret *ret) { - uint32_t needed_size = 24; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rcreate", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 115); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U8LE(ctx, val->qid.type & qt_masks[ctx->version]); - MARSHAL_U32LE(ctx, val->qid.vers); - MARSHAL_U64LE(ctx, val->qid.path); - MARSHAL_U32LE(ctx, val->iounit); - return false; -} - -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -static bool marshal_Tread(struct lib9p_ctx *ctx, struct lib9p_msg_Tread *val, struct _marshal_ret *ret) { - uint32_t needed_size = 23; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Tread", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 116); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->fid); - MARSHAL_U64LE(ctx, val->offset); - MARSHAL_U32LE(ctx, val->count); - return false; -} - -static bool marshal_Rread(struct lib9p_ctx *ctx, struct lib9p_msg_Rread *val, struct _marshal_ret *ret) { - uint32_t needed_size = 11 + val->count; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rread", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 117); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->count); - MARSHAL_BYTES_ZEROCOPY(ctx, val->data, val->count); - return false; -} - -static bool marshal_Twrite(struct lib9p_ctx *ctx, struct lib9p_msg_Twrite *val, struct _marshal_ret *ret) { - uint32_t needed_size = 23 + val->count; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Twrite", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 118); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->fid); - MARSHAL_U64LE(ctx, val->offset); - MARSHAL_U32LE(ctx, val->count); - MARSHAL_BYTES_ZEROCOPY(ctx, val->data, val->count); - return false; -} - -static bool marshal_Rwrite(struct lib9p_ctx *ctx, struct lib9p_msg_Rwrite *val, struct _marshal_ret *ret) { - uint32_t needed_size = 11; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rwrite", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 119); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->count); - return false; -} - -static bool marshal_Tclunk(struct lib9p_ctx *ctx, struct lib9p_msg_Tclunk *val, struct _marshal_ret *ret) { - uint32_t needed_size = 11; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Tclunk", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 120); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->fid); - return false; -} - -static bool marshal_Rclunk(struct lib9p_ctx *ctx, struct lib9p_msg_Rclunk *val, struct _marshal_ret *ret) { - uint32_t needed_size = 7; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rclunk", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 121); - MARSHAL_U16LE(ctx, val->tag); - return false; -} - -static bool marshal_Tremove(struct lib9p_ctx *ctx, struct lib9p_msg_Tremove *val, struct _marshal_ret *ret) { - uint32_t needed_size = 11; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Tremove", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 122); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->fid); - return false; -} - -static bool marshal_Rremove(struct lib9p_ctx *ctx, struct lib9p_msg_Rremove *val, struct _marshal_ret *ret) { - uint32_t needed_size = 7; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rremove", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 123); - MARSHAL_U16LE(ctx, val->tag); - return false; -} - -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -static bool marshal_Tstat(struct lib9p_ctx *ctx, struct lib9p_msg_Tstat *val, struct _marshal_ret *ret) { - uint32_t needed_size = 11; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Tstat", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 124); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->fid); - return false; -} - -static bool marshal_Rstat(struct lib9p_ctx *ctx, struct lib9p_msg_Rstat *val, struct _marshal_ret *ret) { - uint32_t needed_size = 58 + val->stat.file_name.len + val->stat.file_owner_uid.len + val->stat.file_owner_gid.len + val->stat.file_last_modified_uid.len; -#if CONFIG_9P_ENABLE_9P2000_u - if is_ver(ctx, 9P2000_u) { - needed_size += 14 + val->stat.file_extension.len; - } -#endif /* CONFIG_9P_ENABLE_9P2000_u */ - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rstat", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - uint32_t offsetof_stat = 9; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 125); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U16LE(ctx, offsetof_end - offsetof_stat); - uint32_t offsetof_stat_end = 49 + val->stat.file_name.len + val->stat.file_owner_uid.len + val->stat.file_owner_gid.len + val->stat.file_last_modified_uid.len; -#if CONFIG_9P_ENABLE_9P2000_u - if is_ver(ctx, 9P2000_u) { - offsetof_stat_end += 14 + val->stat.file_extension.len; - } -#endif /* CONFIG_9P_ENABLE_9P2000_u */ - uint32_t offsetof_stat_kern_type = 2; - MARSHAL_U16LE(ctx, offsetof_stat_end - offsetof_stat_kern_type); - MARSHAL_U16LE(ctx, val->stat.kern_type); - MARSHAL_U32LE(ctx, val->stat.kern_dev); - MARSHAL_U8LE(ctx, val->stat.file_qid.type & qt_masks[ctx->version]); - MARSHAL_U32LE(ctx, val->stat.file_qid.vers); - MARSHAL_U64LE(ctx, val->stat.file_qid.path); - MARSHAL_U32LE(ctx, val->stat.file_mode & dm_masks[ctx->version]); - MARSHAL_U32LE(ctx, val->stat.file_atime); - MARSHAL_U32LE(ctx, val->stat.file_mtime); - MARSHAL_U64LE(ctx, val->stat.file_size); - MARSHAL_U16LE(ctx, val->stat.file_name.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.file_name.utf8, val->stat.file_name.len); - MARSHAL_U16LE(ctx, val->stat.file_owner_uid.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.file_owner_uid.utf8, val->stat.file_owner_uid.len); - MARSHAL_U16LE(ctx, val->stat.file_owner_gid.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.file_owner_gid.utf8, val->stat.file_owner_gid.len); - MARSHAL_U16LE(ctx, val->stat.file_last_modified_uid.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.file_last_modified_uid.utf8, val->stat.file_last_modified_uid.len); -#if CONFIG_9P_ENABLE_9P2000_u - if (is_ver(ctx, 9P2000_u)) { - MARSHAL_U16LE(ctx, val->stat.file_extension.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.file_extension.utf8, val->stat.file_extension.len); - MARSHAL_U32LE(ctx, val->stat.file_owner_n_uid); - MARSHAL_U32LE(ctx, val->stat.file_owner_n_gid); - MARSHAL_U32LE(ctx, val->stat.file_last_modified_n_uid); - } -#endif /* CONFIG_9P_ENABLE_9P2000_u */ - return false; -} - -static bool marshal_Twstat(struct lib9p_ctx *ctx, struct lib9p_msg_Twstat *val, struct _marshal_ret *ret) { - uint32_t needed_size = 62 + val->stat.file_name.len + val->stat.file_owner_uid.len + val->stat.file_owner_gid.len + val->stat.file_last_modified_uid.len; -#if CONFIG_9P_ENABLE_9P2000_u - if is_ver(ctx, 9P2000_u) { - needed_size += 14 + val->stat.file_extension.len; - } -#endif /* CONFIG_9P_ENABLE_9P2000_u */ - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Twstat", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - uint32_t offsetof_stat = 13; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 126); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->fid); - MARSHAL_U16LE(ctx, offsetof_end - offsetof_stat); - uint32_t offsetof_stat_end = 49 + val->stat.file_name.len + val->stat.file_owner_uid.len + val->stat.file_owner_gid.len + val->stat.file_last_modified_uid.len; -#if CONFIG_9P_ENABLE_9P2000_u - if is_ver(ctx, 9P2000_u) { - offsetof_stat_end += 14 + val->stat.file_extension.len; - } -#endif /* CONFIG_9P_ENABLE_9P2000_u */ - uint32_t offsetof_stat_kern_type = 2; - MARSHAL_U16LE(ctx, offsetof_stat_end - offsetof_stat_kern_type); - MARSHAL_U16LE(ctx, val->stat.kern_type); - MARSHAL_U32LE(ctx, val->stat.kern_dev); - MARSHAL_U8LE(ctx, val->stat.file_qid.type & qt_masks[ctx->version]); - MARSHAL_U32LE(ctx, val->stat.file_qid.vers); - MARSHAL_U64LE(ctx, val->stat.file_qid.path); - MARSHAL_U32LE(ctx, val->stat.file_mode & dm_masks[ctx->version]); - MARSHAL_U32LE(ctx, val->stat.file_atime); - MARSHAL_U32LE(ctx, val->stat.file_mtime); - MARSHAL_U64LE(ctx, val->stat.file_size); - MARSHAL_U16LE(ctx, val->stat.file_name.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.file_name.utf8, val->stat.file_name.len); - MARSHAL_U16LE(ctx, val->stat.file_owner_uid.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.file_owner_uid.utf8, val->stat.file_owner_uid.len); - MARSHAL_U16LE(ctx, val->stat.file_owner_gid.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.file_owner_gid.utf8, val->stat.file_owner_gid.len); - MARSHAL_U16LE(ctx, val->stat.file_last_modified_uid.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.file_last_modified_uid.utf8, val->stat.file_last_modified_uid.len); -#if CONFIG_9P_ENABLE_9P2000_u - if (is_ver(ctx, 9P2000_u)) { - MARSHAL_U16LE(ctx, val->stat.file_extension.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.file_extension.utf8, val->stat.file_extension.len); - MARSHAL_U32LE(ctx, val->stat.file_owner_n_uid); - MARSHAL_U32LE(ctx, val->stat.file_owner_n_gid); - MARSHAL_U32LE(ctx, val->stat.file_last_modified_n_uid); - } -#endif /* CONFIG_9P_ENABLE_9P2000_u */ - return false; -} - -static bool marshal_Rwstat(struct lib9p_ctx *ctx, struct lib9p_msg_Rwstat *val, struct _marshal_ret *ret) { - uint32_t needed_size = 7; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rwstat", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 127); - MARSHAL_U16LE(ctx, val->tag); - return false; -} - -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000_p9p -static bool marshal_Topenfd(struct lib9p_ctx *ctx, struct lib9p_msg_Topenfd *val, struct _marshal_ret *ret) { - uint32_t needed_size = 12; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Topenfd", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 98); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->fid); - MARSHAL_U8LE(ctx, val->mode & o_masks[ctx->version]); - return false; -} - -static bool marshal_Ropenfd(struct lib9p_ctx *ctx, struct lib9p_msg_Ropenfd *val, struct _marshal_ret *ret) { - uint32_t needed_size = 28; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Ropenfd", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 99); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U8LE(ctx, val->qid.type & qt_masks[ctx->version]); - MARSHAL_U32LE(ctx, val->qid.vers); - MARSHAL_U64LE(ctx, val->qid.path); - MARSHAL_U32LE(ctx, val->iounit); - MARSHAL_U32LE(ctx, val->unixfd); - return false; -} - -#endif /* CONFIG_9P_ENABLE_9P2000_p9p */ -#if CONFIG_9P_ENABLE_9P2000_L -static bool marshal_Rlerror(struct lib9p_ctx *ctx, struct lib9p_msg_Rlerror *val, struct _marshal_ret *ret) { - uint32_t needed_size = 11; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rlerror", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 7); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->ecode); - return false; -} - -static bool marshal_Tstatfs(struct lib9p_ctx *ctx, struct lib9p_msg_Tstatfs *val, struct _marshal_ret *ret) { - uint32_t needed_size = 11; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Tstatfs", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 8); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->fid); - return false; -} - -static bool marshal_Rstatfs(struct lib9p_ctx *ctx, struct lib9p_msg_Rstatfs *val, struct _marshal_ret *ret) { - uint32_t needed_size = 67; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rstatfs", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 9); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->type); - MARSHAL_U32LE(ctx, val->bsize); - MARSHAL_U64LE(ctx, val->blocks); - MARSHAL_U64LE(ctx, val->bfree); - MARSHAL_U64LE(ctx, val->bavail); - MARSHAL_U64LE(ctx, val->files); - MARSHAL_U64LE(ctx, val->ffree); - MARSHAL_U64LE(ctx, val->fsid); - MARSHAL_U32LE(ctx, val->namelen); - return false; -} - -static bool marshal_Tlopen(struct lib9p_ctx *ctx, struct lib9p_msg_Tlopen *val, struct _marshal_ret *ret) { - uint32_t needed_size = 15; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Tlopen", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 12); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->fid); - MARSHAL_U32LE(ctx, val->flags & lo_masks[ctx->version]); - return false; -} - -static bool marshal_Rlopen(struct lib9p_ctx *ctx, struct lib9p_msg_Rlopen *val, struct _marshal_ret *ret) { - uint32_t needed_size = 24; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rlopen", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 13); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U8LE(ctx, val->qid.type & qt_masks[ctx->version]); - MARSHAL_U32LE(ctx, val->qid.vers); - MARSHAL_U64LE(ctx, val->qid.path); - MARSHAL_U32LE(ctx, val->iounit); - return false; -} - -static bool marshal_Tlcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Tlcreate *val, struct _marshal_ret *ret) { - uint32_t needed_size = 25 + val->name.len; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Tlcreate", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 14); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->fid); - MARSHAL_U16LE(ctx, val->name.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->name.utf8, val->name.len); - MARSHAL_U32LE(ctx, val->flags & lo_masks[ctx->version]); - MARSHAL_U32LE(ctx, val->mode & mode_masks[ctx->version]); - MARSHAL_U32LE(ctx, val->gid); - return false; -} - -static bool marshal_Rlcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Rlcreate *val, struct _marshal_ret *ret) { - uint32_t needed_size = 24; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rlcreate", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 15); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U8LE(ctx, val->qid.type & qt_masks[ctx->version]); - MARSHAL_U32LE(ctx, val->qid.vers); - MARSHAL_U64LE(ctx, val->qid.path); - MARSHAL_U32LE(ctx, val->iounit); - return false; -} - -static bool marshal_Tsymlink(struct lib9p_ctx *ctx, struct lib9p_msg_Tsymlink *val, struct _marshal_ret *ret) { - uint32_t needed_size = 19 + val->name.len + val->symtgt.len; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Tsymlink", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 16); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->fid); - MARSHAL_U16LE(ctx, val->name.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->name.utf8, val->name.len); - MARSHAL_U16LE(ctx, val->symtgt.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->symtgt.utf8, val->symtgt.len); - MARSHAL_U32LE(ctx, val->gid); - return false; -} - -static bool marshal_Rsymlink(struct lib9p_ctx *ctx, struct lib9p_msg_Rsymlink *val, struct _marshal_ret *ret) { - uint32_t needed_size = 20; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rsymlink", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 17); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U8LE(ctx, val->qid.type & qt_masks[ctx->version]); - MARSHAL_U32LE(ctx, val->qid.vers); - MARSHAL_U64LE(ctx, val->qid.path); - return false; -} - -static bool marshal_Tmknod(struct lib9p_ctx *ctx, struct lib9p_msg_Tmknod *val, struct _marshal_ret *ret) { - uint32_t needed_size = 29 + val->name.len; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Tmknod", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 18); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->dfid); - MARSHAL_U16LE(ctx, val->name.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->name.utf8, val->name.len); - MARSHAL_U32LE(ctx, val->mode & mode_masks[ctx->version]); - MARSHAL_U32LE(ctx, val->major); - MARSHAL_U32LE(ctx, val->minor); - MARSHAL_U32LE(ctx, val->gid); - return false; -} - -static bool marshal_Rmknod(struct lib9p_ctx *ctx, struct lib9p_msg_Rmknod *val, struct _marshal_ret *ret) { - uint32_t needed_size = 20; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rmknod", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 19); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U8LE(ctx, val->qid.type & qt_masks[ctx->version]); - MARSHAL_U32LE(ctx, val->qid.vers); - MARSHAL_U64LE(ctx, val->qid.path); - return false; -} - -static bool marshal_Trename(struct lib9p_ctx *ctx, struct lib9p_msg_Trename *val, struct _marshal_ret *ret) { - uint32_t needed_size = 17 + val->name.len; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Trename", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 20); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->fid); - MARSHAL_U32LE(ctx, val->dfid); - MARSHAL_U16LE(ctx, val->name.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->name.utf8, val->name.len); - return false; -} - -static bool marshal_Rrename(struct lib9p_ctx *ctx, struct lib9p_msg_Rrename *val, struct _marshal_ret *ret) { - uint32_t needed_size = 7; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rrename", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 21); - MARSHAL_U16LE(ctx, val->tag); - return false; -} - -static bool marshal_Treadlink(struct lib9p_ctx *ctx, struct lib9p_msg_Treadlink *val, struct _marshal_ret *ret) { - uint32_t needed_size = 11; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Treadlink", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 22); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->fid); - return false; -} - -static bool marshal_Rreadlink(struct lib9p_ctx *ctx, struct lib9p_msg_Rreadlink *val, struct _marshal_ret *ret) { - uint32_t needed_size = 9 + val->target.len; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rreadlink", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 23); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U16LE(ctx, val->target.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->target.utf8, val->target.len); - return false; -} - -static bool marshal_Tgetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Tgetattr *val, struct _marshal_ret *ret) { - uint32_t needed_size = 19; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Tgetattr", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 24); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->fid); - MARSHAL_U64LE(ctx, val->request_mask & getattr_masks[ctx->version]); - return false; -} - -static bool marshal_Rgetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Rgetattr *val, struct _marshal_ret *ret) { - uint32_t needed_size = 160; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rgetattr", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 25); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U64LE(ctx, val->valid & getattr_masks[ctx->version]); - MARSHAL_U8LE(ctx, val->qid.type & qt_masks[ctx->version]); - MARSHAL_U32LE(ctx, val->qid.vers); - MARSHAL_U64LE(ctx, val->qid.path); - MARSHAL_U32LE(ctx, val->mode & mode_masks[ctx->version]); - MARSHAL_U32LE(ctx, val->uid); - MARSHAL_U32LE(ctx, val->gid); - MARSHAL_U64LE(ctx, val->nlink); - MARSHAL_U64LE(ctx, val->rdev); - MARSHAL_U64LE(ctx, val->filesize); - MARSHAL_U64LE(ctx, val->blksize); - MARSHAL_U64LE(ctx, val->blocks); - MARSHAL_U64LE(ctx, val->atime_sec); - MARSHAL_U64LE(ctx, val->atime_nsec); - MARSHAL_U64LE(ctx, val->mtime_sec); - MARSHAL_U64LE(ctx, val->mtime_nsec); - MARSHAL_U64LE(ctx, val->ctime_sec); - MARSHAL_U64LE(ctx, val->ctime_nsec); - MARSHAL_U64LE(ctx, val->btime_sec); - MARSHAL_U64LE(ctx, val->btime_nsec); - MARSHAL_U64LE(ctx, val->gen); - MARSHAL_U64LE(ctx, val->data_version); - return false; -} - -static bool marshal_Tsetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Tsetattr *val, struct _marshal_ret *ret) { - uint32_t needed_size = 67; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Tsetattr", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 26); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->fid); - MARSHAL_U32LE(ctx, val->valid & setattr_masks[ctx->version]); - MARSHAL_U32LE(ctx, val->mode & mode_masks[ctx->version]); - MARSHAL_U32LE(ctx, val->uid); - MARSHAL_U32LE(ctx, val->gid); - MARSHAL_U64LE(ctx, val->filesize); - MARSHAL_U64LE(ctx, val->atime_sec); - MARSHAL_U64LE(ctx, val->atime_nsec); - MARSHAL_U64LE(ctx, val->mtime_sec); - MARSHAL_U64LE(ctx, val->mtime_nsec); - return false; -} - -static bool marshal_Rsetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Rsetattr *val, struct _marshal_ret *ret) { - uint32_t needed_size = 7; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rsetattr", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 27); - MARSHAL_U16LE(ctx, val->tag); - return false; -} - -static bool marshal_Txattrwalk(struct lib9p_ctx *ctx, struct lib9p_msg_Txattrwalk *val, struct _marshal_ret *ret) { - uint32_t needed_size = 17 + val->name.len; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Txattrwalk", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 30); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->fid); - MARSHAL_U32LE(ctx, val->newfid); - MARSHAL_U16LE(ctx, val->name.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->name.utf8, val->name.len); - return false; -} - -static bool marshal_Rxattrwalk(struct lib9p_ctx *ctx, struct lib9p_msg_Rxattrwalk *val, struct _marshal_ret *ret) { - uint32_t needed_size = 15; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rxattrwalk", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 31); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U64LE(ctx, val->attr_size); - return false; -} - -static bool marshal_Txattrcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Txattrcreate *val, struct _marshal_ret *ret) { - uint32_t needed_size = 25 + val->name.len; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Txattrcreate", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 32); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->fid); - MARSHAL_U16LE(ctx, val->name.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->name.utf8, val->name.len); - MARSHAL_U64LE(ctx, val->attr_size); - MARSHAL_U32LE(ctx, val->flags); - return false; -} - -static bool marshal_Rxattrcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Rxattrcreate *val, struct _marshal_ret *ret) { - uint32_t needed_size = 7; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rxattrcreate", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 33); - MARSHAL_U16LE(ctx, val->tag); - return false; -} - -static bool marshal_Treaddir(struct lib9p_ctx *ctx, struct lib9p_msg_Treaddir *val, struct _marshal_ret *ret) { - uint32_t needed_size = 23; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Treaddir", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 40); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->fid); - MARSHAL_U64LE(ctx, val->offset); - MARSHAL_U32LE(ctx, val->count); - return false; -} - -static bool marshal_Rreaddir(struct lib9p_ctx *ctx, struct lib9p_msg_Rreaddir *val, struct _marshal_ret *ret) { - uint64_t needed_size = 11 + val->count; - if (needed_size > (uint64_t)(ctx->max_msg_size)) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rreaddir", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = (uint32_t)needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 41); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->count); - MARSHAL_BYTES_ZEROCOPY(ctx, val->data, val->count); - return false; -} - -static bool marshal_Tfsync(struct lib9p_ctx *ctx, struct lib9p_msg_Tfsync *val, struct _marshal_ret *ret) { - uint32_t needed_size = 15; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Tfsync", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 50); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->fid); - MARSHAL_U32LE(ctx, val->datasync); - return false; -} - -static bool marshal_Rfsync(struct lib9p_ctx *ctx, struct lib9p_msg_Rfsync *val, struct _marshal_ret *ret) { - uint32_t needed_size = 7; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rfsync", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 51); - MARSHAL_U16LE(ctx, val->tag); - return false; -} - -static bool marshal_Tlock(struct lib9p_ctx *ctx, struct lib9p_msg_Tlock *val, struct _marshal_ret *ret) { - uint32_t needed_size = 38 + val->client_id.len; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Tlock", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 52); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->fid); - MARSHAL_U8LE(ctx, val->type); - MARSHAL_U32LE(ctx, val->flags & lock_flags_masks[ctx->version]); - MARSHAL_U64LE(ctx, val->start); - MARSHAL_U64LE(ctx, val->length); - MARSHAL_U32LE(ctx, val->proc_id); - MARSHAL_U16LE(ctx, val->client_id.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->client_id.utf8, val->client_id.len); - return false; -} - -static bool marshal_Rlock(struct lib9p_ctx *ctx, struct lib9p_msg_Rlock *val, struct _marshal_ret *ret) { - uint32_t needed_size = 8; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rlock", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 53); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U8LE(ctx, val->status); - return false; -} - -static bool marshal_Tgetlock(struct lib9p_ctx *ctx, struct lib9p_msg_Tgetlock *val, struct _marshal_ret *ret) { - uint32_t needed_size = 34 + val->client_id.len; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Tgetlock", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 54); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->fid); - MARSHAL_U8LE(ctx, val->type); - MARSHAL_U64LE(ctx, val->start); - MARSHAL_U64LE(ctx, val->length); - MARSHAL_U32LE(ctx, val->proc_id); - MARSHAL_U16LE(ctx, val->client_id.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->client_id.utf8, val->client_id.len); - return false; -} - -static bool marshal_Rgetlock(struct lib9p_ctx *ctx, struct lib9p_msg_Rgetlock *val, struct _marshal_ret *ret) { - uint32_t needed_size = 30 + val->client_id.len; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rgetlock", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 55); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U8LE(ctx, val->type); - MARSHAL_U64LE(ctx, val->start); - MARSHAL_U64LE(ctx, val->length); - MARSHAL_U32LE(ctx, val->proc_id); - MARSHAL_U16LE(ctx, val->client_id.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->client_id.utf8, val->client_id.len); - return false; -} - -static bool marshal_Tlink(struct lib9p_ctx *ctx, struct lib9p_msg_Tlink *val, struct _marshal_ret *ret) { - uint32_t needed_size = 17 + val->name.len; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Tlink", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 70); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->dfid); - MARSHAL_U32LE(ctx, val->fid); - MARSHAL_U16LE(ctx, val->name.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->name.utf8, val->name.len); - return false; -} - -static bool marshal_Rlink(struct lib9p_ctx *ctx, struct lib9p_msg_Rlink *val, struct _marshal_ret *ret) { - uint32_t needed_size = 7; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rlink", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 71); - MARSHAL_U16LE(ctx, val->tag); - return false; -} - -static bool marshal_Tmkdir(struct lib9p_ctx *ctx, struct lib9p_msg_Tmkdir *val, struct _marshal_ret *ret) { - uint32_t needed_size = 21 + val->name.len; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Tmkdir", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 72); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->dfid); - MARSHAL_U16LE(ctx, val->name.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->name.utf8, val->name.len); - MARSHAL_U32LE(ctx, val->mode & mode_masks[ctx->version]); - MARSHAL_U32LE(ctx, val->gid); - return false; -} - -static bool marshal_Rmkdir(struct lib9p_ctx *ctx, struct lib9p_msg_Rmkdir *val, struct _marshal_ret *ret) { - uint32_t needed_size = 20; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rmkdir", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 73); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U8LE(ctx, val->qid.type & qt_masks[ctx->version]); - MARSHAL_U32LE(ctx, val->qid.vers); - MARSHAL_U64LE(ctx, val->qid.path); - return false; -} - -static bool marshal_Trenameat(struct lib9p_ctx *ctx, struct lib9p_msg_Trenameat *val, struct _marshal_ret *ret) { - uint32_t needed_size = 19 + val->oldname.len + val->newname.len; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Trenameat", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 74); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->olddirfid); - MARSHAL_U16LE(ctx, val->oldname.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->oldname.utf8, val->oldname.len); - MARSHAL_U32LE(ctx, val->newdirfid); - MARSHAL_U16LE(ctx, val->newname.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->newname.utf8, val->newname.len); - return false; -} - -static bool marshal_Rrenameat(struct lib9p_ctx *ctx, struct lib9p_msg_Rrenameat *val, struct _marshal_ret *ret) { - uint32_t needed_size = 7; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rrenameat", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 75); - MARSHAL_U16LE(ctx, val->tag); - return false; -} - -static bool marshal_Tunlinkat(struct lib9p_ctx *ctx, struct lib9p_msg_Tunlinkat *val, struct _marshal_ret *ret) { - uint32_t needed_size = 17 + val->name.len; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Tunlinkat", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 76); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->dirfd); - MARSHAL_U16LE(ctx, val->name.len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->name.utf8, val->name.len); - MARSHAL_U32LE(ctx, val->flags); - return false; -} - -static bool marshal_Runlinkat(struct lib9p_ctx *ctx, struct lib9p_msg_Runlinkat *val, struct _marshal_ret *ret) { - uint32_t needed_size = 7; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Runlinkat", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 77); - MARSHAL_U16LE(ctx, val->tag); - return false; -} - -#endif /* CONFIG_9P_ENABLE_9P2000_L */ -#if CONFIG_9P_ENABLE_9P2000_e -static bool marshal_Tsession(struct lib9p_ctx *ctx, struct lib9p_msg_Tsession *val, struct _marshal_ret *ret) { - uint32_t needed_size = 15; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Tsession", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 150); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U64LE(ctx, val->key); - return false; -} - -static bool marshal_Rsession(struct lib9p_ctx *ctx, struct lib9p_msg_Rsession *val, struct _marshal_ret *ret) { - uint32_t needed_size = 7; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rsession", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 151); - MARSHAL_U16LE(ctx, val->tag); - return false; -} - -static bool marshal_Tsread(struct lib9p_ctx *ctx, struct lib9p_msg_Tsread *val, struct _marshal_ret *ret) { - uint64_t needed_size = 13; - for (uint16_t i = 0; i < val->nwname; i++) { - needed_size += 2 + val->wname[i].len; - } - if (needed_size > (uint64_t)(ctx->max_msg_size)) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Tsread", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = (uint32_t)needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 152); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->fid); - MARSHAL_U16LE(ctx, val->nwname); - for (uint16_t i = 0; i < val->nwname; i++) { - MARSHAL_U16LE(ctx, val->wname[i].len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->wname[i].utf8, val->wname[i].len); - } - return false; -} - -static bool marshal_Rsread(struct lib9p_ctx *ctx, struct lib9p_msg_Rsread *val, struct _marshal_ret *ret) { - uint64_t needed_size = 11 + val->count; - if (needed_size > (uint64_t)(ctx->max_msg_size)) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rsread", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = (uint32_t)needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 153); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->count); - MARSHAL_BYTES_ZEROCOPY(ctx, val->data, val->count); - return false; -} - -static bool marshal_Tswrite(struct lib9p_ctx *ctx, struct lib9p_msg_Tswrite *val, struct _marshal_ret *ret) { - uint64_t needed_size = 17 + val->count; - for (uint16_t i = 0; i < val->nwname; i++) { - needed_size += 2 + val->wname[i].len; - } - if (needed_size > (uint64_t)(ctx->max_msg_size)) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Tswrite", - ctx->version ? "negotiated" : "client", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = (uint32_t)needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 154); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->fid); - MARSHAL_U16LE(ctx, val->nwname); - for (uint16_t i = 0; i < val->nwname; i++) { - MARSHAL_U16LE(ctx, val->wname[i].len); - MARSHAL_BYTES_ZEROCOPY(ctx, val->wname[i].utf8, val->wname[i].len); - } - MARSHAL_U32LE(ctx, val->count); - MARSHAL_BYTES_ZEROCOPY(ctx, val->data, val->count); - return false; -} - -static bool marshal_Rswrite(struct lib9p_ctx *ctx, struct lib9p_msg_Rswrite *val, struct _marshal_ret *ret) { - uint32_t needed_size = 11; - if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", - "Rswrite", - ctx->version ? "negotiated" : "server", - ctx->max_msg_size); - return true; - } - uint32_t offsetof_end = needed_size; - uint32_t offsetof_size = 0; - MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); - MARSHAL_U8LE(ctx, 155); - MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U32LE(ctx, val->count); - return false; -} -#endif /* CONFIG_9P_ENABLE_9P2000_e */ - -/* function tables ************************************************************/ - -const uint32_t _lib9p_table_msg_min_size[LIB9P_VER_NUM] = { - [LIB9P_VER_unknown] = 9, -#if CONFIG_9P_ENABLE_9P2000 - [LIB9P_VER_9P2000] = 9, -#endif /* CONFIG_9P_ENABLE_9P2000 */ -#if CONFIG_9P_ENABLE_9P2000_L - [LIB9P_VER_9P2000_L] = 9, -#endif /* CONFIG_9P_ENABLE_9P2000_L */ -#if CONFIG_9P_ENABLE_9P2000_e - [LIB9P_VER_9P2000_e] = 9, -#endif /* CONFIG_9P_ENABLE_9P2000_e */ -#if CONFIG_9P_ENABLE_9P2000_p9p - [LIB9P_VER_9P2000_p9p] = 9, -#endif /* CONFIG_9P_ENABLE_9P2000_p9p */ -#if CONFIG_9P_ENABLE_9P2000_u - [LIB9P_VER_9P2000_u] = 13, -#endif /* CONFIG_9P_ENABLE_9P2000_u */ -}; - -#define _MSG_RECV(typ) [LIB9P_TYP_##typ/2] = { \ - .basesize = sizeof(struct lib9p_msg_##typ), \ - .validate = validate_##typ, \ - .unmarshal = (_unmarshal_fn_t)unmarshal_##typ, \ - } -#define _MSG_SEND(typ) [LIB9P_TYP_##typ/2] = { \ - .marshal = (_marshal_fn_t)marshal_##typ, \ - } - -const struct _lib9p_recv_tentry _lib9p_table_Tmsg_recv[LIB9P_VER_NUM][0x80] = { - [LIB9P_VER_unknown] = { - _MSG_RECV(Tversion), - }, -#if CONFIG_9P_ENABLE_9P2000 - [LIB9P_VER_9P2000] = { - _MSG_RECV(Tversion), - _MSG_RECV(Tauth), - _MSG_RECV(Tattach), - _MSG_RECV(Tflush), - _MSG_RECV(Twalk), - _MSG_RECV(Topen), - _MSG_RECV(Tcreate), - _MSG_RECV(Tread), - _MSG_RECV(Twrite), - _MSG_RECV(Tclunk), - _MSG_RECV(Tremove), - _MSG_RECV(Tstat), - _MSG_RECV(Twstat), - }, -#endif /* CONFIG_9P_ENABLE_9P2000 */ -#if CONFIG_9P_ENABLE_9P2000_L - [LIB9P_VER_9P2000_L] = { - _MSG_RECV(Tstatfs), - _MSG_RECV(Tlopen), - _MSG_RECV(Tlcreate), - _MSG_RECV(Tsymlink), - _MSG_RECV(Tmknod), - _MSG_RECV(Trename), - _MSG_RECV(Treadlink), - _MSG_RECV(Tgetattr), - _MSG_RECV(Tsetattr), - _MSG_RECV(Txattrwalk), - _MSG_RECV(Txattrcreate), - _MSG_RECV(Treaddir), - _MSG_RECV(Tfsync), - _MSG_RECV(Tlock), - _MSG_RECV(Tgetlock), - _MSG_RECV(Tlink), - _MSG_RECV(Tmkdir), - _MSG_RECV(Trenameat), - _MSG_RECV(Tunlinkat), - _MSG_RECV(Tversion), - _MSG_RECV(Tauth), - _MSG_RECV(Tattach), - _MSG_RECV(Tflush), - _MSG_RECV(Twalk), - _MSG_RECV(Tread), - _MSG_RECV(Twrite), - _MSG_RECV(Tclunk), - _MSG_RECV(Tremove), - }, -#endif /* CONFIG_9P_ENABLE_9P2000_L */ -#if CONFIG_9P_ENABLE_9P2000_e - [LIB9P_VER_9P2000_e] = { - _MSG_RECV(Tversion), - _MSG_RECV(Tauth), - _MSG_RECV(Tattach), - _MSG_RECV(Tflush), - _MSG_RECV(Twalk), - _MSG_RECV(Topen), - _MSG_RECV(Tcreate), - _MSG_RECV(Tread), - _MSG_RECV(Twrite), - _MSG_RECV(Tclunk), - _MSG_RECV(Tremove), - _MSG_RECV(Tstat), - _MSG_RECV(Twstat), - _MSG_RECV(Tsession), - _MSG_RECV(Tsread), - _MSG_RECV(Tswrite), - }, -#endif /* CONFIG_9P_ENABLE_9P2000_e */ -#if CONFIG_9P_ENABLE_9P2000_p9p - [LIB9P_VER_9P2000_p9p] = { - _MSG_RECV(Topenfd), - _MSG_RECV(Tversion), - _MSG_RECV(Tauth), - _MSG_RECV(Tattach), - _MSG_RECV(Tflush), - _MSG_RECV(Twalk), - _MSG_RECV(Topen), - _MSG_RECV(Tcreate), - _MSG_RECV(Tread), - _MSG_RECV(Twrite), - _MSG_RECV(Tclunk), - _MSG_RECV(Tremove), - _MSG_RECV(Tstat), - _MSG_RECV(Twstat), - }, -#endif /* CONFIG_9P_ENABLE_9P2000_p9p */ -#if CONFIG_9P_ENABLE_9P2000_u - [LIB9P_VER_9P2000_u] = { - _MSG_RECV(Tversion), - _MSG_RECV(Tauth), - _MSG_RECV(Tattach), - _MSG_RECV(Tflush), - _MSG_RECV(Twalk), - _MSG_RECV(Topen), - _MSG_RECV(Tcreate), - _MSG_RECV(Tread), - _MSG_RECV(Twrite), - _MSG_RECV(Tclunk), - _MSG_RECV(Tremove), - _MSG_RECV(Tstat), - _MSG_RECV(Twstat), - }, -#endif /* CONFIG_9P_ENABLE_9P2000_u */ -}; - -const struct _lib9p_recv_tentry _lib9p_table_Rmsg_recv[LIB9P_VER_NUM][0x80] = { - [LIB9P_VER_unknown] = { - _MSG_RECV(Rversion), - _MSG_RECV(Rerror), - }, -#if CONFIG_9P_ENABLE_9P2000 - [LIB9P_VER_9P2000] = { - _MSG_RECV(Rversion), - _MSG_RECV(Rauth), - _MSG_RECV(Rattach), - _MSG_RECV(Rerror), - _MSG_RECV(Rflush), - _MSG_RECV(Rwalk), - _MSG_RECV(Ropen), - _MSG_RECV(Rcreate), - _MSG_RECV(Rread), - _MSG_RECV(Rwrite), - _MSG_RECV(Rclunk), - _MSG_RECV(Rremove), - _MSG_RECV(Rstat), - _MSG_RECV(Rwstat), - }, -#endif /* CONFIG_9P_ENABLE_9P2000 */ -#if CONFIG_9P_ENABLE_9P2000_L - [LIB9P_VER_9P2000_L] = { - _MSG_RECV(Rlerror), - _MSG_RECV(Rstatfs), - _MSG_RECV(Rlopen), - _MSG_RECV(Rlcreate), - _MSG_RECV(Rsymlink), - _MSG_RECV(Rmknod), - _MSG_RECV(Rrename), - _MSG_RECV(Rreadlink), - _MSG_RECV(Rgetattr), - _MSG_RECV(Rsetattr), - _MSG_RECV(Rxattrwalk), - _MSG_RECV(Rxattrcreate), - _MSG_RECV(Rreaddir), - _MSG_RECV(Rfsync), - _MSG_RECV(Rlock), - _MSG_RECV(Rgetlock), - _MSG_RECV(Rlink), - _MSG_RECV(Rmkdir), - _MSG_RECV(Rrenameat), - _MSG_RECV(Runlinkat), - _MSG_RECV(Rversion), - _MSG_RECV(Rauth), - _MSG_RECV(Rattach), - _MSG_RECV(Rerror), - _MSG_RECV(Rflush), - _MSG_RECV(Rwalk), - _MSG_RECV(Rread), - _MSG_RECV(Rwrite), - _MSG_RECV(Rclunk), - _MSG_RECV(Rremove), - }, -#endif /* CONFIG_9P_ENABLE_9P2000_L */ -#if CONFIG_9P_ENABLE_9P2000_e - [LIB9P_VER_9P2000_e] = { - _MSG_RECV(Rversion), - _MSG_RECV(Rauth), - _MSG_RECV(Rattach), - _MSG_RECV(Rerror), - _MSG_RECV(Rflush), - _MSG_RECV(Rwalk), - _MSG_RECV(Ropen), - _MSG_RECV(Rcreate), - _MSG_RECV(Rread), - _MSG_RECV(Rwrite), - _MSG_RECV(Rclunk), - _MSG_RECV(Rremove), - _MSG_RECV(Rstat), - _MSG_RECV(Rwstat), - _MSG_RECV(Rsession), - _MSG_RECV(Rsread), - _MSG_RECV(Rswrite), - }, -#endif /* CONFIG_9P_ENABLE_9P2000_e */ -#if CONFIG_9P_ENABLE_9P2000_p9p - [LIB9P_VER_9P2000_p9p] = { - _MSG_RECV(Ropenfd), - _MSG_RECV(Rversion), - _MSG_RECV(Rauth), - _MSG_RECV(Rattach), - _MSG_RECV(Rerror), - _MSG_RECV(Rflush), - _MSG_RECV(Rwalk), - _MSG_RECV(Ropen), - _MSG_RECV(Rcreate), - _MSG_RECV(Rread), - _MSG_RECV(Rwrite), - _MSG_RECV(Rclunk), - _MSG_RECV(Rremove), - _MSG_RECV(Rstat), - _MSG_RECV(Rwstat), - }, -#endif /* CONFIG_9P_ENABLE_9P2000_p9p */ -#if CONFIG_9P_ENABLE_9P2000_u - [LIB9P_VER_9P2000_u] = { - _MSG_RECV(Rversion), - _MSG_RECV(Rauth), - _MSG_RECV(Rattach), - _MSG_RECV(Rerror), - _MSG_RECV(Rflush), - _MSG_RECV(Rwalk), - _MSG_RECV(Ropen), - _MSG_RECV(Rcreate), - _MSG_RECV(Rread), - _MSG_RECV(Rwrite), - _MSG_RECV(Rclunk), - _MSG_RECV(Rremove), - _MSG_RECV(Rstat), - _MSG_RECV(Rwstat), - }, -#endif /* CONFIG_9P_ENABLE_9P2000_u */ -}; - -const struct _lib9p_send_tentry _lib9p_table_Tmsg_send[LIB9P_VER_NUM][0x80] = { - [LIB9P_VER_unknown] = { - _MSG_SEND(Tversion), - }, -#if CONFIG_9P_ENABLE_9P2000 - [LIB9P_VER_9P2000] = { - _MSG_SEND(Tversion), - _MSG_SEND(Tauth), - _MSG_SEND(Tattach), - _MSG_SEND(Tflush), - _MSG_SEND(Twalk), - _MSG_SEND(Topen), - _MSG_SEND(Tcreate), - _MSG_SEND(Tread), - _MSG_SEND(Twrite), - _MSG_SEND(Tclunk), - _MSG_SEND(Tremove), - _MSG_SEND(Tstat), - _MSG_SEND(Twstat), - }, -#endif /* CONFIG_9P_ENABLE_9P2000 */ -#if CONFIG_9P_ENABLE_9P2000_L - [LIB9P_VER_9P2000_L] = { - _MSG_SEND(Tstatfs), - _MSG_SEND(Tlopen), - _MSG_SEND(Tlcreate), - _MSG_SEND(Tsymlink), - _MSG_SEND(Tmknod), - _MSG_SEND(Trename), - _MSG_SEND(Treadlink), - _MSG_SEND(Tgetattr), - _MSG_SEND(Tsetattr), - _MSG_SEND(Txattrwalk), - _MSG_SEND(Txattrcreate), - _MSG_SEND(Treaddir), - _MSG_SEND(Tfsync), - _MSG_SEND(Tlock), - _MSG_SEND(Tgetlock), - _MSG_SEND(Tlink), - _MSG_SEND(Tmkdir), - _MSG_SEND(Trenameat), - _MSG_SEND(Tunlinkat), - _MSG_SEND(Tversion), - _MSG_SEND(Tauth), - _MSG_SEND(Tattach), - _MSG_SEND(Tflush), - _MSG_SEND(Twalk), - _MSG_SEND(Tread), - _MSG_SEND(Twrite), - _MSG_SEND(Tclunk), - _MSG_SEND(Tremove), - }, -#endif /* CONFIG_9P_ENABLE_9P2000_L */ -#if CONFIG_9P_ENABLE_9P2000_e - [LIB9P_VER_9P2000_e] = { - _MSG_SEND(Tversion), - _MSG_SEND(Tauth), - _MSG_SEND(Tattach), - _MSG_SEND(Tflush), - _MSG_SEND(Twalk), - _MSG_SEND(Topen), - _MSG_SEND(Tcreate), - _MSG_SEND(Tread), - _MSG_SEND(Twrite), - _MSG_SEND(Tclunk), - _MSG_SEND(Tremove), - _MSG_SEND(Tstat), - _MSG_SEND(Twstat), - _MSG_SEND(Tsession), - _MSG_SEND(Tsread), - _MSG_SEND(Tswrite), - }, -#endif /* CONFIG_9P_ENABLE_9P2000_e */ -#if CONFIG_9P_ENABLE_9P2000_p9p - [LIB9P_VER_9P2000_p9p] = { - _MSG_SEND(Topenfd), - _MSG_SEND(Tversion), - _MSG_SEND(Tauth), - _MSG_SEND(Tattach), - _MSG_SEND(Tflush), - _MSG_SEND(Twalk), - _MSG_SEND(Topen), - _MSG_SEND(Tcreate), - _MSG_SEND(Tread), - _MSG_SEND(Twrite), - _MSG_SEND(Tclunk), - _MSG_SEND(Tremove), - _MSG_SEND(Tstat), - _MSG_SEND(Twstat), - }, -#endif /* CONFIG_9P_ENABLE_9P2000_p9p */ -#if CONFIG_9P_ENABLE_9P2000_u - [LIB9P_VER_9P2000_u] = { - _MSG_SEND(Tversion), - _MSG_SEND(Tauth), - _MSG_SEND(Tattach), - _MSG_SEND(Tflush), - _MSG_SEND(Twalk), - _MSG_SEND(Topen), - _MSG_SEND(Tcreate), - _MSG_SEND(Tread), - _MSG_SEND(Twrite), - _MSG_SEND(Tclunk), - _MSG_SEND(Tremove), - _MSG_SEND(Tstat), - _MSG_SEND(Twstat), - }, -#endif /* CONFIG_9P_ENABLE_9P2000_u */ -}; - -const struct _lib9p_send_tentry _lib9p_table_Rmsg_send[LIB9P_VER_NUM][0x80] = { - [LIB9P_VER_unknown] = { - _MSG_SEND(Rversion), - _MSG_SEND(Rerror), - }, -#if CONFIG_9P_ENABLE_9P2000 - [LIB9P_VER_9P2000] = { - _MSG_SEND(Rversion), - _MSG_SEND(Rauth), - _MSG_SEND(Rattach), - _MSG_SEND(Rerror), - _MSG_SEND(Rflush), - _MSG_SEND(Rwalk), - _MSG_SEND(Ropen), - _MSG_SEND(Rcreate), - _MSG_SEND(Rread), - _MSG_SEND(Rwrite), - _MSG_SEND(Rclunk), - _MSG_SEND(Rremove), - _MSG_SEND(Rstat), - _MSG_SEND(Rwstat), - }, -#endif /* CONFIG_9P_ENABLE_9P2000 */ -#if CONFIG_9P_ENABLE_9P2000_L - [LIB9P_VER_9P2000_L] = { - _MSG_SEND(Rlerror), - _MSG_SEND(Rstatfs), - _MSG_SEND(Rlopen), - _MSG_SEND(Rlcreate), - _MSG_SEND(Rsymlink), - _MSG_SEND(Rmknod), - _MSG_SEND(Rrename), - _MSG_SEND(Rreadlink), - _MSG_SEND(Rgetattr), - _MSG_SEND(Rsetattr), - _MSG_SEND(Rxattrwalk), - _MSG_SEND(Rxattrcreate), - _MSG_SEND(Rreaddir), - _MSG_SEND(Rfsync), - _MSG_SEND(Rlock), - _MSG_SEND(Rgetlock), - _MSG_SEND(Rlink), - _MSG_SEND(Rmkdir), - _MSG_SEND(Rrenameat), - _MSG_SEND(Runlinkat), - _MSG_SEND(Rversion), - _MSG_SEND(Rauth), - _MSG_SEND(Rattach), - _MSG_SEND(Rerror), - _MSG_SEND(Rflush), - _MSG_SEND(Rwalk), - _MSG_SEND(Rread), - _MSG_SEND(Rwrite), - _MSG_SEND(Rclunk), - _MSG_SEND(Rremove), - }, -#endif /* CONFIG_9P_ENABLE_9P2000_L */ -#if CONFIG_9P_ENABLE_9P2000_e - [LIB9P_VER_9P2000_e] = { - _MSG_SEND(Rversion), - _MSG_SEND(Rauth), - _MSG_SEND(Rattach), - _MSG_SEND(Rerror), - _MSG_SEND(Rflush), - _MSG_SEND(Rwalk), - _MSG_SEND(Ropen), - _MSG_SEND(Rcreate), - _MSG_SEND(Rread), - _MSG_SEND(Rwrite), - _MSG_SEND(Rclunk), - _MSG_SEND(Rremove), - _MSG_SEND(Rstat), - _MSG_SEND(Rwstat), - _MSG_SEND(Rsession), - _MSG_SEND(Rsread), - _MSG_SEND(Rswrite), - }, -#endif /* CONFIG_9P_ENABLE_9P2000_e */ -#if CONFIG_9P_ENABLE_9P2000_p9p - [LIB9P_VER_9P2000_p9p] = { - _MSG_SEND(Ropenfd), - _MSG_SEND(Rversion), - _MSG_SEND(Rauth), - _MSG_SEND(Rattach), - _MSG_SEND(Rerror), - _MSG_SEND(Rflush), - _MSG_SEND(Rwalk), - _MSG_SEND(Ropen), - _MSG_SEND(Rcreate), - _MSG_SEND(Rread), - _MSG_SEND(Rwrite), - _MSG_SEND(Rclunk), - _MSG_SEND(Rremove), - _MSG_SEND(Rstat), - _MSG_SEND(Rwstat), - }, -#endif /* CONFIG_9P_ENABLE_9P2000_p9p */ -#if CONFIG_9P_ENABLE_9P2000_u - [LIB9P_VER_9P2000_u] = { - _MSG_SEND(Rversion), - _MSG_SEND(Rauth), - _MSG_SEND(Rattach), - _MSG_SEND(Rerror), - _MSG_SEND(Rflush), - _MSG_SEND(Rwalk), - _MSG_SEND(Ropen), - _MSG_SEND(Rcreate), - _MSG_SEND(Rread), - _MSG_SEND(Rwrite), - _MSG_SEND(Rclunk), - _MSG_SEND(Rremove), - _MSG_SEND(Rstat), - _MSG_SEND(Rwstat), - }, -#endif /* CONFIG_9P_ENABLE_9P2000_u */ -}; - -LM_FLATTEN ssize_t _lib9p_stat_validate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes, uint32_t *ret_net_size) { - return validate_stat(ctx, net_size, net_bytes, ret_net_size); -} -LM_FLATTEN void _lib9p_stat_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out) { - unmarshal_stat(ctx, net_bytes, out); -} -LM_FLATTEN bool _lib9p_stat_marshal(struct lib9p_ctx *ctx, struct lib9p_stat *val, struct _marshal_ret *ret) { - return marshal_stat(ctx, val, ret); -} |