diff options
Diffstat (limited to 'lib9p')
-rw-r--r-- | lib9p/CMakeLists.txt | 30 | ||||
-rw-r--r-- | lib9p/core.c (renamed from lib9p/9p.c) | 4 | ||||
-rwxr-xr-x | lib9p/core.gen (renamed from lib9p/proto.gen) | 8 | ||||
-rw-r--r-- | lib9p/core_gen/__init__.py (renamed from lib9p/protogen/__init__.py) | 8 | ||||
-rw-r--r-- | lib9p/core_gen/c.py (renamed from lib9p/protogen/c.py) | 8 | ||||
-rw-r--r-- | lib9p/core_gen/c9util.py (renamed from lib9p/protogen/c9util.py) | 2 | ||||
-rw-r--r-- | lib9p/core_gen/c_format.py (renamed from lib9p/protogen/c_format.py) | 5 | ||||
-rw-r--r-- | lib9p/core_gen/c_marshal.py (renamed from lib9p/protogen/c_marshal.py) | 4 | ||||
-rw-r--r-- | lib9p/core_gen/c_unmarshal.py (renamed from lib9p/protogen/c_unmarshal.py) | 2 | ||||
-rw-r--r-- | lib9p/core_gen/c_validate.py (renamed from lib9p/protogen/c_validate.py) | 16 | ||||
-rw-r--r-- | lib9p/core_gen/cutil.py (renamed from lib9p/protogen/cutil.py) | 2 | ||||
-rw-r--r-- | lib9p/core_gen/h.py (renamed from lib9p/protogen/h.py) | 6 | ||||
-rw-r--r-- | lib9p/core_gen/idlutil.py (renamed from lib9p/protogen/idlutil.py) | 42 | ||||
-rw-r--r-- | lib9p/core_generated.c (renamed from lib9p/9p.generated.c) | 979 | ||||
-rw-r--r-- | lib9p/core_include/lib9p/_core_generated.h (renamed from lib9p/include/lib9p/9p.generated.h) | 935 | ||||
-rw-r--r-- | lib9p/core_include/lib9p/core.h (renamed from lib9p/include/lib9p/9p.h) | 27 | ||||
-rw-r--r-- | lib9p/core_tables.c (renamed from lib9p/tables.c) | 10 | ||||
-rw-r--r-- | lib9p/core_tables.h (renamed from lib9p/tables.h) | 10 | ||||
-rw-r--r-- | lib9p/core_utf8.h (renamed from lib9p/utf8.h) | 8 | ||||
-rw-r--r-- | lib9p/idl/2010-9P2000.L.9p | 141 | ||||
-rwxr-xr-x | lib9p/idl/2010-9P2000.L.9p.gen | 282 | ||||
-rw-r--r-- | lib9p/idl/__init__.py | 20 | ||||
-rw-r--r-- | lib9p/include/lib9p/linux-errno.h | 139 | ||||
-rwxr-xr-x | lib9p/include/lib9p/linux-errno.h.gen | 38 | ||||
-rw-r--r-- | lib9p/srv.c | 144 | ||||
-rw-r--r-- | lib9p/srv_include/lib9p/srv.h (renamed from lib9p/include/lib9p/srv.h) | 12 | ||||
-rw-r--r-- | lib9p/tests/client_config/config.h | 21 | ||||
-rw-r--r-- | lib9p/tests/test_compile.c | 135 | ||||
-rwxr-xr-x | lib9p/tests/test_compile.c.gen | 2 | ||||
-rw-r--r-- | lib9p/tests/test_compile_config/config.h | 19 | ||||
-rw-r--r-- | lib9p/tests/test_server/CMakeLists.txt | 1 | ||||
-rw-r--r-- | lib9p/tests/test_server/config/config.h | 17 | ||||
-rw-r--r-- | lib9p/tests/test_server/fs_shutdown.c | 4 | ||||
-rw-r--r-- | lib9p/tests/test_server/fs_slowread.c | 4 | ||||
-rw-r--r-- | lib9p/tests/test_server/fs_whoami.c | 6 | ||||
-rw-r--r-- | lib9p/tests/test_server/main.c | 15 | ||||
-rw-r--r-- | lib9p/tests/testclient-p9p.explog | 36 | ||||
-rw-r--r-- | lib9p/tests/testclient-sess.c | 52 | ||||
-rw-r--r-- | lib9p/tests/testclient-sess.explog | 71 |
39 files changed, 2128 insertions, 1137 deletions
diff --git a/lib9p/CMakeLists.txt b/lib9p/CMakeLists.txt index 949b6d6..543d01a 100644 --- a/lib9p/CMakeLists.txt +++ b/lib9p/CMakeLists.txt @@ -3,27 +3,35 @@ # Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> # SPDX-License-Identifier: AGPL-3.0-or-later -add_library(lib9p INTERFACE) -target_include_directories(lib9p PUBLIC INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include) -target_sources(lib9p INTERFACE - 9p.generated.c - 9p.c - tables.c - srv.c +add_library(lib9p_core INTERFACE) +target_include_directories(lib9p_core PUBLIC INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/core_include) +target_sources(lib9p_core INTERFACE + core.c + core_generated.c + core_tables.c ) -target_link_libraries(lib9p INTERFACE - libcr_ipc +target_link_libraries(lib9p_core INTERFACE libfmt libhw_generic libmisc ) +add_library(lib9p_srv INTERFACE) +target_include_directories(lib9p_srv PUBLIC INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/srv_include) +target_sources(lib9p_srv INTERFACE + srv.c +) +target_link_libraries(lib9p_srv INTERFACE + lib9p_core + libcr_ipc +) + if (ENABLE_TESTS) add_subdirectory(tests/test_server) function(add_lib9p_executable arg_testname) add_executable("${arg_testname}" "tests/${arg_testname}.c") - target_link_libraries("${arg_testname}" lib9p) + target_link_libraries("${arg_testname}" lib9p_core) target_include_directories("${arg_testname}" PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tests ${CMAKE_CURRENT_SOURCE_DIR}/tests/client_config @@ -42,6 +50,6 @@ if (ENABLE_TESTS) add_lib9p_executable("testclient-sess") add_lib9p_test("./testclient-sess") - add_lib_test(lib9p test_compile) + add_lib_test(lib9p_core test_compile) target_include_directories(test_compile PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_compile_config) endif() diff --git a/lib9p/9p.c b/lib9p/core.c index e7b20b5..a07461d 100644 --- a/lib9p/9p.c +++ b/lib9p/core.c @@ -1,4 +1,4 @@ -/* lib9p/9p.c - Base 9P protocol utilities for both clients and servers +/* lib9p/core.c - Base 9P protocol utilities for both clients and servers * * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> * SPDX-License-Identifier: AGPL-3.0-or-later @@ -10,7 +10,7 @@ #include <libfmt/fmt.h> /* for fmt_vsnprintf() */ -#include <lib9p/9p.h> +#include <lib9p/core.h> /* strings ********************************************************************/ diff --git a/lib9p/proto.gen b/lib9p/core.gen index 60f1347..b30ec31 100755 --- a/lib9p/proto.gen +++ b/lib9p/core.gen @@ -1,6 +1,6 @@ #!/usr/bin/env python -# lib9p/proto.gen - Generate C marshalers/unmarshalers for .9p files -# defining 9P protocol variants. +# lib9p/core.gen - Generate C marshalers/unmarshalers for .9p files +# defining 9P protocol variants. # # Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> # SPDX-License-Identifier: AGPL-3.0-or-later @@ -9,7 +9,7 @@ import os.path import sys sys.path.insert(0, os.path.normpath(os.path.join(__file__, ".."))) -import protogen # pylint: disable=wrong-import-position +import core_gen # pylint: disable=wrong-import-position if __name__ == "__main__": - protogen.main() + core_gen.main() diff --git a/lib9p/protogen/__init__.py b/lib9p/core_gen/__init__.py index c2c6173..b0da237 100644 --- a/lib9p/protogen/__init__.py +++ b/lib9p/core_gen/__init__.py @@ -1,4 +1,4 @@ -# lib9p/protogen/__init__.py - Generate C marshalers/unmarshalers for +# lib9p/core_gen/__init__.py - Generate C marshalers/unmarshalers for # .9p files defining 9P protocol variants # # Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> @@ -50,8 +50,10 @@ def main() -> None: versions, typs = parser.all() outdir = os.path.normpath(os.path.join(sys.argv[0], "..")) with open( - os.path.join(outdir, "include/lib9p/9p.generated.h"), "w", encoding="utf-8" + os.path.join(outdir, "core_include/lib9p/_core_generated.h"), + "w", + encoding="utf-8", ) as fh: fh.write(h.gen_h(versions, typs)) - with open(os.path.join(outdir, "9p.generated.c"), "w", encoding="utf-8") as fh: + with open(os.path.join(outdir, "core_generated.c"), "w", encoding="utf-8") as fh: fh.write(c.gen_c(versions, typs)) diff --git a/lib9p/protogen/c.py b/lib9p/core_gen/c.py index 530bdb6..b2e856d 100644 --- a/lib9p/protogen/c.py +++ b/lib9p/core_gen/c.py @@ -1,4 +1,4 @@ -# lib9p/protogen/c.py - Generate 9p.generated.c +# lib9p/core_gen/c.py - Generate core_generated.c # # Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> # SPDX-License-Identifier: AGPL-3.0-or-later @@ -31,10 +31,10 @@ def gen_c(versions: set[str], typs: list[idl.UserType]) -> str: #include <libmisc/assert.h> #include <libmisc/endian.h> -#include <lib9p/9p.h> +#include <lib9p/core.h> -#include "tables.h" -#include "utf8.h" +#include "core_tables.h" +#include "core_utf8.h" """ # libobj vtables ########################################################### ret += """ diff --git a/lib9p/protogen/c9util.py b/lib9p/core_gen/c9util.py index cf91951..84fdee4 100644 --- a/lib9p/protogen/c9util.py +++ b/lib9p/core_gen/c9util.py @@ -1,4 +1,4 @@ -# lib9p/protogen/c9util.py - Utilities for generating lib9p-specific C +# lib9p/core_gen/c9util.py - Utilities for generating lib9p-specific C # # Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> # SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/lib9p/protogen/c_format.py b/lib9p/core_gen/c_format.py index 4a809d1..f9eee90 100644 --- a/lib9p/protogen/c_format.py +++ b/lib9p/core_gen/c_format.py @@ -1,4 +1,4 @@ -# lib9p/protogen/c_format.py - Generate C pretty-print functions +# lib9p/core_gen/c_format.py - Generate C pretty-print functions # # Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> # SPDX-License-Identifier: AGPL-3.0-or-later @@ -140,7 +140,8 @@ def gen_c_format(versions: set[str], typs: list[idl.UserType]) -> str: ret += f'\tfmt_state_puts(state, " {member.membname}=[");\n' ret += f"\tfor ({cnt_typ} i = 0; i < {cnt_str}; i++) {{\n" ret += "\t\tif (i)\n" - ret += '\t\t\tfmt_state_puts(state, ", ");\n' + ret += "\t\t\tfmt_state_putchar(state, ',');\n" + ret += "\t\tfmt_state_putchar(state, ' ');\n" if isinstance(member.typ, idl.Primitive): ret += f'\t\tfmt_state_printf(state, "%"PRIu{member.typ.static_size*8}, self->{member.membname}[i]);\n' else: diff --git a/lib9p/protogen/c_marshal.py b/lib9p/core_gen/c_marshal.py index 4dab864..620bdea 100644 --- a/lib9p/protogen/c_marshal.py +++ b/lib9p/core_gen/c_marshal.py @@ -1,4 +1,4 @@ -# lib9p/protogen/c_marshal.py - Generate C marshal functions +# lib9p/core_gen/c_marshal.py - Generate C marshal functions # # Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> # SPDX-License-Identifier: AGPL-3.0-or-later @@ -381,7 +381,7 @@ def gen_c_marshal(versions: set[str], typs: list[idl.UserType]) -> str: ) ret += "\tif (needed_size > ctx->max_msg_size) {\n" if isinstance(typ, idl.Message): # SPECIAL (disable for stat) - ret += '\t\tlib9p_errorf(ctx, LINUX_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 (limit=%"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" diff --git a/lib9p/protogen/c_unmarshal.py b/lib9p/core_gen/c_unmarshal.py index 34635f9..1afbe1d 100644 --- a/lib9p/protogen/c_unmarshal.py +++ b/lib9p/core_gen/c_unmarshal.py @@ -1,4 +1,4 @@ -# lib9p/protogen/c_unmarshal.py - Generate C unmarshal functions +# lib9p/core_gen/c_unmarshal.py - Generate C unmarshal functions # # Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> # SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/lib9p/protogen/c_validate.py b/lib9p/core_gen/c_validate.py index 535a750..3073ed0 100644 --- a/lib9p/protogen/c_validate.py +++ b/lib9p/core_gen/c_validate.py @@ -1,4 +1,4 @@ -# lib9p/protogen/c_validate.py - Generate C validation functions +# lib9p/core_gen/c_validate.py - Generate C validation functions # # Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> # SPDX-License-Identifier: AGPL-3.0-or-later @@ -57,9 +57,9 @@ def gen_c_validate(versions: set[str], typs: list[idl.UserType]) -> str: "\t\t/* If needed-net-size overflowed uint32_t, then\n" "\t\t * there's no way that actual-net-size will live up to\n" "\t\t * that. */\n" - '\t\treturn lib9p_error(ctx, LINUX_EBADMSG, "message is too short for content");\n' + f'\t\treturn lib9p_error(ctx, {c9util.IDENT("ERRNO_L_EBADMSG")}, "message is too short for content");\n' "\tif (net_offset > net_size)\n" - '\t\treturn lib9p_errorf(ctx, LINUX_EBADMSG, "message is too short for content (%"PRIu32" > %"PRIu32") @ %d", net_offset, net_size, __LINE__);\n' + f'\t\treturn lib9p_errorf(ctx, {c9util.IDENT("ERRNO_L_EBADMSG")}, "message is too short for content (%"PRIu32" > %"PRIu32") @ %d", net_offset, net_size, __LINE__);\n' ) ret += cutil.macro( "#define VALIDATE_NET_UTF8(n)\n" @@ -67,7 +67,7 @@ def gen_c_validate(versions: set[str], typs: list[idl.UserType]) -> str: "\t\tsize_t len = n;\n" "\t\tVALIDATE_NET_BYTES(len);\n" "\t\tif (!is_valid_utf8_without_nul(&net_bytes[net_offset-len], len))\n" - '\t\t\treturn lib9p_error(ctx, LINUX_EBADMSG, "message contains invalid UTF-8");\n' + f'\t\t\treturn lib9p_error(ctx, {c9util.IDENT("ERRNO_L_EBADMSG")}, "message contains invalid UTF-8");\n' "\t}\n" ) ret += cutil.macro( @@ -76,7 +76,7 @@ def gen_c_validate(versions: set[str], typs: list[idl.UserType]) -> str: "\t\t/* If needed-host-size overflowed ssize_t, then there's\n" "\t\t * no way that actual-net-size will live up to\n" "\t\t * that. */\n" - '\t\treturn lib9p_error(ctx, LINUX_EBADMSG, "message is too short for content");\n' + f'\t\treturn lib9p_error(ctx, {c9util.IDENT("ERRNO_L_EBADMSG")}, "message is too short for content");\n' ) ret += "#define GET_U8LE(off) (net_bytes[off])\n" @@ -193,7 +193,7 @@ def gen_c_validate(versions: set[str], typs: list[idl.UserType]) -> str: act = f"(uint{nbits}_t)GET_U{nbits}LE({lookup_sym(f'&{child.membname}')})" exp = f"(uint{nbits}_t)({c9util.idl_expr(child.val, lookup_sym)})" ret += f"{'\t'*indent_lvl()}if ({act} != {exp})\n" - ret += f'{"\t"*(indent_lvl()+1)}return lib9p_errorf(ctx, LINUX_EBADMSG, "{path} value is wrong: actual: %"PRIu{nbits}" != correct:%"PRIu{nbits},\n' + ret += f'{"\t"*(indent_lvl()+1)}return lib9p_errorf(ctx, {c9util.IDENT("ERRNO_L_EBADMSG")}, "{path} value is wrong: actual: %"PRIu{nbits}" != correct:%"PRIu{nbits},\n' ret += f"{'\t'*(indent_lvl()+2)}{act}, {exp});\n" if child.max: incr_flush() @@ -208,7 +208,7 @@ def gen_c_validate(versions: set[str], typs: list[idl.UserType]) -> str: act = f"(uint{nbits}_t)GET_U{nbits}LE({lookup_sym(f'&{child.membname}')})" exp = f"(uint{nbits}_t)({c9util.idl_expr(child.max, lookup_sym)})" ret += f"{'\t'*indent_lvl()}if ({act} > {exp})\n" - ret += f'{"\t"*(indent_lvl()+1)}return lib9p_errorf(ctx, LINUX_EBADMSG, "{path} value is too large: %"PRIu{nbits}" > %"PRIu{nbits},\n' + ret += f'{"\t"*(indent_lvl()+1)}return lib9p_errorf(ctx, {c9util.IDENT("ERRNO_L_EBADMSG")}, "{path} value is too large: %"PRIu{nbits}" > %"PRIu{nbits},\n' ret += f"{'\t'*(indent_lvl()+2)}{act}, {exp});\n" if isinstance(child.typ, idl.Bitfield): incr_flush() @@ -216,7 +216,7 @@ def gen_c_validate(versions: set[str], typs: list[idl.UserType]) -> str: nbits = nbytes * 8 act = f"GET_U{nbits}LE({lookup_sym(f'&{child.membname}')})" ret += f"{'\t'*indent_lvl()}if ({act} & ~{child.typ.typname}_masks[ctx->version])\n" - ret += f'{"\t"*(indent_lvl()+1)}return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in {child.typ.typname} bitfield: %#0{nbytes*2}"PRIx{nbits},\n' + ret += f'{"\t"*(indent_lvl()+1)}return lib9p_errorf(ctx, {c9util.IDENT("ERRNO_L_EBADMSG")}, "unknown bits in {child.typ.typname} bitfield: %#0{nbytes*2}"PRIx{nbits},\n' ret += f"{'\t'*(indent_lvl()+2)}{act} & ~{child.typ.typname}_masks[ctx->version]);\n" def handle( diff --git a/lib9p/protogen/cutil.py b/lib9p/core_gen/cutil.py index 8df6db9..9183cc4 100644 --- a/lib9p/protogen/cutil.py +++ b/lib9p/core_gen/cutil.py @@ -1,4 +1,4 @@ -# lib9p/protogen/cutil.py - Utilities for generating C code +# lib9p/core_gen/cutil.py - Utilities for generating C code # # Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> # SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/lib9p/protogen/h.py b/lib9p/core_gen/h.py index 8f7fba2..3defcb8 100644 --- a/lib9p/protogen/h.py +++ b/lib9p/core_gen/h.py @@ -1,4 +1,4 @@ -# lib9p/protogen/h.py - Generate 9p.generated.h +# lib9p/core_gen/h.py - Generate _core_generated.h # # Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> # SPDX-License-Identifier: AGPL-3.0-or-later @@ -159,8 +159,8 @@ def gen_h(versions: set[str], typs: list[idl.UserType]) -> str: ret = f"""/* Generated by `{' '.join(sys.argv)}`. DO NOT EDIT! */ -#ifndef _LIB9P_9P_H_ -\t#error Do not include <lib9p/9p.generated.h> directly; include <lib9p/9p.h> instead +#ifndef _LIB9P_CORE_H_ +\t#error Do not include <lib9p/_core_generated.h> directly; include <lib9p/core.h> instead #endif #include <stdint.h> /* for uint{{n}}_t types */ diff --git a/lib9p/protogen/idlutil.py b/lib9p/core_gen/idlutil.py index dc4d012..e92839a 100644 --- a/lib9p/protogen/idlutil.py +++ b/lib9p/core_gen/idlutil.py @@ -1,10 +1,9 @@ -# lib9p/protogen/idlutil.py - Utilities for working with the 9P idl package +# lib9p/core_gen/idlutil.py - Utilities for working with the 9P idl package # # Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> # SPDX-License-Identifier: AGPL-3.0-or-later import enum -import graphlib import typing import idl @@ -22,21 +21,40 @@ __all__ = [ def topo_sorted(typs: list[idl.UserType]) -> typing.Iterable[idl.UserType]: - ts: graphlib.TopologicalSorter[idl.UserType] = graphlib.TopologicalSorter() + ret: list[idl.UserType] = [] + struct_ord: dict[str, int] = {} + + def get_struct_ord(typ: idl.Struct) -> int: + nonlocal struct_ord + if typ.typname not in struct_ord: + deps = [ + get_struct_ord(member.typ) + for member in typ.members + if isinstance(member.typ, idl.Struct) + ] + if len(deps) == 0: + struct_ord[typ.typname] = 0 + else: + struct_ord[typ.typname] = 1 + max(deps) + return struct_ord[typ.typname] + for typ in typs: match typ: case idl.Number(): - ts.add(typ) + ret.append(typ) case idl.Bitfield(): - ts.add(typ) + ret.append(typ) case idl.Struct(): # and idl.Message(): - deps = [ - member.typ - for member in typ.members - if not isinstance(member.typ, idl.Primitive) - ] - ts.add(typ, *deps) - return ts.static_order() + _ = get_struct_ord(typ) + for _ord in sorted(set(struct_ord.values())): + for typ in typs: + if not isinstance(typ, idl.Struct): + continue + if struct_ord[typ.typname] != _ord: + continue + ret.append(typ) + assert len(ret) == len(typs) + return ret # walk() ####################################################################### diff --git a/lib9p/9p.generated.c b/lib9p/core_generated.c index 914a612..1789bdc 100644 --- a/lib9p/9p.generated.c +++ b/lib9p/core_generated.c @@ -1,4 +1,4 @@ -/* Generated by `lib9p/proto.gen lib9p/idl/2002-9P2000.9p lib9p/idl/2003-9P2000.p9p.9p lib9p/idl/2005-9P2000.u.9p lib9p/idl/2010-9P2000.L.9p lib9p/idl/2012-9P2000.e.9p`. DO NOT EDIT! */ +/* 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! */ #include <stdbool.h> #include <stddef.h> /* for size_t */ @@ -8,10 +8,10 @@ #include <libmisc/assert.h> #include <libmisc/endian.h> -#include <lib9p/9p.h> +#include <lib9p/core.h> -#include "tables.h" -#include "utf8.h" +#include "core_tables.h" +#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 @@ -318,27 +318,27 @@ static const lib9p_lock_flags_t lock_flags_masks[LIB9P_VER_NUM] = { /* validate_* *****************************************************************/ -#define VALIDATE_NET_BYTES(n) \ - if (__builtin_add_overflow(net_offset, n, &net_offset)) \ - /* If needed-net-size overflowed uint32_t, then \ - * there's no way that actual-net-size will live up to \ - * that. */ \ - return lib9p_error(ctx, LINUX_EBADMSG, "message is too short for content"); \ - if (net_offset > net_size) \ - return lib9p_errorf(ctx, LINUX_EBADMSG, "message is too short for content (%"PRIu32" > %"PRIu32") @ %d", net_offset, net_size, __LINE__); -#define VALIDATE_NET_UTF8(n) \ - { \ - size_t len = n; \ - VALIDATE_NET_BYTES(len); \ - if (!is_valid_utf8_without_nul(&net_bytes[net_offset-len], len)) \ - return lib9p_error(ctx, LINUX_EBADMSG, "message contains invalid UTF-8"); \ +#define VALIDATE_NET_BYTES(n) \ + if (__builtin_add_overflow(net_offset, n, &net_offset)) \ + /* If needed-net-size overflowed uint32_t, then \ + * there's no way that actual-net-size will live up to \ + * that. */ \ + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "message is too short for content"); \ + if (net_offset > net_size) \ + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "message is too short for content (%"PRIu32" > %"PRIu32") @ %d", net_offset, net_size, __LINE__); +#define VALIDATE_NET_UTF8(n) \ + { \ + size_t len = n; \ + VALIDATE_NET_BYTES(len); \ + if (!is_valid_utf8_without_nul(&net_bytes[net_offset-len], len)) \ + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "message contains invalid UTF-8"); \ } #define RESERVE_HOST_BYTES(n) \ if (__builtin_add_overflow(host_size, n, &host_size)) \ /* If needed-host-size overflowed ssize_t, then there's \ * no way that actual-net-size will live up to \ * that. */ \ - return lib9p_error(ctx, LINUX_EBADMSG, "message is too short for content"); + return lib9p_error(ctx, LIB9P_ERRNO_L_EBADMSG, "message is too short for content"); #define GET_U8LE(off) (net_bytes[off]) #define GET_U16LE(off) uint16le_decode(&net_bytes[off]) #define GET_U32LE(off) uint32le_decode(&net_bytes[off]) @@ -357,7 +357,7 @@ static ssize_t validate_stat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t * uint32_t offsetof_file_qid_type = net_offset + 8; VALIDATE_NET_BYTES(21); if (GET_U8LE(offsetof_file_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, + 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; VALIDATE_NET_BYTES(22); @@ -377,10 +377,10 @@ 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, LINUX_EBADMSG, "stat->stat_size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + 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]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in dm bitfield: %#08"PRIx32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in dm bitfield: %#08"PRIx32, GET_U32LE(offsetof_file_mode) & ~dm_masks[ctx->version]); if (ret_net_size) *ret_net_size = net_offset; @@ -398,10 +398,10 @@ static ssize_t validate_Tversion(struct lib9p_ctx *ctx, uint32_t net_size, uint8 VALIDATE_NET_UTF8(LAST_U16LE()); uint32_t offsetof_end = net_offset + 0; if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tversion->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tversion->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(100)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tversion->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tversion->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(100)); return (ssize_t)host_size; } @@ -415,10 +415,10 @@ static ssize_t validate_Rversion(struct lib9p_ctx *ctx, uint32_t net_size, uint8 VALIDATE_NET_UTF8(LAST_U16LE()); uint32_t offsetof_end = net_offset + 0; if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rversion->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rversion->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(101)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rversion->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rversion->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(101)); return (ssize_t)host_size; } @@ -439,10 +439,10 @@ static ssize_t validate_Tauth(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t #endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ uint32_t offsetof_end = net_offset + 0; if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tauth->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tauth->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(102)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tauth->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tauth->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(102)); return (ssize_t)host_size; } @@ -455,14 +455,14 @@ static ssize_t validate_Rauth(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_aqid_type = net_offset + 7; VALIDATE_NET_BYTES(20); if (GET_U8LE(offsetof_aqid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, GET_U8LE(offsetof_aqid_type) & ~qt_masks[ctx->version]); uint32_t offsetof_end = net_offset + 0; if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rauth->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rauth->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(103)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rauth->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rauth->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(103)); return (ssize_t)host_size; } @@ -483,10 +483,10 @@ static ssize_t validate_Tattach(struct lib9p_ctx *ctx, uint32_t net_size, uint8_ #endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ uint32_t offsetof_end = net_offset + 0; if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tattach->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tattach->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(104)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tattach->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tattach->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(104)); return (ssize_t)host_size; } @@ -499,14 +499,14 @@ static ssize_t validate_Rattach(struct lib9p_ctx *ctx, uint32_t net_size, uint8_ uint32_t offsetof_qid_type = net_offset + 7; VALIDATE_NET_BYTES(20); if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]); uint32_t offsetof_end = net_offset + 0; if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rattach->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rattach->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(105)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rattach->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rattach->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(105)); return (ssize_t)host_size; } @@ -527,10 +527,10 @@ static ssize_t validate_Rerror(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_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rerror->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rerror->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(107)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rerror->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rerror->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(107)); return (ssize_t)host_size; } @@ -545,10 +545,10 @@ static ssize_t validate_Tflush(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_end = net_offset + 9; VALIDATE_NET_BYTES(9); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tflush->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tflush->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(108)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tflush->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tflush->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(108)); return (ssize_t)host_size; } @@ -561,10 +561,10 @@ static ssize_t validate_Rflush(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_end = net_offset + 7; VALIDATE_NET_BYTES(7); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rflush->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rflush->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(109)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rflush->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rflush->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(109)); return (ssize_t)host_size; } @@ -583,13 +583,13 @@ static ssize_t validate_Twalk(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t } uint32_t offsetof_end = net_offset + 0; if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Twalk->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twalk->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(110)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Twalk->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twalk->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(110)); if ((uint16_t)GET_U16LE(offsetof_nwname) > (uint16_t)(16)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Twalk->nwname value is too large: %"PRIu16" > %"PRIu16, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twalk->nwname value is too large: %"PRIu16" > %"PRIu16, (uint16_t)GET_U16LE(offsetof_nwname), (uint16_t)(16)); return (ssize_t)host_size; } @@ -606,18 +606,18 @@ static ssize_t validate_Rwalk(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_wqid_type = net_offset + 0; VALIDATE_NET_BYTES(13); if (GET_U8LE(offsetof_wqid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, GET_U8LE(offsetof_wqid_type) & ~qt_masks[ctx->version]); } uint32_t offsetof_end = net_offset + 0; if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rwalk->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwalk->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(111)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rwalk->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwalk->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(111)); if ((uint16_t)GET_U16LE(offsetof_nwqid) > (uint16_t)(16)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rwalk->nwqid value is too large: %"PRIu16" > %"PRIu16, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwalk->nwqid value is too large: %"PRIu16" > %"PRIu16, (uint16_t)GET_U16LE(offsetof_nwqid), (uint16_t)(16)); return (ssize_t)host_size; } @@ -633,13 +633,13 @@ static ssize_t validate_Topen(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_end = net_offset + 12; VALIDATE_NET_BYTES(12); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Topen->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Topen->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(112)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Topen->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Topen->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(112)); if (GET_U8LE(offsetof_mode) & ~o_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in o bitfield: %#02"PRIx8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in o bitfield: %#02"PRIx8, GET_U8LE(offsetof_mode) & ~o_masks[ctx->version]); return (ssize_t)host_size; } @@ -652,15 +652,15 @@ static ssize_t validate_Ropen(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_qid_type = net_offset + 7; VALIDATE_NET_BYTES(20); if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]); uint32_t offsetof_end = net_offset + 4; VALIDATE_NET_BYTES(4); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Ropen->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Ropen->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(113)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Ropen->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Ropen->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(113)); return (ssize_t)host_size; } @@ -677,16 +677,16 @@ static ssize_t validate_Tcreate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_ uint32_t offsetof_end = net_offset + 5; VALIDATE_NET_BYTES(5); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tcreate->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tcreate->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(114)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tcreate->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tcreate->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(114)); if (GET_U32LE(offsetof_perm) & ~dm_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in dm bitfield: %#08"PRIx32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in dm bitfield: %#08"PRIx32, GET_U32LE(offsetof_perm) & ~dm_masks[ctx->version]); if (GET_U8LE(offsetof_mode) & ~o_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in o bitfield: %#02"PRIx8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in o bitfield: %#02"PRIx8, GET_U8LE(offsetof_mode) & ~o_masks[ctx->version]); return (ssize_t)host_size; } @@ -699,15 +699,15 @@ static ssize_t validate_Rcreate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_ uint32_t offsetof_qid_type = net_offset + 7; VALIDATE_NET_BYTES(20); if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]); uint32_t offsetof_end = net_offset + 4; VALIDATE_NET_BYTES(4); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rcreate->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rcreate->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(115)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rcreate->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rcreate->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(115)); return (ssize_t)host_size; } @@ -724,16 +724,16 @@ static ssize_t validate_Tread(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_end = net_offset + 23; VALIDATE_NET_BYTES(23); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tread->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tread->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(116)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tread->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tread->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(116)); if ((uint64_t)GET_U64LE(offsetof_offset) > (uint64_t)(INT64_MAX)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tread->offset value is too large: %"PRIu64" > %"PRIu64, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tread->offset value is too large: %"PRIu64" > %"PRIu64, (uint64_t)GET_U64LE(offsetof_offset), (uint64_t)(INT64_MAX)); if ((uint32_t)GET_U32LE(offsetof_count) > (uint32_t)(INT32_MAX)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tread->count value is too large: %"PRIu32" > %"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tread->count value is too large: %"PRIu32" > %"PRIu32, (uint32_t)GET_U32LE(offsetof_count), (uint32_t)(INT32_MAX)); return (ssize_t)host_size; } @@ -748,13 +748,13 @@ static ssize_t validate_Rread(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t VALIDATE_NET_BYTES(LAST_U32LE()); uint32_t offsetof_end = net_offset + 0; if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rread->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rread->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(117)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rread->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rread->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(117)); if ((uint32_t)GET_U32LE(offsetof_count) > (uint32_t)(INT32_MAX)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rread->count value is too large: %"PRIu32" > %"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rread->count value is too large: %"PRIu32" > %"PRIu32, (uint32_t)GET_U32LE(offsetof_count), (uint32_t)(INT32_MAX)); return (ssize_t)host_size; } @@ -770,16 +770,16 @@ static ssize_t validate_Twrite(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t VALIDATE_NET_BYTES(LAST_U32LE()); uint32_t offsetof_end = net_offset + 0; if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Twrite->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twrite->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(118)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Twrite->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twrite->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(118)); if ((uint64_t)GET_U64LE(offsetof_offset) > (uint64_t)(INT64_MAX)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Twrite->offset value is too large: %"PRIu64" > %"PRIu64, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twrite->offset value is too large: %"PRIu64" > %"PRIu64, (uint64_t)GET_U64LE(offsetof_offset), (uint64_t)(INT64_MAX)); if ((uint32_t)GET_U32LE(offsetof_count) > (uint32_t)(INT32_MAX)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Twrite->count value is too large: %"PRIu32" > %"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twrite->count value is too large: %"PRIu32" > %"PRIu32, (uint32_t)GET_U32LE(offsetof_count), (uint32_t)(INT32_MAX)); return (ssize_t)host_size; } @@ -793,13 +793,13 @@ static ssize_t validate_Rwrite(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_end = net_offset + 11; VALIDATE_NET_BYTES(11); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rwrite->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwrite->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(119)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rwrite->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwrite->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(119)); if ((uint32_t)GET_U32LE(offsetof_count) > (uint32_t)(INT32_MAX)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rwrite->count value is too large: %"PRIu32" > %"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwrite->count value is too large: %"PRIu32" > %"PRIu32, (uint32_t)GET_U32LE(offsetof_count), (uint32_t)(INT32_MAX)); return (ssize_t)host_size; } @@ -812,10 +812,10 @@ static ssize_t validate_Tclunk(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_end = net_offset + 11; VALIDATE_NET_BYTES(11); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tclunk->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tclunk->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(120)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tclunk->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tclunk->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(120)); return (ssize_t)host_size; } @@ -828,10 +828,10 @@ static ssize_t validate_Rclunk(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_end = net_offset + 7; VALIDATE_NET_BYTES(7); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rclunk->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rclunk->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(121)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rclunk->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rclunk->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(121)); return (ssize_t)host_size; } @@ -844,10 +844,10 @@ static ssize_t validate_Tremove(struct lib9p_ctx *ctx, uint32_t net_size, uint8_ uint32_t offsetof_end = net_offset + 11; VALIDATE_NET_BYTES(11); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tremove->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tremove->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(122)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tremove->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tremove->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(122)); return (ssize_t)host_size; } @@ -860,10 +860,10 @@ static ssize_t validate_Rremove(struct lib9p_ctx *ctx, uint32_t net_size, uint8_ uint32_t offsetof_end = net_offset + 7; VALIDATE_NET_BYTES(7); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rremove->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rremove->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(123)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rremove->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rremove->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(123)); return (ssize_t)host_size; } @@ -878,10 +878,10 @@ static ssize_t validate_Tstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_end = net_offset + 11; VALIDATE_NET_BYTES(11); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tstat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tstat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(124)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tstat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tstat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(124)); return (ssize_t)host_size; } @@ -898,7 +898,7 @@ static ssize_t validate_Rstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_stat_file_qid_type = net_offset + 17; VALIDATE_NET_BYTES(30); if (GET_U8LE(offsetof_stat_file_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, + 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; VALIDATE_NET_BYTES(22); @@ -918,20 +918,20 @@ 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, LINUX_EBADMSG, "Rstat->stat.stat_size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + 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]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in dm bitfield: %#08"PRIx32, + 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]); uint32_t offsetof_end = net_offset + 0; if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rstat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rstat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(125)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rstat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rstat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(125)); if ((uint32_t)GET_U32LE(offsetof_nstat) != (uint32_t)(offsetof_end - offsetof_stat)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rstat->nstat value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rstat->nstat value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_nstat), (uint32_t)(offsetof_end - offsetof_stat)); return (ssize_t)host_size; } @@ -948,7 +948,7 @@ static ssize_t validate_Twstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_stat_file_qid_type = net_offset + 21; VALIDATE_NET_BYTES(34); if (GET_U8LE(offsetof_stat_file_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, + 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; VALIDATE_NET_BYTES(22); @@ -968,20 +968,20 @@ 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, LINUX_EBADMSG, "Twstat->stat.stat_size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + 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]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in dm bitfield: %#08"PRIx32, + 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]); uint32_t offsetof_end = net_offset + 0; if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Twstat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twstat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(126)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Twstat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twstat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(126)); if ((uint32_t)GET_U32LE(offsetof_nstat) != (uint32_t)(offsetof_end - offsetof_stat)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Twstat->nstat value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twstat->nstat value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_nstat), (uint32_t)(offsetof_end - offsetof_stat)); return (ssize_t)host_size; } @@ -994,10 +994,10 @@ static ssize_t validate_Rwstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_end = net_offset + 7; VALIDATE_NET_BYTES(7); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rwstat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwstat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(127)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rwstat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rwstat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(127)); return (ssize_t)host_size; } @@ -1013,13 +1013,13 @@ static ssize_t validate_Topenfd(struct lib9p_ctx *ctx, uint32_t net_size, uint8_ uint32_t offsetof_end = net_offset + 12; VALIDATE_NET_BYTES(12); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Topenfd->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Topenfd->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(98)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Topenfd->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Topenfd->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(98)); if (GET_U8LE(offsetof_mode) & ~o_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in o bitfield: %#02"PRIx8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in o bitfield: %#02"PRIx8, GET_U8LE(offsetof_mode) & ~o_masks[ctx->version]); return (ssize_t)host_size; } @@ -1032,15 +1032,15 @@ static ssize_t validate_Ropenfd(struct lib9p_ctx *ctx, uint32_t net_size, uint8_ uint32_t offsetof_qid_type = net_offset + 7; VALIDATE_NET_BYTES(20); if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]); uint32_t offsetof_end = net_offset + 8; VALIDATE_NET_BYTES(8); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Ropenfd->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Ropenfd->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(99)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Ropenfd->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Ropenfd->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(99)); return (ssize_t)host_size; } @@ -1055,10 +1055,10 @@ static ssize_t validate_Rlerror(struct lib9p_ctx *ctx, uint32_t net_size, uint8_ uint32_t offsetof_end = net_offset + 11; VALIDATE_NET_BYTES(11); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rlerror->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlerror->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(7)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rlerror->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlerror->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(7)); return (ssize_t)host_size; } @@ -1071,10 +1071,10 @@ static ssize_t validate_Tstatfs(struct lib9p_ctx *ctx, uint32_t net_size, uint8_ uint32_t offsetof_end = net_offset + 11; VALIDATE_NET_BYTES(11); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tstatfs->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tstatfs->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(8)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tstatfs->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tstatfs->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(8)); return (ssize_t)host_size; } @@ -1087,10 +1087,10 @@ static ssize_t validate_Rstatfs(struct lib9p_ctx *ctx, uint32_t net_size, uint8_ uint32_t offsetof_end = net_offset + 67; VALIDATE_NET_BYTES(67); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rstatfs->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rstatfs->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(9)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rstatfs->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rstatfs->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(9)); return (ssize_t)host_size; } @@ -1104,13 +1104,13 @@ static ssize_t validate_Tlopen(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_end = net_offset + 15; VALIDATE_NET_BYTES(15); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tlopen->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlopen->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(12)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tlopen->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlopen->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(12)); if (GET_U32LE(offsetof_flags) & ~lo_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in lo bitfield: %#08"PRIx32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in lo bitfield: %#08"PRIx32, GET_U32LE(offsetof_flags) & ~lo_masks[ctx->version]); return (ssize_t)host_size; } @@ -1123,15 +1123,15 @@ static ssize_t validate_Rlopen(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_qid_type = net_offset + 7; VALIDATE_NET_BYTES(20); if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]); uint32_t offsetof_end = net_offset + 4; VALIDATE_NET_BYTES(4); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rlopen->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlopen->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(13)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rlopen->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlopen->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(13)); return (ssize_t)host_size; } @@ -1148,16 +1148,16 @@ static ssize_t validate_Tlcreate(struct lib9p_ctx *ctx, uint32_t net_size, uint8 uint32_t offsetof_end = net_offset + 12; VALIDATE_NET_BYTES(12); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tlcreate->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlcreate->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(14)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tlcreate->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlcreate->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(14)); if (GET_U32LE(offsetof_flags) & ~lo_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in lo bitfield: %#08"PRIx32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in lo bitfield: %#08"PRIx32, GET_U32LE(offsetof_flags) & ~lo_masks[ctx->version]); if (GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in mode bitfield: %#08"PRIx32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in mode bitfield: %#08"PRIx32, GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]); return (ssize_t)host_size; } @@ -1170,15 +1170,15 @@ static ssize_t validate_Rlcreate(struct lib9p_ctx *ctx, uint32_t net_size, uint8 uint32_t offsetof_qid_type = net_offset + 7; VALIDATE_NET_BYTES(20); if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]); uint32_t offsetof_end = net_offset + 4; VALIDATE_NET_BYTES(4); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rlcreate->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlcreate->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(15)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rlcreate->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlcreate->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(15)); return (ssize_t)host_size; } @@ -1195,10 +1195,10 @@ static ssize_t validate_Tsymlink(struct lib9p_ctx *ctx, uint32_t net_size, uint8 uint32_t offsetof_end = net_offset + 4; VALIDATE_NET_BYTES(4); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tsymlink->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsymlink->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(16)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tsymlink->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsymlink->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(16)); return (ssize_t)host_size; } @@ -1211,14 +1211,14 @@ static ssize_t validate_Rsymlink(struct lib9p_ctx *ctx, uint32_t net_size, uint8 uint32_t offsetof_qid_type = net_offset + 7; VALIDATE_NET_BYTES(20); if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]); uint32_t offsetof_end = net_offset + 0; if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rsymlink->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsymlink->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(17)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rsymlink->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsymlink->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(17)); return (ssize_t)host_size; } @@ -1234,13 +1234,13 @@ static ssize_t validate_Tmknod(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_end = net_offset + 16; VALIDATE_NET_BYTES(16); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tmknod->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tmknod->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(18)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tmknod->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tmknod->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(18)); if (GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in mode bitfield: %#08"PRIx32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in mode bitfield: %#08"PRIx32, GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]); return (ssize_t)host_size; } @@ -1253,14 +1253,14 @@ static ssize_t validate_Rmknod(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_qid_type = net_offset + 7; VALIDATE_NET_BYTES(20); if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]); uint32_t offsetof_end = net_offset + 0; if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rmknod->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rmknod->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(19)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rmknod->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rmknod->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(19)); return (ssize_t)host_size; } @@ -1274,10 +1274,10 @@ static ssize_t validate_Trename(struct lib9p_ctx *ctx, uint32_t net_size, uint8_ VALIDATE_NET_UTF8(LAST_U16LE()); uint32_t offsetof_end = net_offset + 0; if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Trename->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Trename->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(20)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Trename->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Trename->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(20)); return (ssize_t)host_size; } @@ -1290,10 +1290,10 @@ static ssize_t validate_Rrename(struct lib9p_ctx *ctx, uint32_t net_size, uint8_ uint32_t offsetof_end = net_offset + 7; VALIDATE_NET_BYTES(7); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rrename->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rrename->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(21)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rrename->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rrename->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(21)); return (ssize_t)host_size; } @@ -1306,10 +1306,10 @@ static ssize_t validate_Treadlink(struct lib9p_ctx *ctx, uint32_t net_size, uint uint32_t offsetof_end = net_offset + 11; VALIDATE_NET_BYTES(11); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Treadlink->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Treadlink->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(22)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Treadlink->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Treadlink->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(22)); return (ssize_t)host_size; } @@ -1323,10 +1323,10 @@ static ssize_t validate_Rreadlink(struct lib9p_ctx *ctx, uint32_t net_size, uint VALIDATE_NET_UTF8(LAST_U16LE()); uint32_t offsetof_end = net_offset + 0; if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rreadlink->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rreadlink->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(23)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rreadlink->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rreadlink->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(23)); return (ssize_t)host_size; } @@ -1340,13 +1340,13 @@ static ssize_t validate_Tgetattr(struct lib9p_ctx *ctx, uint32_t net_size, uint8 uint32_t offsetof_end = net_offset + 19; VALIDATE_NET_BYTES(19); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tgetattr->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tgetattr->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(24)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tgetattr->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tgetattr->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(24)); if (GET_U64LE(offsetof_request_mask) & ~getattr_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in getattr bitfield: %#016"PRIx64, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in getattr bitfield: %#016"PRIx64, GET_U64LE(offsetof_request_mask) & ~getattr_masks[ctx->version]); return (ssize_t)host_size; } @@ -1360,22 +1360,22 @@ static ssize_t validate_Rgetattr(struct lib9p_ctx *ctx, uint32_t net_size, uint8 uint32_t offsetof_qid_type = net_offset + 15; VALIDATE_NET_BYTES(28); if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]); uint32_t offsetof_mode = net_offset + 0; uint32_t offsetof_end = net_offset + 132; VALIDATE_NET_BYTES(132); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rgetattr->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rgetattr->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(25)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rgetattr->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rgetattr->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(25)); if (GET_U64LE(offsetof_valid) & ~getattr_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in getattr bitfield: %#016"PRIx64, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in getattr bitfield: %#016"PRIx64, GET_U64LE(offsetof_valid) & ~getattr_masks[ctx->version]); if (GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in mode bitfield: %#08"PRIx32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in mode bitfield: %#08"PRIx32, GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]); return (ssize_t)host_size; } @@ -1390,16 +1390,16 @@ static ssize_t validate_Tsetattr(struct lib9p_ctx *ctx, uint32_t net_size, uint8 uint32_t offsetof_end = net_offset + 67; VALIDATE_NET_BYTES(67); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tsetattr->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsetattr->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(26)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tsetattr->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsetattr->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(26)); if (GET_U32LE(offsetof_valid) & ~setattr_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in setattr bitfield: %#08"PRIx32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in setattr bitfield: %#08"PRIx32, GET_U32LE(offsetof_valid) & ~setattr_masks[ctx->version]); if (GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in mode bitfield: %#08"PRIx32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in mode bitfield: %#08"PRIx32, GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]); return (ssize_t)host_size; } @@ -1412,10 +1412,10 @@ static ssize_t validate_Rsetattr(struct lib9p_ctx *ctx, uint32_t net_size, uint8 uint32_t offsetof_end = net_offset + 7; VALIDATE_NET_BYTES(7); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rsetattr->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsetattr->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(27)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rsetattr->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsetattr->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(27)); return (ssize_t)host_size; } @@ -1429,10 +1429,10 @@ static ssize_t validate_Txattrwalk(struct lib9p_ctx *ctx, uint32_t net_size, uin VALIDATE_NET_UTF8(LAST_U16LE()); uint32_t offsetof_end = net_offset + 0; if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Txattrwalk->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Txattrwalk->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(30)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Txattrwalk->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Txattrwalk->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(30)); return (ssize_t)host_size; } @@ -1445,10 +1445,10 @@ static ssize_t validate_Rxattrwalk(struct lib9p_ctx *ctx, uint32_t net_size, uin uint32_t offsetof_end = net_offset + 15; VALIDATE_NET_BYTES(15); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rxattrwalk->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rxattrwalk->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(31)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rxattrwalk->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rxattrwalk->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(31)); return (ssize_t)host_size; } @@ -1463,10 +1463,10 @@ static ssize_t validate_Txattrcreate(struct lib9p_ctx *ctx, uint32_t net_size, u uint32_t offsetof_end = net_offset + 12; VALIDATE_NET_BYTES(12); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Txattrcreate->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Txattrcreate->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(32)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Txattrcreate->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Txattrcreate->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(32)); return (ssize_t)host_size; } @@ -1479,10 +1479,10 @@ static ssize_t validate_Rxattrcreate(struct lib9p_ctx *ctx, uint32_t net_size, u uint32_t offsetof_end = net_offset + 7; VALIDATE_NET_BYTES(7); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rxattrcreate->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rxattrcreate->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(33)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rxattrcreate->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rxattrcreate->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(33)); return (ssize_t)host_size; } @@ -1495,10 +1495,10 @@ static ssize_t validate_Treaddir(struct lib9p_ctx *ctx, uint32_t net_size, uint8 uint32_t offsetof_end = net_offset + 23; VALIDATE_NET_BYTES(23); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Treaddir->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Treaddir->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(40)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Treaddir->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Treaddir->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(40)); return (ssize_t)host_size; } @@ -1512,10 +1512,10 @@ static ssize_t validate_Rreaddir(struct lib9p_ctx *ctx, uint32_t net_size, uint8 VALIDATE_NET_BYTES(LAST_U32LE()); uint32_t offsetof_end = net_offset + 0; if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rreaddir->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rreaddir->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(41)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rreaddir->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rreaddir->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(41)); return (ssize_t)host_size; } @@ -1528,10 +1528,10 @@ static ssize_t validate_Tfsync(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_end = net_offset + 15; VALIDATE_NET_BYTES(15); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tfsync->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tfsync->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(50)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tfsync->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tfsync->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(50)); return (ssize_t)host_size; } @@ -1544,10 +1544,10 @@ static ssize_t validate_Rfsync(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_end = net_offset + 7; VALIDATE_NET_BYTES(7); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rfsync->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rfsync->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(51)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rfsync->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rfsync->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(51)); return (ssize_t)host_size; } @@ -1562,13 +1562,13 @@ static ssize_t validate_Tlock(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t VALIDATE_NET_UTF8(LAST_U16LE()); uint32_t offsetof_end = net_offset + 0; if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tlock->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlock->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(52)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tlock->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlock->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(52)); if (GET_U32LE(offsetof_flags) & ~lock_flags_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in lock_flags bitfield: %#08"PRIx32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in lock_flags bitfield: %#08"PRIx32, GET_U32LE(offsetof_flags) & ~lock_flags_masks[ctx->version]); return (ssize_t)host_size; } @@ -1581,10 +1581,10 @@ static ssize_t validate_Rlock(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_end = net_offset + 8; VALIDATE_NET_BYTES(8); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rlock->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlock->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(53)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rlock->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlock->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(53)); return (ssize_t)host_size; } @@ -1598,10 +1598,10 @@ static ssize_t validate_Tgetlock(struct lib9p_ctx *ctx, uint32_t net_size, uint8 VALIDATE_NET_UTF8(LAST_U16LE()); uint32_t offsetof_end = net_offset + 0; if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tgetlock->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tgetlock->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(54)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tgetlock->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tgetlock->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(54)); return (ssize_t)host_size; } @@ -1615,10 +1615,10 @@ static ssize_t validate_Rgetlock(struct lib9p_ctx *ctx, uint32_t net_size, uint8 VALIDATE_NET_UTF8(LAST_U16LE()); uint32_t offsetof_end = net_offset + 0; if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rgetlock->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rgetlock->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(55)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rgetlock->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rgetlock->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(55)); return (ssize_t)host_size; } @@ -1632,10 +1632,10 @@ static ssize_t validate_Tlink(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t VALIDATE_NET_UTF8(LAST_U16LE()); uint32_t offsetof_end = net_offset + 0; if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tlink->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlink->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(70)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tlink->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tlink->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(70)); return (ssize_t)host_size; } @@ -1648,10 +1648,10 @@ static ssize_t validate_Rlink(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_end = net_offset + 7; VALIDATE_NET_BYTES(7); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rlink->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlink->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(71)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rlink->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rlink->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(71)); return (ssize_t)host_size; } @@ -1667,13 +1667,13 @@ static ssize_t validate_Tmkdir(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_end = net_offset + 8; VALIDATE_NET_BYTES(8); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tmkdir->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tmkdir->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(72)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tmkdir->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tmkdir->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(72)); if (GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in mode bitfield: %#08"PRIx32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in mode bitfield: %#08"PRIx32, GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]); return (ssize_t)host_size; } @@ -1686,14 +1686,14 @@ static ssize_t validate_Rmkdir(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t uint32_t offsetof_qid_type = net_offset + 7; VALIDATE_NET_BYTES(20); if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]) - return lib9p_errorf(ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]); uint32_t offsetof_end = net_offset + 0; if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rmkdir->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rmkdir->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(73)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rmkdir->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rmkdir->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(73)); return (ssize_t)host_size; } @@ -1709,10 +1709,10 @@ static ssize_t validate_Trenameat(struct lib9p_ctx *ctx, uint32_t net_size, uint VALIDATE_NET_UTF8(LAST_U16LE()); uint32_t offsetof_end = net_offset + 0; if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Trenameat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Trenameat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(74)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Trenameat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Trenameat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(74)); return (ssize_t)host_size; } @@ -1725,10 +1725,10 @@ static ssize_t validate_Rrenameat(struct lib9p_ctx *ctx, uint32_t net_size, uint uint32_t offsetof_end = net_offset + 7; VALIDATE_NET_BYTES(7); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rrenameat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rrenameat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(75)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rrenameat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rrenameat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(75)); return (ssize_t)host_size; } @@ -1743,10 +1743,10 @@ static ssize_t validate_Tunlinkat(struct lib9p_ctx *ctx, uint32_t net_size, uint uint32_t offsetof_end = net_offset + 4; VALIDATE_NET_BYTES(4); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tunlinkat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tunlinkat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(76)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tunlinkat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tunlinkat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(76)); return (ssize_t)host_size; } @@ -1759,10 +1759,10 @@ static ssize_t validate_Runlinkat(struct lib9p_ctx *ctx, uint32_t net_size, uint uint32_t offsetof_end = net_offset + 7; VALIDATE_NET_BYTES(7); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Runlinkat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Runlinkat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(77)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Runlinkat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Runlinkat->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(77)); return (ssize_t)host_size; } @@ -1777,10 +1777,10 @@ static ssize_t validate_Tsession(struct lib9p_ctx *ctx, uint32_t net_size, uint8 uint32_t offsetof_end = net_offset + 15; VALIDATE_NET_BYTES(15); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tsession->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsession->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(150)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tsession->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsession->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(150)); return (ssize_t)host_size; } @@ -1793,10 +1793,10 @@ static ssize_t validate_Rsession(struct lib9p_ctx *ctx, uint32_t net_size, uint8 uint32_t offsetof_end = net_offset + 7; VALIDATE_NET_BYTES(7); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rsession->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsession->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(151)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rsession->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsession->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(151)); return (ssize_t)host_size; } @@ -1814,10 +1814,10 @@ static ssize_t validate_Tsread(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t } uint32_t offsetof_end = net_offset + 0; if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tsread->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsread->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(152)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tsread->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tsread->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(152)); return (ssize_t)host_size; } @@ -1831,10 +1831,10 @@ static ssize_t validate_Rsread(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t VALIDATE_NET_BYTES(LAST_U32LE()); uint32_t offsetof_end = net_offset + 0; if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rsread->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsread->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(153)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rsread->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rsread->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(153)); return (ssize_t)host_size; } @@ -1854,10 +1854,10 @@ static ssize_t validate_Tswrite(struct lib9p_ctx *ctx, uint32_t net_size, uint8_ VALIDATE_NET_BYTES(LAST_U32LE()); uint32_t offsetof_end = net_offset + 0; if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tswrite->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tswrite->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(154)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Tswrite->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Tswrite->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(154)); return (ssize_t)host_size; } @@ -1870,10 +1870,10 @@ static ssize_t validate_Rswrite(struct lib9p_ctx *ctx, uint32_t net_size, uint8_ uint32_t offsetof_end = net_offset + 11; VALIDATE_NET_BYTES(11); if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rswrite->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rswrite->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32, (uint32_t)GET_U32LE(offsetof_size), (uint32_t)(offsetof_end - offsetof_size)); if ((uint8_t)GET_U8LE(offsetof_typ) != (uint8_t)(155)) - return lib9p_errorf(ctx, LINUX_EBADMSG, "Rswrite->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, + return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rswrite->typ value is wrong: actual: %"PRIu8" != correct:%"PRIu8, (uint8_t)GET_U8LE(offsetof_typ), (uint8_t)(155)); return (ssize_t)host_size; } @@ -3023,7 +3023,7 @@ static bool marshal_stat(struct lib9p_ctx *ctx, struct lib9p_stat *val, struct _ static bool marshal_Tversion(struct lib9p_ctx *ctx, struct lib9p_msg_Tversion *val, struct _marshal_ret *ret) { uint32_t needed_size = 13 + val->version.len; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", "Tversion", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -3043,7 +3043,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rversion", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -3068,7 +3068,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Tauth", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -3095,7 +3095,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rauth", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -3120,7 +3120,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Tattach", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -3148,7 +3148,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rattach", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -3175,7 +3175,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rerror", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -3201,7 +3201,7 @@ static bool marshal_Rerror(struct lib9p_ctx *ctx, struct lib9p_msg_Rerror *val, static bool marshal_Tflush(struct lib9p_ctx *ctx, struct lib9p_msg_Tflush *val, struct _marshal_ret *ret) { uint32_t needed_size = 9; if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", "Tflush", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -3219,7 +3219,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rflush", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -3239,7 +3239,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Twalk", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -3263,7 +3263,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rwalk", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -3288,7 +3288,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Topen", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -3307,7 +3307,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Ropen", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -3328,7 +3328,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Tcreate", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -3350,7 +3350,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rcreate", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -3373,7 +3373,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Tread", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -3393,7 +3393,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rread", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -3412,7 +3412,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Twrite", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -3433,7 +3433,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rwrite", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -3451,7 +3451,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Tclunk", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -3469,7 +3469,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rclunk", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -3486,7 +3486,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Tremove", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -3504,7 +3504,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rremove", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -3523,7 +3523,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Tstat", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -3546,7 +3546,7 @@ static bool marshal_Rstat(struct lib9p_ctx *ctx, struct lib9p_msg_Rstat *val, st } #endif /* CONFIG_9P_ENABLE_9P2000_u */ if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", "Rstat", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -3604,7 +3604,7 @@ static bool marshal_Twstat(struct lib9p_ctx *ctx, struct lib9p_msg_Twstat *val, } #endif /* CONFIG_9P_ENABLE_9P2000_u */ if (needed_size > ctx->max_msg_size) { - lib9p_errorf(ctx, LINUX_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx, LIB9P_ERRNO_L_ERANGE, "%s message too large to marshal into %s limit (limit=%"PRIu32")", "Twstat", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -3658,7 +3658,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rwstat", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -3677,7 +3677,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Topenfd", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -3696,7 +3696,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Ropenfd", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -3720,7 +3720,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rlerror", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -3738,7 +3738,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Tstatfs", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -3756,7 +3756,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rstatfs", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -3782,7 +3782,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Tlopen", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -3801,7 +3801,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rlopen", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -3822,7 +3822,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Tlcreate", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -3845,7 +3845,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rlcreate", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -3866,7 +3866,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Tsymlink", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -3889,7 +3889,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rsymlink", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -3909,7 +3909,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Tmknod", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -3933,7 +3933,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rmknod", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -3953,7 +3953,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Trename", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -3974,7 +3974,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rrename", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -3991,7 +3991,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Treadlink", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -4009,7 +4009,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rreadlink", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -4028,7 +4028,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Tgetattr", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -4047,7 +4047,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rgetattr", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -4086,7 +4086,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Tsetattr", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -4113,7 +4113,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rsetattr", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -4130,7 +4130,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Txattrwalk", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -4151,7 +4151,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rxattrwalk", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -4169,7 +4169,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Txattrcreate", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -4191,7 +4191,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rxattrcreate", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -4208,7 +4208,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Treaddir", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -4228,7 +4228,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rreaddir", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -4247,7 +4247,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Tfsync", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -4266,7 +4266,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rfsync", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -4283,7 +4283,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Tlock", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -4308,7 +4308,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rlock", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -4326,7 +4326,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Tgetlock", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -4350,7 +4350,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rgetlock", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -4373,7 +4373,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Tlink", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -4394,7 +4394,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rlink", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -4411,7 +4411,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Tmkdir", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -4433,7 +4433,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rmkdir", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -4453,7 +4453,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Trenameat", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -4476,7 +4476,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rrenameat", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -4493,7 +4493,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Tunlinkat", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -4514,7 +4514,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Runlinkat", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -4533,7 +4533,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Tsession", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -4551,7 +4551,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rsession", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -4571,7 +4571,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Tsread", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -4594,7 +4594,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rsread", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -4616,7 +4616,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Tswrite", ctx->version ? "negotiated" : "client", ctx->max_msg_size); @@ -4641,7 +4641,7 @@ 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, LINUX_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 (limit=%"PRIu32")", "Rswrite", ctx->version ? "negotiated" : "server", ctx->max_msg_size); @@ -5198,7 +5198,8 @@ static void lib9p_msg_Twalk_format(struct lib9p_msg_Twalk *self, struct fmt_stat fmt_state_puts(state, " wname=["); for (uint16_t i = 0; i < self->nwname; i++) { if (i) - fmt_state_puts(state, ", "); + fmt_state_putchar(state, ','); + fmt_state_putchar(state, ' '); lib9p_s_format(&self->wname[i], state); } fmt_state_puts(state, " ]"); @@ -5214,7 +5215,8 @@ static void lib9p_msg_Rwalk_format(struct lib9p_msg_Rwalk *self, struct fmt_stat fmt_state_puts(state, " wqid=["); for (uint16_t i = 0; i < self->nwqid; i++) { if (i) - fmt_state_puts(state, ", "); + fmt_state_putchar(state, ','); + fmt_state_putchar(state, ' '); lib9p_qid_format(&self->wqid[i], state); } fmt_state_puts(state, " ]"); @@ -5454,6 +5456,399 @@ static void lib9p_errno_format(lib9p_errno_t *self, struct fmt_state *state) { case LIB9P_ERRNO_NOERROR: fmt_state_puts(state, "NOERROR"); break; + case LIB9P_ERRNO_L_EPERM: + fmt_state_puts(state, "L_EPERM"); + break; + case LIB9P_ERRNO_L_ENOENT: + fmt_state_puts(state, "L_ENOENT"); + break; + case LIB9P_ERRNO_L_ESRCH: + fmt_state_puts(state, "L_ESRCH"); + break; + case LIB9P_ERRNO_L_EINTR: + fmt_state_puts(state, "L_EINTR"); + break; + case LIB9P_ERRNO_L_EIO: + fmt_state_puts(state, "L_EIO"); + break; + case LIB9P_ERRNO_L_ENXIO: + fmt_state_puts(state, "L_ENXIO"); + break; + case LIB9P_ERRNO_L_E2BIG: + fmt_state_puts(state, "L_E2BIG"); + break; + case LIB9P_ERRNO_L_ENOEXEC: + fmt_state_puts(state, "L_ENOEXEC"); + break; + case LIB9P_ERRNO_L_EBADF: + fmt_state_puts(state, "L_EBADF"); + break; + case LIB9P_ERRNO_L_ECHILD: + fmt_state_puts(state, "L_ECHILD"); + break; + case LIB9P_ERRNO_L_EAGAIN: + fmt_state_puts(state, "L_EAGAIN"); + break; + case LIB9P_ERRNO_L_ENOMEM: + fmt_state_puts(state, "L_ENOMEM"); + break; + case LIB9P_ERRNO_L_EACCES: + fmt_state_puts(state, "L_EACCES"); + break; + case LIB9P_ERRNO_L_EFAULT: + fmt_state_puts(state, "L_EFAULT"); + break; + case LIB9P_ERRNO_L_ENOTBLK: + fmt_state_puts(state, "L_ENOTBLK"); + break; + case LIB9P_ERRNO_L_EBUSY: + fmt_state_puts(state, "L_EBUSY"); + break; + case LIB9P_ERRNO_L_EEXIST: + fmt_state_puts(state, "L_EEXIST"); + break; + case LIB9P_ERRNO_L_EXDEV: + fmt_state_puts(state, "L_EXDEV"); + break; + case LIB9P_ERRNO_L_ENODEV: + fmt_state_puts(state, "L_ENODEV"); + break; + case LIB9P_ERRNO_L_ENOTDIR: + fmt_state_puts(state, "L_ENOTDIR"); + break; + case LIB9P_ERRNO_L_EISDIR: + fmt_state_puts(state, "L_EISDIR"); + break; + case LIB9P_ERRNO_L_EINVAL: + fmt_state_puts(state, "L_EINVAL"); + break; + case LIB9P_ERRNO_L_ENFILE: + fmt_state_puts(state, "L_ENFILE"); + break; + case LIB9P_ERRNO_L_EMFILE: + fmt_state_puts(state, "L_EMFILE"); + break; + case LIB9P_ERRNO_L_ENOTTY: + fmt_state_puts(state, "L_ENOTTY"); + break; + case LIB9P_ERRNO_L_ETXTBSY: + fmt_state_puts(state, "L_ETXTBSY"); + break; + case LIB9P_ERRNO_L_EFBIG: + fmt_state_puts(state, "L_EFBIG"); + break; + case LIB9P_ERRNO_L_ENOSPC: + fmt_state_puts(state, "L_ENOSPC"); + break; + case LIB9P_ERRNO_L_ESPIPE: + fmt_state_puts(state, "L_ESPIPE"); + break; + case LIB9P_ERRNO_L_EROFS: + fmt_state_puts(state, "L_EROFS"); + break; + case LIB9P_ERRNO_L_EMLINK: + fmt_state_puts(state, "L_EMLINK"); + break; + case LIB9P_ERRNO_L_EPIPE: + fmt_state_puts(state, "L_EPIPE"); + break; + case LIB9P_ERRNO_L_EDOM: + fmt_state_puts(state, "L_EDOM"); + break; + case LIB9P_ERRNO_L_ERANGE: + fmt_state_puts(state, "L_ERANGE"); + break; + case LIB9P_ERRNO_L_EDEADLK: + fmt_state_puts(state, "L_EDEADLK"); + break; + case LIB9P_ERRNO_L_ENAMETOOLONG: + fmt_state_puts(state, "L_ENAMETOOLONG"); + break; + case LIB9P_ERRNO_L_ENOLCK: + fmt_state_puts(state, "L_ENOLCK"); + break; + case LIB9P_ERRNO_L_ENOSYS: + fmt_state_puts(state, "L_ENOSYS"); + break; + case LIB9P_ERRNO_L_ENOTEMPTY: + fmt_state_puts(state, "L_ENOTEMPTY"); + break; + case LIB9P_ERRNO_L_ELOOP: + fmt_state_puts(state, "L_ELOOP"); + break; + case LIB9P_ERRNO_L_ENOMSG: + fmt_state_puts(state, "L_ENOMSG"); + break; + case LIB9P_ERRNO_L_EIDRM: + fmt_state_puts(state, "L_EIDRM"); + break; + case LIB9P_ERRNO_L_ECHRNG: + fmt_state_puts(state, "L_ECHRNG"); + break; + case LIB9P_ERRNO_L_EL2NSYNC: + fmt_state_puts(state, "L_EL2NSYNC"); + break; + case LIB9P_ERRNO_L_EL3HLT: + fmt_state_puts(state, "L_EL3HLT"); + break; + case LIB9P_ERRNO_L_EL3RST: + fmt_state_puts(state, "L_EL3RST"); + break; + case LIB9P_ERRNO_L_ELNRNG: + fmt_state_puts(state, "L_ELNRNG"); + break; + case LIB9P_ERRNO_L_EUNATCH: + fmt_state_puts(state, "L_EUNATCH"); + break; + case LIB9P_ERRNO_L_ENOCSI: + fmt_state_puts(state, "L_ENOCSI"); + break; + case LIB9P_ERRNO_L_EL2HLT: + fmt_state_puts(state, "L_EL2HLT"); + break; + case LIB9P_ERRNO_L_EBADE: + fmt_state_puts(state, "L_EBADE"); + break; + case LIB9P_ERRNO_L_EBADR: + fmt_state_puts(state, "L_EBADR"); + break; + case LIB9P_ERRNO_L_EXFULL: + fmt_state_puts(state, "L_EXFULL"); + break; + case LIB9P_ERRNO_L_ENOANO: + fmt_state_puts(state, "L_ENOANO"); + break; + case LIB9P_ERRNO_L_EBADRQC: + fmt_state_puts(state, "L_EBADRQC"); + break; + case LIB9P_ERRNO_L_EBADSLT: + fmt_state_puts(state, "L_EBADSLT"); + break; + case LIB9P_ERRNO_L_EBFONT: + fmt_state_puts(state, "L_EBFONT"); + break; + case LIB9P_ERRNO_L_ENOSTR: + fmt_state_puts(state, "L_ENOSTR"); + break; + case LIB9P_ERRNO_L_ENODATA: + fmt_state_puts(state, "L_ENODATA"); + break; + case LIB9P_ERRNO_L_ETIME: + fmt_state_puts(state, "L_ETIME"); + break; + case LIB9P_ERRNO_L_ENOSR: + fmt_state_puts(state, "L_ENOSR"); + break; + case LIB9P_ERRNO_L_ENONET: + fmt_state_puts(state, "L_ENONET"); + break; + case LIB9P_ERRNO_L_ENOPKG: + fmt_state_puts(state, "L_ENOPKG"); + break; + case LIB9P_ERRNO_L_EREMOTE: + fmt_state_puts(state, "L_EREMOTE"); + break; + case LIB9P_ERRNO_L_ENOLINK: + fmt_state_puts(state, "L_ENOLINK"); + break; + case LIB9P_ERRNO_L_EADV: + fmt_state_puts(state, "L_EADV"); + break; + case LIB9P_ERRNO_L_ESRMNT: + fmt_state_puts(state, "L_ESRMNT"); + break; + case LIB9P_ERRNO_L_ECOMM: + fmt_state_puts(state, "L_ECOMM"); + break; + case LIB9P_ERRNO_L_EPROTO: + fmt_state_puts(state, "L_EPROTO"); + break; + case LIB9P_ERRNO_L_EMULTIHOP: + fmt_state_puts(state, "L_EMULTIHOP"); + break; + case LIB9P_ERRNO_L_EDOTDOT: + fmt_state_puts(state, "L_EDOTDOT"); + break; + case LIB9P_ERRNO_L_EBADMSG: + fmt_state_puts(state, "L_EBADMSG"); + break; + case LIB9P_ERRNO_L_EOVERFLOW: + fmt_state_puts(state, "L_EOVERFLOW"); + break; + case LIB9P_ERRNO_L_ENOTUNIQ: + fmt_state_puts(state, "L_ENOTUNIQ"); + break; + case LIB9P_ERRNO_L_EBADFD: + fmt_state_puts(state, "L_EBADFD"); + break; + case LIB9P_ERRNO_L_EREMCHG: + fmt_state_puts(state, "L_EREMCHG"); + break; + case LIB9P_ERRNO_L_ELIBACC: + fmt_state_puts(state, "L_ELIBACC"); + break; + case LIB9P_ERRNO_L_ELIBBAD: + fmt_state_puts(state, "L_ELIBBAD"); + break; + case LIB9P_ERRNO_L_ELIBSCN: + fmt_state_puts(state, "L_ELIBSCN"); + break; + case LIB9P_ERRNO_L_ELIBMAX: + fmt_state_puts(state, "L_ELIBMAX"); + break; + case LIB9P_ERRNO_L_ELIBEXEC: + fmt_state_puts(state, "L_ELIBEXEC"); + break; + case LIB9P_ERRNO_L_EILSEQ: + fmt_state_puts(state, "L_EILSEQ"); + break; + case LIB9P_ERRNO_L_ERESTART: + fmt_state_puts(state, "L_ERESTART"); + break; + case LIB9P_ERRNO_L_ESTRPIPE: + fmt_state_puts(state, "L_ESTRPIPE"); + break; + case LIB9P_ERRNO_L_EUSERS: + fmt_state_puts(state, "L_EUSERS"); + break; + case LIB9P_ERRNO_L_ENOTSOCK: + fmt_state_puts(state, "L_ENOTSOCK"); + break; + case LIB9P_ERRNO_L_EDESTADDRREQ: + fmt_state_puts(state, "L_EDESTADDRREQ"); + break; + case LIB9P_ERRNO_L_EMSGSIZE: + fmt_state_puts(state, "L_EMSGSIZE"); + break; + case LIB9P_ERRNO_L_EPROTOTYPE: + fmt_state_puts(state, "L_EPROTOTYPE"); + break; + case LIB9P_ERRNO_L_ENOPROTOOPT: + fmt_state_puts(state, "L_ENOPROTOOPT"); + break; + case LIB9P_ERRNO_L_EPROTONOSUPPORT: + fmt_state_puts(state, "L_EPROTONOSUPPORT"); + break; + case LIB9P_ERRNO_L_ESOCKTNOSUPPORT: + fmt_state_puts(state, "L_ESOCKTNOSUPPORT"); + break; + case LIB9P_ERRNO_L_EOPNOTSUPP: + fmt_state_puts(state, "L_EOPNOTSUPP"); + break; + case LIB9P_ERRNO_L_EPFNOSUPPORT: + fmt_state_puts(state, "L_EPFNOSUPPORT"); + break; + case LIB9P_ERRNO_L_EAFNOSUPPORT: + fmt_state_puts(state, "L_EAFNOSUPPORT"); + break; + case LIB9P_ERRNO_L_EADDRINUSE: + fmt_state_puts(state, "L_EADDRINUSE"); + break; + case LIB9P_ERRNO_L_EADDRNOTAVAIL: + fmt_state_puts(state, "L_EADDRNOTAVAIL"); + break; + case LIB9P_ERRNO_L_ENETDOWN: + fmt_state_puts(state, "L_ENETDOWN"); + break; + case LIB9P_ERRNO_L_ENETUNREACH: + fmt_state_puts(state, "L_ENETUNREACH"); + break; + case LIB9P_ERRNO_L_ENETRESET: + fmt_state_puts(state, "L_ENETRESET"); + break; + case LIB9P_ERRNO_L_ECONNABORTED: + fmt_state_puts(state, "L_ECONNABORTED"); + break; + case LIB9P_ERRNO_L_ECONNRESET: + fmt_state_puts(state, "L_ECONNRESET"); + break; + case LIB9P_ERRNO_L_ENOBUFS: + fmt_state_puts(state, "L_ENOBUFS"); + break; + case LIB9P_ERRNO_L_EISCONN: + fmt_state_puts(state, "L_EISCONN"); + break; + case LIB9P_ERRNO_L_ENOTCONN: + fmt_state_puts(state, "L_ENOTCONN"); + break; + case LIB9P_ERRNO_L_ESHUTDOWN: + fmt_state_puts(state, "L_ESHUTDOWN"); + break; + case LIB9P_ERRNO_L_ETOOMANYREFS: + fmt_state_puts(state, "L_ETOOMANYREFS"); + break; + case LIB9P_ERRNO_L_ETIMEDOUT: + fmt_state_puts(state, "L_ETIMEDOUT"); + break; + case LIB9P_ERRNO_L_ECONNREFUSED: + fmt_state_puts(state, "L_ECONNREFUSED"); + break; + case LIB9P_ERRNO_L_EHOSTDOWN: + fmt_state_puts(state, "L_EHOSTDOWN"); + break; + case LIB9P_ERRNO_L_EHOSTUNREACH: + fmt_state_puts(state, "L_EHOSTUNREACH"); + break; + case LIB9P_ERRNO_L_EALREADY: + fmt_state_puts(state, "L_EALREADY"); + break; + case LIB9P_ERRNO_L_EINPROGRESS: + fmt_state_puts(state, "L_EINPROGRESS"); + break; + case LIB9P_ERRNO_L_ESTALE: + fmt_state_puts(state, "L_ESTALE"); + break; + case LIB9P_ERRNO_L_EUCLEAN: + fmt_state_puts(state, "L_EUCLEAN"); + break; + case LIB9P_ERRNO_L_ENOTNAM: + fmt_state_puts(state, "L_ENOTNAM"); + break; + case LIB9P_ERRNO_L_ENAVAIL: + fmt_state_puts(state, "L_ENAVAIL"); + break; + case LIB9P_ERRNO_L_EISNAM: + fmt_state_puts(state, "L_EISNAM"); + break; + case LIB9P_ERRNO_L_EREMOTEIO: + fmt_state_puts(state, "L_EREMOTEIO"); + break; + case LIB9P_ERRNO_L_EDQUOT: + fmt_state_puts(state, "L_EDQUOT"); + break; + case LIB9P_ERRNO_L_ENOMEDIUM: + fmt_state_puts(state, "L_ENOMEDIUM"); + break; + case LIB9P_ERRNO_L_EMEDIUMTYPE: + fmt_state_puts(state, "L_EMEDIUMTYPE"); + break; + case LIB9P_ERRNO_L_ECANCELED: + fmt_state_puts(state, "L_ECANCELED"); + break; + case LIB9P_ERRNO_L_ENOKEY: + fmt_state_puts(state, "L_ENOKEY"); + break; + case LIB9P_ERRNO_L_EKEYEXPIRED: + fmt_state_puts(state, "L_EKEYEXPIRED"); + break; + case LIB9P_ERRNO_L_EKEYREVOKED: + fmt_state_puts(state, "L_EKEYREVOKED"); + break; + case LIB9P_ERRNO_L_EKEYREJECTED: + fmt_state_puts(state, "L_EKEYREJECTED"); + break; + case LIB9P_ERRNO_L_EOWNERDEAD: + fmt_state_puts(state, "L_EOWNERDEAD"); + break; + case LIB9P_ERRNO_L_ENOTRECOVERABLE: + fmt_state_puts(state, "L_ENOTRECOVERABLE"); + break; + case LIB9P_ERRNO_L_ERFKILL: + fmt_state_puts(state, "L_ERFKILL"); + break; + case LIB9P_ERRNO_L_EHWPOISON: + fmt_state_puts(state, "L_EHWPOISON"); + break; default: fmt_state_printf(state, "%"PRIu32, *self); } @@ -7341,7 +7736,8 @@ static void lib9p_msg_Tsread_format(struct lib9p_msg_Tsread *self, struct fmt_st fmt_state_puts(state, " wname=["); for (uint16_t i = 0; i < self->nwname; i++) { if (i) - fmt_state_puts(state, ", "); + fmt_state_putchar(state, ','); + fmt_state_putchar(state, ' '); lib9p_s_format(&self->wname[i], state); } fmt_state_puts(state, " ]"); @@ -7380,7 +7776,8 @@ static void lib9p_msg_Tswrite_format(struct lib9p_msg_Tswrite *self, struct fmt_ fmt_state_puts(state, " wname=["); for (uint16_t i = 0; i < self->nwname; i++) { if (i) - fmt_state_puts(state, ", "); + fmt_state_putchar(state, ','); + fmt_state_putchar(state, ' '); lib9p_s_format(&self->wname[i], state); } fmt_state_puts(state, " ]"); diff --git a/lib9p/include/lib9p/9p.generated.h b/lib9p/core_include/lib9p/_core_generated.h index 49b4818..68eb636 100644 --- a/lib9p/include/lib9p/9p.generated.h +++ b/lib9p/core_include/lib9p/_core_generated.h @@ -1,7 +1,7 @@ -/* Generated by `lib9p/proto.gen lib9p/idl/2002-9P2000.9p lib9p/idl/2003-9P2000.p9p.9p lib9p/idl/2005-9P2000.u.9p lib9p/idl/2010-9P2000.L.9p lib9p/idl/2012-9P2000.e.9p`. DO NOT EDIT! */ +/* 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! */ -#ifndef _LIB9P_9P_H_ - #error Do not include <lib9p/9p.generated.h> directly; include <lib9p/9p.h> instead +#ifndef _LIB9P_CORE_H_ + #error Do not include <lib9p/_core_generated.h> directly; include <lib9p/core.h> instead #endif #include <stdint.h> /* for uint{n}_t types */ @@ -174,13 +174,6 @@ 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)) -/* min_size = 2 ; exp_size = 29 ; max_size = 65,537 ; max_iov = 2 ; max_copy = 2 */ -struct lib9p_s { - uint16_t len; - [[gnu::nonstring]] char *utf8; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_s, lib9p_s); - #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 /* size = 4 ; max_iov = 1 ; max_copy = 4 */ @@ -246,13 +239,6 @@ LO_IMPLEMENTATION_H(fmt_formatter, lib9p_qt_t, lib9p_qt); #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 */ -#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u -/* size = 4 ; max_iov = 1 ; max_copy = 4 */ -typedef uint32_t lib9p_nuid_t; -LO_IMPLEMENTATION_H(fmt_formatter, lib9p_nuid_t, lib9p_nuid); -#define LIB9P_NUID_NONUID ((lib9p_nuid_t)(UINT32_MAX)) - -#endif /* CONFIG_9P_ENABLE_9P2000_L || 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 /* size = 1 ; max_iov = 1 ; max_copy = 1 */ typedef uint8_t lib9p_o_t; @@ -278,9 +264,145 @@ LO_IMPLEMENTATION_H(fmt_formatter, lib9p_o_t, lib9p_o); #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 || CONFIG_9P_ENABLE_9P2000_u /* size = 4 ; max_iov = 1 ; max_copy = 4 */ +typedef uint32_t lib9p_nuid_t; +LO_IMPLEMENTATION_H(fmt_formatter, lib9p_nuid_t, lib9p_nuid); +#define LIB9P_NUID_NONUID ((lib9p_nuid_t)(UINT32_MAX)) + +/* size = 4 ; max_iov = 1 ; max_copy = 4 */ typedef uint32_t lib9p_errno_t; LO_IMPLEMENTATION_H(fmt_formatter, lib9p_errno_t, lib9p_errno); -#define LIB9P_ERRNO_NOERROR ((lib9p_errno_t)(0)) +#define LIB9P_ERRNO_NOERROR ((lib9p_errno_t)(0)) +#define LIB9P_ERRNO_L_EPERM ((lib9p_errno_t)(1)) +#define LIB9P_ERRNO_L_ENOENT ((lib9p_errno_t)(2)) +#define LIB9P_ERRNO_L_ESRCH ((lib9p_errno_t)(3)) +#define LIB9P_ERRNO_L_EINTR ((lib9p_errno_t)(4)) +#define LIB9P_ERRNO_L_EIO ((lib9p_errno_t)(5)) +#define LIB9P_ERRNO_L_ENXIO ((lib9p_errno_t)(6)) +#define LIB9P_ERRNO_L_E2BIG ((lib9p_errno_t)(7)) +#define LIB9P_ERRNO_L_ENOEXEC ((lib9p_errno_t)(8)) +#define LIB9P_ERRNO_L_EBADF ((lib9p_errno_t)(9)) +#define LIB9P_ERRNO_L_ECHILD ((lib9p_errno_t)(10)) +#define LIB9P_ERRNO_L_EAGAIN ((lib9p_errno_t)(11)) +#define LIB9P_ERRNO_L_ENOMEM ((lib9p_errno_t)(12)) +#define LIB9P_ERRNO_L_EACCES ((lib9p_errno_t)(13)) +#define LIB9P_ERRNO_L_EFAULT ((lib9p_errno_t)(14)) +#define LIB9P_ERRNO_L_ENOTBLK ((lib9p_errno_t)(15)) +#define LIB9P_ERRNO_L_EBUSY ((lib9p_errno_t)(16)) +#define LIB9P_ERRNO_L_EEXIST ((lib9p_errno_t)(17)) +#define LIB9P_ERRNO_L_EXDEV ((lib9p_errno_t)(18)) +#define LIB9P_ERRNO_L_ENODEV ((lib9p_errno_t)(19)) +#define LIB9P_ERRNO_L_ENOTDIR ((lib9p_errno_t)(20)) +#define LIB9P_ERRNO_L_EISDIR ((lib9p_errno_t)(21)) +#define LIB9P_ERRNO_L_EINVAL ((lib9p_errno_t)(22)) +#define LIB9P_ERRNO_L_ENFILE ((lib9p_errno_t)(23)) +#define LIB9P_ERRNO_L_EMFILE ((lib9p_errno_t)(24)) +#define LIB9P_ERRNO_L_ENOTTY ((lib9p_errno_t)(25)) +#define LIB9P_ERRNO_L_ETXTBSY ((lib9p_errno_t)(26)) +#define LIB9P_ERRNO_L_EFBIG ((lib9p_errno_t)(27)) +#define LIB9P_ERRNO_L_ENOSPC ((lib9p_errno_t)(28)) +#define LIB9P_ERRNO_L_ESPIPE ((lib9p_errno_t)(29)) +#define LIB9P_ERRNO_L_EROFS ((lib9p_errno_t)(30)) +#define LIB9P_ERRNO_L_EMLINK ((lib9p_errno_t)(31)) +#define LIB9P_ERRNO_L_EPIPE ((lib9p_errno_t)(32)) +#define LIB9P_ERRNO_L_EDOM ((lib9p_errno_t)(33)) +#define LIB9P_ERRNO_L_ERANGE ((lib9p_errno_t)(34)) +#define LIB9P_ERRNO_L_EDEADLK ((lib9p_errno_t)(35)) +#define LIB9P_ERRNO_L_ENAMETOOLONG ((lib9p_errno_t)(36)) +#define LIB9P_ERRNO_L_ENOLCK ((lib9p_errno_t)(37)) +#define LIB9P_ERRNO_L_ENOSYS ((lib9p_errno_t)(38)) +#define LIB9P_ERRNO_L_ENOTEMPTY ((lib9p_errno_t)(39)) +#define LIB9P_ERRNO_L_ELOOP ((lib9p_errno_t)(40)) +#define LIB9P_ERRNO_L_ENOMSG ((lib9p_errno_t)(42)) +#define LIB9P_ERRNO_L_EIDRM ((lib9p_errno_t)(43)) +#define LIB9P_ERRNO_L_ECHRNG ((lib9p_errno_t)(44)) +#define LIB9P_ERRNO_L_EL2NSYNC ((lib9p_errno_t)(45)) +#define LIB9P_ERRNO_L_EL3HLT ((lib9p_errno_t)(46)) +#define LIB9P_ERRNO_L_EL3RST ((lib9p_errno_t)(47)) +#define LIB9P_ERRNO_L_ELNRNG ((lib9p_errno_t)(48)) +#define LIB9P_ERRNO_L_EUNATCH ((lib9p_errno_t)(49)) +#define LIB9P_ERRNO_L_ENOCSI ((lib9p_errno_t)(50)) +#define LIB9P_ERRNO_L_EL2HLT ((lib9p_errno_t)(51)) +#define LIB9P_ERRNO_L_EBADE ((lib9p_errno_t)(52)) +#define LIB9P_ERRNO_L_EBADR ((lib9p_errno_t)(53)) +#define LIB9P_ERRNO_L_EXFULL ((lib9p_errno_t)(54)) +#define LIB9P_ERRNO_L_ENOANO ((lib9p_errno_t)(55)) +#define LIB9P_ERRNO_L_EBADRQC ((lib9p_errno_t)(56)) +#define LIB9P_ERRNO_L_EBADSLT ((lib9p_errno_t)(57)) +#define LIB9P_ERRNO_L_EBFONT ((lib9p_errno_t)(59)) +#define LIB9P_ERRNO_L_ENOSTR ((lib9p_errno_t)(60)) +#define LIB9P_ERRNO_L_ENODATA ((lib9p_errno_t)(61)) +#define LIB9P_ERRNO_L_ETIME ((lib9p_errno_t)(62)) +#define LIB9P_ERRNO_L_ENOSR ((lib9p_errno_t)(63)) +#define LIB9P_ERRNO_L_ENONET ((lib9p_errno_t)(64)) +#define LIB9P_ERRNO_L_ENOPKG ((lib9p_errno_t)(65)) +#define LIB9P_ERRNO_L_EREMOTE ((lib9p_errno_t)(66)) +#define LIB9P_ERRNO_L_ENOLINK ((lib9p_errno_t)(67)) +#define LIB9P_ERRNO_L_EADV ((lib9p_errno_t)(68)) +#define LIB9P_ERRNO_L_ESRMNT ((lib9p_errno_t)(69)) +#define LIB9P_ERRNO_L_ECOMM ((lib9p_errno_t)(70)) +#define LIB9P_ERRNO_L_EPROTO ((lib9p_errno_t)(71)) +#define LIB9P_ERRNO_L_EMULTIHOP ((lib9p_errno_t)(72)) +#define LIB9P_ERRNO_L_EDOTDOT ((lib9p_errno_t)(73)) +#define LIB9P_ERRNO_L_EBADMSG ((lib9p_errno_t)(74)) +#define LIB9P_ERRNO_L_EOVERFLOW ((lib9p_errno_t)(75)) +#define LIB9P_ERRNO_L_ENOTUNIQ ((lib9p_errno_t)(76)) +#define LIB9P_ERRNO_L_EBADFD ((lib9p_errno_t)(77)) +#define LIB9P_ERRNO_L_EREMCHG ((lib9p_errno_t)(78)) +#define LIB9P_ERRNO_L_ELIBACC ((lib9p_errno_t)(79)) +#define LIB9P_ERRNO_L_ELIBBAD ((lib9p_errno_t)(80)) +#define LIB9P_ERRNO_L_ELIBSCN ((lib9p_errno_t)(81)) +#define LIB9P_ERRNO_L_ELIBMAX ((lib9p_errno_t)(82)) +#define LIB9P_ERRNO_L_ELIBEXEC ((lib9p_errno_t)(83)) +#define LIB9P_ERRNO_L_EILSEQ ((lib9p_errno_t)(84)) +#define LIB9P_ERRNO_L_ERESTART ((lib9p_errno_t)(85)) +#define LIB9P_ERRNO_L_ESTRPIPE ((lib9p_errno_t)(86)) +#define LIB9P_ERRNO_L_EUSERS ((lib9p_errno_t)(87)) +#define LIB9P_ERRNO_L_ENOTSOCK ((lib9p_errno_t)(88)) +#define LIB9P_ERRNO_L_EDESTADDRREQ ((lib9p_errno_t)(89)) +#define LIB9P_ERRNO_L_EMSGSIZE ((lib9p_errno_t)(90)) +#define LIB9P_ERRNO_L_EPROTOTYPE ((lib9p_errno_t)(91)) +#define LIB9P_ERRNO_L_ENOPROTOOPT ((lib9p_errno_t)(92)) +#define LIB9P_ERRNO_L_EPROTONOSUPPORT ((lib9p_errno_t)(93)) +#define LIB9P_ERRNO_L_ESOCKTNOSUPPORT ((lib9p_errno_t)(94)) +#define LIB9P_ERRNO_L_EOPNOTSUPP ((lib9p_errno_t)(95)) +#define LIB9P_ERRNO_L_EPFNOSUPPORT ((lib9p_errno_t)(96)) +#define LIB9P_ERRNO_L_EAFNOSUPPORT ((lib9p_errno_t)(97)) +#define LIB9P_ERRNO_L_EADDRINUSE ((lib9p_errno_t)(98)) +#define LIB9P_ERRNO_L_EADDRNOTAVAIL ((lib9p_errno_t)(99)) +#define LIB9P_ERRNO_L_ENETDOWN ((lib9p_errno_t)(100)) +#define LIB9P_ERRNO_L_ENETUNREACH ((lib9p_errno_t)(101)) +#define LIB9P_ERRNO_L_ENETRESET ((lib9p_errno_t)(102)) +#define LIB9P_ERRNO_L_ECONNABORTED ((lib9p_errno_t)(103)) +#define LIB9P_ERRNO_L_ECONNRESET ((lib9p_errno_t)(104)) +#define LIB9P_ERRNO_L_ENOBUFS ((lib9p_errno_t)(105)) +#define LIB9P_ERRNO_L_EISCONN ((lib9p_errno_t)(106)) +#define LIB9P_ERRNO_L_ENOTCONN ((lib9p_errno_t)(107)) +#define LIB9P_ERRNO_L_ESHUTDOWN ((lib9p_errno_t)(108)) +#define LIB9P_ERRNO_L_ETOOMANYREFS ((lib9p_errno_t)(109)) +#define LIB9P_ERRNO_L_ETIMEDOUT ((lib9p_errno_t)(110)) +#define LIB9P_ERRNO_L_ECONNREFUSED ((lib9p_errno_t)(111)) +#define LIB9P_ERRNO_L_EHOSTDOWN ((lib9p_errno_t)(112)) +#define LIB9P_ERRNO_L_EHOSTUNREACH ((lib9p_errno_t)(113)) +#define LIB9P_ERRNO_L_EALREADY ((lib9p_errno_t)(114)) +#define LIB9P_ERRNO_L_EINPROGRESS ((lib9p_errno_t)(115)) +#define LIB9P_ERRNO_L_ESTALE ((lib9p_errno_t)(116)) +#define LIB9P_ERRNO_L_EUCLEAN ((lib9p_errno_t)(117)) +#define LIB9P_ERRNO_L_ENOTNAM ((lib9p_errno_t)(118)) +#define LIB9P_ERRNO_L_ENAVAIL ((lib9p_errno_t)(119)) +#define LIB9P_ERRNO_L_EISNAM ((lib9p_errno_t)(120)) +#define LIB9P_ERRNO_L_EREMOTEIO ((lib9p_errno_t)(121)) +#define LIB9P_ERRNO_L_EDQUOT ((lib9p_errno_t)(122)) +#define LIB9P_ERRNO_L_ENOMEDIUM ((lib9p_errno_t)(123)) +#define LIB9P_ERRNO_L_EMEDIUMTYPE ((lib9p_errno_t)(124)) +#define LIB9P_ERRNO_L_ECANCELED ((lib9p_errno_t)(125)) +#define LIB9P_ERRNO_L_ENOKEY ((lib9p_errno_t)(126)) +#define LIB9P_ERRNO_L_EKEYEXPIRED ((lib9p_errno_t)(127)) +#define LIB9P_ERRNO_L_EKEYREVOKED ((lib9p_errno_t)(128)) +#define LIB9P_ERRNO_L_EKEYREJECTED ((lib9p_errno_t)(129)) +#define LIB9P_ERRNO_L_EOWNERDEAD ((lib9p_errno_t)(130)) +#define LIB9P_ERRNO_L_ENOTRECOVERABLE ((lib9p_errno_t)(131)) +#define LIB9P_ERRNO_L_ERFKILL ((lib9p_errno_t)(132)) +#define LIB9P_ERRNO_L_EHWPOISON ((lib9p_errno_t)(133)) #endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ #if CONFIG_9P_ENABLE_9P2000_L @@ -564,6 +686,21 @@ LO_IMPLEMENTATION_H(fmt_formatter, lib9p_lock_status_t, lib9p_lock_status); #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 +/* min_size = 2 ; exp_size = 29 ; max_size = 65,537 ; max_iov = 2 ; max_copy = 2 */ +struct lib9p_s { + uint16_t len; + [[gnu::nonstring]] char *utf8; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_s, lib9p_s); + +/* size = 13 ; max_iov = 1 ; max_copy = 13 */ +struct lib9p_qid { + lib9p_qt_t type; + uint32_t vers; + uint64_t path; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_qid, lib9p_qid); + /* size = 9 ; max_iov = 1 ; max_copy = 9 */ struct lib9p_msg_Tflush { lib9p_tag_t tag; @@ -577,6 +714,27 @@ struct lib9p_msg_Rflush { }; LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rflush, lib9p_msg_Rflush); +#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 +/* size = 12 ; max_iov = 1 ; max_copy = 12 */ +struct lib9p_msg_Topen { + lib9p_tag_t tag; + lib9p_fid_t fid; + lib9p_o_t mode; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Topen, lib9p_msg_Topen); + +#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 +/* size = 23 ; max_iov = 1 ; max_copy = 23 */ +struct lib9p_msg_Tread { + lib9p_tag_t tag; + lib9p_fid_t fid; + uint64_t offset; + uint32_t count; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tread, lib9p_msg_Tread); + /* min_size = 11 ; exp_size = 8,203 ; max_size = 2,147,483,658 ; max_iov = 2 ; max_copy = 11 */ struct lib9p_msg_Rread { lib9p_tag_t tag; @@ -585,6 +743,16 @@ struct lib9p_msg_Rread { }; LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rread, lib9p_msg_Rread); +/* min_size = 23 ; exp_size = 8,215 ; max_size = 2,147,483,670 ; max_iov = 2 ; max_copy = 23 */ +struct lib9p_msg_Twrite { + lib9p_tag_t tag; + lib9p_fid_t fid; + uint64_t offset; + uint32_t count; + [[gnu::nonstring]] char *data; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Twrite, lib9p_msg_Twrite); + /* size = 11 ; max_iov = 1 ; max_copy = 11 */ struct lib9p_msg_Rwrite { lib9p_tag_t tag; @@ -592,12 +760,26 @@ struct lib9p_msg_Rwrite { }; LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rwrite, lib9p_msg_Rwrite); +/* size = 11 ; max_iov = 1 ; max_copy = 11 */ +struct lib9p_msg_Tclunk { + lib9p_tag_t tag; + lib9p_fid_t fid; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tclunk, lib9p_msg_Tclunk); + /* size = 7 ; max_iov = 1 ; max_copy = 7 */ struct lib9p_msg_Rclunk { lib9p_tag_t tag; }; LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rclunk, lib9p_msg_Rclunk); +/* size = 11 ; max_iov = 1 ; max_copy = 11 */ +struct lib9p_msg_Tremove { + lib9p_tag_t tag; + lib9p_fid_t fid; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tremove, lib9p_msg_Tremove); + /* size = 7 ; max_iov = 1 ; max_copy = 7 */ struct lib9p_msg_Rremove { lib9p_tag_t tag; @@ -606,6 +788,13 @@ LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rremove, lib9p_msg_Rremove); #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 +/* size = 11 ; max_iov = 1 ; max_copy = 11 */ +struct lib9p_msg_Tstat { + lib9p_tag_t tag; + lib9p_fid_t fid; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tstat, lib9p_msg_Tstat); + /* size = 7 ; max_iov = 1 ; max_copy = 7 */ struct lib9p_msg_Rwstat { lib9p_tag_t tag; @@ -613,13 +802,91 @@ struct lib9p_msg_Rwstat { LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rwstat, lib9p_msg_Rwstat); #endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_9P2000_p9p +/* size = 12 ; max_iov = 1 ; max_copy = 12 */ +struct lib9p_msg_Topenfd { + lib9p_tag_t tag; + lib9p_fid_t fid; + lib9p_o_t mode; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Topenfd, lib9p_msg_Topenfd); + +#endif /* CONFIG_9P_ENABLE_9P2000_p9p */ #if CONFIG_9P_ENABLE_9P2000_L +/* size = 11 ; max_iov = 1 ; max_copy = 11 */ +struct lib9p_msg_Rlerror { + lib9p_tag_t tag; + lib9p_errno_t errnum; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rlerror, lib9p_msg_Rlerror); + +/* size = 11 ; max_iov = 1 ; max_copy = 11 */ +struct lib9p_msg_Tstatfs { + lib9p_tag_t tag; + lib9p_fid_t fid; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tstatfs, lib9p_msg_Tstatfs); + +/* size = 67 ; max_iov = 1 ; max_copy = 67 */ +struct lib9p_msg_Rstatfs { + lib9p_tag_t tag; + lib9p_super_magic_t type; + uint32_t bsize; + uint64_t blocks; + uint64_t bfree; + uint64_t bavail; + uint64_t files; + uint64_t ffree; + uint64_t fsid; + uint32_t namelen; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rstatfs, lib9p_msg_Rstatfs); + +/* size = 15 ; max_iov = 1 ; max_copy = 15 */ +struct lib9p_msg_Tlopen { + lib9p_tag_t tag; + lib9p_fid_t fid; + lib9p_lo_t flags; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tlopen, lib9p_msg_Tlopen); + /* size = 7 ; max_iov = 1 ; max_copy = 7 */ struct lib9p_msg_Rrename { lib9p_tag_t tag; }; LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rrename, lib9p_msg_Rrename); +/* size = 11 ; max_iov = 1 ; max_copy = 11 */ +struct lib9p_msg_Treadlink { + lib9p_tag_t tag; + lib9p_fid_t fid; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Treadlink, lib9p_msg_Treadlink); + +/* size = 19 ; max_iov = 1 ; max_copy = 19 */ +struct lib9p_msg_Tgetattr { + lib9p_tag_t tag; + lib9p_fid_t fid; + lib9p_getattr_t request_mask; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tgetattr, lib9p_msg_Tgetattr); + +/* size = 67 ; max_iov = 1 ; max_copy = 67 */ +struct lib9p_msg_Tsetattr { + lib9p_tag_t tag; + lib9p_fid_t fid; + lib9p_setattr_t valid; + lib9p_mode_t mode; + lib9p_nuid_t uid; + lib9p_nuid_t gid; + uint64_t filesize; + uint64_t atime_sec; + uint64_t atime_nsec; + uint64_t mtime_sec; + uint64_t mtime_nsec; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tsetattr, lib9p_msg_Tsetattr); + /* size = 7 ; max_iov = 1 ; max_copy = 7 */ struct lib9p_msg_Rsetattr { lib9p_tag_t tag; @@ -639,6 +906,15 @@ struct lib9p_msg_Rxattrcreate { }; LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rxattrcreate, lib9p_msg_Rxattrcreate); +/* size = 23 ; max_iov = 1 ; max_copy = 23 */ +struct lib9p_msg_Treaddir { + lib9p_tag_t tag; + lib9p_fid_t fid; + uint64_t offset; + uint32_t count; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Treaddir, lib9p_msg_Treaddir); + /* min_size = 11 ; exp_size = 8,203 ; max_size = 4,294,967,306 (warning: >UINT32_MAX) ; max_iov = 2 ; max_copy = 11 */ struct lib9p_msg_Rreaddir { lib9p_tag_t tag; @@ -647,12 +923,27 @@ struct lib9p_msg_Rreaddir { }; LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rreaddir, lib9p_msg_Rreaddir); +/* size = 15 ; max_iov = 1 ; max_copy = 15 */ +struct lib9p_msg_Tfsync { + lib9p_tag_t tag; + lib9p_fid_t fid; + lib9p_b4_t datasync; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tfsync, lib9p_msg_Tfsync); + /* size = 7 ; max_iov = 1 ; max_copy = 7 */ struct lib9p_msg_Rfsync { lib9p_tag_t tag; }; LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rfsync, lib9p_msg_Rfsync); +/* size = 8 ; max_iov = 1 ; max_copy = 8 */ +struct lib9p_msg_Rlock { + lib9p_tag_t tag; + lib9p_lock_status_t status; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rlock, lib9p_msg_Rlock); + /* size = 7 ; max_iov = 1 ; max_copy = 7 */ struct lib9p_msg_Rlink { lib9p_tag_t tag; @@ -702,75 +993,33 @@ struct lib9p_msg_Rswrite { LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rswrite, lib9p_msg_Rswrite); #endif /* CONFIG_9P_ENABLE_9P2000_e */ -#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 = 23 ; max_iov = 1 ; max_copy = 23 */ -struct lib9p_msg_Tread { - lib9p_tag_t tag; - lib9p_fid_t fid; - uint64_t offset; - uint32_t count; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tread, lib9p_msg_Tread); - -/* min_size = 23 ; exp_size = 8,215 ; max_size = 2,147,483,670 ; max_iov = 2 ; max_copy = 23 */ -struct lib9p_msg_Twrite { - lib9p_tag_t tag; - lib9p_fid_t fid; - uint64_t offset; - uint32_t count; - [[gnu::nonstring]] char *data; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Twrite, lib9p_msg_Twrite); - -/* size = 11 ; max_iov = 1 ; max_copy = 11 */ -struct lib9p_msg_Tclunk { - lib9p_tag_t tag; - lib9p_fid_t fid; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tclunk, lib9p_msg_Tclunk); - -/* size = 11 ; max_iov = 1 ; max_copy = 11 */ -struct lib9p_msg_Tremove { - lib9p_tag_t tag; - lib9p_fid_t fid; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tremove, lib9p_msg_Tremove); - -#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 -/* size = 11 ; max_iov = 1 ; max_copy = 11 */ -struct lib9p_msg_Tstat { - lib9p_tag_t tag; - lib9p_fid_t fid; +/* LIB9P_VER_9P2000 : min_size = 49 ; exp_size = 157 ; max_size = 262,189 ; max_iov = 8 ; max_copy = 49 */ +/* LIB9P_VER_9P2000_e : min_size = 49 ; exp_size = 157 ; max_size = 262,189 ; max_iov = 8 ; max_copy = 49 */ +/* 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; +#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; +#endif /* CONFIG_9P_ENABLE_9P2000_u */ }; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tstat, lib9p_msg_Tstat); +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_L -/* size = 11 ; max_iov = 1 ; max_copy = 11 */ -struct lib9p_msg_Tstatfs { - lib9p_tag_t tag; - lib9p_fid_t fid; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tstatfs, lib9p_msg_Tstatfs); - -/* size = 11 ; max_iov = 1 ; max_copy = 11 */ -struct lib9p_msg_Treadlink { - lib9p_tag_t tag; - lib9p_fid_t fid; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Treadlink, lib9p_msg_Treadlink); - -/* size = 23 ; max_iov = 1 ; max_copy = 23 */ -struct lib9p_msg_Treaddir { - lib9p_tag_t tag; - lib9p_fid_t fid; - uint64_t offset; - uint32_t count; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Treaddir, lib9p_msg_Treaddir); - -#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 /* min_size = 13 ; exp_size = 40 ; max_size = 65,548 ; max_iov = 2 ; max_copy = 13 */ struct lib9p_msg_Tversion { @@ -788,113 +1037,6 @@ struct lib9p_msg_Rversion { }; LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rversion, lib9p_msg_Rversion); -/* min_size = 17 ; exp_size = 481 ; max_size = 1,048,609 ; max_iov = 32 ; max_copy = 49 */ -struct lib9p_msg_Twalk { - lib9p_tag_t tag; - lib9p_fid_t fid; - lib9p_fid_t newfid; - uint16_t nwname; - struct lib9p_s *wname; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Twalk, lib9p_msg_Twalk); - -#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_L -/* min_size = 17 ; exp_size = 44 ; max_size = 65,552 ; max_iov = 2 ; max_copy = 17 */ -struct lib9p_msg_Trename { - lib9p_tag_t tag; - lib9p_fid_t fid; - lib9p_fid_t dfid; - struct lib9p_s name; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Trename, lib9p_msg_Trename); - -/* min_size = 9 ; exp_size = 36 ; max_size = 65,544 ; max_iov = 2 ; max_copy = 9 */ -struct lib9p_msg_Rreadlink { - lib9p_tag_t tag; - struct lib9p_s target; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rreadlink, lib9p_msg_Rreadlink); - -/* min_size = 17 ; exp_size = 44 ; max_size = 65,552 ; max_iov = 2 ; max_copy = 17 */ -struct lib9p_msg_Txattrwalk { - lib9p_tag_t tag; - lib9p_fid_t fid; - lib9p_fid_t newfid; - struct lib9p_s name; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Txattrwalk, lib9p_msg_Txattrwalk); - -/* min_size = 25 ; exp_size = 52 ; max_size = 65,560 ; max_iov = 3 ; max_copy = 25 */ -struct lib9p_msg_Txattrcreate { - lib9p_tag_t tag; - lib9p_fid_t fid; - struct lib9p_s name; - uint64_t attr_size; - uint32_t flags; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Txattrcreate, lib9p_msg_Txattrcreate); - -/* min_size = 17 ; exp_size = 44 ; max_size = 65,552 ; max_iov = 2 ; max_copy = 17 */ -struct lib9p_msg_Tlink { - lib9p_tag_t tag; - lib9p_fid_t dfid; - lib9p_fid_t fid; - struct lib9p_s name; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tlink, lib9p_msg_Tlink); - -/* min_size = 19 ; exp_size = 73 ; max_size = 131,089 ; max_iov = 4 ; max_copy = 19 */ -struct lib9p_msg_Trenameat { - lib9p_tag_t tag; - lib9p_fid_t olddirfid; - struct lib9p_s oldname; - lib9p_fid_t newdirfid; - struct lib9p_s newname; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Trenameat, lib9p_msg_Trenameat); - -/* min_size = 17 ; exp_size = 44 ; max_size = 65,552 ; max_iov = 3 ; max_copy = 17 */ -struct lib9p_msg_Tunlinkat { - lib9p_tag_t tag; - lib9p_fid_t dirfd; - struct lib9p_s name; - uint32_t flags; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tunlinkat, lib9p_msg_Tunlinkat); - -#endif /* CONFIG_9P_ENABLE_9P2000_L */ -#if CONFIG_9P_ENABLE_9P2000_e -/* min_size = 13 ; exp_size = 477 ; max_size = 4,294,967,308 (warning: >UINT32_MAX) ; max_iov = 0 + (CONFIG_9P_MAX_9P2000_e_WELEM * 2) ; max_copy = 13 + (CONFIG_9P_MAX_9P2000_e_WELEM * 2) */ -struct lib9p_msg_Tsread { - lib9p_tag_t tag; - uint32_t fid; - uint16_t nwname; - struct lib9p_s *wname; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tsread, lib9p_msg_Tsread); - -/* min_size = 17 ; exp_size = 8,673 ; max_size = 8,589,934,607 (warning: >UINT32_MAX) ; max_iov = 2 + (CONFIG_9P_MAX_9P2000_e_WELEM * 2) ; max_copy = 17 + (CONFIG_9P_MAX_9P2000_e_WELEM * 2) */ -struct lib9p_msg_Tswrite { - lib9p_tag_t tag; - uint32_t fid; - uint16_t nwname; - struct lib9p_s *wname; - uint32_t count; - [[gnu::nonstring]] char *data; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tswrite, lib9p_msg_Tswrite); - -#endif /* CONFIG_9P_ENABLE_9P2000_e */ -#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 = 13 ; max_iov = 1 ; max_copy = 13 */ -struct lib9p_qid { - lib9p_qt_t type; - uint32_t vers; - uint64_t path; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_qid, lib9p_qid); - /* 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 */ @@ -911,6 +1053,13 @@ struct lib9p_msg_Tauth { }; LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tauth, lib9p_msg_Tauth); +/* size = 20 ; max_iov = 1 ; max_copy = 20 */ +struct lib9p_msg_Rauth { + lib9p_tag_t tag; + struct lib9p_qid aqid; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rauth, lib9p_msg_Rauth); + /* LIB9P_VER_9P2000 : min_size = 19 ; exp_size = 73 ; max_size = 131,089 ; max_iov = 4 ; max_copy = 19 */ /* LIB9P_VER_9P2000_L : min_size = 23 ; exp_size = 77 ; max_size = 131,093 ; max_iov = 5 ; max_copy = 23 */ /* LIB9P_VER_9P2000_e : min_size = 19 ; exp_size = 73 ; max_size = 131,089 ; max_iov = 4 ; max_copy = 19 */ @@ -928,49 +1077,14 @@ struct lib9p_msg_Tattach { }; LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tattach, lib9p_msg_Tattach); -#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_L -/* min_size = 19 ; exp_size = 73 ; max_size = 131,089 ; max_iov = 5 ; max_copy = 19 */ -struct lib9p_msg_Tsymlink { - lib9p_tag_t tag; - lib9p_fid_t fid; - struct lib9p_s name; - struct lib9p_s symtgt; - lib9p_nuid_t gid; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tsymlink, lib9p_msg_Tsymlink); - -#endif /* CONFIG_9P_ENABLE_9P2000_L */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -/* size = 12 ; max_iov = 1 ; max_copy = 12 */ -struct lib9p_msg_Topen { - lib9p_tag_t tag; - lib9p_fid_t fid; - lib9p_o_t mode; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Topen, lib9p_msg_Topen); - -/* min_size = 18 ; exp_size = 45 ; max_size = 65,553 ; max_iov = 3 ; max_copy = 18 */ -struct lib9p_msg_Tcreate { - lib9p_tag_t tag; - lib9p_fid_t fid; - struct lib9p_s name; - lib9p_dm_t perm; - lib9p_o_t mode; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tcreate, lib9p_msg_Tcreate); - -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000_p9p -/* size = 12 ; max_iov = 1 ; max_copy = 12 */ -struct lib9p_msg_Topenfd { - lib9p_tag_t tag; - lib9p_fid_t fid; - lib9p_o_t mode; +/* size = 20 ; max_iov = 1 ; max_copy = 20 */ +struct lib9p_msg_Rattach { + lib9p_tag_t tag; + struct lib9p_qid qid; }; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Topenfd, lib9p_msg_Topenfd); +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rattach, lib9p_msg_Rattach); -#endif /* CONFIG_9P_ENABLE_9P2000_p9p */ +#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 */ @@ -986,187 +1100,16 @@ 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 */ -#if CONFIG_9P_ENABLE_9P2000_L -/* size = 11 ; max_iov = 1 ; max_copy = 11 */ -struct lib9p_msg_Rlerror { - lib9p_tag_t tag; - lib9p_errno_t errnum; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rlerror, lib9p_msg_Rlerror); - -/* size = 67 ; max_iov = 1 ; max_copy = 67 */ -struct lib9p_msg_Rstatfs { - lib9p_tag_t tag; - lib9p_super_magic_t type; - uint32_t bsize; - uint64_t blocks; - uint64_t bfree; - uint64_t bavail; - uint64_t files; - uint64_t ffree; - uint64_t fsid; - uint32_t namelen; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rstatfs, lib9p_msg_Rstatfs); - -/* size = 15 ; max_iov = 1 ; max_copy = 15 */ -struct lib9p_msg_Tlopen { - lib9p_tag_t tag; - lib9p_fid_t fid; - lib9p_lo_t flags; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tlopen, lib9p_msg_Tlopen); - -/* min_size = 25 ; exp_size = 52 ; max_size = 65,560 ; max_iov = 3 ; max_copy = 25 */ -struct lib9p_msg_Tlcreate { +#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 { lib9p_tag_t tag; lib9p_fid_t fid; - struct lib9p_s name; - lib9p_lo_t flags; - lib9p_mode_t mode; - lib9p_nuid_t gid; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tlcreate, lib9p_msg_Tlcreate); - -/* min_size = 29 ; exp_size = 56 ; max_size = 65,564 ; max_iov = 3 ; max_copy = 29 */ -struct lib9p_msg_Tmknod { - lib9p_tag_t tag; - lib9p_fid_t dfid; - struct lib9p_s name; - lib9p_mode_t mode; - uint32_t major; - uint32_t minor; - lib9p_nuid_t gid; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tmknod, lib9p_msg_Tmknod); - -/* min_size = 21 ; exp_size = 48 ; max_size = 65,556 ; max_iov = 3 ; max_copy = 21 */ -struct lib9p_msg_Tmkdir { - lib9p_tag_t tag; - lib9p_fid_t dfid; - struct lib9p_s name; - lib9p_mode_t mode; - lib9p_nuid_t gid; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tmkdir, lib9p_msg_Tmkdir); - -/* size = 15 ; max_iov = 1 ; max_copy = 15 */ -struct lib9p_msg_Tfsync { - lib9p_tag_t tag; - lib9p_fid_t fid; - lib9p_b4_t datasync; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tfsync, lib9p_msg_Tfsync); - -/* size = 19 ; max_iov = 1 ; max_copy = 19 */ -struct lib9p_msg_Tgetattr { - lib9p_tag_t tag; - lib9p_fid_t fid; - lib9p_getattr_t request_mask; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tgetattr, lib9p_msg_Tgetattr); - -/* size = 67 ; max_iov = 1 ; max_copy = 67 */ -struct lib9p_msg_Tsetattr { - lib9p_tag_t tag; - lib9p_fid_t fid; - lib9p_setattr_t valid; - lib9p_mode_t mode; - lib9p_nuid_t uid; - lib9p_nuid_t gid; - uint64_t filesize; - uint64_t atime_sec; - uint64_t atime_nsec; - uint64_t mtime_sec; - uint64_t mtime_nsec; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tsetattr, lib9p_msg_Tsetattr); - -/* min_size = 34 ; exp_size = 61 ; max_size = 65,569 ; max_iov = 2 ; max_copy = 34 */ -struct lib9p_msg_Tgetlock { - lib9p_tag_t tag; - lib9p_fid_t fid; - lib9p_lock_type_t type; - uint64_t start; - uint64_t length; - uint32_t proc_id; - struct lib9p_s client_id; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tgetlock, lib9p_msg_Tgetlock); - -/* min_size = 30 ; exp_size = 57 ; max_size = 65,565 ; max_iov = 2 ; max_copy = 30 */ -struct lib9p_msg_Rgetlock { - lib9p_tag_t tag; - lib9p_lock_type_t type; - uint64_t start; - uint64_t length; - uint32_t proc_id; - struct lib9p_s client_id; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rgetlock, lib9p_msg_Rgetlock); - -/* min_size = 38 ; exp_size = 65 ; max_size = 65,573 ; max_iov = 2 ; max_copy = 38 */ -struct lib9p_msg_Tlock { - lib9p_tag_t tag; - lib9p_fid_t fid; - lib9p_lock_type_t type; - lib9p_lock_flags_t flags; - uint64_t start; - uint64_t length; - uint32_t proc_id; - struct lib9p_s client_id; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tlock, lib9p_msg_Tlock); - -/* size = 8 ; max_iov = 1 ; max_copy = 8 */ -struct lib9p_msg_Rlock { - lib9p_tag_t tag; - lib9p_lock_status_t status; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rlock, lib9p_msg_Rlock); - -#endif /* CONFIG_9P_ENABLE_9P2000_L */ -#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 = 49 ; exp_size = 157 ; max_size = 262,189 ; max_iov = 8 ; max_copy = 49 */ -/* LIB9P_VER_9P2000_e : min_size = 49 ; exp_size = 157 ; max_size = 262,189 ; max_iov = 8 ; max_copy = 49 */ -/* 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; -#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; -#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 -/* size = 20 ; max_iov = 1 ; max_copy = 20 */ -struct lib9p_msg_Rauth { - lib9p_tag_t tag; - struct lib9p_qid aqid; -}; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rauth, lib9p_msg_Rauth); - -/* size = 20 ; max_iov = 1 ; max_copy = 20 */ -struct lib9p_msg_Rattach { - lib9p_tag_t tag; - struct lib9p_qid qid; + lib9p_fid_t newfid; + uint16_t nwname; + struct lib9p_s *wname; }; -LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rattach, lib9p_msg_Rattach); +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Twalk, lib9p_msg_Twalk); /* min_size = 9 ; exp_size = 217 ; max_size = 217 ; max_iov = 1 ; max_copy = 217 */ struct lib9p_msg_Rwalk { @@ -1186,6 +1129,16 @@ struct lib9p_msg_Ropen { }; LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Ropen, lib9p_msg_Ropen); +/* min_size = 18 ; exp_size = 45 ; max_size = 65,553 ; max_iov = 3 ; max_copy = 18 */ +struct lib9p_msg_Tcreate { + lib9p_tag_t tag; + lib9p_fid_t fid; + struct lib9p_s name; + lib9p_dm_t perm; + lib9p_o_t mode; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tcreate, lib9p_msg_Tcreate); + /* size = 24 ; max_iov = 1 ; max_copy = 24 */ struct lib9p_msg_Rcreate { lib9p_tag_t tag; @@ -1215,6 +1168,17 @@ struct lib9p_msg_Rlopen { }; LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rlopen, lib9p_msg_Rlopen); +/* min_size = 25 ; exp_size = 52 ; max_size = 65,560 ; max_iov = 3 ; max_copy = 25 */ +struct lib9p_msg_Tlcreate { + lib9p_tag_t tag; + lib9p_fid_t fid; + struct lib9p_s name; + lib9p_lo_t flags; + lib9p_mode_t mode; + lib9p_nuid_t gid; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tlcreate, lib9p_msg_Tlcreate); + /* size = 24 ; max_iov = 1 ; max_copy = 24 */ struct lib9p_msg_Rlcreate { lib9p_tag_t tag; @@ -1223,6 +1187,16 @@ struct lib9p_msg_Rlcreate { }; LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rlcreate, lib9p_msg_Rlcreate); +/* min_size = 19 ; exp_size = 73 ; max_size = 131,089 ; max_iov = 5 ; max_copy = 19 */ +struct lib9p_msg_Tsymlink { + lib9p_tag_t tag; + lib9p_fid_t fid; + struct lib9p_s name; + struct lib9p_s symtgt; + lib9p_nuid_t gid; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tsymlink, lib9p_msg_Tsymlink); + /* size = 20 ; max_iov = 1 ; max_copy = 20 */ struct lib9p_msg_Rsymlink { lib9p_tag_t tag; @@ -1230,6 +1204,18 @@ struct lib9p_msg_Rsymlink { }; LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rsymlink, lib9p_msg_Rsymlink); +/* min_size = 29 ; exp_size = 56 ; max_size = 65,564 ; max_iov = 3 ; max_copy = 29 */ +struct lib9p_msg_Tmknod { + lib9p_tag_t tag; + lib9p_fid_t dfid; + struct lib9p_s name; + lib9p_mode_t mode; + uint32_t major; + uint32_t minor; + lib9p_nuid_t gid; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tmknod, lib9p_msg_Tmknod); + /* size = 20 ; max_iov = 1 ; max_copy = 20 */ struct lib9p_msg_Rmknod { lib9p_tag_t tag; @@ -1237,6 +1223,22 @@ struct lib9p_msg_Rmknod { }; LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rmknod, lib9p_msg_Rmknod); +/* min_size = 17 ; exp_size = 44 ; max_size = 65,552 ; max_iov = 2 ; max_copy = 17 */ +struct lib9p_msg_Trename { + lib9p_tag_t tag; + lib9p_fid_t fid; + lib9p_fid_t dfid; + struct lib9p_s name; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Trename, lib9p_msg_Trename); + +/* min_size = 9 ; exp_size = 36 ; max_size = 65,544 ; max_iov = 2 ; max_copy = 9 */ +struct lib9p_msg_Rreadlink { + lib9p_tag_t tag; + struct lib9p_s target; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rreadlink, lib9p_msg_Rreadlink); + /* size = 160 ; max_iov = 1 ; max_copy = 160 */ struct lib9p_msg_Rgetattr { lib9p_tag_t tag; @@ -1263,6 +1265,80 @@ struct lib9p_msg_Rgetattr { }; LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rgetattr, lib9p_msg_Rgetattr); +/* min_size = 17 ; exp_size = 44 ; max_size = 65,552 ; max_iov = 2 ; max_copy = 17 */ +struct lib9p_msg_Txattrwalk { + lib9p_tag_t tag; + lib9p_fid_t fid; + lib9p_fid_t newfid; + struct lib9p_s name; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Txattrwalk, lib9p_msg_Txattrwalk); + +/* min_size = 25 ; exp_size = 52 ; max_size = 65,560 ; max_iov = 3 ; max_copy = 25 */ +struct lib9p_msg_Txattrcreate { + lib9p_tag_t tag; + lib9p_fid_t fid; + struct lib9p_s name; + uint64_t attr_size; + uint32_t flags; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Txattrcreate, lib9p_msg_Txattrcreate); + +/* min_size = 38 ; exp_size = 65 ; max_size = 65,573 ; max_iov = 2 ; max_copy = 38 */ +struct lib9p_msg_Tlock { + lib9p_tag_t tag; + lib9p_fid_t fid; + lib9p_lock_type_t type; + lib9p_lock_flags_t flags; + uint64_t start; + uint64_t length; + uint32_t proc_id; + struct lib9p_s client_id; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tlock, lib9p_msg_Tlock); + +/* min_size = 34 ; exp_size = 61 ; max_size = 65,569 ; max_iov = 2 ; max_copy = 34 */ +struct lib9p_msg_Tgetlock { + lib9p_tag_t tag; + lib9p_fid_t fid; + lib9p_lock_type_t type; + uint64_t start; + uint64_t length; + uint32_t proc_id; + struct lib9p_s client_id; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tgetlock, lib9p_msg_Tgetlock); + +/* min_size = 30 ; exp_size = 57 ; max_size = 65,565 ; max_iov = 2 ; max_copy = 30 */ +struct lib9p_msg_Rgetlock { + lib9p_tag_t tag; + lib9p_lock_type_t type; + uint64_t start; + uint64_t length; + uint32_t proc_id; + struct lib9p_s client_id; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rgetlock, lib9p_msg_Rgetlock); + +/* min_size = 17 ; exp_size = 44 ; max_size = 65,552 ; max_iov = 2 ; max_copy = 17 */ +struct lib9p_msg_Tlink { + lib9p_tag_t tag; + lib9p_fid_t dfid; + lib9p_fid_t fid; + struct lib9p_s name; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tlink, lib9p_msg_Tlink); + +/* min_size = 21 ; exp_size = 48 ; max_size = 65,556 ; max_iov = 3 ; max_copy = 21 */ +struct lib9p_msg_Tmkdir { + lib9p_tag_t tag; + lib9p_fid_t dfid; + struct lib9p_s name; + lib9p_mode_t mode; + lib9p_nuid_t gid; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tmkdir, lib9p_msg_Tmkdir); + /* size = 20 ; max_iov = 1 ; max_copy = 20 */ struct lib9p_msg_Rmkdir { lib9p_tag_t tag; @@ -1270,7 +1346,48 @@ struct lib9p_msg_Rmkdir { }; LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rmkdir, lib9p_msg_Rmkdir); +/* min_size = 19 ; exp_size = 73 ; max_size = 131,089 ; max_iov = 4 ; max_copy = 19 */ +struct lib9p_msg_Trenameat { + lib9p_tag_t tag; + lib9p_fid_t olddirfid; + struct lib9p_s oldname; + lib9p_fid_t newdirfid; + struct lib9p_s newname; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Trenameat, lib9p_msg_Trenameat); + +/* min_size = 17 ; exp_size = 44 ; max_size = 65,552 ; max_iov = 3 ; max_copy = 17 */ +struct lib9p_msg_Tunlinkat { + lib9p_tag_t tag; + lib9p_fid_t dirfd; + struct lib9p_s name; + uint32_t flags; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tunlinkat, lib9p_msg_Tunlinkat); + #endif /* CONFIG_9P_ENABLE_9P2000_L */ +#if CONFIG_9P_ENABLE_9P2000_e +/* min_size = 13 ; exp_size = 477 ; max_size = 4,294,967,308 (warning: >UINT32_MAX) ; max_iov = 0 + (CONFIG_9P_MAX_9P2000_e_WELEM * 2) ; max_copy = 13 + (CONFIG_9P_MAX_9P2000_e_WELEM * 2) */ +struct lib9p_msg_Tsread { + lib9p_tag_t tag; + uint32_t fid; + uint16_t nwname; + struct lib9p_s *wname; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tsread, lib9p_msg_Tsread); + +/* min_size = 17 ; exp_size = 8,673 ; max_size = 8,589,934,607 (warning: >UINT32_MAX) ; max_iov = 2 + (CONFIG_9P_MAX_9P2000_e_WELEM * 2) ; max_copy = 17 + (CONFIG_9P_MAX_9P2000_e_WELEM * 2) */ +struct lib9p_msg_Tswrite { + lib9p_tag_t tag; + uint32_t fid; + uint16_t nwname; + struct lib9p_s *wname; + uint32_t count; + [[gnu::nonstring]] char *data; +}; +LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tswrite, lib9p_msg_Tswrite); + +#endif /* CONFIG_9P_ENABLE_9P2000_e */ #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 = 58 ; exp_size = 166 ; max_size = 262,198 ; max_iov = 8 ; max_copy = 58 */ /* LIB9P_VER_9P2000_e : min_size = 58 ; exp_size = 166 ; max_size = 262,198 ; max_iov = 8 ; max_copy = 58 */ diff --git a/lib9p/include/lib9p/9p.h b/lib9p/core_include/lib9p/core.h index 42381cf..ff822ed 100644 --- a/lib9p/include/lib9p/9p.h +++ b/lib9p/core_include/lib9p/core.h @@ -1,19 +1,18 @@ -/* lib9p/9p.h - Base 9P protocol definitions for both clients and servers +/* lib9p/core.h - Base 9P protocol definitions for both clients and servers * * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> * SPDX-License-Identifier: AGPL-3.0-or-later */ -#ifndef _LIB9P_9P_H_ -#define _LIB9P_9P_H_ +#ifndef _LIB9P_CORE_H_ +#define _LIB9P_CORE_H_ #include <stdbool.h> #include <sys/types.h> /* for ssize_t */ #include <libmisc/assert.h> -#include <lib9p/linux-errno.h> -#include <lib9p/9p.generated.h> +#include <lib9p/_core_generated.h> #ifndef CONFIG_9P_MAX_ERR_SIZE #error config.h must define CONFIG_9P_MAX_ERR_SIZE @@ -86,12 +85,12 @@ lo_interface fmt_formatter lo_box_lib9p_msg_as_fmt_formatter(struct lib9p_ctx *c * * @return required size, or -1 on error * - * @errno LINUX_EOPNOTSUPP: message is an R-message - * @errno LINUX_EOPNOTSUPP: message has unknown type - * @errno LINUX_EBADMSG: message is wrong size for content - * @errno LINUX_EBADMSG: message contains invalid UTF-8 - * @errno LINUX_EBADMSG: message contains a bitfield with unknown bits - * @errno LINUX_EMSGSIZE: would-be return value overflows SSIZE_MAX + * @errno L_EOPNOTSUPP: message is an R-message + * @errno L_EOPNOTSUPP: message has unknown type + * @errno L_EBADMSG: message is wrong size for content + * @errno L_EBADMSG: message contains invalid UTF-8 + * @errno L_EBADMSG: message contains a bitfield with unknown bits + * @errno L_EMSGSIZE: would-be return value overflows SSIZE_MAX */ ssize_t lib9p_Tmsg_validate(struct lib9p_ctx *ctx, uint8_t *net_bytes); @@ -126,7 +125,7 @@ void lib9p_Tmsg_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes, * @return ret_bytes : the buffer to encode to, must be at be at least ctx->max_msg_size bytes * @return whether there was an error (false=success, true=error) * - * @errno LINUX_ERANGE: reply does not fit in ctx->max_msg_size + * @errno L_ERANGE: reply does not fit in ctx->max_msg_size */ bool lib9p_Tmsg_marshal(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body, struct lib9p_Tmsg_send_buf *ret); @@ -198,9 +197,9 @@ void lib9p_stat_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes, * @return ret_bytes: the buffer to encode into * @return the number of bytes written, or 0 if the stat object does not fit in max_net_size * - * @errno LINUX_ERANGE: reply does not fit in max_net_size + * @errno L_ERANGE: reply does not fit in max_net_size */ uint32_t lib9p_stat_marshal(struct lib9p_ctx *ctx, uint32_t max_net_size, struct lib9p_stat *obj, uint8_t *ret_bytes); -#endif /* _LIB9P_9P_H_ */ +#endif /* _LIB9P_CORE_H_ */ diff --git a/lib9p/tables.c b/lib9p/core_tables.c index 86e3298..a04a5f0 100644 --- a/lib9p/tables.c +++ b/lib9p/core_tables.c @@ -1,4 +1,4 @@ -/* lib9p/tables.c - Access tables of version and message information +/* 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 @@ -9,7 +9,7 @@ #include <libmisc/endian.h> #include <libmisc/log.h> /* for const_byte_str() */ -#include "tables.h" +#include "core_tables.h" /* bounds checks **************************************************************/ @@ -64,14 +64,14 @@ ssize_t _lib9p_validate(uint8_t xxx_low_typ_bit, /* Inspect the first 5 bytes ourselves. */ uint32_t net_size = uint32le_decode(net_bytes); if (net_size < 5) - return lib9p_error(ctx, LINUX_EBADMSG, "message is impossibly short"); + 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, LINUX_EOPNOTSUPP, "%s: message_type=%s", xxx_errmsg, + 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, LINUX_EOPNOTSUPP, "unknown message type: %s (protocol_version=%s)", + 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. */ diff --git a/lib9p/tables.h b/lib9p/core_tables.h index edb402a..2c5f745 100644 --- a/lib9p/tables.h +++ b/lib9p/core_tables.h @@ -1,13 +1,13 @@ -/* lib9p/tables.h - Declare tables of version and message information +/* lib9p/core_tables.h - Declare tables of version and message information * * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> * SPDX-License-Identifier: AGPL-3.0-or-later */ -#ifndef _LIB9P_TABLES_H_ -#define _LIB9P_TABLES_H_ +#ifndef _LIB9P_CORE_TABLES_H_ +#define _LIB9P_CORE_TABLES_H_ -#include <lib9p/9p.h> +#include <lib9p/core.h> /* version ********************************************************************/ @@ -56,4 +56,4 @@ ssize_t _lib9p_stat_validate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t * 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 /* _LIB9P_TABLES_H_ */ +#endif /* _LIB9P_CORE_TABLES_H_ */ diff --git a/lib9p/utf8.h b/lib9p/core_utf8.h index 5ffd674..636d4eb 100644 --- a/lib9p/utf8.h +++ b/lib9p/core_utf8.h @@ -1,11 +1,11 @@ -/* lib9p/utf8.h - Internal UTF-8 validation +/* lib9p/core_utf8.h - Internal UTF-8 validation * * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> * SPDX-License-Identifier: AGPL-3.0-or-later */ -#ifndef _LIB9P_UTF8_H_ -#define _LIB9P_UTF8_H_ +#ifndef _LIB9P_CORE_UTF8_H_ +#define _LIB9P_CORE_UTF8_H_ static inline bool _is_valid_utf8(uint8_t *str, size_t len, bool forbid_nul) { uint32_t ch; @@ -31,4 +31,4 @@ static inline bool _is_valid_utf8(uint8_t *str, size_t len, bool forbid_nul) { #define is_valid_utf8(str, len) _is_valid_utf8(str, len, false) #define is_valid_utf8_without_nul(str, len) _is_valid_utf8(str, len, true) -#endif /* _LIB9P_UTF8_H_ */ +#endif /* _LIB9P_CORE_UTF8_H_ */ diff --git a/lib9p/idl/2010-9P2000.L.9p b/lib9p/idl/2010-9P2000.L.9p index b88b537..5eb7d5c 100644 --- a/lib9p/idl/2010-9P2000.L.9p +++ b/lib9p/idl/2010-9P2000.L.9p @@ -1,3 +1,6 @@ +# lib9p/idl/2010-9P2000.L.9p - Generated by `lib9p/idl/2010-9P2000.L.9p.gen 3rd-party/linux-errno.txt`. DO NOT EDIT! +# 3rd-party/linux-errno.txt - Generated from lib9p/linux-errno.txt.gen and linux.git v6.14. DO NOT EDIT! + # lib9p/idl/2010-9P2000.L.9p - Definitions of 9P2000.L messages # # Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> @@ -13,8 +16,144 @@ version "9P2000.L" from ./2002-9P2000.9p import tag, fid, s, qt, qid from ./2005-9P2000.u.9p import nuid, errno +# BUG: The definitions of errno are not defined in the 9P2000.L +# protocol spec, and Linux kernel errno values vary by architecture. +# Most architectures share a "generic" list, but a handful (as of +# Linux v6.14, Alpha, MIPS, PA-RISC, PowerPC, and SPARC) have their +# own numbers. This IDL file lists the generic numbers. +# # https://github.com/chaos/diod/issues/35 -#num errno += # TODO +num errno += "L_EPERM = 1" # Operation not permitted + "L_ENOENT = 2" # No such file or directory + "L_ESRCH = 3" # No such process + "L_EINTR = 4" # Interrupted system call + "L_EIO = 5" # I/O error + "L_ENXIO = 6" # No such device or address + "L_E2BIG = 7" # Argument list too long + "L_ENOEXEC = 8" # Exec format error + "L_EBADF = 9" # Bad file number + "L_ECHILD = 10" # No child processes + "L_EAGAIN = 11" # Try again + "L_ENOMEM = 12" # Out of memory + "L_EACCES = 13" # Permission denied + "L_EFAULT = 14" # Bad address + "L_ENOTBLK = 15" # Block device required + "L_EBUSY = 16" # Device or resource busy + "L_EEXIST = 17" # File exists + "L_EXDEV = 18" # Cross-device link + "L_ENODEV = 19" # No such device + "L_ENOTDIR = 20" # Not a directory + "L_EISDIR = 21" # Is a directory + "L_EINVAL = 22" # Invalid argument + "L_ENFILE = 23" # File table overflow + "L_EMFILE = 24" # Too many open files + "L_ENOTTY = 25" # Not a typewriter + "L_ETXTBSY = 26" # Text file busy + "L_EFBIG = 27" # File too large + "L_ENOSPC = 28" # No space left on device + "L_ESPIPE = 29" # Illegal seek + "L_EROFS = 30" # Read-only file system + "L_EMLINK = 31" # Too many links + "L_EPIPE = 32" # Broken pipe + "L_EDOM = 33" # Math argument out of domain of func + "L_ERANGE = 34" # Math result not representable + "L_EDEADLK = 35" # Resource deadlock would occur + "L_ENAMETOOLONG = 36" # File name too long + "L_ENOLCK = 37" # No record locks available + "L_ENOSYS = 38" # Invalid system call number + "L_ENOTEMPTY = 39" # Directory not empty + "L_ELOOP = 40" # Too many symbolic links encountered + "L_ENOMSG = 42" # No message of desired type + "L_EIDRM = 43" # Identifier removed + "L_ECHRNG = 44" # Channel number out of range + "L_EL2NSYNC = 45" # Level 2 not synchronized + "L_EL3HLT = 46" # Level 3 halted + "L_EL3RST = 47" # Level 3 reset + "L_ELNRNG = 48" # Link number out of range + "L_EUNATCH = 49" # Protocol driver not attached + "L_ENOCSI = 50" # No CSI structure available + "L_EL2HLT = 51" # Level 2 halted + "L_EBADE = 52" # Invalid exchange + "L_EBADR = 53" # Invalid request descriptor + "L_EXFULL = 54" # Exchange full + "L_ENOANO = 55" # No anode + "L_EBADRQC = 56" # Invalid request code + "L_EBADSLT = 57" # Invalid slot + "L_EBFONT = 59" # Bad font file format + "L_ENOSTR = 60" # Device not a stream + "L_ENODATA = 61" # No data available + "L_ETIME = 62" # Timer expired + "L_ENOSR = 63" # Out of streams resources + "L_ENONET = 64" # Machine is not on the network + "L_ENOPKG = 65" # Package not installed + "L_EREMOTE = 66" # Object is remote + "L_ENOLINK = 67" # Link has been severed + "L_EADV = 68" # Advertise error + "L_ESRMNT = 69" # Srmount error + "L_ECOMM = 70" # Communication error on send + "L_EPROTO = 71" # Protocol error + "L_EMULTIHOP = 72" # Multihop attempted + "L_EDOTDOT = 73" # RFS specific error + "L_EBADMSG = 74" # Not a data message + "L_EOVERFLOW = 75" # Value too large for defined data type + "L_ENOTUNIQ = 76" # Name not unique on network + "L_EBADFD = 77" # File descriptor in bad state + "L_EREMCHG = 78" # Remote address changed + "L_ELIBACC = 79" # Can not access a needed shared library + "L_ELIBBAD = 80" # Accessing a corrupted shared library + "L_ELIBSCN = 81" # .lib section in a.out corrupted + "L_ELIBMAX = 82" # Attempting to link in too many shared libraries + "L_ELIBEXEC = 83" # Cannot exec a shared library directly + "L_EILSEQ = 84" # Illegal byte sequence + "L_ERESTART = 85" # Interrupted system call should be restarted + "L_ESTRPIPE = 86" # Streams pipe error + "L_EUSERS = 87" # Too many users + "L_ENOTSOCK = 88" # Socket operation on non-socket + "L_EDESTADDRREQ = 89" # Destination address required + "L_EMSGSIZE = 90" # Message too long + "L_EPROTOTYPE = 91" # Protocol wrong type for socket + "L_ENOPROTOOPT = 92" # Protocol not available + "L_EPROTONOSUPPORT = 93" # Protocol not supported + "L_ESOCKTNOSUPPORT = 94" # Socket type not supported + "L_EOPNOTSUPP = 95" # Operation not supported on transport endpoint + "L_EPFNOSUPPORT = 96" # Protocol family not supported + "L_EAFNOSUPPORT = 97" # Address family not supported by protocol + "L_EADDRINUSE = 98" # Address already in use + "L_EADDRNOTAVAIL = 99" # Cannot assign requested address + "L_ENETDOWN = 100" # Network is down + "L_ENETUNREACH = 101" # Network is unreachable + "L_ENETRESET = 102" # Network dropped connection because of reset + "L_ECONNABORTED = 103" # Software caused connection abort + "L_ECONNRESET = 104" # Connection reset by peer + "L_ENOBUFS = 105" # No buffer space available + "L_EISCONN = 106" # Transport endpoint is already connected + "L_ENOTCONN = 107" # Transport endpoint is not connected + "L_ESHUTDOWN = 108" # Cannot send after transport endpoint shutdown + "L_ETOOMANYREFS = 109" # Too many references: cannot splice + "L_ETIMEDOUT = 110" # Connection timed out + "L_ECONNREFUSED = 111" # Connection refused + "L_EHOSTDOWN = 112" # Host is down + "L_EHOSTUNREACH = 113" # No route to host + "L_EALREADY = 114" # Operation already in progress + "L_EINPROGRESS = 115" # Operation now in progress + "L_ESTALE = 116" # Stale file handle + "L_EUCLEAN = 117" # Structure needs cleaning + "L_ENOTNAM = 118" # Not a XENIX named type file + "L_ENAVAIL = 119" # No XENIX semaphores available + "L_EISNAM = 120" # Is a named type file + "L_EREMOTEIO = 121" # Remote I/O error + "L_EDQUOT = 122" # Quota exceeded + "L_ENOMEDIUM = 123" # No medium found + "L_EMEDIUMTYPE = 124" # Wrong medium type + "L_ECANCELED = 125" # Operation Canceled + "L_ENOKEY = 126" # Required key not available + "L_EKEYEXPIRED = 127" # Key has expired + "L_EKEYREVOKED = 128" # Key has been revoked + "L_EKEYREJECTED = 129" # Key was rejected by service + "L_EOWNERDEAD = 130" # Owner died + "L_ENOTRECOVERABLE = 131" # State not recoverable + "L_ERFKILL = 132" # Operation not possible due to RF-kill + "L_EHWPOISON = 133" # Memory page has hardware error num super_magic = 4 # See <linux/magic.h> (linux.git include/uapi/linux/magic.h). diff --git a/lib9p/idl/2010-9P2000.L.9p.gen b/lib9p/idl/2010-9P2000.L.9p.gen new file mode 100755 index 0000000..cb32585 --- /dev/null +++ b/lib9p/idl/2010-9P2000.L.9p.gen @@ -0,0 +1,282 @@ +#!/usr/bin/env python +# lib9p/idl/2010-9P2000.L.9p.gen - Generate definitions of 9P2000.L messages +import sys + +print( + f"# lib9p/idl/2010-9P2000.L.9p - Generated by `{' '.join(sys.argv)}`. DO NOT EDIT!" +) +errnos: dict[str, tuple[int, str]] = {} +with open(sys.argv[1], "r", encoding="utf-8") as fh: + for line in fh: + if line.startswith("#"): + print(line) + continue + _num, _name, _desc = line.split(maxsplit=2) + errnos[_name] = (int(_num), _desc.strip()) +print( + """ +# lib9p/idl/2010-9P2000.L.9p - Definitions of 9P2000.L messages +# +# Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> +# SPDX-License-Identifier: AGPL-3.0-or-later + +# "9P2000.L" Linux extension +# https://github.com/chaos/diod/blob/master/protocol.md +# https://github.com/chaos/diod/blob/master/src/libnpfs/protocol.h +version "9P2000.L" + +# low-level types ############################################################## + +from ./2002-9P2000.9p import tag, fid, s, qt, qid +from ./2005-9P2000.u.9p import nuid, errno + +# BUG: The definitions of errno are not defined in the 9P2000.L +# protocol spec, and Linux kernel errno values vary by architecture. +# Most architectures share a "generic" list, but a handful (as of +# Linux v6.14, Alpha, MIPS, PA-RISC, PowerPC, and SPARC) have their +# own numbers. This IDL file lists the generic numbers. +# +# https://github.com/chaos/diod/issues/35 +""".strip() +) + +prefix = "num errno += " +namelen = max(len(name) for name in errnos) +numlen = max(len(str(num)) for (num, desc) in errnos.values()) +for name, (num, desc) in errnos.items(): + print(f'{prefix}"L_{name:<{namelen}} = {num:>{numlen}}" # {desc}') + prefix = " " * len(prefix) +print() + +print( + """ +num super_magic = 4 + # See <linux/magic.h> (linux.git include/uapi/linux/magic.h). + # + # To quote `util-linux.git:include/statfs_magic.h`: + # "Unfortunately, Linux kernel header file <linux/magic.h> is + # incomplete mess and kernel returns by statfs f_type many numbers + # that are nowhere specified (in API)." + # + # util-linux <statfs_magic.h> is also incomplete. As is the + # statfs(2) man-page. + # + # I'm working on a patchset to the kernel to get <linux/magic.h> + # to be complete, but in the mean-time I'm just not going to + # bother with putting a list here. + # + # TODO + "V9FS_MAGIC=0x01021997" + +# "L"inux "O"pen flags (flags to pass to Tlopen and Tlcreate) +# +# The values are not specified in in protocol.md, but are specified in +# protocol.h (and are different than the Linux kernel's values, which +# vary by architecture). +bitfield lo = 4 + "bit 0=num(MODE)" # low bit of the 2-bit RDONLY/WRONLY/RDWR/NOACCESS enum + "bit 1=num(MODE)" # high bit of the 2-bit RDONLY/WRONLY/RDWR/NOACCESS enum + #"bit 2=unused" + #"bit 3=unused" + #"bit 4=unused" + #"bit 5=unused" + "bit 6=CREATE" + "bit 7=EXCL" + "bit 8=NOCTTY" + "bit 9=TRUNC" + "bit 10=APPEND" + "bit 11=NONBLOCK" + "bit 12=DSYNC" + "bit 13=BSD_FASYNC" + "bit 14=DIRECT" + "bit 15=LARGEFILE" + "bit 16=DIRECTORY" + "bit 17=NOFOLLOW" + "bit 18=NOATIME" + "bit 19=CLOEXEC" + "bit 20=SYNC" + + "num(MODE) RDONLY = 0" + "num(MODE) WRONLY = 1" + "num(MODE) RDWR = 2" + "num(MODE) NOACCESS = 3" + + "mask FLAG = 0b111111111111111000000" + +# "D"irentry "T"ype +# +# These match the Linux kernel's values. +num dt = 1 + "UNKNOWN = 0" + "PIPE = 1" + "CHAR_DEV = 2" + "DIRECTORY = 4" + "BLOCK_DEV = 6" # proof it's not a bitfield + "REGULAR = 8" + "SYMLINK = 10" # proof it's not a bitfield + "SOCKET = 12" # proof it's not a bitfield + "_WHITEOUT = 14" # proof it's not a bitfield + +# Mode +# +# These match the Linux kernel's values. Why is this 32-bits wide +# instead of just 16? Who knows? +bitfield mode = 4 + #... + "bit 15=num(FMT)" # bit of the 4-bit FMT_ enum + "bit 14=num(FMT)" # bit of the 4-bit FMT_ enum + "bit 13=num(FMT)" # bit of the 4-bit FMT_ enum + "bit 12=num(FMT)" # bit of the 4-bit FMT_ enum + #... + "bit 11=PERM_SETGROUP" + "bit 10=PERM_SETUSER" + "bit 9=PERM_STICKY" + "bit 8=PERM_OWNER_R" + "bit 7=PERM_OWNER_W" + "bit 6=PERM_OWNER_X" + "bit 5=PERM_GROUP_R" + "bit 4=PERM_GROUP_W" + "bit 3=PERM_GROUP_X" + "bit 2=PERM_OTHER_R" + "bit 1=PERM_OTHER_W" + "bit 0=PERM_OTHER_X" + + "num(FMT) PIPE = dt.PIPE<<12" + "num(FMT) CHAR_DEV = dt.CHAR_DEV<<12" + "num(FMT) DIRECTORY = dt.DIRECTORY<<12" + "num(FMT) BLOCK_DEV = dt.BLOCK_DEV<<12" + "num(FMT) REGULAR = dt.REGULAR<<12" + "num(FMT) SYMLINK = dt.SYMLINK<<12" + "num(FMT) SOCKET = dt.SOCKET<<12" + + "mask PERM = 07777" # PERM_* + +# A boolean value that is for some reason 4 bytes wide. +num b4 = 4 + "FALSE=0" + "TRUE=1" + # all other values are true also + +bitfield getattr = 8 + "bit 0=MODE" + "bit 1=NLINK" + "bit 2=UID" + "bit 3=GID" + "bit 4=RDEV" + "bit 5=ATIME" + "bit 6=MTIME" + "bit 7=CTIME" + "bit 8=INO" + "bit 9=SIZE" + "bit 10=BLOCKS" + + "bit 11=BTIME" + "bit 12=GEN" + "bit 13=DATA_VERSION" + + "alias BASIC=0x000007ff" # Mask for fields up to BLOCKS + "alias ALL =0x00003fff" # Mask for All fields above + +bitfield setattr = 4 + "bit 0=MODE" + "bit 1=UID" + "bit 2=GID" + "bit 3=SIZE" + "bit 4=ATIME" + "bit 5=MTIME" + "bit 6=CTIME" + "bit 7=ATIME_SET" + "bit 8=MTIME_SET" + +num lock_type = 1 + "RDLCK=0" + "WRLCK=1" + "UNLCK=2" + +bitfield lock_flags = 4 + "bit 0=BLOCK" + "bit 1=RECLAIM" + +num lock_status = 1 + "SUCCESS=0" + "BLOCKED=1" + "ERROR=2" + "GRACE=3" + +# 9P2000 Operations (.L subset) ################################################ + +from ./2002-9P2000.9p import Tversion, Rversion +from ./2002-9P2000.9p import Tflush, Rflush +from ./2002-9P2000.9p import Twalk, Rwalk +from ./2002-9P2000.9p import Tread, Rread, Twrite, Rwrite +from ./2002-9P2000.9p import Tclunk, Rclunk +from ./2002-9P2000.9p import Tremove, Rremove + +# 9P2000.u Operations (.L subset) ############################################## + +from ./2005-9P2000.u.9p import Tattach, Rattach, Tauth, Rauth + +# 9P2000.L Operations ########################################################## + +#msg Tlerror = "size[4,val=end-&size] typ[1,val=6] tag[tag] illegal" # analogous to 106/Terror +msg Rlerror = "size[4,val=end-&size] typ[1,val=7] tag[tag] errnum[errno]" # analogous to 107/Rerror +msg Tstatfs = "size[4,val=end-&size] typ[1,val=8] tag[tag] fid[fid]" +msg Rstatfs = "size[4,val=end-&size] typ[1,val=9] tag[tag]" # Description | statfs | statvfs + "type[super_magic]" # Type of filesystem | f_type | - + "bsize[4]" # Block size in bytes | f_bsize | f_bsize + # - # Fragment size in bytes | f_frsize (since Linux 2.6) | f_frsize + "blocks[8]" # Size of FS in f_frsize units | f_blocks | f_blocks + "bfree[8]" # Number of free blocks | f_bfree | f_bfree + "bavail[8]" # Number of free blocks for unprivileged users | f_bavail | b_avail + "files[8]" # Number of inodes | f_files | f_files + "ffree[8]" # Number of free inodes | f_ffree | f_ffree + # - # Number of free inodes for unprivileged users | - | f_favail + "fsid[8]" # Filesystem instance ID | f_fsid | f_fsid + # - # Mount flags | f_flags (since Linux 2.6.36) | f_flag + "namelen[4]" # Maximum filename length | f_namemax | f_namemax +msg Tlopen = "size[4,val=end-&size] typ[1,val=12] tag[tag] fid[fid] flags[lo]" # analogous to 112/Topen +msg Rlopen = "size[4,val=end-&size] typ[1,val=13] tag[tag] qid[qid] iounit[4]" # analogous to 113/Ropen +msg Tlcreate = "size[4,val=end-&size] typ[1,val=14] tag[tag] fid[fid] name[s] flags[lo] mode[mode] gid[nuid]" # analogous to 114/Tcreate +msg Rlcreate = "size[4,val=end-&size] typ[1,val=15] tag[tag] qid[qid] iounit[4]" # analogous to 115/Rcreate +msg Tsymlink = "size[4,val=end-&size] typ[1,val=16] tag[tag] fid[fid] name[s] symtgt[s] gid[nuid]" +msg Rsymlink = "size[4,val=end-&size] typ[1,val=17] tag[tag] qid[qid]" +msg Tmknod = "size[4,val=end-&size] typ[1,val=18] tag[tag] dfid[fid] name[s] mode[mode] major[4] minor[4] gid[nuid]" +msg Rmknod = "size[4,val=end-&size] typ[1,val=19] tag[tag] qid[qid]" +msg Trename = "size[4,val=end-&size] typ[1,val=20] tag[tag] fid[fid] dfid[fid] name[s]" +msg Rrename = "size[4,val=end-&size] typ[1,val=21] tag[tag]" +msg Treadlink = "size[4,val=end-&size] typ[1,val=22] tag[tag] fid[fid]" +msg Rreadlink = "size[4,val=end-&size] typ[1,val=23] tag[tag] target[s]" +msg Tgetattr = "size[4,val=end-&size] typ[1,val=24] tag[tag] fid[fid] request_mask[getattr]" +msg Rgetattr = "size[4,val=end-&size] typ[1,val=25] tag[tag] valid[getattr] qid[qid] mode[mode] uid[nuid] gid[nuid] nlink[8]" + "rdev[8] filesize[8] blksize[8] blocks[8]" + "atime_sec[8] atime_nsec[8] mtime_sec[8] mtime_nsec[8]" + "ctime_sec[8] ctime_nsec[8] btime_sec[8] btime_nsec[8]" + "gen[8] data_version[8]" +msg Tsetattr = "size[4,val=end-&size] typ[1,val=26] tag[tag] fid[fid] valid[setattr] mode[mode] uid[nuid] gid[nuid] filesize[8] atime_sec[8] atime_nsec[8] mtime_sec[8] mtime_nsec[8]" +msg Rsetattr = "size[4,val=end-&size] typ[1,val=27] tag[tag]" +#... +msg Txattrwalk = "size[4,val=end-&size] typ[1,val=30] tag[tag] fid[fid] newfid[fid] name[s]" +msg Rxattrwalk = "size[4,val=end-&size] typ[1,val=31] tag[tag] attr_size[8]" +msg Txattrcreate = "size[4,val=end-&size] typ[1,val=32] tag[tag] fid[fid] name[s] attr_size[8] flags[4]" +msg Rxattrcreate = "size[4,val=end-&size] typ[1,val=33] tag[tag]" +#... +msg Treaddir = "size[4,val=end-&size] typ[1,val=40] tag[tag] fid[fid] offset[8] count[4]" +msg Rreaddir = "size[4,val=end-&size] typ[1,val=41] tag[tag] count[4] count*(data[1])" # data is "qid[qid] offset[8] type[dt] name[s]" +#... +msg Tfsync = "size[4,val=end-&size] typ[1,val=50] tag[tag] fid[fid] datasync[b4]" +msg Rfsync = "size[4,val=end-&size] typ[1,val=51] tag[tag]" +msg Tlock = "size[4,val=end-&size] typ[1,val=52] tag[tag] fid[fid] type[lock_type] flags[lock_flags] start[8] length[8] proc_id[4] client_id[s]" +msg Rlock = "size[4,val=end-&size] typ[1,val=53] tag[tag] status[lock_status]" +msg Tgetlock = "size[4,val=end-&size] typ[1,val=54] tag[tag] fid[fid] type[lock_type] start[8] length[8] proc_id[4] client_id[s]" +msg Rgetlock = "size[4,val=end-&size] typ[1,val=55] tag[tag] type[lock_type] start[8] length[8] proc_id[4] client_id[s]" +# ... +msg Tlink = "size[4,val=end-&size] typ[1,val=70] tag[tag] dfid[fid] fid[fid] name[s]" +msg Rlink = "size[4,val=end-&size] typ[1,val=71] tag[tag]" +msg Tmkdir = "size[4,val=end-&size] typ[1,val=72] tag[tag] dfid[fid] name[s] mode[mode] gid[nuid]" +msg Rmkdir = "size[4,val=end-&size] typ[1,val=73] tag[tag] qid[qid]" +msg Trenameat = "size[4,val=end-&size] typ[1,val=74] tag[tag] olddirfid[fid] oldname[s] newdirfid[fid] newname[s]" +msg Rrenameat = "size[4,val=end-&size] typ[1,val=75] tag[tag]" +msg Tunlinkat = "size[4,val=end-&size] typ[1,val=76] tag[tag] dirfd[fid] name[s] flags[4]" +msg Runlinkat = "size[4,val=end-&size] typ[1,val=77] tag[tag]" +""".strip() +) diff --git a/lib9p/idl/__init__.py b/lib9p/idl/__init__.py index 2d09217..3133cc4 100644 --- a/lib9p/idl/__init__.py +++ b/lib9p/idl/__init__.py @@ -647,17 +647,16 @@ def re_string(grpname: str) -> str: re_line_version = f"version\\s+{re_string('version')}" re_line_import = f"from\\s+(?P<file>\\S+)\\s+import\\s+(?P<syms>{re_impname}(?:\\s*,\\s*{re_impname})*)" re_line_num = f"num\\s+(?P<name>{re_symname})\\s*=\\s*(?P<prim>{re_priname})" +re_line_num_ = f"num\\s+(?P<name>{re_symname})\\s*\\+=\\s*{re_string('spec')}" re_line_bitfield = f"bitfield\\s+(?P<name>{re_symname})\\s*=\\s*(?P<prim>{re_priname})" -re_line_bitfield_ = ( - f"bitfield\\s+(?P<name>{re_symname})\\s*\\+=\\s*{re_string('member')}" -) +re_line_bitfield_ = f"bitfield\\s+(?P<name>{re_symname})\\s*\\+=\\s*{re_string('spec')}" re_line_struct = ( f"struct\\s+(?P<name>{re_symname})\\s*(?P<op>\\+?=)\\s*{re_string('members')}" ) re_line_msg = ( f"msg\\s+(?P<name>{re_msgname})\\s*(?P<op>\\+?=)\\s*{re_string('members')}" ) -re_line_cont = f"\\s+{re_string('specs')}" # could be bitfield/struct/msg +re_line_cont = f"\\s+{re_string('spec')}" # could be bitfield/struct/msg def parse_file( @@ -741,6 +740,11 @@ def parse_file( raise ValueError(f"duplicate type name {num.typname!r}") env[num.typname] = num prev = num + elif m := re.fullmatch(re_line_num_, line): + num = get_type(env, m.group("name"), Number) + parse_numspec(env, version, num, m.group("spec")) + + prev = num elif m := re.fullmatch(re_line_bitfield, line): prim = env[m.group("prim")] assert isinstance(prim, Primitive) @@ -754,7 +758,7 @@ def parse_file( prev = bf elif m := re.fullmatch(re_line_bitfield_, line): bf = get_type(env, m.group("name"), Bitfield) - parse_bitspec(env, version, bf, m.group("member")) + parse_bitspec(env, version, bf, m.group("spec")) prev = bf elif m := re.fullmatch(re_line_struct, line): @@ -798,11 +802,11 @@ def parse_file( elif m := re.fullmatch(re_line_cont, line): match prev: case Bitfield(): - parse_bitspec(env, version, prev, m.group("specs")) + parse_bitspec(env, version, prev, m.group("spec")) case Number(): - parse_numspec(env, version, prev, m.group("specs")) + parse_numspec(env, version, prev, m.group("spec")) case Struct(): # and Message() - parse_members(version, env, prev, m.group("specs")) + parse_members(version, env, prev, m.group("spec")) case _: raise SyntaxError( "continuation line must come after a bitfield, struct, or msg line" diff --git a/lib9p/include/lib9p/linux-errno.h b/lib9p/include/lib9p/linux-errno.h deleted file mode 100644 index e864fb6..0000000 --- a/lib9p/include/lib9p/linux-errno.h +++ /dev/null @@ -1,139 +0,0 @@ -/* lib9p/linux-errno.h - Generated by `lib9p/include/lib9p/linux-errno.h.gen 3rd-party/linux-errno.txt`. DO NOT EDIT! */ -/* 3rd-party/linux-errno.txt - Generated from lib9p/linux-errno.txt.gen and linux.git v6.14. DO NOT EDIT! */ - -#ifndef _LIB9P_LINUX_ERRNO_H_ -#define _LIB9P_LINUX_ERRNO_H_ - -#define LINUX_EPERM 1 /* Operation not permitted */ -#define LINUX_ENOENT 2 /* No such file or directory */ -#define LINUX_ESRCH 3 /* No such process */ -#define LINUX_EINTR 4 /* Interrupted system call */ -#define LINUX_EIO 5 /* I/O error */ -#define LINUX_ENXIO 6 /* No such device or address */ -#define LINUX_E2BIG 7 /* Argument list too long */ -#define LINUX_ENOEXEC 8 /* Exec format error */ -#define LINUX_EBADF 9 /* Bad file number */ -#define LINUX_ECHILD 10 /* No child processes */ -#define LINUX_EAGAIN 11 /* Try again */ -#define LINUX_ENOMEM 12 /* Out of memory */ -#define LINUX_EACCES 13 /* Permission denied */ -#define LINUX_EFAULT 14 /* Bad address */ -#define LINUX_ENOTBLK 15 /* Block device required */ -#define LINUX_EBUSY 16 /* Device or resource busy */ -#define LINUX_EEXIST 17 /* File exists */ -#define LINUX_EXDEV 18 /* Cross-device link */ -#define LINUX_ENODEV 19 /* No such device */ -#define LINUX_ENOTDIR 20 /* Not a directory */ -#define LINUX_EISDIR 21 /* Is a directory */ -#define LINUX_EINVAL 22 /* Invalid argument */ -#define LINUX_ENFILE 23 /* File table overflow */ -#define LINUX_EMFILE 24 /* Too many open files */ -#define LINUX_ENOTTY 25 /* Not a typewriter */ -#define LINUX_ETXTBSY 26 /* Text file busy */ -#define LINUX_EFBIG 27 /* File too large */ -#define LINUX_ENOSPC 28 /* No space left on device */ -#define LINUX_ESPIPE 29 /* Illegal seek */ -#define LINUX_EROFS 30 /* Read-only file system */ -#define LINUX_EMLINK 31 /* Too many links */ -#define LINUX_EPIPE 32 /* Broken pipe */ -#define LINUX_EDOM 33 /* Math argument out of domain of func */ -#define LINUX_ERANGE 34 /* Math result not representable */ -#define LINUX_EDEADLK 35 /* Resource deadlock would occur */ -#define LINUX_ENAMETOOLONG 36 /* File name too long */ -#define LINUX_ENOLCK 37 /* No record locks available */ -#define LINUX_ENOSYS 38 /* Invalid system call number */ -#define LINUX_ENOTEMPTY 39 /* Directory not empty */ -#define LINUX_ELOOP 40 /* Too many symbolic links encountered */ -#define LINUX_ENOMSG 42 /* No message of desired type */ -#define LINUX_EIDRM 43 /* Identifier removed */ -#define LINUX_ECHRNG 44 /* Channel number out of range */ -#define LINUX_EL2NSYNC 45 /* Level 2 not synchronized */ -#define LINUX_EL3HLT 46 /* Level 3 halted */ -#define LINUX_EL3RST 47 /* Level 3 reset */ -#define LINUX_ELNRNG 48 /* Link number out of range */ -#define LINUX_EUNATCH 49 /* Protocol driver not attached */ -#define LINUX_ENOCSI 50 /* No CSI structure available */ -#define LINUX_EL2HLT 51 /* Level 2 halted */ -#define LINUX_EBADE 52 /* Invalid exchange */ -#define LINUX_EBADR 53 /* Invalid request descriptor */ -#define LINUX_EXFULL 54 /* Exchange full */ -#define LINUX_ENOANO 55 /* No anode */ -#define LINUX_EBADRQC 56 /* Invalid request code */ -#define LINUX_EBADSLT 57 /* Invalid slot */ -#define LINUX_EBFONT 59 /* Bad font file format */ -#define LINUX_ENOSTR 60 /* Device not a stream */ -#define LINUX_ENODATA 61 /* No data available */ -#define LINUX_ETIME 62 /* Timer expired */ -#define LINUX_ENOSR 63 /* Out of streams resources */ -#define LINUX_ENONET 64 /* Machine is not on the network */ -#define LINUX_ENOPKG 65 /* Package not installed */ -#define LINUX_EREMOTE 66 /* Object is remote */ -#define LINUX_ENOLINK 67 /* Link has been severed */ -#define LINUX_EADV 68 /* Advertise error */ -#define LINUX_ESRMNT 69 /* Srmount error */ -#define LINUX_ECOMM 70 /* Communication error on send */ -#define LINUX_EPROTO 71 /* Protocol error */ -#define LINUX_EMULTIHOP 72 /* Multihop attempted */ -#define LINUX_EDOTDOT 73 /* RFS specific error */ -#define LINUX_EBADMSG 74 /* Not a data message */ -#define LINUX_EOVERFLOW 75 /* Value too large for defined data type */ -#define LINUX_ENOTUNIQ 76 /* Name not unique on network */ -#define LINUX_EBADFD 77 /* File descriptor in bad state */ -#define LINUX_EREMCHG 78 /* Remote address changed */ -#define LINUX_ELIBACC 79 /* Can not access a needed shared library */ -#define LINUX_ELIBBAD 80 /* Accessing a corrupted shared library */ -#define LINUX_ELIBSCN 81 /* .lib section in a.out corrupted */ -#define LINUX_ELIBMAX 82 /* Attempting to link in too many shared libraries */ -#define LINUX_ELIBEXEC 83 /* Cannot exec a shared library directly */ -#define LINUX_EILSEQ 84 /* Illegal byte sequence */ -#define LINUX_ERESTART 85 /* Interrupted system call should be restarted */ -#define LINUX_ESTRPIPE 86 /* Streams pipe error */ -#define LINUX_EUSERS 87 /* Too many users */ -#define LINUX_ENOTSOCK 88 /* Socket operation on non-socket */ -#define LINUX_EDESTADDRREQ 89 /* Destination address required */ -#define LINUX_EMSGSIZE 90 /* Message too long */ -#define LINUX_EPROTOTYPE 91 /* Protocol wrong type for socket */ -#define LINUX_ENOPROTOOPT 92 /* Protocol not available */ -#define LINUX_EPROTONOSUPPORT 93 /* Protocol not supported */ -#define LINUX_ESOCKTNOSUPPORT 94 /* Socket type not supported */ -#define LINUX_EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ -#define LINUX_EPFNOSUPPORT 96 /* Protocol family not supported */ -#define LINUX_EAFNOSUPPORT 97 /* Address family not supported by protocol */ -#define LINUX_EADDRINUSE 98 /* Address already in use */ -#define LINUX_EADDRNOTAVAIL 99 /* Cannot assign requested address */ -#define LINUX_ENETDOWN 100 /* Network is down */ -#define LINUX_ENETUNREACH 101 /* Network is unreachable */ -#define LINUX_ENETRESET 102 /* Network dropped connection because of reset */ -#define LINUX_ECONNABORTED 103 /* Software caused connection abort */ -#define LINUX_ECONNRESET 104 /* Connection reset by peer */ -#define LINUX_ENOBUFS 105 /* No buffer space available */ -#define LINUX_EISCONN 106 /* Transport endpoint is already connected */ -#define LINUX_ENOTCONN 107 /* Transport endpoint is not connected */ -#define LINUX_ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ -#define LINUX_ETOOMANYREFS 109 /* Too many references: cannot splice */ -#define LINUX_ETIMEDOUT 110 /* Connection timed out */ -#define LINUX_ECONNREFUSED 111 /* Connection refused */ -#define LINUX_EHOSTDOWN 112 /* Host is down */ -#define LINUX_EHOSTUNREACH 113 /* No route to host */ -#define LINUX_EALREADY 114 /* Operation already in progress */ -#define LINUX_EINPROGRESS 115 /* Operation now in progress */ -#define LINUX_ESTALE 116 /* Stale file handle */ -#define LINUX_EUCLEAN 117 /* Structure needs cleaning */ -#define LINUX_ENOTNAM 118 /* Not a XENIX named type file */ -#define LINUX_ENAVAIL 119 /* No XENIX semaphores available */ -#define LINUX_EISNAM 120 /* Is a named type file */ -#define LINUX_EREMOTEIO 121 /* Remote I/O error */ -#define LINUX_EDQUOT 122 /* Quota exceeded */ -#define LINUX_ENOMEDIUM 123 /* No medium found */ -#define LINUX_EMEDIUMTYPE 124 /* Wrong medium type */ -#define LINUX_ECANCELED 125 /* Operation Canceled */ -#define LINUX_ENOKEY 126 /* Required key not available */ -#define LINUX_EKEYEXPIRED 127 /* Key has expired */ -#define LINUX_EKEYREVOKED 128 /* Key has been revoked */ -#define LINUX_EKEYREJECTED 129 /* Key was rejected by service */ -#define LINUX_EOWNERDEAD 130 /* Owner died */ -#define LINUX_ENOTRECOVERABLE 131 /* State not recoverable */ -#define LINUX_ERFKILL 132 /* Operation not possible due to RF-kill */ -#define LINUX_EHWPOISON 133 /* Memory page has hardware error */ - -#endif /* _LIB9P_LINUX_ERRNO_H_ */ diff --git a/lib9p/include/lib9p/linux-errno.h.gen b/lib9p/include/lib9p/linux-errno.h.gen deleted file mode 100755 index 2c736a2..0000000 --- a/lib9p/include/lib9p/linux-errno.h.gen +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env python -# lib9p/linux-errno.h.gen - Generate a C header from a list of errno numbers -# -# Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> -# SPDX-License-Identifier: AGPL-3.0-or-later - -import sys - - -def print_errnos() -> None: - print( - f"/* lib9p/linux-errno.h - Generated by `{' '.join(sys.argv)}`. DO NOT EDIT! */" - ) - errnos: dict[str, tuple[int, str]] = {} - for txtlist in sys.argv[1:]: - with open(txtlist, "r", encoding="utf-8") as fh: - for line in fh: - if line.startswith("#"): - print(f"/* {line[1:].strip()} */") - continue - _num, name, desc = line.split(maxsplit=2) - num = int(_num) - desc = desc.strip() - errnos[name] = (num, desc) - print() - print("#ifndef _LIB9P_LINUX_ERRNO_H_") - print("#define _LIB9P_LINUX_ERRNO_H_") - print() - namelen = max(len(name) for name in errnos) - numlen = max(len(str(num)) for (num, desc) in errnos.values()) - for name, [num, msg] in errnos.items(): - print(f"#define LINUX_{name:<{namelen}} {num:>{numlen}} /* {msg} */") - print() - print("#endif /* _LIB9P_LINUX_ERRNO_H_ */") - - -if __name__ == "__main__": - print_errnos() diff --git a/lib9p/srv.c b/lib9p/srv.c index 0a33e03..7e2bab0 100644 --- a/lib9p/srv.c +++ b/lib9p/srv.c @@ -32,16 +32,6 @@ #include "config.h" -#ifndef CONFIG_9P_SRV_MAX_FIDS - #error config.h must define CONFIG_9P_SRV_MAX_FIDS -#endif -#ifndef CONFIG_9P_SRV_MAX_REQS - #error config.h must define CONFIG_9P_SRV_MAX_REQS -#endif -#ifndef CONFIG_9P_SRV_MAX_DEPTH - /* 1=just the root dir, 2=just files in the root dir, 3=1 subdir, ... */ - #error config.h must define CONFIG_9P_SRV_MAX_DEPTH -#endif #ifndef CONFIG_9P_SRV_MAX_MSG_SIZE #error config.h must define CONFIG_9P_SRV_MAX_MSG_SIZE #endif @@ -61,7 +51,7 @@ bool lib9p_srv_flush_requested(struct lib9p_srv_ctx *ctx) { void lib9p_srv_acknowledge_flush(struct lib9p_srv_ctx *ctx) { assert(ctx); assert(_lib9p_srv_flushch_can_send(&ctx->flushch)); - lib9p_error(&ctx->basectx, LINUX_ECANCELED, "request canceled by flush"); + lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_ECANCELED, "request canceled by flush"); _lib9p_srv_flushch_send(&ctx->flushch, true); } @@ -80,6 +70,8 @@ typedef typeof( ((struct lib9p_qid){}).path ) srv_path_t; struct srv_pathinfo { lo_interface lib9p_srv_file file; enum srv_filetype type; + /* .parent_dir is used for (1) Twalk(".."), and (2) for checking + * permissions on the parent directory for remove(). */ srv_path_t parent_dir; /* References from other srv_pathinfos (via .parent_dir) or @@ -249,14 +241,18 @@ static inline struct srv_pathinfo *srv_path_save(struct srv_req *ctx, static inline void srv_path_decref(struct srv_req *ctx, srv_path_t path) { assert(ctx); - struct srv_pathinfo *pathinfo = map_load(&ctx->parent_sess->paths, path); - assert(pathinfo); - pathinfo->gc_refcount--; - if (pathinfo->gc_refcount == 0) { - if (pathinfo->parent_dir != path) - srv_path_decref(ctx, pathinfo->parent_dir); + for (;;) { + struct srv_pathinfo *pathinfo = map_load(&ctx->parent_sess->paths, path); + assert(pathinfo); + pathinfo->gc_refcount--; + if (pathinfo->gc_refcount) + break; + srv_path_t parent_path = pathinfo->parent_dir; LO_CALL(pathinfo->file, free); map_del(&ctx->parent_sess->paths, path); + if (parent_path == path) + break; + path = parent_path; } } @@ -271,7 +267,7 @@ static inline void srv_fid_del(struct srv_req *ctx, lib9p_fid_t fid, bool remove if (remove) { if (pathinfo->parent_dir == fidinfo->path) { lib9p_errorf(&ctx->basectx, - LINUX_EBUSY, "cannot remove root"); + LIB9P_ERRNO_L_EBUSY, "cannot remove root"); goto clunk; } struct srv_pathinfo *parent = map_load(&ctx->parent_sess->paths, pathinfo->parent_dir); @@ -279,7 +275,7 @@ static inline void srv_fid_del(struct srv_req *ctx, lib9p_fid_t fid, bool remove struct lib9p_stat parent_stat = LO_CALL(parent->file, stat, ctx); if (!srv_check_perm(ctx, &parent_stat, 0b010)) { lib9p_error(&ctx->basectx, - LINUX_EACCES, "remove: you do not have write permission on the parent directory"); + LIB9P_ERRNO_L_EACCES, "you do not have write permission on the parent directory"); goto clunk; } LO_CALL(pathinfo->file, remove, ctx); @@ -310,19 +306,29 @@ static inline void srv_fid_del(struct srv_req *ctx, lib9p_fid_t fid, bool remove * pathinfo->gc_refcount has already been incremented; does *not* * decrement it on failure. */ -static struct srv_fidinfo *srv_fid_store(struct srv_req *ctx, lib9p_fid_t fid, struct srv_pathinfo *pathinfo, bool overwrite) { +static inline struct srv_fidinfo *srv_fid_store(struct srv_req *ctx, lib9p_fid_t fid, struct srv_pathinfo *pathinfo, bool overwrite) { assert(ctx); assert(fid != LIB9P_FID_NOFID); assert(pathinfo); struct lib9p_qid qid = LO_CALL(pathinfo->file, qid); - if (map_load(&ctx->parent_sess->fids, fid)) { + struct srv_fidinfo *old_fidinfo = map_load(&ctx->parent_sess->fids, fid); + if (old_fidinfo) { if (overwrite) { - srv_fid_del(ctx, fid, false); + /* This should only happen from Twalk; because + * directories cannot be RCLOSE and Twalk cannot walk on + * FIDs open for I/O, we can skip most of + * srv_fid_del(). */ + assert(old_fidinfo->type == SRV_FILETYPE_DIR); + assert(old_fidinfo->flags == 0); + + old_fidinfo->authinfo = srv_authinfo_decref(old_fidinfo->authinfo); + srv_path_decref(ctx, old_fidinfo->path); + map_del(&ctx->parent_sess->fids, fid); } else { lib9p_error(&ctx->basectx, - LINUX_EBADF, "FID already in use"); + LIB9P_ERRNO_L_EBADF, "FID already in use"); return NULL; } } @@ -382,11 +388,11 @@ static void srv_respond_error(struct srv_req *req) { /* XXX: This assumes that a version's min_msg_size is the * Rerror overhead. That's true for the current - * implementation of protogen, but is a sneaky assumption. */ + * implementation of core_gen, but is a sneaky assumption. */ uint32_t overhead = lib9p_version_min_msg_size(sess->version); /* Truncate the error-string if necessary to avoid needing to - * return LINUX_ERANGE. */ + * return LIB9P_ERRNO_L_ERANGE. */ if (((uint32_t)host.errstr.len) + overhead > sess->max_msg_size) host.errstr.len = sess->max_msg_size - overhead; @@ -487,7 +493,7 @@ void lib9p_srv_read(struct lib9p_srv *srv, lo_interface net_stream_conn _conn) { }; if (goal > sess.max_msg_size) { lib9p_errorf(&req.basectx, - LINUX_EMSGSIZE, "T-message larger than %s limit (%zu > %"PRIu32")", + LIB9P_ERRNO_L_EMSGSIZE, "T-message larger than %s limit (%zu > %"PRIu32")", sess.initialized ? "negotiated" : "server", goal, sess.max_msg_size); @@ -712,7 +718,7 @@ static void handle_Tversion(struct srv_req *ctx, uint32_t min_msg_size = lib9p_version_min_msg_size(version); if (req->max_msg_size < min_msg_size) { lib9p_errorf(&ctx->basectx, - LINUX_EDOM, "requested max_msg_size is less than minimum for %s (%"PRIu32" < %"PRIu32")", + 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; } @@ -763,7 +769,7 @@ static void handle_Tauth(struct srv_req *ctx, struct lib9p_srv *srv = ctx->parent_sess->parent_conn->parent_srv; if (!srv->auth) { lib9p_error(&ctx->basectx, - LINUX_EOPNOTSUPP, "authentication not required"); + LIB9P_ERRNO_L_EOPNOTSUPP, "authentication not required"); return; } @@ -772,7 +778,7 @@ static void handle_Tauth(struct srv_req *ctx, srv->auth(ctx, req->aname); lib9p_error(&ctx->basectx, - LINUX_EOPNOTSUPP, "TODO: auth not implemented"); + LIB9P_ERRNO_L_EOPNOTSUPP, "TODO: auth not implemented"); if (lib9p_ctx_has_error(&ctx->basectx)) ctx->authinfo = srv_authinfo_decref(ctx->authinfo); @@ -785,7 +791,7 @@ static void handle_Tattach(struct srv_req *ctx, if (req->fid == LIB9P_FID_NOFID) { lib9p_error(&ctx->basectx, - LINUX_EBADF, "cannot assign to NOFID"); + LIB9P_ERRNO_L_EBADF, "cannot assign to NOFID"); return; } @@ -794,36 +800,36 @@ static void handle_Tattach(struct srv_req *ctx, struct srv_fidinfo *afid = map_load(&ctx->parent_sess->fids, req->afid); if (!afid) lib9p_error(&ctx->basectx, - LINUX_EACCES, "FID provided as auth-file is not a valid FID"); + LIB9P_ERRNO_L_EACCES, "FID provided as auth-file is not a valid FID"); else if (afid->type != SRV_FILETYPE_AUTH) lib9p_error(&ctx->basectx, - LINUX_EACCES, "FID provided as auth-file is not an auth-file"); + LIB9P_ERRNO_L_EACCES, "FID provided as auth-file is not an auth-file"); else if (!lib9p_str_eq(afid->authinfo->uname, req->uname)) lib9p_errorf(&ctx->basectx, - LINUX_EACCES, "FID provided as auth-file is for user=\"%.*s\" and cannot be used for user=\"%.*s\"", + 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, req->uname.len, req->uname.utf8); #if CONFIG_9P_ENABLE_9P2000_u else if (afid->authinfo->uid != req->n_uid) lib9p_errorf(&ctx->basectx, - LINUX_EACCES, "FID provided as auth-file is for user=%"PRIu32" and cannot be used for user=%"PRIu32, + 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); #endif else if (!lib9p_str_eq(afid->auth.aname, req->aname)) lib9p_errorf(&ctx->basectx, - LINUX_EACCES, "FID provided as auth-file is for tree=\"%.*s\" and cannot be used for tree=\"%.*s\"", + LIB9P_ERRNO_L_EACCES, "FID provided as auth-file is for tree=\"%.*s\" and cannot be used for tree=\"%.*s\"", afid->auth.aname.len, afid->auth.aname.utf8, req->aname.len, req->aname.utf8); else if (!afid->auth.completed) lib9p_error(&ctx->basectx, - LINUX_EACCES, "FID provided as auth-file has not completed authentication"); + 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); } else { if (req->afid != LIB9P_FID_NOFID) { lib9p_error(&ctx->basectx, - LINUX_EACCES, "FID provided as auth-file, but no auth-file is required"); + LIB9P_ERRNO_L_EACCES, "FID provided as auth-file, but no auth-file is required"); return; } ctx->authinfo = srv_authinfo_new(req->uname, req->n_uid); @@ -872,14 +878,19 @@ static void handle_Twalk(struct srv_req *ctx, if (req->newfid == LIB9P_FID_NOFID) { lib9p_error(&ctx->basectx, - LINUX_EBADF, "cannot assign to NOFID"); + LIB9P_ERRNO_L_EBADF, "cannot assign to NOFID"); return; } struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid); if (!fidinfo) { lib9p_errorf(&ctx->basectx, - LINUX_EBADF, "bad file number %"PRIu32, req->fid); + LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid); + return; + } + if (fidinfo->flags & FIDFLAG_OPEN) { + lib9p_error(&ctx->basectx, + LIB9P_ERRNO_L_EALREADY, "cannot walk on FID open for I/O"); return; } ctx->authinfo = srv_authinfo_incref(fidinfo->authinfo); @@ -890,23 +901,24 @@ static void handle_Twalk(struct srv_req *ctx, resp->wqid = (struct lib9p_qid *)(&resp[1]); 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"); + break; + } + struct srv_pathinfo *new_pathinfo; 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 { - if (pathinfo->type != SRV_FILETYPE_DIR) { - lib9p_error(&ctx->basectx, - LINUX_ENOTDIR, "not a directory"); - break; - } - 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; new_pathinfo = srv_path_save(ctx, member_file, LO_CALL(pathinfo->file, qid).path); + assert(new_pathinfo); } if (new_pathinfo->type == SRV_FILETYPE_DIR) { @@ -916,7 +928,7 @@ static void handle_Twalk(struct srv_req *ctx, lib9p_stat_assert(stat); if (!srv_check_perm(ctx, &stat, 0b001)) { lib9p_error(&ctx->basectx, - LINUX_EACCES, "you do not have execute permission on that directory"); + LIB9P_ERRNO_L_EACCES, "you do not have execute permission on that directory"); srv_path_decref(ctx, LO_CALL(new_pathinfo->file, qid).path); break; } @@ -948,12 +960,12 @@ static void handle_Topen(struct srv_req *ctx, struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid); if (!fidinfo) { lib9p_errorf(&ctx->basectx, - LINUX_EBADF, "bad file number %"PRIu32, req->fid); + LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid); return; } if (fidinfo->flags & FIDFLAG_OPEN) { lib9p_error(&ctx->basectx, - LINUX_EALREADY, "FID is already open"); + LIB9P_ERRNO_L_EALREADY, "FID is already open"); return; } if (fidinfo->type == SRV_FILETYPE_DIR) { @@ -961,7 +973,7 @@ static void handle_Topen(struct srv_req *ctx, (req->mode & LIB9P_O_TRUNC) || (req->mode & LIB9P_O_RCLOSE) ) { lib9p_error(&ctx->basectx, - LINUX_EISDIR, "directories cannot be written, executed, truncated, or removed-on-close"); + LIB9P_ERRNO_L_EISDIR, "directories cannot be written, executed, truncated, or removed-on-close"); return; } } @@ -983,7 +995,7 @@ static void handle_Topen(struct srv_req *ctx, lib9p_stat_assert(parent_stat); if (!srv_check_perm(ctx, &parent_stat, 0b010)) { lib9p_error(&ctx->basectx, - LINUX_EACCES, "permission denied to remove-on-close"); + LIB9P_ERRNO_L_EACCES, "permission denied to remove-on-close"); goto topen_return; } fidflags |= FIDFLAG_RCLOSE; @@ -994,7 +1006,7 @@ static void handle_Topen(struct srv_req *ctx, lib9p_stat_assert(stat); if ((stat.file_mode & LIB9P_DM_EXCL) && pathinfo->io_refcount) { lib9p_error(&ctx->basectx, - LINUX_EEXIST, "exclusive file is already opened"); + LIB9P_ERRNO_L_EEXIST, "exclusive file is already opened"); goto topen_return; } if (stat.file_mode & LIB9P_DM_APPEND) @@ -1021,7 +1033,7 @@ static void handle_Topen(struct srv_req *ctx, } if (!srv_check_perm(ctx, &stat, perm_bits)) { lib9p_error(&ctx->basectx, - LINUX_EACCES, "permission denied"); + LIB9P_ERRNO_L_EACCES, "permission denied"); goto topen_return; } @@ -1076,7 +1088,7 @@ static void handle_Tcreate(struct srv_req *ctx, srv_handler_common(ctx, req, resp); lib9p_error(&ctx->basectx, - LINUX_EOPNOTSUPP, "create not (yet?) implemented"); + LIB9P_ERRNO_L_EOPNOTSUPP, "create not (yet?) implemented"); } static void handle_Tread(struct srv_req *ctx, @@ -1090,12 +1102,12 @@ static void handle_Tread(struct srv_req *ctx, struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid); if (!fidinfo) { lib9p_errorf(&ctx->basectx, - LINUX_EBADF, "bad file number %"PRIu32, req->fid); + LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid); return; } if (!(fidinfo->flags & FIDFLAG_OPEN_R)) { lib9p_error(&ctx->basectx, - LINUX_EINVAL, "FID not open for reading"); + LIB9P_ERRNO_L_EINVAL, "FID not open for reading"); return; } @@ -1111,7 +1123,7 @@ static void handle_Tread(struct srv_req *ctx, idx = fidinfo->dir.idx; else { lib9p_errorf(&ctx->basectx, - LINUX_EINVAL, "invalid offset (must be 0 or %"PRIu64"): %"PRIu64, + 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; @@ -1159,12 +1171,12 @@ static void handle_Twrite(struct srv_req *ctx, struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid); if (!fidinfo) { lib9p_errorf(&ctx->basectx, - LINUX_EBADF, "bad file number %"PRIu32, req->fid); + LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid); return; } if (!(fidinfo->flags & FIDFLAG_OPEN_W)) { lib9p_error(&ctx->basectx, - LINUX_EINVAL, "FID not open for writing"); + LIB9P_ERRNO_L_EINVAL, "FID not open for writing"); return; } @@ -1182,7 +1194,7 @@ static void handle_Tclunk(struct srv_req *ctx, struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid); if (!fidinfo) { lib9p_errorf(&ctx->basectx, - LINUX_EBADF, "bad file number %"PRIu32, req->fid); + LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid); return; } @@ -1199,7 +1211,7 @@ static void handle_Tremove(struct srv_req *ctx, struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid); if (!fidinfo) { lib9p_errorf(&ctx->basectx, - LINUX_EBADF, "bad file number %"PRIu32, req->fid); + LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid); return; } @@ -1216,7 +1228,7 @@ static void handle_Tstat(struct srv_req *ctx, struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid); if (!fidinfo) { lib9p_errorf(&ctx->basectx, - LINUX_EBADF, "bad file number %"PRIu32, req->fid); + LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid); return; } struct srv_pathinfo *pathinfo = map_load(&ctx->parent_sess->paths, fidinfo->path); @@ -1235,7 +1247,7 @@ static void handle_Twstat(struct srv_req *ctx, srv_handler_common(ctx, req, resp); lib9p_error(&ctx->basectx, - LINUX_EOPNOTSUPP, "wstat not (yet?) implemented"); + LIB9P_ERRNO_L_EOPNOTSUPP, "wstat not (yet?) implemented"); } #if CONFIG_9P_ENABLE_9P2000_p9p @@ -1245,7 +1257,7 @@ static void handle_Topenfd(struct srv_req *ctx, srv_handler_common(ctx, req, resp); lib9p_error(&ctx->basectx, - LINUX_EOPNOTSUPP, "openfd not (yet?) implemented"); + LIB9P_ERRNO_L_EOPNOTSUPP, "openfd not (yet?) implemented"); } #endif @@ -1256,7 +1268,7 @@ static void handle_Tsession(struct srv_req *ctx, srv_handler_common(ctx, req, resp); lib9p_error(&ctx->basectx, - LINUX_EOPNOTSUPP, "session not (yet?) implemented"); + LIB9P_ERRNO_L_EOPNOTSUPP, "session not (yet?) implemented"); } static void handle_Tsread(struct srv_req *ctx, @@ -1265,7 +1277,7 @@ static void handle_Tsread(struct srv_req *ctx, srv_handler_common(ctx, req, resp); lib9p_error(&ctx->basectx, - LINUX_EOPNOTSUPP, "sread not (yet?) implemented"); + LIB9P_ERRNO_L_EOPNOTSUPP, "sread not (yet?) implemented"); } static void handle_Tswrite(struct srv_req *ctx, @@ -1274,6 +1286,6 @@ static void handle_Tswrite(struct srv_req *ctx, srv_handler_common(ctx, req, resp); lib9p_error(&ctx->basectx, - LINUX_EOPNOTSUPP, "swrite not (yet?) implemented"); + LIB9P_ERRNO_L_EOPNOTSUPP, "swrite not (yet?) implemented"); } #endif diff --git a/lib9p/include/lib9p/srv.h b/lib9p/srv_include/lib9p/srv.h index bb5efb9..db5be41 100644 --- a/lib9p/include/lib9p/srv.h +++ b/lib9p/srv_include/lib9p/srv.h @@ -15,7 +15,7 @@ #include <libmisc/private.h> #include <libobj/obj.h> -#include <lib9p/9p.h> +#include <lib9p/core.h> /* context ********************************************************************/ @@ -203,11 +203,11 @@ void lib9p_srv_accept_and_read_loop(struct lib9p_srv *srv, lo_interface net_stre * * Errors that this function itself may send to clients: * - * @errno LINUX_EMSGSIZE T-message has size[4] bigger than max_msg_size - * @errno LINUX_EDOM Tversion specified an impossibly small max_msg_size - * @errno LINUX_EOPNOTSUPP T-message has an R-message type, or an unrecognized T-message type - * @errno LINUX_EBADMSG T-message has wrong size[4] for its content, or has invalid UTF-8 - * @errno LINUX_ERANGE R-message does not fit into max_msg_size + * @errno L_EMSGSIZE T-message has size[4] bigger than max_msg_size + * @errno L_EDOM Tversion specified an impossibly small max_msg_size + * @errno L_EOPNOTSUPP T-message has an R-message type, or an unrecognized T-message type + * @errno L_EBADMSG T-message has wrong size[4] for its content, or has invalid UTF-8 + * @errno L_ERANGE R-message does not fit into max_msg_size */ void lib9p_srv_read(struct lib9p_srv *srv, lo_interface net_stream_conn conn); diff --git a/lib9p/tests/client_config/config.h b/lib9p/tests/client_config/config.h index 65ee9de..bcf030d 100644 --- a/lib9p/tests/client_config/config.h +++ b/lib9p/tests/client_config/config.h @@ -7,8 +7,6 @@ #ifndef _CONFIG_H_ #define _CONFIG_H_ -/* 9P *************************************************************************/ - #define CONFIG_9P_MAX_ERR_SIZE 128 #define CONFIG_9P_MAX_9P2000_e_WELEM 16 @@ -18,23 +16,4 @@ #define CONFIG_9P_ENABLE_9P2000_L 1 /* bool */ #define CONFIG_9P_ENABLE_9P2000_p9p 1 /* bool */ -/* 9P server (unused) *********************************************************/ - -#define CONFIG_9P_SRV_MAX_MSG_SIZE ((4*1024)+24) -#define CONFIG_9P_SRV_MAX_HOSTMSG_SIZE CONFIG_9P_SRV_MAX_MSG_SIZE+16 -#define CONFIG_9P_SRV_MAX_FIDS 16 -#define CONFIG_9P_SRV_MAX_REQS 2 -#define CONFIG_9P_SRV_MAX_DEPTH 3 - -/* COROUTINE (unused) *********************************************************/ - -#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 2 - #endif /* _CONFIG_H_ */ diff --git a/lib9p/tests/test_compile.c b/lib9p/tests/test_compile.c index 8f2445d..4532655 100644 --- a/lib9p/tests/test_compile.c +++ b/lib9p/tests/test_compile.c @@ -1,6 +1,6 @@ /* lib9p/tests/test_compile.c - Generated by lib9p/tests/test_compile.c.gen. DO NOT EDIT! */ -#include <lib9p/9p.h> +#include <lib9p/core.h> int main(void) { [[gnu::unused]] uint64_t x; x = LIB9P_TAG_NOTAG; @@ -47,7 +47,6 @@ int main(void) { x = LIB9P_QT_SYMLINK; x = _LIB9P_QT_UNUSED_0; x = LIB9P_QT_FILE; - x = LIB9P_NUID_NONUID; x = _LIB9P_O_UNUSED_7; x = LIB9P_O_RCLOSE; x = _LIB9P_O_RESERVED_CEXEC; @@ -60,7 +59,139 @@ int main(void) { 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; + 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; + 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; + x = LIB9P_ERRNO_L_EBADE; + x = LIB9P_ERRNO_L_EBADR; + x = LIB9P_ERRNO_L_EXFULL; + x = LIB9P_ERRNO_L_ENOANO; + x = LIB9P_ERRNO_L_EBADRQC; + x = LIB9P_ERRNO_L_EBADSLT; + 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; + x = LIB9P_ERRNO_L_ECOMM; + x = LIB9P_ERRNO_L_EPROTO; + x = LIB9P_ERRNO_L_EMULTIHOP; + 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; + x = LIB9P_ERRNO_L_ELIBACC; + x = LIB9P_ERRNO_L_ELIBBAD; + x = LIB9P_ERRNO_L_ELIBSCN; + x = LIB9P_ERRNO_L_ELIBMAX; + 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; + 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; + x = LIB9P_ERRNO_L_ENETDOWN; + x = LIB9P_ERRNO_L_ENETUNREACH; + x = LIB9P_ERRNO_L_ENETRESET; + x = LIB9P_ERRNO_L_ECONNABORTED; + x = LIB9P_ERRNO_L_ECONNRESET; + x = LIB9P_ERRNO_L_ENOBUFS; + x = LIB9P_ERRNO_L_EISCONN; + 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; + 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; + x = LIB9P_ERRNO_L_ENOTRECOVERABLE; + 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; diff --git a/lib9p/tests/test_compile.c.gen b/lib9p/tests/test_compile.c.gen index 47046b3..1289943 100755 --- a/lib9p/tests/test_compile.c.gen +++ b/lib9p/tests/test_compile.c.gen @@ -10,7 +10,7 @@ outfile=$2 { echo "/* ${outfile} - Generated by $0. DO NOT EDIT! */" echo - echo "#include <lib9p/9p.h>" + 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" diff --git a/lib9p/tests/test_compile_config/config.h b/lib9p/tests/test_compile_config/config.h index cc8eec1..f899dfa 100644 --- a/lib9p/tests/test_compile_config/config.h +++ b/lib9p/tests/test_compile_config/config.h @@ -7,32 +7,13 @@ #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_SRV_MAX_MSG_SIZE ((4*1024)+24) -#define CONFIG_9P_SRV_MAX_HOSTMSG_SIZE CONFIG_9P_SRV_MAX_MSG_SIZE+16 -#define CONFIG_9P_SRV_MAX_FIDS 16 -#define CONFIG_9P_SRV_MAX_REQS 2 -#define CONFIG_9P_SRV_MAX_DEPTH 3 - #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 */ -/* 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 2 - #endif /* _CONFIG_H_ */ diff --git a/lib9p/tests/test_server/CMakeLists.txt b/lib9p/tests/test_server/CMakeLists.txt index 681e583..b659373 100644 --- a/lib9p/tests/test_server/CMakeLists.txt +++ b/lib9p/tests/test_server/CMakeLists.txt @@ -19,7 +19,6 @@ target_link_libraries(test_server_objs libcr libcr_ipc libmisc - lib9p lib9p_util libhw_cr ) diff --git a/lib9p/tests/test_server/config/config.h b/lib9p/tests/test_server/config/config.h index 03143e1..d9cf008 100644 --- a/lib9p/tests/test_server/config/config.h +++ b/lib9p/tests/test_server/config/config.h @@ -7,8 +7,8 @@ #ifndef _CONFIG_H_ #define _CONFIG_H_ -#define _CONFIG_9P_NUM_SOCKS 8 -#define CONFIG_SRV9P_NUM_CONNS _CONFIG_9P_NUM_SOCKS +#define _CONFIG_9P_MAX_CONNS 8 +#define _CONFIG_9P_MAX_REQS (2*_CONFIG_9P_MAX_CONNS) /* 9P *************************************************************************/ @@ -38,9 +38,6 @@ * struct padding, (2) array pointers. */ #define CONFIG_9P_SRV_MAX_HOSTMSG_SIZE CONFIG_9P_SRV_MAX_MSG_SIZE+16 -#define CONFIG_9P_SRV_MAX_FIDS 16 -#define CONFIG_9P_SRV_MAX_REQS 2 -#define CONFIG_9P_SRV_MAX_DEPTH 3 #define CONFIG_9P_ENABLE_9P2000 1 /* bool */ #define CONFIG_9P_ENABLE_9P2000_u 1 /* bool */ @@ -57,10 +54,10 @@ #define CONFIG_COROUTINE_DEBUG 0 /* bool */ #define CONFIG_COROUTINE_VALGRIND 1 /* bool */ #define CONFIG_COROUTINE_GDB 1 /* bool */ -#define CONFIG_COROUTINE_NUM ( \ - 1 /* usb_common */ + \ - 1 /* usb_keyboard */ + \ - CONFIG_SRV9P_NUM_CONNS /* accept+read */ + \ - (CONFIG_9P_SRV_MAX_REQS*CONFIG_SRV9P_NUM_CONNS) /* work+write */ ) +#define CONFIG_COROUTINE_NUM ( \ + 1 /* usb_common */ + \ + 1 /* usb_keyboard */ + \ + _CONFIG_9P_MAX_CONNS /* accept+read */ + \ + _CONFIG_9P_MAX_REQS /* work+write */ ) #endif /* _CONFIG_H_ */ diff --git a/lib9p/tests/test_server/fs_shutdown.c b/lib9p/tests/test_server/fs_shutdown.c index 26a8a10..e872b78 100644 --- a/lib9p/tests/test_server/fs_shutdown.c +++ b/lib9p/tests/test_server/fs_shutdown.c @@ -54,12 +54,12 @@ static struct lib9p_stat shutdown_file_stat(struct shutdown_file *self, struct l static void shutdown_file_wstat(struct shutdown_file *self, struct lib9p_srv_ctx *ctx, struct lib9p_stat) { assert(self); assert(ctx); - lib9p_error(&ctx->basectx, LINUX_EROFS, "cannot wstat API file"); + lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EROFS, "cannot wstat API file"); } static void shutdown_file_remove(struct shutdown_file *self, struct lib9p_srv_ctx *ctx) { assert(self); assert(ctx); - lib9p_error(&ctx->basectx, LINUX_EROFS, "cannot remove API file"); + lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EROFS, "cannot remove API file"); } LIB9P_SRV_NOTDIR(struct shutdown_file, shutdown_file) diff --git a/lib9p/tests/test_server/fs_slowread.c b/lib9p/tests/test_server/fs_slowread.c index c5db896..c94fba0 100644 --- a/lib9p/tests/test_server/fs_slowread.c +++ b/lib9p/tests/test_server/fs_slowread.c @@ -54,12 +54,12 @@ static struct lib9p_stat slowread_file_stat(struct slowread_file *self, struct l static void slowread_file_wstat(struct slowread_file *self, struct lib9p_srv_ctx *ctx, struct lib9p_stat) { assert(self); assert(ctx); - lib9p_error(&ctx->basectx, LINUX_EROFS, "cannot wstat API file"); + lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EROFS, "cannot wstat API file"); } static void slowread_file_remove(struct slowread_file *self, struct lib9p_srv_ctx *ctx) { assert(self); assert(ctx); - lib9p_error(&ctx->basectx, LINUX_EROFS, "cannot remove API file"); + lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EROFS, "cannot remove API file"); } LIB9P_SRV_NOTDIR(struct slowread_file, slowread_file) diff --git a/lib9p/tests/test_server/fs_whoami.c b/lib9p/tests/test_server/fs_whoami.c index ff6dd25..560e31f 100644 --- a/lib9p/tests/test_server/fs_whoami.c +++ b/lib9p/tests/test_server/fs_whoami.c @@ -75,12 +75,12 @@ static struct lib9p_stat whoami_file_stat(struct whoami_file *self, struct lib9p static void whoami_file_wstat(struct whoami_file *self, struct lib9p_srv_ctx *ctx, struct lib9p_stat) { assert(self); assert(ctx); - lib9p_error(&ctx->basectx, LINUX_EROFS, "cannot wstat API file"); + lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EROFS, "cannot wstat API file"); } static void whoami_file_remove(struct whoami_file *self, struct lib9p_srv_ctx *ctx) { assert(self); assert(ctx); - lib9p_error(&ctx->basectx, LINUX_EROFS, "cannot remove API file"); + lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EROFS, "cannot remove API file"); } LIB9P_SRV_NOTDIR(struct whoami_file, whoami_file) @@ -140,7 +140,7 @@ static void whoami_fio_pread(struct whoami_fio *self, struct lib9p_srv_ctx *ctx, if (byte_offset > (uint64_t)data_size) { lib9p_error(&ctx->basectx, - LINUX_EINVAL, "offset is past end-of-file length"); + LIB9P_ERRNO_L_EINVAL, "offset is past end-of-file length"); return; } diff --git a/lib9p/tests/test_server/main.c b/lib9p/tests/test_server/main.c index e89a75e..0705747 100644 --- a/lib9p/tests/test_server/main.c +++ b/lib9p/tests/test_server/main.c @@ -27,8 +27,11 @@ #include "config.h" -#ifndef CONFIG_SRV9P_NUM_CONNS - #error config.h must define CONFIG_SRV9P_NUM_CONNS +#ifndef _CONFIG_9P_MAX_CONNS + #error config.h must define _CONFIG_9P_MAX_CONNS +#endif +#ifndef _CONFIG_9P_MAX_REQS + #error config.h must define _CONFIG_9P_MAX_REQS #endif /* globals ********************************************************************/ @@ -39,7 +42,7 @@ const char *hexdig = "0123456789abcdef"; struct { uint16_t port; - struct hostnet_tcp_listener listeners[CONFIG_SRV9P_NUM_CONNS]; + struct hostnet_tcp_listener listeners[_CONFIG_9P_MAX_CONNS]; struct lib9p_srv srv; FILE *logstream; } globals = { @@ -108,14 +111,14 @@ static COROUTINE write_cr(void *) { static COROUTINE init_cr(void *) { cr_begin(); - sleep_for_ms(1); + sleep_for_ms(1); /* test that sleep works */ - for (int i = 0; i < CONFIG_SRV9P_NUM_CONNS; i++) { + for (int i = 0; i < _CONFIG_9P_MAX_CONNS; i++) { char name[] = {'r', 'e', 'a', 'd', '-', hexdig[i], '\0'}; if (!coroutine_add(name, read_cr, &i)) error(1, 0, "coroutine_add(read_cr, &i)"); } - for (int i = 0; i < 2*CONFIG_SRV9P_NUM_CONNS; i++) { + for (int i = 0; i < _CONFIG_9P_MAX_REQS; i++) { char name[] = {'w', 'r', 'i', 't', 'e', '-', hexdig[i], '\0'}; if (!coroutine_add(name, write_cr, NULL)) error(1, 0, "coroutine_add(write_cr, NULL)"); diff --git a/lib9p/tests/testclient-p9p.explog b/lib9p/tests/testclient-p9p.explog index 45651a4..e5901d2 100644 --- a/lib9p/tests/testclient-p9p.explog +++ b/lib9p/tests/testclient-p9p.explog @@ -5,7 +5,7 @@ > 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 } -< Rerror { tag=0 errstr="authentication not required" errnum=95 } +< Rerror { tag=0 errstr="authentication not required" errnum=L_EOPNOTSUPP } > Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" n_uid=0 } < Rattach { tag=0 qid={ type=(DIR) vers=1 path=1 } } > Twalk { tag=0 fid=0 newfid=1 nwname=0 wname=[ ] } @@ -27,17 +27,17 @@ > 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 } -< Rerror { tag=0 errstr="authentication not required" errnum=95 } +< Rerror { tag=0 errstr="authentication not required" errnum=L_EOPNOTSUPP } > Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" n_uid=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 } ] } +> 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 } } > Tclunk { tag=0 fid=1 } < Rclunk { tag=0 } -> Twalk { tag=0 fid=0 newfid=1 nwname=1 wname=["Documentation" ] } -< Rwalk { tag=0 nwqid=1 wqid=[{ type=(DIR) vers=1 path=2 } ] } +> Twalk { tag=0 fid=0 newfid=1 nwname=1 wname=[ "Documentation" ] } +< Rwalk { tag=0 nwqid=1 wqid=[ { type=(DIR) vers=1 path=2 } ] } > Topen { tag=0 fid=1 mode=(MODE_READ) } < Ropen { tag=0 qid={ type=(DIR) vers=1 path=2 } iounit=0 } > Tread { tag=0 fid=1 offset=0 count=4096 } @@ -49,11 +49,11 @@ > 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 } -< Rerror { tag=0 errstr="authentication not required" errnum=95 } +< Rerror { tag=0 errstr="authentication not required" errnum=L_EOPNOTSUPP } > Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" n_uid=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 } ] } +> Twalk { tag=0 fid=0 newfid=1 nwname=1 wname=[ "README.md" ] } +< Rwalk { tag=0 nwqid=1 wqid=[ { type=(0) vers=1 path=4 } ] } > Topen { tag=0 fid=1 mode=(MODE_READ) } < Ropen { tag=0 qid={ type=(0) vers=1 path=4 } iounit=0 } > Tread { tag=0 fid=1 offset=0 count=4096 } @@ -65,11 +65,11 @@ > 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 } -< Rerror { tag=0 errstr="authentication not required" errnum=95 } +< Rerror { tag=0 errstr="authentication not required" errnum=L_EOPNOTSUPP } > Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" n_uid=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 } ] } +> 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 } ] } > Topen { tag=0 fid=1 mode=(MODE_READ) } < Ropen { tag=0 qid={ type=(0) vers=1 path=3 } iounit=0 } > Tread { tag=0 fid=1 offset=0 count=4096 } @@ -81,11 +81,11 @@ > 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 } -< Rerror { tag=0 errstr="authentication not required" errnum=95 } +< Rerror { tag=0 errstr="authentication not required" errnum=L_EOPNOTSUPP } > Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" n_uid=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 } ] } +> 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 } } > Tclunk { tag=0 fid=1 } @@ -93,11 +93,11 @@ > 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 } -< Rerror { tag=0 errstr="authentication not required" errnum=95 } +< Rerror { tag=0 errstr="authentication not required" errnum=L_EOPNOTSUPP } > Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" n_uid=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 } ] } +> Twalk { tag=0 fid=0 newfid=1 nwname=1 wname=[ "shutdown" ] } +< Rwalk { tag=0 nwqid=1 wqid=[ { type=(0) 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 } > Twrite { tag=0 fid=1 offset=0 count=2 data="1\n" } diff --git a/lib9p/tests/testclient-sess.c b/lib9p/tests/testclient-sess.c index 437c489..ded70d1 100644 --- a/lib9p/tests/testclient-sess.c +++ b/lib9p/tests/testclient-sess.c @@ -15,7 +15,7 @@ #include <libmisc/assert.h> #include <libmisc/endian.h> -#include <lib9p/9p.h> +#include <lib9p/core.h> #define MAX_MSG_SIZE (8*1024) @@ -112,6 +112,56 @@ int main(int argc, char *argv[]) { send9p(Tread, .tag=0, .fid=3, .offset=0, .count=100); recv9p(); /* Rread */ + /* walk ***************************************************************/ + send9p(Tversion, .tag=0, .max_msg_size=(8*1024), .version=lib9p_str("9P2000")); + recv9p(); /* Rversion */ + ctx.version = LIB9P_VER_9P2000; + send9p(Tattach, .tag=0, .fid=0, .afid=LIB9P_FID_NOFID, .uname=lib9p_str("nobody"), .aname=lib9p_str("")); + recv9p(); /* Rattach */ + + /* dup */ + send9p(Twalk, .tag=0, .fid=0, .newfid=1, .nwname=0); + recv9p(); /* Rwalk */ + + /* "The walk request carries as arguments an existing fid"... */ + send9p(Twalk, .tag=0, .fid=2, .newfid=3, .nwname=0); + recv9p(); /* Rerror */ + + /* ..."and a proposed newfid"... */ + send9p(Twalk, .tag=0, .fid=1, .newfid=0xffffffff, .nwname=0); + recv9p(); /* Rerror */ + + /* ..."(which must not be in use"... */ + send9p(Twalk, .tag=0, .fid=1, .newfid=0, .nwname=0); + recv9p(); /* Rerror */ + + /* ..."unless it is the same as fid)"... */ + send9p(Twalk, .tag=0, .fid=1, .newfid=1, .nwname=0); + recv9p(); /* Rwalk */ + + /* ... "that the client wishes to associate with the result of + * traversing the directory hierarchy by `walking' the heierarchy using + * the successive path name elements wname."... */ + + /* ..."The fid must represent a directory"... */ + wname[0] = lib9p_str("README.md"); send9p(Twalk, .tag=0, .fid=1, .newfid=2, .nwname=1, .wname=wname); + recv9p(); /* Rwalk */ + wname[0] = lib9p_str(".."); send9p(Twalk, .tag=0, .fid=2, .newfid=3, .nwname=1, .wname=wname); + recv9p(); /* Rerror */ + + /* ..."unless zero path name elements are specified." */ + send9p(Twalk, .tag=0, .fid=2, .newfid=3, .nwname=0); + recv9p(); /* Rwalk */ + + /* "The fid must be valid in the current session" (tested above)... */ + + /* ..."and must not have been opened for I/O by an open or create + * message."... */ + send9p(Topen, .tag=0, .fid=3, .mode=LIB9P_O_MODE_READ); + recv9p(); /* Ropen */ + send9p(Twalk, .tag=0, .fid=3, .newfid=4, .nwname=0); + recv9p(); /* Rerror */ + /* flush **************************************************************/ send9p(Tversion, .tag=0, .max_msg_size=(8*1024), .version=lib9p_str("9P2000")); recv9p(); /* Rversion */ diff --git a/lib9p/tests/testclient-sess.explog b/lib9p/tests/testclient-sess.explog index 6aab242..3e2209a 100644 --- a/lib9p/tests/testclient-sess.explog +++ b/lib9p/tests/testclient-sess.explog @@ -18,10 +18,10 @@ < Rattach { tag=0 qid={ type=(DIR) vers=1 path=1 } } > Tattach { tag=0 fid=1 afid=NOFID uname="bob" aname="" n_uid=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 } ] } -> Twalk { tag=0 fid=1 newfid=3 nwname=1 wname=["whoami" ] } -< Rwalk { tag=0 nwqid=1 wqid=[{ type=(0) vers=1 path=8 } ] } +> Twalk { tag=0 fid=0 newfid=2 nwname=1 wname=[ "whoami" ] } +< Rwalk { tag=0 nwqid=1 wqid=[ { type=(0) vers=1 path=8 } ] } +> Twalk { tag=0 fid=1 newfid=3 nwname=1 wname=[ "whoami" ] } +< Rwalk { tag=0 nwqid=1 wqid=[ { type=(0) vers=1 path=8 } ] } > Topen { tag=0 fid=2 mode=(MODE_READ) } < Ropen { tag=0 qid={ type=(0) vers=1 path=8 } iounit=0 } > Topen { tag=0 fid=3 mode=(MODE_READ) } @@ -31,6 +31,55 @@ > Tread { tag=0 fid=3 offset=0 count=100 } < Rread { tag=0 count=9 data="1001 bob\n" } +# 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 } +< Rattach { tag=0 qid={ type=(DIR) vers=1 path=1 } } + +# dup +> Twalk { tag=0 fid=0 newfid=1 nwname=0 wname=[ ] } +< Rwalk { tag=0 nwqid=0 wqid=[ ] } + +# "The walk request carries as arguments an existing fid"... +> Twalk { tag=0 fid=2 newfid=3 nwname=0 wname=[ ] } +< Rerror { tag=0 errstr="bad file number 2" errnum=L_EBADF } + +# ..."and a proposed newfid"... +> Twalk { tag=0 fid=1 newfid=NOFID nwname=0 wname=[ ] } +< Rerror { tag=0 errstr="cannot assign to NOFID" errnum=L_EBADF } + +# ..."(which must not be in use"... +> Twalk { tag=0 fid=1 newfid=0 nwname=0 wname=[ ] } +< Rerror { tag=0 errstr="FID already in use" errnum=L_EBADF } + +# ..."unless it is the same as fid)"... +> Twalk { tag=0 fid=1 newfid=1 nwname=0 wname=[ ] } +< Rwalk { tag=0 nwqid=0 wqid=[ ] } + +# ... "that the client wishes to associate with the result of +# traversing the directory hierarchy by `walking' the heierarchy using +# the successive path name elements wname."... + +# ..."The fid must represent a directory"... +> Twalk { tag=0 fid=1 newfid=2 nwname=1 wname=[ "README.md" ] } +< Rwalk { tag=0 nwqid=1 wqid=[ { type=(0) vers=1 path=4 } ] } +> Twalk { tag=0 fid=2 newfid=3 nwname=1 wname=[ ".." ] } +< Rerror { tag=0 errstr="not a directory" errnum=L_ENOTDIR } + +# ..."unless zero path name elements are specified." +> Twalk { tag=0 fid=2 newfid=3 nwname=0 wname=[ ] } +< Rwalk { tag=0 nwqid=0 wqid=[ ] } + +# "The fid must be valid in the current session" (tested above)... + +# ..."and must not have been opened for I/O by an open or create +# message."... +> Topen { tag=0 fid=3 mode=(MODE_READ) } +< Ropen { tag=0 qid={ type=(0) vers=1 path=4 } iounit=0 } +> Twalk { tag=0 fid=3 newfid=4 nwname=0 wname=[ ] } +< Rerror { tag=0 errstr="cannot walk on FID open for I/O" errnum=L_EALREADY } + # flush ######################################################################## > Tversion { tag=0 max_msg_size=8192 version="9P2000" } < Rversion { tag=0 max_msg_size=4120 version="9P2000" } @@ -38,8 +87,8 @@ < Rattach { tag=0 qid={ type=(DIR) vers=1 path=1 } } # flush, but original response comes back first -> Twalk { tag=0 fid=0 newfid=1 nwname=1 wname=["slowread" ] } -< Rwalk { tag=0 nwqid=1 wqid=[{ type=(0) vers=1 path=6 } ] } +> Twalk { tag=0 fid=0 newfid=1 nwname=1 wname=[ "slowread" ] } +< Rwalk { tag=0 nwqid=1 wqid=[ { type=(0) vers=1 path=6 } ] } > Topen { tag=0 fid=1 mode=(MODE_READ) } < Ropen { tag=0 qid={ type=(0) vers=1 path=6 } iounit=0 } > Tread { tag=1 fid=1 offset=0 count=6 } @@ -48,14 +97,14 @@ < Rflush { tag=2 } # flush, succeeds -> Twalk { tag=1 fid=0 newfid=2 nwname=1 wname=["slowread-flushable" ] } -< Rwalk { tag=1 nwqid=1 wqid=[{ type=(0) vers=1 path=7 } ] } +> Twalk { tag=1 fid=0 newfid=2 nwname=1 wname=[ "slowread-flushable" ] } +< Rwalk { tag=1 nwqid=1 wqid=[ { type=(0) vers=1 path=7 } ] } > Topen { tag=0 fid=2 mode=(MODE_READ) } < Ropen { tag=0 qid={ type=(0) vers=1 path=7 } iounit=0 } > Tread { tag=1 fid=2 offset=0 count=6 } > Tflush { tag=2 oldtag=1 } < Rflush { tag=2 } -< Rerror { tag=1 errstr="request canceled by flush" errnum=125 } +< Rerror { tag=1 errstr="request canceled by flush" errnum=L_ECANCELED } # flush, unknown tag > Tflush { tag=0 oldtag=99 } @@ -66,8 +115,8 @@ < Rversion { tag=0 max_msg_size=4120 version="9P2000" } > Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" n_uid=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 } ] } +> Twalk { tag=0 fid=0 newfid=0 nwname=1 wname=[ "shutdown" ] } +< Rwalk { tag=0 nwqid=1 wqid=[ { type=(0) vers=1 path=5 } ] } > Topen { tag=0 fid=0 mode=(MODE_WRITE) } < Ropen { tag=0 qid={ type=(0) vers=1 path=5 } iounit=0 } > Twrite { tag=0 fid=0 offset=0 count=2 data="1\n" } |