summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/sbc_harness/config/tusb_config.h4
-rw-r--r--cmd/sbc_harness/fs_harness_flash_bin.c31
-rw-r--r--cmd/sbc_harness/fs_harness_uptime_txt.c31
-rw-r--r--gdb-helpers/libcr.py142
-rw-r--r--lib9p/CMakeLists.txt18
-rw-r--r--lib9p/core.c25
-rw-r--r--lib9p/core_gen/c.py35
-rw-r--r--lib9p/core_gen/c_format.py2
-rw-r--r--lib9p/core_gen/h.py13
-rw-r--r--lib9p/core_generated.c587
-rw-r--r--lib9p/core_include/lib9p/_core_generated.h83
-rw-r--r--lib9p/core_include/lib9p/core.h41
-rw-r--r--lib9p/core_tables.c2
-rw-r--r--lib9p/core_tables.h2
-rw-r--r--lib9p/idl/0000-uninitialized.9p13
-rw-r--r--lib9p/idl/2002-9P2000.9p32
-rw-r--r--lib9p/idl/2005-9P2000.u.9p12
-rw-r--r--lib9p/srv.c626
-rw-r--r--lib9p/srv_include/lib9p/srv.h109
-rw-r--r--lib9p/tests/test_compile.c1571
-rwxr-xr-xlib9p/tests/test_compile.c.gen2
-rw-r--r--lib9p/tests/test_compile_config/config.h22
-rw-r--r--lib9p/tests/test_server/fs_flush.c31
-rw-r--r--lib9p/tests/test_server/fs_shutdown.c36
-rw-r--r--lib9p/tests/test_server/fs_whoami.c39
-rwxr-xr-xlib9p/tests/testclient-p9p2
-rw-r--r--lib9p/tests/testclient-p9p.explog34
-rw-r--r--lib9p/tests/testclient-sess.c4
-rw-r--r--lib9p/tests/testclient-sess.explog14
-rw-r--r--lib9p_util/static.c110
-rw-r--r--libcr/tests/test_matrix.c6
-rw-r--r--libcr_ipc/include/libcr_ipc/chan.h2
-rw-r--r--libcr_ipc/include/libcr_ipc/rpc.h2
-rw-r--r--libcr_ipc/tests/test_chan.c8
-rw-r--r--libcr_ipc/tests/test_mutex.c6
-rw-r--r--libcr_ipc/tests/test_rpc.c12
-rw-r--r--libcr_ipc/tests/test_select.c12
-rw-r--r--libcr_ipc/tests/test_sema.c18
-rw-r--r--libhw_cr/rp2040_include/libhw/rp2040_hwspi.h2
-rw-r--r--libmisc/include/libmisc/assert.h17
-rw-r--r--libmisc/include/libmisc/linkedlist.h10
-rw-r--r--libmisc/include/libmisc/macro.h6
-rw-r--r--libmisc/include/libmisc/map.h2
43 files changed, 2460 insertions, 1316 deletions
diff --git a/cmd/sbc_harness/config/tusb_config.h b/cmd/sbc_harness/config/tusb_config.h
index 0a6d3e4..5240311 100644
--- a/cmd/sbc_harness/config/tusb_config.h
+++ b/cmd/sbc_harness/config/tusb_config.h
@@ -1,6 +1,6 @@
/* tusb_config.h - Compile-time configuration for the TinyUSB library
*
- * Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com>
+ * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*
* SPDX-License-Identifier: MIT
@@ -61,7 +61,7 @@ extern "C" {
TU_BREAKPOINT(); \
return _ret; \
} \
- } while(0)
+ } while (0)
void _libmisc_tu_mess_failed(const char *expr,
const char *file, unsigned int line, const char *func);
diff --git a/cmd/sbc_harness/fs_harness_flash_bin.c b/cmd/sbc_harness/fs_harness_flash_bin.c
index bc3d061..5920b85 100644
--- a/cmd/sbc_harness/fs_harness_flash_bin.c
+++ b/cmd/sbc_harness/fs_harness_flash_bin.c
@@ -148,30 +148,25 @@ static struct lib9p_qid flash_file_qid(struct flash_file *self) {
};
}
-static struct lib9p_stat flash_file_stat(struct flash_file *self, struct lib9p_srv_ctx *ctx) {
+static struct lib9p_srv_stat flash_file_stat(struct flash_file *self, struct lib9p_srv_ctx *ctx) {
assert(self);
assert(ctx);
- return (struct lib9p_stat){
- .kern_type = 0,
- .kern_dev = 0,
- .file_qid = flash_file_qid(self),
- .file_mode = LIB9P_DM_EXCL|0666,
- .file_atime = UTIL9P_ATIME,
- .file_mtime = UTIL9P_MTIME,
- .file_size = DATA_SIZE,
- .file_name = lib9p_str(self->name),
- .file_owner_uid = lib9p_str("root"),
- .file_owner_gid = lib9p_str("root"),
- .file_last_modified_uid = lib9p_str("root"),
- .file_extension = lib9p_str(NULL),
- .file_owner_n_uid = 0,
- .file_owner_n_gid = 0,
- .file_last_modified_n_uid = 0,
+ return (struct lib9p_srv_stat){
+ .qid = flash_file_qid(self),
+ .mode = LIB9P_DM_EXCL|0666,
+ .atime_sec = UTIL9P_ATIME,
+ .mtime_sec = UTIL9P_MTIME,
+ .size = DATA_SIZE,
+ .name = lib9p_str(self->name),
+ .owner_uid = { .name = lib9p_str("root"), .num = 0 },
+ .owner_gid = { .name = lib9p_str("root"), .num = 0 },
+ .last_modifier_uid = { .name = lib9p_str("root"), .num = 0 },
+ .extension = lib9p_str(NULL),
};
}
static void flash_file_wstat(struct flash_file *self, struct lib9p_srv_ctx *ctx,
- struct lib9p_stat) {
+ struct lib9p_srv_stat) {
assert(self);
assert(ctx);
diff --git a/cmd/sbc_harness/fs_harness_uptime_txt.c b/cmd/sbc_harness/fs_harness_uptime_txt.c
index dd5c681..f7b755f 100644
--- a/cmd/sbc_harness/fs_harness_uptime_txt.c
+++ b/cmd/sbc_harness/fs_harness_uptime_txt.c
@@ -38,7 +38,7 @@ static struct lib9p_qid uptime_file_qid(struct uptime_file *self) {
};
}
-static struct lib9p_stat uptime_file_stat(struct uptime_file *self, struct lib9p_srv_ctx *ctx) {
+static struct lib9p_srv_stat uptime_file_stat(struct uptime_file *self, struct lib9p_srv_ctx *ctx) {
assert(self);
assert(ctx);
@@ -52,26 +52,21 @@ static struct lib9p_stat uptime_file_stat(struct uptime_file *self, struct lib9p
size++;
size += 3;
- return (struct lib9p_stat){
- .kern_type = 0,
- .kern_dev = 0,
- .file_qid = uptime_file_qid(self),
- .file_mode = 0444,
- .file_atime = UTIL9P_ATIME,
- .file_mtime = UTIL9P_MTIME,
- .file_size = size,
- .file_name = lib9p_str(self->name),
- .file_owner_uid = lib9p_str("root"),
- .file_owner_gid = lib9p_str("root"),
- .file_last_modified_uid = lib9p_str("root"),
- .file_extension = lib9p_str(NULL),
- .file_owner_n_uid = 0,
- .file_owner_n_gid = 0,
- .file_last_modified_n_uid = 0,
+ return (struct lib9p_srv_stat){
+ .qid = uptime_file_qid(self),
+ .mode = 0444,
+ .atime_sec = UTIL9P_ATIME,
+ .mtime_sec = UTIL9P_MTIME,
+ .size = size,
+ .name = lib9p_str(self->name),
+ .owner_uid = { .name = lib9p_str("root"), .num = 0 },
+ .owner_gid = { .name = lib9p_str("root"), .num = 0 },
+ .last_modifier_uid = { .name = lib9p_str("root"), .num = 0 },
+ .extension = lib9p_str(NULL),
};
}
static void uptime_file_wstat(struct uptime_file *self, struct lib9p_srv_ctx *ctx,
- struct lib9p_stat) {
+ struct lib9p_srv_stat) {
assert(self);
assert(ctx);
diff --git a/gdb-helpers/libcr.py b/gdb-helpers/libcr.py
index fcfd86e..6f95a81 100644
--- a/gdb-helpers/libcr.py
+++ b/gdb-helpers/libcr.py
@@ -89,6 +89,7 @@ def gdb_longjmp(buf: gdb_JmpBuf) -> None:
class CrGlobals:
+ main: "CrMain"
coroutines: list["CrCoroutine"]
_breakpoint: "CrBreakpoint"
_known_threads: set[gdb.InferiorThread]
@@ -98,6 +99,7 @@ class CrGlobals:
gdb.parse_and_eval("sizeof(coroutine_table)/sizeof(coroutine_table[0])")
)
+ self.main = CrMain(self)
self.coroutines = [CrCoroutine(self, i + 1) for i in range(num)]
self._breakpoint = CrBreakpoint()
@@ -126,35 +128,37 @@ class CrGlobals:
# Ignore thread creation events.
self._known_threads = cur_threads
return
- if self.coroutine_running:
- if not self.coroutine_running.is_selected():
- if gdb_bug_32428:
- print("Must return to running coroutine before continuing.")
- print("Hit ^C twice then run:")
- print(f" cr select {self.coroutine_running.id}")
- while True:
- time.sleep(1)
- assert self.coroutine_running.cont_env
- gdb_longjmp(self.coroutine_running.cont_env)
+ if not self.coroutine_running.is_selected():
+ if gdb_bug_32428:
+ print("Must return to running coroutine before continuing.")
+ print("Hit ^C twice then run:")
+ print(f" cr select {self.coroutine_running.cid}")
+ while True:
+ time.sleep(1)
+ assert self.coroutine_running.cont_env
+ gdb_longjmp(self.coroutine_running.cont_env)
+ self.main.cont_env = None
for cr in self.coroutines:
cr.cont_env = None
def is_valid_cid(self, cid: int) -> bool:
- return 0 < cid <= len(self.coroutines)
+ return (0 < cid <= len(self.coroutines)) and (
+ self.coroutines[cid - 1].state != self.CR_NONE
+ )
@property
- def coroutine_running(self) -> "CrCoroutine | None":
+ def coroutine_running(self) -> "CrMain | CrCoroutine":
cid = int(gdb.parse_and_eval("coroutine_running"))
if not self.is_valid_cid(cid):
- return None
+ return self.main
return self.coroutines[cid - 1]
@property
- def coroutine_selected(self) -> "CrCoroutine | None":
+ def coroutine_selected(self) -> "CrMain | CrCoroutine":
for cr in self.coroutines:
if cr.is_selected():
return cr
- return None
+ return self.main
@property
def CR_NONE(self) -> gdb.Value:
@@ -164,6 +168,35 @@ class CrGlobals:
def CR_RUNNING(self) -> gdb.Value:
return gdb.parse_and_eval("CR_RUNNING")
+ def select(self, cr: "CrMain | CrCoroutine", level: int = -1) -> None:
+ self.coroutine_selected.cont_env = gdb_setjmp()
+
+ if cr.cont_env:
+ gdb_longjmp(cr.cont_env)
+ else:
+ env: gdb_JmpBuf
+ if cr == self.coroutine_running:
+ assert False # cr.cont_env should have been set
+ match cr:
+ case CrMain():
+ env = self.readjmp("&coroutine_main_env")
+ case CrCoroutine():
+ if cr.state == self.CR_RUNNING:
+ env = self.readjmp("&coroutine_add_env")
+ else:
+ env = self.readjmp(f"&coroutine_table[{cr.cid-1}].env")
+ gdb_longjmp(env)
+ cr_select_top_frame()
+
+ @contextlib.contextmanager
+ def with_selected(self, cr: "CrMain | CrCoroutine") -> typing.Iterator[None]:
+ saved_env = gdb_setjmp()
+ self.select(cr)
+ try:
+ yield
+ finally:
+ gdb_longjmp(saved_env)
+
class CrBreakpointUnwinder(gdb.unwinder.Unwinder):
"""Used to temporarily disable unwinding so that
@@ -245,6 +278,22 @@ def cr_select_top_frame() -> None:
break
+class CrMain:
+ cr_globals: CrGlobals
+ cont_env: gdb_JmpBuf | None
+
+ def __init__(self, cr_globals: CrGlobals) -> None:
+ self.cr_globals = cr_globals
+ self.cont_env = None
+
+ @property
+ def cid(self) -> int:
+ return 0
+
+ def is_selected(self) -> bool:
+ return not any(cr.is_selected() for cr in self.cr_globals.coroutines)
+
+
class CrCoroutine:
cr_globals: CrGlobals
cid: int
@@ -256,10 +305,6 @@ class CrCoroutine:
self.cont_env = None
@property
- def id(self) -> int:
- return self.cid
-
- @property
def state(self) -> gdb.Value:
return gdb.parse_and_eval(f"coroutine_table[{self.cid-1}].state")
@@ -272,36 +317,10 @@ class CrCoroutine:
def is_selected(self) -> bool:
sp = int(gdb.parse_and_eval("$sp"))
- lo = int(gdb.parse_and_eval(f"coroutine_table[{self.id-1}].stack"))
- hi = lo + int(gdb.parse_and_eval(f"coroutine_table[{self.id-1}].stack_size"))
+ lo = int(gdb.parse_and_eval(f"coroutine_table[{self.cid-1}].stack"))
+ hi = lo + int(gdb.parse_and_eval(f"coroutine_table[{self.cid-1}].stack_size"))
return lo <= sp < hi
- def select(self, level: int = -1) -> None:
- if self.cr_globals.coroutine_selected:
- self.cr_globals.coroutine_selected.cont_env = gdb_setjmp()
-
- if self.cont_env:
- gdb_longjmp(self.cont_env)
- else:
- env: gdb_JmpBuf
- if self == self.cr_globals.coroutine_running:
- assert False # self.cont_env should have been set
- elif self.state == self.cr_globals.CR_RUNNING:
- env = self.cr_globals.readjmp("&coroutine_add_env")
- else:
- env = self.cr_globals.readjmp(f"&coroutine_table[{self.id-1}].env")
- gdb_longjmp(env)
- cr_select_top_frame()
-
- @contextlib.contextmanager
- def with_selected(self) -> typing.Iterator[None]:
- saved_env = gdb_setjmp()
- self.select()
- try:
- yield
- finally:
- gdb_longjmp(saved_env)
-
# User-facing commands #########################################################
@@ -342,8 +361,11 @@ class CrListCommand(gdb.Command):
rows: list[tuple[str, str, str, str, str]] = [
("", "Id", "Name", "State", "Frame")
]
- for cr in self.cr_globals.coroutines:
- if cr.state == self.cr_globals.CR_NONE:
+ for cid in range(len(self.cr_globals.coroutines) + 1):
+ cr: CrMain | CrCoroutine = (
+ self.cr_globals.coroutines[cid - 1] if cid else self.cr_globals.main
+ )
+ if isinstance(cr, CrCoroutine) and cr.state == self.cr_globals.CR_NONE:
continue
rows += [
(
@@ -353,9 +375,9 @@ class CrListCommand(gdb.Command):
"G" if cr.is_selected() else " ",
]
),
- str(cr.id),
- repr(cr.name),
- str(cr.state),
+ str(cr.cid),
+ repr(cr.name) if isinstance(cr, CrCoroutine) else "-",
+ str(cr.state) if isinstance(cr, CrCoroutine) else "-",
self._pretty_frame(cr, from_tty),
)
]
@@ -382,9 +404,9 @@ class CrListCommand(gdb.Command):
l = l[:maxline]
print(l)
- def _pretty_frame(self, cr: CrCoroutine, from_tty: bool) -> str:
+ def _pretty_frame(self, cr: CrMain | CrCoroutine, from_tty: bool) -> str:
try:
- with cr.with_selected():
+ with self.cr_globals.with_selected(cr):
saved_level = gdb.selected_frame().level()
cr_select_top_frame()
full = gdb.execute("frame", from_tty=from_tty, to_string=True)
@@ -411,16 +433,15 @@ class CrSelectCommand(gdb.Command):
if len(argv) != 1:
raise gdb.GdbError("Usage: cr select COROUTINE")
cr = self._find(argv[0])
- cr.select()
+ self.cr_globals.select(cr)
gdb.execute("frame")
- def _find(self, name: str) -> CrCoroutine:
+ def _find(self, name: str) -> CrMain | CrCoroutine:
if name.isnumeric():
cid = int(name)
- if (
- self.cr_globals.is_valid_cid(cid)
- and self.cr_globals.coroutines[cid - 1].state != self.cr_globals.CR_NONE
- ):
+ if cid == 0:
+ return self.cr_globals.main
+ if self.cr_globals.is_valid_cid(cid):
return self.cr_globals.coroutines[cid - 1]
crs: list[CrCoroutine] = []
for cr in self.cr_globals.coroutines:
@@ -445,6 +466,7 @@ def cr_initialize() -> None:
if _cr_globals:
old = _cr_globals
new = CrGlobals()
+ new.main.cont_env = old.main.cont_env
for i in range(min(len(old.coroutines), len(new.coroutines))):
new.coroutines[i].cont_env = old.coroutines[i].cont_env
old.delete()
diff --git a/lib9p/CMakeLists.txt b/lib9p/CMakeLists.txt
index 543d01a..0a5ea3e 100644
--- a/lib9p/CMakeLists.txt
+++ b/lib9p/CMakeLists.txt
@@ -50,6 +50,20 @@ if (ENABLE_TESTS)
add_lib9p_executable("testclient-sess")
add_lib9p_test("./testclient-sess")
- add_lib_test(lib9p_core test_compile)
- target_include_directories(test_compile PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_compile_config)
+ set(cfg_matrix
+ "CONFIG_9P_SRV_DEBUG;[0;1]"
+ "CONFIG_9P_ENABLE_9P2000;[0;1]"
+ "CONFIG_9P_ENABLE_9P2000_u;[0;1]"
+ "CONFIG_9P_ENABLE_9P2000_e;[0;1]"
+ "CONFIG_9P_ENABLE_9P2000_L;[0;1]"
+ "CONFIG_9P_ENABLE_9P2000_p9p;[0;1]"
+ )
+ function(add_compile_test n defs)
+ add_executable("test_compile${n}" "tests/test_compile.c")
+ target_link_libraries("test_compile${n}" lib9p_srv)
+ target_include_directories("test_compile${n}" PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_compile_config)
+ target_compile_definitions("test_compile${n}" PUBLIC "${defs}")
+ # Don't bother running it (don't bother calling add_test())
+ endfunction()
+ apply_matrix(add_compile_test "${cfg_matrix}")
endif()
diff --git a/lib9p/core.c b/lib9p/core.c
index a07461d..cb8ddee 100644
--- a/lib9p/core.c
+++ b/lib9p/core.c
@@ -47,7 +47,7 @@ bool lib9p_str_eq(struct lib9p_s a, struct lib9p_s b) {
void lib9p_ctx_clear_error(struct lib9p_ctx *ctx) {
assert(ctx);
-#if CONFIG_9P_ENABLE_9P2000_u
+#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L
ctx->err_num = 0;
#endif
ctx->err_msg[0] = '\0';
@@ -58,22 +58,31 @@ bool lib9p_ctx_has_error(struct lib9p_ctx *ctx) {
return ctx->err_msg[0];
}
-int lib9p_error(struct lib9p_ctx *ctx, lib9p_errno_t linux_errno, char const *msg) {
+#undef lib9p_error
+#undef lib9p_errorf
+
+int lib9p_error(struct lib9p_ctx *ctx,
+#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L
+ lib9p_errno_t linux_errno,
+#endif
+ char const *msg) {
if (lib9p_ctx_has_error(ctx))
return -1;
strncpy(ctx->err_msg, msg, sizeof(ctx->err_msg));
ctx->err_msg[sizeof(ctx->err_msg)-1] = '\0';
-#if CONFIG_9P_ENABLE_9P2000_u
+#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L
ctx->err_num = linux_errno;
-#else
- (void)(linux_errno);
#endif
return -1;
}
-int lib9p_errorf(struct lib9p_ctx *ctx, lib9p_errno_t linux_errno, char const *fmt, ...) {
+int lib9p_errorf(struct lib9p_ctx *ctx,
+#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L
+ lib9p_errno_t linux_errno,
+#endif
+ char const *fmt, ...) {
int n;
va_list args;
@@ -85,10 +94,8 @@ int lib9p_errorf(struct lib9p_ctx *ctx, lib9p_errno_t linux_errno, char const *f
if ((size_t)(n+1) < sizeof(ctx->err_msg))
memset(&ctx->err_msg[n+1], 0, sizeof(ctx->err_msg)-(n+1));
-#if CONFIG_9P_ENABLE_9P2000_u
+#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L
ctx->err_num = linux_errno;
-#else
- (void)(linux_errno);
#endif
return -1;
diff --git a/lib9p/core_gen/c.py b/lib9p/core_gen/c.py
index b2e856d..a300404 100644
--- a/lib9p/core_gen/c.py
+++ b/lib9p/core_gen/c.py
@@ -79,7 +79,9 @@ def gen_c(versions: set[str], typs: list[idl.UserType]) -> str:
if not isinstance(typ, idl.Bitfield):
continue
ret += "\n"
- ret += cutil.ifdef_push(1, c9util.ver_ifdef(typ.in_versions))
+ ret += cutil.ifdef_push(
+ 1, c9util.ver_ifdef(typ.in_versions - {"unknown"})
+ ) # SPECIAL (initialization)
ret += f"static const {c9util.typename(typ)} {typ.typname}_masks[{c9util.ver_enum('NUM')}] = {{\n"
verwidth = max(len(ver) for ver in versions)
for ver in sorted(versions):
@@ -121,20 +123,17 @@ def gen_c(versions: set[str], typs: list[idl.UserType]) -> str:
ret += "\n"
ret += f"const struct {c9util.ident('_ver_tentry')} {c9util.ident('_table_ver')}[{c9util.ver_enum('NUM')}] = {{\n"
rerror = next(typ for typ in typs if typ.typname == "Rerror")
- for ver in ["unknown", *sorted(versions)]:
+ for ver in sorted(versions):
# XXX: There are good arguments that min_msg_size should be
# something larger than rerror.min_size().
# srv.c:respond_error() assumes that min_msg_size is
# rerror.min_size(); if you do change min_msg_size to
# something larger, then be sure to update respond_error().
- if ver == "unknown":
- min_msg_size = rerror.min_size("9P2000") # SPECIAL (initialization)
- else:
- ret += cutil.ifdef_push(1, c9util.ver_ifdef({ver}))
- min_msg_size = rerror.min_size(ver)
- if ver == "9P2000.L": # SPECIAL (9P2000.L)
- rlerror = next(typ for typ in typs if typ.typname == "Rlerror")
- min_msg_size = rlerror.min_size(ver)
+ ret += cutil.ifdef_push(1, c9util.ver_ifdef({ver}))
+ min_msg_size = rerror.min_size(ver)
+ if ver == "9P2000.L": # SPECIAL (9P2000.L)
+ rlerror = next(typ for typ in typs if typ.typname == "Rlerror")
+ min_msg_size = rlerror.min_size(ver)
ret += f'\t[{c9util.ver_enum(ver)}] = {{.name="{ver}", .min_msg_size={min_msg_size}}},\n'
ret += cutil.ifdef_pop(0)
ret += "};\n"
@@ -143,19 +142,14 @@ def gen_c(versions: set[str], typs: list[idl.UserType]) -> str:
cstruct: str, cname: str, each: str, _range: tuple[int, int, int]
) -> str:
ret = f"const struct {c9util.ident(cstruct)} {c9util.ident(cname)}[{c9util.ver_enum('NUM')}][{hex(len(range(*_range)))}] = {{\n"
- for ver in ["unknown", *sorted(versions)]:
- if ver != "unknown":
- ret += cutil.ifdef_push(1, c9util.ver_ifdef({ver}))
+ for ver in sorted(versions):
+ ret += cutil.ifdef_push(1, c9util.ver_ifdef({ver}))
ret += f"\t[{c9util.ver_enum(ver)}] = {{\n"
for n in range(*_range):
xmsg: idl.Message | None = id2typ.get(n, None)
if xmsg:
- if ver == "unknown": # SPECIAL (initialization)
- if xmsg.typname not in ["Tversion", "Rversion", "Rerror"]:
- xmsg = None
- else:
- if ver not in xmsg.in_versions:
- xmsg = None
+ if ver not in xmsg.in_versions:
+ xmsg = None
if xmsg:
ret += f"\t\t{each}({xmsg.typname}),\n"
ret += "\t},\n"
@@ -194,6 +188,7 @@ def gen_c(versions: set[str], typs: list[idl.UserType]) -> str:
ret += msg_table("_send_tentry", "_table_Rmsg_send", "_MSG_SEND", (1, 0x100, 2))
ret += f"""
+{cutil.ifdef_push(1, c9util.ver_ifdef(next(typ for typ in typs if typ.typname == 'stat').in_versions)).rstrip()}
LM_FLATTEN ssize_t {c9util.ident('_stat_validate')}(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes, uint32_t *ret_net_size) {{
\treturn validate_stat(ctx, net_size, net_bytes, ret_net_size);
}}
@@ -203,7 +198,7 @@ LM_FLATTEN void {c9util.ident('_stat_unmarshal')}(struct lib9p_ctx *ctx, uint8_t
LM_FLATTEN bool {c9util.ident('_stat_marshal')}(struct lib9p_ctx *ctx, struct {c9util.ident('stat')} *val, struct _marshal_ret *ret) {{
\treturn marshal_stat(ctx, val, ret);
}}
-"""
+{cutil.ifdef_pop(0)}"""
############################################################################
return ret
diff --git a/lib9p/core_gen/c_format.py b/lib9p/core_gen/c_format.py
index f9eee90..c633fbb 100644
--- a/lib9p/core_gen/c_format.py
+++ b/lib9p/core_gen/c_format.py
@@ -105,7 +105,7 @@ def gen_c_format(versions: set[str], typs: list[idl.UserType]) -> str:
ret += "\tif (empty)\n"
ret += "\t\tfmt_state_putchar(state, '0');\n"
ret += "\tfmt_state_putchar(state, ')');\n"
- case idl.Struct(typname="s"): # SPECIAL(string)
+ case idl.Struct(typname="s"): # SPECIAL (string)
ret += ext_printf(
'\tfmt_state_printf(state, "%.*q", self->len, self->utf8);\n'
)
diff --git a/lib9p/core_gen/h.py b/lib9p/core_gen/h.py
index 3defcb8..ff070c6 100644
--- a/lib9p/core_gen/h.py
+++ b/lib9p/core_gen/h.py
@@ -192,14 +192,21 @@ def gen_h(versions: set[str], typs: list[idl.UserType]) -> str:
ret += "\t#endif\n"
ret += "#endif\n"
+ # SPECIAL (convenience)
+ ret += "\n"
+ ret += f"#define _LIB9P_ENABLE_stat {c9util.ver_ifdef(next(typ for typ in typs if typ.typname == 'stat').in_versions)}\n"
+
ret += f"""
/* enum version ***************************************************************/
enum {c9util.ident('version')} {{
"""
- fullversions = ["unknown = 0", *sorted(versions)]
- verwidth = max(len(v) for v in fullversions)
- for ver in fullversions:
+ xversions = [
+ "unknown = 0",
+ *sorted(v for v in versions if v != "unknown"),
+ ] # SPECIAL (initialization)
+ verwidth = max(len(v) for v in xversions)
+ for ver in xversions:
if ver in versions:
ret += cutil.ifdef_push(1, c9util.ver_ifdef({ver}))
ret += f"\t{c9util.ver_enum(ver)},"
diff --git a/lib9p/core_generated.c b/lib9p/core_generated.c
index 1789bdc..8539fdf 100644
--- a/lib9p/core_generated.c
+++ b/lib9p/core_generated.c
@@ -1,4 +1,4 @@
-/* Generated by `lib9p/core.gen lib9p/idl/2002-9P2000.9p lib9p/idl/2003-9P2000.p9p.9p lib9p/idl/2005-9P2000.u.9p lib9p/idl/2010-9P2000.L.9p lib9p/idl/2012-9P2000.e.9p`. DO NOT EDIT! */
+/* Generated by `lib9p/core.gen lib9p/idl/0000-uninitialized.9p lib9p/idl/2002-9P2000.9p lib9p/idl/2003-9P2000.p9p.9p lib9p/idl/2005-9P2000.u.9p lib9p/idl/2010-9P2000.L.9p lib9p/idl/2012-9P2000.e.9p`. DO NOT EDIT! */
#include <stdbool.h>
#include <stddef.h> /* for size_t */
@@ -14,33 +14,35 @@
#include "core_utf8.h"
/* libobj vtables *************************************************************/
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown
LO_IMPLEMENTATION_C(fmt_formatter, lib9p_tag_t, lib9p_tag, static);
LO_IMPLEMENTATION_C(fmt_formatter, lib9p_fid_t, lib9p_fid, static);
LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_s, lib9p_s, static);
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown */
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown
LO_IMPLEMENTATION_C(fmt_formatter, lib9p_dm_t, lib9p_dm, static);
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown */
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown
LO_IMPLEMENTATION_C(fmt_formatter, lib9p_qt_t, lib9p_qt, static);
LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_qid, lib9p_qid, static);
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_stat, lib9p_stat, static);
LO_IMPLEMENTATION_C(fmt_formatter, lib9p_o_t, lib9p_o, static);
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown
LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tversion, lib9p_msg_Tversion, static);
LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rversion, lib9p_msg_Rversion, static);
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown */
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tauth, lib9p_msg_Tauth, static);
LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rauth, lib9p_msg_Rauth, static);
LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tattach, lib9p_msg_Tattach, static);
LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rattach, lib9p_msg_Rattach, static);
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown
LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rerror, lib9p_msg_Rerror, static);
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Tflush, lib9p_msg_Tflush, static);
LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rflush, lib9p_msg_Rflush, static);
@@ -163,6 +165,11 @@ LO_IMPLEMENTATION_C(fmt_formatter, struct lib9p_msg_Rswrite, lib9p_msg_Rswrite,
#else
#define _is_ver_9P2000_u(v) false
#endif
+#if CONFIG_9P_ENABLE_unknown
+ #define _is_ver_unknown(v) (v == LIB9P_VER_unknown)
+#else
+ #define _is_ver_unknown(v) false
+#endif
/**
* is_ver(ctx, ver) is essentially `(ctx->version == LIB9P_VER_##ver)`, but
@@ -191,6 +198,9 @@ static const lib9p_dm_t dm_masks[LIB9P_VER_NUM] = {
#if CONFIG_9P_ENABLE_9P2000_u
[LIB9P_VER_9P2000_u] = 0b11111100101111000000000111111111,
#endif /* CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_unknown
+ [LIB9P_VER_unknown] = 0b11111100000000000000000111111111,
+#endif /* CONFIG_9P_ENABLE_unknown */
};
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
@@ -211,6 +221,9 @@ static const lib9p_qt_t qt_masks[LIB9P_VER_NUM] = {
#if CONFIG_9P_ENABLE_9P2000_u
[LIB9P_VER_9P2000_u] = 0b11111110,
#endif /* CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_unknown
+ [LIB9P_VER_unknown] = 0b11111100,
+#endif /* CONFIG_9P_ENABLE_unknown */
};
#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 */
@@ -231,6 +244,9 @@ static const lib9p_o_t o_masks[LIB9P_VER_NUM] = {
#if CONFIG_9P_ENABLE_9P2000_u
[LIB9P_VER_9P2000_u] = 0b01010011,
#endif /* CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_unknown
+ [LIB9P_VER_unknown] = 0b00000000,
+#endif /* CONFIG_9P_ENABLE_unknown */
};
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
@@ -249,6 +265,9 @@ static const lib9p_lo_t lo_masks[LIB9P_VER_NUM] = {
#if CONFIG_9P_ENABLE_9P2000_u
[LIB9P_VER_9P2000_u] = 0b00000000000000000000000000000000,
#endif /* CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_unknown
+ [LIB9P_VER_unknown] = 0b00000000000000000000000000000000,
+#endif /* CONFIG_9P_ENABLE_unknown */
};
static const lib9p_mode_t mode_masks[LIB9P_VER_NUM] = {
@@ -265,6 +284,9 @@ static const lib9p_mode_t mode_masks[LIB9P_VER_NUM] = {
#if CONFIG_9P_ENABLE_9P2000_u
[LIB9P_VER_9P2000_u] = 0b00000000000000000000000000000000,
#endif /* CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_unknown
+ [LIB9P_VER_unknown] = 0b00000000000000000000000000000000,
+#endif /* CONFIG_9P_ENABLE_unknown */
};
static const lib9p_getattr_t getattr_masks[LIB9P_VER_NUM] = {
@@ -281,6 +303,9 @@ static const lib9p_getattr_t getattr_masks[LIB9P_VER_NUM] = {
#if CONFIG_9P_ENABLE_9P2000_u
[LIB9P_VER_9P2000_u] = 0b0000000000000000000000000000000000000000000000000000000000000000,
#endif /* CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_unknown
+ [LIB9P_VER_unknown] = 0b0000000000000000000000000000000000000000000000000000000000000000,
+#endif /* CONFIG_9P_ENABLE_unknown */
};
static const lib9p_setattr_t setattr_masks[LIB9P_VER_NUM] = {
@@ -297,6 +322,9 @@ static const lib9p_setattr_t setattr_masks[LIB9P_VER_NUM] = {
#if CONFIG_9P_ENABLE_9P2000_u
[LIB9P_VER_9P2000_u] = 0b00000000000000000000000000000000,
#endif /* CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_unknown
+ [LIB9P_VER_unknown] = 0b00000000000000000000000000000000,
+#endif /* CONFIG_9P_ENABLE_unknown */
};
static const lib9p_lock_flags_t lock_flags_masks[LIB9P_VER_NUM] = {
@@ -313,6 +341,9 @@ static const lib9p_lock_flags_t lock_flags_masks[LIB9P_VER_NUM] = {
#if CONFIG_9P_ENABLE_9P2000_u
[LIB9P_VER_9P2000_u] = 0b00000000000000000000000000000000,
#endif /* CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_unknown
+ [LIB9P_VER_unknown] = 0b00000000000000000000000000000000,
+#endif /* CONFIG_9P_ENABLE_unknown */
};
#endif /* CONFIG_9P_ENABLE_9P2000_L */
@@ -352,14 +383,14 @@ static const lib9p_lock_flags_t lock_flags_masks[LIB9P_VER_NUM] = {
static ssize_t validate_stat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes, uint32_t *ret_net_size) {
uint32_t net_offset = 0;
ssize_t host_size = sizeof(struct lib9p_stat);
- uint32_t offsetof_stat_size = net_offset + 0;
- uint32_t offsetof_kern_type = net_offset + 2;
- uint32_t offsetof_file_qid_type = net_offset + 8;
+ uint32_t offsetof__stat_size = net_offset + 0;
+ uint32_t offsetof_fstype = net_offset + 2;
+ uint32_t offsetof_qid_type = net_offset + 8;
VALIDATE_NET_BYTES(21);
- if (GET_U8LE(offsetof_file_qid_type) & ~qt_masks[ctx->version])
+ if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])
return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8,
- GET_U8LE(offsetof_file_qid_type) & ~qt_masks[ctx->version]);
- uint32_t offsetof_file_mode = net_offset + 0;
+ GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]);
+ uint32_t offsetof_mode = net_offset + 0;
VALIDATE_NET_BYTES(22);
VALIDATE_NET_UTF8(LAST_U16LE());
VALIDATE_NET_BYTES(2);
@@ -376,19 +407,19 @@ static ssize_t validate_stat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *
}
#endif /* CONFIG_9P_ENABLE_9P2000_u */
uint32_t offsetof_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof_stat_size) != (uint32_t)(offsetof_end - offsetof_kern_type))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "stat->stat_size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_stat_size), (uint32_t)(offsetof_end - offsetof_kern_type));
- if (GET_U32LE(offsetof_file_mode) & ~dm_masks[ctx->version])
+ if ((uint32_t)GET_U32LE(offsetof__stat_size) != (uint32_t)(offsetof_end - offsetof_fstype))
+ return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "stat->_stat_size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
+ (uint32_t)GET_U32LE(offsetof__stat_size), (uint32_t)(offsetof_end - offsetof_fstype));
+ if (GET_U32LE(offsetof_mode) & ~dm_masks[ctx->version])
return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in dm bitfield: %#08"PRIx32,
- GET_U32LE(offsetof_file_mode) & ~dm_masks[ctx->version]);
+ GET_U32LE(offsetof_mode) & ~dm_masks[ctx->version]);
if (ret_net_size)
*ret_net_size = net_offset;
return (ssize_t)host_size;
}
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown
static ssize_t validate_Tversion(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
ssize_t host_size = sizeof(struct lib9p_msg_Tversion);
@@ -423,6 +454,8 @@ static ssize_t validate_Rversion(struct lib9p_ctx *ctx, uint32_t net_size, uint8
return (ssize_t)host_size;
}
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown */
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
static ssize_t validate_Tauth(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
ssize_t host_size = sizeof(struct lib9p_msg_Tauth);
@@ -512,7 +545,7 @@ static ssize_t validate_Rattach(struct lib9p_ctx *ctx, uint32_t net_size, uint8_
}
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown
static ssize_t validate_Rerror(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
ssize_t host_size = sizeof(struct lib9p_msg_Rerror);
@@ -535,7 +568,7 @@ static ssize_t validate_Rerror(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
return (ssize_t)host_size;
}
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
static ssize_t validate_Tflush(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
@@ -893,14 +926,14 @@ static ssize_t validate_Rstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_nstat = net_offset + 7;
uint32_t offsetof_stat = net_offset + 9;
- uint32_t offsetof_stat_stat_size = net_offset + 9;
- uint32_t offsetof_stat_kern_type = net_offset + 11;
- uint32_t offsetof_stat_file_qid_type = net_offset + 17;
+ uint32_t offsetof_stat__stat_size = net_offset + 9;
+ uint32_t offsetof_stat_fstype = net_offset + 11;
+ uint32_t offsetof_stat_qid_type = net_offset + 17;
VALIDATE_NET_BYTES(30);
- if (GET_U8LE(offsetof_stat_file_qid_type) & ~qt_masks[ctx->version])
+ if (GET_U8LE(offsetof_stat_qid_type) & ~qt_masks[ctx->version])
return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8,
- GET_U8LE(offsetof_stat_file_qid_type) & ~qt_masks[ctx->version]);
- uint32_t offsetof_stat_file_mode = net_offset + 0;
+ GET_U8LE(offsetof_stat_qid_type) & ~qt_masks[ctx->version]);
+ uint32_t offsetof_stat_mode = net_offset + 0;
VALIDATE_NET_BYTES(22);
VALIDATE_NET_UTF8(LAST_U16LE());
VALIDATE_NET_BYTES(2);
@@ -917,12 +950,12 @@ static ssize_t validate_Rstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
}
#endif /* CONFIG_9P_ENABLE_9P2000_u */
uint32_t offsetof_stat_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof_stat_stat_size) != (uint32_t)(offsetof_stat_end - offsetof_stat_kern_type))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rstat->stat.stat_size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_stat_stat_size), (uint32_t)(offsetof_stat_end - offsetof_stat_kern_type));
- if (GET_U32LE(offsetof_stat_file_mode) & ~dm_masks[ctx->version])
+ if ((uint32_t)GET_U32LE(offsetof_stat__stat_size) != (uint32_t)(offsetof_stat_end - offsetof_stat_fstype))
+ return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rstat->stat._stat_size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
+ (uint32_t)GET_U32LE(offsetof_stat__stat_size), (uint32_t)(offsetof_stat_end - offsetof_stat_fstype));
+ if (GET_U32LE(offsetof_stat_mode) & ~dm_masks[ctx->version])
return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in dm bitfield: %#08"PRIx32,
- GET_U32LE(offsetof_stat_file_mode) & ~dm_masks[ctx->version]);
+ GET_U32LE(offsetof_stat_mode) & ~dm_masks[ctx->version]);
uint32_t offsetof_end = net_offset + 0;
if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Rstat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
@@ -943,14 +976,14 @@ static ssize_t validate_Twstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_nstat = net_offset + 11;
uint32_t offsetof_stat = net_offset + 13;
- uint32_t offsetof_stat_stat_size = net_offset + 13;
- uint32_t offsetof_stat_kern_type = net_offset + 15;
- uint32_t offsetof_stat_file_qid_type = net_offset + 21;
+ uint32_t offsetof_stat__stat_size = net_offset + 13;
+ uint32_t offsetof_stat_fstype = net_offset + 15;
+ uint32_t offsetof_stat_qid_type = net_offset + 21;
VALIDATE_NET_BYTES(34);
- if (GET_U8LE(offsetof_stat_file_qid_type) & ~qt_masks[ctx->version])
+ if (GET_U8LE(offsetof_stat_qid_type) & ~qt_masks[ctx->version])
return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in qt bitfield: %#02"PRIx8,
- GET_U8LE(offsetof_stat_file_qid_type) & ~qt_masks[ctx->version]);
- uint32_t offsetof_stat_file_mode = net_offset + 0;
+ GET_U8LE(offsetof_stat_qid_type) & ~qt_masks[ctx->version]);
+ uint32_t offsetof_stat_mode = net_offset + 0;
VALIDATE_NET_BYTES(22);
VALIDATE_NET_UTF8(LAST_U16LE());
VALIDATE_NET_BYTES(2);
@@ -967,12 +1000,12 @@ static ssize_t validate_Twstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
}
#endif /* CONFIG_9P_ENABLE_9P2000_u */
uint32_t offsetof_stat_end = net_offset + 0;
- if ((uint32_t)GET_U32LE(offsetof_stat_stat_size) != (uint32_t)(offsetof_stat_end - offsetof_stat_kern_type))
- return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twstat->stat.stat_size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
- (uint32_t)GET_U32LE(offsetof_stat_stat_size), (uint32_t)(offsetof_stat_end - offsetof_stat_kern_type));
- if (GET_U32LE(offsetof_stat_file_mode) & ~dm_masks[ctx->version])
+ if ((uint32_t)GET_U32LE(offsetof_stat__stat_size) != (uint32_t)(offsetof_stat_end - offsetof_stat_fstype))
+ return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twstat->stat._stat_size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
+ (uint32_t)GET_U32LE(offsetof_stat__stat_size), (uint32_t)(offsetof_stat_end - offsetof_stat_fstype));
+ if (GET_U32LE(offsetof_stat_mode) & ~dm_masks[ctx->version])
return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "unknown bits in dm bitfield: %#08"PRIx32,
- GET_U32LE(offsetof_stat_file_mode) & ~dm_masks[ctx->version]);
+ GET_U32LE(offsetof_stat_mode) & ~dm_masks[ctx->version]);
uint32_t offsetof_end = net_offset + 0;
if ((uint32_t)GET_U32LE(offsetof_size) != (uint32_t)(offsetof_end - offsetof_size))
return lib9p_errorf(ctx, LIB9P_ERRNO_L_EBADMSG, "Twstat->size value is wrong: actual: %"PRIu32" != correct:%"PRIu32,
@@ -1903,36 +1936,36 @@ static void unmarshal_stat([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_b
[[gnu::unused]] void *extra = &out[1];
uint32_t net_offset = 0;
net_offset += 2;
- UNMARSHAL_U16LE(ctx, out->kern_type);
- UNMARSHAL_U32LE(ctx, out->kern_dev);
- UNMARSHAL_U8LE(ctx, out->file_qid.type);
- UNMARSHAL_U32LE(ctx, out->file_qid.vers);
- UNMARSHAL_U64LE(ctx, out->file_qid.path);
- UNMARSHAL_U32LE(ctx, out->file_mode);
- UNMARSHAL_U32LE(ctx, out->file_atime);
- UNMARSHAL_U32LE(ctx, out->file_mtime);
- UNMARSHAL_U64LE(ctx, out->file_size);
- UNMARSHAL_U16LE(ctx, out->file_name.len);
- UNMARSHAL_BYTES(ctx, out->file_name.utf8, out->file_name.len);
- UNMARSHAL_U16LE(ctx, out->file_owner_uid.len);
- UNMARSHAL_BYTES(ctx, out->file_owner_uid.utf8, out->file_owner_uid.len);
- UNMARSHAL_U16LE(ctx, out->file_owner_gid.len);
- UNMARSHAL_BYTES(ctx, out->file_owner_gid.utf8, out->file_owner_gid.len);
- UNMARSHAL_U16LE(ctx, out->file_last_modified_uid.len);
- UNMARSHAL_BYTES(ctx, out->file_last_modified_uid.utf8, out->file_last_modified_uid.len);
+ UNMARSHAL_U16LE(ctx, out->fstype);
+ UNMARSHAL_U32LE(ctx, out->fsdev);
+ UNMARSHAL_U8LE(ctx, out->qid.type);
+ UNMARSHAL_U32LE(ctx, out->qid.vers);
+ UNMARSHAL_U64LE(ctx, out->qid.path);
+ UNMARSHAL_U32LE(ctx, out->mode);
+ UNMARSHAL_U32LE(ctx, out->atime);
+ UNMARSHAL_U32LE(ctx, out->mtime);
+ UNMARSHAL_U64LE(ctx, out->length);
+ UNMARSHAL_U16LE(ctx, out->name.len);
+ UNMARSHAL_BYTES(ctx, out->name.utf8, out->name.len);
+ UNMARSHAL_U16LE(ctx, out->owner_uname.len);
+ UNMARSHAL_BYTES(ctx, out->owner_uname.utf8, out->owner_uname.len);
+ UNMARSHAL_U16LE(ctx, out->owner_gname.len);
+ UNMARSHAL_BYTES(ctx, out->owner_gname.utf8, out->owner_gname.len);
+ UNMARSHAL_U16LE(ctx, out->last_modifier_uname.len);
+ UNMARSHAL_BYTES(ctx, out->last_modifier_uname.utf8, out->last_modifier_uname.len);
#if CONFIG_9P_ENABLE_9P2000_u
if (is_ver(ctx, 9P2000_u)) {
- UNMARSHAL_U16LE(ctx, out->file_extension.len);
- UNMARSHAL_BYTES(ctx, out->file_extension.utf8, out->file_extension.len);
- UNMARSHAL_U32LE(ctx, out->file_owner_n_uid);
- UNMARSHAL_U32LE(ctx, out->file_owner_n_gid);
- UNMARSHAL_U32LE(ctx, out->file_last_modified_n_uid);
+ UNMARSHAL_U16LE(ctx, out->extension.len);
+ UNMARSHAL_BYTES(ctx, out->extension.utf8, out->extension.len);
+ UNMARSHAL_U32LE(ctx, out->owner_unum);
+ UNMARSHAL_U32LE(ctx, out->owner_gnum);
+ UNMARSHAL_U32LE(ctx, out->last_modifier_unum);
}
#endif /* CONFIG_9P_ENABLE_9P2000_u */
}
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown
static void unmarshal_Tversion([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) {
struct lib9p_msg_Tversion *out = out_buf;
[[gnu::unused]] void *extra = &out[1];
@@ -1957,6 +1990,8 @@ static void unmarshal_Rversion([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *n
UNMARSHAL_BYTES(ctx, out->version.utf8, out->version.len);
}
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown */
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
static void unmarshal_Tauth([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) {
struct lib9p_msg_Tauth *out = out_buf;
[[gnu::unused]] void *extra = &out[1];
@@ -1971,7 +2006,7 @@ static void unmarshal_Tauth([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_
UNMARSHAL_BYTES(ctx, out->aname.utf8, out->aname.len);
#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u
if (( is_ver(ctx, 9P2000_L) || is_ver(ctx, 9P2000_u) )) {
- UNMARSHAL_U32LE(ctx, out->n_uid);
+ UNMARSHAL_U32LE(ctx, out->unum);
}
#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */
}
@@ -2003,7 +2038,7 @@ static void unmarshal_Tattach([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *ne
UNMARSHAL_BYTES(ctx, out->aname.utf8, out->aname.len);
#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u
if (( is_ver(ctx, 9P2000_L) || is_ver(ctx, 9P2000_u) )) {
- UNMARSHAL_U32LE(ctx, out->n_uid);
+ UNMARSHAL_U32LE(ctx, out->unum);
}
#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */
}
@@ -2021,7 +2056,7 @@ static void unmarshal_Rattach([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *ne
}
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown
static void unmarshal_Rerror([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) {
struct lib9p_msg_Rerror *out = out_buf;
[[gnu::unused]] void *extra = &out[1];
@@ -2038,7 +2073,7 @@ static void unmarshal_Rerror([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net
#endif /* CONFIG_9P_ENABLE_9P2000_u */
}
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
static void unmarshal_Tflush([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) {
struct lib9p_msg_Tflush *out = out_buf;
@@ -2254,30 +2289,30 @@ static void unmarshal_Rstat([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_
UNMARSHAL_U16LE(ctx, out->tag);
net_offset += 2;
net_offset += 2;
- UNMARSHAL_U16LE(ctx, out->stat.kern_type);
- UNMARSHAL_U32LE(ctx, out->stat.kern_dev);
- UNMARSHAL_U8LE(ctx, out->stat.file_qid.type);
- UNMARSHAL_U32LE(ctx, out->stat.file_qid.vers);
- UNMARSHAL_U64LE(ctx, out->stat.file_qid.path);
- UNMARSHAL_U32LE(ctx, out->stat.file_mode);
- UNMARSHAL_U32LE(ctx, out->stat.file_atime);
- UNMARSHAL_U32LE(ctx, out->stat.file_mtime);
- UNMARSHAL_U64LE(ctx, out->stat.file_size);
- UNMARSHAL_U16LE(ctx, out->stat.file_name.len);
- UNMARSHAL_BYTES(ctx, out->stat.file_name.utf8, out->stat.file_name.len);
- UNMARSHAL_U16LE(ctx, out->stat.file_owner_uid.len);
- UNMARSHAL_BYTES(ctx, out->stat.file_owner_uid.utf8, out->stat.file_owner_uid.len);
- UNMARSHAL_U16LE(ctx, out->stat.file_owner_gid.len);
- UNMARSHAL_BYTES(ctx, out->stat.file_owner_gid.utf8, out->stat.file_owner_gid.len);
- UNMARSHAL_U16LE(ctx, out->stat.file_last_modified_uid.len);
- UNMARSHAL_BYTES(ctx, out->stat.file_last_modified_uid.utf8, out->stat.file_last_modified_uid.len);
+ UNMARSHAL_U16LE(ctx, out->stat.fstype);
+ UNMARSHAL_U32LE(ctx, out->stat.fsdev);
+ UNMARSHAL_U8LE(ctx, out->stat.qid.type);
+ UNMARSHAL_U32LE(ctx, out->stat.qid.vers);
+ UNMARSHAL_U64LE(ctx, out->stat.qid.path);
+ UNMARSHAL_U32LE(ctx, out->stat.mode);
+ UNMARSHAL_U32LE(ctx, out->stat.atime);
+ UNMARSHAL_U32LE(ctx, out->stat.mtime);
+ UNMARSHAL_U64LE(ctx, out->stat.length);
+ UNMARSHAL_U16LE(ctx, out->stat.name.len);
+ UNMARSHAL_BYTES(ctx, out->stat.name.utf8, out->stat.name.len);
+ UNMARSHAL_U16LE(ctx, out->stat.owner_uname.len);
+ UNMARSHAL_BYTES(ctx, out->stat.owner_uname.utf8, out->stat.owner_uname.len);
+ UNMARSHAL_U16LE(ctx, out->stat.owner_gname.len);
+ UNMARSHAL_BYTES(ctx, out->stat.owner_gname.utf8, out->stat.owner_gname.len);
+ UNMARSHAL_U16LE(ctx, out->stat.last_modifier_uname.len);
+ UNMARSHAL_BYTES(ctx, out->stat.last_modifier_uname.utf8, out->stat.last_modifier_uname.len);
#if CONFIG_9P_ENABLE_9P2000_u
if (is_ver(ctx, 9P2000_u)) {
- UNMARSHAL_U16LE(ctx, out->stat.file_extension.len);
- UNMARSHAL_BYTES(ctx, out->stat.file_extension.utf8, out->stat.file_extension.len);
- UNMARSHAL_U32LE(ctx, out->stat.file_owner_n_uid);
- UNMARSHAL_U32LE(ctx, out->stat.file_owner_n_gid);
- UNMARSHAL_U32LE(ctx, out->stat.file_last_modified_n_uid);
+ UNMARSHAL_U16LE(ctx, out->stat.extension.len);
+ UNMARSHAL_BYTES(ctx, out->stat.extension.utf8, out->stat.extension.len);
+ UNMARSHAL_U32LE(ctx, out->stat.owner_unum);
+ UNMARSHAL_U32LE(ctx, out->stat.owner_gnum);
+ UNMARSHAL_U32LE(ctx, out->stat.last_modifier_unum);
}
#endif /* CONFIG_9P_ENABLE_9P2000_u */
}
@@ -2292,30 +2327,30 @@ static void unmarshal_Twstat([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net
UNMARSHAL_U32LE(ctx, out->fid);
net_offset += 2;
net_offset += 2;
- UNMARSHAL_U16LE(ctx, out->stat.kern_type);
- UNMARSHAL_U32LE(ctx, out->stat.kern_dev);
- UNMARSHAL_U8LE(ctx, out->stat.file_qid.type);
- UNMARSHAL_U32LE(ctx, out->stat.file_qid.vers);
- UNMARSHAL_U64LE(ctx, out->stat.file_qid.path);
- UNMARSHAL_U32LE(ctx, out->stat.file_mode);
- UNMARSHAL_U32LE(ctx, out->stat.file_atime);
- UNMARSHAL_U32LE(ctx, out->stat.file_mtime);
- UNMARSHAL_U64LE(ctx, out->stat.file_size);
- UNMARSHAL_U16LE(ctx, out->stat.file_name.len);
- UNMARSHAL_BYTES(ctx, out->stat.file_name.utf8, out->stat.file_name.len);
- UNMARSHAL_U16LE(ctx, out->stat.file_owner_uid.len);
- UNMARSHAL_BYTES(ctx, out->stat.file_owner_uid.utf8, out->stat.file_owner_uid.len);
- UNMARSHAL_U16LE(ctx, out->stat.file_owner_gid.len);
- UNMARSHAL_BYTES(ctx, out->stat.file_owner_gid.utf8, out->stat.file_owner_gid.len);
- UNMARSHAL_U16LE(ctx, out->stat.file_last_modified_uid.len);
- UNMARSHAL_BYTES(ctx, out->stat.file_last_modified_uid.utf8, out->stat.file_last_modified_uid.len);
+ UNMARSHAL_U16LE(ctx, out->stat.fstype);
+ UNMARSHAL_U32LE(ctx, out->stat.fsdev);
+ UNMARSHAL_U8LE(ctx, out->stat.qid.type);
+ UNMARSHAL_U32LE(ctx, out->stat.qid.vers);
+ UNMARSHAL_U64LE(ctx, out->stat.qid.path);
+ UNMARSHAL_U32LE(ctx, out->stat.mode);
+ UNMARSHAL_U32LE(ctx, out->stat.atime);
+ UNMARSHAL_U32LE(ctx, out->stat.mtime);
+ UNMARSHAL_U64LE(ctx, out->stat.length);
+ UNMARSHAL_U16LE(ctx, out->stat.name.len);
+ UNMARSHAL_BYTES(ctx, out->stat.name.utf8, out->stat.name.len);
+ UNMARSHAL_U16LE(ctx, out->stat.owner_uname.len);
+ UNMARSHAL_BYTES(ctx, out->stat.owner_uname.utf8, out->stat.owner_uname.len);
+ UNMARSHAL_U16LE(ctx, out->stat.owner_gname.len);
+ UNMARSHAL_BYTES(ctx, out->stat.owner_gname.utf8, out->stat.owner_gname.len);
+ UNMARSHAL_U16LE(ctx, out->stat.last_modifier_uname.len);
+ UNMARSHAL_BYTES(ctx, out->stat.last_modifier_uname.utf8, out->stat.last_modifier_uname.len);
#if CONFIG_9P_ENABLE_9P2000_u
if (is_ver(ctx, 9P2000_u)) {
- UNMARSHAL_U16LE(ctx, out->stat.file_extension.len);
- UNMARSHAL_BYTES(ctx, out->stat.file_extension.utf8, out->stat.file_extension.len);
- UNMARSHAL_U32LE(ctx, out->stat.file_owner_n_uid);
- UNMARSHAL_U32LE(ctx, out->stat.file_owner_n_gid);
- UNMARSHAL_U32LE(ctx, out->stat.file_last_modified_n_uid);
+ UNMARSHAL_U16LE(ctx, out->stat.extension.len);
+ UNMARSHAL_BYTES(ctx, out->stat.extension.utf8, out->stat.extension.len);
+ UNMARSHAL_U32LE(ctx, out->stat.owner_unum);
+ UNMARSHAL_U32LE(ctx, out->stat.owner_gnum);
+ UNMARSHAL_U32LE(ctx, out->stat.last_modifier_unum);
}
#endif /* CONFIG_9P_ENABLE_9P2000_u */
}
@@ -2977,49 +3012,49 @@ static void unmarshal_Rswrite([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *ne
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
static bool marshal_stat(struct lib9p_ctx *ctx, struct lib9p_stat *val, struct _marshal_ret *ret) {
- uint32_t needed_size = 49 + val->file_name.len + val->file_owner_uid.len + val->file_owner_gid.len + val->file_last_modified_uid.len;
+ uint32_t needed_size = 49 + val->name.len + val->owner_uname.len + val->owner_gname.len + val->last_modifier_uname.len;
#if CONFIG_9P_ENABLE_9P2000_u
if is_ver(ctx, 9P2000_u) {
- needed_size += 14 + val->file_extension.len;
+ needed_size += 14 + val->extension.len;
}
#endif /* CONFIG_9P_ENABLE_9P2000_u */
if (needed_size > ctx->max_msg_size) {
return true;
}
uint32_t offsetof_end = needed_size;
- uint32_t offsetof_kern_type = 2;
- MARSHAL_U16LE(ctx, offsetof_end - offsetof_kern_type);
- MARSHAL_U16LE(ctx, val->kern_type);
- MARSHAL_U32LE(ctx, val->kern_dev);
- MARSHAL_U8LE(ctx, val->file_qid.type & qt_masks[ctx->version]);
- MARSHAL_U32LE(ctx, val->file_qid.vers);
- MARSHAL_U64LE(ctx, val->file_qid.path);
- MARSHAL_U32LE(ctx, val->file_mode & dm_masks[ctx->version]);
- MARSHAL_U32LE(ctx, val->file_atime);
- MARSHAL_U32LE(ctx, val->file_mtime);
- MARSHAL_U64LE(ctx, val->file_size);
- MARSHAL_U16LE(ctx, val->file_name.len);
- MARSHAL_BYTES(ctx, val->file_name.utf8, val->file_name.len);
- MARSHAL_U16LE(ctx, val->file_owner_uid.len);
- MARSHAL_BYTES(ctx, val->file_owner_uid.utf8, val->file_owner_uid.len);
- MARSHAL_U16LE(ctx, val->file_owner_gid.len);
- MARSHAL_BYTES(ctx, val->file_owner_gid.utf8, val->file_owner_gid.len);
- MARSHAL_U16LE(ctx, val->file_last_modified_uid.len);
- MARSHAL_BYTES(ctx, val->file_last_modified_uid.utf8, val->file_last_modified_uid.len);
+ uint32_t offsetof_fstype = 2;
+ MARSHAL_U16LE(ctx, offsetof_end - offsetof_fstype);
+ MARSHAL_U16LE(ctx, val->fstype);
+ MARSHAL_U32LE(ctx, val->fsdev);
+ MARSHAL_U8LE(ctx, val->qid.type & qt_masks[ctx->version]);
+ MARSHAL_U32LE(ctx, val->qid.vers);
+ MARSHAL_U64LE(ctx, val->qid.path);
+ MARSHAL_U32LE(ctx, val->mode & dm_masks[ctx->version]);
+ MARSHAL_U32LE(ctx, val->atime);
+ MARSHAL_U32LE(ctx, val->mtime);
+ MARSHAL_U64LE(ctx, val->length);
+ MARSHAL_U16LE(ctx, val->name.len);
+ MARSHAL_BYTES(ctx, val->name.utf8, val->name.len);
+ MARSHAL_U16LE(ctx, val->owner_uname.len);
+ MARSHAL_BYTES(ctx, val->owner_uname.utf8, val->owner_uname.len);
+ MARSHAL_U16LE(ctx, val->owner_gname.len);
+ MARSHAL_BYTES(ctx, val->owner_gname.utf8, val->owner_gname.len);
+ MARSHAL_U16LE(ctx, val->last_modifier_uname.len);
+ MARSHAL_BYTES(ctx, val->last_modifier_uname.utf8, val->last_modifier_uname.len);
#if CONFIG_9P_ENABLE_9P2000_u
if (is_ver(ctx, 9P2000_u)) {
- MARSHAL_U16LE(ctx, val->file_extension.len);
- MARSHAL_BYTES(ctx, val->file_extension.utf8, val->file_extension.len);
- MARSHAL_U32LE(ctx, val->file_owner_n_uid);
- MARSHAL_U32LE(ctx, val->file_owner_n_gid);
- MARSHAL_U32LE(ctx, val->file_last_modified_n_uid);
+ MARSHAL_U16LE(ctx, val->extension.len);
+ MARSHAL_BYTES(ctx, val->extension.utf8, val->extension.len);
+ MARSHAL_U32LE(ctx, val->owner_unum);
+ MARSHAL_U32LE(ctx, val->owner_gnum);
+ MARSHAL_U32LE(ctx, val->last_modifier_unum);
}
#endif /* CONFIG_9P_ENABLE_9P2000_u */
return false;
}
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown
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) {
@@ -3060,6 +3095,8 @@ static bool marshal_Rversion(struct lib9p_ctx *ctx, struct lib9p_msg_Rversion *v
return false;
}
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown */
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
static bool marshal_Tauth(struct lib9p_ctx *ctx, struct lib9p_msg_Tauth *val, struct _marshal_ret *ret) {
uint32_t needed_size = 15 + val->uname.len + val->aname.len;
#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u
@@ -3086,7 +3123,7 @@ static bool marshal_Tauth(struct lib9p_ctx *ctx, struct lib9p_msg_Tauth *val, st
MARSHAL_BYTES_ZEROCOPY(ctx, val->aname.utf8, val->aname.len);
#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u
if (( is_ver(ctx, 9P2000_L) || is_ver(ctx, 9P2000_u) )) {
- MARSHAL_U32LE(ctx, val->n_uid);
+ MARSHAL_U32LE(ctx, val->unum);
}
#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */
return false;
@@ -3139,7 +3176,7 @@ static bool marshal_Tattach(struct lib9p_ctx *ctx, struct lib9p_msg_Tattach *val
MARSHAL_BYTES_ZEROCOPY(ctx, val->aname.utf8, val->aname.len);
#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u
if (( is_ver(ctx, 9P2000_L) || is_ver(ctx, 9P2000_u) )) {
- MARSHAL_U32LE(ctx, val->n_uid);
+ MARSHAL_U32LE(ctx, val->unum);
}
#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */
return false;
@@ -3166,7 +3203,7 @@ static bool marshal_Rattach(struct lib9p_ctx *ctx, struct lib9p_msg_Rattach *val
}
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown
static bool marshal_Rerror(struct lib9p_ctx *ctx, struct lib9p_msg_Rerror *val, struct _marshal_ret *ret) {
uint32_t needed_size = 9 + val->errstr.len;
#if CONFIG_9P_ENABLE_9P2000_u
@@ -3196,7 +3233,7 @@ static bool marshal_Rerror(struct lib9p_ctx *ctx, struct lib9p_msg_Rerror *val,
return false;
}
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
static bool marshal_Tflush(struct lib9p_ctx *ctx, struct lib9p_msg_Tflush *val, struct _marshal_ret *ret) {
uint32_t needed_size = 9;
@@ -3539,10 +3576,10 @@ static bool marshal_Tstat(struct lib9p_ctx *ctx, struct lib9p_msg_Tstat *val, st
}
static bool marshal_Rstat(struct lib9p_ctx *ctx, struct lib9p_msg_Rstat *val, struct _marshal_ret *ret) {
- uint32_t needed_size = 58 + val->stat.file_name.len + val->stat.file_owner_uid.len + val->stat.file_owner_gid.len + val->stat.file_last_modified_uid.len;
+ uint32_t needed_size = 58 + val->stat.name.len + val->stat.owner_uname.len + val->stat.owner_gname.len + val->stat.last_modifier_uname.len;
#if CONFIG_9P_ENABLE_9P2000_u
if is_ver(ctx, 9P2000_u) {
- needed_size += 14 + val->stat.file_extension.len;
+ needed_size += 14 + val->stat.extension.len;
}
#endif /* CONFIG_9P_ENABLE_9P2000_u */
if (needed_size > ctx->max_msg_size) {
@@ -3559,48 +3596,48 @@ static bool marshal_Rstat(struct lib9p_ctx *ctx, struct lib9p_msg_Rstat *val, st
MARSHAL_U8LE(ctx, 125);
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U16LE(ctx, offsetof_end - offsetof_stat);
- uint32_t offsetof_stat_end = 49 + val->stat.file_name.len + val->stat.file_owner_uid.len + val->stat.file_owner_gid.len + val->stat.file_last_modified_uid.len;
+ uint32_t offsetof_stat_end = 49 + val->stat.name.len + val->stat.owner_uname.len + val->stat.owner_gname.len + val->stat.last_modifier_uname.len;
#if CONFIG_9P_ENABLE_9P2000_u
if is_ver(ctx, 9P2000_u) {
- offsetof_stat_end += 14 + val->stat.file_extension.len;
+ offsetof_stat_end += 14 + val->stat.extension.len;
}
#endif /* CONFIG_9P_ENABLE_9P2000_u */
- uint32_t offsetof_stat_kern_type = 2;
- MARSHAL_U16LE(ctx, offsetof_stat_end - offsetof_stat_kern_type);
- MARSHAL_U16LE(ctx, val->stat.kern_type);
- MARSHAL_U32LE(ctx, val->stat.kern_dev);
- MARSHAL_U8LE(ctx, val->stat.file_qid.type & qt_masks[ctx->version]);
- MARSHAL_U32LE(ctx, val->stat.file_qid.vers);
- MARSHAL_U64LE(ctx, val->stat.file_qid.path);
- MARSHAL_U32LE(ctx, val->stat.file_mode & dm_masks[ctx->version]);
- MARSHAL_U32LE(ctx, val->stat.file_atime);
- MARSHAL_U32LE(ctx, val->stat.file_mtime);
- MARSHAL_U64LE(ctx, val->stat.file_size);
- MARSHAL_U16LE(ctx, val->stat.file_name.len);
- MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.file_name.utf8, val->stat.file_name.len);
- MARSHAL_U16LE(ctx, val->stat.file_owner_uid.len);
- MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.file_owner_uid.utf8, val->stat.file_owner_uid.len);
- MARSHAL_U16LE(ctx, val->stat.file_owner_gid.len);
- MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.file_owner_gid.utf8, val->stat.file_owner_gid.len);
- MARSHAL_U16LE(ctx, val->stat.file_last_modified_uid.len);
- MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.file_last_modified_uid.utf8, val->stat.file_last_modified_uid.len);
+ uint32_t offsetof_stat_fstype = 2;
+ MARSHAL_U16LE(ctx, offsetof_stat_end - offsetof_stat_fstype);
+ MARSHAL_U16LE(ctx, val->stat.fstype);
+ MARSHAL_U32LE(ctx, val->stat.fsdev);
+ MARSHAL_U8LE(ctx, val->stat.qid.type & qt_masks[ctx->version]);
+ MARSHAL_U32LE(ctx, val->stat.qid.vers);
+ MARSHAL_U64LE(ctx, val->stat.qid.path);
+ MARSHAL_U32LE(ctx, val->stat.mode & dm_masks[ctx->version]);
+ MARSHAL_U32LE(ctx, val->stat.atime);
+ MARSHAL_U32LE(ctx, val->stat.mtime);
+ MARSHAL_U64LE(ctx, val->stat.length);
+ MARSHAL_U16LE(ctx, val->stat.name.len);
+ MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.name.utf8, val->stat.name.len);
+ MARSHAL_U16LE(ctx, val->stat.owner_uname.len);
+ MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.owner_uname.utf8, val->stat.owner_uname.len);
+ MARSHAL_U16LE(ctx, val->stat.owner_gname.len);
+ MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.owner_gname.utf8, val->stat.owner_gname.len);
+ MARSHAL_U16LE(ctx, val->stat.last_modifier_uname.len);
+ MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.last_modifier_uname.utf8, val->stat.last_modifier_uname.len);
#if CONFIG_9P_ENABLE_9P2000_u
if (is_ver(ctx, 9P2000_u)) {
- MARSHAL_U16LE(ctx, val->stat.file_extension.len);
- MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.file_extension.utf8, val->stat.file_extension.len);
- MARSHAL_U32LE(ctx, val->stat.file_owner_n_uid);
- MARSHAL_U32LE(ctx, val->stat.file_owner_n_gid);
- MARSHAL_U32LE(ctx, val->stat.file_last_modified_n_uid);
+ MARSHAL_U16LE(ctx, val->stat.extension.len);
+ MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.extension.utf8, val->stat.extension.len);
+ MARSHAL_U32LE(ctx, val->stat.owner_unum);
+ MARSHAL_U32LE(ctx, val->stat.owner_gnum);
+ MARSHAL_U32LE(ctx, val->stat.last_modifier_unum);
}
#endif /* CONFIG_9P_ENABLE_9P2000_u */
return false;
}
static bool marshal_Twstat(struct lib9p_ctx *ctx, struct lib9p_msg_Twstat *val, struct _marshal_ret *ret) {
- uint32_t needed_size = 62 + val->stat.file_name.len + val->stat.file_owner_uid.len + val->stat.file_owner_gid.len + val->stat.file_last_modified_uid.len;
+ uint32_t needed_size = 62 + val->stat.name.len + val->stat.owner_uname.len + val->stat.owner_gname.len + val->stat.last_modifier_uname.len;
#if CONFIG_9P_ENABLE_9P2000_u
if is_ver(ctx, 9P2000_u) {
- needed_size += 14 + val->stat.file_extension.len;
+ needed_size += 14 + val->stat.extension.len;
}
#endif /* CONFIG_9P_ENABLE_9P2000_u */
if (needed_size > ctx->max_msg_size) {
@@ -3618,38 +3655,38 @@ static bool marshal_Twstat(struct lib9p_ctx *ctx, struct lib9p_msg_Twstat *val,
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
MARSHAL_U16LE(ctx, offsetof_end - offsetof_stat);
- uint32_t offsetof_stat_end = 49 + val->stat.file_name.len + val->stat.file_owner_uid.len + val->stat.file_owner_gid.len + val->stat.file_last_modified_uid.len;
+ uint32_t offsetof_stat_end = 49 + val->stat.name.len + val->stat.owner_uname.len + val->stat.owner_gname.len + val->stat.last_modifier_uname.len;
#if CONFIG_9P_ENABLE_9P2000_u
if is_ver(ctx, 9P2000_u) {
- offsetof_stat_end += 14 + val->stat.file_extension.len;
+ offsetof_stat_end += 14 + val->stat.extension.len;
}
#endif /* CONFIG_9P_ENABLE_9P2000_u */
- uint32_t offsetof_stat_kern_type = 2;
- MARSHAL_U16LE(ctx, offsetof_stat_end - offsetof_stat_kern_type);
- MARSHAL_U16LE(ctx, val->stat.kern_type);
- MARSHAL_U32LE(ctx, val->stat.kern_dev);
- MARSHAL_U8LE(ctx, val->stat.file_qid.type & qt_masks[ctx->version]);
- MARSHAL_U32LE(ctx, val->stat.file_qid.vers);
- MARSHAL_U64LE(ctx, val->stat.file_qid.path);
- MARSHAL_U32LE(ctx, val->stat.file_mode & dm_masks[ctx->version]);
- MARSHAL_U32LE(ctx, val->stat.file_atime);
- MARSHAL_U32LE(ctx, val->stat.file_mtime);
- MARSHAL_U64LE(ctx, val->stat.file_size);
- MARSHAL_U16LE(ctx, val->stat.file_name.len);
- MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.file_name.utf8, val->stat.file_name.len);
- MARSHAL_U16LE(ctx, val->stat.file_owner_uid.len);
- MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.file_owner_uid.utf8, val->stat.file_owner_uid.len);
- MARSHAL_U16LE(ctx, val->stat.file_owner_gid.len);
- MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.file_owner_gid.utf8, val->stat.file_owner_gid.len);
- MARSHAL_U16LE(ctx, val->stat.file_last_modified_uid.len);
- MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.file_last_modified_uid.utf8, val->stat.file_last_modified_uid.len);
+ uint32_t offsetof_stat_fstype = 2;
+ MARSHAL_U16LE(ctx, offsetof_stat_end - offsetof_stat_fstype);
+ MARSHAL_U16LE(ctx, val->stat.fstype);
+ MARSHAL_U32LE(ctx, val->stat.fsdev);
+ MARSHAL_U8LE(ctx, val->stat.qid.type & qt_masks[ctx->version]);
+ MARSHAL_U32LE(ctx, val->stat.qid.vers);
+ MARSHAL_U64LE(ctx, val->stat.qid.path);
+ MARSHAL_U32LE(ctx, val->stat.mode & dm_masks[ctx->version]);
+ MARSHAL_U32LE(ctx, val->stat.atime);
+ MARSHAL_U32LE(ctx, val->stat.mtime);
+ MARSHAL_U64LE(ctx, val->stat.length);
+ MARSHAL_U16LE(ctx, val->stat.name.len);
+ MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.name.utf8, val->stat.name.len);
+ MARSHAL_U16LE(ctx, val->stat.owner_uname.len);
+ MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.owner_uname.utf8, val->stat.owner_uname.len);
+ MARSHAL_U16LE(ctx, val->stat.owner_gname.len);
+ MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.owner_gname.utf8, val->stat.owner_gname.len);
+ MARSHAL_U16LE(ctx, val->stat.last_modifier_uname.len);
+ MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.last_modifier_uname.utf8, val->stat.last_modifier_uname.len);
#if CONFIG_9P_ENABLE_9P2000_u
if (is_ver(ctx, 9P2000_u)) {
- MARSHAL_U16LE(ctx, val->stat.file_extension.len);
- MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.file_extension.utf8, val->stat.file_extension.len);
- MARSHAL_U32LE(ctx, val->stat.file_owner_n_uid);
- MARSHAL_U32LE(ctx, val->stat.file_owner_n_gid);
- MARSHAL_U32LE(ctx, val->stat.file_last_modified_n_uid);
+ MARSHAL_U16LE(ctx, val->stat.extension.len);
+ MARSHAL_BYTES_ZEROCOPY(ctx, val->stat.extension.utf8, val->stat.extension.len);
+ MARSHAL_U32LE(ctx, val->stat.owner_unum);
+ MARSHAL_U32LE(ctx, val->stat.owner_gnum);
+ MARSHAL_U32LE(ctx, val->stat.last_modifier_unum);
}
#endif /* CONFIG_9P_ENABLE_9P2000_u */
return false;
@@ -4659,7 +4696,7 @@ static bool marshal_Rswrite(struct lib9p_ctx *ctx, struct lib9p_msg_Rswrite *val
/* *_format *******************************************************************/
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown
static void lib9p_tag_format(lib9p_tag_t *self, struct fmt_state *state) {
switch (*self) {
case LIB9P_TAG_NOTAG:
@@ -4688,8 +4725,8 @@ static void lib9p_s_format(struct lib9p_s *self, struct fmt_state *state) {
#pragma GCC diagnostic pop
}
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown */
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown
static void lib9p_dm_format(lib9p_dm_t *self, struct fmt_state *state) {
bool empty = true;
fmt_state_putchar(state, '(');
@@ -4891,8 +4928,8 @@ static void lib9p_dm_format(lib9p_dm_t *self, struct fmt_state *state) {
fmt_state_putchar(state, ')');
}
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown */
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown
static void lib9p_qt_format(lib9p_qt_t *self, struct fmt_state *state) {
bool empty = true;
fmt_state_putchar(state, '(');
@@ -4960,41 +4997,41 @@ static void lib9p_qid_format(struct lib9p_qid *self, struct fmt_state *state) {
fmt_state_puts(state, " }");
}
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
static void lib9p_stat_format(struct lib9p_stat *self, struct fmt_state *state) {
fmt_state_putchar(state, '{');
- fmt_state_puts(state, " kern_type=");
- fmt_state_printf(state, "%"PRIu16, self->kern_type);
- fmt_state_puts(state, " kern_dev=");
- fmt_state_printf(state, "%"PRIu32, self->kern_dev);
- fmt_state_puts(state, " file_qid=");
- lib9p_qid_format(&self->file_qid, state);
- fmt_state_puts(state, " file_mode=");
- lib9p_dm_format(&self->file_mode, state);
- fmt_state_puts(state, " file_atime=");
- fmt_state_printf(state, "%"PRIu32, self->file_atime);
- fmt_state_puts(state, " file_mtime=");
- fmt_state_printf(state, "%"PRIu32, self->file_mtime);
- fmt_state_puts(state, " file_size=");
- fmt_state_printf(state, "%"PRIu64, self->file_size);
- fmt_state_puts(state, " file_name=");
- lib9p_s_format(&self->file_name, state);
- fmt_state_puts(state, " file_owner_uid=");
- lib9p_s_format(&self->file_owner_uid, state);
- fmt_state_puts(state, " file_owner_gid=");
- lib9p_s_format(&self->file_owner_gid, state);
- fmt_state_puts(state, " file_last_modified_uid=");
- lib9p_s_format(&self->file_last_modified_uid, state);
+ fmt_state_puts(state, " fstype=");
+ fmt_state_printf(state, "%"PRIu16, self->fstype);
+ fmt_state_puts(state, " fsdev=");
+ fmt_state_printf(state, "%"PRIu32, self->fsdev);
+ fmt_state_puts(state, " qid=");
+ lib9p_qid_format(&self->qid, state);
+ fmt_state_puts(state, " mode=");
+ lib9p_dm_format(&self->mode, state);
+ fmt_state_puts(state, " atime=");
+ fmt_state_printf(state, "%"PRIu32, self->atime);
+ fmt_state_puts(state, " mtime=");
+ fmt_state_printf(state, "%"PRIu32, self->mtime);
+ fmt_state_puts(state, " length=");
+ fmt_state_printf(state, "%"PRIu64, self->length);
+ fmt_state_puts(state, " name=");
+ lib9p_s_format(&self->name, state);
+ fmt_state_puts(state, " owner_uname=");
+ lib9p_s_format(&self->owner_uname, state);
+ fmt_state_puts(state, " owner_gname=");
+ lib9p_s_format(&self->owner_gname, state);
+ fmt_state_puts(state, " last_modifier_uname=");
+ lib9p_s_format(&self->last_modifier_uname, state);
#if CONFIG_9P_ENABLE_9P2000_u
- fmt_state_puts(state, " file_extension=");
- lib9p_s_format(&self->file_extension, state);
- fmt_state_puts(state, " file_owner_n_uid=");
- lib9p_nuid_format(&self->file_owner_n_uid, state);
- fmt_state_puts(state, " file_owner_n_gid=");
- lib9p_nuid_format(&self->file_owner_n_gid, state);
- fmt_state_puts(state, " file_last_modified_n_uid=");
- lib9p_nuid_format(&self->file_last_modified_n_uid, state);
+ fmt_state_puts(state, " extension=");
+ lib9p_s_format(&self->extension, state);
+ fmt_state_puts(state, " owner_unum=");
+ lib9p_nuid_format(&self->owner_unum, state);
+ fmt_state_puts(state, " owner_gnum=");
+ lib9p_nuid_format(&self->owner_gnum, state);
+ fmt_state_puts(state, " last_modifier_unum=");
+ lib9p_nuid_format(&self->last_modifier_unum, state);
#endif /* CONFIG_9P_ENABLE_9P2000_u */
fmt_state_puts(state, " }");
}
@@ -5075,7 +5112,7 @@ static void lib9p_o_format(lib9p_o_t *self, struct fmt_state *state) {
}
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown
static void lib9p_msg_Tversion_format(struct lib9p_msg_Tversion *self, struct fmt_state *state) {
fmt_state_puts(state, "Tversion {");
fmt_state_puts(state, " tag=");
@@ -5098,6 +5135,8 @@ static void lib9p_msg_Rversion_format(struct lib9p_msg_Rversion *self, struct fm
fmt_state_puts(state, " }");
}
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown */
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
static void lib9p_msg_Tauth_format(struct lib9p_msg_Tauth *self, struct fmt_state *state) {
fmt_state_puts(state, "Tauth {");
fmt_state_puts(state, " tag=");
@@ -5109,8 +5148,8 @@ static void lib9p_msg_Tauth_format(struct lib9p_msg_Tauth *self, struct fmt_stat
fmt_state_puts(state, " aname=");
lib9p_s_format(&self->aname, state);
#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u
- fmt_state_puts(state, " n_uid=");
- lib9p_nuid_format(&self->n_uid, state);
+ fmt_state_puts(state, " unum=");
+ lib9p_nuid_format(&self->unum, state);
#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */
fmt_state_puts(state, " }");
}
@@ -5137,8 +5176,8 @@ static void lib9p_msg_Tattach_format(struct lib9p_msg_Tattach *self, struct fmt_
fmt_state_puts(state, " aname=");
lib9p_s_format(&self->aname, state);
#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u
- fmt_state_puts(state, " n_uid=");
- lib9p_nuid_format(&self->n_uid, state);
+ fmt_state_puts(state, " unum=");
+ lib9p_nuid_format(&self->unum, state);
#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */
fmt_state_puts(state, " }");
}
@@ -5153,7 +5192,7 @@ static void lib9p_msg_Rattach_format(struct lib9p_msg_Rattach *self, struct fmt_
}
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown
static void lib9p_msg_Rerror_format(struct lib9p_msg_Rerror *self, struct fmt_state *state) {
fmt_state_puts(state, "Rerror {");
fmt_state_puts(state, " tag=");
@@ -5167,7 +5206,7 @@ static void lib9p_msg_Rerror_format(struct lib9p_msg_Rerror *self, struct fmt_st
fmt_state_puts(state, " }");
}
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
static void lib9p_msg_Tflush_format(struct lib9p_msg_Tflush *self, struct fmt_state *state) {
fmt_state_puts(state, "Tflush {");
@@ -7811,7 +7850,6 @@ static void lib9p_msg_Rswrite_format(struct lib9p_msg_Rswrite *self, struct fmt_
/* tables.h *******************************************************************/
const struct _lib9p_ver_tentry _lib9p_table_ver[LIB9P_VER_NUM] = {
- [LIB9P_VER_unknown] = {.name="unknown", .min_msg_size=9},
#if CONFIG_9P_ENABLE_9P2000
[LIB9P_VER_9P2000] = {.name="9P2000", .min_msg_size=9},
#endif /* CONFIG_9P_ENABLE_9P2000 */
@@ -7827,6 +7865,9 @@ const struct _lib9p_ver_tentry _lib9p_table_ver[LIB9P_VER_NUM] = {
#if CONFIG_9P_ENABLE_9P2000_u
[LIB9P_VER_9P2000_u] = {.name="9P2000.u", .min_msg_size=13},
#endif /* CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_unknown
+ [LIB9P_VER_unknown] = {.name="unknown", .min_msg_size=9},
+#endif /* CONFIG_9P_ENABLE_unknown */
};
#define _MSG(typ) [LIB9P_TYP_##typ] = { \
@@ -7834,11 +7875,6 @@ const struct _lib9p_ver_tentry _lib9p_table_ver[LIB9P_VER_NUM] = {
.box_as_fmt_formatter = (_box_as_fmt_formatter_fn_t)lo_box_lib9p_msg_##typ##_as_fmt_formatter, \
}
const struct _lib9p_msg_tentry _lib9p_table_msg[LIB9P_VER_NUM][0x100] = {
- [LIB9P_VER_unknown] = {
- _MSG(Tversion),
- _MSG(Rversion),
- _MSG(Rerror),
- },
#if CONFIG_9P_ENABLE_9P2000
[LIB9P_VER_9P2000] = {
_MSG(Tversion),
@@ -8032,6 +8068,13 @@ const struct _lib9p_msg_tentry _lib9p_table_msg[LIB9P_VER_NUM][0x100] = {
_MSG(Rwstat),
},
#endif /* CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_unknown
+ [LIB9P_VER_unknown] = {
+ _MSG(Tversion),
+ _MSG(Rversion),
+ _MSG(Rerror),
+ },
+#endif /* CONFIG_9P_ENABLE_unknown */
};
#define _MSG_RECV(typ) [LIB9P_TYP_##typ/2] = { \
@@ -8043,9 +8086,6 @@ const struct _lib9p_msg_tentry _lib9p_table_msg[LIB9P_VER_NUM][0x100] = {
}
const struct _lib9p_recv_tentry _lib9p_table_Tmsg_recv[LIB9P_VER_NUM][0x80] = {
- [LIB9P_VER_unknown] = {
- _MSG_RECV(Tversion),
- },
#if CONFIG_9P_ENABLE_9P2000
[LIB9P_VER_9P2000] = {
_MSG_RECV(Tversion),
@@ -8150,13 +8190,14 @@ const struct _lib9p_recv_tentry _lib9p_table_Tmsg_recv[LIB9P_VER_NUM][0x80] = {
_MSG_RECV(Twstat),
},
#endif /* CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_unknown
+ [LIB9P_VER_unknown] = {
+ _MSG_RECV(Tversion),
+ },
+#endif /* CONFIG_9P_ENABLE_unknown */
};
const struct _lib9p_recv_tentry _lib9p_table_Rmsg_recv[LIB9P_VER_NUM][0x80] = {
- [LIB9P_VER_unknown] = {
- _MSG_RECV(Rversion),
- _MSG_RECV(Rerror),
- },
#if CONFIG_9P_ENABLE_9P2000
[LIB9P_VER_9P2000] = {
_MSG_RECV(Rversion),
@@ -8266,12 +8307,15 @@ const struct _lib9p_recv_tentry _lib9p_table_Rmsg_recv[LIB9P_VER_NUM][0x80] = {
_MSG_RECV(Rwstat),
},
#endif /* CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_unknown
+ [LIB9P_VER_unknown] = {
+ _MSG_RECV(Rversion),
+ _MSG_RECV(Rerror),
+ },
+#endif /* CONFIG_9P_ENABLE_unknown */
};
const struct _lib9p_send_tentry _lib9p_table_Tmsg_send[LIB9P_VER_NUM][0x80] = {
- [LIB9P_VER_unknown] = {
- _MSG_SEND(Tversion),
- },
#if CONFIG_9P_ENABLE_9P2000
[LIB9P_VER_9P2000] = {
_MSG_SEND(Tversion),
@@ -8376,13 +8420,14 @@ const struct _lib9p_send_tentry _lib9p_table_Tmsg_send[LIB9P_VER_NUM][0x80] = {
_MSG_SEND(Twstat),
},
#endif /* CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_unknown
+ [LIB9P_VER_unknown] = {
+ _MSG_SEND(Tversion),
+ },
+#endif /* CONFIG_9P_ENABLE_unknown */
};
const struct _lib9p_send_tentry _lib9p_table_Rmsg_send[LIB9P_VER_NUM][0x80] = {
- [LIB9P_VER_unknown] = {
- _MSG_SEND(Rversion),
- _MSG_SEND(Rerror),
- },
#if CONFIG_9P_ENABLE_9P2000
[LIB9P_VER_9P2000] = {
_MSG_SEND(Rversion),
@@ -8492,8 +8537,15 @@ const struct _lib9p_send_tentry _lib9p_table_Rmsg_send[LIB9P_VER_NUM][0x80] = {
_MSG_SEND(Rwstat),
},
#endif /* CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_unknown
+ [LIB9P_VER_unknown] = {
+ _MSG_SEND(Rversion),
+ _MSG_SEND(Rerror),
+ },
+#endif /* CONFIG_9P_ENABLE_unknown */
};
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
LM_FLATTEN ssize_t _lib9p_stat_validate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes, uint32_t *ret_net_size) {
return validate_stat(ctx, net_size, net_bytes, ret_net_size);
}
@@ -8503,3 +8555,4 @@ LM_FLATTEN void _lib9p_stat_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes,
LM_FLATTEN bool _lib9p_stat_marshal(struct lib9p_ctx *ctx, struct lib9p_stat *val, struct _marshal_ret *ret) {
return marshal_stat(ctx, val, ret);
}
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
diff --git a/lib9p/core_include/lib9p/_core_generated.h b/lib9p/core_include/lib9p/_core_generated.h
index 68eb636..4c45b58 100644
--- a/lib9p/core_include/lib9p/_core_generated.h
+++ b/lib9p/core_include/lib9p/_core_generated.h
@@ -1,4 +1,4 @@
-/* Generated by `lib9p/core.gen lib9p/idl/2002-9P2000.9p lib9p/idl/2003-9P2000.p9p.9p lib9p/idl/2005-9P2000.u.9p lib9p/idl/2010-9P2000.L.9p lib9p/idl/2012-9P2000.e.9p`. DO NOT EDIT! */
+/* Generated by `lib9p/core.gen lib9p/idl/0000-uninitialized.9p lib9p/idl/2002-9P2000.9p lib9p/idl/2003-9P2000.p9p.9p lib9p/idl/2005-9P2000.u.9p lib9p/idl/2010-9P2000.L.9p lib9p/idl/2012-9P2000.e.9p`. DO NOT EDIT! */
#ifndef _LIB9P_CORE_H_
#error Do not include <lib9p/_core_generated.h> directly; include <lib9p/core.h> instead
@@ -40,6 +40,12 @@
#error config.h must define CONFIG_9P_ENABLE_9P2000_u
#endif
+#ifndef CONFIG_9P_ENABLE_unknown
+ #error config.h must define CONFIG_9P_ENABLE_unknown
+#endif
+
+#define _LIB9P_ENABLE_stat CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+
/* enum version ***************************************************************/
enum lib9p_version {
@@ -111,17 +117,19 @@ enum lib9p_msg_type { /* uint8_t */
LIB9P_TYP_Topenfd = 98,
LIB9P_TYP_Ropenfd = 99,
#endif /* CONFIG_9P_ENABLE_9P2000_p9p */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown
LIB9P_TYP_Tversion = 100,
LIB9P_TYP_Rversion = 101,
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown */
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
LIB9P_TYP_Tauth = 102,
LIB9P_TYP_Rauth = 103,
LIB9P_TYP_Tattach = 104,
LIB9P_TYP_Rattach = 105,
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown
LIB9P_TYP_Rerror = 107,
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
LIB9P_TYP_Tflush = 108,
LIB9P_TYP_Rflush = 109,
@@ -163,7 +171,7 @@ LO_IMPLEMENTATION_H(fmt_formatter, enum lib9p_msg_type, lib9p_msg_type);
/* payload types **************************************************************/
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown
/* size = 2 ; max_iov = 1 ; max_copy = 2 */
typedef uint16_t lib9p_tag_t;
LO_IMPLEMENTATION_H(fmt_formatter, lib9p_tag_t, lib9p_tag);
@@ -174,8 +182,8 @@ typedef uint32_t lib9p_fid_t;
LO_IMPLEMENTATION_H(fmt_formatter, lib9p_fid_t, lib9p_fid);
#define LIB9P_FID_NOFID ((lib9p_fid_t)(UINT32_MAX))
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown */
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown
/* size = 4 ; max_iov = 1 ; max_copy = 4 */
typedef uint32_t lib9p_dm_t;
LO_IMPLEMENTATION_H(fmt_formatter, lib9p_dm_t, lib9p_dm);
@@ -219,8 +227,8 @@ LO_IMPLEMENTATION_H(fmt_formatter, lib9p_dm_t, lib9p_dm);
/* masks */
#define LIB9P_DM_PERM_MASK ((lib9p_dm_t)(0b000000000000000000000111111111))
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown */
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown
/* size = 1 ; max_iov = 1 ; max_copy = 1 */
typedef uint8_t lib9p_qt_t;
LO_IMPLEMENTATION_H(fmt_formatter, lib9p_qt_t, lib9p_qt);
@@ -238,7 +246,7 @@ LO_IMPLEMENTATION_H(fmt_formatter, lib9p_qt_t, lib9p_qt);
/* aliases */
#define LIB9P_QT_FILE ((lib9p_qt_t)(0))
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
/* size = 1 ; max_iov = 1 ; max_copy = 1 */
typedef uint8_t lib9p_o_t;
@@ -685,7 +693,7 @@ LO_IMPLEMENTATION_H(fmt_formatter, lib9p_lock_status_t, lib9p_lock_status);
#define LIB9P_LOCK_STATUS_GRACE ((lib9p_lock_status_t)(3))
#endif /* CONFIG_9P_ENABLE_9P2000_L */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown
/* min_size = 2 ; exp_size = 29 ; max_size = 65,537 ; max_iov = 2 ; max_copy = 2 */
struct lib9p_s {
uint16_t len;
@@ -701,6 +709,8 @@ struct lib9p_qid {
};
LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_qid, lib9p_qid);
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown */
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
/* size = 9 ; max_iov = 1 ; max_copy = 9 */
struct lib9p_msg_Tflush {
lib9p_tag_t tag;
@@ -999,28 +1009,28 @@ LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rswrite, lib9p_msg_Rswrite);
/* LIB9P_VER_9P2000_p9p: min_size = 49 ; exp_size = 157 ; max_size = 262,189 ; max_iov = 8 ; max_copy = 49 */
/* LIB9P_VER_9P2000_u : min_size = 63 ; exp_size = 198 ; max_size = 327,738 ; max_iov = 11 ; max_copy = 63 */
struct lib9p_stat {
- uint16_t kern_type;
- uint32_t kern_dev;
- struct lib9p_qid file_qid;
- lib9p_dm_t file_mode;
- uint32_t file_atime;
- uint32_t file_mtime;
- uint64_t file_size;
- struct lib9p_s file_name;
- struct lib9p_s file_owner_uid;
- struct lib9p_s file_owner_gid;
- struct lib9p_s file_last_modified_uid;
+ uint16_t fstype;
+ uint32_t fsdev;
+ struct lib9p_qid qid;
+ lib9p_dm_t mode;
+ uint32_t atime;
+ uint32_t mtime;
+ uint64_t length;
+ struct lib9p_s name;
+ struct lib9p_s owner_uname;
+ struct lib9p_s owner_gname;
+ struct lib9p_s last_modifier_uname;
#if CONFIG_9P_ENABLE_9P2000_u
- struct lib9p_s file_extension;
- lib9p_nuid_t file_owner_n_uid;
- lib9p_nuid_t file_owner_n_gid;
- lib9p_nuid_t file_last_modified_n_uid;
+ struct lib9p_s extension;
+ lib9p_nuid_t owner_unum;
+ lib9p_nuid_t owner_gnum;
+ lib9p_nuid_t last_modifier_unum;
#endif /* CONFIG_9P_ENABLE_9P2000_u */
};
LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_stat, lib9p_stat);
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown
/* min_size = 13 ; exp_size = 40 ; max_size = 65,548 ; max_iov = 2 ; max_copy = 13 */
struct lib9p_msg_Tversion {
lib9p_tag_t tag;
@@ -1037,6 +1047,8 @@ struct lib9p_msg_Rversion {
};
LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rversion, lib9p_msg_Rversion);
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown */
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
/* LIB9P_VER_9P2000 : min_size = 15 ; exp_size = 69 ; max_size = 131,085 ; max_iov = 4 ; max_copy = 15 */
/* LIB9P_VER_9P2000_L : min_size = 19 ; exp_size = 73 ; max_size = 131,089 ; max_iov = 5 ; max_copy = 19 */
/* LIB9P_VER_9P2000_e : min_size = 15 ; exp_size = 69 ; max_size = 131,085 ; max_iov = 4 ; max_copy = 15 */
@@ -1048,7 +1060,7 @@ struct lib9p_msg_Tauth {
struct lib9p_s uname;
struct lib9p_s aname;
#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u
- lib9p_nuid_t n_uid;
+ lib9p_nuid_t unum;
#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */
};
LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tauth, lib9p_msg_Tauth);
@@ -1072,7 +1084,7 @@ struct lib9p_msg_Tattach {
struct lib9p_s uname;
struct lib9p_s aname;
#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u
- lib9p_nuid_t n_uid;
+ lib9p_nuid_t unum;
#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */
};
LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Tattach, lib9p_msg_Tattach);
@@ -1085,11 +1097,12 @@ struct lib9p_msg_Rattach {
LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rattach, lib9p_msg_Rattach);
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown
/* LIB9P_VER_9P2000 : min_size = 9 ; exp_size = 36 ; max_size = 65,544 ; max_iov = 2 ; max_copy = 9 */
/* LIB9P_VER_9P2000_e : min_size = 9 ; exp_size = 36 ; max_size = 65,544 ; max_iov = 2 ; max_copy = 9 */
/* LIB9P_VER_9P2000_p9p: min_size = 9 ; exp_size = 36 ; max_size = 65,544 ; max_iov = 2 ; max_copy = 9 */
/* LIB9P_VER_9P2000_u : min_size = 13 ; exp_size = 40 ; max_size = 65,548 ; max_iov = 3 ; max_copy = 13 */
+/* LIB9P_VER_unknown : min_size = 9 ; exp_size = 36 ; max_size = 65,544 ; max_iov = 2 ; max_copy = 9 */
struct lib9p_msg_Rerror {
lib9p_tag_t tag;
struct lib9p_s errstr;
@@ -1099,7 +1112,7 @@ struct lib9p_msg_Rerror {
};
LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Rerror, lib9p_msg_Rerror);
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_unknown */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
/* min_size = 17 ; exp_size = 481 ; max_size = 1,048,609 ; max_iov = 32 ; max_copy = 49 */
struct lib9p_msg_Twalk {
@@ -1421,6 +1434,8 @@ LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Twstat, lib9p_msg_Twstat);
#else
#define LIB9P_TMSG_MAX_IOV 32
#endif
+#elif CONFIG_9P_ENABLE_unknown
+ #define LIB9P_TMSG_MAX_IOV 2
#endif
#if CONFIG_9P_ENABLE_9P2000_u
@@ -1441,18 +1456,22 @@ LO_IMPLEMENTATION_H(fmt_formatter, struct lib9p_msg_Twstat, lib9p_msg_Twstat);
#else
#define LIB9P_TMSG_MAX_COPY 62
#endif
+#elif CONFIG_9P_ENABLE_unknown
+ #define LIB9P_TMSG_MAX_COPY 13
#endif
#if CONFIG_9P_ENABLE_9P2000_u
#define LIB9P_RMSG_MAX_IOV 11
#elif CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p
#define LIB9P_RMSG_MAX_IOV 8
-#elif CONFIG_9P_ENABLE_9P2000_L
+#elif CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_unknown
#define LIB9P_RMSG_MAX_IOV 2
#endif
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
#define LIB9P_RMSG_MAX_COPY 217
+#elif CONFIG_9P_ENABLE_unknown
+ #define LIB9P_RMSG_MAX_COPY 13
#endif
struct lib9p_Tmsg_send_buf {
diff --git a/lib9p/core_include/lib9p/core.h b/lib9p/core_include/lib9p/core.h
index ff822ed..38f3934 100644
--- a/lib9p/core_include/lib9p/core.h
+++ b/lib9p/core_include/lib9p/core.h
@@ -12,6 +12,7 @@
#include <libmisc/assert.h>
+#define CONFIG_9P_ENABLE_unknown 1
#include <lib9p/_core_generated.h>
#ifndef CONFIG_9P_MAX_ERR_SIZE
@@ -45,7 +46,7 @@ struct lib9p_ctx {
uint32_t max_msg_size;
/* state */
-#ifdef CONFIG_9P_ENABLE_9P2000_u
+#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L
lib9p_errno_t err_num;
#endif
[[gnu::nonstring]] char err_msg[CONFIG_9P_MAX_ERR_SIZE];
@@ -56,9 +57,31 @@ void lib9p_ctx_clear_error(struct lib9p_ctx *ctx);
bool lib9p_ctx_has_error(struct lib9p_ctx *ctx);
/** Write an static error into ctx, return -1. */
-int lib9p_error(struct lib9p_ctx *ctx, lib9p_errno_t linux_errno, char const *msg);
+int lib9p_error(struct lib9p_ctx *ctx,
+#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L
+ lib9p_errno_t linux_errno,
+#endif
+ char const *msg);
/** Write a printf-style error into ctx, return -1. */
-int lib9p_errorf(struct lib9p_ctx *ctx, lib9p_errno_t linux_errno, char const *fmt, ...) [[gnu::format(printf, 3, 4)]];
+int lib9p_errorf(struct lib9p_ctx *ctx,
+#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L
+ lib9p_errno_t linux_errno,
+#endif
+ char const *fmt, ...)
+#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L
+ [[gnu::format(printf, 3, 4)]]
+#else
+ [[gnu::format(printf, 2, 3)]]
+#endif
+ ;
+
+#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L
+/* Detect things that should be just lib9p_error() */
+#define lib9p_errorf(ctx, errnum, fmt, ...) lib9p_errorf(ctx, errnum, fmt, __VA_ARGS__)
+#else
+#define lib9p_errorf(ctx, errnum, fmt, ...) lib9p_errorf(ctx, fmt, __VA_ARGS__)
+#define lib9p_error(ctx, errnum, errmsg) lib9p_error(ctx, errmsg)
+#endif
/* misc utilities *************************************************************/
@@ -143,16 +166,7 @@ bool lib9p_Rmsg_marshal(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *bo
/* `struct lib9p_stat` helpers ************************************************/
-/** Assert that a `struct lib9p_stat` object looks valid. */
-static inline void lib9p_stat_assert(struct lib9p_stat stat) {
- assert( ((bool)(stat.file_mode & LIB9P_DM_DIR )) == ((bool)(stat.file_qid.type & LIB9P_QT_DIR )) );
- assert( ((bool)(stat.file_mode & LIB9P_DM_APPEND)) == ((bool)(stat.file_qid.type & LIB9P_QT_APPEND)) );
- assert( ((bool)(stat.file_mode & LIB9P_DM_EXCL )) == ((bool)(stat.file_qid.type & LIB9P_QT_EXCL )) );
- assert( ((bool)(stat.file_mode & LIB9P_DM_AUTH )) == ((bool)(stat.file_qid.type & LIB9P_QT_AUTH )) );
- assert( ((bool)(stat.file_mode & LIB9P_DM_TMP )) == ((bool)(stat.file_qid.type & LIB9P_QT_TMP )) );
- assert( (stat.file_size == 0) || !(stat.file_mode & LIB9P_DM_DIR) );
-}
-
+#if _LIB9P_ENABLE_stat
/**
* Validate a message's `stat` structure.
*
@@ -201,5 +215,6 @@ void lib9p_stat_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes,
*/
uint32_t lib9p_stat_marshal(struct lib9p_ctx *ctx, uint32_t max_net_size, struct lib9p_stat *obj,
uint8_t *ret_bytes);
+#endif
#endif /* _LIB9P_CORE_H_ */
diff --git a/lib9p/core_tables.c b/lib9p/core_tables.c
index a04a5f0..bc452c7 100644
--- a/lib9p/core_tables.c
+++ b/lib9p/core_tables.c
@@ -155,6 +155,7 @@ bool lib9p_Rmsg_marshal(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *bo
/* `struct lib9p_stat` helpers ************************************************/
+#if _LIB9P_ENABLE_stat
bool lib9p_stat_validate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes,
uint32_t *ret_net_size, size_t *ret_host_size) {
ssize_t host_size = _lib9p_stat_validate(ctx, net_size, net_bytes, ret_net_size);
@@ -186,3 +187,4 @@ uint32_t lib9p_stat_marshal(struct lib9p_ctx *ctx, uint32_t max_net_size, struct
return 0;
return ret.net_iov[0].iov_len;
}
+#endif
diff --git a/lib9p/core_tables.h b/lib9p/core_tables.h
index 2c5f745..17e9398 100644
--- a/lib9p/core_tables.h
+++ b/lib9p/core_tables.h
@@ -52,8 +52,10 @@ extern const struct _lib9p_send_tentry _lib9p_table_Rmsg_send[LIB9P_VER_NUM][0x8
/* stat ***********************************************************************/
+#if _LIB9P_ENABLE_stat
ssize_t _lib9p_stat_validate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes, uint32_t *ret_net_size);
void _lib9p_stat_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out);
bool _lib9p_stat_marshal(struct lib9p_ctx *ctx, struct lib9p_stat *val, struct _marshal_ret *ret);
+#endif
#endif /* _LIB9P_CORE_TABLES_H_ */
diff --git a/lib9p/idl/0000-uninitialized.9p b/lib9p/idl/0000-uninitialized.9p
new file mode 100644
index 0000000..9319b5e
--- /dev/null
+++ b/lib9p/idl/0000-uninitialized.9p
@@ -0,0 +1,13 @@
+# lib9p/idl/0000-uninitialized.9p - Defs for bootstrapping
+#
+# Copyright (C) 2025 Luke T. Shumaker <lukeshu@lukeshu.com>
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
+version "unknown"
+
+# For the actual protocol.
+from ./2002-9P2000.9p import s, tag
+from ./2002-9P2000.9p import Tversion, Rversion, Rerror
+
+# For srv.h
+from ./2002-9P2000.9p import dm, qt, qid, fid
diff --git a/lib9p/idl/2002-9P2000.9p b/lib9p/idl/2002-9P2000.9p
index 13393c6..712ffea 100644
--- a/lib9p/idl/2002-9P2000.9p
+++ b/lib9p/idl/2002-9P2000.9p
@@ -91,18 +91,26 @@ bitfield qt = 1
struct qid = "type[qt] vers[4] path[8]"
# stat - file status
-struct stat = "stat_size[2,val=end-&kern_type]"
- "kern_type[2]"
- "kern_dev[4]"
- "file_qid[qid]"
- "file_mode[dm]"
- "file_atime[4]"
- "file_mtime[4]"
- "file_size[8]"
- "file_name[s]"
- "file_owner_uid[s]"
- "file_owner_gid[s]"
- "file_last_modified_uid[s]"
+struct stat = "_stat_size[2,val=end-&fstype]"
+ # fstype and fsdev are documented simply as "for kernel
+ # use". The are ignored by Plan 9's in-kernel 9P
+ # client; mntdirfix() overwrites them with fstype='M'
+ # and fsdev=nonce. Processes may observe values other
+ # than fstype='M', as 'M' is used for actual 9P servers,
+ # while other values are used for in-kernel device
+ # servers (such as '|' for pipes, or 'I' for the IP
+ # stack).
+ "fstype[2]" # filesystem type
+ "fsdev[4]" # filesystem instance/subtype
+ "qid[qid]"
+ "mode[dm]"
+ "atime[4]"
+ "mtime[4]"
+ "length[8]" # 0 for directories
+ "name[s]"
+ "owner_uname[s]"
+ "owner_gname[s]"
+ "last_modifier_uname[s]"
# "O"pen flags (flags to pass to Topen and Tcreate)
# Unused bits *must* be 0.
diff --git a/lib9p/idl/2005-9P2000.u.9p b/lib9p/idl/2005-9P2000.u.9p
index 1d630f9..446385c 100644
--- a/lib9p/idl/2005-9P2000.u.9p
+++ b/lib9p/idl/2005-9P2000.u.9p
@@ -17,13 +17,13 @@ num nuid = 4
num errno = 4
"NOERROR = 0"
-struct stat += "file_extension[s]"
- "file_owner_n_uid[nuid]"
- "file_owner_n_gid[nuid]"
- "file_last_modified_n_uid[nuid]"
+struct stat += "extension[s]"
+ "owner_unum[nuid]"
+ "owner_gnum[nuid]"
+ "last_modifier_unum[nuid]"
-msg Tauth += "n_uid[nuid]"
-msg Tattach += "n_uid[nuid]"
+msg Tauth += "unum[nuid]"
+msg Tattach += "unum[nuid]"
msg Rerror += "errnum[errno]"
diff --git a/lib9p/srv.c b/lib9p/srv.c
index 6ab2ab2..08ccfc3 100644
--- a/lib9p/srv.c
+++ b/lib9p/srv.c
@@ -92,11 +92,12 @@ struct srv_pathinfo {
#define FIDFLAG_OPEN_R (1<<0)
#define FIDFLAG_OPEN_W (1<<1)
#define FIDFLAG_RCLOSE (1<<2)
+#define FIDFLAG_APPEND (1<<3)
#define FIDFLAG_OPEN (FIDFLAG_OPEN_R|FIDFLAG_OPEN_W)
struct srv_fidinfo {
srv_path_t path;
- struct lib9p_srv_authinfo *authinfo;
+ struct lib9p_srv_userid *user;
uint8_t flags;
enum srv_filetype type;
union {
@@ -107,6 +108,7 @@ struct srv_fidinfo {
lo_interface lib9p_srv_dio io;
size_t idx;
uint64_t off;
+ struct lib9p_srv_dirent buffered_dirent;
} dir;
struct {
struct lib9p_s aname;
@@ -163,44 +165,52 @@ static inline enum srv_filetype srv_qid_filetype(struct lib9p_qid qid) {
return SRV_FILETYPE_FILE;
}
-static inline bool srv_check_perm(struct srv_req *ctx, struct lib9p_stat *stat, uint8_t action) {
+static inline bool srv_check_perm(struct srv_req *ctx, struct lib9p_srv_stat *stat, uint8_t action) {
assert(ctx);
assert(stat);
assert(action);
/* TODO actually check user and group instead of just assuming "other". */
- uint8_t mode = (uint8_t)(stat->file_mode & 07);
+ uint8_t mode = (uint8_t)(stat->mode & 07);
return mode & action;
}
-struct lib9p_srv_authinfo *srv_authinfo_new(struct lib9p_s uname, lib9p_nuid_t uid) {
- struct lib9p_srv_authinfo *ret = malloc(sizeof(struct lib9p_srv_authinfo) + uname.len);
+[[gnu::unused]]
+static struct lib9p_srv_userid *srv_userid_new(struct lib9p_s name
+#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L
+ , lib9p_nuid_t num
+#endif
+ ) {
+ struct lib9p_srv_userid *ret = malloc(sizeof(struct lib9p_srv_userid) + name.len);
if (!ret)
return NULL;
- ret->uid = uid;
- ret->uname.len = uname.len;
- ret->uname.utf8 = (void *)&ret[1];
- memcpy(ret->uname.utf8, uname.utf8, uname.len);
+#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L
+ ret->num = num;
+#endif
+ ret->name.len = name.len;
+ ret->name.utf8 = (void *)&ret[1];
+ memcpy(ret->name.utf8, name.utf8, name.len);
ret->refcount = 1;
return ret;
}
+#if !(CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L)
+#define srv_userid_new(name, num) srv_userid_new(name)
+#endif
-struct lib9p_srv_authinfo *srv_authinfo_decref(struct lib9p_srv_authinfo *authinfo) {
- assert(authinfo);
- assert(authinfo->refcount);
- authinfo->refcount--;
- if (!authinfo->refcount) {
- free(authinfo);
- return NULL;
- }
- return authinfo;
+static struct lib9p_srv_userid *srv_userid_decref(struct lib9p_srv_userid *userid) {
+ assert(userid);
+ assert(userid->refcount);
+ userid->refcount--;
+ if (!userid->refcount)
+ free(userid);
+ return NULL;
}
-struct lib9p_srv_authinfo *srv_authinfo_incref(struct lib9p_srv_authinfo *authinfo) {
- assert(authinfo);
- authinfo->refcount++;
- return authinfo;
+static struct lib9p_srv_userid *srv_userid_incref(struct lib9p_srv_userid *userid) {
+ assert(userid);
+ userid->refcount++;
+ return userid;
}
/**
@@ -262,32 +272,21 @@ static inline void srv_path_decref(struct srv_req *ctx, srv_path_t path) {
}
}
-static inline void srv_fid_del(struct srv_req *ctx, lib9p_fid_t fid, bool remove) {
- struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, fid);
+static inline void srv_fid_del(struct srv_req *ctx, lib9p_fid_t fid, struct srv_fidinfo *fidinfo, bool remove) {
+ assert(ctx);
+ assert(!ctx->user);
assert(fidinfo);
+
if (fidinfo->flags & FIDFLAG_RCLOSE)
remove = true;
+ ctx->user = srv_userid_incref(fidinfo->user);
+
struct srv_pathinfo *pathinfo = map_load(&ctx->parent_sess->paths, fidinfo->path);
assert(pathinfo);
- if (remove) {
- if (pathinfo->parent_dir == fidinfo->path) {
- lib9p_errorf(&ctx->basectx,
- LIB9P_ERRNO_L_EBUSY, "cannot remove root");
- goto clunk;
- }
- struct srv_pathinfo *parent = map_load(&ctx->parent_sess->paths, pathinfo->parent_dir);
- assert(parent);
- struct lib9p_stat parent_stat = LO_CALL(parent->file, stat, ctx);
- if (!srv_check_perm(ctx, &parent_stat, 0b010)) {
- lib9p_error(&ctx->basectx,
- LIB9P_ERRNO_L_EACCES, "you do not have write permission on the parent directory");
- goto clunk;
- }
+ if (remove)
LO_CALL(pathinfo->file, remove, ctx);
- }
- clunk:
if (fidinfo->flags & FIDFLAG_OPEN) {
switch (fidinfo->type) {
case SRV_FILETYPE_DIR:
@@ -302,9 +301,11 @@ static inline void srv_fid_del(struct srv_req *ctx, lib9p_fid_t fid, bool remove
}
pathinfo->io_refcount--;
}
- fidinfo->authinfo = srv_authinfo_decref(fidinfo->authinfo);
+ fidinfo->user = srv_userid_decref(fidinfo->user);
srv_path_decref(ctx, fidinfo->path);
map_del(&ctx->parent_sess->fids, fid);
+
+ ctx->user = srv_userid_decref(ctx->user);
}
/**
@@ -329,7 +330,7 @@ static inline struct srv_fidinfo *srv_fid_store(struct srv_req *ctx, lib9p_fid_t
assert(old_fidinfo->type == SRV_FILETYPE_DIR);
assert(old_fidinfo->flags == 0);
- old_fidinfo->authinfo = srv_authinfo_decref(old_fidinfo->authinfo);
+ old_fidinfo->user = srv_userid_decref(old_fidinfo->user);
srv_path_decref(ctx, old_fidinfo->path);
map_del(&ctx->parent_sess->fids, fid);
} else {
@@ -339,9 +340,9 @@ static inline struct srv_fidinfo *srv_fid_store(struct srv_req *ctx, lib9p_fid_t
}
}
struct srv_fidinfo *fidinfo = map_store(&ctx->parent_sess->fids, fid, (struct srv_fidinfo){
- .path = qid.path,
- .type = srv_qid_filetype(qid),
- .authinfo = srv_authinfo_incref(ctx->authinfo),
+ .path = qid.path,
+ .type = srv_qid_filetype(qid),
+ .user = srv_userid_incref(ctx->user),
});
assert(fidinfo);
return fidinfo;
@@ -375,7 +376,7 @@ static ssize_t srv_write_Rmsg(struct srv_req *req, struct lib9p_Rmsg_send_buf *r
#define srv_nonrespond_errorf errorf
static void srv_respond_error(struct srv_req *req) {
-#if CONFIG_9P_ENABLE_9P2000_u
+#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L
assert(req->basectx.err_num);
#endif
assert(req->basectx.err_msg[0]);
@@ -533,17 +534,19 @@ void lib9p_srv_read(struct lib9p_srv *srv, lo_interface net_stream_conn _conn) {
assert(map_len(&sess.reqs) == 0);
map_free(&sess.reqs);
+ struct srv_req pseudoreq = {
+ .basectx = {
+ .version = sess.version,
+ .max_msg_size = sess.max_msg_size,
+ },
+ .parent_sess = &sess,
+ };
MAP_FOREACH(&sess.fids, fid, fidinfo) {
- struct srv_req req = {
- .basectx = {
- .version = sess.version,
- .max_msg_size = sess.max_msg_size,
- },
- .parent_sess = &sess,
- };
- srv_fid_del(&req, fid, false);
- if (lib9p_ctx_has_error(&req.basectx))
- errorf("clunk: %.*s", CONFIG_9P_MAX_ERR_SIZE, req.basectx.err_msg);
+ srv_fid_del(&pseudoreq, fid, fidinfo, false);
+ if (lib9p_ctx_has_error(&pseudoreq.basectx)) {
+ srv_nonrespond_errorf("clunk: %.*s", CONFIG_9P_MAX_ERR_SIZE, pseudoreq.basectx.err_msg);
+ lib9p_ctx_clear_error(&pseudoreq.basectx);
+ }
}
map_free(&sess.fids);
@@ -587,9 +590,9 @@ void lib9p_srv_worker_loop(struct lib9p_srv *srv) {
#define _HANDLER_PROTO(typ) \
static void handle_T##typ(struct srv_req *, \
- struct lib9p_msg_T##typ *, \
- struct lib9p_msg_R##typ *)
+ struct lib9p_msg_T##typ *)
_HANDLER_PROTO(version);
+#if _LIB9P_ENABLE_stat
_HANDLER_PROTO(auth);
_HANDLER_PROTO(attach);
_HANDLER_PROTO(flush);
@@ -602,6 +605,7 @@ _HANDLER_PROTO(clunk);
_HANDLER_PROTO(remove);
_HANDLER_PROTO(stat);
_HANDLER_PROTO(wstat);
+#endif
#if CONFIG_9P_ENABLE_9P2000_p9p
_HANDLER_PROTO(openfd);
#endif
@@ -611,16 +615,17 @@ _HANDLER_PROTO(sread);
_HANDLER_PROTO(swrite);
#endif
-typedef void (*tmessage_handler)(struct srv_req *, void *, void *);
+typedef void (*tmessage_handler)(struct srv_req *, void *);
void lib9p_srv_worker(struct srv_req *ctx) {
uint8_t *host_req = NULL;
- uint8_t host_resp[CONFIG_9P_SRV_MAX_HOSTMSG_SIZE];
/* Unmarshal it. *****************************************************/
ssize_t host_size = lib9p_Tmsg_validate(&ctx->basectx, ctx->net_bytes);
- if (host_size < 0)
- goto write;
+ if (host_size < 0) {
+ srv_respond_error(ctx);
+ goto release;
+ }
host_req = calloc(1, host_size);
assert(host_req);
enum lib9p_msg_type typ;
@@ -634,6 +639,7 @@ void lib9p_srv_worker(struct srv_req *ctx) {
#pragma GCC diagnostic ignored "-Wswitch-enum"
switch (typ) {
case LIB9P_TYP_Tversion: handler = (tmessage_handler)handle_Tversion; break;
+#if _LIB9P_ENABLE_stat
case LIB9P_TYP_Tauth: handler = (tmessage_handler)handle_Tauth; break;
case LIB9P_TYP_Tattach: handler = (tmessage_handler)handle_Tattach; break;
case LIB9P_TYP_Tflush: handler = (tmessage_handler)handle_Tflush; break;
@@ -646,8 +652,9 @@ void lib9p_srv_worker(struct srv_req *ctx) {
case LIB9P_TYP_Tremove: handler = (tmessage_handler)handle_Tremove; break;
case LIB9P_TYP_Tstat: handler = (tmessage_handler)handle_Tstat; break;
case LIB9P_TYP_Twstat: handler = (tmessage_handler)handle_Twstat; break;
+#endif
#if CONFIG_9P_ENABLE_9P2000_p9p
- case LIB9P_TYP_Topenfd: handler = (tmessage_handler)handle_Topenfd; break
+ case LIB9P_TYP_Topenfd: handler = (tmessage_handler)handle_Topenfd; break;
#endif
#if CONFIG_9P_ENABLE_9P2000_e
case LIB9P_TYP_Tsession: handler = (tmessage_handler)handle_Tsession; break;
@@ -658,24 +665,11 @@ void lib9p_srv_worker(struct srv_req *ctx) {
assert_notreached("lib9p_Tmsg_validate() should have rejected unknown typ");
}
#pragma GCC diagnostic pop
- handler(ctx, (void *)host_req, (void *)host_resp);
+ handler(ctx, (void *)host_req);
+ assert(ctx->responded);
- /* Write the response. ***********************************************/
- write:
- if (lib9p_ctx_has_error(&ctx->basectx)) {
- srv_respond_error(ctx);
- } else if (ctx->flush_acknowledged) {
- /* do nothing */
- } else {
- struct lib9p_Rmsg_send_buf net_resp;
- if (lib9p_Rmsg_marshal(&ctx->basectx,
- typ+1, host_resp,
- &net_resp))
- goto write;
- srv_msglog(ctx, typ+1, &host_resp);
- srv_write_Rmsg(ctx, &net_resp);
- }
/* Release resources. ************************************************/
+ release:
map_del(&ctx->parent_sess->reqs, ctx->tag);
size_t nwaiters;
while ((nwaiters = cr_chan_num_waiters(&ctx->flush_ch))) {
@@ -690,19 +684,41 @@ void lib9p_srv_worker(struct srv_req *ctx) {
free(ctx->net_bytes);
}
+static inline void _srv_respond(struct srv_req *ctx, enum lib9p_msg_type resp_typ, void *host_resp) {
+ assert(!ctx->responded);
+ if (lib9p_ctx_has_error(&ctx->basectx)) {
+ error:
+ srv_respond_error(ctx);
+ } else if (ctx->flush_acknowledged) {
+ /* do nothing */
+ } else {
+ assert(host_resp);
+ struct lib9p_Rmsg_send_buf net_resp;
+ if (lib9p_Rmsg_marshal(&ctx->basectx,
+ resp_typ, host_resp,
+ &net_resp))
+ goto error;
+ srv_msglog(ctx, resp_typ, host_resp);
+ srv_write_Rmsg(ctx, &net_resp);
+ }
+ ctx->responded = true;
+}
+#define srv_respond(CTX, TYP, HOST_RESP) do { \
+ struct lib9p_msg_R##TYP *_host_resp = HOST_RESP; \
+ _srv_respond(CTX, LIB9P_TYP_R##TYP, _host_resp); \
+} while (0)
+
/* handle_T* ******************************************************************/
-#define srv_handler_common(ctx, req, resp) do { \
- assert(ctx); \
- assert(req); \
- assert(resp); \
- resp->tag = req->tag; \
- } while (0)
+#define srv_handler_common(ctx, typ, req) \
+ assert(ctx); \
+ assert(req); \
+ struct lib9p_msg_T##typ *_typecheck_req [[gnu::unused]] = req; \
+ struct lib9p_msg_R##typ resp = { .tag = ctx->tag }
static void handle_Tversion(struct srv_req *ctx,
- struct lib9p_msg_Tversion *req,
- struct lib9p_msg_Rversion *resp) {
- srv_handler_common(ctx, req, resp);
+ struct lib9p_msg_Tversion *req) {
+ srv_handler_common(ctx, version, req);
enum lib9p_version version = LIB9P_VER_unknown;
@@ -714,7 +730,9 @@ static void handle_Tversion(struct srv_req *ctx,
'0' <= req->version.utf8[4] && req->version.utf8[4] <= '9' &&
'0' <= req->version.utf8[5] && req->version.utf8[5] <= '9' &&
(req->version.len == 6 || req->version.utf8[6] == '.')) {
+#if CONFIG_9P_ENABLE_9P2000
version = LIB9P_VER_9P2000;
+#endif
#if CONFIG_9P_ENABLE_9P2000_p9p
struct lib9p_srv *srv = ctx->parent_sess->parent_conn->parent_srv;
if (srv->type_assert_unix && !LO_IS_NULL(srv->type_assert_unix(ctx->parent_sess->parent_conn->fd)))
@@ -735,15 +753,15 @@ static void handle_Tversion(struct srv_req *ctx,
lib9p_errorf(&ctx->basectx,
LIB9P_ERRNO_L_EDOM, "requested max_msg_size is less than minimum for %s (%"PRIu32" < %"PRIu32")",
lib9p_version_str(version), req->max_msg_size, min_msg_size);
- return;
+ goto tversion_return;
}
- resp->version = lib9p_str((char *)lib9p_version_str(version)); /* cast to discard "const" qualifier */
+ resp.version = lib9p_str((char *)lib9p_version_str(version)); /* cast to discard "const" qualifier */
#if CONFIG_9P_ENABLE_9P2000_p9p
if (version == LIB9P_VER_9P2000_p9p)
- resp->version = lib9p_str("9P2000");
+ resp.version = lib9p_str("9P2000");
#endif
- resp->max_msg_size = (CONFIG_9P_SRV_MAX_MSG_SIZE < req->max_msg_size)
+ resp.max_msg_size = (CONFIG_9P_SRV_MAX_MSG_SIZE < req->max_msg_size)
? CONFIG_9P_SRV_MAX_MSG_SIZE
: req->max_msg_size;
@@ -762,33 +780,36 @@ static void handle_Tversion(struct srv_req *ctx,
cr_select_v(i, args);
}
}
- if (map_len(&ctx->parent_sess->fids)) {
- /* Close all FIDs. */
- MAP_FOREACH(&ctx->parent_sess->fids, fid, fidinfo) {
- handle_Tclunk(ctx,
- &(struct lib9p_msg_Tclunk){.fid = fid},
- &(struct lib9p_msg_Rclunk){});
+ /* Close all FIDs. */
+ MAP_FOREACH(&ctx->parent_sess->fids, fid, fidinfo) {
+ srv_fid_del(ctx, fid, fidinfo, false);
+ if (lib9p_ctx_has_error(&ctx->basectx)) {
+ srv_nonrespond_errorf("clunk: %.*s", CONFIG_9P_MAX_ERR_SIZE, ctx->basectx.err_msg);
+ lib9p_ctx_clear_error(&ctx->basectx);
}
}
/* Replace the old session with the new session. */
ctx->parent_sess->version = version;
- ctx->parent_sess->max_msg_size = resp->max_msg_size;
+ ctx->parent_sess->max_msg_size = resp.max_msg_size;
+
+ tversion_return:
+ srv_respond(ctx, version, &resp);
}
+#if _LIB9P_ENABLE_stat
static void handle_Tauth(struct srv_req *ctx,
- struct lib9p_msg_Tauth *req,
- struct lib9p_msg_Rauth *resp) {
- srv_handler_common(ctx, req, resp);
+ struct lib9p_msg_Tauth *req) {
+ srv_handler_common(ctx, auth, req);
struct lib9p_srv *srv = ctx->parent_sess->parent_conn->parent_srv;
if (!srv->auth) {
lib9p_error(&ctx->basectx,
LIB9P_ERRNO_L_EOPNOTSUPP, "authentication not required");
- return;
+ goto tauth_return;
}
- ctx->authinfo = srv_authinfo_new(req->uname, req->n_uid);
+ ctx->user = srv_userid_new(req->uname, req->unum);
srv->auth(ctx, req->aname);
@@ -796,18 +817,20 @@ static void handle_Tauth(struct srv_req *ctx,
LIB9P_ERRNO_L_EOPNOTSUPP, "TODO: auth not implemented");
if (lib9p_ctx_has_error(&ctx->basectx))
- ctx->authinfo = srv_authinfo_decref(ctx->authinfo);
+ ctx->user = srv_userid_decref(ctx->user);
+
+ tauth_return:
+ srv_respond(ctx, auth, &resp);
}
static void handle_Tattach(struct srv_req *ctx,
- struct lib9p_msg_Tattach *req,
- struct lib9p_msg_Rattach *resp) {
- srv_handler_common(ctx, req, resp);
+ struct lib9p_msg_Tattach *req) {
+ srv_handler_common(ctx, attach, req);
if (req->fid == LIB9P_FID_NOFID) {
lib9p_error(&ctx->basectx,
LIB9P_ERRNO_L_EBADF, "cannot assign to NOFID");
- return;
+ goto tattach_return;
}
struct lib9p_srv *srv = ctx->parent_sess->parent_conn->parent_srv;
@@ -819,16 +842,16 @@ static void handle_Tattach(struct srv_req *ctx,
else if (afid->type != SRV_FILETYPE_AUTH)
lib9p_error(&ctx->basectx,
LIB9P_ERRNO_L_EACCES, "FID provided as auth-file is not an auth-file");
- else if (!lib9p_str_eq(afid->authinfo->uname, req->uname))
+ else if (!lib9p_str_eq(afid->user->name, req->uname))
lib9p_errorf(&ctx->basectx,
LIB9P_ERRNO_L_EACCES, "FID provided as auth-file is for user=\"%.*s\" and cannot be used for user=\"%.*s\"",
- afid->authinfo->uname.len, afid->authinfo->uname.utf8,
+ afid->user->name.len, afid->user->name.utf8,
req->uname.len, req->uname.utf8);
-#if CONFIG_9P_ENABLE_9P2000_u
- else if (afid->authinfo->uid != req->n_uid)
+#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L
+ else if (afid->user->num != req->unum)
lib9p_errorf(&ctx->basectx,
LIB9P_ERRNO_L_EACCES, "FID provided as auth-file is for user=%"PRIu32" and cannot be used for user=%"PRIu32,
- afid->authinfo->uid, req->n_uid);
+ afid->user->num, req->unum);
#endif
else if (!lib9p_str_eq(afid->auth.aname, req->aname))
lib9p_errorf(&ctx->basectx,
@@ -839,24 +862,22 @@ static void handle_Tattach(struct srv_req *ctx,
lib9p_error(&ctx->basectx,
LIB9P_ERRNO_L_EACCES, "FID provided as auth-file has not completed authentication");
if (lib9p_ctx_has_error(&ctx->basectx))
- return;
- ctx->authinfo = srv_authinfo_incref(afid->authinfo);
+ goto tattach_return;
+ ctx->user = srv_userid_incref(afid->user);
} else {
if (req->afid != LIB9P_FID_NOFID) {
lib9p_error(&ctx->basectx,
LIB9P_ERRNO_L_EACCES, "FID provided as auth-file, but no auth-file is required");
- return;
+ goto tattach_return;
}
- ctx->authinfo = srv_authinfo_new(req->uname, req->n_uid);
+ ctx->user = srv_userid_new(req->uname, req->unum);
}
/* 1. File object */
lo_interface lib9p_srv_file root_file = srv->rootdir(ctx, req->aname);
assert(LO_IS_NULL(root_file) == lib9p_ctx_has_error(&ctx->basectx));
- if (lib9p_ctx_has_error(&ctx->basectx)) {
- ctx->authinfo = srv_authinfo_decref(ctx->authinfo);
- return;
- }
+ if (lib9p_ctx_has_error(&ctx->basectx))
+ goto tattach_return;
struct lib9p_qid root_qid = LO_CALL(root_file, qid);
assert(srv_qid_filetype(root_qid) == SRV_FILETYPE_DIR);
@@ -867,19 +888,19 @@ static void handle_Tattach(struct srv_req *ctx,
/* 3. fidinfo */
if (!srv_fid_store(ctx, req->fid, root_pathinfo, false)) {
srv_path_decref(ctx, root_qid.path);
- ctx->authinfo = srv_authinfo_decref(ctx->authinfo);
- return;
+ goto tattach_return;
}
- ctx->authinfo = srv_authinfo_decref(ctx->authinfo);
- resp->qid = root_qid;
- return;
+ resp.qid = root_qid;
+ tattach_return:
+ if (ctx->user)
+ ctx->user = srv_userid_decref(ctx->user);
+ srv_respond(ctx, attach, &resp);
}
static void handle_Tflush(struct srv_req *ctx,
- struct lib9p_msg_Tflush *req,
- struct lib9p_msg_Rflush *resp) {
- srv_handler_common(ctx, req, resp);
+ struct lib9p_msg_Tflush *req) {
+ srv_handler_common(ctx, flush, req);
struct srv_req **oldreqp = map_load(&ctx->parent_sess->reqs, req->oldtag);
if (oldreqp) {
@@ -897,38 +918,39 @@ static void handle_Tflush(struct srv_req *ctx,
break;
}
}
+ srv_respond(ctx, flush, &resp);
}
static void handle_Twalk(struct srv_req *ctx,
- struct lib9p_msg_Twalk *req,
- struct lib9p_msg_Rwalk *resp) {
- srv_handler_common(ctx, req, resp);
+ struct lib9p_msg_Twalk *req) {
+ srv_handler_common(ctx, walk, req);
if (req->newfid == LIB9P_FID_NOFID) {
lib9p_error(&ctx->basectx,
LIB9P_ERRNO_L_EBADF, "cannot assign to NOFID");
- return;
+ goto twalk_return;
}
struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid);
if (!fidinfo) {
lib9p_errorf(&ctx->basectx,
LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid);
- return;
+ goto twalk_return;
}
if (fidinfo->flags & FIDFLAG_OPEN) {
lib9p_error(&ctx->basectx,
LIB9P_ERRNO_L_EALREADY, "cannot walk on FID open for I/O");
- return;
+ goto twalk_return;
}
- ctx->authinfo = srv_authinfo_incref(fidinfo->authinfo);
+ ctx->user = srv_userid_incref(fidinfo->user);
struct srv_pathinfo *pathinfo = map_load(&ctx->parent_sess->paths, fidinfo->path);
assert(pathinfo);
pathinfo->gc_refcount++;
- resp->wqid = (struct lib9p_qid *)(&resp[1]);
- for (resp->nwqid = 0; resp->nwqid < req->nwname; resp->nwqid++) {
+ struct lib9p_qid _resp_qid[16];
+ resp.wqid = _resp_qid;
+ for (resp.nwqid = 0; resp.nwqid < req->nwname; resp.nwqid++) {
if (pathinfo->type != SRV_FILETYPE_DIR) {
lib9p_error(&ctx->basectx,
LIB9P_ERRNO_L_ENOTDIR, "not a directory");
@@ -936,12 +958,12 @@ static void handle_Twalk(struct srv_req *ctx,
}
struct srv_pathinfo *new_pathinfo;
- if (lib9p_str_eq(req->wname[resp->nwqid], lib9p_str(".."))) {
+ if (lib9p_str_eq(req->wname[resp.nwqid], lib9p_str(".."))) {
new_pathinfo = map_load(&ctx->parent_sess->paths, pathinfo->parent_dir);
assert(new_pathinfo);
new_pathinfo->gc_refcount++;
} else {
- lo_interface lib9p_srv_file member_file = LO_CALL(pathinfo->file, dwalk, ctx, req->wname[resp->nwqid]);
+ lo_interface lib9p_srv_file member_file = LO_CALL(pathinfo->file, dwalk, ctx, req->wname[resp.nwqid]);
assert(LO_IS_NULL(member_file) == lib9p_ctx_has_error(&ctx->basectx));
if (lib9p_ctx_has_error(&ctx->basectx))
break;
@@ -950,10 +972,10 @@ static void handle_Twalk(struct srv_req *ctx,
}
if (new_pathinfo->type == SRV_FILETYPE_DIR) {
- struct lib9p_stat stat = LO_CALL(new_pathinfo->file, stat, ctx);
+ struct lib9p_srv_stat stat = LO_CALL(new_pathinfo->file, stat, ctx);
if (lib9p_ctx_has_error(&ctx->basectx))
break;
- lib9p_stat_assert(stat);
+ lib9p_srv_stat_assert(stat);
if (!srv_check_perm(ctx, &stat, 0b001)) {
lib9p_error(&ctx->basectx,
LIB9P_ERRNO_L_EACCES, "you do not have execute permission on that directory");
@@ -962,39 +984,41 @@ static void handle_Twalk(struct srv_req *ctx,
}
}
- resp->wqid[resp->nwqid] = LO_CALL(new_pathinfo->file, qid);
+ resp.wqid[resp.nwqid] = LO_CALL(new_pathinfo->file, qid);
srv_path_decref(ctx, LO_CALL(pathinfo->file, qid).path);
pathinfo = new_pathinfo;
}
- if (resp->nwqid == req->nwname) {
+ if (resp.nwqid == req->nwname) {
if (!srv_fid_store(ctx, req->newfid, pathinfo, req->newfid == req->fid))
srv_path_decref(ctx, LO_CALL(pathinfo->file, qid).path);
} else {
assert(lib9p_ctx_has_error(&ctx->basectx));
srv_path_decref(ctx, LO_CALL(pathinfo->file, qid).path);
- if (resp->nwqid > 0)
+ if (resp.nwqid > 0)
lib9p_ctx_clear_error(&ctx->basectx);
}
- ctx->authinfo = srv_authinfo_decref(ctx->authinfo);
+ twalk_return:
+ if (ctx->user)
+ ctx->user = srv_userid_decref(ctx->user);
+ srv_respond(ctx, walk, &resp);
}
static void handle_Topen(struct srv_req *ctx,
- struct lib9p_msg_Topen *req,
- struct lib9p_msg_Ropen *resp) {
- srv_handler_common(ctx, req, resp);
+ struct lib9p_msg_Topen *req) {
+ srv_handler_common(ctx, open, req);
/* Check that the FID is valid for this. */
struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid);
if (!fidinfo) {
lib9p_errorf(&ctx->basectx,
LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid);
- return;
+ goto topen_return;
}
if (fidinfo->flags & FIDFLAG_OPEN) {
lib9p_error(&ctx->basectx,
LIB9P_ERRNO_L_EALREADY, "FID is already open");
- return;
+ goto topen_return;
}
if (fidinfo->type == SRV_FILETYPE_DIR) {
if ( ((req->mode & LIB9P_O_MODE_MASK) != LIB9P_O_MODE_READ) ||
@@ -1002,10 +1026,10 @@ static void handle_Topen(struct srv_req *ctx,
(req->mode & LIB9P_O_RCLOSE) ) {
lib9p_error(&ctx->basectx,
LIB9P_ERRNO_L_EISDIR, "directories cannot be written, executed, truncated, or removed-on-close");
- return;
+ goto topen_return;
}
}
- ctx->authinfo = srv_authinfo_incref(fidinfo->authinfo);
+ ctx->user = srv_userid_incref(fidinfo->user);
/* Variables. */
lib9p_o_t reqmode = req->mode;
@@ -1017,10 +1041,10 @@ static void handle_Topen(struct srv_req *ctx,
if (reqmode & LIB9P_O_RCLOSE) {
struct srv_pathinfo *parent = map_load(&ctx->parent_sess->paths, pathinfo->parent_dir);
assert(parent);
- struct lib9p_stat parent_stat = LO_CALL(parent->file, stat, ctx);
+ struct lib9p_srv_stat parent_stat = LO_CALL(parent->file, stat, ctx);
if (lib9p_ctx_has_error(&ctx->basectx))
goto topen_return;
- lib9p_stat_assert(parent_stat);
+ lib9p_srv_stat_assert(parent_stat);
if (!srv_check_perm(ctx, &parent_stat, 0b010)) {
lib9p_error(&ctx->basectx,
LIB9P_ERRNO_L_EACCES, "permission denied to remove-on-close");
@@ -1028,17 +1052,19 @@ static void handle_Topen(struct srv_req *ctx,
}
fidflags |= FIDFLAG_RCLOSE;
}
- struct lib9p_stat stat = LO_CALL(pathinfo->file, stat, ctx);
+ struct lib9p_srv_stat stat = LO_CALL(pathinfo->file, stat, ctx);
if (lib9p_ctx_has_error(&ctx->basectx))
goto topen_return;
- lib9p_stat_assert(stat);
- if ((stat.file_mode & LIB9P_DM_EXCL) && pathinfo->io_refcount) {
+ lib9p_srv_stat_assert(stat);
+ if ((stat.mode & LIB9P_DM_EXCL) && pathinfo->io_refcount) {
lib9p_error(&ctx->basectx,
LIB9P_ERRNO_L_EEXIST, "exclusive file is already opened");
goto topen_return;
}
- if (stat.file_mode & LIB9P_DM_APPEND)
+ if (stat.mode & LIB9P_DM_APPEND) {
+ fidflags |= FIDFLAG_APPEND;
reqmode = reqmode & ~LIB9P_O_TRUNC;
+ }
uint8_t perm_bits = 0;
bool rd = false, wr = false;
switch (reqmode & LIB9P_O_MODE_MASK) {
@@ -1104,25 +1130,48 @@ static void handle_Topen(struct srv_req *ctx,
fidflags |= FIDFLAG_OPEN_W;
pathinfo->io_refcount++;
fidinfo->flags = fidflags;
- resp->qid = qid;
- resp->iounit = iounit;
+ resp.qid = qid;
+ resp.iounit = iounit;
topen_return:
- ctx->authinfo = srv_authinfo_decref(ctx->authinfo);
+ if (ctx->user)
+ ctx->user = srv_userid_decref(ctx->user);
+ srv_respond(ctx, open, &resp);
}
static void handle_Tcreate(struct srv_req *ctx,
- struct lib9p_msg_Tcreate *req,
- struct lib9p_msg_Rcreate *resp) {
- srv_handler_common(ctx, req, resp);
+ struct lib9p_msg_Tcreate *req) {
+ srv_handler_common(ctx, create, req);
lib9p_error(&ctx->basectx,
LIB9P_ERRNO_L_EOPNOTSUPP, "create not (yet?) implemented");
+
+ srv_respond(ctx, create, &resp);
+}
+
+static inline struct lib9p_stat srv_stat_to_net_stat(struct lib9p_srv_stat in) {
+ return (struct lib9p_stat){
+ .qid = in.qid,
+ .mode = in.mode,
+ .atime = in.atime_sec,
+ .mtime = in.mtime_sec,
+ .length = in.size,
+ .name = in.name,
+ .owner_uname = in.owner_uid.name,
+ .owner_gname = in.owner_gid.name,
+ .last_modifier_uname = in.last_modifier_uid.name,
+#if CONFIG_9P_ENABLE_9P2000_u
+ .owner_unum = in.owner_uid.num,
+ .owner_gnum = in.owner_gid.num,
+ .last_modifier_unum = in.last_modifier_uid.num,
+ .extension = in.extension,
+#endif
+ };
}
static void handle_Tread(struct srv_req *ctx,
- struct lib9p_msg_Tread *req,
- struct lib9p_msg_Rread *resp) {
- srv_handler_common(ctx, req, resp);
+ struct lib9p_msg_Tread *req) {
+ srv_handler_common(ctx, read, req);
+ char *heap = NULL;
/* TODO: serialize simultaneous reads to the same FID */
@@ -1131,67 +1180,120 @@ static void handle_Tread(struct srv_req *ctx,
if (!fidinfo) {
lib9p_errorf(&ctx->basectx,
LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid);
- return;
+ goto tread_return;
}
if (!(fidinfo->flags & FIDFLAG_OPEN_R)) {
lib9p_error(&ctx->basectx,
LIB9P_ERRNO_L_EINVAL, "FID not open for reading");
- return;
+ goto tread_return;
}
/* Do it. */
- ctx->authinfo = srv_authinfo_incref(fidinfo->authinfo);
+ ctx->user = srv_userid_incref(fidinfo->user);
switch (fidinfo->type) {
case SRV_FILETYPE_DIR:
- /* Translate byte-offset to object-index. */
- size_t idx;
- if (req->offset == 0)
- idx = 0;
- else if (req->offset == fidinfo->dir.off)
- idx = fidinfo->dir.idx;
- else {
+#if _LIB9P_ENABLE_stat
+ /* Seek. */
+ if (req->offset == 0) {
+ fidinfo->dir.idx = 0;
+ fidinfo->dir.off = 0;
+ fidinfo->dir.buffered_dirent = (struct lib9p_srv_dirent){};
+ } else if (req->offset != fidinfo->dir.off) {
lib9p_errorf(&ctx->basectx,
LIB9P_ERRNO_L_EINVAL, "invalid offset (must be 0 or %"PRIu64"): %"PRIu64,
fidinfo->dir.off, req->offset);
- ctx->authinfo = srv_authinfo_decref(ctx->authinfo);
- return;
+ goto tread_return;
}
- /* Do it. */
- resp->data = (char *)(&resp[1]);
- size_t num = LO_CALL(fidinfo->dir.io, dread, ctx, (uint8_t *)resp->data, req->count, idx);
- /* Translate object-count back to byte-count. */
- uint32_t len = 0;
- for (size_t i = 0; i < num; i++) {
- uint32_t i_len;
- lib9p_stat_validate(&ctx->basectx, req->count, &((uint8_t *)resp->data)[len], &i_len, NULL);
- len += i_len;
+ /* Read. */
+ resp.data = heap = malloc(req->count); /* TODO: cap req->count */
+ resp.count = 0;
+ struct srv_pathinfo *dir_pathinfo = NULL;
+ for (;;) {
+ lo_interface lib9p_srv_file member_file = {};
+ struct lib9p_srv_dirent member_dirent;
+ if (fidinfo->dir.buffered_dirent.name.len) {
+ member_dirent = fidinfo->dir.buffered_dirent;
+ } else {
+ member_dirent = LO_CALL(fidinfo->dir.io, dread, ctx, fidinfo->dir.idx);
+ if (lib9p_ctx_has_error(&ctx->basectx)) {
+ if (!resp.count)
+ goto tread_return;
+ lib9p_ctx_clear_error(&ctx->basectx);
+ break;
+ }
+ }
+ if (!member_dirent.name.len)
+ break;
+ struct lib9p_srv_stat member_stat;
+ struct srv_pathinfo *member_pathinfo = map_load(&ctx->parent_sess->paths, member_dirent.qid.path);
+ if (member_pathinfo) {
+ member_stat = LO_CALL(member_pathinfo->file, stat, ctx);
+ } else {
+ if (!dir_pathinfo)
+ dir_pathinfo = map_load(&ctx->parent_sess->paths, fidinfo->path);
+ assert(dir_pathinfo);
+ member_file = LO_CALL(dir_pathinfo->file, dwalk, ctx, member_dirent.name);
+ assert(LO_IS_NULL(member_file) == lib9p_ctx_has_error(&ctx->basectx));
+ if (!lib9p_ctx_has_error(&ctx->basectx))
+ member_stat = LO_CALL(member_file, stat, ctx);
+ }
+ if (lib9p_ctx_has_error(&ctx->basectx)) {
+ if (!LO_IS_NULL(member_file))
+ LO_CALL(member_file, free);
+ if (!resp.count)
+ goto tread_return;
+ lib9p_ctx_clear_error(&ctx->basectx);
+ break;
+ }
+ lib9p_srv_stat_assert(member_stat);
+ struct lib9p_stat member_netstat = srv_stat_to_net_stat(member_stat);
+ uint32_t nbytes = lib9p_stat_marshal(&ctx->basectx, req->count-resp.count, &member_netstat,
+ (uint8_t *)&resp.data[resp.count]);
+ if (!LO_IS_NULL(member_file))
+ LO_CALL(member_file, free);
+ if (!nbytes) {
+ if (!resp.count) {
+ lib9p_error(&ctx->basectx,
+ LIB9P_ERRNO_L_ERANGE, "stat object does not fit into negotiated max message size");
+ goto tread_return;
+ }
+ fidinfo->dir.buffered_dirent = member_dirent;
+ break;
+ }
+ resp.count += nbytes;
+ fidinfo->dir.idx++;
+ fidinfo->dir.off += nbytes;
+ fidinfo->dir.buffered_dirent = (struct lib9p_srv_dirent){};
}
- resp->count = len;
- /* Remember. */
- fidinfo->dir.idx = idx+num;
- fidinfo->dir.off = req->offset + len;
+#else
+ assert_notreached("Tread for directory on protocol version without that");
+#endif
break;
case SRV_FILETYPE_FILE:
struct iovec iov;
LO_CALL(fidinfo->file.io, pread, ctx, req->count, req->offset, &iov);
if (!lib9p_ctx_has_error(&ctx->basectx) && !ctx->flush_acknowledged) {
- resp->count = iov.iov_len;
- resp->data = iov.iov_base;
- if (resp->count > req->count)
- resp->count = req->count;
+ resp.count = iov.iov_len;
+ resp.data = iov.iov_base;
+ if (resp.count > req->count)
+ resp.count = req->count;
}
break;
case SRV_FILETYPE_AUTH:
assert_notreached("TODO: auth not yet implemented");
break;
}
- ctx->authinfo = srv_authinfo_decref(ctx->authinfo);
+ tread_return:
+ if (ctx->user)
+ ctx->user = srv_userid_decref(ctx->user);
+ srv_respond(ctx, read, &resp);
+ if (heap)
+ free(heap);
}
static void handle_Twrite(struct srv_req *ctx,
- struct lib9p_msg_Twrite *req,
- struct lib9p_msg_Rwrite *resp) {
- srv_handler_common(ctx, req, resp);
+ struct lib9p_msg_Twrite *req) {
+ srv_handler_common(ctx, write, req);
/* TODO: serialize simultaneous writes to the same FID */
@@ -1200,120 +1302,154 @@ static void handle_Twrite(struct srv_req *ctx,
if (!fidinfo) {
lib9p_errorf(&ctx->basectx,
LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid);
- return;
+ goto twrite_return;
}
if (!(fidinfo->flags & FIDFLAG_OPEN_W)) {
lib9p_error(&ctx->basectx,
LIB9P_ERRNO_L_EINVAL, "FID not open for writing");
- return;
+ goto twrite_return;
}
+ if (fidinfo->flags & FIDFLAG_APPEND)
+ req->offset = 0;
/* Do it. */
- ctx->authinfo = srv_authinfo_incref(fidinfo->authinfo);
- resp->count = LO_CALL(fidinfo->file.io, pwrite, ctx, req->data, req->count, req->offset);
- ctx->authinfo = srv_authinfo_decref(ctx->authinfo);
+ ctx->user = srv_userid_incref(fidinfo->user);
+ resp.count = LO_CALL(fidinfo->file.io, pwrite, ctx, req->data, req->count, req->offset);
+ twrite_return:
+ if (ctx->user)
+ ctx->user = srv_userid_decref(ctx->user);
+ srv_respond(ctx, write, &resp);
}
static void handle_Tclunk(struct srv_req *ctx,
- struct lib9p_msg_Tclunk *req,
- struct lib9p_msg_Rclunk *resp) {
- srv_handler_common(ctx, req, resp);
+ struct lib9p_msg_Tclunk *req) {
+ srv_handler_common(ctx, clunk, req);
struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid);
if (!fidinfo) {
lib9p_errorf(&ctx->basectx,
LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid);
- return;
+ goto tclunk_return;
}
- ctx->authinfo = srv_authinfo_incref(fidinfo->authinfo);
- srv_fid_del(ctx, req->fid, false);
- ctx->authinfo = srv_authinfo_decref(ctx->authinfo);
+ srv_fid_del(ctx, req->fid, fidinfo, false);
+
+ tclunk_return:
+ srv_respond(ctx, clunk, &resp);
}
static void handle_Tremove(struct srv_req *ctx,
- struct lib9p_msg_Tremove *req,
- struct lib9p_msg_Rremove *resp) {
- srv_handler_common(ctx, req, resp);
+ struct lib9p_msg_Tremove *req) {
+ srv_handler_common(ctx, remove, req);
struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid);
if (!fidinfo) {
lib9p_errorf(&ctx->basectx,
LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid);
- return;
+ goto tremove_return;
}
- ctx->authinfo = srv_authinfo_incref(fidinfo->authinfo);
- srv_fid_del(ctx, req->fid, true);
- ctx->authinfo = srv_authinfo_decref(ctx->authinfo);
+ bool remove = true;
+ struct srv_pathinfo *pathinfo = map_load(&ctx->parent_sess->paths, fidinfo->path);
+ assert(pathinfo);
+ if (pathinfo->parent_dir == fidinfo->path) {
+ lib9p_error(&ctx->basectx,
+ LIB9P_ERRNO_L_EBUSY, "cannot remove root");
+ remove = false;
+ goto tremove_main;
+ }
+ struct srv_pathinfo *parent = map_load(&ctx->parent_sess->paths, pathinfo->parent_dir);
+ assert(parent);
+ struct lib9p_srv_stat parent_stat = LO_CALL(parent->file, stat, ctx);
+ if (!lib9p_ctx_has_error(&ctx->basectx) && !srv_check_perm(ctx, &parent_stat, 0b010)) {
+ lib9p_error(&ctx->basectx,
+ LIB9P_ERRNO_L_EACCES, "you do not have write permission on the parent directory");
+ remove = false;
+ goto tremove_main;
+ }
+
+ tremove_main:
+ srv_fid_del(ctx, req->fid, fidinfo, remove);
+ tremove_return:
+ srv_respond(ctx, remove, &resp);
}
static void handle_Tstat(struct srv_req *ctx,
- struct lib9p_msg_Tstat *req,
- struct lib9p_msg_Rstat *resp) {
- srv_handler_common(ctx, req, resp);
+ struct lib9p_msg_Tstat *req) {
+ srv_handler_common(ctx, stat, req);
struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid);
if (!fidinfo) {
lib9p_errorf(&ctx->basectx,
LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid);
- return;
+ goto tstat_return;
}
struct srv_pathinfo *pathinfo = map_load(&ctx->parent_sess->paths, fidinfo->path);
assert(pathinfo);
- ctx->authinfo = srv_authinfo_incref(fidinfo->authinfo);
- resp->stat = LO_CALL(pathinfo->file, stat, ctx);
- if (!lib9p_ctx_has_error(&ctx->basectx))
- lib9p_stat_assert(resp->stat);
- ctx->authinfo = srv_authinfo_decref(ctx->authinfo);
+ ctx->user = srv_userid_incref(fidinfo->user);
+ struct lib9p_srv_stat stat = LO_CALL(pathinfo->file, stat, ctx);
+ if (lib9p_ctx_has_error(&ctx->basectx))
+ goto tstat_return;
+ lib9p_srv_stat_assert(stat);
+ resp.stat = srv_stat_to_net_stat(stat);
+ tstat_return:
+ if (ctx->user)
+ ctx->user = srv_userid_decref(ctx->user);
+ srv_respond(ctx, stat, &resp);
}
static void handle_Twstat(struct srv_req *ctx,
- struct lib9p_msg_Twstat *req,
- struct lib9p_msg_Rwstat *resp) {
- srv_handler_common(ctx, req, resp);
+ struct lib9p_msg_Twstat *req) {
+ srv_handler_common(ctx, wstat, req);
lib9p_error(&ctx->basectx,
LIB9P_ERRNO_L_EOPNOTSUPP, "wstat not (yet?) implemented");
+
+ srv_respond(ctx, wstat, &resp);
}
+#endif
#if CONFIG_9P_ENABLE_9P2000_p9p
static void handle_Topenfd(struct srv_req *ctx,
- struct lib9p_msg_Topenfd *req,
- struct lib9p_msg_Ropenfd *resp) {
- srv_handler_common(ctx, req, resp);
+ struct lib9p_msg_Topenfd *req) {
+ srv_handler_common(ctx, openfd, req);
lib9p_error(&ctx->basectx,
LIB9P_ERRNO_L_EOPNOTSUPP, "openfd not (yet?) implemented");
+
+ srv_respond(ctx, openfd, &resp);
}
#endif
#if CONFIG_9P_ENABLE_9P2000_e
static void handle_Tsession(struct srv_req *ctx,
- struct lib9p_msg_Tsession *req,
- struct lib9p_msg_Rsession *resp) {
- srv_handler_common(ctx, req, resp);
+ struct lib9p_msg_Tsession *req) {
+ srv_handler_common(ctx, session, req);
lib9p_error(&ctx->basectx,
LIB9P_ERRNO_L_EOPNOTSUPP, "session not (yet?) implemented");
+
+ srv_respond(ctx, session, &resp);
}
static void handle_Tsread(struct srv_req *ctx,
- struct lib9p_msg_Tsread *req,
- struct lib9p_msg_Rsread *resp) {
- srv_handler_common(ctx, req, resp);
+ struct lib9p_msg_Tsread *req) {
+ srv_handler_common(ctx, sread, req);
lib9p_error(&ctx->basectx,
LIB9P_ERRNO_L_EOPNOTSUPP, "sread not (yet?) implemented");
+
+ srv_respond(ctx, sread, &resp);
}
static void handle_Tswrite(struct srv_req *ctx,
- struct lib9p_msg_Tswrite *req,
- struct lib9p_msg_Rswrite *resp) {
- srv_handler_common(ctx, req, resp);
+ struct lib9p_msg_Tswrite *req) {
+ srv_handler_common(ctx, swrite, req);
lib9p_error(&ctx->basectx,
LIB9P_ERRNO_L_EOPNOTSUPP, "swrite not (yet?) implemented");
+
+ srv_respond(ctx, swrite, &resp);
}
#endif
diff --git a/lib9p/srv_include/lib9p/srv.h b/lib9p/srv_include/lib9p/srv.h
index 9b3256b..c72aff5 100644
--- a/lib9p/srv_include/lib9p/srv.h
+++ b/lib9p/srv_include/lib9p/srv.h
@@ -19,9 +19,11 @@
/* context ********************************************************************/
-struct lib9p_srv_authinfo {
- lib9p_nuid_t uid;
- struct lib9p_s uname;
+struct lib9p_srv_userid {
+ struct lib9p_s name;
+#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L
+ lib9p_nuid_t num;
+#endif
BEGIN_PRIVATE(LIB9P_SRV_H);
unsigned int refcount;
@@ -37,7 +39,7 @@ CR_CHAN_DECLARE(_lib9p_srv_flush_ch, enum _lib9p_srv_flush_result);
struct lib9p_srv_ctx {
struct lib9p_ctx basectx;
- struct lib9p_srv_authinfo *authinfo;
+ struct lib9p_srv_userid *user;
BEGIN_PRIVATE(LIB9P_SRV_H);
struct _lib9p_srv_sess *parent_sess;
@@ -45,6 +47,7 @@ struct lib9p_srv_ctx {
uint8_t *net_bytes;
_lib9p_srv_flush_ch_t flush_ch;
bool flush_acknowledged;
+ bool responded;
END_PRIVATE(LIB9P_SRV_H);
};
@@ -66,14 +69,55 @@ bool lib9p_srv_flush_requested(struct lib9p_srv_ctx *ctx);
*/
void lib9p_srv_acknowledge_flush(struct lib9p_srv_ctx *ctx);
+/* version-independent stat ***************************************************/
+
+struct lib9p_srv_stat {
+ struct lib9p_qid qid;
+ lib9p_dm_t mode;
+ uint32_t atime_sec; /* BUG: u32 seconds means a 2106 problem */
+#if CONFIG_9P_ENABLE_9P2000_L
+ uint32_t atime_nsec;
+#endif
+ uint32_t mtime_sec; /* BUG: u32 seconds means a 2106 problem */
+#if CONFIG_9P_ENABLE_9P2000_L
+ uint32_t mtime_nsec;
+ uint32_t ctime_sec; /* BUG: u32 seconds means a 2106 problem */
+ uint32_t ctime_nsec;
+ uint32_t btime_sec; /* BUG: u32 seconds means a 2106 problem */
+ uint32_t btime_nsec;
+#endif
+ uint64_t size;
+ struct lib9p_s name;
+ struct lib9p_srv_userid owner_uid;
+ struct lib9p_srv_userid owner_gid;
+ struct lib9p_srv_userid last_modifier_uid;
+#if CONFIG_9P_ENABLE_9P2000_u
+ struct lib9p_s extension;
+#endif
+};
+
+static inline void lib9p_srv_stat_assert(struct lib9p_srv_stat stat) {
+ assert( ((bool)(stat.mode & LIB9P_DM_DIR )) == ((bool)(stat.qid.type & LIB9P_QT_DIR )) );
+ assert( ((bool)(stat.mode & LIB9P_DM_APPEND)) == ((bool)(stat.qid.type & LIB9P_QT_APPEND)) );
+ assert( ((bool)(stat.mode & LIB9P_DM_EXCL )) == ((bool)(stat.qid.type & LIB9P_QT_EXCL )) );
+ assert( ((bool)(stat.mode & LIB9P_DM_AUTH )) == ((bool)(stat.qid.type & LIB9P_QT_AUTH )) );
+ assert( ((bool)(stat.mode & LIB9P_DM_TMP )) == ((bool)(stat.qid.type & LIB9P_QT_TMP )) );
+ assert( (stat.size == 0) || !(stat.mode & LIB9P_DM_DIR) );
+}
+
/* interface definitions ******************************************************/
+struct lib9p_srv_dirent {
+ struct lib9p_qid qid;
+ struct lib9p_s name;
+};
+
lo_interface lib9p_srv_fio;
lo_interface lib9p_srv_dio;
-/* FIXME: I don't like that the pointers returned by stat() and
- * pread() have to remain live after they return. Perhaps a
- * `respond()`-callback? But that just reads as gross in C.
+/* FIXME: I don't like that the pointer returned by pread() has to
+ * remain live after it returns. Perhaps a `respond()`-callback? But
+ * that just reads as gross in C.
*
* FIXME: It would be nice if pread() could return more than 1 iovec.
*/
@@ -101,19 +145,21 @@ lo_interface lib9p_srv_dio;
\
/* non-"opened" generic I/O *****************************************/ \
\
- LO_FUNC(struct lib9p_stat , stat , struct lib9p_srv_ctx *) \
+ /** Strings returned from stat() must remain valid until free(). */ \
+ LO_FUNC(struct lib9p_srv_stat , stat , struct lib9p_srv_ctx *) \
LO_FUNC(void , wstat , struct lib9p_srv_ctx *, \
- struct lib9p_stat new) \
+ struct lib9p_srv_stat) \
LO_FUNC(void , remove , struct lib9p_srv_ctx *) \
\
/* non-"opened" directory I/O ***************************************/ \
\
- LO_FUNC(lo_interface lib9p_srv_file, dwalk , struct lib9p_srv_ctx *, \
- struct lib9p_s childname) \
- LO_FUNC(lo_interface lib9p_srv_file, dcreate, struct lib9p_srv_ctx *, \
- struct lib9p_s childname, \
- lib9p_dm_t perm, \
- lib9p_o_t flags) \
+ LO_FUNC(lo_interface lib9p_srv_file, dwalk , struct lib9p_srv_ctx *, \
+ struct lib9p_s childname) \
+ LO_FUNC(lo_interface lib9p_srv_file, dcreate, struct lib9p_srv_ctx *, \
+ struct lib9p_s childname, \
+ struct lib9p_srv_userid *user, \
+ struct lib9p_srv_userid *group, \
+ lib9p_dm_t perm) \
\
/* open() for I/O ***************************************************/ \
\
@@ -131,35 +177,36 @@ LO_INTERFACE(lib9p_srv_file);
uint32_t byte_count, \
uint64_t byte_offset, \
struct iovec *ret) \
+ /** \
+ * If the file was append-only when fopen()ed, then byte_offset will \
+ * always be 0. \
+ */ \
LO_FUNC(uint32_t , pwrite , struct lib9p_srv_ctx *, \
void *buf, \
uint32_t byte_count, \
uint64_t byte_offset)
LO_INTERFACE(lib9p_srv_fio);
-/* FIXME: The dio interface just feels clunky. I'm not in a rush to
- * change it because util9p_static_dir is already implemented and I
- * don't anticipate the sbc-harness needing another dio
- * implementation. But if I wanted lib9p to be used outside of
- * sbc-harness, this is one of the first things that I'd want to
- * change.
- */
#define lib9p_srv_dio_LO_IFACE \
LO_FUNC(struct lib9p_qid , qid ) \
LO_FUNC(void , iofree ) \
- LO_FUNC(size_t /* <- obj cnt */ , dread , struct lib9p_srv_ctx *, \
- uint8_t *buf, \
- /* num bytes -> */ uint32_t byte_count, \
- /* starting at this object -> */ size_t obj_offset)
+ /** \
+ * Return the idx-th dirent. idx will always be either 0 or \
+ * prev_idx+1. A dirrent with an empty name signals EOF. The string
+ * must remain valid until the next dread() call or iofree(). \
+ */ \
+ LO_FUNC(struct lib9p_srv_dirent , dread , struct lib9p_srv_ctx *, \
+ size_t idx)
LO_INTERFACE(lib9p_srv_dio);
-#define LIB9P_SRV_NOTDIR(TYP, NAM) \
- static lo_interface lib9p_srv_file NAM##_dwalk (TYP *, struct lib9p_srv_ctx *, struct lib9p_s) { assert_notreached("not a directory"); } \
- static lo_interface lib9p_srv_file NAM##_dcreate(TYP *, struct lib9p_srv_ctx *, struct lib9p_s, lib9p_dm_t, lib9p_o_t) { assert_notreached("not a directory"); } \
- static lo_interface lib9p_srv_dio NAM##_dopen (TYP *, struct lib9p_srv_ctx *) { assert_notreached("not a directory"); }
+#define LIB9P_SRV_NOTDIR(TYP, NAM) \
+ static lo_interface lib9p_srv_file NAM##_dwalk (TYP *, struct lib9p_srv_ctx *, struct lib9p_s) { assert_notreached("not a directory"); } \
+ static lo_interface lib9p_srv_file NAM##_dcreate(TYP *, struct lib9p_srv_ctx *, struct lib9p_s, \
+ struct lib9p_srv_userid *, struct lib9p_srv_userid *, lib9p_dm_t) { assert_notreached("not a directory"); } \
+ static lo_interface lib9p_srv_dio NAM##_dopen (TYP *, struct lib9p_srv_ctx *) { assert_notreached("not a directory"); }
#define LIB9P_SRV_NOTFILE(TYP, NAM) \
- static lo_interface lib9p_srv_fio NAM##_fopen (TYP *, struct lib9p_srv_ctx *, bool, bool, bool) { assert_notreached("not a file"); }
+ static lo_interface lib9p_srv_fio NAM##_fopen (TYP *, struct lib9p_srv_ctx *, bool, bool, bool) { assert_notreached("not a file"); }
/* main server entrypoints ****************************************************/
diff --git a/lib9p/tests/test_compile.c b/lib9p/tests/test_compile.c
index 4532655..e53b738 100644
--- a/lib9p/tests/test_compile.c
+++ b/lib9p/tests/test_compile.c
@@ -3,428 +3,1253 @@
#include <lib9p/core.h>
int main(void) {
[[gnu::unused]] uint64_t x;
- x = LIB9P_TAG_NOTAG;
- x = LIB9P_FID_NOFID;
- x = LIB9P_DM_DIR;
+#ifdef LIB9P_B4_FALSE
+ x = LIB9P_B4_FALSE;
+#endif
+#ifdef LIB9P_B4_TRUE
+ x = LIB9P_B4_TRUE;
+#endif
+#ifdef LIB9P_DM_APPEND
x = LIB9P_DM_APPEND;
- x = LIB9P_DM_EXCL;
- x = _LIB9P_DM_PLAN9_MOUNT;
+#endif
+#ifdef LIB9P_DM_AUTH
x = LIB9P_DM_AUTH;
- x = LIB9P_DM_TMP;
- x = _LIB9P_DM_UNUSED_25;
- x = _LIB9P_DM_UNUSED_24;
+#endif
+#ifdef LIB9P_DM_DEVICE
x = LIB9P_DM_DEVICE;
- x = _LIB9P_DM_UNUSED_22;
- x = LIB9P_DM_PIPE;
- x = LIB9P_DM_SOCKET;
- x = LIB9P_DM_SETUID;
- x = LIB9P_DM_SETGID;
- x = _LIB9P_DM_UNUSED_17;
- x = _LIB9P_DM_UNUSED_16;
- x = _LIB9P_DM_UNUSED_15;
- x = _LIB9P_DM_UNUSED_14;
- x = _LIB9P_DM_UNUSED_13;
- x = _LIB9P_DM_UNUSED_12;
- x = _LIB9P_DM_UNUSED_11;
- x = _LIB9P_DM_UNUSED_10;
- x = _LIB9P_DM_UNUSED_9;
- x = LIB9P_DM_OWNER_R;
- x = LIB9P_DM_OWNER_W;
- x = LIB9P_DM_OWNER_X;
+#endif
+#ifdef LIB9P_DM_DIR
+ x = LIB9P_DM_DIR;
+#endif
+#ifdef LIB9P_DM_EXCL
+ x = LIB9P_DM_EXCL;
+#endif
+#ifdef LIB9P_DM_GROUP_R
x = LIB9P_DM_GROUP_R;
+#endif
+#ifdef LIB9P_DM_GROUP_W
x = LIB9P_DM_GROUP_W;
+#endif
+#ifdef LIB9P_DM_GROUP_X
x = LIB9P_DM_GROUP_X;
+#endif
+#ifdef LIB9P_DM_OTHER_R
x = LIB9P_DM_OTHER_R;
+#endif
+#ifdef LIB9P_DM_OTHER_W
x = LIB9P_DM_OTHER_W;
+#endif
+#ifdef LIB9P_DM_OTHER_X
x = LIB9P_DM_OTHER_X;
+#endif
+#ifdef LIB9P_DM_OWNER_R
+ x = LIB9P_DM_OWNER_R;
+#endif
+#ifdef LIB9P_DM_OWNER_W
+ x = LIB9P_DM_OWNER_W;
+#endif
+#ifdef LIB9P_DM_OWNER_X
+ x = LIB9P_DM_OWNER_X;
+#endif
+#ifdef LIB9P_DM_PERM_MASK
x = LIB9P_DM_PERM_MASK;
- x = LIB9P_QT_DIR;
- x = LIB9P_QT_APPEND;
- x = LIB9P_QT_EXCL;
- x = _LIB9P_QT_PLAN9_MOUNT;
- x = LIB9P_QT_AUTH;
- x = LIB9P_QT_TMP;
- x = LIB9P_QT_SYMLINK;
- x = _LIB9P_QT_UNUSED_0;
- x = LIB9P_QT_FILE;
- x = _LIB9P_O_UNUSED_7;
- x = LIB9P_O_RCLOSE;
- x = _LIB9P_O_RESERVED_CEXEC;
- x = LIB9P_O_TRUNC;
- x = _LIB9P_O_UNUSED_3;
- x = _LIB9P_O_UNUSED_2;
- x = LIB9P_O_FLAG_MASK;
- x = LIB9P_O_MODE_READ;
- x = LIB9P_O_MODE_WRITE;
- x = LIB9P_O_MODE_RDWR;
- x = LIB9P_O_MODE_EXEC;
- x = LIB9P_O_MODE_MASK;
- x = LIB9P_NUID_NONUID;
- x = LIB9P_ERRNO_NOERROR;
- x = LIB9P_ERRNO_L_EPERM;
- x = LIB9P_ERRNO_L_ENOENT;
- x = LIB9P_ERRNO_L_ESRCH;
- x = LIB9P_ERRNO_L_EINTR;
- x = LIB9P_ERRNO_L_EIO;
- x = LIB9P_ERRNO_L_ENXIO;
+#endif
+#ifdef LIB9P_DM_PIPE
+ x = LIB9P_DM_PIPE;
+#endif
+#ifdef LIB9P_DM_SETGID
+ x = LIB9P_DM_SETGID;
+#endif
+#ifdef LIB9P_DM_SETUID
+ x = LIB9P_DM_SETUID;
+#endif
+#ifdef LIB9P_DM_SOCKET
+ x = LIB9P_DM_SOCKET;
+#endif
+#ifdef LIB9P_DM_TMP
+ x = LIB9P_DM_TMP;
+#endif
+#ifdef LIB9P_DT_BLOCK_DEV
+ x = LIB9P_DT_BLOCK_DEV;
+#endif
+#ifdef LIB9P_DT_CHAR_DEV
+ x = LIB9P_DT_CHAR_DEV;
+#endif
+#ifdef LIB9P_DT_DIRECTORY
+ x = LIB9P_DT_DIRECTORY;
+#endif
+#ifdef LIB9P_DT_PIPE
+ x = LIB9P_DT_PIPE;
+#endif
+#ifdef LIB9P_DT_REGULAR
+ x = LIB9P_DT_REGULAR;
+#endif
+#ifdef LIB9P_DT_SOCKET
+ x = LIB9P_DT_SOCKET;
+#endif
+#ifdef LIB9P_DT_SYMLINK
+ x = LIB9P_DT_SYMLINK;
+#endif
+#ifdef LIB9P_DT_UNKNOWN
+ x = LIB9P_DT_UNKNOWN;
+#endif
+#ifdef LIB9P_ERRNO_L_E2BIG
x = LIB9P_ERRNO_L_E2BIG;
- x = LIB9P_ERRNO_L_ENOEXEC;
- x = LIB9P_ERRNO_L_EBADF;
- x = LIB9P_ERRNO_L_ECHILD;
- x = LIB9P_ERRNO_L_EAGAIN;
- x = LIB9P_ERRNO_L_ENOMEM;
+#endif
+#ifdef LIB9P_ERRNO_L_EACCES
x = LIB9P_ERRNO_L_EACCES;
- x = LIB9P_ERRNO_L_EFAULT;
- x = LIB9P_ERRNO_L_ENOTBLK;
- x = LIB9P_ERRNO_L_EBUSY;
- x = LIB9P_ERRNO_L_EEXIST;
- x = LIB9P_ERRNO_L_EXDEV;
- x = LIB9P_ERRNO_L_ENODEV;
- x = LIB9P_ERRNO_L_ENOTDIR;
- x = LIB9P_ERRNO_L_EISDIR;
- x = LIB9P_ERRNO_L_EINVAL;
- x = LIB9P_ERRNO_L_ENFILE;
- x = LIB9P_ERRNO_L_EMFILE;
- x = LIB9P_ERRNO_L_ENOTTY;
- x = LIB9P_ERRNO_L_ETXTBSY;
- x = LIB9P_ERRNO_L_EFBIG;
- x = LIB9P_ERRNO_L_ENOSPC;
- x = LIB9P_ERRNO_L_ESPIPE;
- x = LIB9P_ERRNO_L_EROFS;
- x = LIB9P_ERRNO_L_EMLINK;
- x = LIB9P_ERRNO_L_EPIPE;
- x = LIB9P_ERRNO_L_EDOM;
- x = LIB9P_ERRNO_L_ERANGE;
- x = LIB9P_ERRNO_L_EDEADLK;
- x = LIB9P_ERRNO_L_ENAMETOOLONG;
- x = LIB9P_ERRNO_L_ENOLCK;
- x = LIB9P_ERRNO_L_ENOSYS;
- x = LIB9P_ERRNO_L_ENOTEMPTY;
- x = LIB9P_ERRNO_L_ELOOP;
- x = LIB9P_ERRNO_L_ENOMSG;
- x = LIB9P_ERRNO_L_EIDRM;
- x = LIB9P_ERRNO_L_ECHRNG;
- x = LIB9P_ERRNO_L_EL2NSYNC;
- x = LIB9P_ERRNO_L_EL3HLT;
- x = LIB9P_ERRNO_L_EL3RST;
- x = LIB9P_ERRNO_L_ELNRNG;
- x = LIB9P_ERRNO_L_EUNATCH;
- x = LIB9P_ERRNO_L_ENOCSI;
- x = LIB9P_ERRNO_L_EL2HLT;
+#endif
+#ifdef LIB9P_ERRNO_L_EADDRINUSE
+ x = LIB9P_ERRNO_L_EADDRINUSE;
+#endif
+#ifdef LIB9P_ERRNO_L_EADDRNOTAVAIL
+ x = LIB9P_ERRNO_L_EADDRNOTAVAIL;
+#endif
+#ifdef LIB9P_ERRNO_L_EADV
+ x = LIB9P_ERRNO_L_EADV;
+#endif
+#ifdef LIB9P_ERRNO_L_EAFNOSUPPORT
+ x = LIB9P_ERRNO_L_EAFNOSUPPORT;
+#endif
+#ifdef LIB9P_ERRNO_L_EAGAIN
+ x = LIB9P_ERRNO_L_EAGAIN;
+#endif
+#ifdef LIB9P_ERRNO_L_EALREADY
+ x = LIB9P_ERRNO_L_EALREADY;
+#endif
+#ifdef LIB9P_ERRNO_L_EBADE
x = LIB9P_ERRNO_L_EBADE;
+#endif
+#ifdef LIB9P_ERRNO_L_EBADF
+ x = LIB9P_ERRNO_L_EBADF;
+#endif
+#ifdef LIB9P_ERRNO_L_EBADFD
+ x = LIB9P_ERRNO_L_EBADFD;
+#endif
+#ifdef LIB9P_ERRNO_L_EBADMSG
+ x = LIB9P_ERRNO_L_EBADMSG;
+#endif
+#ifdef LIB9P_ERRNO_L_EBADR
x = LIB9P_ERRNO_L_EBADR;
- x = LIB9P_ERRNO_L_EXFULL;
- x = LIB9P_ERRNO_L_ENOANO;
+#endif
+#ifdef LIB9P_ERRNO_L_EBADRQC
x = LIB9P_ERRNO_L_EBADRQC;
+#endif
+#ifdef LIB9P_ERRNO_L_EBADSLT
x = LIB9P_ERRNO_L_EBADSLT;
+#endif
+#ifdef LIB9P_ERRNO_L_EBFONT
x = LIB9P_ERRNO_L_EBFONT;
- x = LIB9P_ERRNO_L_ENOSTR;
- x = LIB9P_ERRNO_L_ENODATA;
- x = LIB9P_ERRNO_L_ETIME;
- x = LIB9P_ERRNO_L_ENOSR;
- x = LIB9P_ERRNO_L_ENONET;
- x = LIB9P_ERRNO_L_ENOPKG;
- x = LIB9P_ERRNO_L_EREMOTE;
- x = LIB9P_ERRNO_L_ENOLINK;
- x = LIB9P_ERRNO_L_EADV;
- x = LIB9P_ERRNO_L_ESRMNT;
+#endif
+#ifdef LIB9P_ERRNO_L_EBUSY
+ x = LIB9P_ERRNO_L_EBUSY;
+#endif
+#ifdef LIB9P_ERRNO_L_ECANCELED
+ x = LIB9P_ERRNO_L_ECANCELED;
+#endif
+#ifdef LIB9P_ERRNO_L_ECHILD
+ x = LIB9P_ERRNO_L_ECHILD;
+#endif
+#ifdef LIB9P_ERRNO_L_ECHRNG
+ x = LIB9P_ERRNO_L_ECHRNG;
+#endif
+#ifdef LIB9P_ERRNO_L_ECOMM
x = LIB9P_ERRNO_L_ECOMM;
- x = LIB9P_ERRNO_L_EPROTO;
- x = LIB9P_ERRNO_L_EMULTIHOP;
+#endif
+#ifdef LIB9P_ERRNO_L_ECONNABORTED
+ x = LIB9P_ERRNO_L_ECONNABORTED;
+#endif
+#ifdef LIB9P_ERRNO_L_ECONNREFUSED
+ x = LIB9P_ERRNO_L_ECONNREFUSED;
+#endif
+#ifdef LIB9P_ERRNO_L_ECONNRESET
+ x = LIB9P_ERRNO_L_ECONNRESET;
+#endif
+#ifdef LIB9P_ERRNO_L_EDEADLK
+ x = LIB9P_ERRNO_L_EDEADLK;
+#endif
+#ifdef LIB9P_ERRNO_L_EDESTADDRREQ
+ x = LIB9P_ERRNO_L_EDESTADDRREQ;
+#endif
+#ifdef LIB9P_ERRNO_L_EDOM
+ x = LIB9P_ERRNO_L_EDOM;
+#endif
+#ifdef LIB9P_ERRNO_L_EDOTDOT
x = LIB9P_ERRNO_L_EDOTDOT;
- x = LIB9P_ERRNO_L_EBADMSG;
- x = LIB9P_ERRNO_L_EOVERFLOW;
- x = LIB9P_ERRNO_L_ENOTUNIQ;
- x = LIB9P_ERRNO_L_EBADFD;
- x = LIB9P_ERRNO_L_EREMCHG;
+#endif
+#ifdef LIB9P_ERRNO_L_EDQUOT
+ x = LIB9P_ERRNO_L_EDQUOT;
+#endif
+#ifdef LIB9P_ERRNO_L_EEXIST
+ x = LIB9P_ERRNO_L_EEXIST;
+#endif
+#ifdef LIB9P_ERRNO_L_EFAULT
+ x = LIB9P_ERRNO_L_EFAULT;
+#endif
+#ifdef LIB9P_ERRNO_L_EFBIG
+ x = LIB9P_ERRNO_L_EFBIG;
+#endif
+#ifdef LIB9P_ERRNO_L_EHOSTDOWN
+ x = LIB9P_ERRNO_L_EHOSTDOWN;
+#endif
+#ifdef LIB9P_ERRNO_L_EHOSTUNREACH
+ x = LIB9P_ERRNO_L_EHOSTUNREACH;
+#endif
+#ifdef LIB9P_ERRNO_L_EHWPOISON
+ x = LIB9P_ERRNO_L_EHWPOISON;
+#endif
+#ifdef LIB9P_ERRNO_L_EIDRM
+ x = LIB9P_ERRNO_L_EIDRM;
+#endif
+#ifdef LIB9P_ERRNO_L_EILSEQ
+ x = LIB9P_ERRNO_L_EILSEQ;
+#endif
+#ifdef LIB9P_ERRNO_L_EINPROGRESS
+ x = LIB9P_ERRNO_L_EINPROGRESS;
+#endif
+#ifdef LIB9P_ERRNO_L_EINTR
+ x = LIB9P_ERRNO_L_EINTR;
+#endif
+#ifdef LIB9P_ERRNO_L_EINVAL
+ x = LIB9P_ERRNO_L_EINVAL;
+#endif
+#ifdef LIB9P_ERRNO_L_EIO
+ x = LIB9P_ERRNO_L_EIO;
+#endif
+#ifdef LIB9P_ERRNO_L_EISCONN
+ x = LIB9P_ERRNO_L_EISCONN;
+#endif
+#ifdef LIB9P_ERRNO_L_EISDIR
+ x = LIB9P_ERRNO_L_EISDIR;
+#endif
+#ifdef LIB9P_ERRNO_L_EISNAM
+ x = LIB9P_ERRNO_L_EISNAM;
+#endif
+#ifdef LIB9P_ERRNO_L_EKEYEXPIRED
+ x = LIB9P_ERRNO_L_EKEYEXPIRED;
+#endif
+#ifdef LIB9P_ERRNO_L_EKEYREJECTED
+ x = LIB9P_ERRNO_L_EKEYREJECTED;
+#endif
+#ifdef LIB9P_ERRNO_L_EKEYREVOKED
+ x = LIB9P_ERRNO_L_EKEYREVOKED;
+#endif
+#ifdef LIB9P_ERRNO_L_EL2HLT
+ x = LIB9P_ERRNO_L_EL2HLT;
+#endif
+#ifdef LIB9P_ERRNO_L_EL2NSYNC
+ x = LIB9P_ERRNO_L_EL2NSYNC;
+#endif
+#ifdef LIB9P_ERRNO_L_EL3HLT
+ x = LIB9P_ERRNO_L_EL3HLT;
+#endif
+#ifdef LIB9P_ERRNO_L_EL3RST
+ x = LIB9P_ERRNO_L_EL3RST;
+#endif
+#ifdef LIB9P_ERRNO_L_ELIBACC
x = LIB9P_ERRNO_L_ELIBACC;
+#endif
+#ifdef LIB9P_ERRNO_L_ELIBBAD
x = LIB9P_ERRNO_L_ELIBBAD;
- x = LIB9P_ERRNO_L_ELIBSCN;
- x = LIB9P_ERRNO_L_ELIBMAX;
+#endif
+#ifdef LIB9P_ERRNO_L_ELIBEXEC
x = LIB9P_ERRNO_L_ELIBEXEC;
- x = LIB9P_ERRNO_L_EILSEQ;
- x = LIB9P_ERRNO_L_ERESTART;
- x = LIB9P_ERRNO_L_ESTRPIPE;
- x = LIB9P_ERRNO_L_EUSERS;
- x = LIB9P_ERRNO_L_ENOTSOCK;
- x = LIB9P_ERRNO_L_EDESTADDRREQ;
+#endif
+#ifdef LIB9P_ERRNO_L_ELIBMAX
+ x = LIB9P_ERRNO_L_ELIBMAX;
+#endif
+#ifdef LIB9P_ERRNO_L_ELIBSCN
+ x = LIB9P_ERRNO_L_ELIBSCN;
+#endif
+#ifdef LIB9P_ERRNO_L_ELNRNG
+ x = LIB9P_ERRNO_L_ELNRNG;
+#endif
+#ifdef LIB9P_ERRNO_L_ELOOP
+ x = LIB9P_ERRNO_L_ELOOP;
+#endif
+#ifdef LIB9P_ERRNO_L_EMEDIUMTYPE
+ x = LIB9P_ERRNO_L_EMEDIUMTYPE;
+#endif
+#ifdef LIB9P_ERRNO_L_EMFILE
+ x = LIB9P_ERRNO_L_EMFILE;
+#endif
+#ifdef LIB9P_ERRNO_L_EMLINK
+ x = LIB9P_ERRNO_L_EMLINK;
+#endif
+#ifdef LIB9P_ERRNO_L_EMSGSIZE
x = LIB9P_ERRNO_L_EMSGSIZE;
- x = LIB9P_ERRNO_L_EPROTOTYPE;
- x = LIB9P_ERRNO_L_ENOPROTOOPT;
- x = LIB9P_ERRNO_L_EPROTONOSUPPORT;
- x = LIB9P_ERRNO_L_ESOCKTNOSUPPORT;
- x = LIB9P_ERRNO_L_EOPNOTSUPP;
- x = LIB9P_ERRNO_L_EPFNOSUPPORT;
- x = LIB9P_ERRNO_L_EAFNOSUPPORT;
- x = LIB9P_ERRNO_L_EADDRINUSE;
- x = LIB9P_ERRNO_L_EADDRNOTAVAIL;
+#endif
+#ifdef LIB9P_ERRNO_L_EMULTIHOP
+ x = LIB9P_ERRNO_L_EMULTIHOP;
+#endif
+#ifdef LIB9P_ERRNO_L_ENAMETOOLONG
+ x = LIB9P_ERRNO_L_ENAMETOOLONG;
+#endif
+#ifdef LIB9P_ERRNO_L_ENAVAIL
+ x = LIB9P_ERRNO_L_ENAVAIL;
+#endif
+#ifdef LIB9P_ERRNO_L_ENETDOWN
x = LIB9P_ERRNO_L_ENETDOWN;
- x = LIB9P_ERRNO_L_ENETUNREACH;
+#endif
+#ifdef LIB9P_ERRNO_L_ENETRESET
x = LIB9P_ERRNO_L_ENETRESET;
- x = LIB9P_ERRNO_L_ECONNABORTED;
- x = LIB9P_ERRNO_L_ECONNRESET;
+#endif
+#ifdef LIB9P_ERRNO_L_ENETUNREACH
+ x = LIB9P_ERRNO_L_ENETUNREACH;
+#endif
+#ifdef LIB9P_ERRNO_L_ENFILE
+ x = LIB9P_ERRNO_L_ENFILE;
+#endif
+#ifdef LIB9P_ERRNO_L_ENOANO
+ x = LIB9P_ERRNO_L_ENOANO;
+#endif
+#ifdef LIB9P_ERRNO_L_ENOBUFS
x = LIB9P_ERRNO_L_ENOBUFS;
- x = LIB9P_ERRNO_L_EISCONN;
+#endif
+#ifdef LIB9P_ERRNO_L_ENOCSI
+ x = LIB9P_ERRNO_L_ENOCSI;
+#endif
+#ifdef LIB9P_ERRNO_L_ENODATA
+ x = LIB9P_ERRNO_L_ENODATA;
+#endif
+#ifdef LIB9P_ERRNO_L_ENODEV
+ x = LIB9P_ERRNO_L_ENODEV;
+#endif
+#ifdef LIB9P_ERRNO_L_ENOENT
+ x = LIB9P_ERRNO_L_ENOENT;
+#endif
+#ifdef LIB9P_ERRNO_L_ENOEXEC
+ x = LIB9P_ERRNO_L_ENOEXEC;
+#endif
+#ifdef LIB9P_ERRNO_L_ENOKEY
+ x = LIB9P_ERRNO_L_ENOKEY;
+#endif
+#ifdef LIB9P_ERRNO_L_ENOLCK
+ x = LIB9P_ERRNO_L_ENOLCK;
+#endif
+#ifdef LIB9P_ERRNO_L_ENOLINK
+ x = LIB9P_ERRNO_L_ENOLINK;
+#endif
+#ifdef LIB9P_ERRNO_L_ENOMEDIUM
+ x = LIB9P_ERRNO_L_ENOMEDIUM;
+#endif
+#ifdef LIB9P_ERRNO_L_ENOMEM
+ x = LIB9P_ERRNO_L_ENOMEM;
+#endif
+#ifdef LIB9P_ERRNO_L_ENOMSG
+ x = LIB9P_ERRNO_L_ENOMSG;
+#endif
+#ifdef LIB9P_ERRNO_L_ENONET
+ x = LIB9P_ERRNO_L_ENONET;
+#endif
+#ifdef LIB9P_ERRNO_L_ENOPKG
+ x = LIB9P_ERRNO_L_ENOPKG;
+#endif
+#ifdef LIB9P_ERRNO_L_ENOPROTOOPT
+ x = LIB9P_ERRNO_L_ENOPROTOOPT;
+#endif
+#ifdef LIB9P_ERRNO_L_ENOSPC
+ x = LIB9P_ERRNO_L_ENOSPC;
+#endif
+#ifdef LIB9P_ERRNO_L_ENOSR
+ x = LIB9P_ERRNO_L_ENOSR;
+#endif
+#ifdef LIB9P_ERRNO_L_ENOSTR
+ x = LIB9P_ERRNO_L_ENOSTR;
+#endif
+#ifdef LIB9P_ERRNO_L_ENOSYS
+ x = LIB9P_ERRNO_L_ENOSYS;
+#endif
+#ifdef LIB9P_ERRNO_L_ENOTBLK
+ x = LIB9P_ERRNO_L_ENOTBLK;
+#endif
+#ifdef LIB9P_ERRNO_L_ENOTCONN
x = LIB9P_ERRNO_L_ENOTCONN;
- x = LIB9P_ERRNO_L_ESHUTDOWN;
- x = LIB9P_ERRNO_L_ETOOMANYREFS;
- x = LIB9P_ERRNO_L_ETIMEDOUT;
- x = LIB9P_ERRNO_L_ECONNREFUSED;
- x = LIB9P_ERRNO_L_EHOSTDOWN;
- x = LIB9P_ERRNO_L_EHOSTUNREACH;
- x = LIB9P_ERRNO_L_EALREADY;
- x = LIB9P_ERRNO_L_EINPROGRESS;
- x = LIB9P_ERRNO_L_ESTALE;
- x = LIB9P_ERRNO_L_EUCLEAN;
+#endif
+#ifdef LIB9P_ERRNO_L_ENOTDIR
+ x = LIB9P_ERRNO_L_ENOTDIR;
+#endif
+#ifdef LIB9P_ERRNO_L_ENOTEMPTY
+ x = LIB9P_ERRNO_L_ENOTEMPTY;
+#endif
+#ifdef LIB9P_ERRNO_L_ENOTNAM
x = LIB9P_ERRNO_L_ENOTNAM;
- x = LIB9P_ERRNO_L_ENAVAIL;
- x = LIB9P_ERRNO_L_EISNAM;
- x = LIB9P_ERRNO_L_EREMOTEIO;
- x = LIB9P_ERRNO_L_EDQUOT;
- x = LIB9P_ERRNO_L_ENOMEDIUM;
- x = LIB9P_ERRNO_L_EMEDIUMTYPE;
- x = LIB9P_ERRNO_L_ECANCELED;
- x = LIB9P_ERRNO_L_ENOKEY;
- x = LIB9P_ERRNO_L_EKEYEXPIRED;
- x = LIB9P_ERRNO_L_EKEYREVOKED;
- x = LIB9P_ERRNO_L_EKEYREJECTED;
- x = LIB9P_ERRNO_L_EOWNERDEAD;
+#endif
+#ifdef LIB9P_ERRNO_L_ENOTRECOVERABLE
x = LIB9P_ERRNO_L_ENOTRECOVERABLE;
+#endif
+#ifdef LIB9P_ERRNO_L_ENOTSOCK
+ x = LIB9P_ERRNO_L_ENOTSOCK;
+#endif
+#ifdef LIB9P_ERRNO_L_ENOTTY
+ x = LIB9P_ERRNO_L_ENOTTY;
+#endif
+#ifdef LIB9P_ERRNO_L_ENOTUNIQ
+ x = LIB9P_ERRNO_L_ENOTUNIQ;
+#endif
+#ifdef LIB9P_ERRNO_L_ENXIO
+ x = LIB9P_ERRNO_L_ENXIO;
+#endif
+#ifdef LIB9P_ERRNO_L_EOPNOTSUPP
+ x = LIB9P_ERRNO_L_EOPNOTSUPP;
+#endif
+#ifdef LIB9P_ERRNO_L_EOVERFLOW
+ x = LIB9P_ERRNO_L_EOVERFLOW;
+#endif
+#ifdef LIB9P_ERRNO_L_EOWNERDEAD
+ x = LIB9P_ERRNO_L_EOWNERDEAD;
+#endif
+#ifdef LIB9P_ERRNO_L_EPERM
+ x = LIB9P_ERRNO_L_EPERM;
+#endif
+#ifdef LIB9P_ERRNO_L_EPFNOSUPPORT
+ x = LIB9P_ERRNO_L_EPFNOSUPPORT;
+#endif
+#ifdef LIB9P_ERRNO_L_EPIPE
+ x = LIB9P_ERRNO_L_EPIPE;
+#endif
+#ifdef LIB9P_ERRNO_L_EPROTO
+ x = LIB9P_ERRNO_L_EPROTO;
+#endif
+#ifdef LIB9P_ERRNO_L_EPROTONOSUPPORT
+ x = LIB9P_ERRNO_L_EPROTONOSUPPORT;
+#endif
+#ifdef LIB9P_ERRNO_L_EPROTOTYPE
+ x = LIB9P_ERRNO_L_EPROTOTYPE;
+#endif
+#ifdef LIB9P_ERRNO_L_ERANGE
+ x = LIB9P_ERRNO_L_ERANGE;
+#endif
+#ifdef LIB9P_ERRNO_L_EREMCHG
+ x = LIB9P_ERRNO_L_EREMCHG;
+#endif
+#ifdef LIB9P_ERRNO_L_EREMOTE
+ x = LIB9P_ERRNO_L_EREMOTE;
+#endif
+#ifdef LIB9P_ERRNO_L_EREMOTEIO
+ x = LIB9P_ERRNO_L_EREMOTEIO;
+#endif
+#ifdef LIB9P_ERRNO_L_ERESTART
+ x = LIB9P_ERRNO_L_ERESTART;
+#endif
+#ifdef LIB9P_ERRNO_L_ERFKILL
x = LIB9P_ERRNO_L_ERFKILL;
- x = LIB9P_ERRNO_L_EHWPOISON;
- x = LIB9P_SUPER_MAGIC_V9FS_MAGIC;
- x = _LIB9P_LO_UNUSED_31;
- x = _LIB9P_LO_UNUSED_30;
- x = _LIB9P_LO_UNUSED_29;
- x = _LIB9P_LO_UNUSED_28;
- x = _LIB9P_LO_UNUSED_27;
- x = _LIB9P_LO_UNUSED_26;
- x = _LIB9P_LO_UNUSED_25;
- x = _LIB9P_LO_UNUSED_24;
- x = _LIB9P_LO_UNUSED_23;
- x = _LIB9P_LO_UNUSED_22;
- x = _LIB9P_LO_UNUSED_21;
- x = LIB9P_LO_SYNC;
+#endif
+#ifdef LIB9P_ERRNO_L_EROFS
+ x = LIB9P_ERRNO_L_EROFS;
+#endif
+#ifdef LIB9P_ERRNO_L_ESHUTDOWN
+ x = LIB9P_ERRNO_L_ESHUTDOWN;
+#endif
+#ifdef LIB9P_ERRNO_L_ESOCKTNOSUPPORT
+ x = LIB9P_ERRNO_L_ESOCKTNOSUPPORT;
+#endif
+#ifdef LIB9P_ERRNO_L_ESPIPE
+ x = LIB9P_ERRNO_L_ESPIPE;
+#endif
+#ifdef LIB9P_ERRNO_L_ESRCH
+ x = LIB9P_ERRNO_L_ESRCH;
+#endif
+#ifdef LIB9P_ERRNO_L_ESRMNT
+ x = LIB9P_ERRNO_L_ESRMNT;
+#endif
+#ifdef LIB9P_ERRNO_L_ESTALE
+ x = LIB9P_ERRNO_L_ESTALE;
+#endif
+#ifdef LIB9P_ERRNO_L_ESTRPIPE
+ x = LIB9P_ERRNO_L_ESTRPIPE;
+#endif
+#ifdef LIB9P_ERRNO_L_ETIME
+ x = LIB9P_ERRNO_L_ETIME;
+#endif
+#ifdef LIB9P_ERRNO_L_ETIMEDOUT
+ x = LIB9P_ERRNO_L_ETIMEDOUT;
+#endif
+#ifdef LIB9P_ERRNO_L_ETOOMANYREFS
+ x = LIB9P_ERRNO_L_ETOOMANYREFS;
+#endif
+#ifdef LIB9P_ERRNO_L_ETXTBSY
+ x = LIB9P_ERRNO_L_ETXTBSY;
+#endif
+#ifdef LIB9P_ERRNO_L_EUCLEAN
+ x = LIB9P_ERRNO_L_EUCLEAN;
+#endif
+#ifdef LIB9P_ERRNO_L_EUNATCH
+ x = LIB9P_ERRNO_L_EUNATCH;
+#endif
+#ifdef LIB9P_ERRNO_L_EUSERS
+ x = LIB9P_ERRNO_L_EUSERS;
+#endif
+#ifdef LIB9P_ERRNO_L_EXDEV
+ x = LIB9P_ERRNO_L_EXDEV;
+#endif
+#ifdef LIB9P_ERRNO_L_EXFULL
+ x = LIB9P_ERRNO_L_EXFULL;
+#endif
+#ifdef LIB9P_ERRNO_NOERROR
+ x = LIB9P_ERRNO_NOERROR;
+#endif
+#ifdef LIB9P_FID_NOFID
+ x = LIB9P_FID_NOFID;
+#endif
+#ifdef LIB9P_GETATTR_ALL
+ x = LIB9P_GETATTR_ALL;
+#endif
+#ifdef LIB9P_GETATTR_ATIME
+ x = LIB9P_GETATTR_ATIME;
+#endif
+#ifdef LIB9P_GETATTR_BASIC
+ x = LIB9P_GETATTR_BASIC;
+#endif
+#ifdef LIB9P_GETATTR_BLOCKS
+ x = LIB9P_GETATTR_BLOCKS;
+#endif
+#ifdef LIB9P_GETATTR_BTIME
+ x = LIB9P_GETATTR_BTIME;
+#endif
+#ifdef LIB9P_GETATTR_CTIME
+ x = LIB9P_GETATTR_CTIME;
+#endif
+#ifdef LIB9P_GETATTR_DATA_VERSION
+ x = LIB9P_GETATTR_DATA_VERSION;
+#endif
+#ifdef LIB9P_GETATTR_GEN
+ x = LIB9P_GETATTR_GEN;
+#endif
+#ifdef LIB9P_GETATTR_GID
+ x = LIB9P_GETATTR_GID;
+#endif
+#ifdef LIB9P_GETATTR_INO
+ x = LIB9P_GETATTR_INO;
+#endif
+#ifdef LIB9P_GETATTR_MODE
+ x = LIB9P_GETATTR_MODE;
+#endif
+#ifdef LIB9P_GETATTR_MTIME
+ x = LIB9P_GETATTR_MTIME;
+#endif
+#ifdef LIB9P_GETATTR_NLINK
+ x = LIB9P_GETATTR_NLINK;
+#endif
+#ifdef LIB9P_GETATTR_RDEV
+ x = LIB9P_GETATTR_RDEV;
+#endif
+#ifdef LIB9P_GETATTR_SIZE
+ x = LIB9P_GETATTR_SIZE;
+#endif
+#ifdef LIB9P_GETATTR_UID
+ x = LIB9P_GETATTR_UID;
+#endif
+#ifdef LIB9P_LOCK_FLAGS_BLOCK
+ x = LIB9P_LOCK_FLAGS_BLOCK;
+#endif
+#ifdef LIB9P_LOCK_FLAGS_RECLAIM
+ x = LIB9P_LOCK_FLAGS_RECLAIM;
+#endif
+#ifdef LIB9P_LOCK_STATUS_BLOCKED
+ x = LIB9P_LOCK_STATUS_BLOCKED;
+#endif
+#ifdef LIB9P_LOCK_STATUS_ERROR
+ x = LIB9P_LOCK_STATUS_ERROR;
+#endif
+#ifdef LIB9P_LOCK_STATUS_GRACE
+ x = LIB9P_LOCK_STATUS_GRACE;
+#endif
+#ifdef LIB9P_LOCK_STATUS_SUCCESS
+ x = LIB9P_LOCK_STATUS_SUCCESS;
+#endif
+#ifdef LIB9P_LOCK_TYPE_RDLCK
+ x = LIB9P_LOCK_TYPE_RDLCK;
+#endif
+#ifdef LIB9P_LOCK_TYPE_UNLCK
+ x = LIB9P_LOCK_TYPE_UNLCK;
+#endif
+#ifdef LIB9P_LOCK_TYPE_WRLCK
+ x = LIB9P_LOCK_TYPE_WRLCK;
+#endif
+#ifdef LIB9P_LO_APPEND
+ x = LIB9P_LO_APPEND;
+#endif
+#ifdef LIB9P_LO_BSD_FASYNC
+ x = LIB9P_LO_BSD_FASYNC;
+#endif
+#ifdef LIB9P_LO_CLOEXEC
x = LIB9P_LO_CLOEXEC;
- x = LIB9P_LO_NOATIME;
- x = LIB9P_LO_NOFOLLOW;
- x = LIB9P_LO_DIRECTORY;
- x = LIB9P_LO_LARGEFILE;
+#endif
+#ifdef LIB9P_LO_CREATE
+ x = LIB9P_LO_CREATE;
+#endif
+#ifdef LIB9P_LO_DIRECT
x = LIB9P_LO_DIRECT;
- x = LIB9P_LO_BSD_FASYNC;
+#endif
+#ifdef LIB9P_LO_DIRECTORY
+ x = LIB9P_LO_DIRECTORY;
+#endif
+#ifdef LIB9P_LO_DSYNC
x = LIB9P_LO_DSYNC;
- x = LIB9P_LO_NONBLOCK;
- x = LIB9P_LO_APPEND;
- x = LIB9P_LO_TRUNC;
- x = LIB9P_LO_NOCTTY;
+#endif
+#ifdef LIB9P_LO_EXCL
x = LIB9P_LO_EXCL;
- x = LIB9P_LO_CREATE;
- x = _LIB9P_LO_UNUSED_5;
- x = _LIB9P_LO_UNUSED_4;
- x = _LIB9P_LO_UNUSED_3;
- x = _LIB9P_LO_UNUSED_2;
+#endif
+#ifdef LIB9P_LO_FLAG_MASK
x = LIB9P_LO_FLAG_MASK;
+#endif
+#ifdef LIB9P_LO_LARGEFILE
+ x = LIB9P_LO_LARGEFILE;
+#endif
+#ifdef LIB9P_LO_MODE_MASK
+ x = LIB9P_LO_MODE_MASK;
+#endif
+#ifdef LIB9P_LO_MODE_NOACCESS
+ x = LIB9P_LO_MODE_NOACCESS;
+#endif
+#ifdef LIB9P_LO_MODE_RDONLY
x = LIB9P_LO_MODE_RDONLY;
- x = LIB9P_LO_MODE_WRONLY;
+#endif
+#ifdef LIB9P_LO_MODE_RDWR
x = LIB9P_LO_MODE_RDWR;
- x = LIB9P_LO_MODE_NOACCESS;
- x = LIB9P_LO_MODE_MASK;
- x = LIB9P_DT_UNKNOWN;
- x = LIB9P_DT_PIPE;
- x = LIB9P_DT_CHAR_DEV;
- x = LIB9P_DT_DIRECTORY;
- x = LIB9P_DT_BLOCK_DEV;
- x = LIB9P_DT_REGULAR;
- x = LIB9P_DT_SYMLINK;
- x = LIB9P_DT_SOCKET;
- x = _LIB9P_DT_WHITEOUT;
- x = _LIB9P_MODE_UNUSED_31;
- x = _LIB9P_MODE_UNUSED_30;
- x = _LIB9P_MODE_UNUSED_29;
- x = _LIB9P_MODE_UNUSED_28;
- x = _LIB9P_MODE_UNUSED_27;
- x = _LIB9P_MODE_UNUSED_26;
- x = _LIB9P_MODE_UNUSED_25;
- x = _LIB9P_MODE_UNUSED_24;
- x = _LIB9P_MODE_UNUSED_23;
- x = _LIB9P_MODE_UNUSED_22;
- x = _LIB9P_MODE_UNUSED_21;
- x = _LIB9P_MODE_UNUSED_20;
- x = _LIB9P_MODE_UNUSED_19;
- x = _LIB9P_MODE_UNUSED_18;
- x = _LIB9P_MODE_UNUSED_17;
- x = _LIB9P_MODE_UNUSED_16;
- x = LIB9P_MODE_PERM_SETGROUP;
- x = LIB9P_MODE_PERM_SETUSER;
- x = LIB9P_MODE_PERM_STICKY;
- x = LIB9P_MODE_PERM_OWNER_R;
- x = LIB9P_MODE_PERM_OWNER_W;
- x = LIB9P_MODE_PERM_OWNER_X;
+#endif
+#ifdef LIB9P_LO_MODE_WRONLY
+ x = LIB9P_LO_MODE_WRONLY;
+#endif
+#ifdef LIB9P_LO_NOATIME
+ x = LIB9P_LO_NOATIME;
+#endif
+#ifdef LIB9P_LO_NOCTTY
+ x = LIB9P_LO_NOCTTY;
+#endif
+#ifdef LIB9P_LO_NOFOLLOW
+ x = LIB9P_LO_NOFOLLOW;
+#endif
+#ifdef LIB9P_LO_NONBLOCK
+ x = LIB9P_LO_NONBLOCK;
+#endif
+#ifdef LIB9P_LO_SYNC
+ x = LIB9P_LO_SYNC;
+#endif
+#ifdef LIB9P_LO_TRUNC
+ x = LIB9P_LO_TRUNC;
+#endif
+#ifdef LIB9P_MODE_FMT_BLOCK_DEV
+ x = LIB9P_MODE_FMT_BLOCK_DEV;
+#endif
+#ifdef LIB9P_MODE_FMT_CHAR_DEV
+ x = LIB9P_MODE_FMT_CHAR_DEV;
+#endif
+#ifdef LIB9P_MODE_FMT_DIRECTORY
+ x = LIB9P_MODE_FMT_DIRECTORY;
+#endif
+#ifdef LIB9P_MODE_FMT_MASK
+ x = LIB9P_MODE_FMT_MASK;
+#endif
+#ifdef LIB9P_MODE_FMT_PIPE
+ x = LIB9P_MODE_FMT_PIPE;
+#endif
+#ifdef LIB9P_MODE_FMT_REGULAR
+ x = LIB9P_MODE_FMT_REGULAR;
+#endif
+#ifdef LIB9P_MODE_FMT_SOCKET
+ x = LIB9P_MODE_FMT_SOCKET;
+#endif
+#ifdef LIB9P_MODE_FMT_SYMLINK
+ x = LIB9P_MODE_FMT_SYMLINK;
+#endif
+#ifdef LIB9P_MODE_PERM_GROUP_R
x = LIB9P_MODE_PERM_GROUP_R;
+#endif
+#ifdef LIB9P_MODE_PERM_GROUP_W
x = LIB9P_MODE_PERM_GROUP_W;
+#endif
+#ifdef LIB9P_MODE_PERM_GROUP_X
x = LIB9P_MODE_PERM_GROUP_X;
+#endif
+#ifdef LIB9P_MODE_PERM_MASK
+ x = LIB9P_MODE_PERM_MASK;
+#endif
+#ifdef LIB9P_MODE_PERM_OTHER_R
x = LIB9P_MODE_PERM_OTHER_R;
+#endif
+#ifdef LIB9P_MODE_PERM_OTHER_W
x = LIB9P_MODE_PERM_OTHER_W;
+#endif
+#ifdef LIB9P_MODE_PERM_OTHER_X
x = LIB9P_MODE_PERM_OTHER_X;
- x = LIB9P_MODE_PERM_MASK;
- x = LIB9P_MODE_FMT_PIPE;
- x = LIB9P_MODE_FMT_CHAR_DEV;
- x = LIB9P_MODE_FMT_DIRECTORY;
- x = LIB9P_MODE_FMT_BLOCK_DEV;
- x = LIB9P_MODE_FMT_REGULAR;
- x = LIB9P_MODE_FMT_SYMLINK;
- x = LIB9P_MODE_FMT_SOCKET;
- x = LIB9P_MODE_FMT_MASK;
- x = LIB9P_B4_FALSE;
- x = LIB9P_B4_TRUE;
- x = _LIB9P_GETATTR_UNUSED_63;
- x = _LIB9P_GETATTR_UNUSED_62;
- x = _LIB9P_GETATTR_UNUSED_61;
- x = _LIB9P_GETATTR_UNUSED_60;
- x = _LIB9P_GETATTR_UNUSED_59;
- x = _LIB9P_GETATTR_UNUSED_58;
- x = _LIB9P_GETATTR_UNUSED_57;
- x = _LIB9P_GETATTR_UNUSED_56;
- x = _LIB9P_GETATTR_UNUSED_55;
- x = _LIB9P_GETATTR_UNUSED_54;
- x = _LIB9P_GETATTR_UNUSED_53;
- x = _LIB9P_GETATTR_UNUSED_52;
- x = _LIB9P_GETATTR_UNUSED_51;
- x = _LIB9P_GETATTR_UNUSED_50;
- x = _LIB9P_GETATTR_UNUSED_49;
- x = _LIB9P_GETATTR_UNUSED_48;
- x = _LIB9P_GETATTR_UNUSED_47;
- x = _LIB9P_GETATTR_UNUSED_46;
- x = _LIB9P_GETATTR_UNUSED_45;
- x = _LIB9P_GETATTR_UNUSED_44;
- x = _LIB9P_GETATTR_UNUSED_43;
- x = _LIB9P_GETATTR_UNUSED_42;
- x = _LIB9P_GETATTR_UNUSED_41;
- x = _LIB9P_GETATTR_UNUSED_40;
- x = _LIB9P_GETATTR_UNUSED_39;
- x = _LIB9P_GETATTR_UNUSED_38;
- x = _LIB9P_GETATTR_UNUSED_37;
- x = _LIB9P_GETATTR_UNUSED_36;
- x = _LIB9P_GETATTR_UNUSED_35;
- x = _LIB9P_GETATTR_UNUSED_34;
- x = _LIB9P_GETATTR_UNUSED_33;
- x = _LIB9P_GETATTR_UNUSED_32;
- x = _LIB9P_GETATTR_UNUSED_31;
- x = _LIB9P_GETATTR_UNUSED_30;
- x = _LIB9P_GETATTR_UNUSED_29;
- x = _LIB9P_GETATTR_UNUSED_28;
- x = _LIB9P_GETATTR_UNUSED_27;
- x = _LIB9P_GETATTR_UNUSED_26;
- x = _LIB9P_GETATTR_UNUSED_25;
- x = _LIB9P_GETATTR_UNUSED_24;
- x = _LIB9P_GETATTR_UNUSED_23;
- x = _LIB9P_GETATTR_UNUSED_22;
- x = _LIB9P_GETATTR_UNUSED_21;
- x = _LIB9P_GETATTR_UNUSED_20;
- x = _LIB9P_GETATTR_UNUSED_19;
- x = _LIB9P_GETATTR_UNUSED_18;
- x = _LIB9P_GETATTR_UNUSED_17;
- x = _LIB9P_GETATTR_UNUSED_16;
- x = _LIB9P_GETATTR_UNUSED_15;
- x = _LIB9P_GETATTR_UNUSED_14;
- x = LIB9P_GETATTR_DATA_VERSION;
- x = LIB9P_GETATTR_GEN;
- x = LIB9P_GETATTR_BTIME;
- x = LIB9P_GETATTR_BLOCKS;
- x = LIB9P_GETATTR_SIZE;
- x = LIB9P_GETATTR_INO;
- x = LIB9P_GETATTR_CTIME;
- x = LIB9P_GETATTR_MTIME;
- x = LIB9P_GETATTR_ATIME;
- x = LIB9P_GETATTR_RDEV;
- x = LIB9P_GETATTR_GID;
- x = LIB9P_GETATTR_UID;
- x = LIB9P_GETATTR_NLINK;
- x = LIB9P_GETATTR_MODE;
- x = LIB9P_GETATTR_BASIC;
- x = LIB9P_GETATTR_ALL;
- x = _LIB9P_SETATTR_UNUSED_31;
- x = _LIB9P_SETATTR_UNUSED_30;
- x = _LIB9P_SETATTR_UNUSED_29;
- x = _LIB9P_SETATTR_UNUSED_28;
- x = _LIB9P_SETATTR_UNUSED_27;
- x = _LIB9P_SETATTR_UNUSED_26;
- x = _LIB9P_SETATTR_UNUSED_25;
- x = _LIB9P_SETATTR_UNUSED_24;
- x = _LIB9P_SETATTR_UNUSED_23;
- x = _LIB9P_SETATTR_UNUSED_22;
- x = _LIB9P_SETATTR_UNUSED_21;
- x = _LIB9P_SETATTR_UNUSED_20;
- x = _LIB9P_SETATTR_UNUSED_19;
- x = _LIB9P_SETATTR_UNUSED_18;
- x = _LIB9P_SETATTR_UNUSED_17;
- x = _LIB9P_SETATTR_UNUSED_16;
- x = _LIB9P_SETATTR_UNUSED_15;
- x = _LIB9P_SETATTR_UNUSED_14;
- x = _LIB9P_SETATTR_UNUSED_13;
- x = _LIB9P_SETATTR_UNUSED_12;
- x = _LIB9P_SETATTR_UNUSED_11;
- x = _LIB9P_SETATTR_UNUSED_10;
- x = _LIB9P_SETATTR_UNUSED_9;
- x = LIB9P_SETATTR_MTIME_SET;
+#endif
+#ifdef LIB9P_MODE_PERM_OWNER_R
+ x = LIB9P_MODE_PERM_OWNER_R;
+#endif
+#ifdef LIB9P_MODE_PERM_OWNER_W
+ x = LIB9P_MODE_PERM_OWNER_W;
+#endif
+#ifdef LIB9P_MODE_PERM_OWNER_X
+ x = LIB9P_MODE_PERM_OWNER_X;
+#endif
+#ifdef LIB9P_MODE_PERM_SETGROUP
+ x = LIB9P_MODE_PERM_SETGROUP;
+#endif
+#ifdef LIB9P_MODE_PERM_SETUSER
+ x = LIB9P_MODE_PERM_SETUSER;
+#endif
+#ifdef LIB9P_MODE_PERM_STICKY
+ x = LIB9P_MODE_PERM_STICKY;
+#endif
+#ifdef LIB9P_NUID_NONUID
+ x = LIB9P_NUID_NONUID;
+#endif
+#ifdef LIB9P_O_FLAG_MASK
+ x = LIB9P_O_FLAG_MASK;
+#endif
+#ifdef LIB9P_O_MODE_EXEC
+ x = LIB9P_O_MODE_EXEC;
+#endif
+#ifdef LIB9P_O_MODE_MASK
+ x = LIB9P_O_MODE_MASK;
+#endif
+#ifdef LIB9P_O_MODE_RDWR
+ x = LIB9P_O_MODE_RDWR;
+#endif
+#ifdef LIB9P_O_MODE_READ
+ x = LIB9P_O_MODE_READ;
+#endif
+#ifdef LIB9P_O_MODE_WRITE
+ x = LIB9P_O_MODE_WRITE;
+#endif
+#ifdef LIB9P_O_RCLOSE
+ x = LIB9P_O_RCLOSE;
+#endif
+#ifdef LIB9P_O_TRUNC
+ x = LIB9P_O_TRUNC;
+#endif
+#ifdef LIB9P_QT_APPEND
+ x = LIB9P_QT_APPEND;
+#endif
+#ifdef LIB9P_QT_AUTH
+ x = LIB9P_QT_AUTH;
+#endif
+#ifdef LIB9P_QT_DIR
+ x = LIB9P_QT_DIR;
+#endif
+#ifdef LIB9P_QT_EXCL
+ x = LIB9P_QT_EXCL;
+#endif
+#ifdef LIB9P_QT_FILE
+ x = LIB9P_QT_FILE;
+#endif
+#ifdef LIB9P_QT_SYMLINK
+ x = LIB9P_QT_SYMLINK;
+#endif
+#ifdef LIB9P_QT_TMP
+ x = LIB9P_QT_TMP;
+#endif
+#ifdef LIB9P_RMSG_MAX_COPY
+ x = LIB9P_RMSG_MAX_COPY;
+#endif
+#ifdef LIB9P_RMSG_MAX_IOV
+ x = LIB9P_RMSG_MAX_IOV;
+#endif
+#ifdef LIB9P_SETATTR_ATIME
+ x = LIB9P_SETATTR_ATIME;
+#endif
+#ifdef LIB9P_SETATTR_ATIME_SET
x = LIB9P_SETATTR_ATIME_SET;
+#endif
+#ifdef LIB9P_SETATTR_CTIME
x = LIB9P_SETATTR_CTIME;
+#endif
+#ifdef LIB9P_SETATTR_GID
+ x = LIB9P_SETATTR_GID;
+#endif
+#ifdef LIB9P_SETATTR_MODE
+ x = LIB9P_SETATTR_MODE;
+#endif
+#ifdef LIB9P_SETATTR_MTIME
x = LIB9P_SETATTR_MTIME;
- x = LIB9P_SETATTR_ATIME;
+#endif
+#ifdef LIB9P_SETATTR_MTIME_SET
+ x = LIB9P_SETATTR_MTIME_SET;
+#endif
+#ifdef LIB9P_SETATTR_SIZE
x = LIB9P_SETATTR_SIZE;
- x = LIB9P_SETATTR_GID;
+#endif
+#ifdef LIB9P_SETATTR_UID
x = LIB9P_SETATTR_UID;
- x = LIB9P_SETATTR_MODE;
- x = LIB9P_LOCK_TYPE_RDLCK;
- x = LIB9P_LOCK_TYPE_WRLCK;
- x = LIB9P_LOCK_TYPE_UNLCK;
- x = _LIB9P_LOCK_FLAGS_UNUSED_31;
- x = _LIB9P_LOCK_FLAGS_UNUSED_30;
- x = _LIB9P_LOCK_FLAGS_UNUSED_29;
- x = _LIB9P_LOCK_FLAGS_UNUSED_28;
- x = _LIB9P_LOCK_FLAGS_UNUSED_27;
- x = _LIB9P_LOCK_FLAGS_UNUSED_26;
- x = _LIB9P_LOCK_FLAGS_UNUSED_25;
- x = _LIB9P_LOCK_FLAGS_UNUSED_24;
- x = _LIB9P_LOCK_FLAGS_UNUSED_23;
- x = _LIB9P_LOCK_FLAGS_UNUSED_22;
- x = _LIB9P_LOCK_FLAGS_UNUSED_21;
- x = _LIB9P_LOCK_FLAGS_UNUSED_20;
- x = _LIB9P_LOCK_FLAGS_UNUSED_19;
- x = _LIB9P_LOCK_FLAGS_UNUSED_18;
- x = _LIB9P_LOCK_FLAGS_UNUSED_17;
- x = _LIB9P_LOCK_FLAGS_UNUSED_16;
- x = _LIB9P_LOCK_FLAGS_UNUSED_15;
- x = _LIB9P_LOCK_FLAGS_UNUSED_14;
- x = _LIB9P_LOCK_FLAGS_UNUSED_13;
- x = _LIB9P_LOCK_FLAGS_UNUSED_12;
- x = _LIB9P_LOCK_FLAGS_UNUSED_11;
+#endif
+#ifdef LIB9P_SUPER_MAGIC_V9FS_MAGIC
+ x = LIB9P_SUPER_MAGIC_V9FS_MAGIC;
+#endif
+#ifdef LIB9P_TAG_NOTAG
+ x = LIB9P_TAG_NOTAG;
+#endif
+#ifdef LIB9P_TMSG_MAX_COPY
+ x = LIB9P_TMSG_MAX_COPY;
+#endif
+#ifdef LIB9P_TMSG_MAX_IOV
+ x = LIB9P_TMSG_MAX_IOV;
+#endif
+#ifdef _LIB9P_DM_PLAN9_MOUNT
+ x = _LIB9P_DM_PLAN9_MOUNT;
+#endif
+#ifdef _LIB9P_DM_UNUSED_10
+ x = _LIB9P_DM_UNUSED_10;
+#endif
+#ifdef _LIB9P_DM_UNUSED_11
+ x = _LIB9P_DM_UNUSED_11;
+#endif
+#ifdef _LIB9P_DM_UNUSED_12
+ x = _LIB9P_DM_UNUSED_12;
+#endif
+#ifdef _LIB9P_DM_UNUSED_13
+ x = _LIB9P_DM_UNUSED_13;
+#endif
+#ifdef _LIB9P_DM_UNUSED_14
+ x = _LIB9P_DM_UNUSED_14;
+#endif
+#ifdef _LIB9P_DM_UNUSED_15
+ x = _LIB9P_DM_UNUSED_15;
+#endif
+#ifdef _LIB9P_DM_UNUSED_16
+ x = _LIB9P_DM_UNUSED_16;
+#endif
+#ifdef _LIB9P_DM_UNUSED_17
+ x = _LIB9P_DM_UNUSED_17;
+#endif
+#ifdef _LIB9P_DM_UNUSED_22
+ x = _LIB9P_DM_UNUSED_22;
+#endif
+#ifdef _LIB9P_DM_UNUSED_24
+ x = _LIB9P_DM_UNUSED_24;
+#endif
+#ifdef _LIB9P_DM_UNUSED_25
+ x = _LIB9P_DM_UNUSED_25;
+#endif
+#ifdef _LIB9P_DM_UNUSED_9
+ x = _LIB9P_DM_UNUSED_9;
+#endif
+#ifdef _LIB9P_DT_WHITEOUT
+ x = _LIB9P_DT_WHITEOUT;
+#endif
+#ifdef _LIB9P_ENABLE_stat
+ x = _LIB9P_ENABLE_stat;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_14
+ x = _LIB9P_GETATTR_UNUSED_14;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_15
+ x = _LIB9P_GETATTR_UNUSED_15;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_16
+ x = _LIB9P_GETATTR_UNUSED_16;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_17
+ x = _LIB9P_GETATTR_UNUSED_17;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_18
+ x = _LIB9P_GETATTR_UNUSED_18;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_19
+ x = _LIB9P_GETATTR_UNUSED_19;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_20
+ x = _LIB9P_GETATTR_UNUSED_20;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_21
+ x = _LIB9P_GETATTR_UNUSED_21;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_22
+ x = _LIB9P_GETATTR_UNUSED_22;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_23
+ x = _LIB9P_GETATTR_UNUSED_23;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_24
+ x = _LIB9P_GETATTR_UNUSED_24;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_25
+ x = _LIB9P_GETATTR_UNUSED_25;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_26
+ x = _LIB9P_GETATTR_UNUSED_26;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_27
+ x = _LIB9P_GETATTR_UNUSED_27;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_28
+ x = _LIB9P_GETATTR_UNUSED_28;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_29
+ x = _LIB9P_GETATTR_UNUSED_29;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_30
+ x = _LIB9P_GETATTR_UNUSED_30;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_31
+ x = _LIB9P_GETATTR_UNUSED_31;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_32
+ x = _LIB9P_GETATTR_UNUSED_32;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_33
+ x = _LIB9P_GETATTR_UNUSED_33;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_34
+ x = _LIB9P_GETATTR_UNUSED_34;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_35
+ x = _LIB9P_GETATTR_UNUSED_35;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_36
+ x = _LIB9P_GETATTR_UNUSED_36;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_37
+ x = _LIB9P_GETATTR_UNUSED_37;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_38
+ x = _LIB9P_GETATTR_UNUSED_38;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_39
+ x = _LIB9P_GETATTR_UNUSED_39;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_40
+ x = _LIB9P_GETATTR_UNUSED_40;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_41
+ x = _LIB9P_GETATTR_UNUSED_41;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_42
+ x = _LIB9P_GETATTR_UNUSED_42;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_43
+ x = _LIB9P_GETATTR_UNUSED_43;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_44
+ x = _LIB9P_GETATTR_UNUSED_44;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_45
+ x = _LIB9P_GETATTR_UNUSED_45;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_46
+ x = _LIB9P_GETATTR_UNUSED_46;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_47
+ x = _LIB9P_GETATTR_UNUSED_47;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_48
+ x = _LIB9P_GETATTR_UNUSED_48;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_49
+ x = _LIB9P_GETATTR_UNUSED_49;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_50
+ x = _LIB9P_GETATTR_UNUSED_50;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_51
+ x = _LIB9P_GETATTR_UNUSED_51;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_52
+ x = _LIB9P_GETATTR_UNUSED_52;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_53
+ x = _LIB9P_GETATTR_UNUSED_53;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_54
+ x = _LIB9P_GETATTR_UNUSED_54;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_55
+ x = _LIB9P_GETATTR_UNUSED_55;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_56
+ x = _LIB9P_GETATTR_UNUSED_56;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_57
+ x = _LIB9P_GETATTR_UNUSED_57;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_58
+ x = _LIB9P_GETATTR_UNUSED_58;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_59
+ x = _LIB9P_GETATTR_UNUSED_59;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_60
+ x = _LIB9P_GETATTR_UNUSED_60;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_61
+ x = _LIB9P_GETATTR_UNUSED_61;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_62
+ x = _LIB9P_GETATTR_UNUSED_62;
+#endif
+#ifdef _LIB9P_GETATTR_UNUSED_63
+ x = _LIB9P_GETATTR_UNUSED_63;
+#endif
+#ifdef _LIB9P_LOCK_FLAGS_UNUSED_10
x = _LIB9P_LOCK_FLAGS_UNUSED_10;
- x = _LIB9P_LOCK_FLAGS_UNUSED_9;
- x = _LIB9P_LOCK_FLAGS_UNUSED_8;
- x = _LIB9P_LOCK_FLAGS_UNUSED_7;
- x = _LIB9P_LOCK_FLAGS_UNUSED_6;
- x = _LIB9P_LOCK_FLAGS_UNUSED_5;
- x = _LIB9P_LOCK_FLAGS_UNUSED_4;
- x = _LIB9P_LOCK_FLAGS_UNUSED_3;
+#endif
+#ifdef _LIB9P_LOCK_FLAGS_UNUSED_11
+ x = _LIB9P_LOCK_FLAGS_UNUSED_11;
+#endif
+#ifdef _LIB9P_LOCK_FLAGS_UNUSED_12
+ x = _LIB9P_LOCK_FLAGS_UNUSED_12;
+#endif
+#ifdef _LIB9P_LOCK_FLAGS_UNUSED_13
+ x = _LIB9P_LOCK_FLAGS_UNUSED_13;
+#endif
+#ifdef _LIB9P_LOCK_FLAGS_UNUSED_14
+ x = _LIB9P_LOCK_FLAGS_UNUSED_14;
+#endif
+#ifdef _LIB9P_LOCK_FLAGS_UNUSED_15
+ x = _LIB9P_LOCK_FLAGS_UNUSED_15;
+#endif
+#ifdef _LIB9P_LOCK_FLAGS_UNUSED_16
+ x = _LIB9P_LOCK_FLAGS_UNUSED_16;
+#endif
+#ifdef _LIB9P_LOCK_FLAGS_UNUSED_17
+ x = _LIB9P_LOCK_FLAGS_UNUSED_17;
+#endif
+#ifdef _LIB9P_LOCK_FLAGS_UNUSED_18
+ x = _LIB9P_LOCK_FLAGS_UNUSED_18;
+#endif
+#ifdef _LIB9P_LOCK_FLAGS_UNUSED_19
+ x = _LIB9P_LOCK_FLAGS_UNUSED_19;
+#endif
+#ifdef _LIB9P_LOCK_FLAGS_UNUSED_2
x = _LIB9P_LOCK_FLAGS_UNUSED_2;
- x = LIB9P_LOCK_FLAGS_RECLAIM;
- x = LIB9P_LOCK_FLAGS_BLOCK;
- x = LIB9P_LOCK_STATUS_SUCCESS;
- x = LIB9P_LOCK_STATUS_BLOCKED;
- x = LIB9P_LOCK_STATUS_ERROR;
- x = LIB9P_LOCK_STATUS_GRACE;
- x = LIB9P_TMSG_MAX_IOV;
- x = LIB9P_TMSG_MAX_IOV;
- x = LIB9P_TMSG_MAX_COPY;
- x = LIB9P_TMSG_MAX_COPY;
- x = LIB9P_TMSG_MAX_COPY;
- x = LIB9P_TMSG_MAX_COPY;
- x = LIB9P_TMSG_MAX_COPY;
- x = LIB9P_TMSG_MAX_COPY;
- x = LIB9P_RMSG_MAX_IOV;
- x = LIB9P_RMSG_MAX_IOV;
- x = LIB9P_RMSG_MAX_IOV;
- x = LIB9P_RMSG_MAX_COPY;
+#endif
+#ifdef _LIB9P_LOCK_FLAGS_UNUSED_20
+ x = _LIB9P_LOCK_FLAGS_UNUSED_20;
+#endif
+#ifdef _LIB9P_LOCK_FLAGS_UNUSED_21
+ x = _LIB9P_LOCK_FLAGS_UNUSED_21;
+#endif
+#ifdef _LIB9P_LOCK_FLAGS_UNUSED_22
+ x = _LIB9P_LOCK_FLAGS_UNUSED_22;
+#endif
+#ifdef _LIB9P_LOCK_FLAGS_UNUSED_23
+ x = _LIB9P_LOCK_FLAGS_UNUSED_23;
+#endif
+#ifdef _LIB9P_LOCK_FLAGS_UNUSED_24
+ x = _LIB9P_LOCK_FLAGS_UNUSED_24;
+#endif
+#ifdef _LIB9P_LOCK_FLAGS_UNUSED_25
+ x = _LIB9P_LOCK_FLAGS_UNUSED_25;
+#endif
+#ifdef _LIB9P_LOCK_FLAGS_UNUSED_26
+ x = _LIB9P_LOCK_FLAGS_UNUSED_26;
+#endif
+#ifdef _LIB9P_LOCK_FLAGS_UNUSED_27
+ x = _LIB9P_LOCK_FLAGS_UNUSED_27;
+#endif
+#ifdef _LIB9P_LOCK_FLAGS_UNUSED_28
+ x = _LIB9P_LOCK_FLAGS_UNUSED_28;
+#endif
+#ifdef _LIB9P_LOCK_FLAGS_UNUSED_29
+ x = _LIB9P_LOCK_FLAGS_UNUSED_29;
+#endif
+#ifdef _LIB9P_LOCK_FLAGS_UNUSED_3
+ x = _LIB9P_LOCK_FLAGS_UNUSED_3;
+#endif
+#ifdef _LIB9P_LOCK_FLAGS_UNUSED_30
+ x = _LIB9P_LOCK_FLAGS_UNUSED_30;
+#endif
+#ifdef _LIB9P_LOCK_FLAGS_UNUSED_31
+ x = _LIB9P_LOCK_FLAGS_UNUSED_31;
+#endif
+#ifdef _LIB9P_LOCK_FLAGS_UNUSED_4
+ x = _LIB9P_LOCK_FLAGS_UNUSED_4;
+#endif
+#ifdef _LIB9P_LOCK_FLAGS_UNUSED_5
+ x = _LIB9P_LOCK_FLAGS_UNUSED_5;
+#endif
+#ifdef _LIB9P_LOCK_FLAGS_UNUSED_6
+ x = _LIB9P_LOCK_FLAGS_UNUSED_6;
+#endif
+#ifdef _LIB9P_LOCK_FLAGS_UNUSED_7
+ x = _LIB9P_LOCK_FLAGS_UNUSED_7;
+#endif
+#ifdef _LIB9P_LOCK_FLAGS_UNUSED_8
+ x = _LIB9P_LOCK_FLAGS_UNUSED_8;
+#endif
+#ifdef _LIB9P_LOCK_FLAGS_UNUSED_9
+ x = _LIB9P_LOCK_FLAGS_UNUSED_9;
+#endif
+#ifdef _LIB9P_LO_UNUSED_2
+ x = _LIB9P_LO_UNUSED_2;
+#endif
+#ifdef _LIB9P_LO_UNUSED_21
+ x = _LIB9P_LO_UNUSED_21;
+#endif
+#ifdef _LIB9P_LO_UNUSED_22
+ x = _LIB9P_LO_UNUSED_22;
+#endif
+#ifdef _LIB9P_LO_UNUSED_23
+ x = _LIB9P_LO_UNUSED_23;
+#endif
+#ifdef _LIB9P_LO_UNUSED_24
+ x = _LIB9P_LO_UNUSED_24;
+#endif
+#ifdef _LIB9P_LO_UNUSED_25
+ x = _LIB9P_LO_UNUSED_25;
+#endif
+#ifdef _LIB9P_LO_UNUSED_26
+ x = _LIB9P_LO_UNUSED_26;
+#endif
+#ifdef _LIB9P_LO_UNUSED_27
+ x = _LIB9P_LO_UNUSED_27;
+#endif
+#ifdef _LIB9P_LO_UNUSED_28
+ x = _LIB9P_LO_UNUSED_28;
+#endif
+#ifdef _LIB9P_LO_UNUSED_29
+ x = _LIB9P_LO_UNUSED_29;
+#endif
+#ifdef _LIB9P_LO_UNUSED_3
+ x = _LIB9P_LO_UNUSED_3;
+#endif
+#ifdef _LIB9P_LO_UNUSED_30
+ x = _LIB9P_LO_UNUSED_30;
+#endif
+#ifdef _LIB9P_LO_UNUSED_31
+ x = _LIB9P_LO_UNUSED_31;
+#endif
+#ifdef _LIB9P_LO_UNUSED_4
+ x = _LIB9P_LO_UNUSED_4;
+#endif
+#ifdef _LIB9P_LO_UNUSED_5
+ x = _LIB9P_LO_UNUSED_5;
+#endif
+#ifdef _LIB9P_MODE_UNUSED_16
+ x = _LIB9P_MODE_UNUSED_16;
+#endif
+#ifdef _LIB9P_MODE_UNUSED_17
+ x = _LIB9P_MODE_UNUSED_17;
+#endif
+#ifdef _LIB9P_MODE_UNUSED_18
+ x = _LIB9P_MODE_UNUSED_18;
+#endif
+#ifdef _LIB9P_MODE_UNUSED_19
+ x = _LIB9P_MODE_UNUSED_19;
+#endif
+#ifdef _LIB9P_MODE_UNUSED_20
+ x = _LIB9P_MODE_UNUSED_20;
+#endif
+#ifdef _LIB9P_MODE_UNUSED_21
+ x = _LIB9P_MODE_UNUSED_21;
+#endif
+#ifdef _LIB9P_MODE_UNUSED_22
+ x = _LIB9P_MODE_UNUSED_22;
+#endif
+#ifdef _LIB9P_MODE_UNUSED_23
+ x = _LIB9P_MODE_UNUSED_23;
+#endif
+#ifdef _LIB9P_MODE_UNUSED_24
+ x = _LIB9P_MODE_UNUSED_24;
+#endif
+#ifdef _LIB9P_MODE_UNUSED_25
+ x = _LIB9P_MODE_UNUSED_25;
+#endif
+#ifdef _LIB9P_MODE_UNUSED_26
+ x = _LIB9P_MODE_UNUSED_26;
+#endif
+#ifdef _LIB9P_MODE_UNUSED_27
+ x = _LIB9P_MODE_UNUSED_27;
+#endif
+#ifdef _LIB9P_MODE_UNUSED_28
+ x = _LIB9P_MODE_UNUSED_28;
+#endif
+#ifdef _LIB9P_MODE_UNUSED_29
+ x = _LIB9P_MODE_UNUSED_29;
+#endif
+#ifdef _LIB9P_MODE_UNUSED_30
+ x = _LIB9P_MODE_UNUSED_30;
+#endif
+#ifdef _LIB9P_MODE_UNUSED_31
+ x = _LIB9P_MODE_UNUSED_31;
+#endif
+#ifdef _LIB9P_O_RESERVED_CEXEC
+ x = _LIB9P_O_RESERVED_CEXEC;
+#endif
+#ifdef _LIB9P_O_UNUSED_2
+ x = _LIB9P_O_UNUSED_2;
+#endif
+#ifdef _LIB9P_O_UNUSED_3
+ x = _LIB9P_O_UNUSED_3;
+#endif
+#ifdef _LIB9P_O_UNUSED_7
+ x = _LIB9P_O_UNUSED_7;
+#endif
+#ifdef _LIB9P_QT_PLAN9_MOUNT
+ x = _LIB9P_QT_PLAN9_MOUNT;
+#endif
+#ifdef _LIB9P_QT_UNUSED_0
+ x = _LIB9P_QT_UNUSED_0;
+#endif
+#ifdef _LIB9P_SETATTR_UNUSED_10
+ x = _LIB9P_SETATTR_UNUSED_10;
+#endif
+#ifdef _LIB9P_SETATTR_UNUSED_11
+ x = _LIB9P_SETATTR_UNUSED_11;
+#endif
+#ifdef _LIB9P_SETATTR_UNUSED_12
+ x = _LIB9P_SETATTR_UNUSED_12;
+#endif
+#ifdef _LIB9P_SETATTR_UNUSED_13
+ x = _LIB9P_SETATTR_UNUSED_13;
+#endif
+#ifdef _LIB9P_SETATTR_UNUSED_14
+ x = _LIB9P_SETATTR_UNUSED_14;
+#endif
+#ifdef _LIB9P_SETATTR_UNUSED_15
+ x = _LIB9P_SETATTR_UNUSED_15;
+#endif
+#ifdef _LIB9P_SETATTR_UNUSED_16
+ x = _LIB9P_SETATTR_UNUSED_16;
+#endif
+#ifdef _LIB9P_SETATTR_UNUSED_17
+ x = _LIB9P_SETATTR_UNUSED_17;
+#endif
+#ifdef _LIB9P_SETATTR_UNUSED_18
+ x = _LIB9P_SETATTR_UNUSED_18;
+#endif
+#ifdef _LIB9P_SETATTR_UNUSED_19
+ x = _LIB9P_SETATTR_UNUSED_19;
+#endif
+#ifdef _LIB9P_SETATTR_UNUSED_20
+ x = _LIB9P_SETATTR_UNUSED_20;
+#endif
+#ifdef _LIB9P_SETATTR_UNUSED_21
+ x = _LIB9P_SETATTR_UNUSED_21;
+#endif
+#ifdef _LIB9P_SETATTR_UNUSED_22
+ x = _LIB9P_SETATTR_UNUSED_22;
+#endif
+#ifdef _LIB9P_SETATTR_UNUSED_23
+ x = _LIB9P_SETATTR_UNUSED_23;
+#endif
+#ifdef _LIB9P_SETATTR_UNUSED_24
+ x = _LIB9P_SETATTR_UNUSED_24;
+#endif
+#ifdef _LIB9P_SETATTR_UNUSED_25
+ x = _LIB9P_SETATTR_UNUSED_25;
+#endif
+#ifdef _LIB9P_SETATTR_UNUSED_26
+ x = _LIB9P_SETATTR_UNUSED_26;
+#endif
+#ifdef _LIB9P_SETATTR_UNUSED_27
+ x = _LIB9P_SETATTR_UNUSED_27;
+#endif
+#ifdef _LIB9P_SETATTR_UNUSED_28
+ x = _LIB9P_SETATTR_UNUSED_28;
+#endif
+#ifdef _LIB9P_SETATTR_UNUSED_29
+ x = _LIB9P_SETATTR_UNUSED_29;
+#endif
+#ifdef _LIB9P_SETATTR_UNUSED_30
+ x = _LIB9P_SETATTR_UNUSED_30;
+#endif
+#ifdef _LIB9P_SETATTR_UNUSED_31
+ x = _LIB9P_SETATTR_UNUSED_31;
+#endif
+#ifdef _LIB9P_SETATTR_UNUSED_9
+ x = _LIB9P_SETATTR_UNUSED_9;
+#endif
return 0;
}
diff --git a/lib9p/tests/test_compile.c.gen b/lib9p/tests/test_compile.c.gen
index 1289943..eb89c54 100755
--- a/lib9p/tests/test_compile.c.gen
+++ b/lib9p/tests/test_compile.c.gen
@@ -13,7 +13,7 @@ outfile=$2
echo "#include <lib9p/core.h>"
echo 'int main(void) {'
echo ' [[gnu::unused]] uint64_t x;'
- sed -nE 's/^\s*#\s*define\s*(\S[^ (]*)\s.*/ x = \1;/p' <"$generated_h"
+ <"$generated_h" sed -nE 's/^\s*#\s*define\s*(\S[^ (]*)\s.*/\1/p' | LC_COLLATE=C sort -u | sed 's/.*/#ifdef &\n x = &;\n#endif/'
echo ' return 0;'
echo '}'
} >"$outfile"
diff --git a/lib9p/tests/test_compile_config/config.h b/lib9p/tests/test_compile_config/config.h
index f899dfa..02cb8e5 100644
--- a/lib9p/tests/test_compile_config/config.h
+++ b/lib9p/tests/test_compile_config/config.h
@@ -7,13 +7,25 @@
#ifndef _CONFIG_H_
#define _CONFIG_H_
+/* 9P *************************************************************************/
+
#define CONFIG_9P_MAX_ERR_SIZE 128
#define CONFIG_9P_MAX_9P2000_e_WELEM 16
-#define CONFIG_9P_ENABLE_9P2000 1 /* bool */
-#define CONFIG_9P_ENABLE_9P2000_u 1 /* bool */
-#define CONFIG_9P_ENABLE_9P2000_e 1 /* bool */
-#define CONFIG_9P_ENABLE_9P2000_L 1 /* bool */
-#define CONFIG_9P_ENABLE_9P2000_p9p 1 /* bool */
+/* 9P_SRV *********************************************************************/
+
+#define CONFIG_9P_SRV_MAX_MSG_SIZE ((4*1024)+24)
+#define CONFIG_9P_SRV_MAX_HOSTMSG_SIZE CONFIG_9P_SRV_MAX_MSG_SIZE+16
+
+/* COROUTINE ******************************************************************/
+
+#define CONFIG_COROUTINE_STACK_SIZE_DEFAULT (32*1024)
+#define CONFIG_COROUTINE_NAME_LEN 16
+#define CONFIG_COROUTINE_MEASURE_STACK 1 /* bool */
+#define CONFIG_COROUTINE_PROTECT_STACK 1 /* bool */
+#define CONFIG_COROUTINE_DEBUG 0 /* bool */
+#define CONFIG_COROUTINE_VALGRIND 1 /* bool */
+#define CONFIG_COROUTINE_GDB 1 /* bool */
+#define CONFIG_COROUTINE_NUM 8
#endif /* _CONFIG_H_ */
diff --git a/lib9p/tests/test_server/fs_flush.c b/lib9p/tests/test_server/fs_flush.c
index 779eb91..e6408d7 100644
--- a/lib9p/tests/test_server/fs_flush.c
+++ b/lib9p/tests/test_server/fs_flush.c
@@ -31,28 +31,23 @@ static struct lib9p_qid flush_file_qid(struct flush_file *self) {
};
}
-static struct lib9p_stat flush_file_stat(struct flush_file *self, struct lib9p_srv_ctx *ctx) {
+static struct lib9p_srv_stat flush_file_stat(struct flush_file *self, struct lib9p_srv_ctx *ctx) {
assert(self);
assert(ctx);
- return (struct lib9p_stat){
- .kern_type = 0,
- .kern_dev = 0,
- .file_qid = flush_file_qid(self),
- .file_mode = 0444,
- .file_atime = UTIL9P_ATIME,
- .file_mtime = UTIL9P_MTIME,
- .file_size = 6,
- .file_name = lib9p_str(self->name),
- .file_owner_uid = lib9p_str("root"),
- .file_owner_gid = lib9p_str("root"),
- .file_last_modified_uid = lib9p_str("root"),
- .file_extension = lib9p_str(NULL),
- .file_owner_n_uid = 0,
- .file_owner_n_gid = 0,
- .file_last_modified_n_uid = 0,
+ return (struct lib9p_srv_stat){
+ .qid = flush_file_qid(self),
+ .mode = 0444,
+ .atime_sec = UTIL9P_ATIME,
+ .mtime_sec = UTIL9P_MTIME,
+ .size = 6,
+ .name = lib9p_str(self->name),
+ .owner_uid = { .name = lib9p_str("root"), .num = 0 },
+ .owner_gid = { .name = lib9p_str("root"), .num = 0 },
+ .last_modifier_uid = { .name = lib9p_str("root"), .num = 0 },
+ .extension = lib9p_str(NULL),
};
}
-static void flush_file_wstat(struct flush_file *self, struct lib9p_srv_ctx *ctx, struct lib9p_stat) {
+static void flush_file_wstat(struct flush_file *self, struct lib9p_srv_ctx *ctx, struct lib9p_srv_stat) {
assert(self);
assert(ctx);
lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EROFS, "cannot wstat API file");
diff --git a/lib9p/tests/test_server/fs_shutdown.c b/lib9p/tests/test_server/fs_shutdown.c
index e7375ef..d4ae67e 100644
--- a/lib9p/tests/test_server/fs_shutdown.c
+++ b/lib9p/tests/test_server/fs_shutdown.c
@@ -24,34 +24,29 @@ static void shutdown_file_free(struct shutdown_file *self) {
static struct lib9p_qid shutdown_file_qid(struct shutdown_file *self) {
assert(self);
return (struct lib9p_qid){
- .type = LIB9P_QT_FILE,
+ .type = LIB9P_QT_FILE | LIB9P_QT_APPEND,
.vers = 1,
.path = self->pathnum,
};
}
-static struct lib9p_stat shutdown_file_stat(struct shutdown_file *self, struct lib9p_srv_ctx *ctx) {
+static struct lib9p_srv_stat shutdown_file_stat(struct shutdown_file *self, struct lib9p_srv_ctx *ctx) {
assert(self);
assert(ctx);
- return (struct lib9p_stat){
- .kern_type = 0,
- .kern_dev = 0,
- .file_qid = shutdown_file_qid(self),
- .file_mode = 0222,
- .file_atime = UTIL9P_ATIME,
- .file_mtime = UTIL9P_MTIME,
- .file_size = 0,
- .file_name = lib9p_str(self->name),
- .file_owner_uid = lib9p_str("root"),
- .file_owner_gid = lib9p_str("root"),
- .file_last_modified_uid = lib9p_str("root"),
- .file_extension = lib9p_str(NULL),
- .file_owner_n_uid = 0,
- .file_owner_n_gid = 0,
- .file_last_modified_n_uid = 0,
+ return (struct lib9p_srv_stat){
+ .qid = shutdown_file_qid(self),
+ .mode = 0222 | LIB9P_DM_APPEND,
+ .atime_sec = UTIL9P_ATIME,
+ .mtime_sec = UTIL9P_MTIME,
+ .size = 0,
+ .name = lib9p_str(self->name),
+ .owner_uid = { .name=lib9p_str("root"), .num=0 },
+ .owner_gid = { .name=lib9p_str("root"), .num=0 },
+ .last_modifier_uid = { .name=lib9p_str("root"), .num=0 },
+ .extension = lib9p_str(NULL),
};
}
-static void shutdown_file_wstat(struct shutdown_file *self, struct lib9p_srv_ctx *ctx, struct lib9p_stat) {
+static void shutdown_file_wstat(struct shutdown_file *self, struct lib9p_srv_ctx *ctx, struct lib9p_srv_stat) {
assert(self);
assert(ctx);
lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EROFS, "cannot wstat API file");
@@ -91,10 +86,11 @@ static uint32_t shutdown_fio_iounit(struct shutdown_fio *self) {
return 0;
}
-static uint32_t shutdown_fio_pwrite(struct shutdown_fio *self, struct lib9p_srv_ctx *ctx, void *buf, uint32_t byte_count, uint64_t LM_UNUSED(offset)) {
+static uint32_t shutdown_fio_pwrite(struct shutdown_fio *self, struct lib9p_srv_ctx *ctx, void *buf, uint32_t byte_count, uint64_t offset) {
assert(self);
assert(ctx);
assert(buf);
+ assert(offset == 0);
if (byte_count == 0)
return 0;
for (size_t i = 0; i < self->parent->nlisteners; i++)
diff --git a/lib9p/tests/test_server/fs_whoami.c b/lib9p/tests/test_server/fs_whoami.c
index 653ac4b..8d9752a 100644
--- a/lib9p/tests/test_server/fs_whoami.c
+++ b/lib9p/tests/test_server/fs_whoami.c
@@ -23,10 +23,10 @@ LO_IMPLEMENTATION_C(lib9p_srv_fio, struct whoami_fio, whoami_fio, static);
size_t whoami_len(struct lib9p_srv_ctx *ctx) {
assert(ctx);
- assert(ctx->authinfo);
+ assert(ctx->user);
size_t len = 0;
- uint32_t uid = ctx->authinfo->uid;
+ uint32_t uid = ctx->user->num;
while (uid) {
len++;
uid /= 10;
@@ -34,7 +34,7 @@ size_t whoami_len(struct lib9p_srv_ctx *ctx) {
if (!len)
len++;
len += 2;
- len += ctx->authinfo->uname.len;
+ len += ctx->user->name.len;
return len;
}
@@ -52,29 +52,24 @@ static struct lib9p_qid whoami_file_qid(struct whoami_file *self) {
};
}
-static struct lib9p_stat whoami_file_stat(struct whoami_file *self, struct lib9p_srv_ctx *ctx) {
+static struct lib9p_srv_stat whoami_file_stat(struct whoami_file *self, struct lib9p_srv_ctx *ctx) {
assert(self);
assert(ctx);
- return (struct lib9p_stat){
- .kern_type = 0,
- .kern_dev = 0,
- .file_qid = whoami_file_qid(self),
- .file_mode = 0444,
- .file_atime = UTIL9P_ATIME,
- .file_mtime = UTIL9P_MTIME,
- .file_size = whoami_len(ctx),
- .file_name = lib9p_str(self->name),
- .file_owner_uid = lib9p_str("root"),
- .file_owner_gid = lib9p_str("root"),
- .file_last_modified_uid = lib9p_str("root"),
- .file_extension = lib9p_str(NULL),
- .file_owner_n_uid = 0,
- .file_owner_n_gid = 0,
- .file_last_modified_n_uid = 0,
+ return (struct lib9p_srv_stat){
+ .qid = whoami_file_qid(self),
+ .mode = 0444,
+ .atime_sec = UTIL9P_ATIME,
+ .mtime_sec = UTIL9P_MTIME,
+ .size = whoami_len(ctx),
+ .name = lib9p_str(self->name),
+ .owner_uid = { .name=lib9p_str("root"), .num=0 },
+ .owner_gid = { .name=lib9p_str("root"), .num=0 },
+ .last_modifier_uid = { .name=lib9p_str("root"), .num=0 },
+ .extension = lib9p_str(NULL),
};
}
-static void whoami_file_wstat(struct whoami_file *self, struct lib9p_srv_ctx *ctx, struct lib9p_stat) {
+static void whoami_file_wstat(struct whoami_file *self, struct lib9p_srv_ctx *ctx, struct lib9p_srv_stat) {
assert(self);
assert(ctx);
lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EROFS, "cannot wstat API file");
@@ -138,7 +133,7 @@ static void whoami_fio_pread(struct whoami_fio *self, struct lib9p_srv_ctx *ctx,
self->buf_len = data_size+1;
}
snprintf(self->buf, self->buf_len, "%"PRIu32" %.*s\n",
- ctx->authinfo->uid, ctx->authinfo->uname.len, ctx->authinfo->uname.utf8);
+ ctx->user->num, ctx->user->name.len, ctx->user->name.utf8);
if (byte_offset > (uint64_t)data_size) {
lib9p_error(&ctx->basectx,
diff --git a/lib9p/tests/testclient-p9p b/lib9p/tests/testclient-p9p
index 9c9f9f2..09ce746 100755
--- a/lib9p/tests/testclient-p9p
+++ b/lib9p/tests/testclient-p9p
@@ -30,7 +30,7 @@ expect_lines \
'--r--r--r-- M 0 root root 6 Oct 7 2024 flush-silent' \
'--r--r--r-- M 0 root root 6 Oct 7 2024 flush-slowread' \
'--r--r--r-- M 0 root root 6 Oct 7 2024 flush-slowsilent' \
- '---w--w--w- M 0 root root 0 Oct 7 2024 shutdown' \
+ 'a--w--w--w- M 0 root root 0 Oct 7 2024 shutdown' \
'--r--r--r-- M 0 root root 9 Oct 7 2024 whoami'
out=$("${client[@]}" ls -l 'Documentation/')
diff --git a/lib9p/tests/testclient-p9p.explog b/lib9p/tests/testclient-p9p.explog
index 7f3953d..54f1e4b 100644
--- a/lib9p/tests/testclient-p9p.explog
+++ b/lib9p/tests/testclient-p9p.explog
@@ -4,14 +4,14 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
> Tversion { tag=NOTAG max_msg_size=8192 version="9P2000" }
< Rversion { tag=NOTAG max_msg_size=4120 version="9P2000" }
-> Tauth { tag=0 afid=0 uname="nobody" aname="" n_uid=0 }
+> Tauth { tag=0 afid=0 uname="nobody" aname="" unum=0 }
< Rerror { tag=0 errstr="authentication not required" errnum=L_EOPNOTSUPP }
-> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" n_uid=0 }
+> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" unum=0 }
< Rattach { tag=0 qid={ type=(DIR) vers=1 path=1 } }
> Twalk { tag=0 fid=0 newfid=1 nwname=0 wname=[ ] }
< Rwalk { tag=0 nwqid=0 wqid=[ ] }
> Tstat { tag=0 fid=1 }
-< Rstat { tag=0 stat={ kern_type=0 kern_dev=0 file_qid={ type=(DIR) vers=1 path=1 } file_mode=(DIR|0555) file_atime=1728337905 file_mtime=1728337904 file_size=0 file_name="" file_owner_uid="root" file_owner_gid="root" file_last_modified_uid="root" file_extension="" file_owner_n_uid=0 file_owner_n_gid=0 file_last_modified_n_uid=0 } }
+< Rstat { tag=0 stat={ fstype=0 fsdev=0 qid={ type=(DIR) vers=1 path=1 } mode=(DIR|0555) atime=1728337905 mtime=1728337904 length=0 name="" owner_uname="root" owner_gname="root" last_modifier_uname="root" extension="" owner_unum=0 owner_gnum=0 last_modifier_unum=0 } }
> Tclunk { tag=0 fid=1 }
< Rclunk { tag=0 }
> Twalk { tag=0 fid=0 newfid=1 nwname=0 wname=[ ] }
@@ -26,14 +26,14 @@
< Rclunk { tag=0 }
> Tversion { tag=NOTAG max_msg_size=8192 version="9P2000" }
< Rversion { tag=NOTAG max_msg_size=4120 version="9P2000" }
-> Tauth { tag=0 afid=0 uname="nobody" aname="" n_uid=0 }
+> Tauth { tag=0 afid=0 uname="nobody" aname="" unum=0 }
< Rerror { tag=0 errstr="authentication not required" errnum=L_EOPNOTSUPP }
-> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" n_uid=0 }
+> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" unum=0 }
< Rattach { tag=0 qid={ type=(DIR) vers=1 path=1 } }
> Twalk { tag=0 fid=0 newfid=1 nwname=1 wname=[ "Documentation" ] }
< Rwalk { tag=0 nwqid=1 wqid=[ { type=(DIR) vers=1 path=2 } ] }
> Tstat { tag=0 fid=1 }
-< Rstat { tag=0 stat={ kern_type=0 kern_dev=0 file_qid={ type=(DIR) vers=1 path=2 } file_mode=(DIR|0555) file_atime=1728337905 file_mtime=1728337904 file_size=0 file_name="Documentation" file_owner_uid="root" file_owner_gid="root" file_last_modified_uid="root" file_extension="" file_owner_n_uid=0 file_owner_n_gid=0 file_last_modified_n_uid=0 } }
+< Rstat { tag=0 stat={ fstype=0 fsdev=0 qid={ type=(DIR) vers=1 path=2 } mode=(DIR|0555) atime=1728337905 mtime=1728337904 length=0 name="Documentation" owner_uname="root" owner_gname="root" last_modifier_uname="root" extension="" owner_unum=0 owner_gnum=0 last_modifier_unum=0 } }
> Tclunk { tag=0 fid=1 }
< Rclunk { tag=0 }
> Twalk { tag=0 fid=0 newfid=1 nwname=1 wname=[ "Documentation" ] }
@@ -48,9 +48,9 @@
< Rclunk { tag=0 }
> Tversion { tag=NOTAG max_msg_size=8192 version="9P2000" }
< Rversion { tag=NOTAG max_msg_size=4120 version="9P2000" }
-> Tauth { tag=0 afid=0 uname="nobody" aname="" n_uid=0 }
+> Tauth { tag=0 afid=0 uname="nobody" aname="" unum=0 }
< Rerror { tag=0 errstr="authentication not required" errnum=L_EOPNOTSUPP }
-> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" n_uid=0 }
+> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" unum=0 }
< Rattach { tag=0 qid={ type=(DIR) vers=1 path=1 } }
> Twalk { tag=0 fid=0 newfid=1 nwname=1 wname=[ "README.md" ] }
< Rwalk { tag=0 nwqid=1 wqid=[ { type=(0) vers=1 path=4 } ] }
@@ -64,9 +64,9 @@
< Rclunk { tag=0 }
> Tversion { tag=NOTAG max_msg_size=8192 version="9P2000" }
< Rversion { tag=NOTAG max_msg_size=4120 version="9P2000" }
-> Tauth { tag=0 afid=0 uname="nobody" aname="" n_uid=0 }
+> Tauth { tag=0 afid=0 uname="nobody" aname="" unum=0 }
< Rerror { tag=0 errstr="authentication not required" errnum=L_EOPNOTSUPP }
-> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" n_uid=0 }
+> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" unum=0 }
< Rattach { tag=0 qid={ type=(DIR) vers=1 path=1 } }
> Twalk { tag=0 fid=0 newfid=1 nwname=2 wname=[ "Documentation", "x" ] }
< Rwalk { tag=0 nwqid=2 wqid=[ { type=(DIR) vers=1 path=2 }, { type=(0) vers=1 path=3 } ] }
@@ -80,26 +80,26 @@
< Rclunk { tag=0 }
> Tversion { tag=NOTAG max_msg_size=8192 version="9P2000" }
< Rversion { tag=NOTAG max_msg_size=4120 version="9P2000" }
-> Tauth { tag=0 afid=0 uname="nobody" aname="" n_uid=0 }
+> Tauth { tag=0 afid=0 uname="nobody" aname="" unum=0 }
< Rerror { tag=0 errstr="authentication not required" errnum=L_EOPNOTSUPP }
-> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" n_uid=0 }
+> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" unum=0 }
< Rattach { tag=0 qid={ type=(DIR) vers=1 path=1 } }
> Twalk { tag=0 fid=0 newfid=1 nwname=2 wname=[ "Documentation", "x" ] }
< Rwalk { tag=0 nwqid=2 wqid=[ { type=(DIR) vers=1 path=2 }, { type=(0) vers=1 path=3 } ] }
> Tstat { tag=0 fid=1 }
-< Rstat { tag=0 stat={ kern_type=0 kern_dev=0 file_qid={ type=(0) vers=1 path=3 } file_mode=(0444) file_atime=1728337905 file_mtime=1728337904 file_size=166 file_name="x" file_owner_uid="root" file_owner_gid="root" file_last_modified_uid="root" file_extension="" file_owner_n_uid=0 file_owner_n_gid=0 file_last_modified_n_uid=0 } }
+< Rstat { tag=0 stat={ fstype=0 fsdev=0 qid={ type=(0) vers=1 path=3 } mode=(0444) atime=1728337905 mtime=1728337904 length=166 name="x" owner_uname="root" owner_gname="root" last_modifier_uname="root" extension="" owner_unum=0 owner_gnum=0 last_modifier_unum=0 } }
> Tclunk { tag=0 fid=1 }
< Rclunk { tag=0 }
> Tversion { tag=NOTAG max_msg_size=8192 version="9P2000" }
< Rversion { tag=NOTAG max_msg_size=4120 version="9P2000" }
-> Tauth { tag=0 afid=0 uname="nobody" aname="" n_uid=0 }
+> Tauth { tag=0 afid=0 uname="nobody" aname="" unum=0 }
< Rerror { tag=0 errstr="authentication not required" errnum=L_EOPNOTSUPP }
-> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" n_uid=0 }
+> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" unum=0 }
< Rattach { tag=0 qid={ type=(DIR) vers=1 path=1 } }
> Twalk { tag=0 fid=0 newfid=1 nwname=1 wname=[ "shutdown" ] }
-< Rwalk { tag=0 nwqid=1 wqid=[ { type=(0) vers=1 path=5 } ] }
+< Rwalk { tag=0 nwqid=1 wqid=[ { type=(APPEND) vers=1 path=5 } ] }
> Topen { tag=0 fid=1 mode=(TRUNC|MODE_WRITE) }
-< Ropen { tag=0 qid={ type=(0) vers=1 path=5 } iounit=0 }
+< Ropen { tag=0 qid={ type=(APPEND) vers=1 path=5 } iounit=0 }
> Twrite { tag=0 fid=1 offset=0 count=2 data="1\n" }
< Rwrite { tag=0 count=2 }
> Tclunk { tag=0 fid=1 }
diff --git a/lib9p/tests/testclient-sess.c b/lib9p/tests/testclient-sess.c
index 561c0c9..7cb7f97 100644
--- a/lib9p/tests/testclient-sess.c
+++ b/lib9p/tests/testclient-sess.c
@@ -95,9 +95,9 @@ int main(int argc, char *argv[]) {
send9p(Tversion, .tag=0, .max_msg_size=(8*1024), .version=lib9p_str("9P2000.u"));
recv9p(); /* Rversion */
ctx.version = LIB9P_VER_9P2000_u;
- send9p(Tattach, .tag=0, .fid=0, .afid=LIB9P_FID_NOFID, .uname=lib9p_str("alice"), .n_uid=1000, .aname=lib9p_str(""));
+ send9p(Tattach, .tag=0, .fid=0, .afid=LIB9P_FID_NOFID, .uname=lib9p_str("alice"), .unum=1000, .aname=lib9p_str(""));
recv9p(); /* Rattach */
- send9p(Tattach, .tag=0, .fid=1, .afid=LIB9P_FID_NOFID, .uname=lib9p_str("bob"), .n_uid=1001, .aname=lib9p_str(""));
+ send9p(Tattach, .tag=0, .fid=1, .afid=LIB9P_FID_NOFID, .uname=lib9p_str("bob"), .unum=1001, .aname=lib9p_str(""));
recv9p(); /* Rattach */
wname[0] = lib9p_str("whoami"); send9p(Twalk, .tag=0, .fid=0, .newfid=2, .nwname=1, .wname=wname);
recv9p(); /* Rwalk */
diff --git a/lib9p/tests/testclient-sess.explog b/lib9p/tests/testclient-sess.explog
index 74a2cd7..a3838ac 100644
--- a/lib9p/tests/testclient-sess.explog
+++ b/lib9p/tests/testclient-sess.explog
@@ -14,9 +14,9 @@
# ext version, users ###########################################################
> Tversion { tag=0 max_msg_size=8192 version="9P2000.u" }
< Rversion { tag=0 max_msg_size=4120 version="9P2000.u" }
-> Tattach { tag=0 fid=0 afid=NOFID uname="alice" aname="" n_uid=1000 }
+> Tattach { tag=0 fid=0 afid=NOFID uname="alice" aname="" unum=1000 }
< Rattach { tag=0 qid={ type=(DIR) vers=1 path=1 } }
-> Tattach { tag=0 fid=1 afid=NOFID uname="bob" aname="" n_uid=1001 }
+> Tattach { tag=0 fid=1 afid=NOFID uname="bob" aname="" unum=1001 }
< Rattach { tag=0 qid={ type=(DIR) vers=1 path=1 } }
> Twalk { tag=0 fid=0 newfid=2 nwname=1 wname=[ "whoami" ] }
< Rwalk { tag=0 nwqid=1 wqid=[ { type=(0) vers=1 path=8 } ] }
@@ -34,7 +34,7 @@
# walk #########################################################################
> Tversion { tag=0 max_msg_size=8192 version="9P2000" }
< Rversion { tag=0 max_msg_size=4120 version="9P2000" }
-> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" n_uid=0 }
+> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" unum=0 }
< Rattach { tag=0 qid={ type=(DIR) vers=1 path=1 } }
# dup
@@ -83,7 +83,7 @@
# flush ########################################################################
> Tversion { tag=0 max_msg_size=8192 version="9P2000" }
< Rversion { tag=0 max_msg_size=4120 version="9P2000" }
-> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" n_uid=0 }
+> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" unum=0 }
< Rattach { tag=0 qid={ type=(DIR) vers=1 path=1 } }
# flush, but original response comes back first
@@ -146,11 +146,11 @@
# shutdown #####################################################################
> Tversion { tag=0 max_msg_size=8192 version="9P2000" }
< Rversion { tag=0 max_msg_size=4120 version="9P2000" }
-> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" n_uid=0 }
+> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" unum=0 }
< Rattach { tag=0 qid={ type=(DIR) vers=1 path=1 } }
> Twalk { tag=0 fid=0 newfid=0 nwname=1 wname=[ "shutdown" ] }
-< Rwalk { tag=0 nwqid=1 wqid=[ { type=(0) vers=1 path=5 } ] }
+< Rwalk { tag=0 nwqid=1 wqid=[ { type=(APPEND) vers=1 path=5 } ] }
> Topen { tag=0 fid=0 mode=(MODE_WRITE) }
-< Ropen { tag=0 qid={ type=(0) vers=1 path=5 } iounit=0 }
+< Ropen { tag=0 qid={ type=(APPEND) vers=1 path=5 } iounit=0 }
> Twrite { tag=0 fid=0 offset=0 count=2 data="1\n" }
< Rwrite { tag=0 count=2 }
diff --git a/lib9p_util/static.c b/lib9p_util/static.c
index 4fba35a..1726319 100644
--- a/lib9p_util/static.c
+++ b/lib9p_util/static.c
@@ -33,30 +33,25 @@ static struct lib9p_qid util9p_static_dir_qid(struct util9p_static_dir *self) {
};
}
-static struct lib9p_stat util9p_static_dir_stat(struct util9p_static_dir *self, struct lib9p_srv_ctx *ctx) {
+static struct lib9p_srv_stat util9p_static_dir_stat(struct util9p_static_dir *self, struct lib9p_srv_ctx *ctx) {
assert(self);
assert(ctx);
- return (struct lib9p_stat){
- .kern_type = 0,
- .kern_dev = 0,
- .file_qid = util9p_static_dir_qid(self),
- .file_mode = LIB9P_DM_DIR | (self->perm & 0555),
- .file_atime = self->atime,
- .file_mtime = self->mtime,
- .file_size = 0,
- .file_name = lib9p_str(self->name),
- .file_owner_uid = lib9p_str(self->u_name),
- .file_owner_gid = lib9p_str(self->g_name),
- .file_last_modified_uid = lib9p_str(self->m_name),
- .file_extension = lib9p_str(NULL),
- .file_owner_n_uid = self->u_num,
- .file_owner_n_gid = self->g_num,
- .file_last_modified_n_uid = self->m_num,
+ return (struct lib9p_srv_stat){
+ .qid = util9p_static_dir_qid(self),
+ .mode = LIB9P_DM_DIR | (self->perm & 0555),
+ .atime_sec = self->atime,
+ .mtime_sec = self->mtime,
+ .size = 0,
+ .name = lib9p_str(self->name),
+ .owner_uid = { .name = lib9p_str(self->u_name), .num = self->u_num },
+ .owner_gid = { .name = lib9p_str(self->g_name), .num = self->g_num },
+ .last_modifier_uid = { .name = lib9p_str(self->m_name), .num = self->m_num },
+ .extension = lib9p_str(NULL),
};
}
static void util9p_static_dir_wstat(struct util9p_static_dir *self, struct lib9p_srv_ctx *ctx,
- struct lib9p_stat) {
+ struct lib9p_srv_stat) {
assert(self);
assert(ctx);
@@ -76,11 +71,11 @@ static lo_interface lib9p_srv_file util9p_static_dir_dwalk(struct util9p_static_
for (size_t i = 0; !LO_IS_NULL(self->members[i]); i++) {
lo_interface lib9p_srv_file file = self->members[i];
- struct lib9p_stat stat = LO_CALL(file, stat, ctx);
+ struct lib9p_srv_stat stat = LO_CALL(file, stat, ctx);
if (lib9p_ctx_has_error(&ctx->basectx))
break;
- lib9p_stat_assert(stat);
- if (lib9p_str_eq(stat.file_name, childname))
+ lib9p_srv_stat_assert(stat);
+ if (lib9p_str_eq(stat.name, childname))
return file;
}
lib9p_error(&ctx->basectx,
@@ -90,7 +85,9 @@ static lo_interface lib9p_srv_file util9p_static_dir_dwalk(struct util9p_static_
static lo_interface lib9p_srv_file util9p_static_dir_dcreate(struct util9p_static_dir *self, struct lib9p_srv_ctx *ctx,
struct lib9p_s LM_UNUSED(childname),
- lib9p_dm_t LM_UNUSED(perm), lib9p_o_t LM_UNUSED(flags)) {
+ struct lib9p_srv_userid *LM_UNUSED(user),
+ struct lib9p_srv_userid *LM_UNUSED(group),
+ lib9p_dm_t LM_UNUSED(perm)) {
assert(self);
assert(ctx);
@@ -108,33 +105,23 @@ static lo_interface lib9p_srv_dio util9p_static_dir_dopen(struct util9p_static_d
static void util9p_static_dir_iofree(struct util9p_static_dir *self) {
assert(self);
}
-static size_t util9p_static_dir_dread(struct util9p_static_dir *self, struct lib9p_srv_ctx *ctx,
- uint8_t *buf,
- uint32_t byte_count,
- size_t _obj_offset) {
+static struct lib9p_srv_dirent util9p_static_dir_dread(struct util9p_static_dir *self, struct lib9p_srv_ctx *ctx, size_t idx) {
assert(self);
assert(ctx);
- uint32_t byte_offset = 0;
- size_t obj_offset = _obj_offset;
- while (!LO_IS_NULL(self->members[obj_offset])) {
- lo_interface lib9p_srv_file file = self->members[obj_offset];
- struct lib9p_stat stat = LO_CALL(file, stat, ctx);
- if (lib9p_ctx_has_error(&ctx->basectx))
- break;
- lib9p_stat_assert(stat);
- uint32_t nbytes = lib9p_stat_marshal(&ctx->basectx, byte_count-byte_offset, &stat,
- &buf[byte_offset]);
- if (!nbytes) {
- if (obj_offset == _obj_offset)
- lib9p_error(&ctx->basectx,
- LIB9P_ERRNO_L_ERANGE, "stat object does not fit into negotiated max message size");
- break;
- }
- byte_offset += nbytes;
- obj_offset++;
- }
- return obj_offset - _obj_offset;
+ lo_interface lib9p_srv_file file = self->members[idx];
+ if (LO_IS_NULL(file))
+ return (struct lib9p_srv_dirent){};
+
+ struct lib9p_srv_stat stat = LO_CALL(file, stat, ctx);
+ if (lib9p_ctx_has_error(&ctx->basectx))
+ return (struct lib9p_srv_dirent){};
+ lib9p_srv_stat_assert(stat);
+
+ return (struct lib9p_srv_dirent){
+ .qid = stat.qid,
+ .name = stat.name,
+ };
}
/* file ***********************************************************************/
@@ -164,30 +151,25 @@ static inline size_t util9p_static_file_size(struct util9p_static_file *file) {
}
-static struct lib9p_stat util9p_static_file_stat(struct util9p_static_file *self, struct lib9p_srv_ctx *ctx) {
+static struct lib9p_srv_stat util9p_static_file_stat(struct util9p_static_file *self, struct lib9p_srv_ctx *ctx) {
assert(self);
assert(ctx);
- return (struct lib9p_stat){
- .kern_type = 0,
- .kern_dev = 0,
- .file_qid = util9p_static_file_qid(self),
- .file_mode = self->perm & 0444,
- .file_atime = self->atime,
- .file_mtime = self->mtime,
- .file_size = (uint64_t)util9p_static_file_size(self),
- .file_name = lib9p_str(self->name),
- .file_owner_uid = lib9p_str(self->u_name),
- .file_owner_gid = lib9p_str(self->g_name),
- .file_last_modified_uid = lib9p_str(self->m_name),
- .file_extension = lib9p_str(NULL),
- .file_owner_n_uid = self->u_num,
- .file_owner_n_gid = self->g_num,
- .file_last_modified_n_uid = self->m_num,
+ return (struct lib9p_srv_stat){
+ .qid = util9p_static_file_qid(self),
+ .mode = self->perm & 0444,
+ .atime_sec = self->atime,
+ .mtime_sec = self->mtime,
+ .size = (uint64_t)util9p_static_file_size(self),
+ .name = lib9p_str(self->name),
+ .owner_uid = { .name = lib9p_str(self->u_name), .num = self->u_num },
+ .owner_gid = { .name = lib9p_str(self->g_name), .num = self->g_num },
+ .last_modifier_uid = { .name = lib9p_str(self->m_name), .num = self->m_num },
+ .extension = lib9p_str(NULL),
};
}
static void util9p_static_file_wstat(struct util9p_static_file *self, struct lib9p_srv_ctx *ctx,
- struct lib9p_stat) {
+ struct lib9p_srv_stat) {
assert(self);
assert(ctx);
diff --git a/libcr/tests/test_matrix.c b/libcr/tests/test_matrix.c
index 1f23455..eaa4bdc 100644
--- a/libcr/tests/test_matrix.c
+++ b/libcr/tests/test_matrix.c
@@ -1,6 +1,6 @@
/* libcr/tests/test_matrix.c - Tests for libcr
*
- * Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com>
+ * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
@@ -8,14 +8,14 @@
int a = 1;
-COROUTINE cr_init(void *) {
+COROUTINE init_cr(void *) {
cr_begin();
a = 2;
cr_end();
}
int main() {
- coroutine_add("init", cr_init, NULL);
+ coroutine_add("init", init_cr, NULL);
coroutine_main();
if (a != 2)
return 1;
diff --git a/libcr_ipc/include/libcr_ipc/chan.h b/libcr_ipc/include/libcr_ipc/chan.h
index 853b4ad..c57979a 100644
--- a/libcr_ipc/include/libcr_ipc/chan.h
+++ b/libcr_ipc/include/libcr_ipc/chan.h
@@ -48,7 +48,7 @@
#define cr_chan_send(CH, VAL) do { \
typeof((CH)->val_typ[0]) _val_lvalue = VAL; \
(void)cr_select_l(CR_SELECT_SEND(CH, &_val_lvalue)); \
-} while(0)
+} while (0)
/**
* cr_chan_recv(ch) reads and returns a value from ch.
diff --git a/libcr_ipc/include/libcr_ipc/rpc.h b/libcr_ipc/include/libcr_ipc/rpc.h
index ecf48cf..bfa0a04 100644
--- a/libcr_ipc/include/libcr_ipc/rpc.h
+++ b/libcr_ipc/include/libcr_ipc/rpc.h
@@ -123,7 +123,7 @@
*((REQ)._resp) = RESP; \
cr_unpause(REQ._requester); \
cr_yield(); \
-} while(0)
+} while (0)
/* Background details *********************************************************/
diff --git a/libcr_ipc/tests/test_chan.c b/libcr_ipc/tests/test_chan.c
index e5d9dc8..4788dd4 100644
--- a/libcr_ipc/tests/test_chan.c
+++ b/libcr_ipc/tests/test_chan.c
@@ -11,7 +11,7 @@
CR_CHAN_DECLARE(intchan, int);
-COROUTINE cr_producer(void *_ch) {
+COROUTINE producer_cr(void *_ch) {
intchan_t *ch = _ch;
cr_begin();
@@ -26,7 +26,7 @@ COROUTINE cr_producer(void *_ch) {
cr_end();
}
-COROUTINE cr_consumer(void *_ch) {
+COROUTINE consumer_cr(void *_ch) {
int x;
intchan_t *ch = _ch;
cr_begin();
@@ -42,8 +42,8 @@ COROUTINE cr_consumer(void *_ch) {
int main() {
intchan_t ch = {0};
- coroutine_add("producer", cr_producer, &ch);
- coroutine_add("consumer", cr_consumer, &ch);
+ coroutine_add("producer", producer_cr, &ch);
+ coroutine_add("consumer", consumer_cr, &ch);
coroutine_main();
return 0;
}
diff --git a/libcr_ipc/tests/test_mutex.c b/libcr_ipc/tests/test_mutex.c
index 43714c9..d08315d 100644
--- a/libcr_ipc/tests/test_mutex.c
+++ b/libcr_ipc/tests/test_mutex.c
@@ -11,7 +11,7 @@
int counter = 0;
-COROUTINE cr_worker(void *_mu) {
+COROUTINE worker_cr(void *_mu) {
cr_mutex_t *mu = _mu;
cr_begin();
@@ -29,8 +29,8 @@ COROUTINE cr_worker(void *_mu) {
int main() {
cr_mutex_t mu = {};
- coroutine_add("a", cr_worker, &mu);
- coroutine_add("b", cr_worker, &mu);
+ coroutine_add("a", worker_cr, &mu);
+ coroutine_add("b", worker_cr, &mu);
coroutine_main();
test_assert(counter == 200);
return 0;
diff --git a/libcr_ipc/tests/test_rpc.c b/libcr_ipc/tests/test_rpc.c
index 910b738..1461450 100644
--- a/libcr_ipc/tests/test_rpc.c
+++ b/libcr_ipc/tests/test_rpc.c
@@ -14,7 +14,7 @@ CR_RPC_DECLARE(intrpc, int, int);
/* Test that the RPC is fair, have worker1 start waiting first, and
* ensure that it gets the first request. */
-COROUTINE cr_caller(void *_ch) {
+COROUTINE caller_cr(void *_ch) {
intrpc_t *ch = _ch;
cr_begin();
@@ -27,7 +27,7 @@ COROUTINE cr_caller(void *_ch) {
cr_exit();
}
-COROUTINE cr_worker1(void *_ch) {
+COROUTINE worker1_cr(void *_ch) {
intrpc_t *ch = _ch;
cr_begin();
@@ -38,7 +38,7 @@ COROUTINE cr_worker1(void *_ch) {
cr_exit();
}
-COROUTINE cr_worker2(void *_ch) {
+COROUTINE worker2_cr(void *_ch) {
intrpc_t *ch = _ch;
cr_begin();
@@ -51,9 +51,9 @@ COROUTINE cr_worker2(void *_ch) {
int main() {
intrpc_t ch = {0};
- coroutine_add("worker1", cr_worker1, &ch);
- coroutine_add("caller", cr_caller, &ch);
- coroutine_add("worker2", cr_worker2, &ch);
+ coroutine_add("worker1", worker1_cr, &ch);
+ coroutine_add("caller", caller_cr, &ch);
+ coroutine_add("worker2", worker2_cr, &ch);
coroutine_main();
return 0;
}
diff --git a/libcr_ipc/tests/test_select.c b/libcr_ipc/tests/test_select.c
index 3da1c78..9b5d117 100644
--- a/libcr_ipc/tests/test_select.c
+++ b/libcr_ipc/tests/test_select.c
@@ -14,7 +14,7 @@ CR_CHAN_DECLARE(intchan, int);
intchan_t ch[10] = {0};
intchan_t fch = {0};
-COROUTINE cr_consumer(void *) {
+COROUTINE consumer_cr(void *) {
cr_begin();
struct cr_select_arg args[11];
@@ -60,7 +60,7 @@ COROUTINE cr_consumer(void *) {
cr_end();
}
-COROUTINE cr_producer(void *_n) {
+COROUTINE producer_cr(void *_n) {
int n = *(int *)_n;
cr_begin();
@@ -69,7 +69,7 @@ COROUTINE cr_producer(void *_n) {
cr_end();
}
-COROUTINE cr_final(void *) {
+COROUTINE final_cr(void *) {
cr_begin();
int ret = cr_chan_recv(&fch);
@@ -81,9 +81,9 @@ COROUTINE cr_final(void *) {
int main() {
for (int i = 0; i < 10; i++)
- coroutine_add("producer", cr_producer, &i);
- coroutine_add("consumer", cr_consumer, NULL);
- coroutine_add("final", cr_final, NULL);
+ coroutine_add("producer", producer_cr, &i);
+ coroutine_add("consumer", consumer_cr, NULL);
+ coroutine_add("final", final_cr, NULL);
coroutine_main();
return 0;
}
diff --git a/libcr_ipc/tests/test_sema.c b/libcr_ipc/tests/test_sema.c
index e5b22a5..435c01a 100644
--- a/libcr_ipc/tests/test_sema.c
+++ b/libcr_ipc/tests/test_sema.c
@@ -13,7 +13,7 @@
int counter = 0;
-COROUTINE cr_first(void *_sema) {
+COROUTINE first_cr(void *_sema) {
cr_sema_t *sema = _sema;
cr_begin();
@@ -24,7 +24,7 @@ COROUTINE cr_first(void *_sema) {
cr_exit();
}
-COROUTINE cr_second(void *_sema) {
+COROUTINE second_cr(void *_sema) {
cr_sema_t *sema = _sema;
cr_begin();
@@ -35,7 +35,7 @@ COROUTINE cr_second(void *_sema) {
cr_exit();
}
-COROUTINE cr_producer(void *_sema) {
+COROUTINE producer_cr(void *_sema) {
cr_sema_t *sema = _sema;
cr_begin();
@@ -45,7 +45,7 @@ COROUTINE cr_producer(void *_sema) {
cr_end();
}
-COROUTINE cr_consumer(void *_sema) {
+COROUTINE consumer_cr(void *_sema) {
cr_sema_t *sema = _sema;
cr_begin();
@@ -59,16 +59,16 @@ int main() {
cr_sema_t sema = {};
printf("== test 1 =========================================\n");
- coroutine_add("first", cr_first, &sema);
- coroutine_add("second", cr_second, &sema);
+ coroutine_add("first", first_cr, &sema);
+ coroutine_add("second", second_cr, &sema);
coroutine_main();
test_assert(sema.cnt == 0);
printf("== test 2 =========================================\n");
- coroutine_add("consumer", cr_consumer, &sema);
- coroutine_add("producer", cr_producer, &sema);
+ coroutine_add("consumer", consumer_cr, &sema);
+ coroutine_add("producer", producer_cr, &sema);
coroutine_main();
- coroutine_add("consumer", cr_consumer, &sema);
+ coroutine_add("consumer", consumer_cr, &sema);
coroutine_main();
test_assert(sema.cnt == 0);
diff --git a/libhw_cr/rp2040_include/libhw/rp2040_hwspi.h b/libhw_cr/rp2040_include/libhw/rp2040_hwspi.h
index 4951136..8d4effa 100644
--- a/libhw_cr/rp2040_include/libhw/rp2040_hwspi.h
+++ b/libhw_cr/rp2040_include/libhw/rp2040_hwspi.h
@@ -99,7 +99,7 @@ LO_IMPLEMENTATION_H(spi, struct rp2040_hwspi, rp2040_hwspi);
min_delay_ns, bogus_data, \
pin_miso, pin_mosi, pin_clk, pin_cs, \
dma1, dma2, dma3, dma4); \
- } while(0)
+ } while (0)
void _rp2040_hwspi_init(struct rp2040_hwspi *self,
enum rp2040_hwspi_instance inst_num,
enum spi_mode mode,
diff --git a/libmisc/include/libmisc/assert.h b/libmisc/include/libmisc/assert.h
index 8cf0735..ccdb288 100644
--- a/libmisc/include/libmisc/assert.h
+++ b/libmisc/include/libmisc/assert.h
@@ -1,6 +1,6 @@
/* libmisc/assert.h - More assertions
*
- * Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com>
+ * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
@@ -10,15 +10,20 @@
#ifdef NDEBUG
# define __assert_msg(expr, expr_str, msg) ((void)0)
#else
-# define __assert_msg(expr, expr_str, msg) do { if (!(expr)) __assert_msg_fail(expr_str, __FILE__, __LINE__, __func__, msg); } while (0)
+# define __assert_msg(expr, expr_str, msg) \
+ do { \
+ if (!(expr)) \
+ __assert_msg_fail(expr_str, __FILE__, __LINE__, __func__, msg); \
+ } while (0)
[[noreturn]] void __assert_msg_fail(const char *expr,
const char *file, unsigned int line, const char *func,
const char *msg);
#endif
-#define assert_msg(expr, msg) __assert_msg(expr, #expr, msg) /* libmisc */
-#define assert(expr) __assert_msg(expr, #expr, 0) /* C89, POSIX-2001 */
-#define assert_notreached(msg) do { __assert_msg(0, "notreached", msg); __builtin_unreachable(); } while (0) /* libmisc */
-#define static_assert _Static_assert /* C11 */
+#define assert_msg(expr, msg) __assert_msg(expr, #expr, msg) /* libmisc */
+#define assert(expr) __assert_msg(expr, #expr, 0) /* C89, POSIX-2001 */
+#define assert_notreached(msg) do { __assert_msg(0, "notreached", msg); __builtin_unreachable(); } while (0) /* libmisc */
+#define static_assert _Static_assert /* C11 */
+#define static_assert_as_expr(...) (sizeof(struct {static_assert(__VA_ARGS__);})) /* libmisc */
#endif /* _LIBMISC_ASSERT_H_ */
diff --git a/libmisc/include/libmisc/linkedlist.h b/libmisc/include/libmisc/linkedlist.h
index e8c65db..b6ff688 100644
--- a/libmisc/include/libmisc/linkedlist.h
+++ b/libmisc/include/libmisc/linkedlist.h
@@ -56,14 +56,14 @@ void _dlist_pop_from_front(struct _dlist_root *root);
typeof(*_rootp->front) *_nodep = NODE; \
_slist_push_to_rear((struct _slist_root *)_rootp, \
(struct _slist_node *)_nodep); \
-} while(0)
+} while (0)
#define slist_pop_from_front(ROOT) { \
/* This temporary variables are to get the compiler to check \
* the type. */ \
typeof(*(ROOT)->_slist_root_typ[0]) *_rootp = ROOT; \
_slist_pop_from_front((struct _slist_root *)_rootp); \
-} while(0)
+} while (0)
/* doubly linked list (non-intrusive) *****************************************/
@@ -87,7 +87,7 @@ void _dlist_pop_from_front(struct _dlist_root *root);
typeof(*_rootp->front) *_nodep = NODE; \
_dlist_push_to_rear((struct _dlist_root *)_rootp, \
(struct _dlist_node *)_nodep); \
-} while(0)
+} while (0)
#define dlist_remove(ROOT, NODE) { \
/* These temporary variables are to get the compiler to check \
@@ -96,13 +96,13 @@ void _dlist_pop_from_front(struct _dlist_root *root);
typeof(*_rootp->front) *_nodep = NODE; \
_dlist_remove((struct _dlist_root *)_rootp, \
(struct _dlist_node *)_nodep); \
-} while(0)
+} while (0)
#define dlist_pop_from_front(ROOT) { \
/* This temporary variables are to get the compiler to check \
* the type. */ \
typeof(*(ROOT)->_dlist_root_typ[0]) *_rootp = ROOT; \
_dlist_pop_from_front((struct _dlist_root *)_rootp); \
-} while(0)
+} while (0)
#endif /* _LIBMISC_LINKEDLIST_H_ */
diff --git a/libmisc/include/libmisc/macro.h b/libmisc/include/libmisc/macro.h
index 6cb15fb..a95ac82 100644
--- a/libmisc/include/libmisc/macro.h
+++ b/libmisc/include/libmisc/macro.h
@@ -7,6 +7,8 @@
#ifndef _LIBMISC_MACRO_H_
#define _LIBMISC_MACRO_H_
+#include <libmisc/assert.h>
+
/* for function definitions */
#define LM_UNUSED(argname)
@@ -16,7 +18,9 @@
/* types */
-#define LM_ARRAY_LEN(ary) (sizeof(ary)/sizeof((ary)[0]))
+/* If it's a pointer instead of an array, then typeof(&ptr[0]) == typeof(ptr) */
+#define _LM_IS_ARRAY(ary) (!__builtin_types_compatible_p(typeof(&(ary)[0]), typeof(ary)))
+#define LM_ARRAY_LEN(ary) ( (sizeof(ary)/sizeof((ary)[0])) + static_assert_as_expr(_LM_IS_ARRAY(ary)) )
#define LM_CAST_FIELD_TO_STRUCT(STRUCT_TYP, FIELD_NAME, PTR_TO_FIELD) ({ \
/* The _fptr assignment is to get the compiler to do type checking. */ \
diff --git a/libmisc/include/libmisc/map.h b/libmisc/include/libmisc/map.h
index 41ac069..6622595 100644
--- a/libmisc/include/libmisc/map.h
+++ b/libmisc/include/libmisc/map.h
@@ -52,7 +52,7 @@ struct _map {
(M)->core.offsetof_k = offsetof(typeof((M)->kv_typ[0]), val.key); \
(M)->core.offsetof_v = offsetof(typeof((M)->kv_typ[0]), val.val); \
} \
-} while(0)
+} while (0)
/* Methods ********************************************************************/