summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-03-22 19:36:45 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-03-22 19:36:45 -0600
commit488bdd5e4120b684e449b9567169d0416e65276c (patch)
tree9560a18fc2c0ea09fa35715541be24c11792ed23
parent185c3329145959433b8b805de5f114b66b8fcaee (diff)
parent6322636192c57a472176c65257b2b8487f79434e (diff)
Merge branch 'lukeshu/9p-idl'
-rwxr-xr-xbuild-aux/stack.c.gen40
-rw-r--r--gdb-helpers/libcr.py6
-rw-r--r--gdb-helpers/rp2040.py2
-rw-r--r--lib9p/9p.c4
-rw-r--r--lib9p/9p.generated.c676
-rwxr-xr-xlib9p/idl.gen126
-rw-r--r--lib9p/idl/0000-README.md5
-rw-r--r--lib9p/idl/2002-9P2000.9p10
-rw-r--r--lib9p/idl/2005-9P2000.u.9p5
-rw-r--r--lib9p/idl/2010-9P2000.L.9p222
-rw-r--r--lib9p/idl/__init__.py203
-rw-r--r--lib9p/include/lib9p/9p.generated.h436
-rw-r--r--lib9p/include/lib9p/9p.h17
-rw-r--r--lib9p/tests/test_compile.c70
14 files changed, 1147 insertions, 675 deletions
diff --git a/build-aux/stack.c.gen b/build-aux/stack.c.gen
index 5a983cb..a8e2149 100755
--- a/build-aux/stack.c.gen
+++ b/build-aux/stack.c.gen
@@ -71,7 +71,7 @@ def parse_vcg(reader: typing.TextIO) -> typing.Iterator[VCGElem]:
k = m.group(1)
v = m.group(2)
if k in elem.attrs:
- _raise(f"duplicate key: {repr(k)}")
+ _raise(f"duplicate key: {k!r}")
if v.startswith('"'):
def unesc(esc: re.Match[str]) -> str:
@@ -83,7 +83,7 @@ def parse_vcg(reader: typing.TextIO) -> typing.Iterator[VCGElem]:
case "\\":
return "\\"
case _:
- _raise(f"invalid escape code {repr(esc.group(0))}")
+ _raise(f"invalid escape code {esc.group(0)!r}")
v = re_esc.sub(unesc, v[1:-1])
elem.attrs[k] = v
@@ -107,7 +107,7 @@ class BaseName:
def __init__(self, content: str) -> None:
if ":" in content:
- raise ValueError(f"invalid non-qualified name: {repr(content)}")
+ raise ValueError(f"invalid non-qualified name: {content!r}")
self._content = content
def __str__(self) -> str:
@@ -240,9 +240,7 @@ def analyze(
if elem.attrs.get("shape", "") != "ellipse":
m = re_node_label.fullmatch(v)
if not m:
- raise ValueError(
- f"unexpected label value {repr(v)}"
- )
+ raise ValueError(f"unexpected label value {v!r}")
node.location = m.group("location")
node.usage_kind = typing.cast(
UsageKind, m.group("usage_kind")
@@ -251,13 +249,13 @@ def analyze(
node.ndynamic = int(m.group("ndynamic"))
case "shape":
if v != "ellipse":
- raise ValueError(f"unexpected shape value {repr(v)}")
+ raise ValueError(f"unexpected shape value {v!r}")
skip = True
case _:
- raise ValueError(f"unknown edge key {repr(k)}")
+ raise ValueError(f"unknown edge key {k!r}")
if not skip:
if node.funcname in graph:
- raise ValueError(f"duplicate node {repr(str(node.funcname))}")
+ raise ValueError(f"duplicate node {str(node.funcname)!r}")
graph[node.funcname] = node
if ":" in str(node.funcname):
basename = node.funcname.base()
@@ -276,9 +274,9 @@ def analyze(
case "label":
pass
case _:
- raise ValueError(f"unknown edge key {repr(k)}")
+ raise ValueError(f"unknown edge key {k!r}")
if caller is None or callee is None:
- raise ValueError(f"incomplete edge: {repr(elem.attrs)}")
+ raise ValueError(f"incomplete edge: {elem.attrs!r}")
if caller not in graph:
raise ValueError(f"unknown caller: {caller}")
if str(callee) == "__indirect_call":
@@ -289,7 +287,7 @@ def analyze(
else:
graph[caller].calls[callee] = False
case _:
- raise ValueError(f"unknown elem type {repr(elem.typ)}")
+ raise ValueError(f"unknown elem type {elem.typ!r}")
for ci_fname in ci_fnames:
with open(ci_fname, "r", encoding="utf-8") as fh:
@@ -298,7 +296,7 @@ def analyze(
for node in app.extra_nodes():
if node.funcname in graph:
- raise ValueError(f"duplicate node {repr(str(node.funcname))}")
+ raise ValueError(f"duplicate node {str(node.funcname)!r}")
graph[node.funcname] = node
missing: set[QName] = set()
@@ -397,7 +395,7 @@ def read_source(location: str) -> str:
re_location = re.compile(r"(?P<filename>.+):(?P<row>[0-9]+):(?P<col>[0-9]+)")
m = re_location.fullmatch(location)
if not m:
- raise ValueError(f"unexpected label value {repr(location)}")
+ raise ValueError(f"unexpected label value {location!r}")
filename = m.group("filename")
row = int(m.group("row")) - 1
col = int(m.group("col")) - 1
@@ -1493,12 +1491,12 @@ def main(
if val.nstatic == 0:
continue
print(
- f"{name.ljust(namelen)} {str(val.nstatic).rjust(numlen)}"
+ f"{name:<{namelen}} {val.nstatic:>{numlen}}"
+ (f" * {val.cnt}" if val.cnt != 1 else "")
)
print(sep2)
- print(f"{'Total'.ljust(namelen)} {str(nsum).rjust(numlen)}")
- print(f"{'Maximum'.ljust(namelen)} {str(nmax).rjust(numlen)}")
+ print(f"{'Total':<{namelen}} {nsum:>{numlen}}")
+ print(f"{'Maximum':<{namelen}} {nmax:>{numlen}}")
print(sep1)
def next_power_of_2(x: int) -> int:
@@ -1542,8 +1540,8 @@ def main(
if comment:
print(f"/* {name}".ljust(len(prefix) + namelen), end="")
else:
- print(f"{prefix}{name.ljust(namelen)}", end="")
- print(f" = {str(size).rjust(sizelen)};", end="")
+ print(f"{prefix}{name:<{namelen}}", end="")
+ print(f" = {size:>{sizelen}};", end="")
if comment:
print(" */", end="")
elif eqn:
@@ -1557,7 +1555,7 @@ def main(
False,
row.name,
row.size,
- f"LM_NEXT_POWER_OF_2({str(row.base).rjust(baselen)}+{intrstack}+{stack_guard_size})-{stack_guard_size}",
+ f"LM_NEXT_POWER_OF_2({row.base:>{baselen}}+{intrstack}+{stack_guard_size})-{stack_guard_size}",
)
print_row(True, "TOTAL (inc. stack guard)", sizesum)
if mainrow:
@@ -1565,7 +1563,7 @@ def main(
True,
"MAIN/KERNEL",
mainrow.size,
- f" {str(mainrow.base).rjust(baselen)}+{intrstack}",
+ f" {mainrow.base:>{baselen}}+{intrstack}",
)
print()
print("/*")
diff --git a/gdb-helpers/libcr.py b/gdb-helpers/libcr.py
index f74a702..fcfd86e 100644
--- a/gdb-helpers/libcr.py
+++ b/gdb-helpers/libcr.py
@@ -1,6 +1,6 @@
# gdb-helpers/libcr.py - GDB helpers 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
import contextlib
@@ -428,11 +428,11 @@ class CrSelectCommand(gdb.Command):
crs += [cr]
match len(crs):
case 0:
- raise gdb.GdbError(f"No such coroutine: {repr(name)}")
+ raise gdb.GdbError(f"No such coroutine: {name!r}")
case 1:
return crs[0]
case _:
- raise gdb.GdbError(f"Ambiguous name, must use Id: {repr(name)}")
+ raise gdb.GdbError(f"Ambiguous name, must use Id: {name!r}")
# Wire it all in ###############################################################
diff --git a/gdb-helpers/rp2040.py b/gdb-helpers/rp2040.py
index 45bdbc7..087974d 100644
--- a/gdb-helpers/rp2040.py
+++ b/gdb-helpers/rp2040.py
@@ -32,7 +32,7 @@ def box(title: str, content: str) -> str:
ret = "┏━[" + title + "]" + ("━" * (width - len(title) - 5)) + "┓\n"
for line in content.split("\n"):
- ret += f"┃ {line.ljust(width-4)} ┃\n"
+ ret += f"┃ {line:<{width-4}} ┃\n"
ret += "┗" + ("━" * (width - 2)) + "┛"
return ret
diff --git a/lib9p/9p.c b/lib9p/9p.c
index 1caa01a..74a786c 100644
--- a/lib9p/9p.c
+++ b/lib9p/9p.c
@@ -79,7 +79,7 @@ bool lib9p_ctx_has_error(struct lib9p_ctx *ctx) {
return ctx->err_msg[0];
}
-int lib9p_error(struct lib9p_ctx *ctx, uint32_t linux_errno, char const *msg) {
+int lib9p_error(struct lib9p_ctx *ctx, lib9p_errno_t linux_errno, char const *msg) {
if (lib9p_ctx_has_error(ctx))
return -1;
strncpy(ctx->err_msg, msg, sizeof(ctx->err_msg));
@@ -94,7 +94,7 @@ int lib9p_error(struct lib9p_ctx *ctx, uint32_t linux_errno, char const *msg) {
return -1;
}
-int lib9p_errorf(struct lib9p_ctx *ctx, uint32_t linux_errno, char const *fmt, ...) {
+int lib9p_errorf(struct lib9p_ctx *ctx, lib9p_errno_t linux_errno, char const *fmt, ...) {
int n;
va_list args;
diff --git a/lib9p/9p.generated.c b/lib9p/9p.generated.c
index 567f450..8d6c82f 100644
--- a/lib9p/9p.generated.c
+++ b/lib9p/9p.generated.c
@@ -333,6 +333,38 @@ static const lib9p_o_t o_masks[LIB9P_VER_NUM] = {
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000_L
+static const lib9p_lo_t lo_masks[LIB9P_VER_NUM] = {
+#if CONFIG_9P_ENABLE_9P2000
+ [LIB9P_VER_9P2000] = 0b00000000000000000000000000000000,
+#endif /* CONFIG_9P_ENABLE_9P2000 */
+ [LIB9P_VER_9P2000_L] = 0b00000000000111111111111111000011,
+#if CONFIG_9P_ENABLE_9P2000_e
+ [LIB9P_VER_9P2000_e] = 0b00000000000000000000000000000000,
+#endif /* CONFIG_9P_ENABLE_9P2000_e */
+#if CONFIG_9P_ENABLE_9P2000_p9p
+ [LIB9P_VER_9P2000_p9p] = 0b00000000000000000000000000000000,
+#endif /* CONFIG_9P_ENABLE_9P2000_p9p */
+#if CONFIG_9P_ENABLE_9P2000_u
+ [LIB9P_VER_9P2000_u] = 0b00000000000000000000000000000000,
+#endif /* CONFIG_9P_ENABLE_9P2000_u */
+};
+
+static const lib9p_mode_t mode_masks[LIB9P_VER_NUM] = {
+#if CONFIG_9P_ENABLE_9P2000
+ [LIB9P_VER_9P2000] = 0b00000000000000000000000000000000,
+#endif /* CONFIG_9P_ENABLE_9P2000 */
+ [LIB9P_VER_9P2000_L] = 0b00000000000000001111111111111111,
+#if CONFIG_9P_ENABLE_9P2000_e
+ [LIB9P_VER_9P2000_e] = 0b00000000000000000000000000000000,
+#endif /* CONFIG_9P_ENABLE_9P2000_e */
+#if CONFIG_9P_ENABLE_9P2000_p9p
+ [LIB9P_VER_9P2000_p9p] = 0b00000000000000000000000000000000,
+#endif /* CONFIG_9P_ENABLE_9P2000_p9p */
+#if CONFIG_9P_ENABLE_9P2000_u
+ [LIB9P_VER_9P2000_u] = 0b00000000000000000000000000000000,
+#endif /* CONFIG_9P_ENABLE_9P2000_u */
+};
+
static const lib9p_getattr_t getattr_masks[LIB9P_VER_NUM] = {
#if CONFIG_9P_ENABLE_9P2000
[LIB9P_VER_9P2000] = 0b0000000000000000000000000000000000000000000000000000000000000000,
@@ -479,7 +511,45 @@ LM_ALWAYS_INLINE static bool validate_o(struct _validate_ctx *ctx) {
}
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u
+LM_ALWAYS_INLINE static bool validate_errno(struct _validate_ctx *ctx) {
+ return validate_4(ctx);
+}
+
+#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000_L
+LM_ALWAYS_INLINE static bool validate_super_magic(struct _validate_ctx *ctx) {
+ return validate_4(ctx);
+}
+
+LM_ALWAYS_INLINE static bool validate_lo(struct _validate_ctx *ctx) {
+ if (validate_4(ctx))
+ return true;
+ lib9p_lo_t mask = lo_masks[ctx->ctx->version];
+ lib9p_lo_t val = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]);
+ if (val & ~mask)
+ return lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "unknown bits in lo bitfield: %#04"PRIx32, val & ~mask);
+ return false;
+}
+
+LM_ALWAYS_INLINE static bool validate_dt(struct _validate_ctx *ctx) {
+ return validate_1(ctx);
+}
+
+LM_ALWAYS_INLINE static bool validate_mode(struct _validate_ctx *ctx) {
+ if (validate_4(ctx))
+ return true;
+ lib9p_mode_t mask = mode_masks[ctx->ctx->version];
+ lib9p_mode_t val = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]);
+ if (val & ~mask)
+ return lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "unknown bits in mode bitfield: %#04"PRIx32, val & ~mask);
+ return false;
+}
+
+LM_ALWAYS_INLINE static bool validate_b4(struct _validate_ctx *ctx) {
+ return validate_4(ctx);
+}
+
LM_ALWAYS_INLINE static bool validate_getattr(struct _validate_ctx *ctx) {
if (validate_8(ctx))
return true;
@@ -639,46 +709,6 @@ LM_FLATTEN static bool validate_Rwstat(struct _validate_ctx *ctx) {
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000_L
-LM_FLATTEN static bool validate_Rlerror(struct _validate_ctx *ctx) {
- uint32_t size;
- uint8_t typ;
- uint32_t _size_offset;
- return false
- || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; }))
- || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; }))
- || validate_tag(ctx)
- || validate_4(ctx)
- || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
- lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
- || ({ uint8_t exp = 7; (((uint8_t)typ) != exp) &&
- lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); })
- ;
-}
-
-LM_FLATTEN static bool validate_Rstatfs(struct _validate_ctx *ctx) {
- uint32_t size;
- uint8_t typ;
- uint32_t _size_offset;
- return false
- || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; }))
- || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; }))
- || validate_tag(ctx)
- || validate_4(ctx)
- || validate_4(ctx)
- || validate_8(ctx)
- || validate_8(ctx)
- || validate_8(ctx)
- || validate_8(ctx)
- || validate_8(ctx)
- || validate_8(ctx)
- || validate_4(ctx)
- || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
- lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
- || ({ uint8_t exp = 9; (((uint8_t)typ) != exp) &&
- lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); })
- ;
-}
-
LM_FLATTEN static bool validate_Rrename(struct _validate_ctx *ctx) {
uint32_t size;
uint8_t typ;
@@ -1004,23 +1034,6 @@ LM_FLATTEN static bool validate_Tstatfs(struct _validate_ctx *ctx) {
;
}
-LM_FLATTEN static bool validate_Tlopen(struct _validate_ctx *ctx) {
- uint32_t size;
- uint8_t typ;
- uint32_t _size_offset;
- return false
- || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; }))
- || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; }))
- || validate_tag(ctx)
- || validate_fid(ctx)
- || validate_4(ctx)
- || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
- lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
- || ({ uint8_t exp = 12; (((uint8_t)typ) != exp) &&
- lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); })
- ;
-}
-
LM_FLATTEN static bool validate_Treadlink(struct _validate_ctx *ctx) {
uint32_t size;
uint8_t typ;
@@ -1055,23 +1068,6 @@ LM_FLATTEN static bool validate_Treaddir(struct _validate_ctx *ctx) {
;
}
-LM_FLATTEN static bool validate_Tfsync(struct _validate_ctx *ctx) {
- uint32_t size;
- uint8_t typ;
- uint32_t _size_offset;
- return false
- || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; }))
- || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; }))
- || validate_tag(ctx)
- || validate_fid(ctx)
- || validate_4(ctx)
- || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
- lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
- || ({ uint8_t exp = 50; (((uint8_t)typ) != exp) &&
- lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); })
- ;
-}
-
#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
LM_FLATTEN static bool validate_Tversion(struct _validate_ctx *ctx) {
@@ -1108,25 +1104,6 @@ LM_FLATTEN static bool validate_Rversion(struct _validate_ctx *ctx) {
;
}
-LM_FLATTEN static bool validate_Rerror(struct _validate_ctx *ctx) {
- uint32_t size;
- uint8_t typ;
- uint32_t _size_offset;
- return false
- || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; }))
- || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; }))
- || validate_tag(ctx)
- || validate_s(ctx)
-#if CONFIG_9P_ENABLE_9P2000_u
- || ( is_ver(ctx, 9P2000_u) && validate_4(ctx) )
-#endif /* CONFIG_9P_ENABLE_9P2000_u */
- || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
- lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
- || ({ uint8_t exp = 107; (((uint8_t)typ) != exp) &&
- lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); })
- ;
-}
-
LM_FLATTEN static bool validate_Twalk(struct _validate_ctx *ctx) {
uint32_t size;
uint8_t typ;
@@ -1222,47 +1199,6 @@ LM_FLATTEN static bool validate_Txattrcreate(struct _validate_ctx *ctx) {
;
}
-LM_FLATTEN static bool validate_Tgetlock(struct _validate_ctx *ctx) {
- uint32_t size;
- uint8_t typ;
- uint32_t _size_offset;
- return false
- || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; }))
- || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; }))
- || validate_tag(ctx)
- || validate_fid(ctx)
- || validate_1(ctx)
- || validate_8(ctx)
- || validate_8(ctx)
- || validate_4(ctx)
- || validate_s(ctx)
- || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
- lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
- || ({ uint8_t exp = 54; (((uint8_t)typ) != exp) &&
- lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); })
- ;
-}
-
-LM_FLATTEN static bool validate_Rgetlock(struct _validate_ctx *ctx) {
- uint32_t size;
- uint8_t typ;
- uint32_t _size_offset;
- return false
- || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; }))
- || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; }))
- || validate_tag(ctx)
- || validate_1(ctx)
- || validate_8(ctx)
- || validate_8(ctx)
- || validate_4(ctx)
- || validate_s(ctx)
- || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
- lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
- || ({ uint8_t exp = 55; (((uint8_t)typ) != exp) &&
- lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); })
- ;
-}
-
LM_FLATTEN static bool validate_Tlink(struct _validate_ctx *ctx) {
uint32_t size;
uint8_t typ;
@@ -1416,7 +1352,7 @@ LM_FLATTEN static bool validate_Tattach(struct _validate_ctx *ctx) {
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000_L
-LM_FLATTEN static bool validate_Tlcreate(struct _validate_ctx *ctx) {
+LM_FLATTEN static bool validate_Tsymlink(struct _validate_ctx *ctx) {
uint32_t size;
uint8_t typ;
uint32_t _size_offset;
@@ -1426,17 +1362,35 @@ LM_FLATTEN static bool validate_Tlcreate(struct _validate_ctx *ctx) {
|| validate_tag(ctx)
|| validate_fid(ctx)
|| validate_s(ctx)
- || validate_4(ctx)
- || validate_4(ctx)
+ || validate_s(ctx)
|| validate_nuid(ctx)
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
- || ({ uint8_t exp = 14; (((uint8_t)typ) != exp) &&
+ || ({ uint8_t exp = 16; (((uint8_t)typ) != exp) &&
lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); })
;
}
-LM_FLATTEN static bool validate_Tsymlink(struct _validate_ctx *ctx) {
+#endif /* CONFIG_9P_ENABLE_9P2000_L */
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+LM_FLATTEN static bool validate_Topen(struct _validate_ctx *ctx) {
+ uint32_t size;
+ uint8_t typ;
+ uint32_t _size_offset;
+ return false
+ || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; }))
+ || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; }))
+ || validate_tag(ctx)
+ || validate_fid(ctx)
+ || validate_o(ctx)
+ || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
+ lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
+ || ({ uint8_t exp = 112; (((uint8_t)typ) != exp) &&
+ lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); })
+ ;
+}
+
+LM_FLATTEN static bool validate_Tcreate(struct _validate_ctx *ctx) {
uint32_t size;
uint8_t typ;
uint32_t _size_offset;
@@ -1446,16 +1400,18 @@ LM_FLATTEN static bool validate_Tsymlink(struct _validate_ctx *ctx) {
|| validate_tag(ctx)
|| validate_fid(ctx)
|| validate_s(ctx)
- || validate_s(ctx)
- || validate_nuid(ctx)
+ || validate_dm(ctx)
+ || validate_o(ctx)
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
- || ({ uint8_t exp = 16; (((uint8_t)typ) != exp) &&
+ || ({ uint8_t exp = 114; (((uint8_t)typ) != exp) &&
lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); })
;
}
-LM_FLATTEN static bool validate_Tmknod(struct _validate_ctx *ctx) {
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_9P2000_p9p
+LM_FLATTEN static bool validate_Topenfd(struct _validate_ctx *ctx) {
uint32_t size;
uint8_t typ;
uint32_t _size_offset;
@@ -1464,19 +1420,95 @@ LM_FLATTEN static bool validate_Tmknod(struct _validate_ctx *ctx) {
|| (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; }))
|| validate_tag(ctx)
|| validate_fid(ctx)
+ || validate_o(ctx)
+ || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
+ lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
+ || ({ uint8_t exp = 98; (((uint8_t)typ) != exp) &&
+ lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); })
+ ;
+}
+
+#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
+LM_FLATTEN static bool validate_Rerror(struct _validate_ctx *ctx) {
+ uint32_t size;
+ uint8_t typ;
+ uint32_t _size_offset;
+ return false
+ || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; }))
+ || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; }))
+ || validate_tag(ctx)
|| validate_s(ctx)
+#if CONFIG_9P_ENABLE_9P2000_u
+ || ( is_ver(ctx, 9P2000_u) && validate_errno(ctx) )
+#endif /* CONFIG_9P_ENABLE_9P2000_u */
+ || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
+ lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
+ || ({ uint8_t exp = 107; (((uint8_t)typ) != exp) &&
+ lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); })
+ ;
+}
+
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_9P2000_L
+LM_FLATTEN static bool validate_Rlerror(struct _validate_ctx *ctx) {
+ uint32_t size;
+ uint8_t typ;
+ uint32_t _size_offset;
+ return false
+ || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; }))
+ || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; }))
+ || validate_tag(ctx)
+ || validate_errno(ctx)
+ || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
+ lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
+ || ({ uint8_t exp = 7; (((uint8_t)typ) != exp) &&
+ lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); })
+ ;
+}
+
+LM_FLATTEN static bool validate_Rstatfs(struct _validate_ctx *ctx) {
+ uint32_t size;
+ uint8_t typ;
+ uint32_t _size_offset;
+ return false
+ || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; }))
+ || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; }))
+ || validate_tag(ctx)
+ || validate_super_magic(ctx)
|| validate_4(ctx)
+ || validate_8(ctx)
+ || validate_8(ctx)
+ || validate_8(ctx)
+ || validate_8(ctx)
+ || validate_8(ctx)
+ || validate_8(ctx)
|| validate_4(ctx)
- || validate_4(ctx)
- || validate_nuid(ctx)
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
- || ({ uint8_t exp = 18; (((uint8_t)typ) != exp) &&
+ || ({ uint8_t exp = 9; (((uint8_t)typ) != exp) &&
lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); })
;
}
-LM_FLATTEN static bool validate_Tmkdir(struct _validate_ctx *ctx) {
+LM_FLATTEN static bool validate_Tlopen(struct _validate_ctx *ctx) {
+ uint32_t size;
+ uint8_t typ;
+ uint32_t _size_offset;
+ return false
+ || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; }))
+ || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; }))
+ || validate_tag(ctx)
+ || validate_fid(ctx)
+ || validate_lo(ctx)
+ || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
+ lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
+ || ({ uint8_t exp = 12; (((uint8_t)typ) != exp) &&
+ lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); })
+ ;
+}
+
+LM_FLATTEN static bool validate_Tlcreate(struct _validate_ctx *ctx) {
uint32_t size;
uint8_t typ;
uint32_t _size_offset;
@@ -1486,18 +1518,17 @@ LM_FLATTEN static bool validate_Tmkdir(struct _validate_ctx *ctx) {
|| validate_tag(ctx)
|| validate_fid(ctx)
|| validate_s(ctx)
- || validate_4(ctx)
+ || validate_lo(ctx)
+ || validate_mode(ctx)
|| validate_nuid(ctx)
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
- || ({ uint8_t exp = 72; (((uint8_t)typ) != exp) &&
+ || ({ uint8_t exp = 14; (((uint8_t)typ) != exp) &&
lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); })
;
}
-#endif /* CONFIG_9P_ENABLE_9P2000_L */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
-LM_FLATTEN static bool validate_Topen(struct _validate_ctx *ctx) {
+LM_FLATTEN static bool validate_Tmknod(struct _validate_ctx *ctx) {
uint32_t size;
uint8_t typ;
uint32_t _size_offset;
@@ -1506,15 +1537,19 @@ LM_FLATTEN static bool validate_Topen(struct _validate_ctx *ctx) {
|| (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; }))
|| validate_tag(ctx)
|| validate_fid(ctx)
- || validate_o(ctx)
+ || validate_s(ctx)
+ || validate_mode(ctx)
+ || validate_4(ctx)
+ || validate_4(ctx)
+ || validate_nuid(ctx)
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
- || ({ uint8_t exp = 112; (((uint8_t)typ) != exp) &&
+ || ({ uint8_t exp = 18; (((uint8_t)typ) != exp) &&
lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); })
;
}
-LM_FLATTEN static bool validate_Tcreate(struct _validate_ctx *ctx) {
+LM_FLATTEN static bool validate_Tmkdir(struct _validate_ctx *ctx) {
uint32_t size;
uint8_t typ;
uint32_t _size_offset;
@@ -1524,18 +1559,16 @@ LM_FLATTEN static bool validate_Tcreate(struct _validate_ctx *ctx) {
|| validate_tag(ctx)
|| validate_fid(ctx)
|| validate_s(ctx)
- || validate_dm(ctx)
- || validate_o(ctx)
+ || validate_mode(ctx)
+ || validate_nuid(ctx)
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
- || ({ uint8_t exp = 114; (((uint8_t)typ) != exp) &&
+ || ({ uint8_t exp = 72; (((uint8_t)typ) != exp) &&
lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); })
;
}
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000_p9p
-LM_FLATTEN static bool validate_Topenfd(struct _validate_ctx *ctx) {
+LM_FLATTEN static bool validate_Tfsync(struct _validate_ctx *ctx) {
uint32_t size;
uint8_t typ;
uint32_t _size_offset;
@@ -1544,16 +1577,14 @@ LM_FLATTEN static bool validate_Topenfd(struct _validate_ctx *ctx) {
|| (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; }))
|| validate_tag(ctx)
|| validate_fid(ctx)
- || validate_o(ctx)
+ || validate_b4(ctx)
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
- || ({ uint8_t exp = 98; (((uint8_t)typ) != exp) &&
+ || ({ uint8_t exp = 50; (((uint8_t)typ) != exp) &&
lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); })
;
}
-#endif /* CONFIG_9P_ENABLE_9P2000_p9p */
-#if CONFIG_9P_ENABLE_9P2000_L
LM_FLATTEN static bool validate_Tgetattr(struct _validate_ctx *ctx) {
uint32_t size;
uint8_t typ;
@@ -1581,7 +1612,7 @@ LM_FLATTEN static bool validate_Tsetattr(struct _validate_ctx *ctx) {
|| validate_tag(ctx)
|| validate_fid(ctx)
|| validate_setattr(ctx)
- || validate_4(ctx)
+ || validate_mode(ctx)
|| validate_nuid(ctx)
|| validate_nuid(ctx)
|| validate_8(ctx)
@@ -1596,6 +1627,47 @@ LM_FLATTEN static bool validate_Tsetattr(struct _validate_ctx *ctx) {
;
}
+LM_FLATTEN static bool validate_Tgetlock(struct _validate_ctx *ctx) {
+ uint32_t size;
+ uint8_t typ;
+ uint32_t _size_offset;
+ return false
+ || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; }))
+ || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; }))
+ || validate_tag(ctx)
+ || validate_fid(ctx)
+ || validate_lock_type(ctx)
+ || validate_8(ctx)
+ || validate_8(ctx)
+ || validate_4(ctx)
+ || validate_s(ctx)
+ || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
+ lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
+ || ({ uint8_t exp = 54; (((uint8_t)typ) != exp) &&
+ lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); })
+ ;
+}
+
+LM_FLATTEN static bool validate_Rgetlock(struct _validate_ctx *ctx) {
+ uint32_t size;
+ uint8_t typ;
+ uint32_t _size_offset;
+ return false
+ || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; }))
+ || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; }))
+ || validate_tag(ctx)
+ || validate_lock_type(ctx)
+ || validate_8(ctx)
+ || validate_8(ctx)
+ || validate_4(ctx)
+ || validate_s(ctx)
+ || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
+ lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
+ || ({ uint8_t exp = 55; (((uint8_t)typ) != exp) &&
+ lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); })
+ ;
+}
+
LM_FLATTEN static bool validate_Tlock(struct _validate_ctx *ctx) {
uint32_t size;
uint8_t typ;
@@ -1849,9 +1921,9 @@ LM_FLATTEN static bool validate_Rgetattr(struct _validate_ctx *ctx) {
|| (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; }))
|| (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; }))
|| validate_tag(ctx)
- || validate_8(ctx)
+ || validate_getattr(ctx)
|| validate_qid(ctx)
- || validate_4(ctx)
+ || validate_mode(ctx)
|| validate_nuid(ctx)
|| validate_nuid(ctx)
|| validate_8(ctx)
@@ -2001,7 +2073,33 @@ LM_ALWAYS_INLINE static void unmarshal_o(struct _unmarshal_ctx *ctx, lib9p_o_t *
}
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u
+LM_ALWAYS_INLINE static void unmarshal_errno(struct _unmarshal_ctx *ctx, lib9p_errno_t *out) {
+ unmarshal_4(ctx, (uint32_t *)out);
+}
+
+#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000_L
+LM_ALWAYS_INLINE static void unmarshal_super_magic(struct _unmarshal_ctx *ctx, lib9p_super_magic_t *out) {
+ unmarshal_4(ctx, (uint32_t *)out);
+}
+
+LM_ALWAYS_INLINE static void unmarshal_lo(struct _unmarshal_ctx *ctx, lib9p_lo_t *out) {
+ unmarshal_4(ctx, (uint32_t *)out);
+}
+
+LM_ALWAYS_INLINE static void unmarshal_dt(struct _unmarshal_ctx *ctx, lib9p_dt_t *out) {
+ unmarshal_1(ctx, (uint8_t *)out);
+}
+
+LM_ALWAYS_INLINE static void unmarshal_mode(struct _unmarshal_ctx *ctx, lib9p_mode_t *out) {
+ unmarshal_4(ctx, (uint32_t *)out);
+}
+
+LM_ALWAYS_INLINE static void unmarshal_b4(struct _unmarshal_ctx *ctx, lib9p_b4_t *out) {
+ unmarshal_4(ctx, (uint32_t *)out);
+}
+
LM_ALWAYS_INLINE static void unmarshal_getattr(struct _unmarshal_ctx *ctx, lib9p_getattr_t *out) {
unmarshal_8(ctx, (uint64_t *)out);
}
@@ -2082,30 +2180,6 @@ LM_FLATTEN static void unmarshal_Rwstat(struct _unmarshal_ctx *ctx, struct lib9p
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000_L
-LM_FLATTEN static void unmarshal_Rlerror(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rlerror *out) {
- memset(out, 0, sizeof(*out));
- ctx->net_offset += 4;
- ctx->net_offset += 1;
- unmarshal_tag(ctx, &out->tag);
- unmarshal_4(ctx, &out->ecode);
-}
-
-LM_FLATTEN static void unmarshal_Rstatfs(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rstatfs *out) {
- memset(out, 0, sizeof(*out));
- ctx->net_offset += 4;
- ctx->net_offset += 1;
- unmarshal_tag(ctx, &out->tag);
- unmarshal_4(ctx, &out->type);
- unmarshal_4(ctx, &out->bsize);
- unmarshal_8(ctx, &out->blocks);
- unmarshal_8(ctx, &out->bfree);
- unmarshal_8(ctx, &out->bavail);
- unmarshal_8(ctx, &out->files);
- unmarshal_8(ctx, &out->ffree);
- unmarshal_8(ctx, &out->fsid);
- unmarshal_4(ctx, &out->namelen);
-}
-
LM_FLATTEN static void unmarshal_Rrename(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rrename *out) {
memset(out, 0, sizeof(*out));
ctx->net_offset += 4;
@@ -2268,15 +2342,6 @@ LM_FLATTEN static void unmarshal_Tstatfs(struct _unmarshal_ctx *ctx, struct lib9
unmarshal_fid(ctx, &out->fid);
}
-LM_FLATTEN static void unmarshal_Tlopen(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tlopen *out) {
- memset(out, 0, sizeof(*out));
- ctx->net_offset += 4;
- ctx->net_offset += 1;
- unmarshal_tag(ctx, &out->tag);
- unmarshal_fid(ctx, &out->fid);
- unmarshal_4(ctx, &out->flags);
-}
-
LM_FLATTEN static void unmarshal_Treadlink(struct _unmarshal_ctx *ctx, struct lib9p_msg_Treadlink *out) {
memset(out, 0, sizeof(*out));
ctx->net_offset += 4;
@@ -2295,15 +2360,6 @@ LM_FLATTEN static void unmarshal_Treaddir(struct _unmarshal_ctx *ctx, struct lib
unmarshal_4(ctx, &out->count);
}
-LM_FLATTEN static void unmarshal_Tfsync(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tfsync *out) {
- memset(out, 0, sizeof(*out));
- ctx->net_offset += 4;
- ctx->net_offset += 1;
- unmarshal_tag(ctx, &out->tag);
- unmarshal_fid(ctx, &out->fid);
- unmarshal_4(ctx, &out->datasync);
-}
-
#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
LM_FLATTEN static void unmarshal_Tversion(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tversion *out) {
@@ -2324,17 +2380,6 @@ LM_FLATTEN static void unmarshal_Rversion(struct _unmarshal_ctx *ctx, struct lib
unmarshal_s(ctx, &out->version);
}
-LM_FLATTEN static void unmarshal_Rerror(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rerror *out) {
- memset(out, 0, sizeof(*out));
- ctx->net_offset += 4;
- ctx->net_offset += 1;
- unmarshal_tag(ctx, &out->tag);
- unmarshal_s(ctx, &out->ename);
-#if CONFIG_9P_ENABLE_9P2000_u
- if ( is_ver(ctx, 9P2000_u) ) unmarshal_4(ctx, &out->errno);
-#endif /* CONFIG_9P_ENABLE_9P2000_u */
-}
-
LM_FLATTEN static void unmarshal_Twalk(struct _unmarshal_ctx *ctx, struct lib9p_msg_Twalk *out) {
memset(out, 0, sizeof(*out));
ctx->net_offset += 4;
@@ -2390,31 +2435,6 @@ LM_FLATTEN static void unmarshal_Txattrcreate(struct _unmarshal_ctx *ctx, struct
unmarshal_4(ctx, &out->flags);
}
-LM_FLATTEN static void unmarshal_Tgetlock(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tgetlock *out) {
- memset(out, 0, sizeof(*out));
- ctx->net_offset += 4;
- ctx->net_offset += 1;
- unmarshal_tag(ctx, &out->tag);
- unmarshal_fid(ctx, &out->fid);
- unmarshal_1(ctx, &out->type);
- unmarshal_8(ctx, &out->start);
- unmarshal_8(ctx, &out->length);
- unmarshal_4(ctx, &out->proc_id);
- unmarshal_s(ctx, &out->client_id);
-}
-
-LM_FLATTEN static void unmarshal_Rgetlock(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rgetlock *out) {
- memset(out, 0, sizeof(*out));
- ctx->net_offset += 4;
- ctx->net_offset += 1;
- unmarshal_tag(ctx, &out->tag);
- unmarshal_1(ctx, &out->type);
- unmarshal_8(ctx, &out->start);
- unmarshal_8(ctx, &out->length);
- unmarshal_4(ctx, &out->proc_id);
- unmarshal_s(ctx, &out->client_id);
-}
-
LM_FLATTEN static void unmarshal_Tlink(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tlink *out) {
memset(out, 0, sizeof(*out));
ctx->net_offset += 4;
@@ -2515,88 +2535,143 @@ LM_FLATTEN static void unmarshal_Tattach(struct _unmarshal_ctx *ctx, struct lib9
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000_L
-LM_FLATTEN static void unmarshal_Tlcreate(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tlcreate *out) {
+LM_FLATTEN static void unmarshal_Tsymlink(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tsymlink *out) {
memset(out, 0, sizeof(*out));
ctx->net_offset += 4;
ctx->net_offset += 1;
unmarshal_tag(ctx, &out->tag);
unmarshal_fid(ctx, &out->fid);
unmarshal_s(ctx, &out->name);
- unmarshal_4(ctx, &out->flags);
- unmarshal_4(ctx, &out->mode);
+ unmarshal_s(ctx, &out->symtgt);
unmarshal_nuid(ctx, &out->gid);
}
-LM_FLATTEN static void unmarshal_Tsymlink(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tsymlink *out) {
+#endif /* CONFIG_9P_ENABLE_9P2000_L */
+#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
+LM_FLATTEN static void unmarshal_Topen(struct _unmarshal_ctx *ctx, struct lib9p_msg_Topen *out) {
memset(out, 0, sizeof(*out));
ctx->net_offset += 4;
ctx->net_offset += 1;
unmarshal_tag(ctx, &out->tag);
unmarshal_fid(ctx, &out->fid);
- unmarshal_s(ctx, &out->name);
- unmarshal_s(ctx, &out->symtgt);
- unmarshal_nuid(ctx, &out->gid);
+ unmarshal_o(ctx, &out->mode);
}
-LM_FLATTEN static void unmarshal_Tmknod(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tmknod *out) {
+LM_FLATTEN static void unmarshal_Tcreate(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tcreate *out) {
memset(out, 0, sizeof(*out));
ctx->net_offset += 4;
ctx->net_offset += 1;
unmarshal_tag(ctx, &out->tag);
- unmarshal_fid(ctx, &out->dfid);
+ unmarshal_fid(ctx, &out->fid);
unmarshal_s(ctx, &out->name);
- unmarshal_4(ctx, &out->mode);
- unmarshal_4(ctx, &out->major);
- unmarshal_4(ctx, &out->minor);
- unmarshal_nuid(ctx, &out->gid);
+ unmarshal_dm(ctx, &out->perm);
+ unmarshal_o(ctx, &out->mode);
}
-LM_FLATTEN static void unmarshal_Tmkdir(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tmkdir *out) {
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_9P2000_p9p
+LM_FLATTEN static void unmarshal_Topenfd(struct _unmarshal_ctx *ctx, struct lib9p_msg_Topenfd *out) {
memset(out, 0, sizeof(*out));
ctx->net_offset += 4;
ctx->net_offset += 1;
unmarshal_tag(ctx, &out->tag);
- unmarshal_fid(ctx, &out->dfid);
- unmarshal_s(ctx, &out->name);
- unmarshal_4(ctx, &out->mode);
- unmarshal_nuid(ctx, &out->gid);
+ unmarshal_fid(ctx, &out->fid);
+ unmarshal_o(ctx, &out->mode);
}
-#endif /* CONFIG_9P_ENABLE_9P2000_L */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
-LM_FLATTEN static void unmarshal_Topen(struct _unmarshal_ctx *ctx, struct lib9p_msg_Topen *out) {
+#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
+LM_FLATTEN static void unmarshal_Rerror(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rerror *out) {
+ memset(out, 0, sizeof(*out));
+ ctx->net_offset += 4;
+ ctx->net_offset += 1;
+ unmarshal_tag(ctx, &out->tag);
+ unmarshal_s(ctx, &out->ename);
+#if CONFIG_9P_ENABLE_9P2000_u
+ if ( is_ver(ctx, 9P2000_u) ) unmarshal_errno(ctx, &out->errno);
+#endif /* CONFIG_9P_ENABLE_9P2000_u */
+}
+
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_9P2000_L
+LM_FLATTEN static void unmarshal_Rlerror(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rlerror *out) {
+ memset(out, 0, sizeof(*out));
+ ctx->net_offset += 4;
+ ctx->net_offset += 1;
+ unmarshal_tag(ctx, &out->tag);
+ unmarshal_errno(ctx, &out->ecode);
+}
+
+LM_FLATTEN static void unmarshal_Rstatfs(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rstatfs *out) {
+ memset(out, 0, sizeof(*out));
+ ctx->net_offset += 4;
+ ctx->net_offset += 1;
+ unmarshal_tag(ctx, &out->tag);
+ unmarshal_super_magic(ctx, &out->type);
+ unmarshal_4(ctx, &out->bsize);
+ unmarshal_8(ctx, &out->blocks);
+ unmarshal_8(ctx, &out->bfree);
+ unmarshal_8(ctx, &out->bavail);
+ unmarshal_8(ctx, &out->files);
+ unmarshal_8(ctx, &out->ffree);
+ unmarshal_8(ctx, &out->fsid);
+ unmarshal_4(ctx, &out->namelen);
+}
+
+LM_FLATTEN static void unmarshal_Tlopen(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tlopen *out) {
memset(out, 0, sizeof(*out));
ctx->net_offset += 4;
ctx->net_offset += 1;
unmarshal_tag(ctx, &out->tag);
unmarshal_fid(ctx, &out->fid);
- unmarshal_o(ctx, &out->mode);
+ unmarshal_lo(ctx, &out->flags);
}
-LM_FLATTEN static void unmarshal_Tcreate(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tcreate *out) {
+LM_FLATTEN static void unmarshal_Tlcreate(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tlcreate *out) {
memset(out, 0, sizeof(*out));
ctx->net_offset += 4;
ctx->net_offset += 1;
unmarshal_tag(ctx, &out->tag);
unmarshal_fid(ctx, &out->fid);
unmarshal_s(ctx, &out->name);
- unmarshal_dm(ctx, &out->perm);
- unmarshal_o(ctx, &out->mode);
+ unmarshal_lo(ctx, &out->flags);
+ unmarshal_mode(ctx, &out->mode);
+ unmarshal_nuid(ctx, &out->gid);
}
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000_p9p
-LM_FLATTEN static void unmarshal_Topenfd(struct _unmarshal_ctx *ctx, struct lib9p_msg_Topenfd *out) {
+LM_FLATTEN static void unmarshal_Tmknod(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tmknod *out) {
+ memset(out, 0, sizeof(*out));
+ ctx->net_offset += 4;
+ ctx->net_offset += 1;
+ unmarshal_tag(ctx, &out->tag);
+ unmarshal_fid(ctx, &out->dfid);
+ unmarshal_s(ctx, &out->name);
+ unmarshal_mode(ctx, &out->mode);
+ unmarshal_4(ctx, &out->major);
+ unmarshal_4(ctx, &out->minor);
+ unmarshal_nuid(ctx, &out->gid);
+}
+
+LM_FLATTEN static void unmarshal_Tmkdir(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tmkdir *out) {
+ memset(out, 0, sizeof(*out));
+ ctx->net_offset += 4;
+ ctx->net_offset += 1;
+ unmarshal_tag(ctx, &out->tag);
+ unmarshal_fid(ctx, &out->dfid);
+ unmarshal_s(ctx, &out->name);
+ unmarshal_mode(ctx, &out->mode);
+ unmarshal_nuid(ctx, &out->gid);
+}
+
+LM_FLATTEN static void unmarshal_Tfsync(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tfsync *out) {
memset(out, 0, sizeof(*out));
ctx->net_offset += 4;
ctx->net_offset += 1;
unmarshal_tag(ctx, &out->tag);
unmarshal_fid(ctx, &out->fid);
- unmarshal_o(ctx, &out->mode);
+ unmarshal_b4(ctx, &out->datasync);
}
-#endif /* CONFIG_9P_ENABLE_9P2000_p9p */
-#if CONFIG_9P_ENABLE_9P2000_L
LM_FLATTEN static void unmarshal_Tgetattr(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tgetattr *out) {
memset(out, 0, sizeof(*out));
ctx->net_offset += 4;
@@ -2613,7 +2688,7 @@ LM_FLATTEN static void unmarshal_Tsetattr(struct _unmarshal_ctx *ctx, struct lib
unmarshal_tag(ctx, &out->tag);
unmarshal_fid(ctx, &out->fid);
unmarshal_setattr(ctx, &out->valid);
- unmarshal_4(ctx, &out->mode);
+ unmarshal_mode(ctx, &out->mode);
unmarshal_nuid(ctx, &out->uid);
unmarshal_nuid(ctx, &out->gid);
unmarshal_8(ctx, &out->filesize);
@@ -2623,6 +2698,31 @@ LM_FLATTEN static void unmarshal_Tsetattr(struct _unmarshal_ctx *ctx, struct lib
unmarshal_8(ctx, &out->mtime_nsec);
}
+LM_FLATTEN static void unmarshal_Tgetlock(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tgetlock *out) {
+ memset(out, 0, sizeof(*out));
+ ctx->net_offset += 4;
+ ctx->net_offset += 1;
+ unmarshal_tag(ctx, &out->tag);
+ unmarshal_fid(ctx, &out->fid);
+ unmarshal_lock_type(ctx, &out->type);
+ unmarshal_8(ctx, &out->start);
+ unmarshal_8(ctx, &out->length);
+ unmarshal_4(ctx, &out->proc_id);
+ unmarshal_s(ctx, &out->client_id);
+}
+
+LM_FLATTEN static void unmarshal_Rgetlock(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rgetlock *out) {
+ memset(out, 0, sizeof(*out));
+ ctx->net_offset += 4;
+ ctx->net_offset += 1;
+ unmarshal_tag(ctx, &out->tag);
+ unmarshal_lock_type(ctx, &out->type);
+ unmarshal_8(ctx, &out->start);
+ unmarshal_8(ctx, &out->length);
+ unmarshal_4(ctx, &out->proc_id);
+ unmarshal_s(ctx, &out->client_id);
+}
+
LM_FLATTEN static void unmarshal_Tlock(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tlock *out) {
memset(out, 0, sizeof(*out));
ctx->net_offset += 4;
@@ -2772,9 +2872,9 @@ LM_FLATTEN static void unmarshal_Rgetattr(struct _unmarshal_ctx *ctx, struct lib
ctx->net_offset += 4;
ctx->net_offset += 1;
unmarshal_tag(ctx, &out->tag);
- unmarshal_8(ctx, &out->valid);
+ unmarshal_getattr(ctx, &out->valid);
unmarshal_qid(ctx, &out->qid);
- unmarshal_4(ctx, &out->mode);
+ unmarshal_mode(ctx, &out->mode);
unmarshal_nuid(ctx, &out->uid);
unmarshal_nuid(ctx, &out->gid);
unmarshal_8(ctx, &out->nlink);
@@ -3714,7 +3814,7 @@ static bool marshal_Tlopen(struct _marshal_ctx *ctx, struct lib9p_msg_Tlopen *va
MARSHAL_U8LE(ctx, 12);
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
- MARSHAL_U32LE(ctx, val->flags);
+ MARSHAL_U32LE(ctx, val->flags & lo_masks[ctx->ctx->version]);
return false;
}
@@ -3756,8 +3856,8 @@ static bool marshal_Tlcreate(struct _marshal_ctx *ctx, struct lib9p_msg_Tlcreate
MARSHAL_U32LE(ctx, val->fid);
MARSHAL_U16LE(ctx, val->name.len);
MARSHAL_BYTES_ZEROCOPY(ctx, val->name.utf8, val->name.len);
- MARSHAL_U32LE(ctx, val->flags);
- MARSHAL_U32LE(ctx, val->mode);
+ MARSHAL_U32LE(ctx, val->flags & lo_masks[ctx->ctx->version]);
+ MARSHAL_U32LE(ctx, val->mode & mode_masks[ctx->ctx->version]);
MARSHAL_U32LE(ctx, val->gid);
return false;
}
@@ -3843,7 +3943,7 @@ static bool marshal_Tmknod(struct _marshal_ctx *ctx, struct lib9p_msg_Tmknod *va
MARSHAL_U32LE(ctx, val->dfid);
MARSHAL_U16LE(ctx, val->name.len);
MARSHAL_BYTES_ZEROCOPY(ctx, val->name.utf8, val->name.len);
- MARSHAL_U32LE(ctx, val->mode);
+ MARSHAL_U32LE(ctx, val->mode & mode_masks[ctx->ctx->version]);
MARSHAL_U32LE(ctx, val->major);
MARSHAL_U32LE(ctx, val->minor);
MARSHAL_U32LE(ctx, val->gid);
@@ -3978,11 +4078,11 @@ static bool marshal_Rgetattr(struct _marshal_ctx *ctx, struct lib9p_msg_Rgetattr
MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
MARSHAL_U8LE(ctx, 25);
MARSHAL_U16LE(ctx, val->tag);
- MARSHAL_U64LE(ctx, val->valid);
+ MARSHAL_U64LE(ctx, val->valid & getattr_masks[ctx->ctx->version]);
MARSHAL_U8LE(ctx, val->qid.type & qt_masks[ctx->ctx->version]);
MARSHAL_U32LE(ctx, val->qid.vers);
MARSHAL_U64LE(ctx, val->qid.path);
- MARSHAL_U32LE(ctx, val->mode);
+ MARSHAL_U32LE(ctx, val->mode & mode_masks[ctx->ctx->version]);
MARSHAL_U32LE(ctx, val->uid);
MARSHAL_U32LE(ctx, val->gid);
MARSHAL_U64LE(ctx, val->nlink);
@@ -4019,7 +4119,7 @@ static bool marshal_Tsetattr(struct _marshal_ctx *ctx, struct lib9p_msg_Tsetattr
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
MARSHAL_U32LE(ctx, val->valid & setattr_masks[ctx->ctx->version]);
- MARSHAL_U32LE(ctx, val->mode);
+ MARSHAL_U32LE(ctx, val->mode & mode_masks[ctx->ctx->version]);
MARSHAL_U32LE(ctx, val->uid);
MARSHAL_U32LE(ctx, val->gid);
MARSHAL_U64LE(ctx, val->filesize);
@@ -4345,7 +4445,7 @@ static bool marshal_Tmkdir(struct _marshal_ctx *ctx, struct lib9p_msg_Tmkdir *va
MARSHAL_U32LE(ctx, val->dfid);
MARSHAL_U16LE(ctx, val->name.len);
MARSHAL_BYTES_ZEROCOPY(ctx, val->name.utf8, val->name.len);
- MARSHAL_U32LE(ctx, val->mode);
+ MARSHAL_U32LE(ctx, val->mode & mode_masks[ctx->ctx->version]);
MARSHAL_U32LE(ctx, val->gid);
return false;
}
diff --git a/lib9p/idl.gen b/lib9p/idl.gen
index 779b6d5..eaeca49 100755
--- a/lib9p/idl.gen
+++ b/lib9p/idl.gen
@@ -147,8 +147,8 @@ def ifdef_pop(n: int) -> str:
# topo_sorted() ################################################################
-def topo_sorted(typs: list[idl.Type]) -> typing.Iterable[idl.Type]:
- ts: graphlib.TopologicalSorter[idl.Type] = graphlib.TopologicalSorter()
+def topo_sorted(typs: list[idl.UserType]) -> typing.Iterable[idl.UserType]:
+ ts: graphlib.TopologicalSorter[idl.UserType] = graphlib.TopologicalSorter()
for typ in typs:
match typ:
case idl.Number():
@@ -375,7 +375,7 @@ def get_buffer_size(typ: idl.Type, version: str) -> BufferSize:
# Generate .h ##################################################################
-def gen_h(versions: set[str], typs: list[idl.Type]) -> str:
+def gen_h(versions: set[str], typs: list[idl.UserType]) -> str:
global _ifdef_stack
_ifdef_stack = []
@@ -440,9 +440,7 @@ enum {idprefix}version {{
continue
msg = id2typ[n]
ret += ifdef_push(1, c_ver_ifdef(msg.in_versions))
- ret += (
- f"\t{idprefix.upper()}TYP_{msg.typname.ljust(namewidth)} = {msg.msgid},\n"
- )
+ ret += f"\t{idprefix.upper()}TYP_{msg.typname:<{namewidth}} = {msg.msgid},\n"
ret += ifdef_pop(0)
ret += "};\n"
@@ -451,7 +449,7 @@ enum {idprefix}version {{
"""
def per_version_comment(
- typ: idl.Type, fn: typing.Callable[[idl.Type, str], str]
+ typ: idl.UserType, fn: typing.Callable[[idl.UserType, str], str]
) -> str:
lines: dict[str, str] = {}
for version in sorted(typ.in_versions):
@@ -464,14 +462,14 @@ enum {idprefix}version {{
ret = ""
v_width = max(len(c_ver_enum(v)) for v in typ.in_versions)
for version, line in lines.items():
- ret += f"/* {c_ver_enum(version).ljust(v_width)}: {line} */\n"
+ ret += f"/* {c_ver_enum(version):<{v_width}}: {line} */\n"
return ret
for typ in topo_sorted(typs):
ret += "\n"
ret += ifdef_push(1, c_ver_ifdef(typ.in_versions))
- def sum_size(typ: idl.Type, version: str) -> str:
+ def sum_size(typ: idl.UserType, version: str) -> str:
sz = get_buffer_size(typ, version)
assert (
sz.min_size <= sz.exp_size
@@ -496,48 +494,78 @@ enum {idprefix}version {{
prefix = f"{idprefix.upper()}{typ.typname.upper()}_"
namewidth = max(len(name) for name in typ.vals)
for name, val in typ.vals.items():
- ret += f"#define {prefix}{name.ljust(namewidth)} (({c_typename(typ)})UINT{typ.static_size*8}_C({val}))\n"
+ ret += f"#define {prefix}{name:<{namewidth}} (({c_typename(typ)})UINT{typ.static_size*8}_C({val}))\n"
case idl.Bitfield():
ret += f"typedef {c_typename(typ.prim)} {c_typename(typ)};\n"
- names = [
- typ.bits[n] or f" {n}" for n in reversed(range(0, len(typ.bits)))
- ]
- if aliases := [k for k in typ.names if k not in typ.bits]:
- names.append("")
- names.extend(aliases)
- prefix = f"{idprefix.upper()}{typ.typname.upper()}_"
- namewidth = max(len(add_prefix(prefix, name)) for name in names)
- ret += "\n"
- for name in names:
- if name == "":
- ret += "\n"
- continue
+ def bitname(val: idl.Bit | idl.BitAlias) -> str:
+ s = val.bitname
+ match val:
+ case idl.Bit(cat=idl.BitCat.RESERVED):
+ s = "_RESERVED_" + s
+ case idl.Bit(cat=idl.BitCat.SUBFIELD):
+ assert isinstance(typ, idl.Bitfield)
+ n = sum(
+ 1
+ for b in typ.bits[: val.num]
+ if b.cat == idl.BitCat.SUBFIELD
+ and b.bitname == val.bitname
+ )
+ s = f"_{s}_{n}"
+ case idl.Bit(cat=idl.BitCat.UNUSED):
+ return ""
+ return add_prefix(f"{idprefix.upper()}{typ.typname.upper()}_", s)
- if name.startswith(" "):
- vers = typ.in_versions
- c_name = ""
- c_val = f"1<<{name[1:]}"
- else:
- vers = typ.names[name].in_versions
- c_name = add_prefix(prefix, name)
- c_val = f"{typ.names[name].val}"
+ namewidth = max(
+ len(bitname(val)) for val in [*typ.bits, *typ.names.values()]
+ )
+ ret += "\n"
+ for bit in reversed(typ.bits):
+ vers = bit.in_versions
+ if bit.cat == idl.BitCat.UNUSED:
+ vers = typ.in_versions
ret += ifdef_push(2, c_ver_ifdef(vers))
# It is important all of the `beg` strings have
# the same length.
end = ""
- if name.startswith(" "):
- beg = "/* unused"
- end = " */"
- elif _ifdef_stack[-1]:
- beg = "# define"
- else:
- beg = "#define "
+ match bit.cat:
+ case (
+ idl.BitCat.USED | idl.BitCat.RESERVED | idl.BitCat.SUBFIELD
+ ):
+ if _ifdef_stack[-1]:
+ beg = "# define"
+ else:
+ beg = "#define "
+ case idl.BitCat.UNUSED:
+ beg = "/* unused"
+ end = " */"
+
+ c_name = bitname(bit)
+ c_val = f"1<<{bit.num}"
+ ret += f"{beg} {c_name:<{namewidth}} (({c_typename(typ)})({c_val})){end}\n"
+ if aliases := [
+ alias
+ for alias in typ.names.values()
+ if isinstance(alias, idl.BitAlias)
+ ]:
+ ret += "\n"
- ret += f"{beg} {c_name.ljust(namewidth)} (({c_typename(typ)})({c_val})){end}\n"
+ for alias in aliases:
+ ret += ifdef_push(2, c_ver_ifdef(alias.in_versions))
+
+ end = ""
+ if _ifdef_stack[-1]:
+ beg = "# define"
+ else:
+ beg = "#define "
+
+ c_name = bitname(alias)
+ c_val = alias.val
+ ret += f"{beg} {c_name:<{namewidth}} (({c_typename(typ)})({c_val})){end}\n"
ret += ifdef_pop(1)
+ del bitname
case idl.Struct(): # and idl.Message():
ret += c_typename(typ) + " {"
if not typ.members:
@@ -551,9 +579,10 @@ enum {idprefix}version {{
if member.val:
continue
ret += ifdef_push(2, c_ver_ifdef(member.in_versions))
- ret += f"\t{c_typename(member.typ, member).ljust(typewidth)} {'*' if member.cnt else ' '}{member.membname};\n"
+ ret += f"\t{c_typename(member.typ, member):<{typewidth}} {'*' if member.cnt else ' '}{member.membname};\n"
ret += ifdef_pop(1)
ret += "};\n"
+ del typ
ret += ifdef_pop(0)
ret += """
@@ -643,7 +672,7 @@ enum {idprefix}version {{
# Generate .c ##################################################################
-def gen_c(versions: set[str], typs: list[idl.Type]) -> str:
+def gen_c(versions: set[str], typs: list[idl.UserType]) -> str:
global _ifdef_stack
_ifdef_stack = []
@@ -746,8 +775,13 @@ const char *const _{idprefix}table_ver_name[{c_ver_enum('NUM')}] = {{
ret += (
f"\t[{c_ver_enum(ver)}]{' '*(verwidth-len(ver))} = 0b"
+ "".join(
- "1" if typ.bit_is_valid(bitname, ver) else "0"
- for bitname in reversed(typ.bits)
+ (
+ "1"
+ if bit.cat in (idl.BitCat.USED, idl.BitCat.SUBFIELD)
+ and ver in bit.in_versions
+ else "0"
+ )
+ for bit in reversed(typ.bits)
)
+ ",\n"
)
@@ -1088,7 +1122,7 @@ LM_ALWAYS_INLINE static void unmarshal_8(struct _unmarshal_ctx *ctx, uint64_t *o
type OffsetExprRecursion = typing.Callable[[Path], WalkCmd]
- def get_offset_expr(typ: idl.Type, recurse: OffsetExprRecursion) -> OffsetExpr:
+ def get_offset_expr(typ: idl.UserType, recurse: OffsetExprRecursion) -> OffsetExpr:
if not isinstance(typ, idl.Struct):
assert typ.static_size
ret = OffsetExpr()
@@ -1384,8 +1418,10 @@ def main() -> None:
)
assert e.text
print(f"\t{e.text}", file=sys.stderr)
+ text_suffix = e.text.lstrip()
+ text_prefix = e.text[: -len(text_suffix)]
print(
- f"\t{ANSIColors.RED}{'~'*len(e.text)}{ANSIColors.RESET}",
+ f"\t{text_prefix}{ANSIColors.RED}{'~'*len(text_suffix)}{ANSIColors.RESET}",
file=sys.stderr,
)
sys.exit(2)
diff --git a/lib9p/idl/0000-README.md b/lib9p/idl/0000-README.md
index 036de22..e19a1e8 100644
--- a/lib9p/idl/0000-README.md
+++ b/lib9p/idl/0000-README.md
@@ -41,6 +41,11 @@ and messages (which are a special-case of structures).
msg Tname = "size[4,val=end-&size] typ[1,val=TYP] tag[tag] REST..."
+Bitfield bit names may be wrapped in `reserved(...)` or
+`subfield(...)`; reserved indicates that the bit is named but is not
+allowed to be used, and subfield indicates that the bit is part of a
+num/enum that is handled by an alias.
+
Struct fields that have numeric types (either primitives or `num`
types) can add to their type `,val=` and/or `,max=` to specify what
the exact value must be and/or what the maximum (inclusive) value is.
diff --git a/lib9p/idl/2002-9P2000.9p b/lib9p/idl/2002-9P2000.9p
index 438e02f..2a4f7ed 100644
--- a/lib9p/idl/2002-9P2000.9p
+++ b/lib9p/idl/2002-9P2000.9p
@@ -42,7 +42,7 @@ bitfield dm = 4
# that the file is mounted by the kernel as a 9P transport;
# that the kernel has a lock on doing I/O on it, so userspace
# can't do I/O on it.
- "28=_PLAN9_MOUNT"
+ "28=reserved(PLAN9_MOUNT)"
"27=AUTH"
"26=TMP"
#...
@@ -63,7 +63,7 @@ bitfield qt = 1
"7=DIR"
"6=APPEND"
"5=EXCL"
- "4=_PLAN9_MOUNT" # See "_PLAN9_MOUNT" in "dm" above.
+ "4=reserved(PLAN9_MOUNT)" # See "PLAN9_MOUNT" in "dm" above.
"3=AUTH"
# Fun historical fact: QTTMP was a relatively late addition to
# Plan 9, in 2003-12.
@@ -107,12 +107,12 @@ struct stat = "stat_size[2,val=end-&kern_type]"
# "O"pen flags (flags to pass to Topen and Tcreate)
# Unused bits *must* be 0.
bitfield o = 1
- "0=mode_0" # low bit of the 2-bit READ/WRITE/RDWR/EXEC enum
- "1=mode_1" # high bit of the 2-bit READ/WRITE/RDWR/EXEC enum
+ "0=subfield(mode)" # low bit of the 2-bit READ/WRITE/RDWR/EXEC enum
+ "1=subfield(mode)" # high bit of the 2-bit READ/WRITE/RDWR/EXEC enum
#"2=unused"
#"3=unused"
"4=TRUNC"
- #"5=_reserved_CEXEC" # close-on-exec
+ "5=reserved(CEXEC)" # close-on-exec
"6=RCLOSE" # remove-on-close
#"7=unused"
diff --git a/lib9p/idl/2005-9P2000.u.9p b/lib9p/idl/2005-9P2000.u.9p
index d96bbce..fefe3e9 100644
--- a/lib9p/idl/2005-9P2000.u.9p
+++ b/lib9p/idl/2005-9P2000.u.9p
@@ -14,6 +14,9 @@ from ./2002-9P2000.9p import *
num nuid = 4
"NONUID = ~0"
+num errno = 4
+ "NOERROR = 0"
+
struct stat += "file_extension[s]"
"file_owner_n_uid[nuid]"
"file_owner_n_gid[nuid]"
@@ -22,7 +25,7 @@ struct stat += "file_extension[s]"
msg Tauth += "n_uid[nuid]"
msg Tattach += "n_uid[nuid]"
-msg Rerror += "errno[4]"
+msg Rerror += "errno[errno]"
bitfield dm += "23=DEVICE"
"21=NAMEDPIPE"
diff --git a/lib9p/idl/2010-9P2000.L.9p b/lib9p/idl/2010-9P2000.L.9p
index e21d411..7ac86a6 100644
--- a/lib9p/idl/2010-9P2000.L.9p
+++ b/lib9p/idl/2010-9P2000.L.9p
@@ -5,82 +5,206 @@
# "9P2000.L" Linux extension
# https://github.com/chaos/diod/blob/master/protocol.md
+# https://github.com/chaos/diod/blob/master/src/libnpfs/protocol.h
version "9P2000.L"
from ./2002-9P2000.9p import tag, fid, s, qt, qid
from ./2002-9P2000.9p import Rerror
from ./2002-9P2000.9p import Tversion, Rversion, Tflush, Rflush, Twalk, Rwalk, Tread, Rread, Twrite, Rwrite, Tclunk, Rclunk, Tremove, Rremove
-from ./2005-9P2000.u.9p import nuid, Tauth, Rauth, Tattach, Rattach
+from ./2005-9P2000.u.9p import nuid, errno, Tauth, Rauth, Tattach, Rattach
+
+#num errno += # TODO
+
+num super_magic = 4
+ # See <linux/magic.h> (linux.git include/uapi/linux/magic.h).
+ #
+ # To quote `util-linux.git:include/statfs_magic.h`:
+ # "Unfortunately, Linux kernel header file <linux/magic.h> is
+ # incomplete mess and kernel returns by statfs f_type many numbers
+ # that are nowhere specified (in API)."
+ #
+ # util-linux <statfs_magic.h> is also incomplete. As is the
+ # statfs(2) man-page.
+ #
+ # I'm working on a patchset to the kernel to get <linux/magic.h>
+ # to be complete, but in the mean-time I'm just not going to
+ # bother with putting a list here.
+ #
+ # TODO
+ "V9FS_MAGIC=0x01021997"
+
+# "L"inux "O"pen flags (flags to pass to Tlopen and Tlcreate)
+#
+# The values are not specified in in protocol.md, but are specified in
+# protocol.h (and are different than the Linux kernel's values, which
+# vary by architecture).
+bitfield lo = 4
+ "0=subfield(mode)" # low bit of the 2-bit RDONLY/WRONLY/RDWR/NOACCESS enum
+ "1=subfield(mode)" # high bit of the 2-bit RDONLY/WRONLY/RDWR/NOACCESS enum
+ #"2=unused"
+ #"3=unused"
+ #"4=unused"
+ #"5=unused"
+ "6=CREATE"
+ "7=EXCL"
+ "8=NOCTTY"
+ "9=TRUNC"
+ "10=APPEND"
+ "11=NONBLOCK"
+ "12=DSYNC"
+ "13=BSD_FASYNC"
+ "14=DIRECT"
+ "15=LARGEFILE"
+ "16=DIRECTORY"
+ "17=NOFOLLOW"
+ "18=NOATIME"
+ "19=CLOEXEC"
+ "20=SYNC"
+
+ "RDONLY = 0"
+ "WRONLY = 1"
+ "RDWR = 2"
+ "NOACCESS = 3"
+
+ "MODE_MASK = 0b000000000000000000011"
+ "FLAG_MASK = 0b111111111111111000000"
+
+# "D"irentry "T"ype
+#
+# These match the Linux kernel's values.
+num dt = 1
+ "UNKNOWN = 0"
+ "NAMED_PIPE = 1"
+ "CHAR_DEV = 2"
+ "DIRECTORY = 4"
+ "BLOCK_DEV = 6"
+ "REGULAR = 8"
+ "SYMLINK = 10"
+ "SOCKET = 12"
+ "WHITEOUT = 14"
+
+# Mode
+#
+# These match the Linux kernel's values. Why is this 32-bits wide
+# instead of just 16? Who knows?
+bitfield mode = 4
+ #...
+ "15=subfield(fmt)" # bit of the 4-bit FMT_ enum
+ "14=subfield(fmt)" # bit of the 4-bit FMT_ enum
+ "13=subfield(fmt)" # bit of the 4-bit FMT_ enum
+ "12=subfield(fmt)" # bit of the 4-bit FMT_ enum
+ #...
+ "11=PERM_SETGROUP"
+ "10=PERM_SETUSER"
+ "9=PERM_STICKY"
+ "8=PERM_OWNER_R"
+ "7=PERM_OWNER_W"
+ "6=PERM_OWNER_X"
+ "5=PERM_GROUP_R"
+ "4=PERM_GROUP_W"
+ "3=PERM_GROUP_X"
+ "2=PERM_OTHER_R"
+ "1=PERM_OTHER_W"
+ "0=PERM_OTHER_X"
+
+ "FMT_NAMED_PIPE = LIB9P_DT_NAMED_PIPE<<12"
+ "FMT_CHAR_DEV = LIB9P_DT_CHAR_DEV<<12"
+ "FMT_DIRECTORY = LIB9P_DT_DIRECTORY<<12"
+ "FMT_BLOCK_DEV = LIB9P_DT_BLOCK_DEV<<12"
+ "FMT_REGULAR = LIB9P_DT_REGULAR<<12"
+ "FMT_SYMLINK = LIB9P_DT_SYMLINK<<12"
+ "FMT_SOCKET = LIB9P_DT_SOCKET<<12"
+
+ "PERM_MASK = 0000777" # PERM_*
+ "FMT_MASK = 0170000" # _fmt_*
+
+# A boolean value that is for some reason 4 bytes wide.
+num b4 = 4
+ "FALSE=0"
+ "TRUE=1"
+ # all other values are true also
bitfield getattr = 8
- "0=MODE"
- "1=NLINK"
- "2=UID"
- "3=GID"
- "4=RDEV"
- "5=ATIME"
- "6=MTIME"
- "7=CTIME"
- "8=INO"
- "9=SIZE"
- "10=BLOCKS"
-
- "11=BTIME"
- "12=GEN"
- "13=DATA_VERSION"
-
- "BASIC=0x000007ff" # Mask for fields up to BLOCKS
- "ALL =0x00003fff" # Mask for All fields above
+ "0=MODE"
+ "1=NLINK"
+ "2=UID"
+ "3=GID"
+ "4=RDEV"
+ "5=ATIME"
+ "6=MTIME"
+ "7=CTIME"
+ "8=INO"
+ "9=SIZE"
+ "10=BLOCKS"
+
+ "11=BTIME"
+ "12=GEN"
+ "13=DATA_VERSION"
+
+ "BASIC=0x000007ff" # Mask for fields up to BLOCKS
+ "ALL =0x00003fff" # Mask for All fields above
bitfield setattr = 4
- "0=MODE"
- "1=UID"
- "2=GID"
- "3=SIZE"
- "4=ATIME"
- "5=MTIME"
- "6=CTIME"
- "7=ATIME_SET"
- "8=MTIME_SET"
+ "0=MODE"
+ "1=UID"
+ "2=GID"
+ "3=SIZE"
+ "4=ATIME"
+ "5=MTIME"
+ "6=CTIME"
+ "7=ATIME_SET"
+ "8=MTIME_SET"
num lock_type = 1
- "RDLCK=0"
- "WRLCK=1"
- "UNLCK=2"
+ "RDLCK=0"
+ "WRLCK=1"
+ "UNLCK=2"
bitfield lock_flags = 4
- "0=BLOCK"
- "1=RECLAIM"
+ "0=BLOCK"
+ "1=RECLAIM"
num lock_status = 1
- "SUCCESS=0"
- "BLOCKED=1"
- "ERROR=2"
- "GRACE=3"
+ "SUCCESS=0"
+ "BLOCKED=1"
+ "ERROR=2"
+ "GRACE=3"
#msg Tlerror = "size[4,val=end-&size] typ[1,val=6] tag[tag] illegal" # analogous to 106/Terror
-msg Rlerror = "size[4,val=end-&size] typ[1,val=7] tag[tag] ecode[4]" # analogous to 107/Rerror
+msg Rlerror = "size[4,val=end-&size] typ[1,val=7] tag[tag] ecode[errno]" # analogous to 107/Rerror
msg Tstatfs = "size[4,val=end-&size] typ[1,val=8] tag[tag] fid[fid]"
-msg Rstatfs = "size[4,val=end-&size] typ[1,val=9] tag[tag] type[4] bsize[4] blocks[8] bfree[8] bavail[8] files[8] ffree[8] fsid[8] namelen[4]"
-msg Tlopen = "size[4,val=end-&size] typ[1,val=12] tag[tag] fid[fid] flags[4]" # analogous to 112/Topen
+msg Rstatfs = "size[4,val=end-&size] typ[1,val=9] tag[tag]" # Description | statfs | statvfs
+ "type[super_magic]" # Type of filesystem | f_type | -
+ "bsize[4]" # Block size in bytes | f_bsize | f_bsize
+ # - # Fragment size in bytes | f_frsize (since Linux 2.6) | f_frsize
+ "blocks[8]" # Size of FS in f_frsize units | f_blocks | f_blocks
+ "bfree[8]" # Number of free blocks | f_bfree | f_bfree
+ "bavail[8]" # Number of free blocks for unprivileged users | f_bavail | b_avail
+ "files[8]" # Number of inodes | f_files | f_files
+ "ffree[8]" # Number of free inodes | f_ffree | f_ffree
+ # - # Number of free inodes for unprivileged users | - | f_favail
+ "fsid[8]" # Filesystem instance ID | f_fsid | f_fsid
+ # - # Mount flags | f_flags (since Linux 2.6.36) | f_flag
+ "namelen[4]" # Maximum filename length | f_namemax | f_namemax
+msg Tlopen = "size[4,val=end-&size] typ[1,val=12] tag[tag] fid[fid] flags[lo]" # analogous to 112/Topen
msg Rlopen = "size[4,val=end-&size] typ[1,val=13] tag[tag] qid[qid] iounit[4]" # analogous to 113/Ropen
-msg Tlcreate = "size[4,val=end-&size] typ[1,val=14] tag[tag] fid[fid] name[s] flags[4] mode[4] gid[nuid]" # analogous to 114/Tcreate
+msg Tlcreate = "size[4,val=end-&size] typ[1,val=14] tag[tag] fid[fid] name[s] flags[lo] mode[mode] gid[nuid]" # analogous to 114/Tcreate
msg Rlcreate = "size[4,val=end-&size] typ[1,val=15] tag[tag] qid[qid] iounit[4]" # analogous to 115/Rcreate
msg Tsymlink = "size[4,val=end-&size] typ[1,val=16] tag[tag] fid[fid] name[s] symtgt[s] gid[nuid]"
msg Rsymlink = "size[4,val=end-&size] typ[1,val=17] tag[tag] qid[qid]"
-msg Tmknod = "size[4,val=end-&size] typ[1,val=18] tag[tag] dfid[fid] name[s] mode[4] major[4] minor[4] gid[nuid]"
+msg Tmknod = "size[4,val=end-&size] typ[1,val=18] tag[tag] dfid[fid] name[s] mode[mode] major[4] minor[4] gid[nuid]"
msg Rmknod = "size[4,val=end-&size] typ[1,val=19] tag[tag] qid[qid]"
msg Trename = "size[4,val=end-&size] typ[1,val=20] tag[tag] fid[fid] dfid[fid] name[s]"
msg Rrename = "size[4,val=end-&size] typ[1,val=21] tag[tag]"
msg Treadlink = "size[4,val=end-&size] typ[1,val=22] tag[tag] fid[fid]"
msg Rreadlink = "size[4,val=end-&size] typ[1,val=23] tag[tag] target[s]"
msg Tgetattr = "size[4,val=end-&size] typ[1,val=24] tag[tag] fid[fid] request_mask[getattr]"
-msg Rgetattr = "size[4,val=end-&size] typ[1,val=25] tag[tag] valid[8] qid[qid] mode[4] uid[nuid] gid[nuid] nlink[8]"
+msg Rgetattr = "size[4,val=end-&size] typ[1,val=25] tag[tag] valid[getattr] qid[qid] mode[mode] uid[nuid] gid[nuid] nlink[8]"
"rdev[8] filesize[8] blksize[8] blocks[8]"
"atime_sec[8] atime_nsec[8] mtime_sec[8] mtime_nsec[8]"
"ctime_sec[8] ctime_nsec[8] btime_sec[8] btime_nsec[8]"
"gen[8] data_version[8]"
-msg Tsetattr = "size[4,val=end-&size] typ[1,val=26] tag[tag] fid[fid] valid[setattr] mode[4] uid[nuid] gid[nuid] filesize[8] atime_sec[8] atime_nsec[8] mtime_sec[8] mtime_nsec[8]"
+msg Tsetattr = "size[4,val=end-&size] typ[1,val=26] tag[tag] fid[fid] valid[setattr] mode[mode] uid[nuid] gid[nuid] filesize[8] atime_sec[8] atime_nsec[8] mtime_sec[8] mtime_nsec[8]"
msg Rsetattr = "size[4,val=end-&size] typ[1,val=27] tag[tag]"
#...
msg Txattrwalk = "size[4,val=end-&size] typ[1,val=30] tag[tag] fid[fid] newfid[fid] name[s]"
@@ -89,18 +213,18 @@ msg Txattrcreate = "size[4,val=end-&size] typ[1,val=32] tag[tag] fid[fid] name[s
msg Rxattrcreate = "size[4,val=end-&size] typ[1,val=33] tag[tag]"
#...
msg Treaddir = "size[4,val=end-&size] typ[1,val=40] tag[tag] fid[fid] offset[8] count[4]"
-msg Rreaddir = "size[4,val=end-&size] typ[1,val=41] tag[tag] count[4] count*(data[1])" # data is "qid[qid] offset[8] type[1] name[s]"
+msg Rreaddir = "size[4,val=end-&size] typ[1,val=41] tag[tag] count[4] count*(data[1])" # data is "qid[qid] offset[8] type[dt] name[s]"
#...
-msg Tfsync = "size[4,val=end-&size] typ[1,val=50] tag[tag] fid[fid] datasync[4]"
+msg Tfsync = "size[4,val=end-&size] typ[1,val=50] tag[tag] fid[fid] datasync[b4]"
msg Rfsync = "size[4,val=end-&size] typ[1,val=51] tag[tag]"
msg Tlock = "size[4,val=end-&size] typ[1,val=52] tag[tag] fid[fid] type[lock_type] flags[lock_flags] start[8] length[8] proc_id[4] client_id[s]"
msg Rlock = "size[4,val=end-&size] typ[1,val=53] tag[tag] status[lock_status]"
-msg Tgetlock = "size[4,val=end-&size] typ[1,val=54] tag[tag] fid[fid] type[1] start[8] length[8] proc_id[4] client_id[s]"
-msg Rgetlock = "size[4,val=end-&size] typ[1,val=55] tag[tag] type[1] start[8] length[8] proc_id[4] client_id[s]"
+msg Tgetlock = "size[4,val=end-&size] typ[1,val=54] tag[tag] fid[fid] type[lock_type] start[8] length[8] proc_id[4] client_id[s]"
+msg Rgetlock = "size[4,val=end-&size] typ[1,val=55] tag[tag] type[lock_type] start[8] length[8] proc_id[4] client_id[s]"
# ...
msg Tlink = "size[4,val=end-&size] typ[1,val=70] tag[tag] dfid[fid] fid[fid] name[s]"
msg Rlink = "size[4,val=end-&size] typ[1,val=71] tag[tag]"
-msg Tmkdir = "size[4,val=end-&size] typ[1,val=72] tag[tag] dfid[fid] name[s] mode[4] gid[nuid]"
+msg Tmkdir = "size[4,val=end-&size] typ[1,val=72] tag[tag] dfid[fid] name[s] mode[mode] gid[nuid]"
msg Rmkdir = "size[4,val=end-&size] typ[1,val=73] tag[tag] qid[qid]"
msg Trenameat = "size[4,val=end-&size] typ[1,val=74] tag[tag] olddirfid[fid] oldname[s] newdirfid[fid] newname[s]"
msg Rrenameat = "size[4,val=end-&size] typ[1,val=75] tag[tag]"
diff --git a/lib9p/idl/__init__.py b/lib9p/idl/__init__.py
index 042a438..e7b3670 100644
--- a/lib9p/idl/__init__.py
+++ b/lib9p/idl/__init__.py
@@ -16,7 +16,7 @@ __all__ = [
"Type",
"Primitive",
"Number",
- *["Bitfield", "BitfieldVal"],
+ *["Bitfield", "Bit", "BitCat", "BitAlias"],
*["Struct", "StructMember", "Expr", "ExprOp", "ExprSym", "ExprLit"],
"Message",
]
@@ -74,27 +74,49 @@ class Number:
return self.static_size
-class BitfieldVal:
+class BitCat(enum.Enum):
+ UNUSED = 1
+ USED = 2
+ RESERVED = 3
+ SUBFIELD = 4
+
+
+class Bit:
bitname: str
in_versions: set[str]
+ num: int
+ cat: BitCat
- val: str
+ def __init__(self, num: int) -> None:
+ self.bitname = ""
+ self.in_versions = set()
+ self.num = num
+ self.cat = BitCat.UNUSED
- def __init__(self) -> None:
+
+class BitAlias:
+ bitname: str
+ in_versions: set[str]
+ val: str # FIXME: Don't have bitfield aliases be raw C expressions
+
+ def __init__(self, name: str, val: str) -> None:
+ self.bitname = name
self.in_versions = set()
+ self.val = val
class Bitfield:
typname: str
in_versions: set[str]
-
prim: Primitive
+ bits: list[Bit]
+ names: dict[str, Bit | BitAlias]
- bits: list[str] # bitnames
- names: dict[str, BitfieldVal] # bits *and* aliases
-
- def __init__(self) -> None:
+ def __init__(self, name: str, prim: Primitive) -> None:
+ self.typname = name
self.in_versions = set()
+ self.prim = prim
+ self.bits = [Bit(i) for i in range(prim.static_size * 8)]
self.names = {}
@property
@@ -107,21 +129,6 @@ class Bitfield:
def max_size(self, version: str) -> int:
return self.static_size
- def bit_is_valid(self, bit: str | int, ver: str | None = None) -> bool:
- """Return whether the given bit is valid in the given protocol
- version.
-
- """
- bitname = self.bits[bit] if isinstance(bit, int) else bit
- assert bitname in self.bits
- if not bitname:
- return False
- if bitname.startswith("_"):
- return False
- if ver and (ver not in self.names[bitname].in_versions):
- return False
- return True
-
class ExprLit:
val: int
@@ -169,12 +176,10 @@ class StructMember:
assert self.cnt
if not isinstance(self.cnt.typ, Primitive):
raise ValueError(
- f"list count must be an integer type: {repr(self.cnt.membname)}"
+ f"list count must be an integer type: {self.cnt.membname!r}"
)
if self.cnt.val: # TODO: allow this?
- raise ValueError(
- f"list count may not have ,val=: {repr(self.cnt.membname)}"
- )
+ raise ValueError(f"list count may not have ,val=: {self.cnt.membname!r}")
return 0
@property
@@ -182,17 +187,15 @@ class StructMember:
assert self.cnt
if not isinstance(self.cnt.typ, Primitive):
raise ValueError(
- f"list count must be an integer type: {repr(self.cnt.membname)}"
+ f"list count must be an integer type: {self.cnt.membname!r}"
)
if self.cnt.val: # TODO: allow this?
- raise ValueError(
- f"list count may not have ,val=: {repr(self.cnt.membname)}"
- )
+ raise ValueError(f"list count may not have ,val=: {self.cnt.membname!r}")
if self.cnt.max:
# TODO: be more flexible?
if len(self.cnt.max.tokens) != 1:
raise ValueError(
- f"list count ,max= may only have 1 token: {repr(self.cnt.membname)}"
+ f"list count ,max= may only have 1 token: {self.cnt.membname!r}"
)
match tok := self.cnt.max.tokens[0]:
case ExprLit():
@@ -203,7 +206,7 @@ class StructMember:
return (1 << 63) - 1
case _:
raise ValueError(
- f'list count ,max= only allows literal, "s32_max", and "s64_max" tokens: {repr(self.cnt.membname)}'
+ f'list count ,max= only allows literal, "s32_max", and "s64_max" tokens: {self.cnt.membname!r}'
)
return (1 << (self.cnt.typ.value * 8)) - 1
@@ -271,12 +274,15 @@ class Message(Struct):
type Type = Primitive | Number | Bitfield | Struct | Message
+type UserType = Number | Bitfield | Struct | Message
T = typing.TypeVar("T", Number, Bitfield, Struct, Message)
# Parse ########################################################################
re_priname = "(?:1|2|4|8)" # primitive names
re_symname = "(?:[a-zA-Z_][a-zA-Z_0-9]*)" # "symbol" names; most *.9p-defined names
+re_symname_u = "(?:[A-Z_][A-Z_0-9]*)" # upper-case "symbol" names; bit names
+re_symname_l = "(?:[a-z_][a-z_0-9]*)" # lower-case "symbol" names; bit names
re_impname = r"(?:\*|" + re_symname + ")" # names we can import
re_msgname = r"(?:[TR][a-zA-Z_0-9]*)" # names a message can be
@@ -286,8 +292,18 @@ re_expr = f"(?:(?:-|\\+|[0-9]+|&?{re_symname})+)"
re_numspec = f"(?P<name>{re_symname})\\s*=\\s*(?P<val>\\S+)"
-re_bitspec_bit = f"(?P<bit>[0-9]+)\\s*=\\s*(?P<name>{re_symname})"
-re_bitspec_alias = f"(?P<name>{re_symname})\\s*=\\s*(?P<val>\\S+)"
+re_bitspec_bit = (
+ "(?P<bitnum>[0-9]+)\\s*=\\s*(?:"
+ + "|".join(
+ [
+ f"(?P<name_used>{re_symname_u})",
+ f"reserved\\((?P<name_reserved>{re_symname_u})\\)",
+ f"subfield\\((?P<name_subfield>{re_symname_l})\\)",
+ ]
+ )
+ + ")"
+)
+re_bitspec_alias = f"(?P<name>{re_symname_u})\\s*=\\s*(?P<val>\\S+)"
re_memberspec = f"(?:(?P<cnt>{re_symname})\\*\\()?(?P<name>{re_symname})\\[(?P<typ>{re_memtype})(?:,max=(?P<max>{re_expr})|,val=(?P<val>{re_expr}))*\\]\\)?"
@@ -299,45 +315,57 @@ def parse_numspec(ver: str, n: Number, spec: str) -> None:
name = m.group("name")
val = m.group("val")
if name in n.vals:
- raise ValueError(f"{n.typname}: name {repr(name)} already assigned")
+ raise ValueError(f"{n.typname}: name {name!r} already assigned")
n.vals[name] = val
else:
- raise SyntaxError(f"invalid num spec {repr(spec)}")
+ raise SyntaxError(f"invalid num spec {spec!r}")
def parse_bitspec(ver: str, bf: Bitfield, spec: str) -> None:
spec = spec.strip()
- bit: int | None
- val: BitfieldVal
if m := re.fullmatch(re_bitspec_bit, spec):
- bit = int(m.group("bit"))
- name = m.group("name")
-
- val = BitfieldVal()
- val.bitname = name
- val.val = f"1<<{bit}"
- val.in_versions.add(ver)
-
- if bit < 0 or bit >= len(bf.bits):
- raise ValueError(f"{bf.typname}: bit {bit} is out-of-bounds")
- if bf.bits[bit]:
- raise ValueError(f"{bf.typname}: bit {bit} already assigned")
- bf.bits[bit] = val.bitname
+ bitnum = int(m.group("bitnum"))
+ if bitnum < 0 or bitnum >= len(bf.bits):
+ raise ValueError(f"{bf.typname}: bit num {bitnum} out-of-bounds")
+ bit = bf.bits[bitnum]
+ if bit.cat != BitCat.UNUSED:
+ raise ValueError(f"{bf.typname}: bit num {bitnum} already assigned")
+ if name := m.group("name_used"):
+ bit.bitname = name
+ bit.cat = BitCat.USED
+ bit.in_versions.add(ver)
+ elif name := m.group("name_reserved"):
+ bit.bitname = name
+ bit.cat = BitCat.RESERVED
+ bit.in_versions.add(ver)
+ elif name := m.group("name_subfield"):
+ bit.bitname = name
+ bit.cat = BitCat.SUBFIELD
+ bit.in_versions.add(ver)
+ if bit.bitname:
+ if bit.bitname in bf.names:
+ other = bf.names[bit.bitname]
+ if (
+ isinstance(other, Bit)
+ and other.cat == bit.cat
+ and bit.cat == BitCat.SUBFIELD
+ ):
+ return
+ raise ValueError(
+ f"{bf.typname}: bit name {bit.bitname!r} already assigned"
+ )
+ bf.names[bit.bitname] = bit
elif m := re.fullmatch(re_bitspec_alias, spec):
- name = m.group("name")
- valstr = m.group("val")
-
- val = BitfieldVal()
- val.bitname = name
- val.val = valstr
- val.in_versions.add(ver)
+ alias = BitAlias(m.group("name"), m.group("val"))
+ alias.in_versions.add(ver)
+ if alias.bitname in bf.names:
+ raise ValueError(
+ f"{bf.typname}: bit name {alias.bitname!r} already assigned"
+ )
+ bf.names[alias.bitname] = alias
else:
- raise SyntaxError(f"invalid bitfield spec {repr(spec)}")
-
- if val.bitname in bf.names:
- raise ValueError(f"{bf.typname}: name {val.bitname} already assigned")
- bf.names[val.bitname] = val
+ raise SyntaxError(f"invalid bitfield spec {spec!r}")
def parse_expr(expr: str) -> Expr:
@@ -359,7 +387,7 @@ def parse_members(ver: str, env: dict[str, Type], struct: Struct, specs: str) ->
for spec in specs.split():
m = re.fullmatch(re_memberspec, spec)
if not m:
- raise SyntaxError(f"invalid member spec {repr(spec)}")
+ raise SyntaxError(f"invalid member spec {spec!r}")
member = StructMember()
member.in_versions = {ver}
@@ -369,12 +397,12 @@ def parse_members(ver: str, env: dict[str, Type], struct: Struct, specs: str) ->
raise ValueError(f"duplicate member name {member.membname!r}")
if m.group("typ") not in env:
- raise NameError(f"Unknown type {repr(m.group('typ'))}")
+ raise NameError(f"Unknown type {m.group('typ')!r}")
member.typ = env[m.group("typ")]
if cnt := m.group("cnt"):
if len(struct.members) == 0 or struct.members[-1].membname != cnt:
- raise ValueError(f"list count must be previous item: {repr(cnt)}")
+ raise ValueError(f"list count must be previous item: {cnt!r}")
cnt_mem = struct.members[-1]
member.cnt = cnt_mem
_ = member.max_cnt # force validation
@@ -417,8 +445,8 @@ re_line_cont = f"\\s+{re_string('specs')}" # could be bitfield/struct/msg
def parse_file(
- filename: str, get_include: typing.Callable[[str], tuple[str, list[Type]]]
-) -> tuple[str, list[Type]]:
+ filename: str, get_include: typing.Callable[[str], tuple[str, list[UserType]]]
+) -> tuple[str, list[UserType]]:
version: str | None = None
env: dict[str, Type] = {
"1": Primitive.u8,
@@ -430,10 +458,10 @@ def parse_file(
def get_type(name: str, tc: type[T]) -> T:
nonlocal env
if name not in env:
- raise NameError(f"Unknown type {repr(name)}")
+ raise NameError(f"Unknown type {name!r}")
ret = env[name]
if (not isinstance(ret, tc)) or (ret.__class__.__name__ != tc.__name__):
- raise NameError(f"Type {repr(ret.typname)} is not a {tc.__name__}")
+ raise NameError(f"Type {ret.typname!r} is not a {tc.__name__}")
return ret
with open(filename, "r", encoding="utf-8") as fh:
@@ -466,6 +494,9 @@ def parse_file(
typ.in_versions.add(version)
case Bitfield():
typ.in_versions.add(version)
+ for bit in typ.bits:
+ if other_version in bit.in_versions:
+ bit.in_versions.add(version)
for val in typ.names.values():
if other_version in val.in_versions:
val.in_versions.add(version)
@@ -481,7 +512,7 @@ def parse_file(
env[typ.typname] = typ
if symname != "*" and not found:
raise ValueError(
- f"import: {m.group('file')}: no symbol {repr(symname)}"
+ f"import: {m.group('file')}: no symbol {symname!r}"
)
elif m := re.fullmatch(re_line_num, line):
num = Number()
@@ -497,15 +528,11 @@ def parse_file(
env[num.typname] = num
prev = num
elif m := re.fullmatch(re_line_bitfield, line):
- bf = Bitfield()
- bf.typname = m.group("name")
- bf.in_versions.add(version)
-
prim = env[m.group("prim")]
assert isinstance(prim, Primitive)
- bf.prim = prim
- bf.bits = (prim.static_size * 8) * [""]
+ bf = Bitfield(m.group("name"), prim)
+ bf.in_versions.add(version)
if bf.typname in env:
raise ValueError(f"duplicate type name {bf.typname!r}")
@@ -577,7 +604,7 @@ def parse_file(
if not version:
raise SyntaxError("must have exactly 1 version line")
- typs: list[Type] = [x for x in env.values() if not isinstance(x, Primitive)]
+ typs: list[UserType] = [x for x in env.values() if not isinstance(x, Primitive)]
for typ in [typ for typ in typs if isinstance(typ, Struct)]:
valid_syms = [
@@ -607,35 +634,35 @@ def parse_file(
class Parser:
- cache: dict[str, tuple[str, list[Type]]] = {}
+ cache: dict[str, tuple[str, list[UserType]]] = {}
- def parse_file(self, filename: str) -> tuple[str, list[Type]]:
+ def parse_file(self, filename: str) -> tuple[str, list[UserType]]:
filename = os.path.normpath(filename)
if filename not in self.cache:
- def get_include(other_filename: str) -> tuple[str, list[Type]]:
+ def get_include(other_filename: str) -> tuple[str, list[UserType]]:
return self.parse_file(os.path.join(filename, "..", other_filename))
self.cache[filename] = parse_file(filename, get_include)
return self.cache[filename]
- def all(self) -> tuple[set[str], list[Type]]:
+ def all(self) -> tuple[set[str], list[UserType]]:
ret_versions: set[str] = set()
- ret_typs: dict[str, Type] = {}
+ ret_typs: dict[str, UserType] = {}
for version, typs in self.cache.values():
if version in ret_versions:
- raise ValueError(f"duplicate protocol version {repr(version)}")
+ raise ValueError(f"duplicate protocol version {version!r}")
ret_versions.add(version)
for typ in typs:
if typ.typname in ret_typs:
if typ != ret_typs[typ.typname]:
- raise ValueError(f"duplicate type name {repr(typ.typname)}")
+ raise ValueError(f"duplicate type name {typ.typname!r}")
else:
ret_typs[typ.typname] = typ
msgids: set[int] = set()
for typ in ret_typs.values():
if isinstance(typ, Message):
if typ.msgid in msgids:
- raise ValueError(f"duplicate msgid {repr(typ.msgid)}")
+ raise ValueError(f"duplicate msgid {typ.msgid!r}")
msgids.add(typ.msgid)
return ret_versions, list(ret_typs.values())
diff --git a/lib9p/include/lib9p/9p.generated.h b/lib9p/include/lib9p/9p.generated.h
index a1c9958..725e781 100644
--- a/lib9p/include/lib9p/9p.generated.h
+++ b/lib9p/include/lib9p/9p.generated.h
@@ -176,62 +176,62 @@ struct lib9p_s {
/* size = 4 ; max_iov = 1 ; max_copy = 4 */
typedef uint32_t lib9p_dm_t;
-#define LIB9P_DM_DIR ((lib9p_dm_t)(1<<31))
-#define LIB9P_DM_APPEND ((lib9p_dm_t)(1<<30))
-#define LIB9P_DM_EXCL ((lib9p_dm_t)(1<<29))
-#define _LIB9P_DM_PLAN9_MOUNT ((lib9p_dm_t)(1<<28))
-#define LIB9P_DM_AUTH ((lib9p_dm_t)(1<<27))
-#define LIB9P_DM_TMP ((lib9p_dm_t)(1<<26))
-/* unused ((lib9p_dm_t)(1<<25)) */
-/* unused ((lib9p_dm_t)(1<<24)) */
+#define LIB9P_DM_DIR ((lib9p_dm_t)(1<<31))
+#define LIB9P_DM_APPEND ((lib9p_dm_t)(1<<30))
+#define LIB9P_DM_EXCL ((lib9p_dm_t)(1<<29))
+#define _LIB9P_DM_RESERVED_PLAN9_MOUNT ((lib9p_dm_t)(1<<28))
+#define LIB9P_DM_AUTH ((lib9p_dm_t)(1<<27))
+#define LIB9P_DM_TMP ((lib9p_dm_t)(1<<26))
+/* unused ((lib9p_dm_t)(1<<25)) */
+/* unused ((lib9p_dm_t)(1<<24)) */
#if CONFIG_9P_ENABLE_9P2000_u
-# define LIB9P_DM_DEVICE ((lib9p_dm_t)(1<<23))
+# define LIB9P_DM_DEVICE ((lib9p_dm_t)(1<<23))
#endif /* CONFIG_9P_ENABLE_9P2000_u */
-/* unused ((lib9p_dm_t)(1<<22)) */
+/* unused ((lib9p_dm_t)(1<<22)) */
#if CONFIG_9P_ENABLE_9P2000_u
-# define LIB9P_DM_NAMEDPIPE ((lib9p_dm_t)(1<<21))
-# define LIB9P_DM_SOCKET ((lib9p_dm_t)(1<<20))
-# define LIB9P_DM_SETUID ((lib9p_dm_t)(1<<19))
-# define LIB9P_DM_SETGID ((lib9p_dm_t)(1<<18))
+# define LIB9P_DM_NAMEDPIPE ((lib9p_dm_t)(1<<21))
+# define LIB9P_DM_SOCKET ((lib9p_dm_t)(1<<20))
+# define LIB9P_DM_SETUID ((lib9p_dm_t)(1<<19))
+# define LIB9P_DM_SETGID ((lib9p_dm_t)(1<<18))
#endif /* CONFIG_9P_ENABLE_9P2000_u */
-/* unused ((lib9p_dm_t)(1<<17)) */
-/* unused ((lib9p_dm_t)(1<<16)) */
-/* unused ((lib9p_dm_t)(1<<15)) */
-/* unused ((lib9p_dm_t)(1<<14)) */
-/* unused ((lib9p_dm_t)(1<<13)) */
-/* unused ((lib9p_dm_t)(1<<12)) */
-/* unused ((lib9p_dm_t)(1<<11)) */
-/* unused ((lib9p_dm_t)(1<<10)) */
-/* unused ((lib9p_dm_t)(1<<9)) */
-#define LIB9P_DM_OWNER_R ((lib9p_dm_t)(1<<8))
-#define LIB9P_DM_OWNER_W ((lib9p_dm_t)(1<<7))
-#define LIB9P_DM_OWNER_X ((lib9p_dm_t)(1<<6))
-#define LIB9P_DM_GROUP_R ((lib9p_dm_t)(1<<5))
-#define LIB9P_DM_GROUP_W ((lib9p_dm_t)(1<<4))
-#define LIB9P_DM_GROUP_X ((lib9p_dm_t)(1<<3))
-#define LIB9P_DM_OTHER_R ((lib9p_dm_t)(1<<2))
-#define LIB9P_DM_OTHER_W ((lib9p_dm_t)(1<<1))
-#define LIB9P_DM_OTHER_X ((lib9p_dm_t)(1<<0))
-
-#define LIB9P_DM_PERM_MASK ((lib9p_dm_t)(0777))
+/* unused ((lib9p_dm_t)(1<<17)) */
+/* unused ((lib9p_dm_t)(1<<16)) */
+/* unused ((lib9p_dm_t)(1<<15)) */
+/* unused ((lib9p_dm_t)(1<<14)) */
+/* unused ((lib9p_dm_t)(1<<13)) */
+/* unused ((lib9p_dm_t)(1<<12)) */
+/* unused ((lib9p_dm_t)(1<<11)) */
+/* unused ((lib9p_dm_t)(1<<10)) */
+/* unused ((lib9p_dm_t)(1<<9)) */
+#define LIB9P_DM_OWNER_R ((lib9p_dm_t)(1<<8))
+#define LIB9P_DM_OWNER_W ((lib9p_dm_t)(1<<7))
+#define LIB9P_DM_OWNER_X ((lib9p_dm_t)(1<<6))
+#define LIB9P_DM_GROUP_R ((lib9p_dm_t)(1<<5))
+#define LIB9P_DM_GROUP_W ((lib9p_dm_t)(1<<4))
+#define LIB9P_DM_GROUP_X ((lib9p_dm_t)(1<<3))
+#define LIB9P_DM_OTHER_R ((lib9p_dm_t)(1<<2))
+#define LIB9P_DM_OTHER_W ((lib9p_dm_t)(1<<1))
+#define LIB9P_DM_OTHER_X ((lib9p_dm_t)(1<<0))
+
+#define LIB9P_DM_PERM_MASK ((lib9p_dm_t)(0777))
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
/* size = 1 ; max_iov = 1 ; max_copy = 1 */
typedef uint8_t lib9p_qt_t;
-#define LIB9P_QT_DIR ((lib9p_qt_t)(1<<7))
-#define LIB9P_QT_APPEND ((lib9p_qt_t)(1<<6))
-#define LIB9P_QT_EXCL ((lib9p_qt_t)(1<<5))
-#define _LIB9P_QT_PLAN9_MOUNT ((lib9p_qt_t)(1<<4))
-#define LIB9P_QT_AUTH ((lib9p_qt_t)(1<<3))
-#define LIB9P_QT_TMP ((lib9p_qt_t)(1<<2))
+#define LIB9P_QT_DIR ((lib9p_qt_t)(1<<7))
+#define LIB9P_QT_APPEND ((lib9p_qt_t)(1<<6))
+#define LIB9P_QT_EXCL ((lib9p_qt_t)(1<<5))
+#define _LIB9P_QT_RESERVED_PLAN9_MOUNT ((lib9p_qt_t)(1<<4))
+#define LIB9P_QT_AUTH ((lib9p_qt_t)(1<<3))
+#define LIB9P_QT_TMP ((lib9p_qt_t)(1<<2))
#if CONFIG_9P_ENABLE_9P2000_u
-# define LIB9P_QT_SYMLINK ((lib9p_qt_t)(1<<1))
+# define LIB9P_QT_SYMLINK ((lib9p_qt_t)(1<<1))
#endif /* CONFIG_9P_ENABLE_9P2000_u */
-/* unused ((lib9p_qt_t)(1<<0)) */
+/* unused ((lib9p_qt_t)(1<<0)) */
-#define LIB9P_QT_FILE ((lib9p_qt_t)(0))
+#define LIB9P_QT_FILE ((lib9p_qt_t)(0))
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u
@@ -244,24 +244,140 @@ typedef uint32_t lib9p_nuid_t;
/* size = 1 ; max_iov = 1 ; max_copy = 1 */
typedef uint8_t lib9p_o_t;
-/* unused ((lib9p_o_t)(1<<7)) */
-#define LIB9P_O_RCLOSE ((lib9p_o_t)(1<<6))
-/* unused ((lib9p_o_t)(1<<5)) */
-#define LIB9P_O_TRUNC ((lib9p_o_t)(1<<4))
-/* unused ((lib9p_o_t)(1<<3)) */
-/* unused ((lib9p_o_t)(1<<2)) */
-#define LIB9P_O_mode_1 ((lib9p_o_t)(1<<1))
-#define LIB9P_O_mode_0 ((lib9p_o_t)(1<<0))
-
-#define LIB9P_O_READ ((lib9p_o_t)(0))
-#define LIB9P_O_WRITE ((lib9p_o_t)(1))
-#define LIB9P_O_RDWR ((lib9p_o_t)(2))
-#define LIB9P_O_EXEC ((lib9p_o_t)(3))
-#define LIB9P_O_MODE_MASK ((lib9p_o_t)(0b00000011))
-#define LIB9P_O_FLAG_MASK ((lib9p_o_t)(0b11111100))
+/* unused ((lib9p_o_t)(1<<7)) */
+#define LIB9P_O_RCLOSE ((lib9p_o_t)(1<<6))
+#define _LIB9P_O_RESERVED_CEXEC ((lib9p_o_t)(1<<5))
+#define LIB9P_O_TRUNC ((lib9p_o_t)(1<<4))
+/* unused ((lib9p_o_t)(1<<3)) */
+/* unused ((lib9p_o_t)(1<<2)) */
+#define _LIB9P_O_mode_1 ((lib9p_o_t)(1<<1))
+#define _LIB9P_O_mode_0 ((lib9p_o_t)(1<<0))
+
+#define LIB9P_O_READ ((lib9p_o_t)(0))
+#define LIB9P_O_WRITE ((lib9p_o_t)(1))
+#define LIB9P_O_RDWR ((lib9p_o_t)(2))
+#define LIB9P_O_EXEC ((lib9p_o_t)(3))
+#define LIB9P_O_MODE_MASK ((lib9p_o_t)(0b00000011))
+#define LIB9P_O_FLAG_MASK ((lib9p_o_t)(0b11111100))
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
+#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u
+/* size = 4 ; max_iov = 1 ; max_copy = 4 */
+typedef uint32_t lib9p_errno_t;
+#define LIB9P_ERRNO_NOERROR ((lib9p_errno_t)UINT32_C(0))
+
+#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000_L
+/* size = 4 ; max_iov = 1 ; max_copy = 4 */
+typedef uint32_t lib9p_super_magic_t;
+#define LIB9P_SUPER_MAGIC_V9FS_MAGIC ((lib9p_super_magic_t)UINT32_C(0x01021997))
+
+/* size = 4 ; max_iov = 1 ; max_copy = 4 */
+typedef uint32_t lib9p_lo_t;
+
+/* unused ((lib9p_lo_t)(1<<31)) */
+/* unused ((lib9p_lo_t)(1<<30)) */
+/* unused ((lib9p_lo_t)(1<<29)) */
+/* unused ((lib9p_lo_t)(1<<28)) */
+/* unused ((lib9p_lo_t)(1<<27)) */
+/* unused ((lib9p_lo_t)(1<<26)) */
+/* unused ((lib9p_lo_t)(1<<25)) */
+/* unused ((lib9p_lo_t)(1<<24)) */
+/* unused ((lib9p_lo_t)(1<<23)) */
+/* unused ((lib9p_lo_t)(1<<22)) */
+/* unused ((lib9p_lo_t)(1<<21)) */
+#define LIB9P_LO_SYNC ((lib9p_lo_t)(1<<20))
+#define LIB9P_LO_CLOEXEC ((lib9p_lo_t)(1<<19))
+#define LIB9P_LO_NOATIME ((lib9p_lo_t)(1<<18))
+#define LIB9P_LO_NOFOLLOW ((lib9p_lo_t)(1<<17))
+#define LIB9P_LO_DIRECTORY ((lib9p_lo_t)(1<<16))
+#define LIB9P_LO_LARGEFILE ((lib9p_lo_t)(1<<15))
+#define LIB9P_LO_DIRECT ((lib9p_lo_t)(1<<14))
+#define LIB9P_LO_BSD_FASYNC ((lib9p_lo_t)(1<<13))
+#define LIB9P_LO_DSYNC ((lib9p_lo_t)(1<<12))
+#define LIB9P_LO_NONBLOCK ((lib9p_lo_t)(1<<11))
+#define LIB9P_LO_APPEND ((lib9p_lo_t)(1<<10))
+#define LIB9P_LO_TRUNC ((lib9p_lo_t)(1<<9))
+#define LIB9P_LO_NOCTTY ((lib9p_lo_t)(1<<8))
+#define LIB9P_LO_EXCL ((lib9p_lo_t)(1<<7))
+#define LIB9P_LO_CREATE ((lib9p_lo_t)(1<<6))
+/* unused ((lib9p_lo_t)(1<<5)) */
+/* unused ((lib9p_lo_t)(1<<4)) */
+/* unused ((lib9p_lo_t)(1<<3)) */
+/* unused ((lib9p_lo_t)(1<<2)) */
+#define _LIB9P_LO_mode_1 ((lib9p_lo_t)(1<<1))
+#define _LIB9P_LO_mode_0 ((lib9p_lo_t)(1<<0))
+
+#define LIB9P_LO_RDONLY ((lib9p_lo_t)(0))
+#define LIB9P_LO_WRONLY ((lib9p_lo_t)(1))
+#define LIB9P_LO_RDWR ((lib9p_lo_t)(2))
+#define LIB9P_LO_NOACCESS ((lib9p_lo_t)(3))
+#define LIB9P_LO_MODE_MASK ((lib9p_lo_t)(0b000000000000000000011))
+#define LIB9P_LO_FLAG_MASK ((lib9p_lo_t)(0b111111111111111000000))
+
+/* size = 1 ; max_iov = 1 ; max_copy = 1 */
+typedef uint8_t lib9p_dt_t;
+#define LIB9P_DT_UNKNOWN ((lib9p_dt_t)UINT8_C(0))
+#define LIB9P_DT_NAMED_PIPE ((lib9p_dt_t)UINT8_C(1))
+#define LIB9P_DT_CHAR_DEV ((lib9p_dt_t)UINT8_C(2))
+#define LIB9P_DT_DIRECTORY ((lib9p_dt_t)UINT8_C(4))
+#define LIB9P_DT_BLOCK_DEV ((lib9p_dt_t)UINT8_C(6))
+#define LIB9P_DT_REGULAR ((lib9p_dt_t)UINT8_C(8))
+#define LIB9P_DT_SYMLINK ((lib9p_dt_t)UINT8_C(10))
+#define LIB9P_DT_SOCKET ((lib9p_dt_t)UINT8_C(12))
+#define LIB9P_DT_WHITEOUT ((lib9p_dt_t)UINT8_C(14))
+
+/* size = 4 ; max_iov = 1 ; max_copy = 4 */
+typedef uint32_t lib9p_mode_t;
+
+/* unused ((lib9p_mode_t)(1<<31)) */
+/* unused ((lib9p_mode_t)(1<<30)) */
+/* unused ((lib9p_mode_t)(1<<29)) */
+/* unused ((lib9p_mode_t)(1<<28)) */
+/* unused ((lib9p_mode_t)(1<<27)) */
+/* unused ((lib9p_mode_t)(1<<26)) */
+/* unused ((lib9p_mode_t)(1<<25)) */
+/* unused ((lib9p_mode_t)(1<<24)) */
+/* unused ((lib9p_mode_t)(1<<23)) */
+/* unused ((lib9p_mode_t)(1<<22)) */
+/* unused ((lib9p_mode_t)(1<<21)) */
+/* unused ((lib9p_mode_t)(1<<20)) */
+/* unused ((lib9p_mode_t)(1<<19)) */
+/* unused ((lib9p_mode_t)(1<<18)) */
+/* unused ((lib9p_mode_t)(1<<17)) */
+/* unused ((lib9p_mode_t)(1<<16)) */
+#define _LIB9P_MODE_fmt_3 ((lib9p_mode_t)(1<<15))
+#define _LIB9P_MODE_fmt_2 ((lib9p_mode_t)(1<<14))
+#define _LIB9P_MODE_fmt_1 ((lib9p_mode_t)(1<<13))
+#define _LIB9P_MODE_fmt_0 ((lib9p_mode_t)(1<<12))
+#define LIB9P_MODE_PERM_SETGROUP ((lib9p_mode_t)(1<<11))
+#define LIB9P_MODE_PERM_SETUSER ((lib9p_mode_t)(1<<10))
+#define LIB9P_MODE_PERM_STICKY ((lib9p_mode_t)(1<<9))
+#define LIB9P_MODE_PERM_OWNER_R ((lib9p_mode_t)(1<<8))
+#define LIB9P_MODE_PERM_OWNER_W ((lib9p_mode_t)(1<<7))
+#define LIB9P_MODE_PERM_OWNER_X ((lib9p_mode_t)(1<<6))
+#define LIB9P_MODE_PERM_GROUP_R ((lib9p_mode_t)(1<<5))
+#define LIB9P_MODE_PERM_GROUP_W ((lib9p_mode_t)(1<<4))
+#define LIB9P_MODE_PERM_GROUP_X ((lib9p_mode_t)(1<<3))
+#define LIB9P_MODE_PERM_OTHER_R ((lib9p_mode_t)(1<<2))
+#define LIB9P_MODE_PERM_OTHER_W ((lib9p_mode_t)(1<<1))
+#define LIB9P_MODE_PERM_OTHER_X ((lib9p_mode_t)(1<<0))
+
+#define LIB9P_MODE_FMT_NAMED_PIPE ((lib9p_mode_t)(LIB9P_DT_NAMED_PIPE<<12))
+#define LIB9P_MODE_FMT_CHAR_DEV ((lib9p_mode_t)(LIB9P_DT_CHAR_DEV<<12))
+#define LIB9P_MODE_FMT_DIRECTORY ((lib9p_mode_t)(LIB9P_DT_DIRECTORY<<12))
+#define LIB9P_MODE_FMT_BLOCK_DEV ((lib9p_mode_t)(LIB9P_DT_BLOCK_DEV<<12))
+#define LIB9P_MODE_FMT_REGULAR ((lib9p_mode_t)(LIB9P_DT_REGULAR<<12))
+#define LIB9P_MODE_FMT_SYMLINK ((lib9p_mode_t)(LIB9P_DT_SYMLINK<<12))
+#define LIB9P_MODE_FMT_SOCKET ((lib9p_mode_t)(LIB9P_DT_SOCKET<<12))
+#define LIB9P_MODE_PERM_MASK ((lib9p_mode_t)(0000777))
+#define LIB9P_MODE_FMT_MASK ((lib9p_mode_t)(0170000))
+
+/* size = 4 ; max_iov = 1 ; max_copy = 4 */
+typedef uint32_t lib9p_b4_t;
+#define LIB9P_B4_FALSE ((lib9p_b4_t)UINT32_C(0))
+#define LIB9P_B4_TRUE ((lib9p_b4_t)UINT32_C(1))
+
/* size = 8 ; max_iov = 1 ; max_copy = 8 */
typedef uint64_t lib9p_getattr_t;
@@ -463,26 +579,6 @@ struct lib9p_msg_Rwstat {
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000_L
-/* size = 11 ; max_iov = 1 ; max_copy = 11 */
-struct lib9p_msg_Rlerror {
- lib9p_tag_t tag;
- uint32_t ecode;
-};
-
-/* size = 67 ; max_iov = 1 ; max_copy = 67 */
-struct lib9p_msg_Rstatfs {
- lib9p_tag_t tag;
- uint32_t type;
- uint32_t bsize;
- uint64_t blocks;
- uint64_t bfree;
- uint64_t bavail;
- uint64_t files;
- uint64_t ffree;
- uint64_t fsid;
- uint32_t namelen;
-};
-
/* size = 7 ; max_iov = 1 ; max_copy = 7 */
struct lib9p_msg_Rrename {
lib9p_tag_t tag;
@@ -604,13 +700,6 @@ struct lib9p_msg_Tstatfs {
lib9p_fid_t fid;
};
-/* size = 15 ; max_iov = 1 ; max_copy = 15 */
-struct lib9p_msg_Tlopen {
- lib9p_tag_t tag;
- lib9p_fid_t fid;
- uint32_t flags;
-};
-
/* size = 11 ; max_iov = 1 ; max_copy = 11 */
struct lib9p_msg_Treadlink {
lib9p_tag_t tag;
@@ -625,13 +714,6 @@ struct lib9p_msg_Treaddir {
uint32_t count;
};
-/* size = 15 ; max_iov = 1 ; max_copy = 15 */
-struct lib9p_msg_Tfsync {
- lib9p_tag_t tag;
- lib9p_fid_t fid;
- uint32_t datasync;
-};
-
#endif /* CONFIG_9P_ENABLE_9P2000_L */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
/* min_size = 13 ; exp_size = 40 ; max_size = 65,548 ; max_iov = 2 ; max_copy = 13 */
@@ -648,19 +730,6 @@ struct lib9p_msg_Rversion {
struct lib9p_s version;
};
-/* LIB9P_VER_9P2000 : min_size = 9 ; exp_size = 36 ; max_size = 65,544 ; max_iov = 2 ; max_copy = 9 */
-/* LIB9P_VER_9P2000_L : 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 */
-struct lib9p_msg_Rerror {
- lib9p_tag_t tag;
- struct lib9p_s ename;
-#if CONFIG_9P_ENABLE_9P2000_u
- uint32_t errno;
-#endif /* CONFIG_9P_ENABLE_9P2000_u */
-};
-
/* min_size = 17 ; exp_size = 481 ; max_size = 1,048,609 ; max_iov = 32 ; max_copy = 49 */
struct lib9p_msg_Twalk {
lib9p_tag_t tag;
@@ -703,27 +772,6 @@ struct lib9p_msg_Txattrcreate {
uint32_t flags;
};
-/* min_size = 34 ; exp_size = 61 ; max_size = 65,569 ; max_iov = 2 ; max_copy = 34 */
-struct lib9p_msg_Tgetlock {
- lib9p_tag_t tag;
- lib9p_fid_t fid;
- uint8_t type;
- uint64_t start;
- uint64_t length;
- uint32_t proc_id;
- struct lib9p_s client_id;
-};
-
-/* min_size = 30 ; exp_size = 57 ; max_size = 65,565 ; max_iov = 2 ; max_copy = 30 */
-struct lib9p_msg_Rgetlock {
- lib9p_tag_t tag;
- uint8_t type;
- uint64_t start;
- uint64_t length;
- uint32_t proc_id;
- struct lib9p_s client_id;
-};
-
/* min_size = 17 ; exp_size = 44 ; max_size = 65,552 ; max_iov = 2 ; max_copy = 17 */
struct lib9p_msg_Tlink {
lib9p_tag_t tag;
@@ -811,16 +859,6 @@ struct lib9p_msg_Tattach {
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000_L
-/* min_size = 25 ; exp_size = 52 ; max_size = 65,560 ; max_iov = 3 ; max_copy = 25 */
-struct lib9p_msg_Tlcreate {
- lib9p_tag_t tag;
- lib9p_fid_t fid;
- struct lib9p_s name;
- uint32_t flags;
- uint32_t mode;
- lib9p_nuid_t gid;
-};
-
/* min_size = 19 ; exp_size = 73 ; max_size = 131,089 ; max_iov = 5 ; max_copy = 19 */
struct lib9p_msg_Tsymlink {
lib9p_tag_t tag;
@@ -830,26 +868,6 @@ struct lib9p_msg_Tsymlink {
lib9p_nuid_t gid;
};
-/* min_size = 29 ; exp_size = 56 ; max_size = 65,564 ; max_iov = 3 ; max_copy = 29 */
-struct lib9p_msg_Tmknod {
- lib9p_tag_t tag;
- lib9p_fid_t dfid;
- struct lib9p_s name;
- uint32_t mode;
- uint32_t major;
- uint32_t minor;
- lib9p_nuid_t gid;
-};
-
-/* min_size = 21 ; exp_size = 48 ; max_size = 65,556 ; max_iov = 3 ; max_copy = 21 */
-struct lib9p_msg_Tmkdir {
- lib9p_tag_t tag;
- lib9p_fid_t dfid;
- struct lib9p_s name;
- uint32_t mode;
- lib9p_nuid_t gid;
-};
-
#endif /* CONFIG_9P_ENABLE_9P2000_L */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
/* size = 12 ; max_iov = 1 ; max_copy = 12 */
@@ -878,7 +896,86 @@ struct lib9p_msg_Topenfd {
};
#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
+/* LIB9P_VER_9P2000 : min_size = 9 ; exp_size = 36 ; max_size = 65,544 ; max_iov = 2 ; max_copy = 9 */
+/* LIB9P_VER_9P2000_L : 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 */
+struct lib9p_msg_Rerror {
+ lib9p_tag_t tag;
+ struct lib9p_s ename;
+#if CONFIG_9P_ENABLE_9P2000_u
+ lib9p_errno_t errno;
+#endif /* CONFIG_9P_ENABLE_9P2000_u */
+};
+
+#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000_L
+/* size = 11 ; max_iov = 1 ; max_copy = 11 */
+struct lib9p_msg_Rlerror {
+ lib9p_tag_t tag;
+ lib9p_errno_t ecode;
+};
+
+/* size = 67 ; max_iov = 1 ; max_copy = 67 */
+struct lib9p_msg_Rstatfs {
+ lib9p_tag_t tag;
+ lib9p_super_magic_t type;
+ uint32_t bsize;
+ uint64_t blocks;
+ uint64_t bfree;
+ uint64_t bavail;
+ uint64_t files;
+ uint64_t ffree;
+ uint64_t fsid;
+ uint32_t namelen;
+};
+
+/* size = 15 ; max_iov = 1 ; max_copy = 15 */
+struct lib9p_msg_Tlopen {
+ lib9p_tag_t tag;
+ lib9p_fid_t fid;
+ lib9p_lo_t flags;
+};
+
+/* min_size = 25 ; exp_size = 52 ; max_size = 65,560 ; max_iov = 3 ; max_copy = 25 */
+struct lib9p_msg_Tlcreate {
+ lib9p_tag_t tag;
+ lib9p_fid_t fid;
+ struct lib9p_s name;
+ lib9p_lo_t flags;
+ lib9p_mode_t mode;
+ lib9p_nuid_t gid;
+};
+
+/* min_size = 29 ; exp_size = 56 ; max_size = 65,564 ; max_iov = 3 ; max_copy = 29 */
+struct lib9p_msg_Tmknod {
+ lib9p_tag_t tag;
+ lib9p_fid_t dfid;
+ struct lib9p_s name;
+ lib9p_mode_t mode;
+ uint32_t major;
+ uint32_t minor;
+ lib9p_nuid_t gid;
+};
+
+/* min_size = 21 ; exp_size = 48 ; max_size = 65,556 ; max_iov = 3 ; max_copy = 21 */
+struct lib9p_msg_Tmkdir {
+ lib9p_tag_t tag;
+ lib9p_fid_t dfid;
+ struct lib9p_s name;
+ lib9p_mode_t mode;
+ lib9p_nuid_t gid;
+};
+
+/* size = 15 ; max_iov = 1 ; max_copy = 15 */
+struct lib9p_msg_Tfsync {
+ lib9p_tag_t tag;
+ lib9p_fid_t fid;
+ lib9p_b4_t datasync;
+};
+
/* size = 19 ; max_iov = 1 ; max_copy = 19 */
struct lib9p_msg_Tgetattr {
lib9p_tag_t tag;
@@ -891,7 +988,7 @@ struct lib9p_msg_Tsetattr {
lib9p_tag_t tag;
lib9p_fid_t fid;
lib9p_setattr_t valid;
- uint32_t mode;
+ lib9p_mode_t mode;
lib9p_nuid_t uid;
lib9p_nuid_t gid;
uint64_t filesize;
@@ -901,6 +998,27 @@ struct lib9p_msg_Tsetattr {
uint64_t mtime_nsec;
};
+/* min_size = 34 ; exp_size = 61 ; max_size = 65,569 ; max_iov = 2 ; max_copy = 34 */
+struct lib9p_msg_Tgetlock {
+ lib9p_tag_t tag;
+ lib9p_fid_t fid;
+ lib9p_lock_type_t type;
+ uint64_t start;
+ uint64_t length;
+ uint32_t proc_id;
+ struct lib9p_s client_id;
+};
+
+/* min_size = 30 ; exp_size = 57 ; max_size = 65,565 ; max_iov = 2 ; max_copy = 30 */
+struct lib9p_msg_Rgetlock {
+ lib9p_tag_t tag;
+ lib9p_lock_type_t type;
+ uint64_t start;
+ uint64_t length;
+ uint32_t proc_id;
+ struct lib9p_s client_id;
+};
+
/* min_size = 38 ; exp_size = 65 ; max_size = 65,573 ; max_iov = 2 ; max_copy = 38 */
struct lib9p_msg_Tlock {
lib9p_tag_t tag;
@@ -1023,9 +1141,9 @@ struct lib9p_msg_Rmknod {
/* size = 160 ; max_iov = 1 ; max_copy = 160 */
struct lib9p_msg_Rgetattr {
lib9p_tag_t tag;
- uint64_t valid;
+ lib9p_getattr_t valid;
struct lib9p_qid qid;
- uint32_t mode;
+ lib9p_mode_t mode;
lib9p_nuid_t uid;
lib9p_nuid_t gid;
uint64_t nlink;
diff --git a/lib9p/include/lib9p/9p.h b/lib9p/include/lib9p/9p.h
index 44b5410..35b7ef2 100644
--- a/lib9p/include/lib9p/9p.h
+++ b/lib9p/include/lib9p/9p.h
@@ -46,7 +46,7 @@ struct lib9p_ctx {
/* state */
#ifdef CONFIG_9P_ENABLE_9P2000_u
- uint32_t err_num;
+ lib9p_errno_t err_num;
#endif
[[gnu::nonstring]] char err_msg[CONFIG_9P_MAX_ERR_SIZE];
};
@@ -56,9 +56,9 @@ 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, uint32_t linux_errno, char const *msg);
+int lib9p_error(struct lib9p_ctx *ctx, lib9p_errno_t linux_errno, char const *msg);
/** Write a printf-style error into ctx, return -1. */
-int lib9p_errorf(struct lib9p_ctx *ctx, uint32_t linux_errno, char const *fmt, ...) [[gnu::format(printf, 3, 4)]];
+int lib9p_errorf(struct lib9p_ctx *ctx, lib9p_errno_t linux_errno, char const *fmt, ...) [[gnu::format(printf, 3, 4)]];
/* main T-message functions ***************************************************/
@@ -139,12 +139,11 @@ bool lib9p_Rmsg_marshal(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *bo
/** 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_PLAN9_MOUNT)) == ((bool)(stat.file_qid.type & _LIB9P_QT_PLAN9_MOUNT)) );
- 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( ((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) );
}
diff --git a/lib9p/tests/test_compile.c b/lib9p/tests/test_compile.c
index 989bf20..6abee05 100644
--- a/lib9p/tests/test_compile.c
+++ b/lib9p/tests/test_compile.c
@@ -8,7 +8,7 @@ int main(void) {
x = LIB9P_DM_DIR;
x = LIB9P_DM_APPEND;
x = LIB9P_DM_EXCL;
- x = _LIB9P_DM_PLAN9_MOUNT;
+ x = _LIB9P_DM_RESERVED_PLAN9_MOUNT;
x = LIB9P_DM_AUTH;
x = LIB9P_DM_TMP;
x = LIB9P_DM_DEVICE;
@@ -29,22 +29,84 @@ int main(void) {
x = LIB9P_QT_DIR;
x = LIB9P_QT_APPEND;
x = LIB9P_QT_EXCL;
- x = _LIB9P_QT_PLAN9_MOUNT;
+ x = _LIB9P_QT_RESERVED_PLAN9_MOUNT;
x = LIB9P_QT_AUTH;
x = LIB9P_QT_TMP;
x = LIB9P_QT_SYMLINK;
x = LIB9P_QT_FILE;
x = LIB9P_NUID_NONUID;
x = LIB9P_O_RCLOSE;
+ x = _LIB9P_O_RESERVED_CEXEC;
x = LIB9P_O_TRUNC;
- x = LIB9P_O_mode_1;
- x = LIB9P_O_mode_0;
+ x = _LIB9P_O_mode_1;
+ x = _LIB9P_O_mode_0;
x = LIB9P_O_READ;
x = LIB9P_O_WRITE;
x = LIB9P_O_RDWR;
x = LIB9P_O_EXEC;
x = LIB9P_O_MODE_MASK;
x = LIB9P_O_FLAG_MASK;
+ x = LIB9P_ERRNO_NOERROR;
+ x = LIB9P_SUPER_MAGIC_V9FS_MAGIC;
+ x = LIB9P_LO_SYNC;
+ x = LIB9P_LO_CLOEXEC;
+ x = LIB9P_LO_NOATIME;
+ x = LIB9P_LO_NOFOLLOW;
+ x = LIB9P_LO_DIRECTORY;
+ x = LIB9P_LO_LARGEFILE;
+ x = LIB9P_LO_DIRECT;
+ x = LIB9P_LO_BSD_FASYNC;
+ x = LIB9P_LO_DSYNC;
+ x = LIB9P_LO_NONBLOCK;
+ x = LIB9P_LO_APPEND;
+ x = LIB9P_LO_TRUNC;
+ x = LIB9P_LO_NOCTTY;
+ x = LIB9P_LO_EXCL;
+ x = LIB9P_LO_CREATE;
+ x = _LIB9P_LO_mode_1;
+ x = _LIB9P_LO_mode_0;
+ x = LIB9P_LO_RDONLY;
+ x = LIB9P_LO_WRONLY;
+ x = LIB9P_LO_RDWR;
+ x = LIB9P_LO_NOACCESS;
+ x = LIB9P_LO_MODE_MASK;
+ x = LIB9P_LO_FLAG_MASK;
+ x = LIB9P_DT_UNKNOWN;
+ x = LIB9P_DT_NAMED_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_fmt_3;
+ x = _LIB9P_MODE_fmt_2;
+ x = _LIB9P_MODE_fmt_1;
+ x = _LIB9P_MODE_fmt_0;
+ 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;
+ x = LIB9P_MODE_PERM_GROUP_R;
+ x = LIB9P_MODE_PERM_GROUP_W;
+ x = LIB9P_MODE_PERM_GROUP_X;
+ x = LIB9P_MODE_PERM_OTHER_R;
+ x = LIB9P_MODE_PERM_OTHER_W;
+ x = LIB9P_MODE_PERM_OTHER_X;
+ x = LIB9P_MODE_FMT_NAMED_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_PERM_MASK;
+ x = LIB9P_MODE_FMT_MASK;
+ x = LIB9P_B4_FALSE;
+ x = LIB9P_B4_TRUE;
x = LIB9P_GETATTR_DATA_VERSION;
x = LIB9P_GETATTR_GEN;
x = LIB9P_GETATTR_BTIME;