summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-01-27 21:38:15 -0700
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-01-27 21:38:15 -0700
commitf7b7c04e2ebb24ccae89b77ce76f0b405eb213d1 (patch)
tree87f743d15943f47bb55f0a675877b9f7f42e4597
parentfbc408b36495a60aaf87f5e368a11f57f246d023 (diff)
parent508730301701ece981149f18bc515797cf2b9990 (diff)
Merge branch 'lukeshu/misc'
-rwxr-xr-xbuild-aux/stack.c.gen35
-rw-r--r--lib9p/9p.generated.c359
-rwxr-xr-xlib9p/idl.gen43
-rw-r--r--lib9p/idl/2002-9P2000.9p9
-rw-r--r--lib9p/idl/2010-9P2000.L.9p6
-rw-r--r--lib9p/idl/2012-9P2000.e.9p7
-rw-r--r--lib9p/idl/__init__.py6
-rw-r--r--lib9p/include/lib9p/9p.generated.h85
8 files changed, 265 insertions, 285 deletions
diff --git a/build-aux/stack.c.gen b/build-aux/stack.c.gen
index 0568af0..9f2d60f 100755
--- a/build-aux/stack.c.gen
+++ b/build-aux/stack.c.gen
@@ -109,11 +109,14 @@ class Node:
nstatic: int
ndynamic: int
- # edges with .sourcename set to this node
- calls: set[str]
+ # edges with .sourcename set to this node, val is if it's
+ # OK/expected that the function be missing.
+ calls: dict[str, bool]
-def synthetic_node(name: str, nstatic: int, calls: set[str] = set()) -> Node:
+def synthetic_node(
+ name: str, nstatic: int, calls: typing.Collection[str] = set()
+) -> Node:
n = Node()
n.funcname = name
@@ -123,7 +126,7 @@ def synthetic_node(name: str, nstatic: int, calls: set[str] = set()) -> Node:
n.nstatic = nstatic
n.ndynamic = 0
- n.calls = calls
+ n.calls = dict((c, False) for c in calls)
return n
@@ -154,7 +157,7 @@ def analyze(
match elem.typ:
case "node":
node = Node()
- node.calls = set()
+ node.calls = {}
skip = False
for k, v in elem.attrs.items():
match k:
@@ -207,9 +210,10 @@ def analyze(
raise ValueError(f"unknown caller: {caller}")
if callee == "__indirect_call":
for callee in app_indirect_callees(elem):
- graph[caller].calls.add(callee)
+ if callee not in graph[caller].calls:
+ graph[caller].calls[callee] = True
else:
- graph[caller].calls.add(callee)
+ graph[caller].calls[callee] = False
case _:
raise ValueError(f"unknown elem type {repr(elem.typ)}")
@@ -245,13 +249,16 @@ def analyze(
return None
- def nstatic(orig_funcname: str, chain: list[str] = []) -> int:
+ def nstatic(
+ orig_funcname: str, chain: list[str] = [], missing_ok: bool = False
+ ) -> int:
nonlocal dbg
funcname = resolve_funcname(orig_funcname)
if not funcname:
if app_skip_call(chain, orig_funcname):
return 0
- missing.add(orig_funcname)
+ if not missing_ok:
+ missing.add(orig_funcname)
return 0
if app_skip_call(chain, funcname):
return 0
@@ -265,7 +272,13 @@ def analyze(
if node.usage_kind == "dynamic" or node.ndynamic > 0:
dynamic.add(app_location_xform(funcname))
return node.nstatic + max(
- [0, *[nstatic(call, chain + [funcname]) for call in node.calls]]
+ [
+ 0,
+ *[
+ nstatic(call, chain + [funcname], missing_ok)
+ for call, missing_ok in node.calls.items()
+ ],
+ ]
)
print("/*")
@@ -291,7 +304,7 @@ def analyze(
# Print.
print("= " + grp_name + " " + sep1[len(grp_name) + 3 :])
- for name, num in rows.items():
+ for name, num in sorted(rows.items()):
print(f"{name.ljust(namelen)} {str(num).rjust(numlen)}")
print(sep2)
print(f"{'Total'.ljust(namelen)} {str(nsum).rjust(numlen)}")
diff --git a/lib9p/9p.generated.c b/lib9p/9p.generated.c
index 353654c..ab39102 100644
--- a/lib9p/9p.generated.c
+++ b/lib9p/9p.generated.c
@@ -153,6 +153,7 @@ const char * _lib9p_table_msg_name[LIB9P_VER_NUM][0x100] = {
_MSG_NAME(Twrite),
_MSG_NAME(Rwrite),
_MSG_NAME(Tclunk),
+ _MSG_NAME(Rclunk),
_MSG_NAME(Tremove),
_MSG_NAME(Rremove),
},
@@ -374,6 +375,14 @@ LM_ALWAYS_INLINE static bool validate_d(struct _validate_ctx *ctx) {
return _validate_size_net(ctx, len) || _validate_size_host(ctx, len);
}
+LM_ALWAYS_INLINE static bool validate_d_signed(struct _validate_ctx *ctx) {
+ uint32_t base_offset = ctx->net_offset;
+ if (validate_4(ctx))
+ return true;
+ uint32_t len = uint32le_decode(&ctx->net_bytes[base_offset]);
+ return _validate_size_net(ctx, len) || _validate_size_host(ctx, len);
+}
+
LM_ALWAYS_INLINE static bool validate_s(struct _validate_ctx *ctx) {
uint32_t base_offset = ctx->net_offset;
if (validate_2(ctx))
@@ -469,15 +478,6 @@ LM_ALWAYS_INLINE static bool validate_lock_status(struct _validate_ctx *ctx) {
}
#endif /* CONFIG_9P_ENABLE_9P2000_L */
-#if CONFIG_9P_ENABLE_9P2000_e
-LM_ALWAYS_INLINE static bool validate_d_e(struct _validate_ctx *ctx) {
- return false
- || validate_4(ctx)
- || _validate_list(ctx, uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]), validate_1, sizeof(uint8_t))
- ;
-}
-
-#endif /* CONFIG_9P_ENABLE_9P2000_e */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_FLATTEN static bool validate_Tflush(struct _validate_ctx *ctx) {
uint32_t size;
@@ -526,8 +526,6 @@ LM_FLATTEN static bool validate_Rwrite(struct _validate_ctx *ctx) {
;
}
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_FLATTEN static bool validate_Rclunk(struct _validate_ctx *ctx) {
uint32_t size;
uint8_t typ;
@@ -543,8 +541,6 @@ LM_FLATTEN static bool validate_Rclunk(struct _validate_ctx *ctx) {
;
}
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_FLATTEN static bool validate_Rremove(struct _validate_ctx *ctx) {
uint32_t size;
uint8_t typ;
@@ -680,23 +676,6 @@ LM_FLATTEN static bool validate_Rxattrcreate(struct _validate_ctx *ctx) {
;
}
-LM_FLATTEN static bool validate_Rreaddir(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_list(ctx, uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]), validate_1, sizeof(uint8_t))
- || ({ 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 = 41; (((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_Rfsync(struct _validate_ctx *ctx) {
uint32_t size;
uint8_t typ;
@@ -968,7 +947,41 @@ LM_FLATTEN static bool validate_Tfsync(struct _validate_ctx *ctx) {
;
}
+LM_FLATTEN static bool validate_Rreaddir(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_d(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 = 41; (((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_e
+LM_FLATTEN static bool validate_Rsread(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_d(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 = 153; (((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_e */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_FLATTEN static bool validate_Rread(struct _validate_ctx *ctx) {
uint32_t size;
@@ -978,7 +991,7 @@ LM_FLATTEN static bool validate_Rread(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_d(ctx)
+ || validate_d_signed(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 = 117; (((uint8_t)typ) != exp) &&
@@ -997,7 +1010,7 @@ LM_FLATTEN static bool validate_Twrite(struct _validate_ctx *ctx) {
|| validate_tag(ctx)
|| validate_fid(ctx)
|| (validate_8(ctx) || ({ offset = uint64le_decode(&ctx->net_bytes[ctx->net_offset-8]); false; }))
- || validate_d(ctx)
+ || validate_d_signed(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 = 118; (((uint8_t)typ) != exp) &&
@@ -1271,6 +1284,25 @@ LM_FLATTEN static bool validate_Tsread(struct _validate_ctx *ctx) {
;
}
+LM_FLATTEN static bool validate_Tswrite(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_2(ctx)
+ || _validate_list(ctx, uint16le_decode(&ctx->net_bytes[ctx->net_offset-2]), validate_s, sizeof(struct lib9p_s))
+ || validate_d(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 = 154; (((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_e */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_ALWAYS_INLINE static bool validate_qid(struct _validate_ctx *ctx) {
@@ -1507,43 +1539,6 @@ LM_FLATTEN static bool validate_Rlock(struct _validate_ctx *ctx) {
}
#endif /* CONFIG_9P_ENABLE_9P2000_L */
-#if CONFIG_9P_ENABLE_9P2000_e
-LM_FLATTEN static bool validate_Rsread(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_d_e(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 = 153; (((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_Tswrite(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_2(ctx)
- || _validate_list(ctx, uint16le_decode(&ctx->net_bytes[ctx->net_offset-2]), validate_s, sizeof(struct lib9p_s))
- || validate_d_e(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 = 154; (((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_e */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_ALWAYS_INLINE static bool validate_stat(struct _validate_ctx *ctx) {
uint16_t stat_size;
@@ -1867,6 +1862,15 @@ LM_ALWAYS_INLINE static void unmarshal_d(struct _unmarshal_ctx *ctx, struct lib9
unmarshal_1(ctx, (uint8_t *)&out->dat[i]);
}
+LM_ALWAYS_INLINE static void unmarshal_d_signed(struct _unmarshal_ctx *ctx, struct lib9p_d_signed *out) {
+ memset(out, 0, sizeof(*out));
+ unmarshal_4(ctx, &out->len);
+ out->dat = ctx->extra;
+ ctx->extra += sizeof(out->dat[0]) * out->len;
+ for (typeof(out->len) i = 0; i < out->len; i++)
+ unmarshal_1(ctx, (uint8_t *)&out->dat[i]);
+}
+
LM_ALWAYS_INLINE static void unmarshal_s(struct _unmarshal_ctx *ctx, struct lib9p_s *out) {
memset(out, 0, sizeof(*out));
unmarshal_2(ctx, &out->len);
@@ -1923,17 +1927,6 @@ LM_ALWAYS_INLINE static void unmarshal_lock_status(struct _unmarshal_ctx *ctx, l
}
#endif /* CONFIG_9P_ENABLE_9P2000_L */
-#if CONFIG_9P_ENABLE_9P2000_e
-LM_ALWAYS_INLINE static void unmarshal_d_e(struct _unmarshal_ctx *ctx, struct lib9p_d_e *out) {
- memset(out, 0, sizeof(*out));
- unmarshal_4(ctx, &out->len);
- out->dat = ctx->extra;
- ctx->extra += sizeof(out->dat[0]) * out->len;
- for (typeof(out->len) i = 0; i < out->len; i++)
- unmarshal_1(ctx, &out->dat[i]);
-}
-
-#endif /* CONFIG_9P_ENABLE_9P2000_e */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_FLATTEN static void unmarshal_Tflush(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tflush *out) {
memset(out, 0, sizeof(*out));
@@ -1958,8 +1951,6 @@ LM_FLATTEN static void unmarshal_Rwrite(struct _unmarshal_ctx *ctx, struct lib9p
unmarshal_4(ctx, &out->count);
}
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_FLATTEN static void unmarshal_Rclunk(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rclunk *out) {
memset(out, 0, sizeof(*out));
ctx->net_offset += 4;
@@ -1967,8 +1958,6 @@ LM_FLATTEN static void unmarshal_Rclunk(struct _unmarshal_ctx *ctx, struct lib9p
unmarshal_tag(ctx, &out->tag);
}
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_FLATTEN static void unmarshal_Rremove(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rremove *out) {
memset(out, 0, sizeof(*out));
ctx->net_offset += 4;
@@ -2040,18 +2029,6 @@ LM_FLATTEN static void unmarshal_Rxattrcreate(struct _unmarshal_ctx *ctx, struct
unmarshal_tag(ctx, &out->tag);
}
-LM_FLATTEN static void unmarshal_Rreaddir(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rreaddir *out) {
- memset(out, 0, sizeof(*out));
- ctx->net_offset += 4;
- ctx->net_offset += 1;
- unmarshal_tag(ctx, &out->tag);
- unmarshal_4(ctx, &out->count);
- out->data = ctx->extra;
- ctx->extra += sizeof(out->data[0]) * out->count;
- for (typeof(out->count) i = 0; i < out->count; i++)
- unmarshal_1(ctx, &out->data[i]);
-}
-
LM_FLATTEN static void unmarshal_Rfsync(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rfsync *out) {
memset(out, 0, sizeof(*out));
ctx->net_offset += 4;
@@ -2189,14 +2166,32 @@ LM_FLATTEN static void unmarshal_Tfsync(struct _unmarshal_ctx *ctx, struct lib9p
unmarshal_4(ctx, &out->datasync);
}
+LM_FLATTEN static void unmarshal_Rreaddir(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rreaddir *out) {
+ memset(out, 0, sizeof(*out));
+ ctx->net_offset += 4;
+ ctx->net_offset += 1;
+ unmarshal_tag(ctx, &out->tag);
+ unmarshal_d(ctx, &out->data);
+}
+
#endif /* CONFIG_9P_ENABLE_9P2000_L */
+#if CONFIG_9P_ENABLE_9P2000_e
+LM_FLATTEN static void unmarshal_Rsread(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rsread *out) {
+ memset(out, 0, sizeof(*out));
+ ctx->net_offset += 4;
+ ctx->net_offset += 1;
+ unmarshal_tag(ctx, &out->tag);
+ unmarshal_d(ctx, &out->data);
+}
+
+#endif /* CONFIG_9P_ENABLE_9P2000_e */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_FLATTEN static void unmarshal_Rread(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rread *out) {
memset(out, 0, sizeof(*out));
ctx->net_offset += 4;
ctx->net_offset += 1;
unmarshal_tag(ctx, &out->tag);
- unmarshal_d(ctx, &out->data);
+ unmarshal_d_signed(ctx, &out->data);
}
LM_FLATTEN static void unmarshal_Twrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Twrite *out) {
@@ -2206,7 +2201,7 @@ LM_FLATTEN static void unmarshal_Twrite(struct _unmarshal_ctx *ctx, struct lib9p
unmarshal_tag(ctx, &out->tag);
unmarshal_fid(ctx, &out->fid);
unmarshal_8(ctx, &out->offset);
- unmarshal_d(ctx, &out->data);
+ unmarshal_d_signed(ctx, &out->data);
}
LM_FLATTEN static void unmarshal_Tversion(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tversion *out) {
@@ -2364,6 +2359,20 @@ LM_FLATTEN static void unmarshal_Tsread(struct _unmarshal_ctx *ctx, struct lib9p
unmarshal_s(ctx, &out->wname[i]);
}
+LM_FLATTEN static void unmarshal_Tswrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tswrite *out) {
+ memset(out, 0, sizeof(*out));
+ ctx->net_offset += 4;
+ ctx->net_offset += 1;
+ unmarshal_tag(ctx, &out->tag);
+ unmarshal_4(ctx, &out->fid);
+ unmarshal_2(ctx, &out->nwname);
+ out->wname = ctx->extra;
+ ctx->extra += sizeof(out->wname[0]) * out->nwname;
+ for (typeof(out->nwname) i = 0; i < out->nwname; i++)
+ unmarshal_s(ctx, &out->wname[i]);
+ unmarshal_d(ctx, &out->data);
+}
+
#endif /* CONFIG_9P_ENABLE_9P2000_e */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_ALWAYS_INLINE static void unmarshal_qid(struct _unmarshal_ctx *ctx, struct lib9p_qid *out) {
@@ -2511,30 +2520,6 @@ LM_FLATTEN static void unmarshal_Rlock(struct _unmarshal_ctx *ctx, struct lib9p_
}
#endif /* CONFIG_9P_ENABLE_9P2000_L */
-#if CONFIG_9P_ENABLE_9P2000_e
-LM_FLATTEN static void unmarshal_Rsread(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rsread *out) {
- memset(out, 0, sizeof(*out));
- ctx->net_offset += 4;
- ctx->net_offset += 1;
- unmarshal_tag(ctx, &out->tag);
- unmarshal_d_e(ctx, &out->data);
-}
-
-LM_FLATTEN static void unmarshal_Tswrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tswrite *out) {
- memset(out, 0, sizeof(*out));
- ctx->net_offset += 4;
- ctx->net_offset += 1;
- unmarshal_tag(ctx, &out->tag);
- unmarshal_4(ctx, &out->fid);
- unmarshal_2(ctx, &out->nwname);
- out->wname = ctx->extra;
- ctx->extra += sizeof(out->wname[0]) * out->nwname;
- for (typeof(out->nwname) i = 0; i < out->nwname; i++)
- unmarshal_s(ctx, &out->wname[i]);
- unmarshal_d_e(ctx, &out->data);
-}
-
-#endif /* CONFIG_9P_ENABLE_9P2000_e */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_ALWAYS_INLINE static void unmarshal_stat(struct _unmarshal_ctx *ctx, struct lib9p_stat *out) {
memset(out, 0, sizeof(*out));
@@ -2762,6 +2747,16 @@ LM_ALWAYS_INLINE static bool marshal_d(struct _marshal_ctx *ctx, struct lib9p_d
;
}
+LM_ALWAYS_INLINE static bool marshal_d_signed(struct _marshal_ctx *ctx, struct lib9p_d_signed *val) {
+ return false
+ || marshal_4(ctx, &val->len)
+ || ({ bool err = false;
+ for (typeof(val->len) i = 0; i < val->len && !err; i++)
+ err = marshal_1(ctx, (uint8_t *)&val->dat[i]);
+ err; })
+ ;
+}
+
LM_ALWAYS_INLINE static bool marshal_s(struct _marshal_ctx *ctx, struct lib9p_s *val) {
return false
|| marshal_2(ctx, &val->len)
@@ -2825,18 +2820,6 @@ LM_ALWAYS_INLINE static bool marshal_lock_status(struct _marshal_ctx *ctx, lib9p
}
#endif /* CONFIG_9P_ENABLE_9P2000_L */
-#if CONFIG_9P_ENABLE_9P2000_e
-LM_ALWAYS_INLINE static bool marshal_d_e(struct _marshal_ctx *ctx, struct lib9p_d_e *val) {
- return false
- || marshal_4(ctx, &val->len)
- || ({ bool err = false;
- for (typeof(val->len) i = 0; i < val->len && !err; i++)
- err = marshal_1(ctx, &val->dat[i]);
- err; })
- ;
-}
-
-#endif /* CONFIG_9P_ENABLE_9P2000_e */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_FLATTEN static bool marshal_Tflush(struct _marshal_ctx *ctx, struct lib9p_msg_Tflush *val) {
uint32_t _size_offset;
@@ -2876,8 +2859,6 @@ LM_FLATTEN static bool marshal_Rwrite(struct _marshal_ctx *ctx, struct lib9p_msg
;
}
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_FLATTEN static bool marshal_Rclunk(struct _marshal_ctx *ctx, struct lib9p_msg_Rclunk *val) {
uint32_t _size_offset;
uint32_t _typ_offset;
@@ -2890,8 +2871,6 @@ LM_FLATTEN static bool marshal_Rclunk(struct _marshal_ctx *ctx, struct lib9p_msg
;
}
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_FLATTEN static bool marshal_Rremove(struct _marshal_ctx *ctx, struct lib9p_msg_Rremove *val) {
uint32_t _size_offset;
uint32_t _typ_offset;
@@ -3003,23 +2982,6 @@ LM_FLATTEN static bool marshal_Rxattrcreate(struct _marshal_ctx *ctx, struct lib
;
}
-LM_FLATTEN static bool marshal_Rreaddir(struct _marshal_ctx *ctx, struct lib9p_msg_Rreaddir *val) {
- uint32_t _size_offset;
- uint32_t _typ_offset;
- return false
- || ({ _size_offset = ctx->net_offset; ({ ctx->net_offset += 4; false; }); })
- || ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
- || marshal_tag(ctx, &val->tag)
- || marshal_4(ctx, &val->count)
- || ({ bool err = false;
- for (typeof(val->count) i = 0; i < val->count && !err; i++)
- err = marshal_1(ctx, &val->data[i]);
- err; })
- || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
- || ({ ctx->net_bytes[_typ_offset] = 41; false; })
- ;
-}
-
LM_FLATTEN static bool marshal_Rfsync(struct _marshal_ctx *ctx, struct lib9p_msg_Rfsync *val) {
uint32_t _size_offset;
uint32_t _typ_offset;
@@ -3237,7 +3199,35 @@ LM_FLATTEN static bool marshal_Tfsync(struct _marshal_ctx *ctx, struct lib9p_msg
;
}
+LM_FLATTEN static bool marshal_Rreaddir(struct _marshal_ctx *ctx, struct lib9p_msg_Rreaddir *val) {
+ uint32_t _size_offset;
+ uint32_t _typ_offset;
+ return false
+ || ({ _size_offset = ctx->net_offset; ({ ctx->net_offset += 4; false; }); })
+ || ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
+ || marshal_tag(ctx, &val->tag)
+ || marshal_d(ctx, &val->data)
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 41; false; })
+ ;
+}
+
#endif /* CONFIG_9P_ENABLE_9P2000_L */
+#if CONFIG_9P_ENABLE_9P2000_e
+LM_FLATTEN static bool marshal_Rsread(struct _marshal_ctx *ctx, struct lib9p_msg_Rsread *val) {
+ uint32_t _size_offset;
+ uint32_t _typ_offset;
+ return false
+ || ({ _size_offset = ctx->net_offset; ({ ctx->net_offset += 4; false; }); })
+ || ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
+ || marshal_tag(ctx, &val->tag)
+ || marshal_d(ctx, &val->data)
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 153; false; })
+ ;
+}
+
+#endif /* CONFIG_9P_ENABLE_9P2000_e */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_FLATTEN static bool marshal_Rread(struct _marshal_ctx *ctx, struct lib9p_msg_Rread *val) {
uint32_t _size_offset;
@@ -3246,7 +3236,7 @@ LM_FLATTEN static bool marshal_Rread(struct _marshal_ctx *ctx, struct lib9p_msg_
|| ({ _size_offset = ctx->net_offset; ({ ctx->net_offset += 4; false; }); })
|| ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
|| marshal_tag(ctx, &val->tag)
- || marshal_d(ctx, &val->data)
+ || marshal_d_signed(ctx, &val->data)
|| ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
|| ({ ctx->net_bytes[_typ_offset] = 117; false; })
;
@@ -3261,7 +3251,7 @@ LM_FLATTEN static bool marshal_Twrite(struct _marshal_ctx *ctx, struct lib9p_msg
|| marshal_tag(ctx, &val->tag)
|| marshal_fid(ctx, &val->fid)
|| marshal_8(ctx, &val->offset)
- || marshal_d(ctx, &val->data)
+ || marshal_d_signed(ctx, &val->data)
|| ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
|| ({ ctx->net_bytes[_typ_offset] = 118; false; })
;
@@ -3492,6 +3482,25 @@ LM_FLATTEN static bool marshal_Tsread(struct _marshal_ctx *ctx, struct lib9p_msg
;
}
+LM_FLATTEN static bool marshal_Tswrite(struct _marshal_ctx *ctx, struct lib9p_msg_Tswrite *val) {
+ uint32_t _size_offset;
+ uint32_t _typ_offset;
+ return false
+ || ({ _size_offset = ctx->net_offset; ({ ctx->net_offset += 4; false; }); })
+ || ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
+ || marshal_tag(ctx, &val->tag)
+ || marshal_4(ctx, &val->fid)
+ || marshal_2(ctx, &val->nwname)
+ || ({ bool err = false;
+ for (typeof(val->nwname) i = 0; i < val->nwname && !err; i++)
+ err = marshal_s(ctx, &val->wname[i]);
+ err; })
+ || marshal_d(ctx, &val->data)
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 154; false; })
+ ;
+}
+
#endif /* CONFIG_9P_ENABLE_9P2000_e */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_ALWAYS_INLINE static bool marshal_qid(struct _marshal_ctx *ctx, struct lib9p_qid *val) {
@@ -3695,40 +3704,6 @@ LM_FLATTEN static bool marshal_Rlock(struct _marshal_ctx *ctx, struct lib9p_msg_
}
#endif /* CONFIG_9P_ENABLE_9P2000_L */
-#if CONFIG_9P_ENABLE_9P2000_e
-LM_FLATTEN static bool marshal_Rsread(struct _marshal_ctx *ctx, struct lib9p_msg_Rsread *val) {
- uint32_t _size_offset;
- uint32_t _typ_offset;
- return false
- || ({ _size_offset = ctx->net_offset; ({ ctx->net_offset += 4; false; }); })
- || ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
- || marshal_tag(ctx, &val->tag)
- || marshal_d_e(ctx, &val->data)
- || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
- || ({ ctx->net_bytes[_typ_offset] = 153; false; })
- ;
-}
-
-LM_FLATTEN static bool marshal_Tswrite(struct _marshal_ctx *ctx, struct lib9p_msg_Tswrite *val) {
- uint32_t _size_offset;
- uint32_t _typ_offset;
- return false
- || ({ _size_offset = ctx->net_offset; ({ ctx->net_offset += 4; false; }); })
- || ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
- || marshal_tag(ctx, &val->tag)
- || marshal_4(ctx, &val->fid)
- || marshal_2(ctx, &val->nwname)
- || ({ bool err = false;
- for (typeof(val->nwname) i = 0; i < val->nwname && !err; i++)
- err = marshal_s(ctx, &val->wname[i]);
- err; })
- || marshal_d_e(ctx, &val->data)
- || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
- || ({ ctx->net_bytes[_typ_offset] = 154; false; })
- ;
-}
-
-#endif /* CONFIG_9P_ENABLE_9P2000_e */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_ALWAYS_INLINE static bool marshal_stat(struct _marshal_ctx *ctx, struct lib9p_stat *val) {
uint32_t _stat_size_offset;
@@ -4125,6 +4100,7 @@ const struct _lib9p_recv_tentry _lib9p_table_Rmsg_recv[LIB9P_VER_NUM][0x80] = {
_MSG_RECV(Rwalk),
_MSG_RECV(Rread),
_MSG_RECV(Rwrite),
+ _MSG_RECV(Rclunk),
_MSG_RECV(Rremove),
},
#endif /* CONFIG_9P_ENABLE_9P2000_L */
@@ -4313,6 +4289,7 @@ const struct _lib9p_send_tentry _lib9p_table_Rmsg_send[LIB9P_VER_NUM][0x80] = {
_MSG_SEND(Rwalk),
_MSG_SEND(Rread),
_MSG_SEND(Rwrite),
+ _MSG_SEND(Rclunk),
_MSG_SEND(Rremove),
},
#endif /* CONFIG_9P_ENABLE_9P2000_L */
diff --git a/lib9p/idl.gen b/lib9p/idl.gen
index f154cb1..0b86246 100755
--- a/lib9p/idl.gen
+++ b/lib9p/idl.gen
@@ -40,12 +40,8 @@ def add_prefix(p: str, s: str) -> str:
return p + s
-def join_lines(*args: str) -> str:
- return "\n".join([a.rstrip() for a in args]).rstrip() + "\n"
-
-
-def c_macro(*args: str) -> str:
- full = join_lines(*args).rstrip()
+def c_macro(full: str) -> str:
+ full = full.rstrip()
assert "\n" in full
lines = [l.rstrip() for l in full.split("\n")]
width = max(len(l.expandtabs(tabsize=8)) for l in lines[:-1])
@@ -73,7 +69,9 @@ def c_ver_cond(versions: set[str]) -> str:
def c_typename(typ: idl.Type, parent: idl.Type | None = None) -> str:
match typ:
case idl.Primitive():
- if typ.value == 1 and parent and parent.name in ["d", "s"]: # SPECIAL
+ if (
+ typ.value == 1 and parent and parent.name in ["d", "d_signed", "s"]
+ ): # SPECIAL
return "[[gnu::nonstring]] char"
return f"uint{typ.value*8}_t"
case idl.Number():
@@ -279,12 +277,11 @@ enum {idprefix}version {{
case idl.Bitfield():
ret += f"typedef {c_typename(typ.prim)} {c_typename(typ)};\n"
names = [
- *reversed(
- [typ.bits[n] or f" {n}" for n in range(0, len(typ.bits))]
- ),
- "",
- *[k for k in typ.names if k not in typ.bits],
+ 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.name.upper()}_"
namewidth = max(len(add_prefix(prefix, name)) for name in names)
@@ -499,7 +496,7 @@ LM_ALWAYS_INLINE static bool _validate_list(struct _validate_ctx *ctx,
ret += ifdef_push(1, c_ver_ifdef(typ.in_versions))
ret += f"{inline} static bool validate_{typ.name}(struct _validate_ctx *{argfn('ctx')}) {{\n"
- if typ.name == "d": # SPECIAL
+ if typ.name == "d" or typ.name == "d_signed": # SPECIAL
# Optimize... maybe the compiler could figure out to do
# this, but let's make it obvious.
ret += "\tuint32_t base_offset = ctx->net_offset;\n"
@@ -672,7 +669,7 @@ LM_ALWAYS_INLINE static void unmarshal_8(struct _unmarshal_ctx *ctx, uint64_t *o
ret += f"out->{member.name} = ctx->extra;\n"
ret += f"{prefix}ctx->extra += sizeof(out->{member.name}[0]) * out->{member.cnt.name};\n"
ret += f"{prefix}for (typeof(out->{member.cnt.name}) i = 0; i < out->{member.cnt.name}; i++)\n"
- if typ.name in ["d", "s"]: # SPECIAL
+ if typ.name in ["d", "d_signed", "s"]: # SPECIAL
# Special-case is that we cast from `char` to `uint8_t`.
ret += f"{prefix}\tunmarshal_{member.typ.name}(ctx, (uint8_t *)&out->{member.name}[i]);\n"
else:
@@ -775,7 +772,7 @@ LM_ALWAYS_INLINE static bool marshal_8(struct _marshal_ctx *ctx, uint64_t *val)
ret += "({ bool err = false;\n"
ret += f"\t for (typeof(val->{member.cnt.name}) i = 0; i < val->{member.cnt.name} && !err; i++)\n"
ret += "\t \terr = "
- if typ.name in ["d", "s"]: # SPECIAL
+ if typ.name in ["d", "d_signed", "s"]: # SPECIAL
# Special-case is that we cast from `char` to `uint8_t`.
ret += f"marshal_{member.typ.name}(ctx, (uint8_t *)&val->{member.name}[i]);\n"
else:
@@ -816,16 +813,16 @@ LM_ALWAYS_INLINE static bool marshal_8(struct _marshal_ctx *ctx, uint64_t *val)
"""
ret += c_macro(
- f"#define _MSG_RECV(typ) [{idprefix.upper()}TYP_##typ/2] = {{",
- f"\t\t.basesize = sizeof(struct {idprefix}msg_##typ),",
- f"\t\t.validate = validate_##typ,",
- f"\t\t.unmarshal = (_unmarshal_fn_t)unmarshal_##typ,",
- f"\t}}",
+ f"#define _MSG_RECV(typ) [{idprefix.upper()}TYP_##typ/2] = {{\n"
+ f"\t\t.basesize = sizeof(struct {idprefix}msg_##typ),\n"
+ f"\t\t.validate = validate_##typ,\n"
+ f"\t\t.unmarshal = (_unmarshal_fn_t)unmarshal_##typ,\n"
+ f"\t}}\n"
)
ret += c_macro(
- f"#define _MSG_SEND(typ) [{idprefix.upper()}TYP_##typ/2] = {{",
- f"\t\t.marshal = (_marshal_fn_t)marshal_##typ,",
- f"\t}}",
+ f"#define _MSG_SEND(typ) [{idprefix.upper()}TYP_##typ/2] = {{\n"
+ f"\t\t.marshal = (_marshal_fn_t)marshal_##typ,\n"
+ f"\t}}\n"
)
ret += "\n"
ret += msg_table("Tmsg", "recv", f"struct _{idprefix}recv_tentry", (0, 0x100, 2))
diff --git a/lib9p/idl/2002-9P2000.9p b/lib9p/idl/2002-9P2000.9p
index c1cd74b..f0df7d1 100644
--- a/lib9p/idl/2002-9P2000.9p
+++ b/lib9p/idl/2002-9P2000.9p
@@ -27,8 +27,11 @@ num tag = 2
num fid = 4
"NOFID = ~0"
+# data - u32le `n`, then `n` bytes of data
+struct d = "len[4] len*(dat[1])"
+
# data - s32le `n`, then `n` bytes of data
-struct d = "len[4,max=s32_max] len*(dat[1])"
+struct d_signed = "len[4,max=s32_max] len*(dat[1])"
# string - u16le `n`, then `n` bytes of UTF-8, without any nul-bytes
struct s = "len[2] len*(utf8[1])"
@@ -142,8 +145,8 @@ msg Ropen = "size[4,val=end-&size] typ[1,val=113] tag[tag] qid[qid] iounit[4]
msg Tcreate = "size[4,val=end-&size] typ[1,val=114] tag[tag] fid[fid] name[s] perm[dm] mode[o]"
msg Rcreate = "size[4,val=end-&size] typ[1,val=115] tag[tag] qid[qid] iounit[4]"
msg Tread = "size[4,val=end-&size] typ[1,val=116] tag[tag] fid[fid] offset[8,max=s64_max] count[4,max=s32_max]"
-msg Rread = "size[4,val=end-&size] typ[1,val=117] tag[tag] data[d]" # for directories `data` is the sequence "cnt*(entries[stat])"
-msg Twrite = "size[4,val=end-&size] typ[1,val=118] tag[tag] fid[fid] offset[8,max=s64_max] data[d]"
+msg Rread = "size[4,val=end-&size] typ[1,val=117] tag[tag] data[d_signed]" # for directories `data` is the sequence "cnt*(entries[stat])"
+msg Twrite = "size[4,val=end-&size] typ[1,val=118] tag[tag] fid[fid] offset[8,max=s64_max] data[d_signed]"
msg Rwrite = "size[4,val=end-&size] typ[1,val=119] tag[tag] count[4]"
msg Tclunk = "size[4,val=end-&size] typ[1,val=120] tag[tag] fid[fid]"
msg Rclunk = "size[4,val=end-&size] typ[1,val=121] tag[tag]"
diff --git a/lib9p/idl/2010-9P2000.L.9p b/lib9p/idl/2010-9P2000.L.9p
index 3886265..3e5db69 100644
--- a/lib9p/idl/2010-9P2000.L.9p
+++ b/lib9p/idl/2010-9P2000.L.9p
@@ -7,9 +7,9 @@
# https://github.com/chaos/diod/blob/master/protocol.md
version "9P2000.L"
-from ./2002-9P2000.9p import tag, fid, s, d, qt, qid
+from ./2002-9P2000.9p import tag, fid, s, d, d_signed, 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 ./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
bitfield getattr = 8
@@ -89,7 +89,7 @@ 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] data[d]" # data is "qid[qid] offset[8] type[1] name[s]"
#...
msg Tfsync = "size[4,val=end-&size] typ[1,val=50] tag[tag] fid[fid] datasync[4]"
msg Rfsync = "size[4,val=end-&size] typ[1,val=51] tag[tag]"
diff --git a/lib9p/idl/2012-9P2000.e.9p b/lib9p/idl/2012-9P2000.e.9p
index aba4e66..ef80796 100644
--- a/lib9p/idl/2012-9P2000.e.9p
+++ b/lib9p/idl/2012-9P2000.e.9p
@@ -10,12 +10,9 @@ version "9P2000.e"
from ./2002-9P2000.9p import *
-# like 9P2000 `d`, but without the s32_max limit
-struct d_e = "len[4] len*(dat[1])"
-
msg Tsession = "size[4,val=end-&size] typ[1,val=150] tag[tag] key[8]"
msg Rsession = "size[4,val=end-&size] typ[1,val=151] tag[tag]"
msg Tsread = "size[4,val=end-&size] typ[1,val=152] tag[tag] fid[4] nwname[2] nwname*(wname[s])"
-msg Rsread = "size[4,val=end-&size] typ[1,val=153] tag[tag] data[d_e]"
-msg Tswrite = "size[4,val=end-&size] typ[1,val=154] tag[tag] fid[4] nwname[2] nwname*(wname[s]) data[d_e]"
+msg Rsread = "size[4,val=end-&size] typ[1,val=153] tag[tag] data[d]"
+msg Tswrite = "size[4,val=end-&size] typ[1,val=154] tag[tag] fid[4] nwname[2] nwname*(wname[s]) data[d]"
msg Rswrite = "size[4,val=end-&size] typ[1,val=155] tag[tag] count[4]"
diff --git a/lib9p/idl/__init__.py b/lib9p/idl/__init__.py
index fec6c41..41664f1 100644
--- a/lib9p/idl/__init__.py
+++ b/lib9p/idl/__init__.py
@@ -449,8 +449,10 @@ def parse_file(
other_version, other_typs = get_include(m.group("file"))
for symname in m.group("syms").split(sep=","):
symname = symname.strip()
+ found = False
for typ in other_typs:
if typ.name == symname or symname == "*":
+ found = True
match typ:
case Primitive():
pass
@@ -467,6 +469,10 @@ def parse_file(
if other_version in member.in_versions:
member.in_versions.add(version)
env[typ.name] = typ
+ if symname != "*" and not found:
+ raise ValueError(
+ f"import: {m.group('file')}: no symbol {repr(symname)}"
+ )
elif m := re.fullmatch(re_line_num, line):
num = Number()
num.name = m.group("name")
diff --git a/lib9p/include/lib9p/9p.generated.h b/lib9p/include/lib9p/9p.generated.h
index abc2686..99bc4ce 100644
--- a/lib9p/include/lib9p/9p.generated.h
+++ b/lib9p/include/lib9p/9p.generated.h
@@ -113,11 +113,7 @@ enum lib9p_msg_type { /* uint8_t */
LIB9P_TYP_Twrite = 118,
LIB9P_TYP_Rwrite = 119,
LIB9P_TYP_Tclunk = 120,
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LIB9P_TYP_Rclunk = 121,
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LIB9P_TYP_Tremove = 122,
LIB9P_TYP_Rremove = 123,
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
@@ -148,12 +144,18 @@ typedef uint16_t lib9p_tag_t;
typedef uint32_t lib9p_fid_t;
#define LIB9P_FID_NOFID ((lib9p_fid_t)UINT32_C(~0))
-/* min_size = 4 ; max_size = 2,147,483,651 */
+/* min_size = 4 ; max_size = 4,294,967,299 (warning: >UINT32_MAX) */
struct lib9p_d {
uint32_t len;
[[gnu::nonstring]] char *dat;
};
+/* min_size = 4 ; max_size = 2,147,483,651 */
+struct lib9p_d_signed {
+ uint32_t len;
+ [[gnu::nonstring]] char *dat;
+};
+
/* min_size = 2 ; max_size = 65,537 */
struct lib9p_s {
uint16_t len;
@@ -358,7 +360,6 @@ typedef uint32_t lib9p_setattr_t;
#define LIB9P_SETATTR_UID ((lib9p_setattr_t)(1<<1))
#define LIB9P_SETATTR_MODE ((lib9p_setattr_t)(1<<0))
-
/* size = 1 */
typedef uint8_t lib9p_lock_type_t;
#define LIB9P_LOCK_TYPE_RDLCK ((lib9p_lock_type_t)UINT8_C(0))
@@ -401,7 +402,6 @@ typedef uint32_t lib9p_lock_flags_t;
#define LIB9P_LOCK_FLAGS_RECLAIM ((lib9p_lock_flags_t)(1<<1))
#define LIB9P_LOCK_FLAGS_BLOCK ((lib9p_lock_flags_t)(1<<0))
-
/* size = 1 */
typedef uint8_t lib9p_lock_status_t;
#define LIB9P_LOCK_STATUS_SUCCESS ((lib9p_lock_status_t)UINT8_C(0))
@@ -410,14 +410,6 @@ typedef uint8_t lib9p_lock_status_t;
#define LIB9P_LOCK_STATUS_GRACE ((lib9p_lock_status_t)UINT8_C(3))
#endif /* CONFIG_9P_ENABLE_9P2000_L */
-#if CONFIG_9P_ENABLE_9P2000_e
-/* min_size = 4 ; max_size = 4,294,967,299 (warning: >UINT32_MAX) */
-struct lib9p_d_e {
- uint32_t len;
- uint8_t *dat;
-};
-
-#endif /* CONFIG_9P_ENABLE_9P2000_e */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
/* size = 9 */
struct lib9p_msg_Tflush {
@@ -436,15 +428,11 @@ struct lib9p_msg_Rwrite {
uint32_t count;
};
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
/* size = 7 */
struct lib9p_msg_Rclunk {
lib9p_tag_t tag;
};
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
/* size = 7 */
struct lib9p_msg_Rremove {
lib9p_tag_t tag;
@@ -500,13 +488,6 @@ struct lib9p_msg_Rxattrcreate {
lib9p_tag_t tag;
};
-/* min_size = 11 ; max_size = 4,294,967,306 (warning: >UINT32_MAX) */
-struct lib9p_msg_Rreaddir {
- lib9p_tag_t tag;
- uint32_t count;
- uint8_t *data;
-};
-
/* size = 7 */
struct lib9p_msg_Rfsync {
lib9p_tag_t tag;
@@ -612,20 +593,34 @@ struct lib9p_msg_Tfsync {
uint32_t datasync;
};
+/* min_size = 11 ; max_size = 4,294,967,306 (warning: >UINT32_MAX) */
+struct lib9p_msg_Rreaddir {
+ lib9p_tag_t tag;
+ struct lib9p_d data;
+};
+
#endif /* CONFIG_9P_ENABLE_9P2000_L */
+#if CONFIG_9P_ENABLE_9P2000_e
+/* min_size = 11 ; max_size = 4,294,967,306 (warning: >UINT32_MAX) */
+struct lib9p_msg_Rsread {
+ lib9p_tag_t tag;
+ struct lib9p_d data;
+};
+
+#endif /* CONFIG_9P_ENABLE_9P2000_e */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
/* min_size = 11 ; max_size = 2,147,483,658 */
struct lib9p_msg_Rread {
- lib9p_tag_t tag;
- struct lib9p_d data;
+ lib9p_tag_t tag;
+ struct lib9p_d_signed data;
};
/* min_size = 23 ; max_size = 2,147,483,670 */
struct lib9p_msg_Twrite {
- lib9p_tag_t tag;
- lib9p_fid_t fid;
- uint64_t offset;
- struct lib9p_d data;
+ lib9p_tag_t tag;
+ lib9p_fid_t fid;
+ uint64_t offset;
+ struct lib9p_d_signed data;
};
/* min_size = 13 ; max_size = 65,548 */
@@ -752,6 +747,15 @@ struct lib9p_msg_Tsread {
struct lib9p_s *wname;
};
+/* min_size = 17 ; max_size = 8,589,934,607 (warning: >UINT32_MAX) */
+struct lib9p_msg_Tswrite {
+ lib9p_tag_t tag;
+ uint32_t fid;
+ uint16_t nwname;
+ struct lib9p_s *wname;
+ struct lib9p_d data;
+};
+
#endif /* CONFIG_9P_ENABLE_9P2000_e */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
/* size = 13 */
@@ -883,23 +887,6 @@ struct lib9p_msg_Rlock {
};
#endif /* CONFIG_9P_ENABLE_9P2000_L */
-#if CONFIG_9P_ENABLE_9P2000_e
-/* min_size = 11 ; max_size = 4,294,967,306 (warning: >UINT32_MAX) */
-struct lib9p_msg_Rsread {
- lib9p_tag_t tag;
- struct lib9p_d_e data;
-};
-
-/* min_size = 17 ; max_size = 8,589,934,607 (warning: >UINT32_MAX) */
-struct lib9p_msg_Tswrite {
- lib9p_tag_t tag;
- uint32_t fid;
- uint16_t nwname;
- struct lib9p_s *wname;
- struct lib9p_d_e data;
-};
-
-#endif /* CONFIG_9P_ENABLE_9P2000_e */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
/* LIB9P_VER_9P2000 : min_size = 49 ; max_size = 262,189 */
/* LIB9P_VER_9P2000_e: min_size = 49 ; max_size = 262,189 */