diff options
Diffstat (limited to 'lib9p')
26 files changed, 2700 insertions, 1556 deletions
diff --git a/lib9p/CMakeLists.txt b/lib9p/CMakeLists.txt index 543d01a..cff07ad 100644 --- a/lib9p/CMakeLists.txt +++ b/lib9p/CMakeLists.txt @@ -8,7 +8,6 @@ target_include_directories(lib9p_core PUBLIC INTERFACE ${CMAKE_CURRENT_SOURCE_DI target_sources(lib9p_core INTERFACE core.c core_generated.c - core_tables.c ) target_link_libraries(lib9p_core INTERFACE libfmt @@ -50,6 +49,20 @@ if (ENABLE_TESTS) add_lib9p_executable("testclient-sess") add_lib9p_test("./testclient-sess") - add_lib_test(lib9p_core test_compile) - target_include_directories(test_compile PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_compile_config) + set(cfg_matrix + "CONFIG_9P_SRV_DEBUG;[0;1]" + "CONFIG_9P_ENABLE_9P2000;[0;1]" + "CONFIG_9P_ENABLE_9P2000_u;[0;1]" + "CONFIG_9P_ENABLE_9P2000_e;[0;1]" + "CONFIG_9P_ENABLE_9P2000_L;[0;1]" + "CONFIG_9P_ENABLE_9P2000_p9p;[0;1]" + ) + function(add_compile_test n defs) + add_executable("test_compile${n}" "tests/test_compile.c") + target_link_libraries("test_compile${n}" lib9p_srv) + target_include_directories("test_compile${n}" PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_compile_config) + target_compile_definitions("test_compile${n}" PUBLIC "${defs}") + # Don't bother running it (don't bother calling add_test()) + endfunction() + apply_matrix(add_compile_test "${cfg_matrix}") endif() diff --git a/lib9p/core.c b/lib9p/core.c index a07461d..03cdea5 100644 --- a/lib9p/core.c +++ b/lib9p/core.c @@ -4,14 +4,18 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -#include <inttypes.h> /* for PRIu{n} */ -#include <stdarg.h> /* for va_* */ -#include <string.h> /* for strncpy() */ +#include <stdarg.h> /* for va_* */ +#include <string.h> /* for strlen(), strnlen(), strncpy(), memcmp(), memset() */ -#include <libfmt/fmt.h> /* for fmt_vsnprintf() */ +#include <libfmt/fmt.h> /* for fmt_vsnprintf() */ +#include <libmisc/assert.h> /* for assert() */ +#include <libmisc/endian.h> /* for uint32le_decode() */ +#include <libmisc/log.h> /* for const_byte_str() */ #include <lib9p/core.h> +#include "core_tables.h" + /* strings ********************************************************************/ struct lib9p_s lib9p_str(char *s) { @@ -47,7 +51,7 @@ bool lib9p_str_eq(struct lib9p_s a, struct lib9p_s b) { void lib9p_ctx_clear_error(struct lib9p_ctx *ctx) { assert(ctx); -#if CONFIG_9P_ENABLE_9P2000_u +#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L ctx->err_num = 0; #endif ctx->err_msg[0] = '\0'; @@ -58,22 +62,28 @@ bool lib9p_ctx_has_error(struct lib9p_ctx *ctx) { return ctx->err_msg[0]; } -int lib9p_error(struct lib9p_ctx *ctx, lib9p_errno_t linux_errno, char const *msg) { +int _lib9p_error(struct lib9p_ctx *ctx, +#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L + lib9p_errno_t linux_errno, +#endif + char const *msg) { if (lib9p_ctx_has_error(ctx)) return -1; strncpy(ctx->err_msg, msg, sizeof(ctx->err_msg)); ctx->err_msg[sizeof(ctx->err_msg)-1] = '\0'; -#if CONFIG_9P_ENABLE_9P2000_u +#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L ctx->err_num = linux_errno; -#else - (void)(linux_errno); #endif return -1; } -int lib9p_errorf(struct lib9p_ctx *ctx, lib9p_errno_t linux_errno, char const *fmt, ...) { +int _lib9p_errorf(struct lib9p_ctx *ctx, +#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L + lib9p_errno_t linux_errno, +#endif + char const *fmt, ...) { int n; va_list args; @@ -85,11 +95,192 @@ int lib9p_errorf(struct lib9p_ctx *ctx, lib9p_errno_t linux_errno, char const *f if ((size_t)(n+1) < sizeof(ctx->err_msg)) memset(&ctx->err_msg[n+1], 0, sizeof(ctx->err_msg)-(n+1)); -#if CONFIG_9P_ENABLE_9P2000_u +#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L ctx->err_num = linux_errno; -#else - (void)(linux_errno); #endif return -1; } + +/* bounds checks **************************************************************/ + +static inline void assert_ver(enum lib9p_version ver) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wtype-limits" + assert(0 <= ver && ver < LIB9P_VER_NUM); +#pragma GCC diagnostic pop +} + +static inline void assert_typ(enum lib9p_msg_type typ) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wtype-limits" + assert(0 <= typ && typ < 0xFF); +#pragma GCC diagnostic pop +} + +/* simple lookups *************************************************************/ + +const char *lib9p_version_str(enum lib9p_version ver) { + assert_ver(ver); + return _lib9p_table_ver[ver].name; +} + +uint32_t lib9p_version_min_Rerror_size(enum lib9p_version ver) { + assert_ver(ver); + return _lib9p_table_ver[ver].min_Rerror_size; +} + +uint32_t lib9p_version_min_Rread_size(enum lib9p_version ver) { + assert_ver(ver); + return _lib9p_table_ver[ver].min_Rread_size; +} + +const char *lib9p_msgtype_str(enum lib9p_version ver, enum lib9p_msg_type typ) { + assert_ver(ver); + assert_typ(typ); + return _lib9p_table_msg[ver][typ].name ?: const_byte_str(typ); +} + +lo_interface fmt_formatter lo_box_lib9p_msg_as_fmt_formatter(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body) { + assert(ctx); + assert_ver(ctx->version); + assert_typ(typ); + assert(_lib9p_table_msg[ctx->version][typ].box_as_fmt_formatter); + return _lib9p_table_msg[ctx->version][typ].box_as_fmt_formatter(body); +} + +/* main message functions *****************************************************/ + +static +ssize_t _lib9p_validate(uint8_t xxx_low_typ_bit, + const char *xxx_errmsg, + const struct _lib9p_recv_tentry xxx_table[LIB9P_VER_NUM][0x80], + struct lib9p_ctx *ctx, uint8_t *net_bytes) { + assert_ver(ctx->version); + /* Inspect the first 5 bytes ourselves. */ + uint32_t net_size = uint32le_decode(net_bytes); + if (net_size < 5) + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "message is impossibly short"); + uint8_t typ = net_bytes[4]; + if (typ % 2 != xxx_low_typ_bit) + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EOPNOTSUPP, "%s: message_type=%s", xxx_errmsg, + lib9p_msgtype_str(ctx->version, typ)); + struct _lib9p_recv_tentry tentry = xxx_table[ctx->version][typ/2]; + if (!tentry.validate) + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EOPNOTSUPP, "unknown message type: %s (protocol_version=%s)", + lib9p_msgtype_str(ctx->version, typ), lib9p_version_str(ctx->version)); + + /* Now use the message-type-specific tentry to process the whole thing. */ + return tentry.validate(ctx, net_size, net_bytes); +} + +ssize_t lib9p_Tmsg_validate(struct lib9p_ctx *ctx, uint8_t *net_bytes) { + return _lib9p_validate(0, "expected a T-message but got an R-message", _lib9p_table_Tmsg_recv, + ctx, net_bytes); +} + +ssize_t lib9p_Rmsg_validate(struct lib9p_ctx *ctx, uint8_t *net_bytes) { + return _lib9p_validate(1, "expected an R-message but got a T-message", _lib9p_table_Rmsg_recv, + ctx, net_bytes); +} + +static +void _lib9p_unmarshal(const struct _lib9p_recv_tentry xxx_table[LIB9P_VER_NUM][0x80], + struct lib9p_ctx *ctx, uint8_t *net_bytes, + enum lib9p_msg_type *ret_typ, void *ret_body) { + assert_ver(ctx->version); + enum lib9p_msg_type typ = net_bytes[4]; + *ret_typ = typ; + struct _lib9p_recv_tentry tentry = xxx_table[ctx->version][typ/2]; + assert(tentry.unmarshal); + + tentry.unmarshal(ctx, net_bytes, ret_body); +} + +void lib9p_Tmsg_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes, + enum lib9p_msg_type *ret_typ, void *ret_body) { + _lib9p_unmarshal(_lib9p_table_Tmsg_recv, + ctx, net_bytes, ret_typ, ret_body); +} + +void lib9p_Rmsg_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes, + enum lib9p_msg_type *ret_typ, void *ret_body) { + _lib9p_unmarshal(_lib9p_table_Rmsg_recv, + ctx, net_bytes, ret_typ, ret_body); +} + +static +bool _lib9p_marshal(const struct _lib9p_send_tentry xxx_table[LIB9P_VER_NUM][0x80], + struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body, + size_t *ret_iov_cnt, struct iovec *ret_iov, uint8_t *ret_copied) { + assert_ver(ctx->version); + assert_typ(typ); + struct _marshal_ret ret = { + .net_iov_cnt = 1, + .net_iov = ret_iov, + .net_copied_size = 0, + .net_copied = ret_copied, + }; + struct _lib9p_send_tentry tentry = xxx_table[ctx->version][typ/2]; + assert(tentry.marshal); + + bool ret_erred = tentry.marshal(ctx, body, &ret); + if (ret_iov[ret.net_iov_cnt-1].iov_len == 0) + ret.net_iov_cnt--; + *ret_iov_cnt = ret.net_iov_cnt; + return ret_erred; +} + +bool lib9p_Tmsg_marshal(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body, + struct lib9p_Tmsg_send_buf *ret) { + assert(typ % 2 == 0); + memset(ret, 0, sizeof(*ret)); + return _lib9p_marshal(_lib9p_table_Tmsg_send, + ctx, typ, body, + &ret->iov_cnt, ret->iov, ret->copied); +} + +bool lib9p_Rmsg_marshal(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body, + struct lib9p_Rmsg_send_buf *ret) { + assert(typ % 2 == 1); + memset(ret, 0, sizeof(*ret)); + return _lib9p_marshal(_lib9p_table_Rmsg_send, + ctx, typ, body, + &ret->iov_cnt, ret->iov, ret->copied); +} + +/* `struct lib9p_stat` helpers ************************************************/ + +#if _LIB9P_ENABLE_stat +bool lib9p_stat_validate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes, + uint32_t *ret_net_size, size_t *ret_host_size) { + ssize_t host_size = _lib9p_stat_validate(ctx, net_size, net_bytes, ret_net_size); + if (host_size < 0) + return true; + if (ret_host_size) + *ret_host_size = (size_t)host_size; + return false; +} + +void lib9p_stat_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes, + struct lib9p_stat *ret) { + _lib9p_stat_unmarshal(ctx, net_bytes, ret); +} + +uint32_t lib9p_stat_marshal(struct lib9p_ctx *ctx, uint32_t max_net_size, struct lib9p_stat *obj, + uint8_t *ret_bytes) { + struct lib9p_ctx _ctx = *ctx; + _ctx.max_msg_size = max_net_size; + + struct iovec iov = {0}; + struct _marshal_ret ret = { + .net_iov_cnt = 1, + .net_iov = &iov, + .net_copied_size = 0, + .net_copied = ret_bytes, + }; + if (_lib9p_stat_marshal(&_ctx, obj, &ret)) + return 0; + return ret.net_iov[0].iov_len; +} +#endif diff --git a/lib9p/core_gen/c.py b/lib9p/core_gen/c.py index b2e856d..b0ff871 100644 --- a/lib9p/core_gen/c.py +++ b/lib9p/core_gen/c.py @@ -79,7 +79,9 @@ def gen_c(versions: set[str], typs: list[idl.UserType]) -> str: if not isinstance(typ, idl.Bitfield): continue ret += "\n" - ret += cutil.ifdef_push(1, c9util.ver_ifdef(typ.in_versions)) + ret += cutil.ifdef_push( # SPECIAL (initialization) + 1, c9util.ver_ifdef(typ.in_versions - {"uninitialized"}) + ) ret += f"static const {c9util.typename(typ)} {typ.typname}_masks[{c9util.ver_enum('NUM')}] = {{\n" verwidth = max(len(ver) for ver in versions) for ver in sorted(versions): @@ -121,21 +123,15 @@ def gen_c(versions: set[str], typs: list[idl.UserType]) -> str: ret += "\n" ret += f"const struct {c9util.ident('_ver_tentry')} {c9util.ident('_table_ver')}[{c9util.ver_enum('NUM')}] = {{\n" rerror = next(typ for typ in typs if typ.typname == "Rerror") - for ver in ["unknown", *sorted(versions)]: - # XXX: There are good arguments that min_msg_size should be - # something larger than rerror.min_size(). - # srv.c:respond_error() assumes that min_msg_size is - # rerror.min_size(); if you do change min_msg_size to - # something larger, then be sure to update respond_error(). - if ver == "unknown": - min_msg_size = rerror.min_size("9P2000") # SPECIAL (initialization) - else: - ret += cutil.ifdef_push(1, c9util.ver_ifdef({ver})) - min_msg_size = rerror.min_size(ver) - if ver == "9P2000.L": # SPECIAL (9P2000.L) - rlerror = next(typ for typ in typs if typ.typname == "Rlerror") - min_msg_size = rlerror.min_size(ver) - ret += f'\t[{c9util.ver_enum(ver)}] = {{.name="{ver}", .min_msg_size={min_msg_size}}},\n' + rlerror = next(typ for typ in typs if typ.typname == "Rlerror") + rread = next(typ for typ in typs if typ.typname == "Rread") + for ver in sorted(versions): + ret += cutil.ifdef_push(1, c9util.ver_ifdef({ver})) + min_rerror_size = rerror.min_size(ver) + if ver == "9P2000.L": # SPECIAL (9P2000.L) + min_rerror_size = rlerror.min_size(ver) + min_rread_size = rread.min_size(ver) + ret += f'\t[{c9util.ver_enum(ver)}] = {{.name="{ver}", .min_Rerror_size={min_rerror_size}, .min_Rread_size={min_rread_size}}},\n' ret += cutil.ifdef_pop(0) ret += "};\n" @@ -143,19 +139,14 @@ def gen_c(versions: set[str], typs: list[idl.UserType]) -> str: cstruct: str, cname: str, each: str, _range: tuple[int, int, int] ) -> str: ret = f"const struct {c9util.ident(cstruct)} {c9util.ident(cname)}[{c9util.ver_enum('NUM')}][{hex(len(range(*_range)))}] = {{\n" - for ver in ["unknown", *sorted(versions)]: - if ver != "unknown": - ret += cutil.ifdef_push(1, c9util.ver_ifdef({ver})) + for ver in sorted(versions): + ret += cutil.ifdef_push(1, c9util.ver_ifdef({ver})) ret += f"\t[{c9util.ver_enum(ver)}] = {{\n" for n in range(*_range): xmsg: idl.Message | None = id2typ.get(n, None) if xmsg: - if ver == "unknown": # SPECIAL (initialization) - if xmsg.typname not in ["Tversion", "Rversion", "Rerror"]: - xmsg = None - else: - if ver not in xmsg.in_versions: - xmsg = None + if ver not in xmsg.in_versions: + xmsg = None if xmsg: ret += f"\t\t{each}({xmsg.typname}),\n" ret += "\t},\n" @@ -194,6 +185,7 @@ def gen_c(versions: set[str], typs: list[idl.UserType]) -> str: ret += msg_table("_send_tentry", "_table_Rmsg_send", "_MSG_SEND", (1, 0x100, 2)) ret += f""" +{cutil.ifdef_push(1, c9util.ver_ifdef(next(typ for typ in typs if typ.typname == 'stat').in_versions)).rstrip()} LM_FLATTEN ssize_t {c9util.ident('_stat_validate')}(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes, uint32_t *ret_net_size) {{ \treturn validate_stat(ctx, net_size, net_bytes, ret_net_size); }} @@ -203,7 +195,7 @@ LM_FLATTEN void {c9util.ident('_stat_unmarshal')}(struct lib9p_ctx *ctx, uint8_t LM_FLATTEN bool {c9util.ident('_stat_marshal')}(struct lib9p_ctx *ctx, struct {c9util.ident('stat')} *val, struct _marshal_ret *ret) {{ \treturn marshal_stat(ctx, val, ret); }} -""" +{cutil.ifdef_pop(0)}""" ############################################################################ return ret diff --git a/lib9p/core_gen/c_format.py b/lib9p/core_gen/c_format.py index f9eee90..c633fbb 100644 --- a/lib9p/core_gen/c_format.py +++ b/lib9p/core_gen/c_format.py @@ -105,7 +105,7 @@ def gen_c_format(versions: set[str], typs: list[idl.UserType]) -> str: ret += "\tif (empty)\n" ret += "\t\tfmt_state_putchar(state, '0');\n" ret += "\tfmt_state_putchar(state, ')');\n" - case idl.Struct(typname="s"): # SPECIAL(string) + case idl.Struct(typname="s"): # SPECIAL (string) ret += ext_printf( '\tfmt_state_printf(state, "%.*q", self->len, self->utf8);\n' ) diff --git a/lib9p/core_gen/c_marshal.py b/lib9p/core_gen/c_marshal.py index 620bdea..322e1ef 100644 --- a/lib9p/core_gen/c_marshal.py +++ b/lib9p/core_gen/c_marshal.py @@ -370,21 +370,21 @@ def gen_c_marshal(versions: set[str], typs: list[idl.UserType]) -> str: # Pass 1 - check size max_size = max(typ.max_size(v) for v in typ.in_versions) + szbits = 32 if max_size > cutil.UINT32_MAX: # SPECIAL (9P2000.e) - ret += get_offset_expr(typ, go_to_end).gen_c( - "uint64_t", "needed_size", "val->", 1, 0 - ) + szbits = 64 + ret += get_offset_expr(typ, go_to_end).gen_c( + f"uint{szbits}_t", "needed_size", "val->", 1, 0 + ) + if szbits > 32: # SPECIAL (9P2000.e) ret += "\tif (needed_size > (uint64_t)(ctx->max_msg_size)) {\n" else: - ret += get_offset_expr(typ, go_to_end).gen_c( - "uint32_t", "needed_size", "val->", 1, 0 - ) ret += "\tif (needed_size > ctx->max_msg_size) {\n" if isinstance(typ, idl.Message): # SPECIAL (disable for stat) - ret += f'\t\tlib9p_errorf(ctx, {c9util.IDENT("ERRNO_L_ERANGE")}, "%s message too large to marshal into %s limit (limit=%"PRIu32")",\n' + ret += f'\t\tlib9p_errorf(ctx, {c9util.IDENT("ERRNO_L_ERANGE")}, "%s message too large to marshal into %s limit (%"PRIu{szbits}" > %"PRIu32")",\n' ret += f'\t\t\t"{typ.typname}",\n' ret += f'\t\t\tctx->version ? "negotiated" : "{'client' if typ.msgid % 2 == 0 else 'server'}",\n' - ret += "\t\t\tctx->max_msg_size);\n" + ret += "\t\t\tneeded_size, ctx->max_msg_size);\n" ret += "\t\treturn true;\n" ret += "\t}\n" diff --git a/lib9p/core_gen/h.py b/lib9p/core_gen/h.py index 3defcb8..3c857c1 100644 --- a/lib9p/core_gen/h.py +++ b/lib9p/core_gen/h.py @@ -192,14 +192,21 @@ def gen_h(versions: set[str], typs: list[idl.UserType]) -> str: ret += "\t#endif\n" ret += "#endif\n" + # SPECIAL (convenience) + ret += "\n" + ret += f"#define _LIB9P_ENABLE_stat {c9util.ver_ifdef(next(typ for typ in typs if typ.typname == 'stat').in_versions)}\n" + ret += f""" /* enum version ***************************************************************/ enum {c9util.ident('version')} {{ """ - fullversions = ["unknown = 0", *sorted(versions)] - verwidth = max(len(v) for v in fullversions) - for ver in fullversions: + xversions = [ # SPECIAL (initialization) + "uninitialized = 0", + *sorted(v for v in versions if v != "uninitialized"), + ] + verwidth = max(len(v) for v in xversions) + for ver in xversions: if ver in versions: ret += cutil.ifdef_push(1, c9util.ver_ifdef({ver})) ret += f"\t{c9util.ver_enum(ver)}," diff --git a/lib9p/core_generated.c b/lib9p/core_generated.c index 1789bdc..1de7c67 100644 --- a/lib9p/core_generated.c +++ b/lib9p/core_generated.c @@ -1,4 +1,4 @@ -/* Generated by `lib9p/core.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! */ +/* Generated by `lib9p/core.gen lib9p/idl/0000-uninitialized.9p 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 */ @@ -14,33 +14,35 @@ #include "core_utf8.h" /* libobj vtables *************************************************************/ -#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 +#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 || CONFIG_9P_ENABLE_uninitialized LO_IMPLEMENTATION_C(fmt_formatter, lib9p_tag_t, lib9p_tag, static); LO_IMPLEMENTATION_C(fmt_formatter, lib9p_fid_t, lib9p_fid, static); LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_s, lib9p_s, static); -#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 +#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 || CONFIG_9P_ENABLE_uninitialized */ +#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized LO_IMPLEMENTATION_C(fmt_formatter, lib9p_dm_t, lib9p_dm, static); -#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 +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */ +#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 || CONFIG_9P_ENABLE_uninitialized LO_IMPLEMENTATION_C(fmt_formatter, lib9p_qt_t, lib9p_qt, static); LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_qid, lib9p_qid, static); -#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 */ +#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 || CONFIG_9P_ENABLE_uninitialized */ #if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_stat, lib9p_stat, static); LO_IMPLEMENTATION_C(fmt_formatter, lib9p_o_t, lib9p_o, static); #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 +#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 || CONFIG_9P_ENABLE_uninitialized LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tversion, lib9p_msg_Tversion, static); LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rversion, lib9p_msg_Rversion, static); +#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 || CONFIG_9P_ENABLE_uninitialized */ +#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 LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tauth, lib9p_msg_Tauth, static); LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rauth, lib9p_msg_Rauth, static); LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tattach, lib9p_msg_Tattach, static); LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rattach, lib9p_msg_Rattach, static); #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 +#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rerror, lib9p_msg_Rerror, static); -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || 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 || CONFIG_9P_ENABLE_uninitialized */ #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 LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tflush, lib9p_msg_Tflush, static); LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rflush, lib9p_msg_Rflush, static); @@ -163,6 +165,11 @@ LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rswrite, lib9p_msg_Rswrite, #else #define _is_ver_9P2000_u(v) false #endif +#if CONFIG_9P_ENABLE_uninitialized + #define _is_ver_uninitialized(v) (v == LIB9P_VER_uninitialized) +#else + #define _is_ver_uninitialized(v) false +#endif /** * is_ver(ctx, ver) is essentially `(ctx->version == LIB9P_VER_##ver)`, but @@ -177,142 +184,166 @@ LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rswrite, lib9p_msg_Rswrite, #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] = 0b11111100000000000000000111111111, + [LIB9P_VER_9P2000] = 0b11111100000000000000000111111111, #endif /* CONFIG_9P_ENABLE_9P2000 */ #if CONFIG_9P_ENABLE_9P2000_L - [LIB9P_VER_9P2000_L] = 0b00000000000000000000000000000000, + [LIB9P_VER_9P2000_L] = 0b00000000000000000000000000000000, #endif /* CONFIG_9P_ENABLE_9P2000_L */ #if CONFIG_9P_ENABLE_9P2000_e - [LIB9P_VER_9P2000_e] = 0b11111100000000000000000111111111, + [LIB9P_VER_9P2000_e] = 0b11111100000000000000000111111111, #endif /* CONFIG_9P_ENABLE_9P2000_e */ #if CONFIG_9P_ENABLE_9P2000_p9p - [LIB9P_VER_9P2000_p9p] = 0b11111100000000000000000111111111, + [LIB9P_VER_9P2000_p9p] = 0b11111100000000000000000111111111, #endif /* CONFIG_9P_ENABLE_9P2000_p9p */ #if CONFIG_9P_ENABLE_9P2000_u - [LIB9P_VER_9P2000_u] = 0b11111100101111000000000111111111, + [LIB9P_VER_9P2000_u] = 0b11111100101111000000000111111111, #endif /* CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_uninitialized + [LIB9P_VER_uninitialized] = 0b11111100000000000000000111111111, +#endif /* CONFIG_9P_ENABLE_uninitialized */ }; #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] = 0b11111100, + [LIB9P_VER_9P2000] = 0b11111100, #endif /* CONFIG_9P_ENABLE_9P2000 */ #if CONFIG_9P_ENABLE_9P2000_L - [LIB9P_VER_9P2000_L] = 0b11111100, + [LIB9P_VER_9P2000_L] = 0b11111100, #endif /* CONFIG_9P_ENABLE_9P2000_L */ #if CONFIG_9P_ENABLE_9P2000_e - [LIB9P_VER_9P2000_e] = 0b11111100, + [LIB9P_VER_9P2000_e] = 0b11111100, #endif /* CONFIG_9P_ENABLE_9P2000_e */ #if CONFIG_9P_ENABLE_9P2000_p9p - [LIB9P_VER_9P2000_p9p] = 0b11111100, + [LIB9P_VER_9P2000_p9p] = 0b11111100, #endif /* CONFIG_9P_ENABLE_9P2000_p9p */ #if CONFIG_9P_ENABLE_9P2000_u - [LIB9P_VER_9P2000_u] = 0b11111110, + [LIB9P_VER_9P2000_u] = 0b11111110, #endif /* CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_uninitialized + [LIB9P_VER_uninitialized] = 0b11111100, +#endif /* CONFIG_9P_ENABLE_uninitialized */ }; #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, + [LIB9P_VER_9P2000] = 0b01010011, #endif /* CONFIG_9P_ENABLE_9P2000 */ #if CONFIG_9P_ENABLE_9P2000_L - [LIB9P_VER_9P2000_L] = 0b00000000, + [LIB9P_VER_9P2000_L] = 0b00000000, #endif /* CONFIG_9P_ENABLE_9P2000_L */ #if CONFIG_9P_ENABLE_9P2000_e - [LIB9P_VER_9P2000_e] = 0b01010011, + [LIB9P_VER_9P2000_e] = 0b01010011, #endif /* CONFIG_9P_ENABLE_9P2000_e */ #if CONFIG_9P_ENABLE_9P2000_p9p - [LIB9P_VER_9P2000_p9p] = 0b01010011, + [LIB9P_VER_9P2000_p9p] = 0b01010011, #endif /* CONFIG_9P_ENABLE_9P2000_p9p */ #if CONFIG_9P_ENABLE_9P2000_u - [LIB9P_VER_9P2000_u] = 0b01010011, + [LIB9P_VER_9P2000_u] = 0b01010011, #endif /* CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_uninitialized + [LIB9P_VER_uninitialized] = 0b00000000, +#endif /* CONFIG_9P_ENABLE_uninitialized */ }; #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, + [LIB9P_VER_9P2000] = 0b00000000000000000000000000000000, #endif /* CONFIG_9P_ENABLE_9P2000 */ - [LIB9P_VER_9P2000_L] = 0b00000000000111111111111111000011, + [LIB9P_VER_9P2000_L] = 0b00000000000111111111111111000011, #if CONFIG_9P_ENABLE_9P2000_e - [LIB9P_VER_9P2000_e] = 0b00000000000000000000000000000000, + [LIB9P_VER_9P2000_e] = 0b00000000000000000000000000000000, #endif /* CONFIG_9P_ENABLE_9P2000_e */ #if CONFIG_9P_ENABLE_9P2000_p9p - [LIB9P_VER_9P2000_p9p] = 0b00000000000000000000000000000000, + [LIB9P_VER_9P2000_p9p] = 0b00000000000000000000000000000000, #endif /* CONFIG_9P_ENABLE_9P2000_p9p */ #if CONFIG_9P_ENABLE_9P2000_u - [LIB9P_VER_9P2000_u] = 0b00000000000000000000000000000000, + [LIB9P_VER_9P2000_u] = 0b00000000000000000000000000000000, #endif /* CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_uninitialized + [LIB9P_VER_uninitialized] = 0b00000000000000000000000000000000, +#endif /* CONFIG_9P_ENABLE_uninitialized */ }; static const lib9p_mode_t mode_masks[LIB9P_VER_NUM] = { #if CONFIG_9P_ENABLE_9P2000 - [LIB9P_VER_9P2000] = 0b00000000000000000000000000000000, + [LIB9P_VER_9P2000] = 0b00000000000000000000000000000000, #endif /* CONFIG_9P_ENABLE_9P2000 */ - [LIB9P_VER_9P2000_L] = 0b00000000000000001111111111111111, + [LIB9P_VER_9P2000_L] = 0b00000000000000001111111111111111, #if CONFIG_9P_ENABLE_9P2000_e - [LIB9P_VER_9P2000_e] = 0b00000000000000000000000000000000, + [LIB9P_VER_9P2000_e] = 0b00000000000000000000000000000000, #endif /* CONFIG_9P_ENABLE_9P2000_e */ #if CONFIG_9P_ENABLE_9P2000_p9p - [LIB9P_VER_9P2000_p9p] = 0b00000000000000000000000000000000, + [LIB9P_VER_9P2000_p9p] = 0b00000000000000000000000000000000, #endif /* CONFIG_9P_ENABLE_9P2000_p9p */ #if CONFIG_9P_ENABLE_9P2000_u - [LIB9P_VER_9P2000_u] = 0b00000000000000000000000000000000, + [LIB9P_VER_9P2000_u] = 0b00000000000000000000000000000000, #endif /* CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_uninitialized + [LIB9P_VER_uninitialized] = 0b00000000000000000000000000000000, +#endif /* CONFIG_9P_ENABLE_uninitialized */ }; static const lib9p_getattr_t getattr_masks[LIB9P_VER_NUM] = { #if CONFIG_9P_ENABLE_9P2000 - [LIB9P_VER_9P2000] = 0b0000000000000000000000000000000000000000000000000000000000000000, + [LIB9P_VER_9P2000] = 0b0000000000000000000000000000000000000000000000000000000000000000, #endif /* CONFIG_9P_ENABLE_9P2000 */ - [LIB9P_VER_9P2000_L] = 0b0000000000000000000000000000000000000000000000000011111111111111, + [LIB9P_VER_9P2000_L] = 0b0000000000000000000000000000000000000000000000000011111111111111, #if CONFIG_9P_ENABLE_9P2000_e - [LIB9P_VER_9P2000_e] = 0b0000000000000000000000000000000000000000000000000000000000000000, + [LIB9P_VER_9P2000_e] = 0b0000000000000000000000000000000000000000000000000000000000000000, #endif /* CONFIG_9P_ENABLE_9P2000_e */ #if CONFIG_9P_ENABLE_9P2000_p9p - [LIB9P_VER_9P2000_p9p] = 0b0000000000000000000000000000000000000000000000000000000000000000, + [LIB9P_VER_9P2000_p9p] = 0b0000000000000000000000000000000000000000000000000000000000000000, #endif /* CONFIG_9P_ENABLE_9P2000_p9p */ #if CONFIG_9P_ENABLE_9P2000_u - [LIB9P_VER_9P2000_u] = 0b0000000000000000000000000000000000000000000000000000000000000000, + [LIB9P_VER_9P2000_u] = 0b0000000000000000000000000000000000000000000000000000000000000000, #endif /* CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_uninitialized + [LIB9P_VER_uninitialized] = 0b0000000000000000000000000000000000000000000000000000000000000000, +#endif /* CONFIG_9P_ENABLE_uninitialized */ }; static const lib9p_setattr_t setattr_masks[LIB9P_VER_NUM] = { #if CONFIG_9P_ENABLE_9P2000 - [LIB9P_VER_9P2000] = 0b00000000000000000000000000000000, + [LIB9P_VER_9P2000] = 0b00000000000000000000000000000000, #endif /* CONFIG_9P_ENABLE_9P2000 */ - [LIB9P_VER_9P2000_L] = 0b00000000000000000000000111111111, + [LIB9P_VER_9P2000_L] = 0b00000000000000000000000111111111, #if CONFIG_9P_ENABLE_9P2000_e - [LIB9P_VER_9P2000_e] = 0b00000000000000000000000000000000, + [LIB9P_VER_9P2000_e] = 0b00000000000000000000000000000000, #endif /* CONFIG_9P_ENABLE_9P2000_e */ #if CONFIG_9P_ENABLE_9P2000_p9p - [LIB9P_VER_9P2000_p9p] = 0b00000000000000000000000000000000, + [LIB9P_VER_9P2000_p9p] = 0b00000000000000000000000000000000, #endif /* CONFIG_9P_ENABLE_9P2000_p9p */ #if CONFIG_9P_ENABLE_9P2000_u - [LIB9P_VER_9P2000_u] = 0b00000000000000000000000000000000, + [LIB9P_VER_9P2000_u] = 0b00000000000000000000000000000000, #endif /* CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_uninitialized + [LIB9P_VER_uninitialized] = 0b00000000000000000000000000000000, +#endif /* CONFIG_9P_ENABLE_uninitialized */ }; static const lib9p_lock_flags_t lock_flags_masks[LIB9P_VER_NUM] = { #if CONFIG_9P_ENABLE_9P2000 - [LIB9P_VER_9P2000] = 0b00000000000000000000000000000000, + [LIB9P_VER_9P2000] = 0b00000000000000000000000000000000, #endif /* CONFIG_9P_ENABLE_9P2000 */ - [LIB9P_VER_9P2000_L] = 0b00000000000000000000000000000011, + [LIB9P_VER_9P2000_L] = 0b00000000000000000000000000000011, #if CONFIG_9P_ENABLE_9P2000_e - [LIB9P_VER_9P2000_e] = 0b00000000000000000000000000000000, + [LIB9P_VER_9P2000_e] = 0b00000000000000000000000000000000, #endif /* CONFIG_9P_ENABLE_9P2000_e */ #if CONFIG_9P_ENABLE_9P2000_p9p - [LIB9P_VER_9P2000_p9p] = 0b00000000000000000000000000000000, + [LIB9P_VER_9P2000_p9p] = 0b00000000000000000000000000000000, #endif /* CONFIG_9P_ENABLE_9P2000_p9p */ #if CONFIG_9P_ENABLE_9P2000_u - [LIB9P_VER_9P2000_u] = 0b00000000000000000000000000000000, + [LIB9P_VER_9P2000_u] = 0b00000000000000000000000000000000, #endif /* CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_uninitialized + [LIB9P_VER_uninitialized] = 0b00000000000000000000000000000000, +#endif /* CONFIG_9P_ENABLE_uninitialized */ }; #endif /* CONFIG_9P_ENABLE_9P2000_L */ @@ -352,14 +383,14 @@ static const lib9p_lock_flags_t lock_flags_masks[LIB9P_VER_NUM] = { 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; + uint32_t offsetof__stat_size = net_offset + 0; + uint32_t offsetof_fstype = net_offset + 2; + uint32_t offsetof_qid_type = net_offset + 8; VALIDATE_NET_BYTES(21); - if (GET_U8LE(offsetof_file_qid_type) & ~qt_masks[ctx->version]) + if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]) return lib9p_errorf(ctx, LIB9P_ERRNO_L_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; + GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]); + uint32_t offsetof_mode = net_offset + 0; VALIDATE_NET_BYTES(22); VALIDATE_NET_UTF8(LAST_U16LE()); VALIDATE_NET_BYTES(2); @@ -376,19 +407,19 @@ static ssize_t validate_stat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t * } #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, LIB9P_ERRNO_L_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]) + if ((uint32_t)GET_U32LE(offsetof__stat_size) != (uint32_t)(offsetof_end - offsetof_fstype)) + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "stat->_stat_size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + (uint32_t)GET_U32LE(offsetof__stat_size), (uint32_t)(offsetof_end - offsetof_fstype)); + if (GET_U32LE(offsetof_mode) & ~dm_masks[ctx->version]) return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in dm bitfield: %#08"PRIx32, - GET_U32LE(offsetof_file_mode) & ~dm_masks[ctx->version]); + GET_U32LE(offsetof_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 +#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 || CONFIG_9P_ENABLE_uninitialized 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); @@ -423,6 +454,8 @@ static ssize_t validate_Rversion(struct lib9p_ctx *ctx, uint32_t net_size, uint8 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 || CONFIG_9P_ENABLE_uninitialized */ +#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_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); @@ -512,7 +545,7 @@ static ssize_t validate_Rattach(struct lib9p_ctx *ctx, uint32_t net_size, uint8_ } #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 +#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized 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); @@ -535,7 +568,7 @@ static ssize_t validate_Rerror(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t 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 */ +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */ #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_Tflush(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) { uint32_t net_offset = 0; @@ -893,14 +926,14 @@ static ssize_t validate_Rstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t 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; + uint32_t offsetof_stat__stat_size = net_offset + 9; + uint32_t offsetof_stat_fstype = net_offset + 11; + uint32_t offsetof_stat_qid_type = net_offset + 17; VALIDATE_NET_BYTES(30); - if (GET_U8LE(offsetof_stat_file_qid_type) & ~qt_masks[ctx->version]) + if (GET_U8LE(offsetof_stat_qid_type) & ~qt_masks[ctx->version]) return lib9p_errorf(ctx, LIB9P_ERRNO_L_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; + GET_U8LE(offsetof_stat_qid_type) & ~qt_masks[ctx->version]); + uint32_t offsetof_stat_mode = net_offset + 0; VALIDATE_NET_BYTES(22); VALIDATE_NET_UTF8(LAST_U16LE()); VALIDATE_NET_BYTES(2); @@ -917,12 +950,12 @@ static ssize_t validate_Rstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t } #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, LIB9P_ERRNO_L_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]) + if ((uint32_t)GET_U32LE(offsetof_stat__stat_size) != (uint32_t)(offsetof_stat_end - offsetof_stat_fstype)) + return lib9p_errorf(ctx, LIB9P_ERRNO_L_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_fstype)); + if (GET_U32LE(offsetof_stat_mode) & ~dm_masks[ctx->version]) return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in dm bitfield: %#08"PRIx32, - GET_U32LE(offsetof_stat_file_mode) & ~dm_masks[ctx->version]); + GET_U32LE(offsetof_stat_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, LIB9P_ERRNO_L_EBADMSG, "Rstat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, @@ -943,14 +976,14 @@ static ssize_t validate_Twstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t 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; + uint32_t offsetof_stat__stat_size = net_offset + 13; + uint32_t offsetof_stat_fstype = net_offset + 15; + uint32_t offsetof_stat_qid_type = net_offset + 21; VALIDATE_NET_BYTES(34); - if (GET_U8LE(offsetof_stat_file_qid_type) & ~qt_masks[ctx->version]) + if (GET_U8LE(offsetof_stat_qid_type) & ~qt_masks[ctx->version]) return lib9p_errorf(ctx, LIB9P_ERRNO_L_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; + GET_U8LE(offsetof_stat_qid_type) & ~qt_masks[ctx->version]); + uint32_t offsetof_stat_mode = net_offset + 0; VALIDATE_NET_BYTES(22); VALIDATE_NET_UTF8(LAST_U16LE()); VALIDATE_NET_BYTES(2); @@ -967,12 +1000,12 @@ static ssize_t validate_Twstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t } #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, LIB9P_ERRNO_L_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]) + if ((uint32_t)GET_U32LE(offsetof_stat__stat_size) != (uint32_t)(offsetof_stat_end - offsetof_stat_fstype)) + return lib9p_errorf(ctx, LIB9P_ERRNO_L_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_fstype)); + if (GET_U32LE(offsetof_stat_mode) & ~dm_masks[ctx->version]) return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in dm bitfield: %#08"PRIx32, - GET_U32LE(offsetof_stat_file_mode) & ~dm_masks[ctx->version]); + GET_U32LE(offsetof_stat_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, LIB9P_ERRNO_L_EBADMSG, "Twstat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, @@ -1903,36 +1936,36 @@ static void unmarshal_stat([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_b [[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); + UNMARSHAL_U16LE(ctx, out->fstype); + UNMARSHAL_U32LE(ctx, out->fsdev); + 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->atime); + UNMARSHAL_U32LE(ctx, out->mtime); + UNMARSHAL_U64LE(ctx, out->length); + UNMARSHAL_U16LE(ctx, out->name.len); + UNMARSHAL_BYTES(ctx, out->name.utf8, out->name.len); + UNMARSHAL_U16LE(ctx, out->owner_uname.len); + UNMARSHAL_BYTES(ctx, out->owner_uname.utf8, out->owner_uname.len); + UNMARSHAL_U16LE(ctx, out->owner_gname.len); + UNMARSHAL_BYTES(ctx, out->owner_gname.utf8, out->owner_gname.len); + UNMARSHAL_U16LE(ctx, out->last_modifier_uname.len); + UNMARSHAL_BYTES(ctx, out->last_modifier_uname.utf8, out->last_modifier_uname.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); + UNMARSHAL_U16LE(ctx, out->extension.len); + UNMARSHAL_BYTES(ctx, out->extension.utf8, out->extension.len); + UNMARSHAL_U32LE(ctx, out->owner_unum); + UNMARSHAL_U32LE(ctx, out->owner_gnum); + UNMARSHAL_U32LE(ctx, out->last_modifier_unum); } #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 +#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 || CONFIG_9P_ENABLE_uninitialized 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]; @@ -1957,6 +1990,8 @@ static void unmarshal_Rversion([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *n UNMARSHAL_BYTES(ctx, out->version.utf8, out->version.len); } +#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 || CONFIG_9P_ENABLE_uninitialized */ +#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_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]; @@ -1971,7 +2006,7 @@ static void unmarshal_Tauth([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_ 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); + UNMARSHAL_U32LE(ctx, out->unum); } #endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ } @@ -2003,7 +2038,7 @@ static void unmarshal_Tattach([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *ne 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); + UNMARSHAL_U32LE(ctx, out->unum); } #endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ } @@ -2021,7 +2056,7 @@ static void unmarshal_Rattach([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *ne } #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 +#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized 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]; @@ -2038,7 +2073,7 @@ static void unmarshal_Rerror([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net #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 */ +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */ #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_Tflush([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Tflush *out = out_buf; @@ -2254,30 +2289,30 @@ static void unmarshal_Rstat([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_ 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); + UNMARSHAL_U16LE(ctx, out->stat.fstype); + UNMARSHAL_U32LE(ctx, out->stat.fsdev); + UNMARSHAL_U8LE(ctx, out->stat.qid.type); + UNMARSHAL_U32LE(ctx, out->stat.qid.vers); + UNMARSHAL_U64LE(ctx, out->stat.qid.path); + UNMARSHAL_U32LE(ctx, out->stat.mode); + UNMARSHAL_U32LE(ctx, out->stat.atime); + UNMARSHAL_U32LE(ctx, out->stat.mtime); + UNMARSHAL_U64LE(ctx, out->stat.length); + UNMARSHAL_U16LE(ctx, out->stat.name.len); + UNMARSHAL_BYTES(ctx, out->stat.name.utf8, out->stat.name.len); + UNMARSHAL_U16LE(ctx, out->stat.owner_uname.len); + UNMARSHAL_BYTES(ctx, out->stat.owner_uname.utf8, out->stat.owner_uname.len); + UNMARSHAL_U16LE(ctx, out->stat.owner_gname.len); + UNMARSHAL_BYTES(ctx, out->stat.owner_gname.utf8, out->stat.owner_gname.len); + UNMARSHAL_U16LE(ctx, out->stat.last_modifier_uname.len); + UNMARSHAL_BYTES(ctx, out->stat.last_modifier_uname.utf8, out->stat.last_modifier_uname.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); + UNMARSHAL_U16LE(ctx, out->stat.extension.len); + UNMARSHAL_BYTES(ctx, out->stat.extension.utf8, out->stat.extension.len); + UNMARSHAL_U32LE(ctx, out->stat.owner_unum); + UNMARSHAL_U32LE(ctx, out->stat.owner_gnum); + UNMARSHAL_U32LE(ctx, out->stat.last_modifier_unum); } #endif /* CONFIG_9P_ENABLE_9P2000_u */ } @@ -2292,30 +2327,30 @@ static void unmarshal_Twstat([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net 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); + UNMARSHAL_U16LE(ctx, out->stat.fstype); + UNMARSHAL_U32LE(ctx, out->stat.fsdev); + UNMARSHAL_U8LE(ctx, out->stat.qid.type); + UNMARSHAL_U32LE(ctx, out->stat.qid.vers); + UNMARSHAL_U64LE(ctx, out->stat.qid.path); + UNMARSHAL_U32LE(ctx, out->stat.mode); + UNMARSHAL_U32LE(ctx, out->stat.atime); + UNMARSHAL_U32LE(ctx, out->stat.mtime); + UNMARSHAL_U64LE(ctx, out->stat.length); + UNMARSHAL_U16LE(ctx, out->stat.name.len); + UNMARSHAL_BYTES(ctx, out->stat.name.utf8, out->stat.name.len); + UNMARSHAL_U16LE(ctx, out->stat.owner_uname.len); + UNMARSHAL_BYTES(ctx, out->stat.owner_uname.utf8, out->stat.owner_uname.len); + UNMARSHAL_U16LE(ctx, out->stat.owner_gname.len); + UNMARSHAL_BYTES(ctx, out->stat.owner_gname.utf8, out->stat.owner_gname.len); + UNMARSHAL_U16LE(ctx, out->stat.last_modifier_uname.len); + UNMARSHAL_BYTES(ctx, out->stat.last_modifier_uname.utf8, out->stat.last_modifier_uname.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); + UNMARSHAL_U16LE(ctx, out->stat.extension.len); + UNMARSHAL_BYTES(ctx, out->stat.extension.utf8, out->stat.extension.len); + UNMARSHAL_U32LE(ctx, out->stat.owner_unum); + UNMARSHAL_U32LE(ctx, out->stat.owner_gnum); + UNMARSHAL_U32LE(ctx, out->stat.last_modifier_unum); } #endif /* CONFIG_9P_ENABLE_9P2000_u */ } @@ -2977,56 +3012,56 @@ static void unmarshal_Rswrite([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *ne #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; + uint32_t needed_size = 49 + val->name.len + val->owner_uname.len + val->owner_gname.len + val->last_modifier_uname.len; #if CONFIG_9P_ENABLE_9P2000_u if is_ver(ctx, 9P2000_u) { - needed_size += 14 + val->file_extension.len; + needed_size += 14 + val->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); + uint32_t offsetof_fstype = 2; + MARSHAL_U16LE(ctx, offsetof_end - offsetof_fstype); + MARSHAL_U16LE(ctx, val->fstype); + MARSHAL_U32LE(ctx, val->fsdev); + 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 & dm_masks[ctx->version]); + MARSHAL_U32LE(ctx, val->atime); + MARSHAL_U32LE(ctx, val->mtime); + MARSHAL_U64LE(ctx, val->length); + MARSHAL_U16LE(ctx, val->name.len); + MARSHAL_BYTES(ctx, val->name.utf8, val->name.len); + MARSHAL_U16LE(ctx, val->owner_uname.len); + MARSHAL_BYTES(ctx, val->owner_uname.utf8, val->owner_uname.len); + MARSHAL_U16LE(ctx, val->owner_gname.len); + MARSHAL_BYTES(ctx, val->owner_gname.utf8, val->owner_gname.len); + MARSHAL_U16LE(ctx, val->last_modifier_uname.len); + MARSHAL_BYTES(ctx, val->last_modifier_uname.utf8, val->last_modifier_uname.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); + MARSHAL_U16LE(ctx, val->extension.len); + MARSHAL_BYTES(ctx, val->extension.utf8, val->extension.len); + MARSHAL_U32LE(ctx, val->owner_unum); + MARSHAL_U32LE(ctx, val->owner_gnum); + MARSHAL_U32LE(ctx, val->last_modifier_unum); } #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 +#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 || CONFIG_9P_ENABLE_uninitialized 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Tversion", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3043,10 +3078,10 @@ static bool marshal_Tversion(struct lib9p_ctx *ctx, struct lib9p_msg_Tversion *v 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Rversion", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3060,6 +3095,8 @@ static bool marshal_Rversion(struct lib9p_ctx *ctx, struct lib9p_msg_Rversion *v 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 || CONFIG_9P_ENABLE_uninitialized */ +#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_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 @@ -3068,10 +3105,10 @@ static bool marshal_Tauth(struct lib9p_ctx *ctx, struct lib9p_msg_Tauth *val, st } #endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Tauth", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3086,7 +3123,7 @@ static bool marshal_Tauth(struct lib9p_ctx *ctx, struct lib9p_msg_Tauth *val, st 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); + MARSHAL_U32LE(ctx, val->unum); } #endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ return false; @@ -3095,10 +3132,10 @@ static bool marshal_Tauth(struct lib9p_ctx *ctx, struct lib9p_msg_Tauth *val, st 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Rauth", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3120,10 +3157,10 @@ static bool marshal_Tattach(struct lib9p_ctx *ctx, struct lib9p_msg_Tattach *val } #endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Tattach", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3139,7 +3176,7 @@ static bool marshal_Tattach(struct lib9p_ctx *ctx, struct lib9p_msg_Tattach *val 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); + MARSHAL_U32LE(ctx, val->unum); } #endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ return false; @@ -3148,10 +3185,10 @@ static bool marshal_Tattach(struct lib9p_ctx *ctx, struct lib9p_msg_Tattach *val 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Rattach", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3166,7 +3203,7 @@ static bool marshal_Rattach(struct lib9p_ctx *ctx, struct lib9p_msg_Rattach *val } #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 +#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized static bool marshal_Rerror(struct lib9p_ctx *ctx, struct lib9p_msg_Rerror *val, struct _marshal_ret *ret) { uint32_t needed_size = 9 + val->errstr.len; #if CONFIG_9P_ENABLE_9P2000_u @@ -3175,10 +3212,10 @@ static bool marshal_Rerror(struct lib9p_ctx *ctx, struct lib9p_msg_Rerror *val, } #endif /* CONFIG_9P_ENABLE_9P2000_u */ if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Rerror", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3196,15 +3233,15 @@ static bool marshal_Rerror(struct lib9p_ctx *ctx, struct lib9p_msg_Rerror *val, return false; } -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || 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 || CONFIG_9P_ENABLE_uninitialized */ #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_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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Tflush", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3219,10 +3256,10 @@ static bool marshal_Tflush(struct lib9p_ctx *ctx, struct lib9p_msg_Tflush *val, 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Rflush", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3239,10 +3276,10 @@ static bool marshal_Twalk(struct lib9p_ctx *ctx, struct lib9p_msg_Twalk *val, st needed_size += 2 + val->wname[i].len; } if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Twalk", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3263,10 +3300,10 @@ static bool marshal_Twalk(struct lib9p_ctx *ctx, struct lib9p_msg_Twalk *val, st 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Rwalk", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3288,10 +3325,10 @@ static bool marshal_Rwalk(struct lib9p_ctx *ctx, struct lib9p_msg_Rwalk *val, st 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Topen", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3307,10 +3344,10 @@ static bool marshal_Topen(struct lib9p_ctx *ctx, struct lib9p_msg_Topen *val, st 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Ropen", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3328,10 +3365,10 @@ static bool marshal_Ropen(struct lib9p_ctx *ctx, struct lib9p_msg_Ropen *val, st 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Tcreate", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3350,10 +3387,10 @@ static bool marshal_Tcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Tcreate *val 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Rcreate", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3373,10 +3410,10 @@ static bool marshal_Rcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Rcreate *val 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Tread", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3393,10 +3430,10 @@ static bool marshal_Tread(struct lib9p_ctx *ctx, struct lib9p_msg_Tread *val, st 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Rread", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3412,10 +3449,10 @@ static bool marshal_Rread(struct lib9p_ctx *ctx, struct lib9p_msg_Rread *val, st 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Twrite", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3433,10 +3470,10 @@ static bool marshal_Twrite(struct lib9p_ctx *ctx, struct lib9p_msg_Twrite *val, 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Rwrite", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3451,10 +3488,10 @@ static bool marshal_Rwrite(struct lib9p_ctx *ctx, struct lib9p_msg_Rwrite *val, 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Tclunk", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3469,10 +3506,10 @@ static bool marshal_Tclunk(struct lib9p_ctx *ctx, struct lib9p_msg_Tclunk *val, 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Rclunk", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3486,10 +3523,10 @@ static bool marshal_Rclunk(struct lib9p_ctx *ctx, struct lib9p_msg_Rclunk *val, 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Tremove", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3504,10 +3541,10 @@ static bool marshal_Tremove(struct lib9p_ctx *ctx, struct lib9p_msg_Tremove *val 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Rremove", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3523,10 +3560,10 @@ static bool marshal_Rremove(struct lib9p_ctx *ctx, struct lib9p_msg_Rremove *val 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Tstat", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3539,17 +3576,17 @@ static bool marshal_Tstat(struct lib9p_ctx *ctx, struct lib9p_msg_Tstat *val, st } 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; + uint32_t needed_size = 58 + val->stat.name.len + val->stat.owner_uname.len + val->stat.owner_gname.len + val->stat.last_modifier_uname.len; #if CONFIG_9P_ENABLE_9P2000_u if is_ver(ctx, 9P2000_u) { - needed_size += 14 + val->stat.file_extension.len; + needed_size += 14 + val->stat.extension.len; } #endif /* CONFIG_9P_ENABLE_9P2000_u */ if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Rstat", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3559,55 +3596,55 @@ static bool marshal_Rstat(struct lib9p_ctx *ctx, struct lib9p_msg_Rstat *val, st 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; + uint32_t offsetof_stat_end = 49 + val->stat.name.len + val->stat.owner_uname.len + val->stat.owner_gname.len + val->stat.last_modifier_uname.len; #if CONFIG_9P_ENABLE_9P2000_u if is_ver(ctx, 9P2000_u) { - offsetof_stat_end += 14 + val->stat.file_extension.len; + offsetof_stat_end += 14 + val->stat.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); + uint32_t offsetof_stat_fstype = 2; + MARSHAL_U16LE(ctx, offsetof_stat_end - offsetof_stat_fstype); + MARSHAL_U16LE(ctx, val->stat.fstype); + MARSHAL_U32LE(ctx, val->stat.fsdev); + MARSHAL_U8LE(ctx, val->stat.qid.type & qt_masks[ctx->version]); + MARSHAL_U32LE(ctx, val->stat.qid.vers); + MARSHAL_U64LE(ctx, val->stat.qid.path); + MARSHAL_U32LE(ctx, val->stat.mode & dm_masks[ctx->version]); + MARSHAL_U32LE(ctx, val->stat.atime); + MARSHAL_U32LE(ctx, val->stat.mtime); + MARSHAL_U64LE(ctx, val->stat.length); + MARSHAL_U16LE(ctx, val->stat.name.len); + MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.name.utf8, val->stat.name.len); + MARSHAL_U16LE(ctx, val->stat.owner_uname.len); + MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.owner_uname.utf8, val->stat.owner_uname.len); + MARSHAL_U16LE(ctx, val->stat.owner_gname.len); + MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.owner_gname.utf8, val->stat.owner_gname.len); + MARSHAL_U16LE(ctx, val->stat.last_modifier_uname.len); + MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.last_modifier_uname.utf8, val->stat.last_modifier_uname.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); + MARSHAL_U16LE(ctx, val->stat.extension.len); + MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.extension.utf8, val->stat.extension.len); + MARSHAL_U32LE(ctx, val->stat.owner_unum); + MARSHAL_U32LE(ctx, val->stat.owner_gnum); + MARSHAL_U32LE(ctx, val->stat.last_modifier_unum); } #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; + uint32_t needed_size = 62 + val->stat.name.len + val->stat.owner_uname.len + val->stat.owner_gname.len + val->stat.last_modifier_uname.len; #if CONFIG_9P_ENABLE_9P2000_u if is_ver(ctx, 9P2000_u) { - needed_size += 14 + val->stat.file_extension.len; + needed_size += 14 + val->stat.extension.len; } #endif /* CONFIG_9P_ENABLE_9P2000_u */ if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Twstat", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3618,38 +3655,38 @@ static bool marshal_Twstat(struct lib9p_ctx *ctx, struct lib9p_msg_Twstat *val, 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; + uint32_t offsetof_stat_end = 49 + val->stat.name.len + val->stat.owner_uname.len + val->stat.owner_gname.len + val->stat.last_modifier_uname.len; #if CONFIG_9P_ENABLE_9P2000_u if is_ver(ctx, 9P2000_u) { - offsetof_stat_end += 14 + val->stat.file_extension.len; + offsetof_stat_end += 14 + val->stat.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); + uint32_t offsetof_stat_fstype = 2; + MARSHAL_U16LE(ctx, offsetof_stat_end - offsetof_stat_fstype); + MARSHAL_U16LE(ctx, val->stat.fstype); + MARSHAL_U32LE(ctx, val->stat.fsdev); + MARSHAL_U8LE(ctx, val->stat.qid.type & qt_masks[ctx->version]); + MARSHAL_U32LE(ctx, val->stat.qid.vers); + MARSHAL_U64LE(ctx, val->stat.qid.path); + MARSHAL_U32LE(ctx, val->stat.mode & dm_masks[ctx->version]); + MARSHAL_U32LE(ctx, val->stat.atime); + MARSHAL_U32LE(ctx, val->stat.mtime); + MARSHAL_U64LE(ctx, val->stat.length); + MARSHAL_U16LE(ctx, val->stat.name.len); + MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.name.utf8, val->stat.name.len); + MARSHAL_U16LE(ctx, val->stat.owner_uname.len); + MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.owner_uname.utf8, val->stat.owner_uname.len); + MARSHAL_U16LE(ctx, val->stat.owner_gname.len); + MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.owner_gname.utf8, val->stat.owner_gname.len); + MARSHAL_U16LE(ctx, val->stat.last_modifier_uname.len); + MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.last_modifier_uname.utf8, val->stat.last_modifier_uname.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); + MARSHAL_U16LE(ctx, val->stat.extension.len); + MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.extension.utf8, val->stat.extension.len); + MARSHAL_U32LE(ctx, val->stat.owner_unum); + MARSHAL_U32LE(ctx, val->stat.owner_gnum); + MARSHAL_U32LE(ctx, val->stat.last_modifier_unum); } #endif /* CONFIG_9P_ENABLE_9P2000_u */ return false; @@ -3658,10 +3695,10 @@ static bool marshal_Twstat(struct lib9p_ctx *ctx, struct lib9p_msg_Twstat *val, 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Rwstat", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3677,10 +3714,10 @@ static bool marshal_Rwstat(struct lib9p_ctx *ctx, struct lib9p_msg_Rwstat *val, 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Topenfd", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3696,10 +3733,10 @@ static bool marshal_Topenfd(struct lib9p_ctx *ctx, struct lib9p_msg_Topenfd *val 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Ropenfd", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3720,10 +3757,10 @@ static bool marshal_Ropenfd(struct lib9p_ctx *ctx, struct lib9p_msg_Ropenfd *val 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Rlerror", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3738,10 +3775,10 @@ static bool marshal_Rlerror(struct lib9p_ctx *ctx, struct lib9p_msg_Rlerror *val 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Tstatfs", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3756,10 +3793,10 @@ static bool marshal_Tstatfs(struct lib9p_ctx *ctx, struct lib9p_msg_Tstatfs *val 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Rstatfs", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3782,10 +3819,10 @@ static bool marshal_Rstatfs(struct lib9p_ctx *ctx, struct lib9p_msg_Rstatfs *val 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Tlopen", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3801,10 +3838,10 @@ static bool marshal_Tlopen(struct lib9p_ctx *ctx, struct lib9p_msg_Tlopen *val, 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Rlopen", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3822,10 +3859,10 @@ static bool marshal_Rlopen(struct lib9p_ctx *ctx, struct lib9p_msg_Rlopen *val, 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Tlcreate", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3845,10 +3882,10 @@ static bool marshal_Tlcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Tlcreate *v 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Rlcreate", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3866,10 +3903,10 @@ static bool marshal_Rlcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Rlcreate *v 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Tsymlink", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3889,10 +3926,10 @@ static bool marshal_Tsymlink(struct lib9p_ctx *ctx, struct lib9p_msg_Tsymlink *v 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Rsymlink", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3909,10 +3946,10 @@ static bool marshal_Rsymlink(struct lib9p_ctx *ctx, struct lib9p_msg_Rsymlink *v 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Tmknod", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3933,10 +3970,10 @@ static bool marshal_Tmknod(struct lib9p_ctx *ctx, struct lib9p_msg_Tmknod *val, 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Rmknod", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3953,10 +3990,10 @@ static bool marshal_Rmknod(struct lib9p_ctx *ctx, struct lib9p_msg_Rmknod *val, 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Trename", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3974,10 +4011,10 @@ static bool marshal_Trename(struct lib9p_ctx *ctx, struct lib9p_msg_Trename *val 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Rrename", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -3991,10 +4028,10 @@ static bool marshal_Rrename(struct lib9p_ctx *ctx, struct lib9p_msg_Rrename *val 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Treadlink", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -4009,10 +4046,10 @@ static bool marshal_Treadlink(struct lib9p_ctx *ctx, struct lib9p_msg_Treadlink 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Rreadlink", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -4028,10 +4065,10 @@ static bool marshal_Rreadlink(struct lib9p_ctx *ctx, struct lib9p_msg_Rreadlink 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Tgetattr", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -4047,10 +4084,10 @@ static bool marshal_Tgetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Tgetattr *v 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Rgetattr", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -4086,10 +4123,10 @@ static bool marshal_Rgetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Rgetattr *v 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Tsetattr", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -4113,10 +4150,10 @@ static bool marshal_Tsetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Tsetattr *v 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Rsetattr", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -4130,10 +4167,10 @@ static bool marshal_Rsetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Rsetattr *v 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Txattrwalk", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -4151,10 +4188,10 @@ static bool marshal_Txattrwalk(struct lib9p_ctx *ctx, struct lib9p_msg_Txattrwal 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Rxattrwalk", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -4169,10 +4206,10 @@ static bool marshal_Rxattrwalk(struct lib9p_ctx *ctx, struct lib9p_msg_Rxattrwal 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Txattrcreate", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -4191,10 +4228,10 @@ static bool marshal_Txattrcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Txattrc 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Rxattrcreate", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -4208,10 +4245,10 @@ static bool marshal_Rxattrcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Rxattrc 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Treaddir", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -4228,10 +4265,10 @@ static bool marshal_Treaddir(struct lib9p_ctx *ctx, struct lib9p_msg_Treaddir *v 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu64" > %"PRIu32")", "Rreaddir", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = (uint32_t)needed_size; @@ -4247,10 +4284,10 @@ static bool marshal_Rreaddir(struct lib9p_ctx *ctx, struct lib9p_msg_Rreaddir *v 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Tfsync", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -4266,10 +4303,10 @@ static bool marshal_Tfsync(struct lib9p_ctx *ctx, struct lib9p_msg_Tfsync *val, 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Rfsync", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -4283,10 +4320,10 @@ static bool marshal_Rfsync(struct lib9p_ctx *ctx, struct lib9p_msg_Rfsync *val, 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Tlock", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -4308,10 +4345,10 @@ static bool marshal_Tlock(struct lib9p_ctx *ctx, struct lib9p_msg_Tlock *val, st 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Rlock", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -4326,10 +4363,10 @@ static bool marshal_Rlock(struct lib9p_ctx *ctx, struct lib9p_msg_Rlock *val, st 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Tgetlock", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -4350,10 +4387,10 @@ static bool marshal_Tgetlock(struct lib9p_ctx *ctx, struct lib9p_msg_Tgetlock *v 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Rgetlock", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -4373,10 +4410,10 @@ static bool marshal_Rgetlock(struct lib9p_ctx *ctx, struct lib9p_msg_Rgetlock *v 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Tlink", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -4394,10 +4431,10 @@ static bool marshal_Tlink(struct lib9p_ctx *ctx, struct lib9p_msg_Tlink *val, st 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Rlink", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -4411,10 +4448,10 @@ static bool marshal_Rlink(struct lib9p_ctx *ctx, struct lib9p_msg_Rlink *val, st 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Tmkdir", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -4433,10 +4470,10 @@ static bool marshal_Tmkdir(struct lib9p_ctx *ctx, struct lib9p_msg_Tmkdir *val, 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Rmkdir", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -4453,10 +4490,10 @@ static bool marshal_Rmkdir(struct lib9p_ctx *ctx, struct lib9p_msg_Rmkdir *val, 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Trenameat", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -4476,10 +4513,10 @@ static bool marshal_Trenameat(struct lib9p_ctx *ctx, struct lib9p_msg_Trenameat 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Rrenameat", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -4493,10 +4530,10 @@ static bool marshal_Rrenameat(struct lib9p_ctx *ctx, struct lib9p_msg_Rrenameat 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Tunlinkat", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -4514,10 +4551,10 @@ static bool marshal_Tunlinkat(struct lib9p_ctx *ctx, struct lib9p_msg_Tunlinkat 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Runlinkat", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -4533,10 +4570,10 @@ static bool marshal_Runlinkat(struct lib9p_ctx *ctx, struct lib9p_msg_Runlinkat 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Tsession", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -4551,10 +4588,10 @@ static bool marshal_Tsession(struct lib9p_ctx *ctx, struct lib9p_msg_Tsession *v 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Rsession", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -4571,10 +4608,10 @@ static bool marshal_Tsread(struct lib9p_ctx *ctx, struct lib9p_msg_Tsread *val, needed_size += 2 + val->wname[i].len; } if (needed_size > (uint64_t)(ctx->max_msg_size)) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu64" > %"PRIu32")", "Tsread", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = (uint32_t)needed_size; @@ -4594,10 +4631,10 @@ static bool marshal_Tsread(struct lib9p_ctx *ctx, struct lib9p_msg_Tsread *val, 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu64" > %"PRIu32")", "Rsread", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = (uint32_t)needed_size; @@ -4616,10 +4653,10 @@ static bool marshal_Tswrite(struct lib9p_ctx *ctx, struct lib9p_msg_Tswrite *val needed_size += 2 + val->wname[i].len; } if (needed_size > (uint64_t)(ctx->max_msg_size)) { - lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu64" > %"PRIu32")", "Tswrite", ctx->version ? "negotiated" : "client", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = (uint32_t)needed_size; @@ -4641,10 +4678,10 @@ static bool marshal_Tswrite(struct lib9p_ctx *ctx, struct lib9p_msg_Tswrite *val 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, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (%"PRIu32" > %"PRIu32")", "Rswrite", ctx->version ? "negotiated" : "server", - ctx->max_msg_size); + needed_size, ctx->max_msg_size); return true; } uint32_t offsetof_end = needed_size; @@ -4659,7 +4696,7 @@ static bool marshal_Rswrite(struct lib9p_ctx *ctx, struct lib9p_msg_Rswrite *val /* *_format *******************************************************************/ -#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 +#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 || CONFIG_9P_ENABLE_uninitialized static void lib9p_tag_format(lib9p_tag_t *self, struct fmt_state *state) { switch (*self) { case LIB9P_TAG_NOTAG: @@ -4688,8 +4725,8 @@ static void lib9p_s_format(struct lib9p_s *self, struct fmt_state *state) { #pragma GCC diagnostic pop } -#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 +#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 || CONFIG_9P_ENABLE_uninitialized */ +#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized static void lib9p_dm_format(lib9p_dm_t *self, struct fmt_state *state) { bool empty = true; fmt_state_putchar(state, '('); @@ -4891,8 +4928,8 @@ static void lib9p_dm_format(lib9p_dm_t *self, struct fmt_state *state) { fmt_state_putchar(state, ')'); } -#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 +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */ +#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 || CONFIG_9P_ENABLE_uninitialized static void lib9p_qt_format(lib9p_qt_t *self, struct fmt_state *state) { bool empty = true; fmt_state_putchar(state, '('); @@ -4960,41 +4997,41 @@ static void lib9p_qid_format(struct lib9p_qid *self, struct fmt_state *state) { fmt_state_puts(state, " }"); } -#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 */ +#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 || CONFIG_9P_ENABLE_uninitialized */ #if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u static void lib9p_stat_format(struct lib9p_stat *self, struct fmt_state *state) { fmt_state_putchar(state, '{'); - fmt_state_puts(state, " kern_type="); - fmt_state_printf(state, "%"PRIu16, self->kern_type); - fmt_state_puts(state, " kern_dev="); - fmt_state_printf(state, "%"PRIu32, self->kern_dev); - fmt_state_puts(state, " file_qid="); - lib9p_qid_format(&self->file_qid, state); - fmt_state_puts(state, " file_mode="); - lib9p_dm_format(&self->file_mode, state); - fmt_state_puts(state, " file_atime="); - fmt_state_printf(state, "%"PRIu32, self->file_atime); - fmt_state_puts(state, " file_mtime="); - fmt_state_printf(state, "%"PRIu32, self->file_mtime); - fmt_state_puts(state, " file_size="); - fmt_state_printf(state, "%"PRIu64, self->file_size); - fmt_state_puts(state, " file_name="); - lib9p_s_format(&self->file_name, state); - fmt_state_puts(state, " file_owner_uid="); - lib9p_s_format(&self->file_owner_uid, state); - fmt_state_puts(state, " file_owner_gid="); - lib9p_s_format(&self->file_owner_gid, state); - fmt_state_puts(state, " file_last_modified_uid="); - lib9p_s_format(&self->file_last_modified_uid, state); + fmt_state_puts(state, " fstype="); + fmt_state_printf(state, "%"PRIu16, self->fstype); + fmt_state_puts(state, " fsdev="); + fmt_state_printf(state, "%"PRIu32, self->fsdev); + fmt_state_puts(state, " qid="); + lib9p_qid_format(&self->qid, state); + fmt_state_puts(state, " mode="); + lib9p_dm_format(&self->mode, state); + fmt_state_puts(state, " atime="); + fmt_state_printf(state, "%"PRIu32, self->atime); + fmt_state_puts(state, " mtime="); + fmt_state_printf(state, "%"PRIu32, self->mtime); + fmt_state_puts(state, " length="); + fmt_state_printf(state, "%"PRIu64, self->length); + fmt_state_puts(state, " name="); + lib9p_s_format(&self->name, state); + fmt_state_puts(state, " owner_uname="); + lib9p_s_format(&self->owner_uname, state); + fmt_state_puts(state, " owner_gname="); + lib9p_s_format(&self->owner_gname, state); + fmt_state_puts(state, " last_modifier_uname="); + lib9p_s_format(&self->last_modifier_uname, state); #if CONFIG_9P_ENABLE_9P2000_u - fmt_state_puts(state, " file_extension="); - lib9p_s_format(&self->file_extension, state); - fmt_state_puts(state, " file_owner_n_uid="); - lib9p_nuid_format(&self->file_owner_n_uid, state); - fmt_state_puts(state, " file_owner_n_gid="); - lib9p_nuid_format(&self->file_owner_n_gid, state); - fmt_state_puts(state, " file_last_modified_n_uid="); - lib9p_nuid_format(&self->file_last_modified_n_uid, state); + fmt_state_puts(state, " extension="); + lib9p_s_format(&self->extension, state); + fmt_state_puts(state, " owner_unum="); + lib9p_nuid_format(&self->owner_unum, state); + fmt_state_puts(state, " owner_gnum="); + lib9p_nuid_format(&self->owner_gnum, state); + fmt_state_puts(state, " last_modifier_unum="); + lib9p_nuid_format(&self->last_modifier_unum, state); #endif /* CONFIG_9P_ENABLE_9P2000_u */ fmt_state_puts(state, " }"); } @@ -5075,7 +5112,7 @@ static void lib9p_o_format(lib9p_o_t *self, struct fmt_state *state) { } #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 +#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 || CONFIG_9P_ENABLE_uninitialized static void lib9p_msg_Tversion_format(struct lib9p_msg_Tversion *self, struct fmt_state *state) { fmt_state_puts(state, "Tversion {"); fmt_state_puts(state, " tag="); @@ -5098,6 +5135,8 @@ static void lib9p_msg_Rversion_format(struct lib9p_msg_Rversion *self, struct fm fmt_state_puts(state, " }"); } +#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 || CONFIG_9P_ENABLE_uninitialized */ +#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 lib9p_msg_Tauth_format(struct lib9p_msg_Tauth *self, struct fmt_state *state) { fmt_state_puts(state, "Tauth {"); fmt_state_puts(state, " tag="); @@ -5109,8 +5148,8 @@ static void lib9p_msg_Tauth_format(struct lib9p_msg_Tauth *self, struct fmt_stat fmt_state_puts(state, " aname="); lib9p_s_format(&self->aname, state); #if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u - fmt_state_puts(state, " n_uid="); - lib9p_nuid_format(&self->n_uid, state); + fmt_state_puts(state, " unum="); + lib9p_nuid_format(&self->unum, state); #endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ fmt_state_puts(state, " }"); } @@ -5137,8 +5176,8 @@ static void lib9p_msg_Tattach_format(struct lib9p_msg_Tattach *self, struct fmt_ fmt_state_puts(state, " aname="); lib9p_s_format(&self->aname, state); #if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u - fmt_state_puts(state, " n_uid="); - lib9p_nuid_format(&self->n_uid, state); + fmt_state_puts(state, " unum="); + lib9p_nuid_format(&self->unum, state); #endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ fmt_state_puts(state, " }"); } @@ -5153,7 +5192,7 @@ static void lib9p_msg_Rattach_format(struct lib9p_msg_Rattach *self, struct fmt_ } #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 +#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized static void lib9p_msg_Rerror_format(struct lib9p_msg_Rerror *self, struct fmt_state *state) { fmt_state_puts(state, "Rerror {"); fmt_state_puts(state, " tag="); @@ -5167,7 +5206,7 @@ static void lib9p_msg_Rerror_format(struct lib9p_msg_Rerror *self, struct fmt_st fmt_state_puts(state, " }"); } -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || 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 || CONFIG_9P_ENABLE_uninitialized */ #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 lib9p_msg_Tflush_format(struct lib9p_msg_Tflush *self, struct fmt_state *state) { fmt_state_puts(state, "Tflush {"); @@ -7811,22 +7850,24 @@ static void lib9p_msg_Rswrite_format(struct lib9p_msg_Rswrite *self, struct fmt_ /* tables.h *******************************************************************/ const struct _lib9p_ver_tentry _lib9p_table_ver[LIB9P_VER_NUM] = { - [LIB9P_VER_unknown] = {.name="unknown", .min_msg_size=9}, #if CONFIG_9P_ENABLE_9P2000 - [LIB9P_VER_9P2000] = {.name="9P2000", .min_msg_size=9}, + [LIB9P_VER_9P2000] = {.name="9P2000", .min_Rerror_size=9, .min_Rread_size=11}, #endif /* CONFIG_9P_ENABLE_9P2000 */ #if CONFIG_9P_ENABLE_9P2000_L - [LIB9P_VER_9P2000_L] = {.name="9P2000.L", .min_msg_size=11}, + [LIB9P_VER_9P2000_L] = {.name="9P2000.L", .min_Rerror_size=11, .min_Rread_size=11}, #endif /* CONFIG_9P_ENABLE_9P2000_L */ #if CONFIG_9P_ENABLE_9P2000_e - [LIB9P_VER_9P2000_e] = {.name="9P2000.e", .min_msg_size=9}, + [LIB9P_VER_9P2000_e] = {.name="9P2000.e", .min_Rerror_size=9, .min_Rread_size=11}, #endif /* CONFIG_9P_ENABLE_9P2000_e */ #if CONFIG_9P_ENABLE_9P2000_p9p - [LIB9P_VER_9P2000_p9p] = {.name="9P2000.p9p", .min_msg_size=9}, + [LIB9P_VER_9P2000_p9p] = {.name="9P2000.p9p", .min_Rerror_size=9, .min_Rread_size=11}, #endif /* CONFIG_9P_ENABLE_9P2000_p9p */ #if CONFIG_9P_ENABLE_9P2000_u - [LIB9P_VER_9P2000_u] = {.name="9P2000.u", .min_msg_size=13}, + [LIB9P_VER_9P2000_u] = {.name="9P2000.u", .min_Rerror_size=13, .min_Rread_size=11}, #endif /* CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_uninitialized + [LIB9P_VER_uninitialized] = {.name="uninitialized", .min_Rerror_size=9, .min_Rread_size=0}, +#endif /* CONFIG_9P_ENABLE_uninitialized */ }; #define _MSG(typ) [LIB9P_TYP_##typ] = { \ @@ -7834,11 +7875,6 @@ const struct _lib9p_ver_tentry _lib9p_table_ver[LIB9P_VER_NUM] = { .box_as_fmt_formatter = (_box_as_fmt_formatter_fn_t)lo_box_lib9p_msg_##typ##_as_fmt_formatter, \ } const struct _lib9p_msg_tentry _lib9p_table_msg[LIB9P_VER_NUM][0x100] = { - [LIB9P_VER_unknown] = { - _MSG(Tversion), - _MSG(Rversion), - _MSG(Rerror), - }, #if CONFIG_9P_ENABLE_9P2000 [LIB9P_VER_9P2000] = { _MSG(Tversion), @@ -8032,6 +8068,13 @@ const struct _lib9p_msg_tentry _lib9p_table_msg[LIB9P_VER_NUM][0x100] = { _MSG(Rwstat), }, #endif /* CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_uninitialized + [LIB9P_VER_uninitialized] = { + _MSG(Tversion), + _MSG(Rversion), + _MSG(Rerror), + }, +#endif /* CONFIG_9P_ENABLE_uninitialized */ }; #define _MSG_RECV(typ) [LIB9P_TYP_##typ/2] = { \ @@ -8043,9 +8086,6 @@ const struct _lib9p_msg_tentry _lib9p_table_msg[LIB9P_VER_NUM][0x100] = { } 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), @@ -8150,13 +8190,14 @@ const struct _lib9p_recv_tentry _lib9p_table_Tmsg_recv[LIB9P_VER_NUM][0x80] = { _MSG_RECV(Twstat), }, #endif /* CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_uninitialized + [LIB9P_VER_uninitialized] = { + _MSG_RECV(Tversion), + }, +#endif /* CONFIG_9P_ENABLE_uninitialized */ }; 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), @@ -8266,12 +8307,15 @@ const struct _lib9p_recv_tentry _lib9p_table_Rmsg_recv[LIB9P_VER_NUM][0x80] = { _MSG_RECV(Rwstat), }, #endif /* CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_uninitialized + [LIB9P_VER_uninitialized] = { + _MSG_RECV(Rversion), + _MSG_RECV(Rerror), + }, +#endif /* CONFIG_9P_ENABLE_uninitialized */ }; 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), @@ -8376,13 +8420,14 @@ const struct _lib9p_send_tentry _lib9p_table_Tmsg_send[LIB9P_VER_NUM][0x80] = { _MSG_SEND(Twstat), }, #endif /* CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_uninitialized + [LIB9P_VER_uninitialized] = { + _MSG_SEND(Tversion), + }, +#endif /* CONFIG_9P_ENABLE_uninitialized */ }; 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), @@ -8492,8 +8537,15 @@ const struct _lib9p_send_tentry _lib9p_table_Rmsg_send[LIB9P_VER_NUM][0x80] = { _MSG_SEND(Rwstat), }, #endif /* CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_uninitialized + [LIB9P_VER_uninitialized] = { + _MSG_SEND(Rversion), + _MSG_SEND(Rerror), + }, +#endif /* CONFIG_9P_ENABLE_uninitialized */ }; +#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || 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); } @@ -8503,3 +8555,4 @@ LM_FLATTEN void _lib9p_stat_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes, LM_FLATTEN bool _lib9p_stat_marshal(struct lib9p_ctx *ctx, struct lib9p_stat *val, struct _marshal_ret *ret) { return marshal_stat(ctx, val, ret); } +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ diff --git a/lib9p/core_include/lib9p/_core_generated.h b/lib9p/core_include/lib9p/_core_generated.h index 68eb636..9e6366f 100644 --- a/lib9p/core_include/lib9p/_core_generated.h +++ b/lib9p/core_include/lib9p/_core_generated.h @@ -1,4 +1,4 @@ -/* Generated by `lib9p/core.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! */ +/* Generated by `lib9p/core.gen lib9p/idl/0000-uninitialized.9p 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! */ #ifndef _LIB9P_CORE_H_ #error Do not include <lib9p/_core_generated.h> directly; include <lib9p/core.h> instead @@ -40,24 +40,30 @@ #error config.h must define CONFIG_9P_ENABLE_9P2000_u #endif +#ifndef CONFIG_9P_ENABLE_uninitialized + #error config.h must define CONFIG_9P_ENABLE_uninitialized +#endif + +#define _LIB9P_ENABLE_stat CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u + /* enum version ***************************************************************/ enum lib9p_version { - LIB9P_VER_unknown = 0, /* "unknown" */ + LIB9P_VER_uninitialized = 0, /* "uninitialized" */ #if CONFIG_9P_ENABLE_9P2000 - LIB9P_VER_9P2000, /* "9P2000" */ + LIB9P_VER_9P2000, /* "9P2000" */ #endif /* CONFIG_9P_ENABLE_9P2000 */ #if CONFIG_9P_ENABLE_9P2000_L - LIB9P_VER_9P2000_L, /* "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" */ + LIB9P_VER_9P2000_e, /* "9P2000.e" */ #endif /* CONFIG_9P_ENABLE_9P2000_e */ #if CONFIG_9P_ENABLE_9P2000_p9p - LIB9P_VER_9P2000_p9p, /* "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" */ + LIB9P_VER_9P2000_u, /* "9P2000.u" */ #endif /* CONFIG_9P_ENABLE_9P2000_u */ LIB9P_VER_NUM, }; @@ -111,17 +117,19 @@ enum lib9p_msg_type { /* uint8_t */ LIB9P_TYP_Topenfd = 98, LIB9P_TYP_Ropenfd = 99, #endif /* CONFIG_9P_ENABLE_9P2000_p9p */ -#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 +#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 || CONFIG_9P_ENABLE_uninitialized LIB9P_TYP_Tversion = 100, LIB9P_TYP_Rversion = 101, +#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 || CONFIG_9P_ENABLE_uninitialized */ +#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 LIB9P_TYP_Tauth = 102, LIB9P_TYP_Rauth = 103, LIB9P_TYP_Tattach = 104, LIB9P_TYP_Rattach = 105, #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 +#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized LIB9P_TYP_Rerror = 107, -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || 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 || CONFIG_9P_ENABLE_uninitialized */ #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 LIB9P_TYP_Tflush = 108, LIB9P_TYP_Rflush = 109, @@ -163,7 +171,7 @@ LO_IMPLEMENTATION_H(fmt_formatter, enum lib9p_msg_type, lib9p_msg_type); /* payload types **************************************************************/ -#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 +#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 || CONFIG_9P_ENABLE_uninitialized /* size = 2 ; max_iov = 1 ; max_copy = 2 */ typedef uint16_t lib9p_tag_t; LO_IMPLEMENTATION_H(fmt_formatter, lib9p_tag_t, lib9p_tag); @@ -174,8 +182,8 @@ typedef uint32_t lib9p_fid_t; LO_IMPLEMENTATION_H(fmt_formatter, lib9p_fid_t, lib9p_fid); #define LIB9P_FID_NOFID ((lib9p_fid_t)(UINT32_MAX)) -#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 +#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 || CONFIG_9P_ENABLE_uninitialized */ +#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized /* size = 4 ; max_iov = 1 ; max_copy = 4 */ typedef uint32_t lib9p_dm_t; LO_IMPLEMENTATION_H(fmt_formatter, lib9p_dm_t, lib9p_dm); @@ -219,8 +227,8 @@ LO_IMPLEMENTATION_H(fmt_formatter, lib9p_dm_t, lib9p_dm); /* masks */ #define LIB9P_DM_PERM_MASK ((lib9p_dm_t)(0b000000000000000000000111111111)) -#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 +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */ +#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 || CONFIG_9P_ENABLE_uninitialized /* size = 1 ; max_iov = 1 ; max_copy = 1 */ typedef uint8_t lib9p_qt_t; LO_IMPLEMENTATION_H(fmt_formatter, lib9p_qt_t, lib9p_qt); @@ -238,7 +246,7 @@ LO_IMPLEMENTATION_H(fmt_formatter, lib9p_qt_t, lib9p_qt); /* aliases */ #define LIB9P_QT_FILE ((lib9p_qt_t)(0)) -#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 */ +#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 || CONFIG_9P_ENABLE_uninitialized */ #if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u /* size = 1 ; max_iov = 1 ; max_copy = 1 */ typedef uint8_t lib9p_o_t; @@ -685,7 +693,7 @@ LO_IMPLEMENTATION_H(fmt_formatter, lib9p_lock_status_t, lib9p_lock_status); #define LIB9P_LOCK_STATUS_GRACE ((lib9p_lock_status_t)(3)) #endif /* CONFIG_9P_ENABLE_9P2000_L */ -#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 +#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 || CONFIG_9P_ENABLE_uninitialized /* min_size = 2 ; exp_size = 29 ; max_size = 65,537 ; max_iov = 2 ; max_copy = 2 */ struct lib9p_s { uint16_t len; @@ -701,6 +709,8 @@ struct lib9p_qid { }; LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_qid, lib9p_qid); +#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 || CONFIG_9P_ENABLE_uninitialized */ +#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 /* size = 9 ; max_iov = 1 ; max_copy = 9 */ struct lib9p_msg_Tflush { lib9p_tag_t tag; @@ -999,28 +1009,28 @@ LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rswrite, lib9p_msg_Rswrite); /* LIB9P_VER_9P2000_p9p: min_size = 49 ; exp_size = 157 ; max_size = 262,189 ; max_iov = 8 ; max_copy = 49 */ /* LIB9P_VER_9P2000_u : min_size = 63 ; exp_size = 198 ; max_size = 327,738 ; max_iov = 11 ; max_copy = 63 */ struct lib9p_stat { - uint16_t kern_type; - uint32_t kern_dev; - struct lib9p_qid file_qid; - lib9p_dm_t file_mode; - uint32_t file_atime; - uint32_t file_mtime; - uint64_t file_size; - struct lib9p_s file_name; - struct lib9p_s file_owner_uid; - struct lib9p_s file_owner_gid; - struct lib9p_s file_last_modified_uid; + uint16_t fstype; + uint32_t fsdev; + struct lib9p_qid qid; + lib9p_dm_t mode; + uint32_t atime; + uint32_t mtime; + uint64_t length; + struct lib9p_s name; + struct lib9p_s owner_uname; + struct lib9p_s owner_gname; + struct lib9p_s last_modifier_uname; #if CONFIG_9P_ENABLE_9P2000_u - struct lib9p_s file_extension; - lib9p_nuid_t file_owner_n_uid; - lib9p_nuid_t file_owner_n_gid; - lib9p_nuid_t file_last_modified_n_uid; + struct lib9p_s extension; + lib9p_nuid_t owner_unum; + lib9p_nuid_t owner_gnum; + lib9p_nuid_t last_modifier_unum; #endif /* CONFIG_9P_ENABLE_9P2000_u */ }; LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_stat, lib9p_stat); #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 +#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 || CONFIG_9P_ENABLE_uninitialized /* min_size = 13 ; exp_size = 40 ; max_size = 65,548 ; max_iov = 2 ; max_copy = 13 */ struct lib9p_msg_Tversion { lib9p_tag_t tag; @@ -1037,6 +1047,8 @@ struct lib9p_msg_Rversion { }; LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rversion, lib9p_msg_Rversion); +#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 || CONFIG_9P_ENABLE_uninitialized */ +#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 /* LIB9P_VER_9P2000 : min_size = 15 ; exp_size = 69 ; max_size = 131,085 ; max_iov = 4 ; max_copy = 15 */ /* LIB9P_VER_9P2000_L : min_size = 19 ; exp_size = 73 ; max_size = 131,089 ; max_iov = 5 ; max_copy = 19 */ /* LIB9P_VER_9P2000_e : min_size = 15 ; exp_size = 69 ; max_size = 131,085 ; max_iov = 4 ; max_copy = 15 */ @@ -1048,7 +1060,7 @@ struct lib9p_msg_Tauth { struct lib9p_s uname; struct lib9p_s aname; #if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u - lib9p_nuid_t n_uid; + lib9p_nuid_t unum; #endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ }; LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tauth, lib9p_msg_Tauth); @@ -1072,7 +1084,7 @@ struct lib9p_msg_Tattach { struct lib9p_s uname; struct lib9p_s aname; #if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u - lib9p_nuid_t n_uid; + lib9p_nuid_t unum; #endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ }; LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tattach, lib9p_msg_Tattach); @@ -1085,11 +1097,12 @@ struct lib9p_msg_Rattach { LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rattach, lib9p_msg_Rattach); #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 -/* LIB9P_VER_9P2000 : min_size = 9 ; exp_size = 36 ; max_size = 65,544 ; max_iov = 2 ; max_copy = 9 */ -/* LIB9P_VER_9P2000_e : min_size = 9 ; exp_size = 36 ; max_size = 65,544 ; max_iov = 2 ; max_copy = 9 */ -/* LIB9P_VER_9P2000_p9p: min_size = 9 ; exp_size = 36 ; max_size = 65,544 ; max_iov = 2 ; max_copy = 9 */ -/* LIB9P_VER_9P2000_u : min_size = 13 ; exp_size = 40 ; max_size = 65,548 ; max_iov = 3 ; max_copy = 13 */ +#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized +/* LIB9P_VER_9P2000 : min_size = 9 ; exp_size = 36 ; max_size = 65,544 ; max_iov = 2 ; max_copy = 9 */ +/* LIB9P_VER_9P2000_e : min_size = 9 ; exp_size = 36 ; max_size = 65,544 ; max_iov = 2 ; max_copy = 9 */ +/* LIB9P_VER_9P2000_p9p : min_size = 9 ; exp_size = 36 ; max_size = 65,544 ; max_iov = 2 ; max_copy = 9 */ +/* LIB9P_VER_9P2000_u : min_size = 13 ; exp_size = 40 ; max_size = 65,548 ; max_iov = 3 ; max_copy = 13 */ +/* LIB9P_VER_uninitialized: min_size = 9 ; exp_size = 36 ; max_size = 65,544 ; max_iov = 2 ; max_copy = 9 */ struct lib9p_msg_Rerror { lib9p_tag_t tag; struct lib9p_s errstr; @@ -1099,7 +1112,7 @@ struct lib9p_msg_Rerror { }; LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rerror, lib9p_msg_Rerror); -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || 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 || CONFIG_9P_ENABLE_uninitialized */ #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 /* min_size = 17 ; exp_size = 481 ; max_size = 1,048,609 ; max_iov = 32 ; max_copy = 49 */ struct lib9p_msg_Twalk { @@ -1421,6 +1434,8 @@ LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Twstat, lib9p_msg_Twstat); #else #define LIB9P_TMSG_MAX_IOV 32 #endif +#elif CONFIG_9P_ENABLE_uninitialized + #define LIB9P_TMSG_MAX_IOV 2 #endif #if CONFIG_9P_ENABLE_9P2000_u @@ -1441,18 +1456,22 @@ LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Twstat, lib9p_msg_Twstat); #else #define LIB9P_TMSG_MAX_COPY 62 #endif +#elif CONFIG_9P_ENABLE_uninitialized + #define LIB9P_TMSG_MAX_COPY 13 #endif #if CONFIG_9P_ENABLE_9P2000_u #define LIB9P_RMSG_MAX_IOV 11 #elif CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p #define LIB9P_RMSG_MAX_IOV 8 -#elif CONFIG_9P_ENABLE_9P2000_L +#elif CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_uninitialized #define LIB9P_RMSG_MAX_IOV 2 #endif #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 #define LIB9P_RMSG_MAX_COPY 217 +#elif CONFIG_9P_ENABLE_uninitialized + #define LIB9P_RMSG_MAX_COPY 13 #endif struct lib9p_Tmsg_send_buf { diff --git a/lib9p/core_include/lib9p/core.h b/lib9p/core_include/lib9p/core.h index ff822ed..549411f 100644 --- a/lib9p/core_include/lib9p/core.h +++ b/lib9p/core_include/lib9p/core.h @@ -12,6 +12,7 @@ #include <libmisc/assert.h> +#define CONFIG_9P_ENABLE_uninitialized 1 #include <lib9p/_core_generated.h> #ifndef CONFIG_9P_MAX_ERR_SIZE @@ -45,7 +46,7 @@ struct lib9p_ctx { uint32_t max_msg_size; /* state */ -#ifdef CONFIG_9P_ENABLE_9P2000_u +#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L lib9p_errno_t err_num; #endif [[gnu::nonstring]] char err_msg[CONFIG_9P_MAX_ERR_SIZE]; @@ -55,14 +56,29 @@ void lib9p_ctx_clear_error(struct lib9p_ctx *ctx); bool lib9p_ctx_has_error(struct lib9p_ctx *ctx); -/** Write an static error into ctx, return -1. */ -int lib9p_error(struct lib9p_ctx *ctx, lib9p_errno_t linux_errno, char const *msg); -/** Write a printf-style error into ctx, return -1. */ -int lib9p_errorf(struct lib9p_ctx *ctx, lib9p_errno_t linux_errno, char const *fmt, ...) [[gnu::format(printf, 3, 4)]]; +/* NB: This __VA_ARGS__ definition of lib9p_errorf() is handy because it + * will produce an error if .../__VA_ARGS__ is empty; which means that + * it should be lib9p_error() instead! */ +#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L + int _lib9p_error(struct lib9p_ctx *ctx, lib9p_errno_t linux_errno, char const *msg); + int _lib9p_errorf(struct lib9p_ctx *ctx, lib9p_errno_t linux_errno, char const *fmt, ...) [[gnu::format(printf, 3, 4)]]; + /** Write an static error into ctx, return -1. */ + #define lib9p_error(ctx, errnum, errmsg) _lib9p_error(ctx, errnum, errmsg) + /** Write a printf-style error into ctx, return -1. */ + #define lib9p_errorf(ctx, errnum, fmt, ...) _lib9p_errorf(ctx, errnum, fmt, __VA_ARGS__) +#else + int _lib9p_error(struct lib9p_ctx *ctx, char const *msg); + int _lib9p_errorf(struct lib9p_ctx *ctx, char const *fmt, ...) [[gnu::format(printf, 2, 3)]]; + /** Write an static error into ctx, return -1. */ + #define lib9p_error(ctx, errnum, errmsg) _lib9p_error(ctx, errmsg) + /** Write a printf-style error into ctx, return -1. */ + #define lib9p_errorf(ctx, errnum, fmt, ...) _lib9p_errorf(ctx, fmt, __VA_ARGS__) +#endif /* misc utilities *************************************************************/ -uint32_t lib9p_version_min_msg_size(enum lib9p_version); +uint32_t lib9p_version_min_Rerror_size(enum lib9p_version); +uint32_t lib9p_version_min_Rread_size(enum lib9p_version); lo_interface fmt_formatter lo_box_lib9p_msg_as_fmt_formatter(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body); @@ -143,16 +159,7 @@ bool lib9p_Rmsg_marshal(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *bo /* `struct lib9p_stat` helpers ************************************************/ -/** Assert that a `struct lib9p_stat` object looks valid. */ -static inline void lib9p_stat_assert(struct lib9p_stat stat) { - assert( ((bool)(stat.file_mode & LIB9P_DM_DIR )) == ((bool)(stat.file_qid.type & LIB9P_QT_DIR )) ); - assert( ((bool)(stat.file_mode & LIB9P_DM_APPEND)) == ((bool)(stat.file_qid.type & LIB9P_QT_APPEND)) ); - assert( ((bool)(stat.file_mode & LIB9P_DM_EXCL )) == ((bool)(stat.file_qid.type & LIB9P_QT_EXCL )) ); - assert( ((bool)(stat.file_mode & LIB9P_DM_AUTH )) == ((bool)(stat.file_qid.type & LIB9P_QT_AUTH )) ); - assert( ((bool)(stat.file_mode & LIB9P_DM_TMP )) == ((bool)(stat.file_qid.type & LIB9P_QT_TMP )) ); - assert( (stat.file_size == 0) || !(stat.file_mode & LIB9P_DM_DIR) ); -} - +#if _LIB9P_ENABLE_stat /** * Validate a message's `stat` structure. * @@ -201,5 +208,6 @@ void lib9p_stat_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes, */ uint32_t lib9p_stat_marshal(struct lib9p_ctx *ctx, uint32_t max_net_size, struct lib9p_stat *obj, uint8_t *ret_bytes); +#endif #endif /* _LIB9P_CORE_H_ */ diff --git a/lib9p/core_tables.c b/lib9p/core_tables.c deleted file mode 100644 index a04a5f0..0000000 --- a/lib9p/core_tables.c +++ /dev/null @@ -1,188 +0,0 @@ -/* lib9p/core_tables.c - Access tables of version and message information - * - * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -#include <string.h> - -#include <libmisc/endian.h> -#include <libmisc/log.h> /* for const_byte_str() */ - -#include "core_tables.h" - -/* bounds checks **************************************************************/ - -static inline void assert_ver(enum lib9p_version ver) { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wtype-limits" - assert(0 <= ver && ver < LIB9P_VER_NUM); -#pragma GCC diagnostic pop -} - -static inline void assert_typ(enum lib9p_msg_type typ) { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wtype-limits" - assert(0 <= typ && typ < 0xFF); -#pragma GCC diagnostic pop -} - -/* simple lookups *************************************************************/ - -const char *lib9p_version_str(enum lib9p_version ver) { - assert_ver(ver); - return _lib9p_table_ver[ver].name; -} - -uint32_t lib9p_version_min_msg_size(enum lib9p_version ver) { - assert_ver(ver); - return _lib9p_table_ver[ver].min_msg_size; -} - -const char *lib9p_msgtype_str(enum lib9p_version ver, enum lib9p_msg_type typ) { - assert_ver(ver); - assert_typ(typ); - return _lib9p_table_msg[ver][typ].name ?: const_byte_str(typ); -} - -lo_interface fmt_formatter lo_box_lib9p_msg_as_fmt_formatter(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body) { - assert(ctx); - assert_ver(ctx->version); - assert_typ(typ); - assert(_lib9p_table_msg[ctx->version][typ].box_as_fmt_formatter); - return _lib9p_table_msg[ctx->version][typ].box_as_fmt_formatter(body); -} - -/* main message functions *****************************************************/ - -static -ssize_t _lib9p_validate(uint8_t xxx_low_typ_bit, - const char *xxx_errmsg, - const struct _lib9p_recv_tentry xxx_table[LIB9P_VER_NUM][0x80], - struct lib9p_ctx *ctx, uint8_t *net_bytes) { - assert_ver(ctx->version); - /* Inspect the first 5 bytes ourselves. */ - uint32_t net_size = uint32le_decode(net_bytes); - if (net_size < 5) - return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "message is impossibly short"); - uint8_t typ = net_bytes[4]; - if (typ % 2 != xxx_low_typ_bit) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EOPNOTSUPP, "%s: message_type=%s", xxx_errmsg, - lib9p_msgtype_str(ctx->version, typ)); - struct _lib9p_recv_tentry tentry = xxx_table[ctx->version][typ/2]; - if (!tentry.validate) - return lib9p_errorf(ctx, LIB9P_ERRNO_L_EOPNOTSUPP, "unknown message type: %s (protocol_version=%s)", - lib9p_msgtype_str(ctx->version, typ), lib9p_version_str(ctx->version)); - - /* Now use the message-type-specific tentry to process the whole thing. */ - return tentry.validate(ctx, net_size, net_bytes); -} - -ssize_t lib9p_Tmsg_validate(struct lib9p_ctx *ctx, uint8_t *net_bytes) { - return _lib9p_validate(0, "expected a T-message but got an R-message", _lib9p_table_Tmsg_recv, - ctx, net_bytes); -} - -ssize_t lib9p_Rmsg_validate(struct lib9p_ctx *ctx, uint8_t *net_bytes) { - return _lib9p_validate(1, "expected an R-message but got a T-message", _lib9p_table_Rmsg_recv, - ctx, net_bytes); -} - -static -void _lib9p_unmarshal(const struct _lib9p_recv_tentry xxx_table[LIB9P_VER_NUM][0x80], - struct lib9p_ctx *ctx, uint8_t *net_bytes, - enum lib9p_msg_type *ret_typ, void *ret_body) { - assert_ver(ctx->version); - enum lib9p_msg_type typ = net_bytes[4]; - *ret_typ = typ; - struct _lib9p_recv_tentry tentry = xxx_table[ctx->version][typ/2]; - assert(tentry.unmarshal); - - tentry.unmarshal(ctx, net_bytes, ret_body); -} - -void lib9p_Tmsg_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes, - enum lib9p_msg_type *ret_typ, void *ret_body) { - _lib9p_unmarshal(_lib9p_table_Tmsg_recv, - ctx, net_bytes, ret_typ, ret_body); -} - -void lib9p_Rmsg_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes, - enum lib9p_msg_type *ret_typ, void *ret_body) { - _lib9p_unmarshal(_lib9p_table_Rmsg_recv, - ctx, net_bytes, ret_typ, ret_body); -} - -static -bool _lib9p_marshal(const struct _lib9p_send_tentry xxx_table[LIB9P_VER_NUM][0x80], - struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body, - size_t *ret_iov_cnt, struct iovec *ret_iov, uint8_t *ret_copied) { - assert_ver(ctx->version); - assert_typ(typ); - struct _marshal_ret ret = { - .net_iov_cnt = 1, - .net_iov = ret_iov, - .net_copied_size = 0, - .net_copied = ret_copied, - }; - struct _lib9p_send_tentry tentry = xxx_table[ctx->version][typ/2]; - assert(tentry.marshal); - - bool ret_erred = tentry.marshal(ctx, body, &ret); - if (ret_iov[ret.net_iov_cnt-1].iov_len == 0) - ret.net_iov_cnt--; - *ret_iov_cnt = ret.net_iov_cnt; - return ret_erred; -} - -bool lib9p_Tmsg_marshal(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body, - struct lib9p_Tmsg_send_buf *ret) { - assert(typ % 2 == 0); - memset(ret, 0, sizeof(*ret)); - return _lib9p_marshal(_lib9p_table_Tmsg_send, - ctx, typ, body, - &ret->iov_cnt, ret->iov, ret->copied); -} - -bool lib9p_Rmsg_marshal(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body, - struct lib9p_Rmsg_send_buf *ret) { - assert(typ % 2 == 1); - memset(ret, 0, sizeof(*ret)); - return _lib9p_marshal(_lib9p_table_Rmsg_send, - ctx, typ, body, - &ret->iov_cnt, ret->iov, ret->copied); -} - -/* `struct lib9p_stat` helpers ************************************************/ - -bool lib9p_stat_validate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes, - uint32_t *ret_net_size, size_t *ret_host_size) { - ssize_t host_size = _lib9p_stat_validate(ctx, net_size, net_bytes, ret_net_size); - if (host_size < 0) - return true; - if (ret_host_size) - *ret_host_size = (size_t)host_size; - return false; -} - -void lib9p_stat_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes, - struct lib9p_stat *ret) { - _lib9p_stat_unmarshal(ctx, net_bytes, ret); -} - -uint32_t lib9p_stat_marshal(struct lib9p_ctx *ctx, uint32_t max_net_size, struct lib9p_stat *obj, - uint8_t *ret_bytes) { - struct lib9p_ctx _ctx = *ctx; - _ctx.max_msg_size = max_net_size; - - struct iovec iov = {0}; - struct _marshal_ret ret = { - .net_iov_cnt = 1, - .net_iov = &iov, - .net_copied_size = 0, - .net_copied = ret_bytes, - }; - if (_lib9p_stat_marshal(&_ctx, obj, &ret)) - return 0; - return ret.net_iov[0].iov_len; -} diff --git a/lib9p/core_tables.h b/lib9p/core_tables.h index 2c5f745..da2027a 100644 --- a/lib9p/core_tables.h +++ b/lib9p/core_tables.h @@ -13,7 +13,8 @@ struct _lib9p_ver_tentry { const char *name; - uint32_t min_msg_size; + uint32_t min_Rerror_size; + uint32_t min_Rread_size; }; extern const struct _lib9p_ver_tentry _lib9p_table_ver[LIB9P_VER_NUM]; @@ -52,8 +53,10 @@ extern const struct _lib9p_send_tentry _lib9p_table_Rmsg_send[LIB9P_VER_NUM][0x8 /* stat ***********************************************************************/ +#if _LIB9P_ENABLE_stat ssize_t _lib9p_stat_validate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes, uint32_t *ret_net_size); void _lib9p_stat_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out); bool _lib9p_stat_marshal(struct lib9p_ctx *ctx, struct lib9p_stat *val, struct _marshal_ret *ret); +#endif #endif /* _LIB9P_CORE_TABLES_H_ */ diff --git a/lib9p/idl/0000-uninitialized.9p b/lib9p/idl/0000-uninitialized.9p new file mode 100644 index 0000000..193cb19 --- /dev/null +++ b/lib9p/idl/0000-uninitialized.9p @@ -0,0 +1,13 @@ +# lib9p/idl/0000-uninitialized.9p - Defs for bootstrapping +# +# Copyright (C) 2025 Luke T. Shumaker <lukeshu@lukeshu.com> +# SPDX-License-Identifier: AGPL-3.0-or-later + +version "uninitialized" + +# For the actual protocol. +from ./2002-9P2000.9p import s, tag +from ./2002-9P2000.9p import Tversion, Rversion, Rerror + +# For srv.h +from ./2002-9P2000.9p import dm, qt, qid, fid diff --git a/lib9p/idl/2002-9P2000.9p b/lib9p/idl/2002-9P2000.9p index 13393c6..712ffea 100644 --- a/lib9p/idl/2002-9P2000.9p +++ b/lib9p/idl/2002-9P2000.9p @@ -91,18 +91,26 @@ bitfield qt = 1 struct qid = "type[qt] vers[4] path[8]" # stat - file status -struct stat = "stat_size[2,val=end-&kern_type]" - "kern_type[2]" - "kern_dev[4]" - "file_qid[qid]" - "file_mode[dm]" - "file_atime[4]" - "file_mtime[4]" - "file_size[8]" - "file_name[s]" - "file_owner_uid[s]" - "file_owner_gid[s]" - "file_last_modified_uid[s]" +struct stat = "_stat_size[2,val=end-&fstype]" + # fstype and fsdev are documented simply as "for kernel + # use". The are ignored by Plan 9's in-kernel 9P + # client; mntdirfix() overwrites them with fstype='M' + # and fsdev=nonce. Processes may observe values other + # than fstype='M', as 'M' is used for actual 9P servers, + # while other values are used for in-kernel device + # servers (such as '|' for pipes, or 'I' for the IP + # stack). + "fstype[2]" # filesystem type + "fsdev[4]" # filesystem instance/subtype + "qid[qid]" + "mode[dm]" + "atime[4]" + "mtime[4]" + "length[8]" # 0 for directories + "name[s]" + "owner_uname[s]" + "owner_gname[s]" + "last_modifier_uname[s]" # "O"pen flags (flags to pass to Topen and Tcreate) # Unused bits *must* be 0. diff --git a/lib9p/idl/2005-9P2000.u.9p b/lib9p/idl/2005-9P2000.u.9p index 1d630f9..446385c 100644 --- a/lib9p/idl/2005-9P2000.u.9p +++ b/lib9p/idl/2005-9P2000.u.9p @@ -17,13 +17,13 @@ num nuid = 4 num errno = 4 "NOERROR = 0" -struct stat += "file_extension[s]" - "file_owner_n_uid[nuid]" - "file_owner_n_gid[nuid]" - "file_last_modified_n_uid[nuid]" +struct stat += "extension[s]" + "owner_unum[nuid]" + "owner_gnum[nuid]" + "last_modifier_unum[nuid]" -msg Tauth += "n_uid[nuid]" -msg Tattach += "n_uid[nuid]" +msg Tauth += "unum[nuid]" +msg Tattach += "unum[nuid]" msg Rerror += "errnum[errno]" diff --git a/lib9p/srv.c b/lib9p/srv.c index b14ae33..6d9d992 100644 --- a/lib9p/srv.c +++ b/lib9p/srv.c @@ -43,13 +43,15 @@ static_assert(CONFIG_9P_SRV_MAX_HOSTMSG_SIZE <= SSIZE_MAX); /* context ********************************************************************/ -bool lib9p_srv_accept_flush(struct lib9p_srv_ctx *ctx) { +bool lib9p_srv_flush_requested(struct lib9p_srv_ctx *ctx) { assert(ctx); - if (cr_chan_can_send(&ctx->flush_ch)) { - ctx->flush_observed = true; - return true; - } - return false; + return cr_chan_can_send(&ctx->flush_ch); +} + +void lib9p_srv_acknowledge_flush(struct lib9p_srv_ctx *ctx) { + assert(ctx); + assert(cr_chan_can_send(&ctx->flush_ch)); + ctx->flush_acknowledged = true; } #define req_debugf(fmt, ...) \ @@ -90,11 +92,12 @@ struct srv_pathinfo { #define FIDFLAG_OPEN_R (1<<0) #define FIDFLAG_OPEN_W (1<<1) #define FIDFLAG_RCLOSE (1<<2) +#define FIDFLAG_APPEND (1<<3) #define FIDFLAG_OPEN (FIDFLAG_OPEN_R|FIDFLAG_OPEN_W) struct srv_fidinfo { srv_path_t path; - struct lib9p_srv_authinfo *authinfo; + struct lib9p_srv_userid *user; uint8_t flags; enum srv_filetype type; union { @@ -105,6 +108,7 @@ struct srv_fidinfo { lo_interface lib9p_srv_dio io; size_t idx; uint64_t off; + struct lib9p_srv_dirent buffered_dirent; } dir; struct { struct lib9p_s aname; @@ -161,44 +165,52 @@ static inline enum srv_filetype srv_qid_filetype(struct lib9p_qid qid) { return SRV_FILETYPE_FILE; } -static inline bool srv_check_perm(struct srv_req *ctx, struct lib9p_stat *stat, uint8_t action) { +static inline bool srv_check_perm(struct srv_req *ctx, struct lib9p_srv_stat *stat, uint8_t action) { assert(ctx); assert(stat); assert(action); /* TODO actually check user and group instead of just assuming "other". */ - uint8_t mode = (uint8_t)(stat->file_mode & 07); + uint8_t mode = (uint8_t)(stat->mode & 07); return mode & action; } -struct lib9p_srv_authinfo *srv_authinfo_new(struct lib9p_s uname, lib9p_nuid_t uid) { - struct lib9p_srv_authinfo *ret = malloc(sizeof(struct lib9p_srv_authinfo) + uname.len); +[[gnu::unused]] +static struct lib9p_srv_userid *srv_userid_new(struct lib9p_s name +#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L + , lib9p_nuid_t num +#endif + ) { + struct lib9p_srv_userid *ret = malloc(sizeof(struct lib9p_srv_userid) + name.len); if (!ret) return NULL; - ret->uid = uid; - ret->uname.len = uname.len; - ret->uname.utf8 = (void *)&ret[1]; - memcpy(ret->uname.utf8, uname.utf8, uname.len); +#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L + ret->num = num; +#endif + ret->name.len = name.len; + ret->name.utf8 = (void *)&ret[1]; + memcpy(ret->name.utf8, name.utf8, name.len); ret->refcount = 1; return ret; } +#if !(CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L) +#define srv_userid_new(name, num) srv_userid_new(name) +#endif -struct lib9p_srv_authinfo *srv_authinfo_decref(struct lib9p_srv_authinfo *authinfo) { - assert(authinfo); - assert(authinfo->refcount); - authinfo->refcount--; - if (!authinfo->refcount) { - free(authinfo); - return NULL; - } - return authinfo; +static struct lib9p_srv_userid *srv_userid_decref(struct lib9p_srv_userid *userid) { + assert(userid); + assert(userid->refcount); + userid->refcount--; + if (!userid->refcount) + free(userid); + return NULL; } -struct lib9p_srv_authinfo *srv_authinfo_incref(struct lib9p_srv_authinfo *authinfo) { - assert(authinfo); - authinfo->refcount++; - return authinfo; +static struct lib9p_srv_userid *srv_userid_incref(struct lib9p_srv_userid *userid) { + assert(userid); + userid->refcount++; + return userid; } /** @@ -260,32 +272,21 @@ static inline void srv_path_decref(struct srv_req *ctx, srv_path_t path) { } } -static inline void srv_fid_del(struct srv_req *ctx, lib9p_fid_t fid, bool remove) { - struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, fid); +static inline void srv_fid_del(struct srv_req *ctx, lib9p_fid_t fid, struct srv_fidinfo *fidinfo, bool remove) { + assert(ctx); + assert(!ctx->user); assert(fidinfo); + if (fidinfo->flags & FIDFLAG_RCLOSE) remove = true; + ctx->user = srv_userid_incref(fidinfo->user); + struct srv_pathinfo *pathinfo = map_load(&ctx->parent_sess->paths, fidinfo->path); assert(pathinfo); - if (remove) { - if (pathinfo->parent_dir == fidinfo->path) { - lib9p_errorf(&ctx->basectx, - LIB9P_ERRNO_L_EBUSY, "cannot remove root"); - goto clunk; - } - struct srv_pathinfo *parent = map_load(&ctx->parent_sess->paths, pathinfo->parent_dir); - assert(parent); - struct lib9p_stat parent_stat = LO_CALL(parent->file, stat, ctx); - if (!srv_check_perm(ctx, &parent_stat, 0b010)) { - lib9p_error(&ctx->basectx, - LIB9P_ERRNO_L_EACCES, "you do not have write permission on the parent directory"); - goto clunk; - } + if (remove) LO_CALL(pathinfo->file, remove, ctx); - } - clunk: if (fidinfo->flags & FIDFLAG_OPEN) { switch (fidinfo->type) { case SRV_FILETYPE_DIR: @@ -300,9 +301,11 @@ static inline void srv_fid_del(struct srv_req *ctx, lib9p_fid_t fid, bool remove } pathinfo->io_refcount--; } - fidinfo->authinfo = srv_authinfo_decref(fidinfo->authinfo); + fidinfo->user = srv_userid_decref(fidinfo->user); srv_path_decref(ctx, fidinfo->path); map_del(&ctx->parent_sess->fids, fid); + + ctx->user = srv_userid_decref(ctx->user); } /** @@ -327,7 +330,7 @@ static inline struct srv_fidinfo *srv_fid_store(struct srv_req *ctx, lib9p_fid_t assert(old_fidinfo->type == SRV_FILETYPE_DIR); assert(old_fidinfo->flags == 0); - old_fidinfo->authinfo = srv_authinfo_decref(old_fidinfo->authinfo); + old_fidinfo->user = srv_userid_decref(old_fidinfo->user); srv_path_decref(ctx, old_fidinfo->path); map_del(&ctx->parent_sess->fids, fid); } else { @@ -337,9 +340,9 @@ static inline struct srv_fidinfo *srv_fid_store(struct srv_req *ctx, lib9p_fid_t } } struct srv_fidinfo *fidinfo = map_store(&ctx->parent_sess->fids, fid, (struct srv_fidinfo){ - .path = qid.path, - .type = srv_qid_filetype(qid), - .authinfo = srv_authinfo_incref(ctx->authinfo), + .path = qid.path, + .type = srv_qid_filetype(qid), + .user = srv_userid_incref(ctx->user), }); assert(fidinfo); return fidinfo; @@ -373,7 +376,7 @@ static ssize_t srv_write_Rmsg(struct srv_req *req, struct lib9p_Rmsg_send_buf *r #define srv_nonrespond_errorf errorf static void srv_respond_error(struct srv_req *req) { -#if CONFIG_9P_ENABLE_9P2000_u +#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L assert(req->basectx.err_num); #endif assert(req->basectx.err_msg[0]); @@ -390,10 +393,7 @@ static void srv_respond_error(struct srv_req *req) { struct srv_sess *sess = req->parent_sess; - /* XXX: This assumes that a version's min_msg_size is the - * Rerror overhead. That's true for the current - * implementation of core_gen, but is a sneaky assumption. */ - uint32_t overhead = lib9p_version_min_msg_size(sess->version); + uint32_t overhead = lib9p_version_min_Rerror_size(sess->version); /* Truncate the error-string if necessary to avoid needing to * return LIB9P_ERRNO_L_ERANGE. */ @@ -466,7 +466,7 @@ void lib9p_srv_read(struct lib9p_srv *srv, lo_interface net_stream_conn _conn) { }; struct srv_sess sess = { .parent_conn = &conn, - .version = LIB9P_VER_unknown, + .version = LIB9P_VER_uninitialized, .max_msg_size = CONFIG_9P_SRV_MAX_MSG_SIZE, .initialized = false, }; @@ -531,17 +531,19 @@ void lib9p_srv_read(struct lib9p_srv *srv, lo_interface net_stream_conn _conn) { assert(map_len(&sess.reqs) == 0); map_free(&sess.reqs); + struct srv_req pseudoreq = { + .basectx = { + .version = sess.version, + .max_msg_size = sess.max_msg_size, + }, + .parent_sess = &sess, + }; MAP_FOREACH(&sess.fids, fid, fidinfo) { - struct srv_req req = { - .basectx = { - .version = sess.version, - .max_msg_size = sess.max_msg_size, - }, - .parent_sess = &sess, - }; - srv_fid_del(&req, fid, false); - if (lib9p_ctx_has_error(&req.basectx)) - errorf("clunk: %.*s", CONFIG_9P_MAX_ERR_SIZE, req.basectx.err_msg); + srv_fid_del(&pseudoreq, fid, fidinfo, false); + if (lib9p_ctx_has_error(&pseudoreq.basectx)) { + srv_nonrespond_errorf("clunk: %.*s", CONFIG_9P_MAX_ERR_SIZE, pseudoreq.basectx.err_msg); + lib9p_ctx_clear_error(&pseudoreq.basectx); + } } map_free(&sess.fids); @@ -585,9 +587,9 @@ void lib9p_srv_worker_loop(struct lib9p_srv *srv) { #define _HANDLER_PROTO(typ) \ static void handle_T##typ(struct srv_req *, \ - struct lib9p_msg_T##typ *, \ - struct lib9p_msg_R##typ *) + struct lib9p_msg_T##typ *) _HANDLER_PROTO(version); +#if _LIB9P_ENABLE_stat _HANDLER_PROTO(auth); _HANDLER_PROTO(attach); _HANDLER_PROTO(flush); @@ -600,6 +602,7 @@ _HANDLER_PROTO(clunk); _HANDLER_PROTO(remove); _HANDLER_PROTO(stat); _HANDLER_PROTO(wstat); +#endif #if CONFIG_9P_ENABLE_9P2000_p9p _HANDLER_PROTO(openfd); #endif @@ -609,16 +612,17 @@ _HANDLER_PROTO(sread); _HANDLER_PROTO(swrite); #endif -typedef void (*tmessage_handler)(struct srv_req *, void *, void *); +typedef void (*tmessage_handler)(struct srv_req *, void *); void lib9p_srv_worker(struct srv_req *ctx) { uint8_t *host_req = NULL; - uint8_t host_resp[CONFIG_9P_SRV_MAX_HOSTMSG_SIZE]; /* Unmarshal it. *****************************************************/ ssize_t host_size = lib9p_Tmsg_validate(&ctx->basectx, ctx->net_bytes); - if (host_size < 0) - goto write; + if (host_size < 0) { + srv_respond_error(ctx); + goto release; + } host_req = calloc(1, host_size); assert(host_req); enum lib9p_msg_type typ; @@ -632,6 +636,7 @@ void lib9p_srv_worker(struct srv_req *ctx) { #pragma GCC diagnostic ignored "-Wswitch-enum" switch (typ) { case LIB9P_TYP_Tversion: handler = (tmessage_handler)handle_Tversion; break; +#if _LIB9P_ENABLE_stat case LIB9P_TYP_Tauth: handler = (tmessage_handler)handle_Tauth; break; case LIB9P_TYP_Tattach: handler = (tmessage_handler)handle_Tattach; break; case LIB9P_TYP_Tflush: handler = (tmessage_handler)handle_Tflush; break; @@ -644,8 +649,9 @@ void lib9p_srv_worker(struct srv_req *ctx) { case LIB9P_TYP_Tremove: handler = (tmessage_handler)handle_Tremove; break; case LIB9P_TYP_Tstat: handler = (tmessage_handler)handle_Tstat; break; case LIB9P_TYP_Twstat: handler = (tmessage_handler)handle_Twstat; break; +#endif #if CONFIG_9P_ENABLE_9P2000_p9p - case LIB9P_TYP_Topenfd: handler = (tmessage_handler)handle_Topenfd; break + case LIB9P_TYP_Topenfd: handler = (tmessage_handler)handle_Topenfd; break; #endif #if CONFIG_9P_ENABLE_9P2000_e case LIB9P_TYP_Tsession: handler = (tmessage_handler)handle_Tsession; break; @@ -656,24 +662,11 @@ void lib9p_srv_worker(struct srv_req *ctx) { assert_notreached("lib9p_Tmsg_validate() should have rejected unknown typ"); } #pragma GCC diagnostic pop - handler(ctx, (void *)host_req, (void *)host_resp); + handler(ctx, (void *)host_req); + assert(ctx->responded); - /* Write the response. ***********************************************/ - write: - if (lib9p_ctx_has_error(&ctx->basectx)) { - srv_respond_error(ctx); - } else if (ctx->flush_observed) { - /* do nothing */ - } else { - struct lib9p_Rmsg_send_buf net_resp; - if (lib9p_Rmsg_marshal(&ctx->basectx, - typ+1, host_resp, - &net_resp)) - goto write; - srv_msglog(ctx, typ+1, &host_resp); - srv_write_Rmsg(ctx, &net_resp); - } /* Release resources. ************************************************/ + release: map_del(&ctx->parent_sess->reqs, ctx->tag); size_t nwaiters; while ((nwaiters = cr_chan_num_waiters(&ctx->flush_ch))) { @@ -688,21 +681,43 @@ void lib9p_srv_worker(struct srv_req *ctx) { free(ctx->net_bytes); } +static inline void _srv_respond(struct srv_req *ctx, enum lib9p_msg_type resp_typ, void *host_resp) { + assert(!ctx->responded); + if (lib9p_ctx_has_error(&ctx->basectx)) { + error: + srv_respond_error(ctx); + } else if (ctx->flush_acknowledged) { + /* do nothing */ + } else { + assert(host_resp); + struct lib9p_Rmsg_send_buf net_resp; + if (lib9p_Rmsg_marshal(&ctx->basectx, + resp_typ, host_resp, + &net_resp)) + goto error; + srv_msglog(ctx, resp_typ, host_resp); + srv_write_Rmsg(ctx, &net_resp); + } + ctx->responded = true; +} +#define srv_respond(CTX, TYP, HOST_RESP) do { \ + struct lib9p_msg_R##TYP *_host_resp = HOST_RESP; \ + _srv_respond(CTX, LIB9P_TYP_R##TYP, _host_resp); \ +} while (0) + /* handle_T* ******************************************************************/ -#define srv_handler_common(ctx, req, resp) do { \ - assert(ctx); \ - assert(req); \ - assert(resp); \ - resp->tag = req->tag; \ - } while (0) +#define srv_handler_common(ctx, typ, req) \ + assert(ctx); \ + assert(req); \ + struct lib9p_msg_T##typ *_typecheck_req [[gnu::unused]] = req; \ + struct lib9p_msg_R##typ resp = { .tag = ctx->tag } static void handle_Tversion(struct srv_req *ctx, - struct lib9p_msg_Tversion *req, - struct lib9p_msg_Rversion *resp) { - srv_handler_common(ctx, req, resp); + struct lib9p_msg_Tversion *req) { + srv_handler_common(ctx, version, req); - enum lib9p_version version = LIB9P_VER_unknown; + enum lib9p_version version = LIB9P_VER_uninitialized; if (req->version.len >= 6 && req->version.utf8[0] == '9' && @@ -712,7 +727,9 @@ static void handle_Tversion(struct srv_req *ctx, '0' <= req->version.utf8[4] && req->version.utf8[4] <= '9' && '0' <= req->version.utf8[5] && req->version.utf8[5] <= '9' && (req->version.len == 6 || req->version.utf8[6] == '.')) { +#if CONFIG_9P_ENABLE_9P2000 version = LIB9P_VER_9P2000; +#endif #if CONFIG_9P_ENABLE_9P2000_p9p struct lib9p_srv *srv = ctx->parent_sess->parent_conn->parent_srv; if (srv->type_assert_unix && !LO_IS_NULL(srv->type_assert_unix(ctx->parent_sess->parent_conn->fd))) @@ -728,20 +745,24 @@ static void handle_Tversion(struct srv_req *ctx, #endif } - uint32_t min_msg_size = lib9p_version_min_msg_size(version); + /* XXX: There are good arguments that min_msg_size should be + * something larger than max(rerror.min_size(), + * rread.min_size()+1). */ + uint32_t min_msg_size = _LIB9P_MAX(lib9p_version_min_Rerror_size(ctx->basectx.version), + lib9p_version_min_Rread_size(ctx->basectx.version)+1); if (req->max_msg_size < min_msg_size) { lib9p_errorf(&ctx->basectx, LIB9P_ERRNO_L_EDOM, "requested max_msg_size is less than minimum for %s (%"PRIu32" < %"PRIu32")", lib9p_version_str(version), req->max_msg_size, min_msg_size); - return; + goto tversion_return; } - resp->version = lib9p_str((char *)lib9p_version_str(version)); /* cast to discard "const" qualifier */ + resp.version = lib9p_str((char *)lib9p_version_str(version)); /* cast to discard "const" qualifier */ #if CONFIG_9P_ENABLE_9P2000_p9p if (version == LIB9P_VER_9P2000_p9p) - resp->version = lib9p_str("9P2000"); + resp.version = lib9p_str("9P2000"); #endif - resp->max_msg_size = (CONFIG_9P_SRV_MAX_MSG_SIZE < req->max_msg_size) + resp.max_msg_size = (CONFIG_9P_SRV_MAX_MSG_SIZE < req->max_msg_size) ? CONFIG_9P_SRV_MAX_MSG_SIZE : req->max_msg_size; @@ -760,33 +781,36 @@ static void handle_Tversion(struct srv_req *ctx, cr_select_v(i, args); } } - if (map_len(&ctx->parent_sess->fids)) { - /* Close all FIDs. */ - MAP_FOREACH(&ctx->parent_sess->fids, fid, fidinfo) { - handle_Tclunk(ctx, - &(struct lib9p_msg_Tclunk){.fid = fid}, - &(struct lib9p_msg_Rclunk){}); + /* Close all FIDs. */ + MAP_FOREACH(&ctx->parent_sess->fids, fid, fidinfo) { + srv_fid_del(ctx, fid, fidinfo, false); + if (lib9p_ctx_has_error(&ctx->basectx)) { + srv_nonrespond_errorf("clunk: %.*s", CONFIG_9P_MAX_ERR_SIZE, ctx->basectx.err_msg); + lib9p_ctx_clear_error(&ctx->basectx); } } /* Replace the old session with the new session. */ ctx->parent_sess->version = version; - ctx->parent_sess->max_msg_size = resp->max_msg_size; + ctx->parent_sess->max_msg_size = resp.max_msg_size; + + tversion_return: + srv_respond(ctx, version, &resp); } +#if _LIB9P_ENABLE_stat static void handle_Tauth(struct srv_req *ctx, - struct lib9p_msg_Tauth *req, - struct lib9p_msg_Rauth *resp) { - srv_handler_common(ctx, req, resp); + struct lib9p_msg_Tauth *req) { + srv_handler_common(ctx, auth, req); struct lib9p_srv *srv = ctx->parent_sess->parent_conn->parent_srv; if (!srv->auth) { lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EOPNOTSUPP, "authentication not required"); - return; + goto tauth_return; } - ctx->authinfo = srv_authinfo_new(req->uname, req->n_uid); + ctx->user = srv_userid_new(req->uname, req->unum); srv->auth(ctx, req->aname); @@ -794,18 +818,20 @@ static void handle_Tauth(struct srv_req *ctx, LIB9P_ERRNO_L_EOPNOTSUPP, "TODO: auth not implemented"); if (lib9p_ctx_has_error(&ctx->basectx)) - ctx->authinfo = srv_authinfo_decref(ctx->authinfo); + ctx->user = srv_userid_decref(ctx->user); + + tauth_return: + srv_respond(ctx, auth, &resp); } static void handle_Tattach(struct srv_req *ctx, - struct lib9p_msg_Tattach *req, - struct lib9p_msg_Rattach *resp) { - srv_handler_common(ctx, req, resp); + struct lib9p_msg_Tattach *req) { + srv_handler_common(ctx, attach, req); if (req->fid == LIB9P_FID_NOFID) { lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EBADF, "cannot assign to NOFID"); - return; + goto tattach_return; } struct lib9p_srv *srv = ctx->parent_sess->parent_conn->parent_srv; @@ -817,16 +843,16 @@ static void handle_Tattach(struct srv_req *ctx, else if (afid->type != SRV_FILETYPE_AUTH) lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EACCES, "FID provided as auth-file is not an auth-file"); - else if (!lib9p_str_eq(afid->authinfo->uname, req->uname)) + else if (!lib9p_str_eq(afid->user->name, req->uname)) lib9p_errorf(&ctx->basectx, LIB9P_ERRNO_L_EACCES, "FID provided as auth-file is for user=\"%.*s\" and cannot be used for user=\"%.*s\"", - afid->authinfo->uname.len, afid->authinfo->uname.utf8, + afid->user->name.len, afid->user->name.utf8, req->uname.len, req->uname.utf8); -#if CONFIG_9P_ENABLE_9P2000_u - else if (afid->authinfo->uid != req->n_uid) +#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L + else if (afid->user->num != req->unum) lib9p_errorf(&ctx->basectx, LIB9P_ERRNO_L_EACCES, "FID provided as auth-file is for user=%"PRIu32" and cannot be used for user=%"PRIu32, - afid->authinfo->uid, req->n_uid); + afid->user->num, req->unum); #endif else if (!lib9p_str_eq(afid->auth.aname, req->aname)) lib9p_errorf(&ctx->basectx, @@ -837,24 +863,22 @@ static void handle_Tattach(struct srv_req *ctx, lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EACCES, "FID provided as auth-file has not completed authentication"); if (lib9p_ctx_has_error(&ctx->basectx)) - return; - ctx->authinfo = srv_authinfo_incref(afid->authinfo); + goto tattach_return; + ctx->user = srv_userid_incref(afid->user); } else { if (req->afid != LIB9P_FID_NOFID) { lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EACCES, "FID provided as auth-file, but no auth-file is required"); - return; + goto tattach_return; } - ctx->authinfo = srv_authinfo_new(req->uname, req->n_uid); + ctx->user = srv_userid_new(req->uname, req->unum); } /* 1. File object */ lo_interface lib9p_srv_file root_file = srv->rootdir(ctx, req->aname); assert(LO_IS_NULL(root_file) == lib9p_ctx_has_error(&ctx->basectx)); - if (lib9p_ctx_has_error(&ctx->basectx)) { - ctx->authinfo = srv_authinfo_decref(ctx->authinfo); - return; - } + if (lib9p_ctx_has_error(&ctx->basectx)) + goto tattach_return; struct lib9p_qid root_qid = LO_CALL(root_file, qid); assert(srv_qid_filetype(root_qid) == SRV_FILETYPE_DIR); @@ -865,19 +889,19 @@ static void handle_Tattach(struct srv_req *ctx, /* 3. fidinfo */ if (!srv_fid_store(ctx, req->fid, root_pathinfo, false)) { srv_path_decref(ctx, root_qid.path); - ctx->authinfo = srv_authinfo_decref(ctx->authinfo); - return; + goto tattach_return; } - ctx->authinfo = srv_authinfo_decref(ctx->authinfo); - resp->qid = root_qid; - return; + resp.qid = root_qid; + tattach_return: + if (ctx->user) + ctx->user = srv_userid_decref(ctx->user); + srv_respond(ctx, attach, &resp); } static void handle_Tflush(struct srv_req *ctx, - struct lib9p_msg_Tflush *req, - struct lib9p_msg_Rflush *resp) { - srv_handler_common(ctx, req, resp); + struct lib9p_msg_Tflush *req) { + srv_handler_common(ctx, flush, req); struct srv_req **oldreqp = map_load(&ctx->parent_sess->reqs, req->oldtag); if (oldreqp) { @@ -887,46 +911,47 @@ static void handle_Tflush(struct srv_req *ctx, CR_SELECT_SEND(&ctx->flush_ch, &res))) { case 0: /* original request returned */ req_debugf("original request (tag=%"PRIu16") returned", req->oldtag); - ctx->flush_observed = (res == _LIB9P_SRV_FLUSH_SILENT); + ctx->flush_acknowledged = (res == _LIB9P_SRV_FLUSH_SILENT); break; case 1: /* flush itself got flushed */ req_debugf("flush itself flushed"); - ctx->flush_observed = true; + ctx->flush_acknowledged = true; break; } } + srv_respond(ctx, flush, &resp); } static void handle_Twalk(struct srv_req *ctx, - struct lib9p_msg_Twalk *req, - struct lib9p_msg_Rwalk *resp) { - srv_handler_common(ctx, req, resp); + struct lib9p_msg_Twalk *req) { + srv_handler_common(ctx, walk, req); if (req->newfid == LIB9P_FID_NOFID) { lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EBADF, "cannot assign to NOFID"); - return; + goto twalk_return; } struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid); if (!fidinfo) { lib9p_errorf(&ctx->basectx, LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid); - return; + goto twalk_return; } if (fidinfo->flags & FIDFLAG_OPEN) { lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EALREADY, "cannot walk on FID open for I/O"); - return; + goto twalk_return; } - ctx->authinfo = srv_authinfo_incref(fidinfo->authinfo); + ctx->user = srv_userid_incref(fidinfo->user); struct srv_pathinfo *pathinfo = map_load(&ctx->parent_sess->paths, fidinfo->path); assert(pathinfo); pathinfo->gc_refcount++; - resp->wqid = (struct lib9p_qid *)(&resp[1]); - for (resp->nwqid = 0; resp->nwqid < req->nwname; resp->nwqid++) { + struct lib9p_qid _resp_qid[16]; + resp.wqid = _resp_qid; + for (resp.nwqid = 0; resp.nwqid < req->nwname; resp.nwqid++) { if (pathinfo->type != SRV_FILETYPE_DIR) { lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_ENOTDIR, "not a directory"); @@ -934,12 +959,12 @@ static void handle_Twalk(struct srv_req *ctx, } struct srv_pathinfo *new_pathinfo; - if (lib9p_str_eq(req->wname[resp->nwqid], lib9p_str(".."))) { + if (lib9p_str_eq(req->wname[resp.nwqid], lib9p_str(".."))) { new_pathinfo = map_load(&ctx->parent_sess->paths, pathinfo->parent_dir); assert(new_pathinfo); new_pathinfo->gc_refcount++; } else { - lo_interface lib9p_srv_file member_file = LO_CALL(pathinfo->file, dwalk, ctx, req->wname[resp->nwqid]); + lo_interface lib9p_srv_file member_file = LO_CALL(pathinfo->file, dwalk, ctx, req->wname[resp.nwqid]); assert(LO_IS_NULL(member_file) == lib9p_ctx_has_error(&ctx->basectx)); if (lib9p_ctx_has_error(&ctx->basectx)) break; @@ -948,10 +973,10 @@ static void handle_Twalk(struct srv_req *ctx, } if (new_pathinfo->type == SRV_FILETYPE_DIR) { - struct lib9p_stat stat = LO_CALL(new_pathinfo->file, stat, ctx); + struct lib9p_srv_stat stat = LO_CALL(new_pathinfo->file, stat, ctx); if (lib9p_ctx_has_error(&ctx->basectx)) break; - lib9p_stat_assert(stat); + lib9p_srv_stat_assert(stat); if (!srv_check_perm(ctx, &stat, 0b001)) { lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EACCES, "you do not have execute permission on that directory"); @@ -960,39 +985,41 @@ static void handle_Twalk(struct srv_req *ctx, } } - resp->wqid[resp->nwqid] = LO_CALL(new_pathinfo->file, qid); + resp.wqid[resp.nwqid] = LO_CALL(new_pathinfo->file, qid); srv_path_decref(ctx, LO_CALL(pathinfo->file, qid).path); pathinfo = new_pathinfo; } - if (resp->nwqid == req->nwname) { + if (resp.nwqid == req->nwname) { if (!srv_fid_store(ctx, req->newfid, pathinfo, req->newfid == req->fid)) srv_path_decref(ctx, LO_CALL(pathinfo->file, qid).path); } else { assert(lib9p_ctx_has_error(&ctx->basectx)); srv_path_decref(ctx, LO_CALL(pathinfo->file, qid).path); - if (resp->nwqid > 0) + if (resp.nwqid > 0) lib9p_ctx_clear_error(&ctx->basectx); } - ctx->authinfo = srv_authinfo_decref(ctx->authinfo); + twalk_return: + if (ctx->user) + ctx->user = srv_userid_decref(ctx->user); + srv_respond(ctx, walk, &resp); } static void handle_Topen(struct srv_req *ctx, - struct lib9p_msg_Topen *req, - struct lib9p_msg_Ropen *resp) { - srv_handler_common(ctx, req, resp); + struct lib9p_msg_Topen *req) { + srv_handler_common(ctx, open, req); /* Check that the FID is valid for this. */ struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid); if (!fidinfo) { lib9p_errorf(&ctx->basectx, LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid); - return; + goto topen_return; } if (fidinfo->flags & FIDFLAG_OPEN) { lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EALREADY, "FID is already open"); - return; + goto topen_return; } if (fidinfo->type == SRV_FILETYPE_DIR) { if ( ((req->mode & LIB9P_O_MODE_MASK) != LIB9P_O_MODE_READ) || @@ -1000,10 +1027,10 @@ static void handle_Topen(struct srv_req *ctx, (req->mode & LIB9P_O_RCLOSE) ) { lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EISDIR, "directories cannot be written, executed, truncated, or removed-on-close"); - return; + goto topen_return; } } - ctx->authinfo = srv_authinfo_incref(fidinfo->authinfo); + ctx->user = srv_userid_incref(fidinfo->user); /* Variables. */ lib9p_o_t reqmode = req->mode; @@ -1015,10 +1042,10 @@ static void handle_Topen(struct srv_req *ctx, if (reqmode & LIB9P_O_RCLOSE) { struct srv_pathinfo *parent = map_load(&ctx->parent_sess->paths, pathinfo->parent_dir); assert(parent); - struct lib9p_stat parent_stat = LO_CALL(parent->file, stat, ctx); + struct lib9p_srv_stat parent_stat = LO_CALL(parent->file, stat, ctx); if (lib9p_ctx_has_error(&ctx->basectx)) goto topen_return; - lib9p_stat_assert(parent_stat); + lib9p_srv_stat_assert(parent_stat); if (!srv_check_perm(ctx, &parent_stat, 0b010)) { lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EACCES, "permission denied to remove-on-close"); @@ -1026,17 +1053,19 @@ static void handle_Topen(struct srv_req *ctx, } fidflags |= FIDFLAG_RCLOSE; } - struct lib9p_stat stat = LO_CALL(pathinfo->file, stat, ctx); + struct lib9p_srv_stat stat = LO_CALL(pathinfo->file, stat, ctx); if (lib9p_ctx_has_error(&ctx->basectx)) goto topen_return; - lib9p_stat_assert(stat); - if ((stat.file_mode & LIB9P_DM_EXCL) && pathinfo->io_refcount) { + lib9p_srv_stat_assert(stat); + if ((stat.mode & LIB9P_DM_EXCL) && pathinfo->io_refcount) { lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EEXIST, "exclusive file is already opened"); goto topen_return; } - if (stat.file_mode & LIB9P_DM_APPEND) + if (stat.mode & LIB9P_DM_APPEND) { + fidflags |= FIDFLAG_APPEND; reqmode = reqmode & ~LIB9P_O_TRUNC; + } uint8_t perm_bits = 0; bool rd = false, wr = false; switch (reqmode & LIB9P_O_MODE_MASK) { @@ -1102,94 +1131,173 @@ static void handle_Topen(struct srv_req *ctx, fidflags |= FIDFLAG_OPEN_W; pathinfo->io_refcount++; fidinfo->flags = fidflags; - resp->qid = qid; - resp->iounit = iounit; + resp.qid = qid; + resp.iounit = iounit; topen_return: - ctx->authinfo = srv_authinfo_decref(ctx->authinfo); + if (ctx->user) + ctx->user = srv_userid_decref(ctx->user); + srv_respond(ctx, open, &resp); } static void handle_Tcreate(struct srv_req *ctx, - struct lib9p_msg_Tcreate *req, - struct lib9p_msg_Rcreate *resp) { - srv_handler_common(ctx, req, resp); + struct lib9p_msg_Tcreate *req) { + srv_handler_common(ctx, create, req); lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EOPNOTSUPP, "create not (yet?) implemented"); + + srv_respond(ctx, create, &resp); +} + +static inline struct lib9p_stat srv_stat_to_net_stat(struct lib9p_srv_stat in) { + return (struct lib9p_stat){ + .qid = in.qid, + .mode = in.mode, + .atime = in.atime_sec, + .mtime = in.mtime_sec, + .length = in.size, + .name = in.name, + .owner_uname = in.owner_uid.name, + .owner_gname = in.owner_gid.name, + .last_modifier_uname = in.last_modifier_uid.name, +#if CONFIG_9P_ENABLE_9P2000_u + .owner_unum = in.owner_uid.num, + .owner_gnum = in.owner_gid.num, + .last_modifier_unum = in.last_modifier_uid.num, + .extension = in.extension, +#endif + }; } static void handle_Tread(struct srv_req *ctx, - struct lib9p_msg_Tread *req, - struct lib9p_msg_Rread *resp) { - srv_handler_common(ctx, req, resp); + struct lib9p_msg_Tread *req) { + srv_handler_common(ctx, read, req); + char *heap = NULL; /* TODO: serialize simultaneous reads to the same FID */ + if (req->count > ctx->basectx.max_msg_size - lib9p_version_min_Rread_size(ctx->basectx.version)) + req->count = ctx->basectx.max_msg_size - lib9p_version_min_Rread_size(ctx->basectx.version); + /* Check that the FID is valid for this. */ struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid); if (!fidinfo) { lib9p_errorf(&ctx->basectx, LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid); - return; + goto tread_return; } if (!(fidinfo->flags & FIDFLAG_OPEN_R)) { lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EINVAL, "FID not open for reading"); - return; + goto tread_return; } /* Do it. */ - ctx->authinfo = srv_authinfo_incref(fidinfo->authinfo); + ctx->user = srv_userid_incref(fidinfo->user); switch (fidinfo->type) { case SRV_FILETYPE_DIR: - /* Translate byte-offset to object-index. */ - size_t idx; - if (req->offset == 0) - idx = 0; - else if (req->offset == fidinfo->dir.off) - idx = fidinfo->dir.idx; - else { +#if _LIB9P_ENABLE_stat + /* Seek. */ + if (req->offset == 0) { + fidinfo->dir.idx = 0; + fidinfo->dir.off = 0; + fidinfo->dir.buffered_dirent = (struct lib9p_srv_dirent){}; + } else if (req->offset != fidinfo->dir.off) { lib9p_errorf(&ctx->basectx, LIB9P_ERRNO_L_EINVAL, "invalid offset (must be 0 or %"PRIu64"): %"PRIu64, fidinfo->dir.off, req->offset); - ctx->authinfo = srv_authinfo_decref(ctx->authinfo); - return; + goto tread_return; } - /* Do it. */ - resp->data = (char *)(&resp[1]); - size_t num = LO_CALL(fidinfo->dir.io, dread, ctx, (uint8_t *)resp->data, req->count, idx); - /* Translate object-count back to byte-count. */ - uint32_t len = 0; - for (size_t i = 0; i < num; i++) { - uint32_t i_len; - lib9p_stat_validate(&ctx->basectx, req->count, &((uint8_t *)resp->data)[len], &i_len, NULL); - len += i_len; + /* Read. */ + resp.data = heap = malloc(req->count); + resp.count = 0; + struct srv_pathinfo *dir_pathinfo = NULL; + for (;;) { + lo_interface lib9p_srv_file member_file = {}; + struct lib9p_srv_dirent member_dirent; + if (fidinfo->dir.buffered_dirent.name.len) { + member_dirent = fidinfo->dir.buffered_dirent; + } else { + member_dirent = LO_CALL(fidinfo->dir.io, dread, ctx, fidinfo->dir.idx); + if (lib9p_ctx_has_error(&ctx->basectx)) { + if (!resp.count) + goto tread_return; + lib9p_ctx_clear_error(&ctx->basectx); + break; + } + } + if (!member_dirent.name.len) + break; + struct lib9p_srv_stat member_stat; + struct srv_pathinfo *member_pathinfo = map_load(&ctx->parent_sess->paths, member_dirent.qid.path); + if (member_pathinfo) { + member_stat = LO_CALL(member_pathinfo->file, stat, ctx); + } else { + if (!dir_pathinfo) + dir_pathinfo = map_load(&ctx->parent_sess->paths, fidinfo->path); + assert(dir_pathinfo); + member_file = LO_CALL(dir_pathinfo->file, dwalk, ctx, member_dirent.name); + assert(LO_IS_NULL(member_file) == lib9p_ctx_has_error(&ctx->basectx)); + if (!lib9p_ctx_has_error(&ctx->basectx)) + member_stat = LO_CALL(member_file, stat, ctx); + } + if (lib9p_ctx_has_error(&ctx->basectx)) { + if (!LO_IS_NULL(member_file)) + LO_CALL(member_file, free); + if (!resp.count) + goto tread_return; + lib9p_ctx_clear_error(&ctx->basectx); + break; + } + lib9p_srv_stat_assert(member_stat); + struct lib9p_stat member_netstat = srv_stat_to_net_stat(member_stat); + uint32_t nbytes = lib9p_stat_marshal(&ctx->basectx, req->count-resp.count, &member_netstat, + (uint8_t *)&resp.data[resp.count]); + if (!LO_IS_NULL(member_file)) + LO_CALL(member_file, free); + if (!nbytes) { + if (!resp.count) { + lib9p_error(&ctx->basectx, + LIB9P_ERRNO_L_ERANGE, "stat object does not fit into negotiated max message size"); + goto tread_return; + } + fidinfo->dir.buffered_dirent = member_dirent; + break; + } + resp.count += nbytes; + fidinfo->dir.idx++; + fidinfo->dir.off += nbytes; + fidinfo->dir.buffered_dirent = (struct lib9p_srv_dirent){}; } - resp->count = len; - /* Remember. */ - fidinfo->dir.idx = idx+num; - fidinfo->dir.off = req->offset + len; +#else + assert_notreached("Tread for directory on protocol version without that"); +#endif break; case SRV_FILETYPE_FILE: struct iovec iov; LO_CALL(fidinfo->file.io, pread, ctx, req->count, req->offset, &iov); - if (!lib9p_ctx_has_error(&ctx->basectx) && !ctx->flush_observed) { - resp->count = iov.iov_len; - resp->data = iov.iov_base; - if (resp->count > req->count) - resp->count = req->count; + if (!lib9p_ctx_has_error(&ctx->basectx) && !ctx->flush_acknowledged) { + resp.count = iov.iov_len; + resp.data = iov.iov_base; + if (resp.count > req->count) + resp.count = req->count; } break; case SRV_FILETYPE_AUTH: assert_notreached("TODO: auth not yet implemented"); break; } - ctx->authinfo = srv_authinfo_decref(ctx->authinfo); + tread_return: + if (ctx->user) + ctx->user = srv_userid_decref(ctx->user); + srv_respond(ctx, read, &resp); + if (heap) + free(heap); } static void handle_Twrite(struct srv_req *ctx, - struct lib9p_msg_Twrite *req, - struct lib9p_msg_Rwrite *resp) { - srv_handler_common(ctx, req, resp); + struct lib9p_msg_Twrite *req) { + srv_handler_common(ctx, write, req); /* TODO: serialize simultaneous writes to the same FID */ @@ -1198,120 +1306,154 @@ static void handle_Twrite(struct srv_req *ctx, if (!fidinfo) { lib9p_errorf(&ctx->basectx, LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid); - return; + goto twrite_return; } if (!(fidinfo->flags & FIDFLAG_OPEN_W)) { lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EINVAL, "FID not open for writing"); - return; + goto twrite_return; } + if (fidinfo->flags & FIDFLAG_APPEND) + req->offset = 0; /* Do it. */ - ctx->authinfo = srv_authinfo_incref(fidinfo->authinfo); - resp->count = LO_CALL(fidinfo->file.io, pwrite, ctx, req->data, req->count, req->offset); - ctx->authinfo = srv_authinfo_decref(ctx->authinfo); + ctx->user = srv_userid_incref(fidinfo->user); + resp.count = LO_CALL(fidinfo->file.io, pwrite, ctx, req->data, req->count, req->offset); + twrite_return: + if (ctx->user) + ctx->user = srv_userid_decref(ctx->user); + srv_respond(ctx, write, &resp); } static void handle_Tclunk(struct srv_req *ctx, - struct lib9p_msg_Tclunk *req, - struct lib9p_msg_Rclunk *resp) { - srv_handler_common(ctx, req, resp); + struct lib9p_msg_Tclunk *req) { + srv_handler_common(ctx, clunk, req); struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid); if (!fidinfo) { lib9p_errorf(&ctx->basectx, LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid); - return; + goto tclunk_return; } - ctx->authinfo = srv_authinfo_incref(fidinfo->authinfo); - srv_fid_del(ctx, req->fid, false); - ctx->authinfo = srv_authinfo_decref(ctx->authinfo); + srv_fid_del(ctx, req->fid, fidinfo, false); + + tclunk_return: + srv_respond(ctx, clunk, &resp); } static void handle_Tremove(struct srv_req *ctx, - struct lib9p_msg_Tremove *req, - struct lib9p_msg_Rremove *resp) { - srv_handler_common(ctx, req, resp); + struct lib9p_msg_Tremove *req) { + srv_handler_common(ctx, remove, req); struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid); if (!fidinfo) { lib9p_errorf(&ctx->basectx, LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid); - return; + goto tremove_return; } - ctx->authinfo = srv_authinfo_incref(fidinfo->authinfo); - srv_fid_del(ctx, req->fid, true); - ctx->authinfo = srv_authinfo_decref(ctx->authinfo); + bool remove = true; + struct srv_pathinfo *pathinfo = map_load(&ctx->parent_sess->paths, fidinfo->path); + assert(pathinfo); + if (pathinfo->parent_dir == fidinfo->path) { + lib9p_error(&ctx->basectx, + LIB9P_ERRNO_L_EBUSY, "cannot remove root"); + remove = false; + goto tremove_main; + } + struct srv_pathinfo *parent = map_load(&ctx->parent_sess->paths, pathinfo->parent_dir); + assert(parent); + struct lib9p_srv_stat parent_stat = LO_CALL(parent->file, stat, ctx); + if (!lib9p_ctx_has_error(&ctx->basectx) && !srv_check_perm(ctx, &parent_stat, 0b010)) { + lib9p_error(&ctx->basectx, + LIB9P_ERRNO_L_EACCES, "you do not have write permission on the parent directory"); + remove = false; + goto tremove_main; + } + + tremove_main: + srv_fid_del(ctx, req->fid, fidinfo, remove); + tremove_return: + srv_respond(ctx, remove, &resp); } static void handle_Tstat(struct srv_req *ctx, - struct lib9p_msg_Tstat *req, - struct lib9p_msg_Rstat *resp) { - srv_handler_common(ctx, req, resp); + struct lib9p_msg_Tstat *req) { + srv_handler_common(ctx, stat, req); struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid); if (!fidinfo) { lib9p_errorf(&ctx->basectx, LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid); - return; + goto tstat_return; } struct srv_pathinfo *pathinfo = map_load(&ctx->parent_sess->paths, fidinfo->path); assert(pathinfo); - ctx->authinfo = srv_authinfo_incref(fidinfo->authinfo); - resp->stat = LO_CALL(pathinfo->file, stat, ctx); - if (!lib9p_ctx_has_error(&ctx->basectx)) - lib9p_stat_assert(resp->stat); - ctx->authinfo = srv_authinfo_decref(ctx->authinfo); + ctx->user = srv_userid_incref(fidinfo->user); + struct lib9p_srv_stat stat = LO_CALL(pathinfo->file, stat, ctx); + if (lib9p_ctx_has_error(&ctx->basectx)) + goto tstat_return; + lib9p_srv_stat_assert(stat); + resp.stat = srv_stat_to_net_stat(stat); + tstat_return: + if (ctx->user) + ctx->user = srv_userid_decref(ctx->user); + srv_respond(ctx, stat, &resp); } static void handle_Twstat(struct srv_req *ctx, - struct lib9p_msg_Twstat *req, - struct lib9p_msg_Rwstat *resp) { - srv_handler_common(ctx, req, resp); + struct lib9p_msg_Twstat *req) { + srv_handler_common(ctx, wstat, req); lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EOPNOTSUPP, "wstat not (yet?) implemented"); + + srv_respond(ctx, wstat, &resp); } +#endif #if CONFIG_9P_ENABLE_9P2000_p9p static void handle_Topenfd(struct srv_req *ctx, - struct lib9p_msg_Topenfd *req, - struct lib9p_msg_Ropenfd *resp) { - srv_handler_common(ctx, req, resp); + struct lib9p_msg_Topenfd *req) { + srv_handler_common(ctx, openfd, req); lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EOPNOTSUPP, "openfd not (yet?) implemented"); + + srv_respond(ctx, openfd, &resp); } #endif #if CONFIG_9P_ENABLE_9P2000_e static void handle_Tsession(struct srv_req *ctx, - struct lib9p_msg_Tsession *req, - struct lib9p_msg_Rsession *resp) { - srv_handler_common(ctx, req, resp); + struct lib9p_msg_Tsession *req) { + srv_handler_common(ctx, session, req); lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EOPNOTSUPP, "session not (yet?) implemented"); + + srv_respond(ctx, session, &resp); } static void handle_Tsread(struct srv_req *ctx, - struct lib9p_msg_Tsread *req, - struct lib9p_msg_Rsread *resp) { - srv_handler_common(ctx, req, resp); + struct lib9p_msg_Tsread *req) { + srv_handler_common(ctx, sread, req); lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EOPNOTSUPP, "sread not (yet?) implemented"); + + srv_respond(ctx, sread, &resp); } static void handle_Tswrite(struct srv_req *ctx, - struct lib9p_msg_Tswrite *req, - struct lib9p_msg_Rswrite *resp) { - srv_handler_common(ctx, req, resp); + struct lib9p_msg_Tswrite *req) { + srv_handler_common(ctx, swrite, req); lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EOPNOTSUPP, "swrite not (yet?) implemented"); + + srv_respond(ctx, swrite, &resp); } #endif diff --git a/lib9p/srv_include/lib9p/srv.h b/lib9p/srv_include/lib9p/srv.h index 5c1614a..ca80e7b 100644 --- a/lib9p/srv_include/lib9p/srv.h +++ b/lib9p/srv_include/lib9p/srv.h @@ -19,9 +19,11 @@ /* context ********************************************************************/ -struct lib9p_srv_authinfo { - lib9p_nuid_t uid; - struct lib9p_s uname; +struct lib9p_srv_userid { + struct lib9p_s name; +#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L + lib9p_nuid_t num; +#endif BEGIN_PRIVATE(LIB9P_SRV_H); unsigned int refcount; @@ -37,31 +39,89 @@ CR_CHAN_DECLARE(_lib9p_srv_flush_ch, enum _lib9p_srv_flush_result); struct lib9p_srv_ctx { struct lib9p_ctx basectx; - struct lib9p_srv_authinfo *authinfo; + struct lib9p_srv_userid *user; BEGIN_PRIVATE(LIB9P_SRV_H); struct _lib9p_srv_sess *parent_sess; lib9p_tag_t tag; uint8_t *net_bytes; _lib9p_srv_flush_ch_t flush_ch; - bool flush_observed; + bool flush_acknowledged; + bool responded; END_PRIVATE(LIB9P_SRV_H); }; -bool lib9p_srv_accept_flush(struct lib9p_srv_ctx *ctx); +/** + * Return whether there is an outstanding Tflush or Tversion + * cancellation of this request. After becoming true, this may go + * back to false if the Tflush itself is flushed. + */ +bool lib9p_srv_flush_requested(struct lib9p_srv_ctx *ctx); + +/** + * Acknowledge that the handler is responding to an outstanding flush; + * a non-Rerror R-message will be elided in favor of Rflush/Rversion. + * lib9p_srv_flush_requested() must be true; so do not cr_yield() + * between checking lib9p_srv_flush_requested() and calling + * lib9p_srv_acknowledge_flush(). These are separate calls to + * facilitate cases where a flush merely truncates a call, instead of + * totally canceling it. + */ +void lib9p_srv_acknowledge_flush(struct lib9p_srv_ctx *ctx); + +/* version-independent stat ***************************************************/ + +struct lib9p_srv_stat { + struct lib9p_qid qid; + lib9p_dm_t mode; + uint32_t atime_sec; /* BUG: u32 seconds means a 2106 problem */ +#if CONFIG_9P_ENABLE_9P2000_L + uint32_t atime_nsec; +#endif + uint32_t mtime_sec; /* BUG: u32 seconds means a 2106 problem */ +#if CONFIG_9P_ENABLE_9P2000_L + uint32_t mtime_nsec; + uint32_t ctime_sec; /* BUG: u32 seconds means a 2106 problem */ + uint32_t ctime_nsec; + uint32_t btime_sec; /* BUG: u32 seconds means a 2106 problem */ + uint32_t btime_nsec; +#endif + uint64_t size; + struct lib9p_s name; + struct lib9p_srv_userid owner_uid; + struct lib9p_srv_userid owner_gid; + struct lib9p_srv_userid last_modifier_uid; +#if CONFIG_9P_ENABLE_9P2000_u + struct lib9p_s extension; +#endif +}; + +static inline void lib9p_srv_stat_assert(struct lib9p_srv_stat stat) { + assert( ((bool)(stat.mode & LIB9P_DM_DIR )) == ((bool)(stat.qid.type & LIB9P_QT_DIR )) ); + assert( ((bool)(stat.mode & LIB9P_DM_APPEND)) == ((bool)(stat.qid.type & LIB9P_QT_APPEND)) ); + assert( ((bool)(stat.mode & LIB9P_DM_EXCL )) == ((bool)(stat.qid.type & LIB9P_QT_EXCL )) ); + assert( ((bool)(stat.mode & LIB9P_DM_AUTH )) == ((bool)(stat.qid.type & LIB9P_QT_AUTH )) ); + assert( ((bool)(stat.mode & LIB9P_DM_TMP )) == ((bool)(stat.qid.type & LIB9P_QT_TMP )) ); + assert( (stat.size == 0) || !(stat.mode & LIB9P_DM_DIR) ); +} /* interface definitions ******************************************************/ +struct lib9p_srv_dirent { + struct lib9p_qid qid; + struct lib9p_s name; +}; + lo_interface lib9p_srv_fio; lo_interface lib9p_srv_dio; -/* FIXME: I don't like that the pointers returned by stat() and - * pread() have to remain live after they return. Perhaps a - * `respond()`-callback? But that just reads as gross in C. +/* FIXME: I don't like that the pointer returned by pread() has to + * remain live after it returns. Perhaps a `respond()`-callback? But + * that just reads as gross in C. * * FIXME: It would be nice if pread() could return more than 1 iovec. */ -#define lib9p_srv_file_LO_IFACE \ +#define lib9p_srv_file_LO_IFACE /*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ \ /* resource management **********************************************/ \ \ /** \ @@ -85,29 +145,31 @@ lo_interface lib9p_srv_dio; \ /* non-"opened" generic I/O *****************************************/ \ \ - LO_FUNC(struct lib9p_stat , stat , struct lib9p_srv_ctx *) \ + /** Strings returned from stat() must remain valid until free(). */ \ + LO_FUNC(struct lib9p_srv_stat , stat , struct lib9p_srv_ctx *) \ LO_FUNC(void , wstat , struct lib9p_srv_ctx *, \ - struct lib9p_stat new) \ + struct lib9p_srv_stat) \ LO_FUNC(void , remove , struct lib9p_srv_ctx *) \ \ /* non-"opened" directory I/O ***************************************/ \ \ - LO_FUNC(lo_interface lib9p_srv_file, dwalk , struct lib9p_srv_ctx *, \ - struct lib9p_s childname) \ - LO_FUNC(lo_interface lib9p_srv_file, dcreate, struct lib9p_srv_ctx *, \ - struct lib9p_s childname, \ - lib9p_dm_t perm, \ - lib9p_o_t flags) \ + LO_FUNC(lo_interface lib9p_srv_file, dwalk , struct lib9p_srv_ctx *, \ + struct lib9p_s childname) \ + LO_FUNC(lo_interface lib9p_srv_file, dcreate, struct lib9p_srv_ctx *, \ + struct lib9p_s childname, \ + struct lib9p_srv_userid *user, \ + struct lib9p_srv_userid *group, \ + lib9p_dm_t perm) \ \ /* open() for I/O ***************************************************/ \ \ - LO_FUNC(lo_interface lib9p_srv_fio , fopen , struct lib9p_srv_ctx *, \ - bool rd, bool wr, \ - bool trunc) \ - LO_FUNC(lo_interface lib9p_srv_dio , dopen , struct lib9p_srv_ctx *) -LO_INTERFACE(lib9p_srv_file); + LO_FUNC(lo_interface lib9p_srv_fio , fopen , struct lib9p_srv_ctx *, \ + bool rd, bool wr, \ + bool trunc) \ + LO_FUNC(lo_interface lib9p_srv_dio , dopen , struct lib9p_srv_ctx *) +LO_INTERFACE(lib9p_srv_file); /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ -#define lib9p_srv_fio_LO_IFACE \ +#define lib9p_srv_fio_LO_IFACE /*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ \ LO_FUNC(struct lib9p_qid , qid ) \ LO_FUNC(void , iofree ) \ LO_FUNC(uint32_t , iounit ) \ @@ -115,35 +177,36 @@ LO_INTERFACE(lib9p_srv_file); uint32_t byte_count, \ uint64_t byte_offset, \ struct iovec *ret) \ + /** \ + * If the file was append-only when fopen()ed, then byte_offset will \ + * always be 0. \ + */ \ LO_FUNC(uint32_t , pwrite , struct lib9p_srv_ctx *, \ void *buf, \ uint32_t byte_count, \ uint64_t byte_offset) -LO_INTERFACE(lib9p_srv_fio); - -/* FIXME: The dio interface just feels clunky. I'm not in a rush to - * change it because util9p_static_dir is already implemented and I - * don't anticipate the sbc-harness needing another dio - * implementation. But if I wanted lib9p to be used outside of - * sbc-harness, this is one of the first things that I'd want to - * change. - */ -#define lib9p_srv_dio_LO_IFACE \ +LO_INTERFACE(lib9p_srv_fio); /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ + +#define lib9p_srv_dio_LO_IFACE /*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ \ LO_FUNC(struct lib9p_qid , qid ) \ LO_FUNC(void , iofree ) \ - LO_FUNC(size_t /* <- obj cnt */ , dread , struct lib9p_srv_ctx *, \ - uint8_t *buf, \ - /* num bytes -> */ uint32_t byte_count, \ - /* starting at this object -> */ size_t obj_offset) -LO_INTERFACE(lib9p_srv_dio); + /** \ + * Return the idx-th dirent. idx will always be either 0 or \ + * prev_idx+1. A dirrent with an empty name signals EOF. The string \ + * must remain valid until the next dread() call or iofree(). \ + */ \ + LO_FUNC(struct lib9p_srv_dirent , dread , struct lib9p_srv_ctx *, \ + size_t idx) +LO_INTERFACE(lib9p_srv_dio); /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ -#define LIB9P_SRV_NOTDIR(TYP, NAM) \ - static lo_interface lib9p_srv_file NAM##_dwalk (TYP *, struct lib9p_srv_ctx *, struct lib9p_s) { assert_notreached("not a directory"); } \ - static lo_interface lib9p_srv_file NAM##_dcreate(TYP *, struct lib9p_srv_ctx *, struct lib9p_s, lib9p_dm_t, lib9p_o_t) { assert_notreached("not a directory"); } \ - static lo_interface lib9p_srv_dio NAM##_dopen (TYP *, struct lib9p_srv_ctx *) { assert_notreached("not a directory"); } +#define LIB9P_SRV_NOTDIR(TYP, NAM) \ + static lo_interface lib9p_srv_file NAM##_dwalk (TYP *, struct lib9p_srv_ctx *, struct lib9p_s) { assert_notreached("not a directory"); } \ + static lo_interface lib9p_srv_file NAM##_dcreate(TYP *, struct lib9p_srv_ctx *, struct lib9p_s, \ + struct lib9p_srv_userid *, struct lib9p_srv_userid *, lib9p_dm_t) { assert_notreached("not a directory"); } \ + static lo_interface lib9p_srv_dio NAM##_dopen (TYP *, struct lib9p_srv_ctx *) { assert_notreached("not a directory"); } #define LIB9P_SRV_NOTFILE(TYP, NAM) \ - static lo_interface lib9p_srv_fio NAM##_fopen (TYP *, struct lib9p_srv_ctx *, bool, bool, bool) { assert_notreached("not a file"); } + static lo_interface lib9p_srv_fio NAM##_fopen (TYP *, struct lib9p_srv_ctx *, bool, bool, bool) { assert_notreached("not a file"); } /* main server entrypoints ****************************************************/ diff --git a/lib9p/tests/test_compile.c b/lib9p/tests/test_compile.c index 4532655..e53b738 100644 --- a/lib9p/tests/test_compile.c +++ b/lib9p/tests/test_compile.c @@ -3,428 +3,1253 @@ #include <lib9p/core.h> int main(void) { [[gnu::unused]] uint64_t x; - x = LIB9P_TAG_NOTAG; - x = LIB9P_FID_NOFID; - x = LIB9P_DM_DIR; +#ifdef LIB9P_B4_FALSE + x = LIB9P_B4_FALSE; +#endif +#ifdef LIB9P_B4_TRUE + x = LIB9P_B4_TRUE; +#endif +#ifdef LIB9P_DM_APPEND x = LIB9P_DM_APPEND; - x = LIB9P_DM_EXCL; - x = _LIB9P_DM_PLAN9_MOUNT; +#endif +#ifdef LIB9P_DM_AUTH x = LIB9P_DM_AUTH; - x = LIB9P_DM_TMP; - x = _LIB9P_DM_UNUSED_25; - x = _LIB9P_DM_UNUSED_24; +#endif +#ifdef LIB9P_DM_DEVICE x = LIB9P_DM_DEVICE; - x = _LIB9P_DM_UNUSED_22; - x = LIB9P_DM_PIPE; - x = LIB9P_DM_SOCKET; - x = LIB9P_DM_SETUID; - x = LIB9P_DM_SETGID; - x = _LIB9P_DM_UNUSED_17; - x = _LIB9P_DM_UNUSED_16; - x = _LIB9P_DM_UNUSED_15; - x = _LIB9P_DM_UNUSED_14; - x = _LIB9P_DM_UNUSED_13; - x = _LIB9P_DM_UNUSED_12; - x = _LIB9P_DM_UNUSED_11; - x = _LIB9P_DM_UNUSED_10; - x = _LIB9P_DM_UNUSED_9; - x = LIB9P_DM_OWNER_R; - x = LIB9P_DM_OWNER_W; - x = LIB9P_DM_OWNER_X; +#endif +#ifdef LIB9P_DM_DIR + x = LIB9P_DM_DIR; +#endif +#ifdef LIB9P_DM_EXCL + x = LIB9P_DM_EXCL; +#endif +#ifdef LIB9P_DM_GROUP_R x = LIB9P_DM_GROUP_R; +#endif +#ifdef LIB9P_DM_GROUP_W x = LIB9P_DM_GROUP_W; +#endif +#ifdef LIB9P_DM_GROUP_X x = LIB9P_DM_GROUP_X; +#endif +#ifdef LIB9P_DM_OTHER_R x = LIB9P_DM_OTHER_R; +#endif +#ifdef LIB9P_DM_OTHER_W x = LIB9P_DM_OTHER_W; +#endif +#ifdef LIB9P_DM_OTHER_X x = LIB9P_DM_OTHER_X; +#endif +#ifdef LIB9P_DM_OWNER_R + x = LIB9P_DM_OWNER_R; +#endif +#ifdef LIB9P_DM_OWNER_W + x = LIB9P_DM_OWNER_W; +#endif +#ifdef LIB9P_DM_OWNER_X + x = LIB9P_DM_OWNER_X; +#endif +#ifdef LIB9P_DM_PERM_MASK x = LIB9P_DM_PERM_MASK; - x = LIB9P_QT_DIR; - x = LIB9P_QT_APPEND; - x = LIB9P_QT_EXCL; - x = _LIB9P_QT_PLAN9_MOUNT; - x = LIB9P_QT_AUTH; - x = LIB9P_QT_TMP; - x = LIB9P_QT_SYMLINK; - x = _LIB9P_QT_UNUSED_0; - x = LIB9P_QT_FILE; - x = _LIB9P_O_UNUSED_7; - x = LIB9P_O_RCLOSE; - x = _LIB9P_O_RESERVED_CEXEC; - x = LIB9P_O_TRUNC; - x = _LIB9P_O_UNUSED_3; - x = _LIB9P_O_UNUSED_2; - x = LIB9P_O_FLAG_MASK; - x = LIB9P_O_MODE_READ; - x = LIB9P_O_MODE_WRITE; - x = LIB9P_O_MODE_RDWR; - x = LIB9P_O_MODE_EXEC; - x = LIB9P_O_MODE_MASK; - x = LIB9P_NUID_NONUID; - x = LIB9P_ERRNO_NOERROR; - x = LIB9P_ERRNO_L_EPERM; - x = LIB9P_ERRNO_L_ENOENT; - x = LIB9P_ERRNO_L_ESRCH; - x = LIB9P_ERRNO_L_EINTR; - x = LIB9P_ERRNO_L_EIO; - x = LIB9P_ERRNO_L_ENXIO; +#endif +#ifdef LIB9P_DM_PIPE + x = LIB9P_DM_PIPE; +#endif +#ifdef LIB9P_DM_SETGID + x = LIB9P_DM_SETGID; +#endif +#ifdef LIB9P_DM_SETUID + x = LIB9P_DM_SETUID; +#endif +#ifdef LIB9P_DM_SOCKET + x = LIB9P_DM_SOCKET; +#endif +#ifdef LIB9P_DM_TMP + x = LIB9P_DM_TMP; +#endif +#ifdef LIB9P_DT_BLOCK_DEV + x = LIB9P_DT_BLOCK_DEV; +#endif +#ifdef LIB9P_DT_CHAR_DEV + x = LIB9P_DT_CHAR_DEV; +#endif +#ifdef LIB9P_DT_DIRECTORY + x = LIB9P_DT_DIRECTORY; +#endif +#ifdef LIB9P_DT_PIPE + x = LIB9P_DT_PIPE; +#endif +#ifdef LIB9P_DT_REGULAR + x = LIB9P_DT_REGULAR; +#endif +#ifdef LIB9P_DT_SOCKET + x = LIB9P_DT_SOCKET; +#endif +#ifdef LIB9P_DT_SYMLINK + x = LIB9P_DT_SYMLINK; +#endif +#ifdef LIB9P_DT_UNKNOWN + x = LIB9P_DT_UNKNOWN; +#endif +#ifdef LIB9P_ERRNO_L_E2BIG x = LIB9P_ERRNO_L_E2BIG; - x = LIB9P_ERRNO_L_ENOEXEC; - x = LIB9P_ERRNO_L_EBADF; - x = LIB9P_ERRNO_L_ECHILD; - x = LIB9P_ERRNO_L_EAGAIN; - x = LIB9P_ERRNO_L_ENOMEM; +#endif +#ifdef LIB9P_ERRNO_L_EACCES x = LIB9P_ERRNO_L_EACCES; - x = LIB9P_ERRNO_L_EFAULT; - x = LIB9P_ERRNO_L_ENOTBLK; - x = LIB9P_ERRNO_L_EBUSY; - x = LIB9P_ERRNO_L_EEXIST; - x = LIB9P_ERRNO_L_EXDEV; - x = LIB9P_ERRNO_L_ENODEV; - x = LIB9P_ERRNO_L_ENOTDIR; - x = LIB9P_ERRNO_L_EISDIR; - x = LIB9P_ERRNO_L_EINVAL; - x = LIB9P_ERRNO_L_ENFILE; - x = LIB9P_ERRNO_L_EMFILE; - x = LIB9P_ERRNO_L_ENOTTY; - x = LIB9P_ERRNO_L_ETXTBSY; - x = LIB9P_ERRNO_L_EFBIG; - x = LIB9P_ERRNO_L_ENOSPC; - x = LIB9P_ERRNO_L_ESPIPE; - x = LIB9P_ERRNO_L_EROFS; - x = LIB9P_ERRNO_L_EMLINK; - x = LIB9P_ERRNO_L_EPIPE; - x = LIB9P_ERRNO_L_EDOM; - x = LIB9P_ERRNO_L_ERANGE; - x = LIB9P_ERRNO_L_EDEADLK; - x = LIB9P_ERRNO_L_ENAMETOOLONG; - x = LIB9P_ERRNO_L_ENOLCK; - x = LIB9P_ERRNO_L_ENOSYS; - x = LIB9P_ERRNO_L_ENOTEMPTY; - x = LIB9P_ERRNO_L_ELOOP; - x = LIB9P_ERRNO_L_ENOMSG; - x = LIB9P_ERRNO_L_EIDRM; - x = LIB9P_ERRNO_L_ECHRNG; - x = LIB9P_ERRNO_L_EL2NSYNC; - x = LIB9P_ERRNO_L_EL3HLT; - x = LIB9P_ERRNO_L_EL3RST; - x = LIB9P_ERRNO_L_ELNRNG; - x = LIB9P_ERRNO_L_EUNATCH; - x = LIB9P_ERRNO_L_ENOCSI; - x = LIB9P_ERRNO_L_EL2HLT; +#endif +#ifdef LIB9P_ERRNO_L_EADDRINUSE + x = LIB9P_ERRNO_L_EADDRINUSE; +#endif +#ifdef LIB9P_ERRNO_L_EADDRNOTAVAIL + x = LIB9P_ERRNO_L_EADDRNOTAVAIL; +#endif +#ifdef LIB9P_ERRNO_L_EADV + x = LIB9P_ERRNO_L_EADV; +#endif +#ifdef LIB9P_ERRNO_L_EAFNOSUPPORT + x = LIB9P_ERRNO_L_EAFNOSUPPORT; +#endif +#ifdef LIB9P_ERRNO_L_EAGAIN + x = LIB9P_ERRNO_L_EAGAIN; +#endif +#ifdef LIB9P_ERRNO_L_EALREADY + x = LIB9P_ERRNO_L_EALREADY; +#endif +#ifdef LIB9P_ERRNO_L_EBADE x = LIB9P_ERRNO_L_EBADE; +#endif +#ifdef LIB9P_ERRNO_L_EBADF + x = LIB9P_ERRNO_L_EBADF; +#endif +#ifdef LIB9P_ERRNO_L_EBADFD + x = LIB9P_ERRNO_L_EBADFD; +#endif +#ifdef LIB9P_ERRNO_L_EBADMSG + x = LIB9P_ERRNO_L_EBADMSG; +#endif +#ifdef LIB9P_ERRNO_L_EBADR x = LIB9P_ERRNO_L_EBADR; - x = LIB9P_ERRNO_L_EXFULL; - x = LIB9P_ERRNO_L_ENOANO; +#endif +#ifdef LIB9P_ERRNO_L_EBADRQC x = LIB9P_ERRNO_L_EBADRQC; +#endif +#ifdef LIB9P_ERRNO_L_EBADSLT x = LIB9P_ERRNO_L_EBADSLT; +#endif +#ifdef LIB9P_ERRNO_L_EBFONT x = LIB9P_ERRNO_L_EBFONT; - x = LIB9P_ERRNO_L_ENOSTR; - x = LIB9P_ERRNO_L_ENODATA; - x = LIB9P_ERRNO_L_ETIME; - x = LIB9P_ERRNO_L_ENOSR; - x = LIB9P_ERRNO_L_ENONET; - x = LIB9P_ERRNO_L_ENOPKG; - x = LIB9P_ERRNO_L_EREMOTE; - x = LIB9P_ERRNO_L_ENOLINK; - x = LIB9P_ERRNO_L_EADV; - x = LIB9P_ERRNO_L_ESRMNT; +#endif +#ifdef LIB9P_ERRNO_L_EBUSY + x = LIB9P_ERRNO_L_EBUSY; +#endif +#ifdef LIB9P_ERRNO_L_ECANCELED + x = LIB9P_ERRNO_L_ECANCELED; +#endif +#ifdef LIB9P_ERRNO_L_ECHILD + x = LIB9P_ERRNO_L_ECHILD; +#endif +#ifdef LIB9P_ERRNO_L_ECHRNG + x = LIB9P_ERRNO_L_ECHRNG; +#endif +#ifdef LIB9P_ERRNO_L_ECOMM x = LIB9P_ERRNO_L_ECOMM; - x = LIB9P_ERRNO_L_EPROTO; - x = LIB9P_ERRNO_L_EMULTIHOP; +#endif +#ifdef LIB9P_ERRNO_L_ECONNABORTED + x = LIB9P_ERRNO_L_ECONNABORTED; +#endif +#ifdef LIB9P_ERRNO_L_ECONNREFUSED + x = LIB9P_ERRNO_L_ECONNREFUSED; +#endif +#ifdef LIB9P_ERRNO_L_ECONNRESET + x = LIB9P_ERRNO_L_ECONNRESET; +#endif +#ifdef LIB9P_ERRNO_L_EDEADLK + x = LIB9P_ERRNO_L_EDEADLK; +#endif +#ifdef LIB9P_ERRNO_L_EDESTADDRREQ + x = LIB9P_ERRNO_L_EDESTADDRREQ; +#endif +#ifdef LIB9P_ERRNO_L_EDOM + x = LIB9P_ERRNO_L_EDOM; +#endif +#ifdef LIB9P_ERRNO_L_EDOTDOT x = LIB9P_ERRNO_L_EDOTDOT; - x = LIB9P_ERRNO_L_EBADMSG; - x = LIB9P_ERRNO_L_EOVERFLOW; - x = LIB9P_ERRNO_L_ENOTUNIQ; - x = LIB9P_ERRNO_L_EBADFD; - x = LIB9P_ERRNO_L_EREMCHG; +#endif +#ifdef LIB9P_ERRNO_L_EDQUOT + x = LIB9P_ERRNO_L_EDQUOT; +#endif +#ifdef LIB9P_ERRNO_L_EEXIST + x = LIB9P_ERRNO_L_EEXIST; +#endif +#ifdef LIB9P_ERRNO_L_EFAULT + x = LIB9P_ERRNO_L_EFAULT; +#endif +#ifdef LIB9P_ERRNO_L_EFBIG + x = LIB9P_ERRNO_L_EFBIG; +#endif +#ifdef LIB9P_ERRNO_L_EHOSTDOWN + x = LIB9P_ERRNO_L_EHOSTDOWN; +#endif +#ifdef LIB9P_ERRNO_L_EHOSTUNREACH + x = LIB9P_ERRNO_L_EHOSTUNREACH; +#endif +#ifdef LIB9P_ERRNO_L_EHWPOISON + x = LIB9P_ERRNO_L_EHWPOISON; +#endif +#ifdef LIB9P_ERRNO_L_EIDRM + x = LIB9P_ERRNO_L_EIDRM; +#endif +#ifdef LIB9P_ERRNO_L_EILSEQ + x = LIB9P_ERRNO_L_EILSEQ; +#endif +#ifdef LIB9P_ERRNO_L_EINPROGRESS + x = LIB9P_ERRNO_L_EINPROGRESS; +#endif +#ifdef LIB9P_ERRNO_L_EINTR + x = LIB9P_ERRNO_L_EINTR; +#endif +#ifdef LIB9P_ERRNO_L_EINVAL + x = LIB9P_ERRNO_L_EINVAL; +#endif +#ifdef LIB9P_ERRNO_L_EIO + x = LIB9P_ERRNO_L_EIO; +#endif +#ifdef LIB9P_ERRNO_L_EISCONN + x = LIB9P_ERRNO_L_EISCONN; +#endif +#ifdef LIB9P_ERRNO_L_EISDIR + x = LIB9P_ERRNO_L_EISDIR; +#endif +#ifdef LIB9P_ERRNO_L_EISNAM + x = LIB9P_ERRNO_L_EISNAM; +#endif +#ifdef LIB9P_ERRNO_L_EKEYEXPIRED + x = LIB9P_ERRNO_L_EKEYEXPIRED; +#endif +#ifdef LIB9P_ERRNO_L_EKEYREJECTED + x = LIB9P_ERRNO_L_EKEYREJECTED; +#endif +#ifdef LIB9P_ERRNO_L_EKEYREVOKED + x = LIB9P_ERRNO_L_EKEYREVOKED; +#endif +#ifdef LIB9P_ERRNO_L_EL2HLT + x = LIB9P_ERRNO_L_EL2HLT; +#endif +#ifdef LIB9P_ERRNO_L_EL2NSYNC + x = LIB9P_ERRNO_L_EL2NSYNC; +#endif +#ifdef LIB9P_ERRNO_L_EL3HLT + x = LIB9P_ERRNO_L_EL3HLT; +#endif +#ifdef LIB9P_ERRNO_L_EL3RST + x = LIB9P_ERRNO_L_EL3RST; +#endif +#ifdef LIB9P_ERRNO_L_ELIBACC x = LIB9P_ERRNO_L_ELIBACC; +#endif +#ifdef LIB9P_ERRNO_L_ELIBBAD x = LIB9P_ERRNO_L_ELIBBAD; - x = LIB9P_ERRNO_L_ELIBSCN; - x = LIB9P_ERRNO_L_ELIBMAX; +#endif +#ifdef LIB9P_ERRNO_L_ELIBEXEC x = LIB9P_ERRNO_L_ELIBEXEC; - x = LIB9P_ERRNO_L_EILSEQ; - x = LIB9P_ERRNO_L_ERESTART; - x = LIB9P_ERRNO_L_ESTRPIPE; - x = LIB9P_ERRNO_L_EUSERS; - x = LIB9P_ERRNO_L_ENOTSOCK; - x = LIB9P_ERRNO_L_EDESTADDRREQ; +#endif +#ifdef LIB9P_ERRNO_L_ELIBMAX + x = LIB9P_ERRNO_L_ELIBMAX; +#endif +#ifdef LIB9P_ERRNO_L_ELIBSCN + x = LIB9P_ERRNO_L_ELIBSCN; +#endif +#ifdef LIB9P_ERRNO_L_ELNRNG + x = LIB9P_ERRNO_L_ELNRNG; +#endif +#ifdef LIB9P_ERRNO_L_ELOOP + x = LIB9P_ERRNO_L_ELOOP; +#endif +#ifdef LIB9P_ERRNO_L_EMEDIUMTYPE + x = LIB9P_ERRNO_L_EMEDIUMTYPE; +#endif +#ifdef LIB9P_ERRNO_L_EMFILE + x = LIB9P_ERRNO_L_EMFILE; +#endif +#ifdef LIB9P_ERRNO_L_EMLINK + x = LIB9P_ERRNO_L_EMLINK; +#endif +#ifdef LIB9P_ERRNO_L_EMSGSIZE x = LIB9P_ERRNO_L_EMSGSIZE; - x = LIB9P_ERRNO_L_EPROTOTYPE; - x = LIB9P_ERRNO_L_ENOPROTOOPT; - x = LIB9P_ERRNO_L_EPROTONOSUPPORT; - x = LIB9P_ERRNO_L_ESOCKTNOSUPPORT; - x = LIB9P_ERRNO_L_EOPNOTSUPP; - x = LIB9P_ERRNO_L_EPFNOSUPPORT; - x = LIB9P_ERRNO_L_EAFNOSUPPORT; - x = LIB9P_ERRNO_L_EADDRINUSE; - x = LIB9P_ERRNO_L_EADDRNOTAVAIL; +#endif +#ifdef LIB9P_ERRNO_L_EMULTIHOP + x = LIB9P_ERRNO_L_EMULTIHOP; +#endif +#ifdef LIB9P_ERRNO_L_ENAMETOOLONG + x = LIB9P_ERRNO_L_ENAMETOOLONG; +#endif +#ifdef LIB9P_ERRNO_L_ENAVAIL + x = LIB9P_ERRNO_L_ENAVAIL; +#endif +#ifdef LIB9P_ERRNO_L_ENETDOWN x = LIB9P_ERRNO_L_ENETDOWN; - x = LIB9P_ERRNO_L_ENETUNREACH; +#endif +#ifdef LIB9P_ERRNO_L_ENETRESET x = LIB9P_ERRNO_L_ENETRESET; - x = LIB9P_ERRNO_L_ECONNABORTED; - x = LIB9P_ERRNO_L_ECONNRESET; +#endif +#ifdef LIB9P_ERRNO_L_ENETUNREACH + x = LIB9P_ERRNO_L_ENETUNREACH; +#endif +#ifdef LIB9P_ERRNO_L_ENFILE + x = LIB9P_ERRNO_L_ENFILE; +#endif +#ifdef LIB9P_ERRNO_L_ENOANO + x = LIB9P_ERRNO_L_ENOANO; +#endif +#ifdef LIB9P_ERRNO_L_ENOBUFS x = LIB9P_ERRNO_L_ENOBUFS; - x = LIB9P_ERRNO_L_EISCONN; +#endif +#ifdef LIB9P_ERRNO_L_ENOCSI + x = LIB9P_ERRNO_L_ENOCSI; +#endif +#ifdef LIB9P_ERRNO_L_ENODATA + x = LIB9P_ERRNO_L_ENODATA; +#endif +#ifdef LIB9P_ERRNO_L_ENODEV + x = LIB9P_ERRNO_L_ENODEV; +#endif +#ifdef LIB9P_ERRNO_L_ENOENT + x = LIB9P_ERRNO_L_ENOENT; +#endif +#ifdef LIB9P_ERRNO_L_ENOEXEC + x = LIB9P_ERRNO_L_ENOEXEC; +#endif +#ifdef LIB9P_ERRNO_L_ENOKEY + x = LIB9P_ERRNO_L_ENOKEY; +#endif +#ifdef LIB9P_ERRNO_L_ENOLCK + x = LIB9P_ERRNO_L_ENOLCK; +#endif +#ifdef LIB9P_ERRNO_L_ENOLINK + x = LIB9P_ERRNO_L_ENOLINK; +#endif +#ifdef LIB9P_ERRNO_L_ENOMEDIUM + x = LIB9P_ERRNO_L_ENOMEDIUM; +#endif +#ifdef LIB9P_ERRNO_L_ENOMEM + x = LIB9P_ERRNO_L_ENOMEM; +#endif +#ifdef LIB9P_ERRNO_L_ENOMSG + x = LIB9P_ERRNO_L_ENOMSG; +#endif +#ifdef LIB9P_ERRNO_L_ENONET + x = LIB9P_ERRNO_L_ENONET; +#endif +#ifdef LIB9P_ERRNO_L_ENOPKG + x = LIB9P_ERRNO_L_ENOPKG; +#endif +#ifdef LIB9P_ERRNO_L_ENOPROTOOPT + x = LIB9P_ERRNO_L_ENOPROTOOPT; +#endif +#ifdef LIB9P_ERRNO_L_ENOSPC + x = LIB9P_ERRNO_L_ENOSPC; +#endif +#ifdef LIB9P_ERRNO_L_ENOSR + x = LIB9P_ERRNO_L_ENOSR; +#endif +#ifdef LIB9P_ERRNO_L_ENOSTR + x = LIB9P_ERRNO_L_ENOSTR; +#endif +#ifdef LIB9P_ERRNO_L_ENOSYS + x = LIB9P_ERRNO_L_ENOSYS; +#endif +#ifdef LIB9P_ERRNO_L_ENOTBLK + x = LIB9P_ERRNO_L_ENOTBLK; +#endif +#ifdef LIB9P_ERRNO_L_ENOTCONN x = LIB9P_ERRNO_L_ENOTCONN; - x = LIB9P_ERRNO_L_ESHUTDOWN; - x = LIB9P_ERRNO_L_ETOOMANYREFS; - x = LIB9P_ERRNO_L_ETIMEDOUT; - x = LIB9P_ERRNO_L_ECONNREFUSED; - x = LIB9P_ERRNO_L_EHOSTDOWN; - x = LIB9P_ERRNO_L_EHOSTUNREACH; - x = LIB9P_ERRNO_L_EALREADY; - x = LIB9P_ERRNO_L_EINPROGRESS; - x = LIB9P_ERRNO_L_ESTALE; - x = LIB9P_ERRNO_L_EUCLEAN; +#endif +#ifdef LIB9P_ERRNO_L_ENOTDIR + x = LIB9P_ERRNO_L_ENOTDIR; +#endif +#ifdef LIB9P_ERRNO_L_ENOTEMPTY + x = LIB9P_ERRNO_L_ENOTEMPTY; +#endif +#ifdef LIB9P_ERRNO_L_ENOTNAM x = LIB9P_ERRNO_L_ENOTNAM; - x = LIB9P_ERRNO_L_ENAVAIL; - x = LIB9P_ERRNO_L_EISNAM; - x = LIB9P_ERRNO_L_EREMOTEIO; - x = LIB9P_ERRNO_L_EDQUOT; - x = LIB9P_ERRNO_L_ENOMEDIUM; - x = LIB9P_ERRNO_L_EMEDIUMTYPE; - x = LIB9P_ERRNO_L_ECANCELED; - x = LIB9P_ERRNO_L_ENOKEY; - x = LIB9P_ERRNO_L_EKEYEXPIRED; - x = LIB9P_ERRNO_L_EKEYREVOKED; - x = LIB9P_ERRNO_L_EKEYREJECTED; - x = LIB9P_ERRNO_L_EOWNERDEAD; +#endif +#ifdef LIB9P_ERRNO_L_ENOTRECOVERABLE x = LIB9P_ERRNO_L_ENOTRECOVERABLE; +#endif +#ifdef LIB9P_ERRNO_L_ENOTSOCK + x = LIB9P_ERRNO_L_ENOTSOCK; +#endif +#ifdef LIB9P_ERRNO_L_ENOTTY + x = LIB9P_ERRNO_L_ENOTTY; +#endif +#ifdef LIB9P_ERRNO_L_ENOTUNIQ + x = LIB9P_ERRNO_L_ENOTUNIQ; +#endif +#ifdef LIB9P_ERRNO_L_ENXIO + x = LIB9P_ERRNO_L_ENXIO; +#endif +#ifdef LIB9P_ERRNO_L_EOPNOTSUPP + x = LIB9P_ERRNO_L_EOPNOTSUPP; +#endif +#ifdef LIB9P_ERRNO_L_EOVERFLOW + x = LIB9P_ERRNO_L_EOVERFLOW; +#endif +#ifdef LIB9P_ERRNO_L_EOWNERDEAD + x = LIB9P_ERRNO_L_EOWNERDEAD; +#endif +#ifdef LIB9P_ERRNO_L_EPERM + x = LIB9P_ERRNO_L_EPERM; +#endif +#ifdef LIB9P_ERRNO_L_EPFNOSUPPORT + x = LIB9P_ERRNO_L_EPFNOSUPPORT; +#endif +#ifdef LIB9P_ERRNO_L_EPIPE + x = LIB9P_ERRNO_L_EPIPE; +#endif +#ifdef LIB9P_ERRNO_L_EPROTO + x = LIB9P_ERRNO_L_EPROTO; +#endif +#ifdef LIB9P_ERRNO_L_EPROTONOSUPPORT + x = LIB9P_ERRNO_L_EPROTONOSUPPORT; +#endif +#ifdef LIB9P_ERRNO_L_EPROTOTYPE + x = LIB9P_ERRNO_L_EPROTOTYPE; +#endif +#ifdef LIB9P_ERRNO_L_ERANGE + x = LIB9P_ERRNO_L_ERANGE; +#endif +#ifdef LIB9P_ERRNO_L_EREMCHG + x = LIB9P_ERRNO_L_EREMCHG; +#endif +#ifdef LIB9P_ERRNO_L_EREMOTE + x = LIB9P_ERRNO_L_EREMOTE; +#endif +#ifdef LIB9P_ERRNO_L_EREMOTEIO + x = LIB9P_ERRNO_L_EREMOTEIO; +#endif +#ifdef LIB9P_ERRNO_L_ERESTART + x = LIB9P_ERRNO_L_ERESTART; +#endif +#ifdef LIB9P_ERRNO_L_ERFKILL x = LIB9P_ERRNO_L_ERFKILL; - x = LIB9P_ERRNO_L_EHWPOISON; - x = LIB9P_SUPER_MAGIC_V9FS_MAGIC; - x = _LIB9P_LO_UNUSED_31; - x = _LIB9P_LO_UNUSED_30; - x = _LIB9P_LO_UNUSED_29; - x = _LIB9P_LO_UNUSED_28; - x = _LIB9P_LO_UNUSED_27; - x = _LIB9P_LO_UNUSED_26; - x = _LIB9P_LO_UNUSED_25; - x = _LIB9P_LO_UNUSED_24; - x = _LIB9P_LO_UNUSED_23; - x = _LIB9P_LO_UNUSED_22; - x = _LIB9P_LO_UNUSED_21; - x = LIB9P_LO_SYNC; +#endif +#ifdef LIB9P_ERRNO_L_EROFS + x = LIB9P_ERRNO_L_EROFS; +#endif +#ifdef LIB9P_ERRNO_L_ESHUTDOWN + x = LIB9P_ERRNO_L_ESHUTDOWN; +#endif +#ifdef LIB9P_ERRNO_L_ESOCKTNOSUPPORT + x = LIB9P_ERRNO_L_ESOCKTNOSUPPORT; +#endif +#ifdef LIB9P_ERRNO_L_ESPIPE + x = LIB9P_ERRNO_L_ESPIPE; +#endif +#ifdef LIB9P_ERRNO_L_ESRCH + x = LIB9P_ERRNO_L_ESRCH; +#endif +#ifdef LIB9P_ERRNO_L_ESRMNT + x = LIB9P_ERRNO_L_ESRMNT; +#endif +#ifdef LIB9P_ERRNO_L_ESTALE + x = LIB9P_ERRNO_L_ESTALE; +#endif +#ifdef LIB9P_ERRNO_L_ESTRPIPE + x = LIB9P_ERRNO_L_ESTRPIPE; +#endif +#ifdef LIB9P_ERRNO_L_ETIME + x = LIB9P_ERRNO_L_ETIME; +#endif +#ifdef LIB9P_ERRNO_L_ETIMEDOUT + x = LIB9P_ERRNO_L_ETIMEDOUT; +#endif +#ifdef LIB9P_ERRNO_L_ETOOMANYREFS + x = LIB9P_ERRNO_L_ETOOMANYREFS; +#endif +#ifdef LIB9P_ERRNO_L_ETXTBSY + x = LIB9P_ERRNO_L_ETXTBSY; +#endif +#ifdef LIB9P_ERRNO_L_EUCLEAN + x = LIB9P_ERRNO_L_EUCLEAN; +#endif +#ifdef LIB9P_ERRNO_L_EUNATCH + x = LIB9P_ERRNO_L_EUNATCH; +#endif +#ifdef LIB9P_ERRNO_L_EUSERS + x = LIB9P_ERRNO_L_EUSERS; +#endif +#ifdef LIB9P_ERRNO_L_EXDEV + x = LIB9P_ERRNO_L_EXDEV; +#endif +#ifdef LIB9P_ERRNO_L_EXFULL + x = LIB9P_ERRNO_L_EXFULL; +#endif +#ifdef LIB9P_ERRNO_NOERROR + x = LIB9P_ERRNO_NOERROR; +#endif +#ifdef LIB9P_FID_NOFID + x = LIB9P_FID_NOFID; +#endif +#ifdef LIB9P_GETATTR_ALL + x = LIB9P_GETATTR_ALL; +#endif +#ifdef LIB9P_GETATTR_ATIME + x = LIB9P_GETATTR_ATIME; +#endif +#ifdef LIB9P_GETATTR_BASIC + x = LIB9P_GETATTR_BASIC; +#endif +#ifdef LIB9P_GETATTR_BLOCKS + x = LIB9P_GETATTR_BLOCKS; +#endif +#ifdef LIB9P_GETATTR_BTIME + x = LIB9P_GETATTR_BTIME; +#endif +#ifdef LIB9P_GETATTR_CTIME + x = LIB9P_GETATTR_CTIME; +#endif +#ifdef LIB9P_GETATTR_DATA_VERSION + x = LIB9P_GETATTR_DATA_VERSION; +#endif +#ifdef LIB9P_GETATTR_GEN + x = LIB9P_GETATTR_GEN; +#endif +#ifdef LIB9P_GETATTR_GID + x = LIB9P_GETATTR_GID; +#endif +#ifdef LIB9P_GETATTR_INO + x = LIB9P_GETATTR_INO; +#endif +#ifdef LIB9P_GETATTR_MODE + x = LIB9P_GETATTR_MODE; +#endif +#ifdef LIB9P_GETATTR_MTIME + x = LIB9P_GETATTR_MTIME; +#endif +#ifdef LIB9P_GETATTR_NLINK + x = LIB9P_GETATTR_NLINK; +#endif +#ifdef LIB9P_GETATTR_RDEV + x = LIB9P_GETATTR_RDEV; +#endif +#ifdef LIB9P_GETATTR_SIZE + x = LIB9P_GETATTR_SIZE; +#endif +#ifdef LIB9P_GETATTR_UID + x = LIB9P_GETATTR_UID; +#endif +#ifdef LIB9P_LOCK_FLAGS_BLOCK + x = LIB9P_LOCK_FLAGS_BLOCK; +#endif +#ifdef LIB9P_LOCK_FLAGS_RECLAIM + x = LIB9P_LOCK_FLAGS_RECLAIM; +#endif +#ifdef LIB9P_LOCK_STATUS_BLOCKED + x = LIB9P_LOCK_STATUS_BLOCKED; +#endif +#ifdef LIB9P_LOCK_STATUS_ERROR + x = LIB9P_LOCK_STATUS_ERROR; +#endif +#ifdef LIB9P_LOCK_STATUS_GRACE + x = LIB9P_LOCK_STATUS_GRACE; +#endif +#ifdef LIB9P_LOCK_STATUS_SUCCESS + x = LIB9P_LOCK_STATUS_SUCCESS; +#endif +#ifdef LIB9P_LOCK_TYPE_RDLCK + x = LIB9P_LOCK_TYPE_RDLCK; +#endif +#ifdef LIB9P_LOCK_TYPE_UNLCK + x = LIB9P_LOCK_TYPE_UNLCK; +#endif +#ifdef LIB9P_LOCK_TYPE_WRLCK + x = LIB9P_LOCK_TYPE_WRLCK; +#endif +#ifdef LIB9P_LO_APPEND + x = LIB9P_LO_APPEND; +#endif +#ifdef LIB9P_LO_BSD_FASYNC + x = LIB9P_LO_BSD_FASYNC; +#endif +#ifdef LIB9P_LO_CLOEXEC x = LIB9P_LO_CLOEXEC; - x = LIB9P_LO_NOATIME; - x = LIB9P_LO_NOFOLLOW; - x = LIB9P_LO_DIRECTORY; - x = LIB9P_LO_LARGEFILE; +#endif +#ifdef LIB9P_LO_CREATE + x = LIB9P_LO_CREATE; +#endif +#ifdef LIB9P_LO_DIRECT x = LIB9P_LO_DIRECT; - x = LIB9P_LO_BSD_FASYNC; +#endif +#ifdef LIB9P_LO_DIRECTORY + x = LIB9P_LO_DIRECTORY; +#endif +#ifdef LIB9P_LO_DSYNC x = LIB9P_LO_DSYNC; - x = LIB9P_LO_NONBLOCK; - x = LIB9P_LO_APPEND; - x = LIB9P_LO_TRUNC; - x = LIB9P_LO_NOCTTY; +#endif +#ifdef LIB9P_LO_EXCL x = LIB9P_LO_EXCL; - x = LIB9P_LO_CREATE; - x = _LIB9P_LO_UNUSED_5; - x = _LIB9P_LO_UNUSED_4; - x = _LIB9P_LO_UNUSED_3; - x = _LIB9P_LO_UNUSED_2; +#endif +#ifdef LIB9P_LO_FLAG_MASK x = LIB9P_LO_FLAG_MASK; +#endif +#ifdef LIB9P_LO_LARGEFILE + x = LIB9P_LO_LARGEFILE; +#endif +#ifdef LIB9P_LO_MODE_MASK + x = LIB9P_LO_MODE_MASK; +#endif +#ifdef LIB9P_LO_MODE_NOACCESS + x = LIB9P_LO_MODE_NOACCESS; +#endif +#ifdef LIB9P_LO_MODE_RDONLY x = LIB9P_LO_MODE_RDONLY; - x = LIB9P_LO_MODE_WRONLY; +#endif +#ifdef LIB9P_LO_MODE_RDWR x = LIB9P_LO_MODE_RDWR; - x = LIB9P_LO_MODE_NOACCESS; - x = LIB9P_LO_MODE_MASK; - x = LIB9P_DT_UNKNOWN; - x = LIB9P_DT_PIPE; - x = LIB9P_DT_CHAR_DEV; - x = LIB9P_DT_DIRECTORY; - x = LIB9P_DT_BLOCK_DEV; - x = LIB9P_DT_REGULAR; - x = LIB9P_DT_SYMLINK; - x = LIB9P_DT_SOCKET; - x = _LIB9P_DT_WHITEOUT; - x = _LIB9P_MODE_UNUSED_31; - x = _LIB9P_MODE_UNUSED_30; - x = _LIB9P_MODE_UNUSED_29; - x = _LIB9P_MODE_UNUSED_28; - x = _LIB9P_MODE_UNUSED_27; - x = _LIB9P_MODE_UNUSED_26; - x = _LIB9P_MODE_UNUSED_25; - x = _LIB9P_MODE_UNUSED_24; - x = _LIB9P_MODE_UNUSED_23; - x = _LIB9P_MODE_UNUSED_22; - x = _LIB9P_MODE_UNUSED_21; - x = _LIB9P_MODE_UNUSED_20; - x = _LIB9P_MODE_UNUSED_19; - x = _LIB9P_MODE_UNUSED_18; - x = _LIB9P_MODE_UNUSED_17; - x = _LIB9P_MODE_UNUSED_16; - x = LIB9P_MODE_PERM_SETGROUP; - x = LIB9P_MODE_PERM_SETUSER; - x = LIB9P_MODE_PERM_STICKY; - x = LIB9P_MODE_PERM_OWNER_R; - x = LIB9P_MODE_PERM_OWNER_W; - x = LIB9P_MODE_PERM_OWNER_X; +#endif +#ifdef LIB9P_LO_MODE_WRONLY + x = LIB9P_LO_MODE_WRONLY; +#endif +#ifdef LIB9P_LO_NOATIME + x = LIB9P_LO_NOATIME; +#endif +#ifdef LIB9P_LO_NOCTTY + x = LIB9P_LO_NOCTTY; +#endif +#ifdef LIB9P_LO_NOFOLLOW + x = LIB9P_LO_NOFOLLOW; +#endif +#ifdef LIB9P_LO_NONBLOCK + x = LIB9P_LO_NONBLOCK; +#endif +#ifdef LIB9P_LO_SYNC + x = LIB9P_LO_SYNC; +#endif +#ifdef LIB9P_LO_TRUNC + x = LIB9P_LO_TRUNC; +#endif +#ifdef LIB9P_MODE_FMT_BLOCK_DEV + x = LIB9P_MODE_FMT_BLOCK_DEV; +#endif +#ifdef LIB9P_MODE_FMT_CHAR_DEV + x = LIB9P_MODE_FMT_CHAR_DEV; +#endif +#ifdef LIB9P_MODE_FMT_DIRECTORY + x = LIB9P_MODE_FMT_DIRECTORY; +#endif +#ifdef LIB9P_MODE_FMT_MASK + x = LIB9P_MODE_FMT_MASK; +#endif +#ifdef LIB9P_MODE_FMT_PIPE + x = LIB9P_MODE_FMT_PIPE; +#endif +#ifdef LIB9P_MODE_FMT_REGULAR + x = LIB9P_MODE_FMT_REGULAR; +#endif +#ifdef LIB9P_MODE_FMT_SOCKET + x = LIB9P_MODE_FMT_SOCKET; +#endif +#ifdef LIB9P_MODE_FMT_SYMLINK + x = LIB9P_MODE_FMT_SYMLINK; +#endif +#ifdef LIB9P_MODE_PERM_GROUP_R x = LIB9P_MODE_PERM_GROUP_R; +#endif +#ifdef LIB9P_MODE_PERM_GROUP_W x = LIB9P_MODE_PERM_GROUP_W; +#endif +#ifdef LIB9P_MODE_PERM_GROUP_X x = LIB9P_MODE_PERM_GROUP_X; +#endif +#ifdef LIB9P_MODE_PERM_MASK + x = LIB9P_MODE_PERM_MASK; +#endif +#ifdef LIB9P_MODE_PERM_OTHER_R x = LIB9P_MODE_PERM_OTHER_R; +#endif +#ifdef LIB9P_MODE_PERM_OTHER_W x = LIB9P_MODE_PERM_OTHER_W; +#endif +#ifdef LIB9P_MODE_PERM_OTHER_X x = LIB9P_MODE_PERM_OTHER_X; - x = LIB9P_MODE_PERM_MASK; - x = LIB9P_MODE_FMT_PIPE; - x = LIB9P_MODE_FMT_CHAR_DEV; - x = LIB9P_MODE_FMT_DIRECTORY; - x = LIB9P_MODE_FMT_BLOCK_DEV; - x = LIB9P_MODE_FMT_REGULAR; - x = LIB9P_MODE_FMT_SYMLINK; - x = LIB9P_MODE_FMT_SOCKET; - x = LIB9P_MODE_FMT_MASK; - x = LIB9P_B4_FALSE; - x = LIB9P_B4_TRUE; - x = _LIB9P_GETATTR_UNUSED_63; - x = _LIB9P_GETATTR_UNUSED_62; - x = _LIB9P_GETATTR_UNUSED_61; - x = _LIB9P_GETATTR_UNUSED_60; - x = _LIB9P_GETATTR_UNUSED_59; - x = _LIB9P_GETATTR_UNUSED_58; - x = _LIB9P_GETATTR_UNUSED_57; - x = _LIB9P_GETATTR_UNUSED_56; - x = _LIB9P_GETATTR_UNUSED_55; - x = _LIB9P_GETATTR_UNUSED_54; - x = _LIB9P_GETATTR_UNUSED_53; - x = _LIB9P_GETATTR_UNUSED_52; - x = _LIB9P_GETATTR_UNUSED_51; - x = _LIB9P_GETATTR_UNUSED_50; - x = _LIB9P_GETATTR_UNUSED_49; - x = _LIB9P_GETATTR_UNUSED_48; - x = _LIB9P_GETATTR_UNUSED_47; - x = _LIB9P_GETATTR_UNUSED_46; - x = _LIB9P_GETATTR_UNUSED_45; - x = _LIB9P_GETATTR_UNUSED_44; - x = _LIB9P_GETATTR_UNUSED_43; - x = _LIB9P_GETATTR_UNUSED_42; - x = _LIB9P_GETATTR_UNUSED_41; - x = _LIB9P_GETATTR_UNUSED_40; - x = _LIB9P_GETATTR_UNUSED_39; - x = _LIB9P_GETATTR_UNUSED_38; - x = _LIB9P_GETATTR_UNUSED_37; - x = _LIB9P_GETATTR_UNUSED_36; - x = _LIB9P_GETATTR_UNUSED_35; - x = _LIB9P_GETATTR_UNUSED_34; - x = _LIB9P_GETATTR_UNUSED_33; - x = _LIB9P_GETATTR_UNUSED_32; - x = _LIB9P_GETATTR_UNUSED_31; - x = _LIB9P_GETATTR_UNUSED_30; - x = _LIB9P_GETATTR_UNUSED_29; - x = _LIB9P_GETATTR_UNUSED_28; - x = _LIB9P_GETATTR_UNUSED_27; - x = _LIB9P_GETATTR_UNUSED_26; - x = _LIB9P_GETATTR_UNUSED_25; - x = _LIB9P_GETATTR_UNUSED_24; - x = _LIB9P_GETATTR_UNUSED_23; - x = _LIB9P_GETATTR_UNUSED_22; - x = _LIB9P_GETATTR_UNUSED_21; - x = _LIB9P_GETATTR_UNUSED_20; - x = _LIB9P_GETATTR_UNUSED_19; - x = _LIB9P_GETATTR_UNUSED_18; - x = _LIB9P_GETATTR_UNUSED_17; - x = _LIB9P_GETATTR_UNUSED_16; - x = _LIB9P_GETATTR_UNUSED_15; - x = _LIB9P_GETATTR_UNUSED_14; - x = LIB9P_GETATTR_DATA_VERSION; - x = LIB9P_GETATTR_GEN; - x = LIB9P_GETATTR_BTIME; - x = LIB9P_GETATTR_BLOCKS; - x = LIB9P_GETATTR_SIZE; - x = LIB9P_GETATTR_INO; - x = LIB9P_GETATTR_CTIME; - x = LIB9P_GETATTR_MTIME; - x = LIB9P_GETATTR_ATIME; - x = LIB9P_GETATTR_RDEV; - x = LIB9P_GETATTR_GID; - x = LIB9P_GETATTR_UID; - x = LIB9P_GETATTR_NLINK; - x = LIB9P_GETATTR_MODE; - x = LIB9P_GETATTR_BASIC; - x = LIB9P_GETATTR_ALL; - x = _LIB9P_SETATTR_UNUSED_31; - x = _LIB9P_SETATTR_UNUSED_30; - x = _LIB9P_SETATTR_UNUSED_29; - x = _LIB9P_SETATTR_UNUSED_28; - x = _LIB9P_SETATTR_UNUSED_27; - x = _LIB9P_SETATTR_UNUSED_26; - x = _LIB9P_SETATTR_UNUSED_25; - x = _LIB9P_SETATTR_UNUSED_24; - x = _LIB9P_SETATTR_UNUSED_23; - x = _LIB9P_SETATTR_UNUSED_22; - x = _LIB9P_SETATTR_UNUSED_21; - x = _LIB9P_SETATTR_UNUSED_20; - x = _LIB9P_SETATTR_UNUSED_19; - x = _LIB9P_SETATTR_UNUSED_18; - x = _LIB9P_SETATTR_UNUSED_17; - x = _LIB9P_SETATTR_UNUSED_16; - x = _LIB9P_SETATTR_UNUSED_15; - x = _LIB9P_SETATTR_UNUSED_14; - x = _LIB9P_SETATTR_UNUSED_13; - x = _LIB9P_SETATTR_UNUSED_12; - x = _LIB9P_SETATTR_UNUSED_11; - x = _LIB9P_SETATTR_UNUSED_10; - x = _LIB9P_SETATTR_UNUSED_9; - x = LIB9P_SETATTR_MTIME_SET; +#endif +#ifdef LIB9P_MODE_PERM_OWNER_R + x = LIB9P_MODE_PERM_OWNER_R; +#endif +#ifdef LIB9P_MODE_PERM_OWNER_W + x = LIB9P_MODE_PERM_OWNER_W; +#endif +#ifdef LIB9P_MODE_PERM_OWNER_X + x = LIB9P_MODE_PERM_OWNER_X; +#endif +#ifdef LIB9P_MODE_PERM_SETGROUP + x = LIB9P_MODE_PERM_SETGROUP; +#endif +#ifdef LIB9P_MODE_PERM_SETUSER + x = LIB9P_MODE_PERM_SETUSER; +#endif +#ifdef LIB9P_MODE_PERM_STICKY + x = LIB9P_MODE_PERM_STICKY; +#endif +#ifdef LIB9P_NUID_NONUID + x = LIB9P_NUID_NONUID; +#endif +#ifdef LIB9P_O_FLAG_MASK + x = LIB9P_O_FLAG_MASK; +#endif +#ifdef LIB9P_O_MODE_EXEC + x = LIB9P_O_MODE_EXEC; +#endif +#ifdef LIB9P_O_MODE_MASK + x = LIB9P_O_MODE_MASK; +#endif +#ifdef LIB9P_O_MODE_RDWR + x = LIB9P_O_MODE_RDWR; +#endif +#ifdef LIB9P_O_MODE_READ + x = LIB9P_O_MODE_READ; +#endif +#ifdef LIB9P_O_MODE_WRITE + x = LIB9P_O_MODE_WRITE; +#endif +#ifdef LIB9P_O_RCLOSE + x = LIB9P_O_RCLOSE; +#endif +#ifdef LIB9P_O_TRUNC + x = LIB9P_O_TRUNC; +#endif +#ifdef LIB9P_QT_APPEND + x = LIB9P_QT_APPEND; +#endif +#ifdef LIB9P_QT_AUTH + x = LIB9P_QT_AUTH; +#endif +#ifdef LIB9P_QT_DIR + x = LIB9P_QT_DIR; +#endif +#ifdef LIB9P_QT_EXCL + x = LIB9P_QT_EXCL; +#endif +#ifdef LIB9P_QT_FILE + x = LIB9P_QT_FILE; +#endif +#ifdef LIB9P_QT_SYMLINK + x = LIB9P_QT_SYMLINK; +#endif +#ifdef LIB9P_QT_TMP + x = LIB9P_QT_TMP; +#endif +#ifdef LIB9P_RMSG_MAX_COPY + x = LIB9P_RMSG_MAX_COPY; +#endif +#ifdef LIB9P_RMSG_MAX_IOV + x = LIB9P_RMSG_MAX_IOV; +#endif +#ifdef LIB9P_SETATTR_ATIME + x = LIB9P_SETATTR_ATIME; +#endif +#ifdef LIB9P_SETATTR_ATIME_SET x = LIB9P_SETATTR_ATIME_SET; +#endif +#ifdef LIB9P_SETATTR_CTIME x = LIB9P_SETATTR_CTIME; +#endif +#ifdef LIB9P_SETATTR_GID + x = LIB9P_SETATTR_GID; +#endif +#ifdef LIB9P_SETATTR_MODE + x = LIB9P_SETATTR_MODE; +#endif +#ifdef LIB9P_SETATTR_MTIME x = LIB9P_SETATTR_MTIME; - x = LIB9P_SETATTR_ATIME; +#endif +#ifdef LIB9P_SETATTR_MTIME_SET + x = LIB9P_SETATTR_MTIME_SET; +#endif +#ifdef LIB9P_SETATTR_SIZE x = LIB9P_SETATTR_SIZE; - x = LIB9P_SETATTR_GID; +#endif +#ifdef LIB9P_SETATTR_UID x = LIB9P_SETATTR_UID; - x = LIB9P_SETATTR_MODE; - x = LIB9P_LOCK_TYPE_RDLCK; - x = LIB9P_LOCK_TYPE_WRLCK; - x = LIB9P_LOCK_TYPE_UNLCK; - x = _LIB9P_LOCK_FLAGS_UNUSED_31; - x = _LIB9P_LOCK_FLAGS_UNUSED_30; - x = _LIB9P_LOCK_FLAGS_UNUSED_29; - x = _LIB9P_LOCK_FLAGS_UNUSED_28; - x = _LIB9P_LOCK_FLAGS_UNUSED_27; - x = _LIB9P_LOCK_FLAGS_UNUSED_26; - x = _LIB9P_LOCK_FLAGS_UNUSED_25; - x = _LIB9P_LOCK_FLAGS_UNUSED_24; - x = _LIB9P_LOCK_FLAGS_UNUSED_23; - x = _LIB9P_LOCK_FLAGS_UNUSED_22; - x = _LIB9P_LOCK_FLAGS_UNUSED_21; - x = _LIB9P_LOCK_FLAGS_UNUSED_20; - x = _LIB9P_LOCK_FLAGS_UNUSED_19; - x = _LIB9P_LOCK_FLAGS_UNUSED_18; - x = _LIB9P_LOCK_FLAGS_UNUSED_17; - x = _LIB9P_LOCK_FLAGS_UNUSED_16; - x = _LIB9P_LOCK_FLAGS_UNUSED_15; - x = _LIB9P_LOCK_FLAGS_UNUSED_14; - x = _LIB9P_LOCK_FLAGS_UNUSED_13; - x = _LIB9P_LOCK_FLAGS_UNUSED_12; - x = _LIB9P_LOCK_FLAGS_UNUSED_11; +#endif +#ifdef LIB9P_SUPER_MAGIC_V9FS_MAGIC + x = LIB9P_SUPER_MAGIC_V9FS_MAGIC; +#endif +#ifdef LIB9P_TAG_NOTAG + x = LIB9P_TAG_NOTAG; +#endif +#ifdef LIB9P_TMSG_MAX_COPY + x = LIB9P_TMSG_MAX_COPY; +#endif +#ifdef LIB9P_TMSG_MAX_IOV + x = LIB9P_TMSG_MAX_IOV; +#endif +#ifdef _LIB9P_DM_PLAN9_MOUNT + x = _LIB9P_DM_PLAN9_MOUNT; +#endif +#ifdef _LIB9P_DM_UNUSED_10 + x = _LIB9P_DM_UNUSED_10; +#endif +#ifdef _LIB9P_DM_UNUSED_11 + x = _LIB9P_DM_UNUSED_11; +#endif +#ifdef _LIB9P_DM_UNUSED_12 + x = _LIB9P_DM_UNUSED_12; +#endif +#ifdef _LIB9P_DM_UNUSED_13 + x = _LIB9P_DM_UNUSED_13; +#endif +#ifdef _LIB9P_DM_UNUSED_14 + x = _LIB9P_DM_UNUSED_14; +#endif +#ifdef _LIB9P_DM_UNUSED_15 + x = _LIB9P_DM_UNUSED_15; +#endif +#ifdef _LIB9P_DM_UNUSED_16 + x = _LIB9P_DM_UNUSED_16; +#endif +#ifdef _LIB9P_DM_UNUSED_17 + x = _LIB9P_DM_UNUSED_17; +#endif +#ifdef _LIB9P_DM_UNUSED_22 + x = _LIB9P_DM_UNUSED_22; +#endif +#ifdef _LIB9P_DM_UNUSED_24 + x = _LIB9P_DM_UNUSED_24; +#endif +#ifdef _LIB9P_DM_UNUSED_25 + x = _LIB9P_DM_UNUSED_25; +#endif +#ifdef _LIB9P_DM_UNUSED_9 + x = _LIB9P_DM_UNUSED_9; +#endif +#ifdef _LIB9P_DT_WHITEOUT + x = _LIB9P_DT_WHITEOUT; +#endif +#ifdef _LIB9P_ENABLE_stat + x = _LIB9P_ENABLE_stat; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_14 + x = _LIB9P_GETATTR_UNUSED_14; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_15 + x = _LIB9P_GETATTR_UNUSED_15; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_16 + x = _LIB9P_GETATTR_UNUSED_16; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_17 + x = _LIB9P_GETATTR_UNUSED_17; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_18 + x = _LIB9P_GETATTR_UNUSED_18; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_19 + x = _LIB9P_GETATTR_UNUSED_19; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_20 + x = _LIB9P_GETATTR_UNUSED_20; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_21 + x = _LIB9P_GETATTR_UNUSED_21; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_22 + x = _LIB9P_GETATTR_UNUSED_22; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_23 + x = _LIB9P_GETATTR_UNUSED_23; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_24 + x = _LIB9P_GETATTR_UNUSED_24; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_25 + x = _LIB9P_GETATTR_UNUSED_25; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_26 + x = _LIB9P_GETATTR_UNUSED_26; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_27 + x = _LIB9P_GETATTR_UNUSED_27; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_28 + x = _LIB9P_GETATTR_UNUSED_28; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_29 + x = _LIB9P_GETATTR_UNUSED_29; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_30 + x = _LIB9P_GETATTR_UNUSED_30; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_31 + x = _LIB9P_GETATTR_UNUSED_31; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_32 + x = _LIB9P_GETATTR_UNUSED_32; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_33 + x = _LIB9P_GETATTR_UNUSED_33; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_34 + x = _LIB9P_GETATTR_UNUSED_34; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_35 + x = _LIB9P_GETATTR_UNUSED_35; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_36 + x = _LIB9P_GETATTR_UNUSED_36; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_37 + x = _LIB9P_GETATTR_UNUSED_37; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_38 + x = _LIB9P_GETATTR_UNUSED_38; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_39 + x = _LIB9P_GETATTR_UNUSED_39; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_40 + x = _LIB9P_GETATTR_UNUSED_40; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_41 + x = _LIB9P_GETATTR_UNUSED_41; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_42 + x = _LIB9P_GETATTR_UNUSED_42; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_43 + x = _LIB9P_GETATTR_UNUSED_43; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_44 + x = _LIB9P_GETATTR_UNUSED_44; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_45 + x = _LIB9P_GETATTR_UNUSED_45; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_46 + x = _LIB9P_GETATTR_UNUSED_46; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_47 + x = _LIB9P_GETATTR_UNUSED_47; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_48 + x = _LIB9P_GETATTR_UNUSED_48; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_49 + x = _LIB9P_GETATTR_UNUSED_49; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_50 + x = _LIB9P_GETATTR_UNUSED_50; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_51 + x = _LIB9P_GETATTR_UNUSED_51; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_52 + x = _LIB9P_GETATTR_UNUSED_52; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_53 + x = _LIB9P_GETATTR_UNUSED_53; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_54 + x = _LIB9P_GETATTR_UNUSED_54; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_55 + x = _LIB9P_GETATTR_UNUSED_55; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_56 + x = _LIB9P_GETATTR_UNUSED_56; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_57 + x = _LIB9P_GETATTR_UNUSED_57; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_58 + x = _LIB9P_GETATTR_UNUSED_58; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_59 + x = _LIB9P_GETATTR_UNUSED_59; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_60 + x = _LIB9P_GETATTR_UNUSED_60; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_61 + x = _LIB9P_GETATTR_UNUSED_61; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_62 + x = _LIB9P_GETATTR_UNUSED_62; +#endif +#ifdef _LIB9P_GETATTR_UNUSED_63 + x = _LIB9P_GETATTR_UNUSED_63; +#endif +#ifdef _LIB9P_LOCK_FLAGS_UNUSED_10 x = _LIB9P_LOCK_FLAGS_UNUSED_10; - x = _LIB9P_LOCK_FLAGS_UNUSED_9; - x = _LIB9P_LOCK_FLAGS_UNUSED_8; - x = _LIB9P_LOCK_FLAGS_UNUSED_7; - x = _LIB9P_LOCK_FLAGS_UNUSED_6; - x = _LIB9P_LOCK_FLAGS_UNUSED_5; - x = _LIB9P_LOCK_FLAGS_UNUSED_4; - x = _LIB9P_LOCK_FLAGS_UNUSED_3; +#endif +#ifdef _LIB9P_LOCK_FLAGS_UNUSED_11 + x = _LIB9P_LOCK_FLAGS_UNUSED_11; +#endif +#ifdef _LIB9P_LOCK_FLAGS_UNUSED_12 + x = _LIB9P_LOCK_FLAGS_UNUSED_12; +#endif +#ifdef _LIB9P_LOCK_FLAGS_UNUSED_13 + x = _LIB9P_LOCK_FLAGS_UNUSED_13; +#endif +#ifdef _LIB9P_LOCK_FLAGS_UNUSED_14 + x = _LIB9P_LOCK_FLAGS_UNUSED_14; +#endif +#ifdef _LIB9P_LOCK_FLAGS_UNUSED_15 + x = _LIB9P_LOCK_FLAGS_UNUSED_15; +#endif +#ifdef _LIB9P_LOCK_FLAGS_UNUSED_16 + x = _LIB9P_LOCK_FLAGS_UNUSED_16; +#endif +#ifdef _LIB9P_LOCK_FLAGS_UNUSED_17 + x = _LIB9P_LOCK_FLAGS_UNUSED_17; +#endif +#ifdef _LIB9P_LOCK_FLAGS_UNUSED_18 + x = _LIB9P_LOCK_FLAGS_UNUSED_18; +#endif +#ifdef _LIB9P_LOCK_FLAGS_UNUSED_19 + x = _LIB9P_LOCK_FLAGS_UNUSED_19; +#endif +#ifdef _LIB9P_LOCK_FLAGS_UNUSED_2 x = _LIB9P_LOCK_FLAGS_UNUSED_2; - x = LIB9P_LOCK_FLAGS_RECLAIM; - x = LIB9P_LOCK_FLAGS_BLOCK; - x = LIB9P_LOCK_STATUS_SUCCESS; - x = LIB9P_LOCK_STATUS_BLOCKED; - x = LIB9P_LOCK_STATUS_ERROR; - x = LIB9P_LOCK_STATUS_GRACE; - x = LIB9P_TMSG_MAX_IOV; - x = LIB9P_TMSG_MAX_IOV; - x = LIB9P_TMSG_MAX_COPY; - x = LIB9P_TMSG_MAX_COPY; - x = LIB9P_TMSG_MAX_COPY; - x = LIB9P_TMSG_MAX_COPY; - x = LIB9P_TMSG_MAX_COPY; - x = LIB9P_TMSG_MAX_COPY; - x = LIB9P_RMSG_MAX_IOV; - x = LIB9P_RMSG_MAX_IOV; - x = LIB9P_RMSG_MAX_IOV; - x = LIB9P_RMSG_MAX_COPY; +#endif +#ifdef _LIB9P_LOCK_FLAGS_UNUSED_20 + x = _LIB9P_LOCK_FLAGS_UNUSED_20; +#endif +#ifdef _LIB9P_LOCK_FLAGS_UNUSED_21 + x = _LIB9P_LOCK_FLAGS_UNUSED_21; +#endif +#ifdef _LIB9P_LOCK_FLAGS_UNUSED_22 + x = _LIB9P_LOCK_FLAGS_UNUSED_22; +#endif +#ifdef _LIB9P_LOCK_FLAGS_UNUSED_23 + x = _LIB9P_LOCK_FLAGS_UNUSED_23; +#endif +#ifdef _LIB9P_LOCK_FLAGS_UNUSED_24 + x = _LIB9P_LOCK_FLAGS_UNUSED_24; +#endif +#ifdef _LIB9P_LOCK_FLAGS_UNUSED_25 + x = _LIB9P_LOCK_FLAGS_UNUSED_25; +#endif +#ifdef _LIB9P_LOCK_FLAGS_UNUSED_26 + x = _LIB9P_LOCK_FLAGS_UNUSED_26; +#endif +#ifdef _LIB9P_LOCK_FLAGS_UNUSED_27 + x = _LIB9P_LOCK_FLAGS_UNUSED_27; +#endif +#ifdef _LIB9P_LOCK_FLAGS_UNUSED_28 + x = _LIB9P_LOCK_FLAGS_UNUSED_28; +#endif +#ifdef _LIB9P_LOCK_FLAGS_UNUSED_29 + x = _LIB9P_LOCK_FLAGS_UNUSED_29; +#endif +#ifdef _LIB9P_LOCK_FLAGS_UNUSED_3 + x = _LIB9P_LOCK_FLAGS_UNUSED_3; +#endif +#ifdef _LIB9P_LOCK_FLAGS_UNUSED_30 + x = _LIB9P_LOCK_FLAGS_UNUSED_30; +#endif +#ifdef _LIB9P_LOCK_FLAGS_UNUSED_31 + x = _LIB9P_LOCK_FLAGS_UNUSED_31; +#endif +#ifdef _LIB9P_LOCK_FLAGS_UNUSED_4 + x = _LIB9P_LOCK_FLAGS_UNUSED_4; +#endif +#ifdef _LIB9P_LOCK_FLAGS_UNUSED_5 + x = _LIB9P_LOCK_FLAGS_UNUSED_5; +#endif +#ifdef _LIB9P_LOCK_FLAGS_UNUSED_6 + x = _LIB9P_LOCK_FLAGS_UNUSED_6; +#endif +#ifdef _LIB9P_LOCK_FLAGS_UNUSED_7 + x = _LIB9P_LOCK_FLAGS_UNUSED_7; +#endif +#ifdef _LIB9P_LOCK_FLAGS_UNUSED_8 + x = _LIB9P_LOCK_FLAGS_UNUSED_8; +#endif +#ifdef _LIB9P_LOCK_FLAGS_UNUSED_9 + x = _LIB9P_LOCK_FLAGS_UNUSED_9; +#endif +#ifdef _LIB9P_LO_UNUSED_2 + x = _LIB9P_LO_UNUSED_2; +#endif +#ifdef _LIB9P_LO_UNUSED_21 + x = _LIB9P_LO_UNUSED_21; +#endif +#ifdef _LIB9P_LO_UNUSED_22 + x = _LIB9P_LO_UNUSED_22; +#endif +#ifdef _LIB9P_LO_UNUSED_23 + x = _LIB9P_LO_UNUSED_23; +#endif +#ifdef _LIB9P_LO_UNUSED_24 + x = _LIB9P_LO_UNUSED_24; +#endif +#ifdef _LIB9P_LO_UNUSED_25 + x = _LIB9P_LO_UNUSED_25; +#endif +#ifdef _LIB9P_LO_UNUSED_26 + x = _LIB9P_LO_UNUSED_26; +#endif +#ifdef _LIB9P_LO_UNUSED_27 + x = _LIB9P_LO_UNUSED_27; +#endif +#ifdef _LIB9P_LO_UNUSED_28 + x = _LIB9P_LO_UNUSED_28; +#endif +#ifdef _LIB9P_LO_UNUSED_29 + x = _LIB9P_LO_UNUSED_29; +#endif +#ifdef _LIB9P_LO_UNUSED_3 + x = _LIB9P_LO_UNUSED_3; +#endif +#ifdef _LIB9P_LO_UNUSED_30 + x = _LIB9P_LO_UNUSED_30; +#endif +#ifdef _LIB9P_LO_UNUSED_31 + x = _LIB9P_LO_UNUSED_31; +#endif +#ifdef _LIB9P_LO_UNUSED_4 + x = _LIB9P_LO_UNUSED_4; +#endif +#ifdef _LIB9P_LO_UNUSED_5 + x = _LIB9P_LO_UNUSED_5; +#endif +#ifdef _LIB9P_MODE_UNUSED_16 + x = _LIB9P_MODE_UNUSED_16; +#endif +#ifdef _LIB9P_MODE_UNUSED_17 + x = _LIB9P_MODE_UNUSED_17; +#endif +#ifdef _LIB9P_MODE_UNUSED_18 + x = _LIB9P_MODE_UNUSED_18; +#endif +#ifdef _LIB9P_MODE_UNUSED_19 + x = _LIB9P_MODE_UNUSED_19; +#endif +#ifdef _LIB9P_MODE_UNUSED_20 + x = _LIB9P_MODE_UNUSED_20; +#endif +#ifdef _LIB9P_MODE_UNUSED_21 + x = _LIB9P_MODE_UNUSED_21; +#endif +#ifdef _LIB9P_MODE_UNUSED_22 + x = _LIB9P_MODE_UNUSED_22; +#endif +#ifdef _LIB9P_MODE_UNUSED_23 + x = _LIB9P_MODE_UNUSED_23; +#endif +#ifdef _LIB9P_MODE_UNUSED_24 + x = _LIB9P_MODE_UNUSED_24; +#endif +#ifdef _LIB9P_MODE_UNUSED_25 + x = _LIB9P_MODE_UNUSED_25; +#endif +#ifdef _LIB9P_MODE_UNUSED_26 + x = _LIB9P_MODE_UNUSED_26; +#endif +#ifdef _LIB9P_MODE_UNUSED_27 + x = _LIB9P_MODE_UNUSED_27; +#endif +#ifdef _LIB9P_MODE_UNUSED_28 + x = _LIB9P_MODE_UNUSED_28; +#endif +#ifdef _LIB9P_MODE_UNUSED_29 + x = _LIB9P_MODE_UNUSED_29; +#endif +#ifdef _LIB9P_MODE_UNUSED_30 + x = _LIB9P_MODE_UNUSED_30; +#endif +#ifdef _LIB9P_MODE_UNUSED_31 + x = _LIB9P_MODE_UNUSED_31; +#endif +#ifdef _LIB9P_O_RESERVED_CEXEC + x = _LIB9P_O_RESERVED_CEXEC; +#endif +#ifdef _LIB9P_O_UNUSED_2 + x = _LIB9P_O_UNUSED_2; +#endif +#ifdef _LIB9P_O_UNUSED_3 + x = _LIB9P_O_UNUSED_3; +#endif +#ifdef _LIB9P_O_UNUSED_7 + x = _LIB9P_O_UNUSED_7; +#endif +#ifdef _LIB9P_QT_PLAN9_MOUNT + x = _LIB9P_QT_PLAN9_MOUNT; +#endif +#ifdef _LIB9P_QT_UNUSED_0 + x = _LIB9P_QT_UNUSED_0; +#endif +#ifdef _LIB9P_SETATTR_UNUSED_10 + x = _LIB9P_SETATTR_UNUSED_10; +#endif +#ifdef _LIB9P_SETATTR_UNUSED_11 + x = _LIB9P_SETATTR_UNUSED_11; +#endif +#ifdef _LIB9P_SETATTR_UNUSED_12 + x = _LIB9P_SETATTR_UNUSED_12; +#endif +#ifdef _LIB9P_SETATTR_UNUSED_13 + x = _LIB9P_SETATTR_UNUSED_13; +#endif +#ifdef _LIB9P_SETATTR_UNUSED_14 + x = _LIB9P_SETATTR_UNUSED_14; +#endif +#ifdef _LIB9P_SETATTR_UNUSED_15 + x = _LIB9P_SETATTR_UNUSED_15; +#endif +#ifdef _LIB9P_SETATTR_UNUSED_16 + x = _LIB9P_SETATTR_UNUSED_16; +#endif +#ifdef _LIB9P_SETATTR_UNUSED_17 + x = _LIB9P_SETATTR_UNUSED_17; +#endif +#ifdef _LIB9P_SETATTR_UNUSED_18 + x = _LIB9P_SETATTR_UNUSED_18; +#endif +#ifdef _LIB9P_SETATTR_UNUSED_19 + x = _LIB9P_SETATTR_UNUSED_19; +#endif +#ifdef _LIB9P_SETATTR_UNUSED_20 + x = _LIB9P_SETATTR_UNUSED_20; +#endif +#ifdef _LIB9P_SETATTR_UNUSED_21 + x = _LIB9P_SETATTR_UNUSED_21; +#endif +#ifdef _LIB9P_SETATTR_UNUSED_22 + x = _LIB9P_SETATTR_UNUSED_22; +#endif +#ifdef _LIB9P_SETATTR_UNUSED_23 + x = _LIB9P_SETATTR_UNUSED_23; +#endif +#ifdef _LIB9P_SETATTR_UNUSED_24 + x = _LIB9P_SETATTR_UNUSED_24; +#endif +#ifdef _LIB9P_SETATTR_UNUSED_25 + x = _LIB9P_SETATTR_UNUSED_25; +#endif +#ifdef _LIB9P_SETATTR_UNUSED_26 + x = _LIB9P_SETATTR_UNUSED_26; +#endif +#ifdef _LIB9P_SETATTR_UNUSED_27 + x = _LIB9P_SETATTR_UNUSED_27; +#endif +#ifdef _LIB9P_SETATTR_UNUSED_28 + x = _LIB9P_SETATTR_UNUSED_28; +#endif +#ifdef _LIB9P_SETATTR_UNUSED_29 + x = _LIB9P_SETATTR_UNUSED_29; +#endif +#ifdef _LIB9P_SETATTR_UNUSED_30 + x = _LIB9P_SETATTR_UNUSED_30; +#endif +#ifdef _LIB9P_SETATTR_UNUSED_31 + x = _LIB9P_SETATTR_UNUSED_31; +#endif +#ifdef _LIB9P_SETATTR_UNUSED_9 + x = _LIB9P_SETATTR_UNUSED_9; +#endif return 0; } diff --git a/lib9p/tests/test_compile.c.gen b/lib9p/tests/test_compile.c.gen index 1289943..eb89c54 100755 --- a/lib9p/tests/test_compile.c.gen +++ b/lib9p/tests/test_compile.c.gen @@ -13,7 +13,7 @@ outfile=$2 echo "#include <lib9p/core.h>" echo 'int main(void) {' echo ' [[gnu::unused]] uint64_t x;' - sed -nE 's/^\s*#\s*define\s*(\S[^ (]*)\s.*/ x = \1;/p' <"$generated_h" + <"$generated_h" sed -nE 's/^\s*#\s*define\s*(\S[^ (]*)\s.*/\1/p' | LC_COLLATE=C sort -u | sed 's/.*/#ifdef &\n x = &;\n#endif/' echo ' return 0;' echo '}' } >"$outfile" diff --git a/lib9p/tests/test_compile_config/config.h b/lib9p/tests/test_compile_config/config.h index f899dfa..02cb8e5 100644 --- a/lib9p/tests/test_compile_config/config.h +++ b/lib9p/tests/test_compile_config/config.h @@ -7,13 +7,25 @@ #ifndef _CONFIG_H_ #define _CONFIG_H_ +/* 9P *************************************************************************/ + #define CONFIG_9P_MAX_ERR_SIZE 128 #define CONFIG_9P_MAX_9P2000_e_WELEM 16 -#define CONFIG_9P_ENABLE_9P2000 1 /* bool */ -#define CONFIG_9P_ENABLE_9P2000_u 1 /* bool */ -#define CONFIG_9P_ENABLE_9P2000_e 1 /* bool */ -#define CONFIG_9P_ENABLE_9P2000_L 1 /* bool */ -#define CONFIG_9P_ENABLE_9P2000_p9p 1 /* bool */ +/* 9P_SRV *********************************************************************/ + +#define CONFIG_9P_SRV_MAX_MSG_SIZE ((4*1024)+24) +#define CONFIG_9P_SRV_MAX_HOSTMSG_SIZE CONFIG_9P_SRV_MAX_MSG_SIZE+16 + +/* COROUTINE ******************************************************************/ + +#define CONFIG_COROUTINE_STACK_SIZE_DEFAULT (32*1024) +#define CONFIG_COROUTINE_NAME_LEN 16 +#define CONFIG_COROUTINE_MEASURE_STACK 1 /* bool */ +#define CONFIG_COROUTINE_PROTECT_STACK 1 /* bool */ +#define CONFIG_COROUTINE_DEBUG 0 /* bool */ +#define CONFIG_COROUTINE_VALGRIND 1 /* bool */ +#define CONFIG_COROUTINE_GDB 1 /* bool */ +#define CONFIG_COROUTINE_NUM 8 #endif /* _CONFIG_H_ */ diff --git a/lib9p/tests/test_server/fs_flush.c b/lib9p/tests/test_server/fs_flush.c index dbed3e7..e6408d7 100644 --- a/lib9p/tests/test_server/fs_flush.c +++ b/lib9p/tests/test_server/fs_flush.c @@ -31,28 +31,23 @@ static struct lib9p_qid flush_file_qid(struct flush_file *self) { }; } -static struct lib9p_stat flush_file_stat(struct flush_file *self, struct lib9p_srv_ctx *ctx) { +static struct lib9p_srv_stat flush_file_stat(struct flush_file *self, struct lib9p_srv_ctx *ctx) { assert(self); assert(ctx); - return (struct lib9p_stat){ - .kern_type = 0, - .kern_dev = 0, - .file_qid = flush_file_qid(self), - .file_mode = 0444, - .file_atime = UTIL9P_ATIME, - .file_mtime = UTIL9P_MTIME, - .file_size = 6, - .file_name = lib9p_str(self->name), - .file_owner_uid = lib9p_str("root"), - .file_owner_gid = lib9p_str("root"), - .file_last_modified_uid = lib9p_str("root"), - .file_extension = lib9p_str(NULL), - .file_owner_n_uid = 0, - .file_owner_n_gid = 0, - .file_last_modified_n_uid = 0, + return (struct lib9p_srv_stat){ + .qid = flush_file_qid(self), + .mode = 0444, + .atime_sec = UTIL9P_ATIME, + .mtime_sec = UTIL9P_MTIME, + .size = 6, + .name = lib9p_str(self->name), + .owner_uid = { .name = lib9p_str("root"), .num = 0 }, + .owner_gid = { .name = lib9p_str("root"), .num = 0 }, + .last_modifier_uid = { .name = lib9p_str("root"), .num = 0 }, + .extension = lib9p_str(NULL), }; } -static void flush_file_wstat(struct flush_file *self, struct lib9p_srv_ctx *ctx, struct lib9p_stat) { +static void flush_file_wstat(struct flush_file *self, struct lib9p_srv_ctx *ctx, struct lib9p_srv_stat) { assert(self); assert(ctx); lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EROFS, "cannot wstat API file"); @@ -107,7 +102,7 @@ static void flush_fio_pread(struct flush_fio *self, struct lib9p_srv_ctx *ctx, assert(ret); /* Wait for first Tflush */ - while (cr_chan_num_waiters(&ctx->flush_ch) == 0) + while (!lib9p_srv_flush_requested(ctx)) cr_yield(); /* Wait for the specified number of Tflush (may be higher *or* @@ -117,7 +112,6 @@ static void flush_fio_pread(struct flush_fio *self, struct lib9p_srv_ctx *ctx, cr_yield(); /* Return */ - bool flushed; switch (self->parent->flush_behavior) { case FLUSH_READ: *ret = (struct iovec){ @@ -126,13 +120,11 @@ static void flush_fio_pread(struct flush_fio *self, struct lib9p_srv_ctx *ctx, }; break; case FLUSH_ERROR: - flushed = lib9p_srv_accept_flush(ctx); - assert(flushed); + lib9p_srv_acknowledge_flush(ctx); lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_ECANCELED, "request canceled by flush"); break; case FLUSH_SILENT: - flushed = lib9p_srv_accept_flush(ctx); - assert(flushed); + lib9p_srv_acknowledge_flush(ctx); break; } cr_yield(); diff --git a/lib9p/tests/test_server/fs_shutdown.c b/lib9p/tests/test_server/fs_shutdown.c index e7375ef..d4ae67e 100644 --- a/lib9p/tests/test_server/fs_shutdown.c +++ b/lib9p/tests/test_server/fs_shutdown.c @@ -24,34 +24,29 @@ static void shutdown_file_free(struct shutdown_file *self) { static struct lib9p_qid shutdown_file_qid(struct shutdown_file *self) { assert(self); return (struct lib9p_qid){ - .type = LIB9P_QT_FILE, + .type = LIB9P_QT_FILE | LIB9P_QT_APPEND, .vers = 1, .path = self->pathnum, }; } -static struct lib9p_stat shutdown_file_stat(struct shutdown_file *self, struct lib9p_srv_ctx *ctx) { +static struct lib9p_srv_stat shutdown_file_stat(struct shutdown_file *self, struct lib9p_srv_ctx *ctx) { assert(self); assert(ctx); - return (struct lib9p_stat){ - .kern_type = 0, - .kern_dev = 0, - .file_qid = shutdown_file_qid(self), - .file_mode = 0222, - .file_atime = UTIL9P_ATIME, - .file_mtime = UTIL9P_MTIME, - .file_size = 0, - .file_name = lib9p_str(self->name), - .file_owner_uid = lib9p_str("root"), - .file_owner_gid = lib9p_str("root"), - .file_last_modified_uid = lib9p_str("root"), - .file_extension = lib9p_str(NULL), - .file_owner_n_uid = 0, - .file_owner_n_gid = 0, - .file_last_modified_n_uid = 0, + return (struct lib9p_srv_stat){ + .qid = shutdown_file_qid(self), + .mode = 0222 | LIB9P_DM_APPEND, + .atime_sec = UTIL9P_ATIME, + .mtime_sec = UTIL9P_MTIME, + .size = 0, + .name = lib9p_str(self->name), + .owner_uid = { .name=lib9p_str("root"), .num=0 }, + .owner_gid = { .name=lib9p_str("root"), .num=0 }, + .last_modifier_uid = { .name=lib9p_str("root"), .num=0 }, + .extension = lib9p_str(NULL), }; } -static void shutdown_file_wstat(struct shutdown_file *self, struct lib9p_srv_ctx *ctx, struct lib9p_stat) { +static void shutdown_file_wstat(struct shutdown_file *self, struct lib9p_srv_ctx *ctx, struct lib9p_srv_stat) { assert(self); assert(ctx); lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EROFS, "cannot wstat API file"); @@ -91,10 +86,11 @@ static uint32_t shutdown_fio_iounit(struct shutdown_fio *self) { return 0; } -static uint32_t shutdown_fio_pwrite(struct shutdown_fio *self, struct lib9p_srv_ctx *ctx, void *buf, uint32_t byte_count, uint64_t LM_UNUSED(offset)) { +static uint32_t shutdown_fio_pwrite(struct shutdown_fio *self, struct lib9p_srv_ctx *ctx, void *buf, uint32_t byte_count, uint64_t offset) { assert(self); assert(ctx); assert(buf); + assert(offset == 0); if (byte_count == 0) return 0; for (size_t i = 0; i < self->parent->nlisteners; i++) diff --git a/lib9p/tests/test_server/fs_whoami.c b/lib9p/tests/test_server/fs_whoami.c index 653ac4b..8d9752a 100644 --- a/lib9p/tests/test_server/fs_whoami.c +++ b/lib9p/tests/test_server/fs_whoami.c @@ -23,10 +23,10 @@ LO_IMPLEMENTATION_C(lib9p_srv_fio, struct whoami_fio, whoami_fio, static); size_t whoami_len(struct lib9p_srv_ctx *ctx) { assert(ctx); - assert(ctx->authinfo); + assert(ctx->user); size_t len = 0; - uint32_t uid = ctx->authinfo->uid; + uint32_t uid = ctx->user->num; while (uid) { len++; uid /= 10; @@ -34,7 +34,7 @@ size_t whoami_len(struct lib9p_srv_ctx *ctx) { if (!len) len++; len += 2; - len += ctx->authinfo->uname.len; + len += ctx->user->name.len; return len; } @@ -52,29 +52,24 @@ static struct lib9p_qid whoami_file_qid(struct whoami_file *self) { }; } -static struct lib9p_stat whoami_file_stat(struct whoami_file *self, struct lib9p_srv_ctx *ctx) { +static struct lib9p_srv_stat whoami_file_stat(struct whoami_file *self, struct lib9p_srv_ctx *ctx) { assert(self); assert(ctx); - return (struct lib9p_stat){ - .kern_type = 0, - .kern_dev = 0, - .file_qid = whoami_file_qid(self), - .file_mode = 0444, - .file_atime = UTIL9P_ATIME, - .file_mtime = UTIL9P_MTIME, - .file_size = whoami_len(ctx), - .file_name = lib9p_str(self->name), - .file_owner_uid = lib9p_str("root"), - .file_owner_gid = lib9p_str("root"), - .file_last_modified_uid = lib9p_str("root"), - .file_extension = lib9p_str(NULL), - .file_owner_n_uid = 0, - .file_owner_n_gid = 0, - .file_last_modified_n_uid = 0, + return (struct lib9p_srv_stat){ + .qid = whoami_file_qid(self), + .mode = 0444, + .atime_sec = UTIL9P_ATIME, + .mtime_sec = UTIL9P_MTIME, + .size = whoami_len(ctx), + .name = lib9p_str(self->name), + .owner_uid = { .name=lib9p_str("root"), .num=0 }, + .owner_gid = { .name=lib9p_str("root"), .num=0 }, + .last_modifier_uid = { .name=lib9p_str("root"), .num=0 }, + .extension = lib9p_str(NULL), }; } -static void whoami_file_wstat(struct whoami_file *self, struct lib9p_srv_ctx *ctx, struct lib9p_stat) { +static void whoami_file_wstat(struct whoami_file *self, struct lib9p_srv_ctx *ctx, struct lib9p_srv_stat) { assert(self); assert(ctx); lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EROFS, "cannot wstat API file"); @@ -138,7 +133,7 @@ static void whoami_fio_pread(struct whoami_fio *self, struct lib9p_srv_ctx *ctx, self->buf_len = data_size+1; } snprintf(self->buf, self->buf_len, "%"PRIu32" %.*s\n", - ctx->authinfo->uid, ctx->authinfo->uname.len, ctx->authinfo->uname.utf8); + ctx->user->num, ctx->user->name.len, ctx->user->name.utf8); if (byte_offset > (uint64_t)data_size) { lib9p_error(&ctx->basectx, diff --git a/lib9p/tests/testclient-p9p b/lib9p/tests/testclient-p9p index 9c9f9f2..09ce746 100755 --- a/lib9p/tests/testclient-p9p +++ b/lib9p/tests/testclient-p9p @@ -30,7 +30,7 @@ expect_lines \ '--r--r--r-- M 0 root root 6 Oct 7 2024 flush-silent' \ '--r--r--r-- M 0 root root 6 Oct 7 2024 flush-slowread' \ '--r--r--r-- M 0 root root 6 Oct 7 2024 flush-slowsilent' \ - '---w--w--w- M 0 root root 0 Oct 7 2024 shutdown' \ + 'a--w--w--w- M 0 root root 0 Oct 7 2024 shutdown' \ '--r--r--r-- M 0 root root 9 Oct 7 2024 whoami' out=$("${client[@]}" ls -l 'Documentation/') diff --git a/lib9p/tests/testclient-p9p.explog b/lib9p/tests/testclient-p9p.explog index 7f3953d..54f1e4b 100644 --- a/lib9p/tests/testclient-p9p.explog +++ b/lib9p/tests/testclient-p9p.explog @@ -4,14 +4,14 @@ # SPDX-License-Identifier: AGPL-3.0-or-later > Tversion { tag=NOTAG max_msg_size=8192 version="9P2000" } < Rversion { tag=NOTAG max_msg_size=4120 version="9P2000" } -> Tauth { tag=0 afid=0 uname="nobody" aname="" n_uid=0 } +> Tauth { tag=0 afid=0 uname="nobody" aname="" unum=0 } < Rerror { tag=0 errstr="authentication not required" errnum=L_EOPNOTSUPP } -> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" n_uid=0 } +> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" unum=0 } < Rattach { tag=0 qid={ type=(DIR) vers=1 path=1 } } > Twalk { tag=0 fid=0 newfid=1 nwname=0 wname=[ ] } < Rwalk { tag=0 nwqid=0 wqid=[ ] } > Tstat { tag=0 fid=1 } -< Rstat { tag=0 stat={ kern_type=0 kern_dev=0 file_qid={ type=(DIR) vers=1 path=1 } file_mode=(DIR|0555) file_atime=1728337905 file_mtime=1728337904 file_size=0 file_name="" file_owner_uid="root" file_owner_gid="root" file_last_modified_uid="root" file_extension="" file_owner_n_uid=0 file_owner_n_gid=0 file_last_modified_n_uid=0 } } +< Rstat { tag=0 stat={ fstype=0 fsdev=0 qid={ type=(DIR) vers=1 path=1 } mode=(DIR|0555) atime=1728337905 mtime=1728337904 length=0 name="" owner_uname="root" owner_gname="root" last_modifier_uname="root" extension="" owner_unum=0 owner_gnum=0 last_modifier_unum=0 } } > Tclunk { tag=0 fid=1 } < Rclunk { tag=0 } > Twalk { tag=0 fid=0 newfid=1 nwname=0 wname=[ ] } @@ -26,14 +26,14 @@ < Rclunk { tag=0 } > Tversion { tag=NOTAG max_msg_size=8192 version="9P2000" } < Rversion { tag=NOTAG max_msg_size=4120 version="9P2000" } -> Tauth { tag=0 afid=0 uname="nobody" aname="" n_uid=0 } +> Tauth { tag=0 afid=0 uname="nobody" aname="" unum=0 } < Rerror { tag=0 errstr="authentication not required" errnum=L_EOPNOTSUPP } -> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" n_uid=0 } +> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" unum=0 } < Rattach { tag=0 qid={ type=(DIR) vers=1 path=1 } } > Twalk { tag=0 fid=0 newfid=1 nwname=1 wname=[ "Documentation" ] } < Rwalk { tag=0 nwqid=1 wqid=[ { type=(DIR) vers=1 path=2 } ] } > Tstat { tag=0 fid=1 } -< Rstat { tag=0 stat={ kern_type=0 kern_dev=0 file_qid={ type=(DIR) vers=1 path=2 } file_mode=(DIR|0555) file_atime=1728337905 file_mtime=1728337904 file_size=0 file_name="Documentation" file_owner_uid="root" file_owner_gid="root" file_last_modified_uid="root" file_extension="" file_owner_n_uid=0 file_owner_n_gid=0 file_last_modified_n_uid=0 } } +< Rstat { tag=0 stat={ fstype=0 fsdev=0 qid={ type=(DIR) vers=1 path=2 } mode=(DIR|0555) atime=1728337905 mtime=1728337904 length=0 name="Documentation" owner_uname="root" owner_gname="root" last_modifier_uname="root" extension="" owner_unum=0 owner_gnum=0 last_modifier_unum=0 } } > Tclunk { tag=0 fid=1 } < Rclunk { tag=0 } > Twalk { tag=0 fid=0 newfid=1 nwname=1 wname=[ "Documentation" ] } @@ -48,9 +48,9 @@ < Rclunk { tag=0 } > Tversion { tag=NOTAG max_msg_size=8192 version="9P2000" } < Rversion { tag=NOTAG max_msg_size=4120 version="9P2000" } -> Tauth { tag=0 afid=0 uname="nobody" aname="" n_uid=0 } +> Tauth { tag=0 afid=0 uname="nobody" aname="" unum=0 } < Rerror { tag=0 errstr="authentication not required" errnum=L_EOPNOTSUPP } -> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" n_uid=0 } +> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" unum=0 } < Rattach { tag=0 qid={ type=(DIR) vers=1 path=1 } } > Twalk { tag=0 fid=0 newfid=1 nwname=1 wname=[ "README.md" ] } < Rwalk { tag=0 nwqid=1 wqid=[ { type=(0) vers=1 path=4 } ] } @@ -64,9 +64,9 @@ < Rclunk { tag=0 } > Tversion { tag=NOTAG max_msg_size=8192 version="9P2000" } < Rversion { tag=NOTAG max_msg_size=4120 version="9P2000" } -> Tauth { tag=0 afid=0 uname="nobody" aname="" n_uid=0 } +> Tauth { tag=0 afid=0 uname="nobody" aname="" unum=0 } < Rerror { tag=0 errstr="authentication not required" errnum=L_EOPNOTSUPP } -> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" n_uid=0 } +> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" unum=0 } < Rattach { tag=0 qid={ type=(DIR) vers=1 path=1 } } > Twalk { tag=0 fid=0 newfid=1 nwname=2 wname=[ "Documentation", "x" ] } < Rwalk { tag=0 nwqid=2 wqid=[ { type=(DIR) vers=1 path=2 }, { type=(0) vers=1 path=3 } ] } @@ -80,26 +80,26 @@ < Rclunk { tag=0 } > Tversion { tag=NOTAG max_msg_size=8192 version="9P2000" } < Rversion { tag=NOTAG max_msg_size=4120 version="9P2000" } -> Tauth { tag=0 afid=0 uname="nobody" aname="" n_uid=0 } +> Tauth { tag=0 afid=0 uname="nobody" aname="" unum=0 } < Rerror { tag=0 errstr="authentication not required" errnum=L_EOPNOTSUPP } -> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" n_uid=0 } +> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" unum=0 } < Rattach { tag=0 qid={ type=(DIR) vers=1 path=1 } } > Twalk { tag=0 fid=0 newfid=1 nwname=2 wname=[ "Documentation", "x" ] } < Rwalk { tag=0 nwqid=2 wqid=[ { type=(DIR) vers=1 path=2 }, { type=(0) vers=1 path=3 } ] } > Tstat { tag=0 fid=1 } -< Rstat { tag=0 stat={ kern_type=0 kern_dev=0 file_qid={ type=(0) vers=1 path=3 } file_mode=(0444) file_atime=1728337905 file_mtime=1728337904 file_size=166 file_name="x" file_owner_uid="root" file_owner_gid="root" file_last_modified_uid="root" file_extension="" file_owner_n_uid=0 file_owner_n_gid=0 file_last_modified_n_uid=0 } } +< Rstat { tag=0 stat={ fstype=0 fsdev=0 qid={ type=(0) vers=1 path=3 } mode=(0444) atime=1728337905 mtime=1728337904 length=166 name="x" owner_uname="root" owner_gname="root" last_modifier_uname="root" extension="" owner_unum=0 owner_gnum=0 last_modifier_unum=0 } } > Tclunk { tag=0 fid=1 } < Rclunk { tag=0 } > Tversion { tag=NOTAG max_msg_size=8192 version="9P2000" } < Rversion { tag=NOTAG max_msg_size=4120 version="9P2000" } -> Tauth { tag=0 afid=0 uname="nobody" aname="" n_uid=0 } +> Tauth { tag=0 afid=0 uname="nobody" aname="" unum=0 } < Rerror { tag=0 errstr="authentication not required" errnum=L_EOPNOTSUPP } -> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" n_uid=0 } +> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" unum=0 } < Rattach { tag=0 qid={ type=(DIR) vers=1 path=1 } } > Twalk { tag=0 fid=0 newfid=1 nwname=1 wname=[ "shutdown" ] } -< Rwalk { tag=0 nwqid=1 wqid=[ { type=(0) vers=1 path=5 } ] } +< Rwalk { tag=0 nwqid=1 wqid=[ { type=(APPEND) vers=1 path=5 } ] } > Topen { tag=0 fid=1 mode=(TRUNC|MODE_WRITE) } -< Ropen { tag=0 qid={ type=(0) vers=1 path=5 } iounit=0 } +< Ropen { tag=0 qid={ type=(APPEND) vers=1 path=5 } iounit=0 } > Twrite { tag=0 fid=1 offset=0 count=2 data="1\n" } < Rwrite { tag=0 count=2 } > Tclunk { tag=0 fid=1 } diff --git a/lib9p/tests/testclient-sess.c b/lib9p/tests/testclient-sess.c index 561c0c9..7cb7f97 100644 --- a/lib9p/tests/testclient-sess.c +++ b/lib9p/tests/testclient-sess.c @@ -95,9 +95,9 @@ int main(int argc, char *argv[]) { send9p(Tversion, .tag=0, .max_msg_size=(8*1024), .version=lib9p_str("9P2000.u")); recv9p(); /* Rversion */ ctx.version = LIB9P_VER_9P2000_u; - send9p(Tattach, .tag=0, .fid=0, .afid=LIB9P_FID_NOFID, .uname=lib9p_str("alice"), .n_uid=1000, .aname=lib9p_str("")); + send9p(Tattach, .tag=0, .fid=0, .afid=LIB9P_FID_NOFID, .uname=lib9p_str("alice"), .unum=1000, .aname=lib9p_str("")); recv9p(); /* Rattach */ - send9p(Tattach, .tag=0, .fid=1, .afid=LIB9P_FID_NOFID, .uname=lib9p_str("bob"), .n_uid=1001, .aname=lib9p_str("")); + send9p(Tattach, .tag=0, .fid=1, .afid=LIB9P_FID_NOFID, .uname=lib9p_str("bob"), .unum=1001, .aname=lib9p_str("")); recv9p(); /* Rattach */ wname[0] = lib9p_str("whoami"); send9p(Twalk, .tag=0, .fid=0, .newfid=2, .nwname=1, .wname=wname); recv9p(); /* Rwalk */ diff --git a/lib9p/tests/testclient-sess.explog b/lib9p/tests/testclient-sess.explog index 74a2cd7..a3838ac 100644 --- a/lib9p/tests/testclient-sess.explog +++ b/lib9p/tests/testclient-sess.explog @@ -14,9 +14,9 @@ # ext version, users ########################################################### > Tversion { tag=0 max_msg_size=8192 version="9P2000.u" } < Rversion { tag=0 max_msg_size=4120 version="9P2000.u" } -> Tattach { tag=0 fid=0 afid=NOFID uname="alice" aname="" n_uid=1000 } +> Tattach { tag=0 fid=0 afid=NOFID uname="alice" aname="" unum=1000 } < Rattach { tag=0 qid={ type=(DIR) vers=1 path=1 } } -> Tattach { tag=0 fid=1 afid=NOFID uname="bob" aname="" n_uid=1001 } +> Tattach { tag=0 fid=1 afid=NOFID uname="bob" aname="" unum=1001 } < Rattach { tag=0 qid={ type=(DIR) vers=1 path=1 } } > Twalk { tag=0 fid=0 newfid=2 nwname=1 wname=[ "whoami" ] } < Rwalk { tag=0 nwqid=1 wqid=[ { type=(0) vers=1 path=8 } ] } @@ -34,7 +34,7 @@ # walk ######################################################################### > Tversion { tag=0 max_msg_size=8192 version="9P2000" } < Rversion { tag=0 max_msg_size=4120 version="9P2000" } -> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" n_uid=0 } +> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" unum=0 } < Rattach { tag=0 qid={ type=(DIR) vers=1 path=1 } } # dup @@ -83,7 +83,7 @@ # flush ######################################################################## > Tversion { tag=0 max_msg_size=8192 version="9P2000" } < Rversion { tag=0 max_msg_size=4120 version="9P2000" } -> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" n_uid=0 } +> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" unum=0 } < Rattach { tag=0 qid={ type=(DIR) vers=1 path=1 } } # flush, but original response comes back first @@ -146,11 +146,11 @@ # shutdown ##################################################################### > Tversion { tag=0 max_msg_size=8192 version="9P2000" } < Rversion { tag=0 max_msg_size=4120 version="9P2000" } -> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" n_uid=0 } +> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" unum=0 } < Rattach { tag=0 qid={ type=(DIR) vers=1 path=1 } } > Twalk { tag=0 fid=0 newfid=0 nwname=1 wname=[ "shutdown" ] } -< Rwalk { tag=0 nwqid=1 wqid=[ { type=(0) vers=1 path=5 } ] } +< Rwalk { tag=0 nwqid=1 wqid=[ { type=(APPEND) vers=1 path=5 } ] } > Topen { tag=0 fid=0 mode=(MODE_WRITE) } -< Ropen { tag=0 qid={ type=(0) vers=1 path=5 } iounit=0 } +< Ropen { tag=0 qid={ type=(APPEND) vers=1 path=5 } iounit=0 } > Twrite { tag=0 fid=0 offset=0 count=2 data="1\n" } < Rwrite { tag=0 count=2 } |