diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-01-14 18:59:16 -0700 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-01-14 20:01:57 -0700 |
commit | 4e987e1b1e0aef7dc0ab634fd65b9e04969eb9c9 (patch) | |
tree | e1ce0705e0002f0c7418b7c89577ae7439a7428f | |
parent | e73293ae85e39999a37a9798ff44807e5e54625e (diff) |
lib9p: idl.gen: Do topological sorting on types
-rw-r--r-- | lib9p/9p.generated.c | 1042 | ||||
-rwxr-xr-x | lib9p/idl.gen | 28 | ||||
-rw-r--r-- | lib9p/include/lib9p/9p.generated.h | 280 |
3 files changed, 705 insertions, 645 deletions
diff --git a/lib9p/9p.generated.c b/lib9p/9p.generated.c index 6757134..f1ed265 100644 --- a/lib9p/9p.generated.c +++ b/lib9p/9p.generated.c @@ -159,41 +159,6 @@ LM_ALWAYS_INLINE static bool validate_qt(struct _validate_ctx *ctx) { return false; } -LM_ALWAYS_INLINE static bool validate_qid(struct _validate_ctx *ctx) { - return false - || validate_qt(ctx) - || validate_4(ctx) - || validate_8(ctx) - ; -} - -LM_ALWAYS_INLINE static bool validate_stat(struct _validate_ctx *ctx) { - uint16_t stat_size; - uint32_t _kern_type_offset; - return false - || (validate_2(ctx) || ({ stat_size = decode_u16le(&ctx->net_bytes[ctx->net_offset-2]); false; })) - || ({ _kern_type_offset = ctx->net_offset; validate_2(ctx); }) - || validate_4(ctx) - || validate_qid(ctx) - || validate_dm(ctx) - || validate_4(ctx) - || validate_4(ctx) - || validate_8(ctx) - || validate_s(ctx) - || validate_s(ctx) - || validate_s(ctx) - || validate_s(ctx) -#if CONFIG_9P_ENABLE_9P2000_u - || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && validate_s(ctx) ) - || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && validate_4(ctx) ) - || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && validate_4(ctx) ) - || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && validate_4(ctx) ) -#endif /* CONFIG_9P_ENABLE_9P2000_u */ - || ({ uint16_t exp = ctx->net_offset - _kern_type_offset; (((uint16_t)stat_size) != exp) && - lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "stat_size value is wrong (actual:%"PRIu16" != correct:%"PRIu16")", (uint16_t)stat_size, exp); }) - ; -} - LM_ALWAYS_INLINE static bool validate_o(struct _validate_ctx *ctx) { if (validate_1(ctx)) return true; @@ -204,7 +169,7 @@ LM_ALWAYS_INLINE static bool validate_o(struct _validate_ctx *ctx) { return false; } -LM_FLATTEN static bool validate_Tversion(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Tflush(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -212,16 +177,15 @@ LM_FLATTEN static bool validate_Tversion(struct _validate_ctx *ctx) { || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; })) || validate_tag(ctx) - || validate_4(ctx) - || validate_s(ctx) + || validate_2(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 = 100; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 108; (((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_Rversion(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Rflush(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -229,16 +193,14 @@ LM_FLATTEN static bool validate_Rversion(struct _validate_ctx *ctx) { || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; })) || validate_tag(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 = 101; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 109; (((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_Tauth(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Rwrite(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -246,20 +208,15 @@ LM_FLATTEN static bool validate_Tauth(struct _validate_ctx *ctx) { || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; })) || validate_tag(ctx) - || validate_fid(ctx) - || validate_s(ctx) - || validate_s(ctx) -#if CONFIG_9P_ENABLE_9P2000_u - || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && validate_4(ctx) ) -#endif /* CONFIG_9P_ENABLE_9P2000_u */ + || 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 = 102; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 119; (((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_Rauth(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Rclunk(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -267,15 +224,14 @@ LM_FLATTEN static bool validate_Rauth(struct _validate_ctx *ctx) { || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; })) || validate_tag(ctx) - || validate_qid(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 = 103; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 121; (((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_Tattach(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Rremove(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -283,21 +239,14 @@ LM_FLATTEN static bool validate_Tattach(struct _validate_ctx *ctx) { || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; })) || validate_tag(ctx) - || validate_fid(ctx) - || validate_fid(ctx) - || validate_s(ctx) - || validate_s(ctx) -#if CONFIG_9P_ENABLE_9P2000_u - || ( (ctx->ctx->version==LIB9P_VER_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 = 104; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 123; (((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_Rattach(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Rwstat(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -305,15 +254,16 @@ LM_FLATTEN static bool validate_Rattach(struct _validate_ctx *ctx) { || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; })) || validate_tag(ctx) - || validate_qid(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 = 105; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 127; (((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_Rerror(struct _validate_ctx *ctx) { +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_9P2000_e +LM_FLATTEN static bool validate_Tsession(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -321,18 +271,15 @@ LM_FLATTEN static bool validate_Rerror(struct _validate_ctx *ctx) { || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; })) || validate_tag(ctx) - || validate_s(ctx) -#if CONFIG_9P_ENABLE_9P2000_u - || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && validate_4(ctx) ) -#endif /* CONFIG_9P_ENABLE_9P2000_u */ + || validate_8(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 = 107; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 150; (((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_Tflush(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Rsession(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -340,15 +287,14 @@ LM_FLATTEN static bool validate_Tflush(struct _validate_ctx *ctx) { || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; })) || validate_tag(ctx) - || validate_2(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 = 108; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 151; (((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_Rflush(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Rswrite(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -356,56 +302,57 @@ LM_FLATTEN static bool validate_Rflush(struct _validate_ctx *ctx) { || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = decode_u8le(&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 = 109; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 155; (((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) { +#endif /* CONFIG_9P_ENABLE_9P2000_e */ +#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u +LM_FLATTEN static bool validate_Tread(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; - uint16_t nwname; + uint64_t offset; + uint32_t count; uint32_t _size_offset; return false || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; })) || validate_tag(ctx) || validate_fid(ctx) - || validate_fid(ctx) - || (validate_2(ctx) || ({ nwname = decode_u16le(&ctx->net_bytes[ctx->net_offset-2]); false; })) - || _validate_list(ctx, decode_u16le(&ctx->net_bytes[ctx->net_offset-2]), validate_s, sizeof(struct lib9p_s)) + || (validate_8(ctx) || ({ offset = decode_u64le(&ctx->net_bytes[ctx->net_offset-8]); false; })) + || (validate_4(ctx) || ({ count = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; })) || ({ 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 = 110; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 116; (((uint8_t)typ) != exp) && lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); }) - || ({ uint16_t max = 16; (((uint16_t)nwname) > max) && - lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "nwname value is too large (%"PRIu16" > %"PRIu16")", nwname, max); }) + || ({ uint64_t max = INT64_MAX; (((uint64_t)offset) > max) && + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "offset value is too large (%"PRIu64" > %"PRIu64")", offset, max); }) + || ({ uint32_t max = INT32_MAX; (((uint32_t)count) > max) && + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "count value is too large (%"PRIu32" > %"PRIu32")", count, max); }) ; } -LM_FLATTEN static bool validate_Rwalk(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Tclunk(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; - uint16_t nwqid; uint32_t _size_offset; return false || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; })) || validate_tag(ctx) - || (validate_2(ctx) || ({ nwqid = decode_u16le(&ctx->net_bytes[ctx->net_offset-2]); false; })) - || _validate_list(ctx, decode_u16le(&ctx->net_bytes[ctx->net_offset-2]), validate_qid, sizeof(struct lib9p_qid)) + || validate_fid(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 = 111; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 120; (((uint8_t)typ) != exp) && lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); }) - || ({ uint16_t max = 16; (((uint16_t)nwqid) > max) && - lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "nwqid value is too large (%"PRIu16" > %"PRIu16")", nwqid, max); }) ; } -LM_FLATTEN static bool validate_Topen(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Tremove(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -414,15 +361,14 @@ LM_FLATTEN static bool validate_Topen(struct _validate_ctx *ctx) { || (validate_1(ctx) || ({ typ = decode_u8le(&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) && + || ({ uint8_t exp = 122; (((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_Ropen(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Tstat(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -430,16 +376,15 @@ LM_FLATTEN static bool validate_Ropen(struct _validate_ctx *ctx) { || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; })) || validate_tag(ctx) - || validate_qid(ctx) - || validate_4(ctx) + || validate_fid(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 = 113; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 124; (((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_Rread(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -447,59 +392,56 @@ LM_FLATTEN static bool validate_Tcreate(struct _validate_ctx *ctx) { || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; })) || validate_tag(ctx) - || validate_fid(ctx) - || validate_s(ctx) - || validate_dm(ctx) - || validate_o(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 = 114; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 117; (((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_Rcreate(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Twrite(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; + uint64_t offset; uint32_t _size_offset; return false || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; })) || validate_tag(ctx) - || validate_qid(ctx) - || validate_4(ctx) + || validate_fid(ctx) + || (validate_8(ctx) || ({ offset = decode_u64le(&ctx->net_bytes[ctx->net_offset-8]); false; })) + || 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 = 115; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 118; (((uint8_t)typ) != exp) && lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); }) + || ({ uint64_t max = INT64_MAX; (((uint64_t)offset) > max) && + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "offset value is too large (%"PRIu64" > %"PRIu64")", offset, max); }) ; } -LM_FLATTEN static bool validate_Tread(struct _validate_ctx *ctx) { +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_9P2000_e +LM_FLATTEN static bool validate_Rsread(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; - uint64_t offset; - uint32_t count; uint32_t _size_offset; return false || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; })) || validate_tag(ctx) - || validate_fid(ctx) - || (validate_8(ctx) || ({ offset = decode_u64le(&ctx->net_bytes[ctx->net_offset-8]); false; })) - || (validate_4(ctx) || ({ count = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; })) + || 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 = 116; (((uint8_t)typ) != 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); }) - || ({ uint64_t max = INT64_MAX; (((uint64_t)offset) > max) && - lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "offset value is too large (%"PRIu64" > %"PRIu64")", offset, max); }) - || ({ uint32_t max = INT32_MAX; (((uint32_t)count) > max) && - lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "count value is too large (%"PRIu32" > %"PRIu32")", count, max); }) ; } -LM_FLATTEN static bool validate_Rread(struct _validate_ctx *ctx) { +#endif /* CONFIG_9P_ENABLE_9P2000_e */ +#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u +LM_FLATTEN static bool validate_Tversion(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -507,36 +449,33 @@ LM_FLATTEN static bool validate_Rread(struct _validate_ctx *ctx) { || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; })) || validate_tag(ctx) - || validate_d(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 = 117; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 100; (((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_Twrite(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Rversion(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; - uint64_t offset; uint32_t _size_offset; return false || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; })) || validate_tag(ctx) - || validate_fid(ctx) - || (validate_8(ctx) || ({ offset = decode_u64le(&ctx->net_bytes[ctx->net_offset-8]); false; })) - || validate_d(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 = 118; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 101; (((uint8_t)typ) != exp) && lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); }) - || ({ uint64_t max = INT64_MAX; (((uint64_t)offset) > max) && - lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "offset value is too large (%"PRIu64" > %"PRIu64")", offset, max); }) ; } -LM_FLATTEN static bool validate_Rwrite(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Tauth(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -544,15 +483,20 @@ LM_FLATTEN static bool validate_Rwrite(struct _validate_ctx *ctx) { || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; })) || validate_tag(ctx) - || validate_4(ctx) + || validate_fid(ctx) + || validate_s(ctx) + || validate_s(ctx) +#if CONFIG_9P_ENABLE_9P2000_u + || ( (ctx->ctx->version==LIB9P_VER_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 = 119; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 102; (((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_Tclunk(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Tattach(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -561,14 +505,20 @@ LM_FLATTEN static bool validate_Tclunk(struct _validate_ctx *ctx) { || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; })) || validate_tag(ctx) || validate_fid(ctx) + || validate_fid(ctx) + || validate_s(ctx) + || validate_s(ctx) +#if CONFIG_9P_ENABLE_9P2000_u + || ( (ctx->ctx->version==LIB9P_VER_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 = 120; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 104; (((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_Rclunk(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Rerror(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -576,30 +526,42 @@ LM_FLATTEN static bool validate_Rclunk(struct _validate_ctx *ctx) { || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; })) || validate_tag(ctx) + || validate_s(ctx) +#if CONFIG_9P_ENABLE_9P2000_u + || ( (ctx->ctx->version==LIB9P_VER_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 = 121; (((uint8_t)typ) != 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_Tremove(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Twalk(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; + uint16_t nwname; uint32_t _size_offset; return false || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; })) || validate_tag(ctx) || validate_fid(ctx) + || validate_fid(ctx) + || (validate_2(ctx) || ({ nwname = decode_u16le(&ctx->net_bytes[ctx->net_offset-2]); false; })) + || _validate_list(ctx, decode_u16le(&ctx->net_bytes[ctx->net_offset-2]), validate_s, sizeof(struct lib9p_s)) || ({ 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 = 122; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 110; (((uint8_t)typ) != exp) && lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); }) + || ({ uint16_t max = 16; (((uint16_t)nwname) > max) && + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "nwname value is too large (%"PRIu16" > %"PRIu16")", nwname, max); }) ; } -LM_FLATTEN static bool validate_Rremove(struct _validate_ctx *ctx) { +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_9P2000_e +LM_FLATTEN static bool validate_Tsread(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -607,14 +569,17 @@ LM_FLATTEN static bool validate_Rremove(struct _validate_ctx *ctx) { || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; })) || validate_tag(ctx) + || validate_4(ctx) + || validate_2(ctx) + || _validate_list(ctx, decode_u16le(&ctx->net_bytes[ctx->net_offset-2]), validate_s, sizeof(struct lib9p_s)) || ({ 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 = 123; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 152; (((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_Tstat(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Tswrite(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -622,58 +587,91 @@ LM_FLATTEN static bool validate_Tstat(struct _validate_ctx *ctx) { || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; })) || validate_tag(ctx) - || validate_fid(ctx) + || validate_4(ctx) + || validate_2(ctx) + || _validate_list(ctx, decode_u16le(&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 = 124; (((uint8_t)typ) != 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); }) ; } -LM_FLATTEN static bool validate_Rstat(struct _validate_ctx *ctx) { +#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_qid(struct _validate_ctx *ctx) { + return false + || validate_qt(ctx) + || validate_4(ctx) + || validate_8(ctx) + ; +} + +LM_FLATTEN static bool validate_Topen(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; - uint16_t nstat; uint32_t _size_offset; - uint32_t _stat_offset; return false || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; })) || validate_tag(ctx) - || (validate_2(ctx) || ({ nstat = decode_u16le(&ctx->net_bytes[ctx->net_offset-2]); false; })) - || ({ _stat_offset = ctx->net_offset; validate_stat(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 = 125; (((uint8_t)typ) != 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); }) - || ({ uint16_t exp = ctx->net_offset - _stat_offset; (((uint16_t)nstat) != exp) && - lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "nstat value is wrong (actual:%"PRIu16" != correct:%"PRIu16")", (uint16_t)nstat, exp); }) ; } -LM_FLATTEN static bool validate_Twstat(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Tcreate(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; - uint16_t nstat; uint32_t _size_offset; - uint32_t _stat_offset; return false || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; })) || validate_tag(ctx) || validate_fid(ctx) - || (validate_2(ctx) || ({ nstat = decode_u16le(&ctx->net_bytes[ctx->net_offset-2]); false; })) - || ({ _stat_offset = ctx->net_offset; validate_stat(ctx); }) + || validate_s(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 = 126; (((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); }) - || ({ uint16_t exp = ctx->net_offset - _stat_offset; (((uint16_t)nstat) != exp) && - lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "nstat value is wrong (actual:%"PRIu16" != correct:%"PRIu16")", (uint16_t)nstat, exp); }) ; } -LM_FLATTEN static bool validate_Rwstat(struct _validate_ctx *ctx) { +LM_ALWAYS_INLINE static bool validate_stat(struct _validate_ctx *ctx) { + uint16_t stat_size; + uint32_t _kern_type_offset; + return false + || (validate_2(ctx) || ({ stat_size = decode_u16le(&ctx->net_bytes[ctx->net_offset-2]); false; })) + || ({ _kern_type_offset = ctx->net_offset; validate_2(ctx); }) + || validate_4(ctx) + || validate_qid(ctx) + || validate_dm(ctx) + || validate_4(ctx) + || validate_4(ctx) + || validate_8(ctx) + || validate_s(ctx) + || validate_s(ctx) + || validate_s(ctx) + || validate_s(ctx) +#if CONFIG_9P_ENABLE_9P2000_u + || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && validate_s(ctx) ) + || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && validate_4(ctx) ) + || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && validate_4(ctx) ) + || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && validate_4(ctx) ) +#endif /* CONFIG_9P_ENABLE_9P2000_u */ + || ({ uint16_t exp = ctx->net_offset - _kern_type_offset; (((uint16_t)stat_size) != exp) && + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "stat_size value is wrong (actual:%"PRIu16" != correct:%"PRIu16")", (uint16_t)stat_size, exp); }) + ; +} + +LM_FLATTEN static bool validate_Rauth(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -681,16 +679,15 @@ LM_FLATTEN static bool validate_Rwstat(struct _validate_ctx *ctx) { || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; })) || validate_tag(ctx) + || validate_qid(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 = 127; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 103; (((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_u */ -#if CONFIG_9P_ENABLE_9P2000_e -LM_FLATTEN static bool validate_Tsession(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Rattach(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -698,30 +695,35 @@ LM_FLATTEN static bool validate_Tsession(struct _validate_ctx *ctx) { || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; })) || validate_tag(ctx) - || validate_8(ctx) + || validate_qid(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 = 150; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 105; (((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_Rsession(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Rwalk(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; + uint16_t nwqid; uint32_t _size_offset; return false || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; })) || validate_tag(ctx) + || (validate_2(ctx) || ({ nwqid = decode_u16le(&ctx->net_bytes[ctx->net_offset-2]); false; })) + || _validate_list(ctx, decode_u16le(&ctx->net_bytes[ctx->net_offset-2]), validate_qid, sizeof(struct lib9p_qid)) || ({ 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 = 151; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 111; (((uint8_t)typ) != exp) && lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); }) + || ({ uint16_t max = 16; (((uint16_t)nwqid) > max) && + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "nwqid value is too large (%"PRIu16" > %"PRIu16")", nwqid, max); }) ; } -LM_FLATTEN static bool validate_Tsread(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Ropen(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -729,17 +731,16 @@ LM_FLATTEN static bool validate_Tsread(struct _validate_ctx *ctx) { || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; })) || validate_tag(ctx) + || validate_qid(ctx) || validate_4(ctx) - || validate_2(ctx) - || _validate_list(ctx, decode_u16le(&ctx->net_bytes[ctx->net_offset-2]), validate_s, sizeof(struct lib9p_s)) || ({ 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 = 152; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 113; (((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_Rsread(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Rcreate(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -747,49 +748,58 @@ LM_FLATTEN static bool validate_Rsread(struct _validate_ctx *ctx) { || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; })) || validate_tag(ctx) - || validate_d(ctx) + || validate_qid(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 = 153; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 115; (((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) { +LM_FLATTEN static bool validate_Rstat(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; + uint16_t nstat; uint32_t _size_offset; + uint32_t _stat_offset; return false || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; })) || validate_tag(ctx) - || validate_4(ctx) - || validate_2(ctx) - || _validate_list(ctx, decode_u16le(&ctx->net_bytes[ctx->net_offset-2]), validate_s, sizeof(struct lib9p_s)) - || validate_d(ctx) + || (validate_2(ctx) || ({ nstat = decode_u16le(&ctx->net_bytes[ctx->net_offset-2]); false; })) + || ({ _stat_offset = ctx->net_offset; validate_stat(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) && + || ({ uint8_t exp = 125; (((uint8_t)typ) != exp) && lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); }) + || ({ uint16_t exp = ctx->net_offset - _stat_offset; (((uint16_t)nstat) != exp) && + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "nstat value is wrong (actual:%"PRIu16" != correct:%"PRIu16")", (uint16_t)nstat, exp); }) ; } -LM_FLATTEN static bool validate_Rswrite(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Twstat(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; + uint16_t nstat; uint32_t _size_offset; + uint32_t _stat_offset; return false || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; })) || validate_tag(ctx) - || validate_4(ctx) + || validate_fid(ctx) + || (validate_2(ctx) || ({ nstat = decode_u16le(&ctx->net_bytes[ctx->net_offset-2]); false; })) + || ({ _stat_offset = ctx->net_offset; validate_stat(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 = 155; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 126; (((uint8_t)typ) != exp) && lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); }) + || ({ uint16_t exp = ctx->net_offset - _stat_offset; (((uint16_t)nstat) != exp) && + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "nstat value is wrong (actual:%"PRIu16" != correct:%"PRIu16")", (uint16_t)nstat, exp); }) ; } -#endif /* CONFIG_9P_ENABLE_9P2000_e */ +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */ /* unmarshal_* ****************************************************************/ @@ -850,350 +860,360 @@ LM_ALWAYS_INLINE static void unmarshal_qt(struct _unmarshal_ctx *ctx, lib9p_qt_t unmarshal_1(ctx, (uint8_t *)out); } -LM_ALWAYS_INLINE static void unmarshal_qid(struct _unmarshal_ctx *ctx, struct lib9p_qid *out) { - memset(out, 0, sizeof(*out)); - unmarshal_qt(ctx, &out->type); - unmarshal_4(ctx, &out->vers); - unmarshal_8(ctx, &out->path); -} - -LM_ALWAYS_INLINE static void unmarshal_stat(struct _unmarshal_ctx *ctx, struct lib9p_stat *out) { - memset(out, 0, sizeof(*out)); - ctx->net_offset += 2; - unmarshal_2(ctx, &out->kern_type); - unmarshal_4(ctx, &out->kern_dev); - unmarshal_qid(ctx, &out->file_qid); - unmarshal_dm(ctx, &out->file_mode); - unmarshal_4(ctx, &out->file_atime); - unmarshal_4(ctx, &out->file_mtime); - unmarshal_8(ctx, &out->file_size); - unmarshal_s(ctx, &out->file_name); - unmarshal_s(ctx, &out->file_owner_uid); - unmarshal_s(ctx, &out->file_owner_gid); - unmarshal_s(ctx, &out->file_last_modified_uid); -#if CONFIG_9P_ENABLE_9P2000_u - if ( (ctx->ctx->version==LIB9P_VER_9P2000_u) ) unmarshal_s(ctx, &out->file_extension); - if ( (ctx->ctx->version==LIB9P_VER_9P2000_u) ) unmarshal_4(ctx, &out->file_owner_n_uid); - if ( (ctx->ctx->version==LIB9P_VER_9P2000_u) ) unmarshal_4(ctx, &out->file_owner_n_gid); - if ( (ctx->ctx->version==LIB9P_VER_9P2000_u) ) unmarshal_4(ctx, &out->file_last_modified_n_uid); -#endif /* CONFIG_9P_ENABLE_9P2000_u */ -} - LM_ALWAYS_INLINE static void unmarshal_o(struct _unmarshal_ctx *ctx, lib9p_o_t *out) { unmarshal_1(ctx, (uint8_t *)out); } -LM_FLATTEN static void unmarshal_Tversion(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tversion *out) { +LM_FLATTEN static void unmarshal_Tflush(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tflush *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; unmarshal_tag(ctx, &out->tag); - unmarshal_4(ctx, &out->max_msg_size); - unmarshal_s(ctx, &out->version); + unmarshal_2(ctx, &out->oldtag); } -LM_FLATTEN static void unmarshal_Rversion(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rversion *out) { +LM_FLATTEN static void unmarshal_Rflush(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rflush *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; unmarshal_tag(ctx, &out->tag); - unmarshal_4(ctx, &out->max_msg_size); - unmarshal_s(ctx, &out->version); } -LM_FLATTEN static void unmarshal_Tauth(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tauth *out) { +LM_FLATTEN static void unmarshal_Rwrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rwrite *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; unmarshal_tag(ctx, &out->tag); - unmarshal_fid(ctx, &out->afid); - unmarshal_s(ctx, &out->uname); - unmarshal_s(ctx, &out->aname); -#if CONFIG_9P_ENABLE_9P2000_u - if ( (ctx->ctx->version==LIB9P_VER_9P2000_u) ) unmarshal_4(ctx, &out->n_uname); -#endif /* CONFIG_9P_ENABLE_9P2000_u */ + unmarshal_4(ctx, &out->count); } -LM_FLATTEN static void unmarshal_Rauth(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rauth *out) { +LM_FLATTEN static void unmarshal_Rclunk(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rclunk *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; unmarshal_tag(ctx, &out->tag); - unmarshal_qid(ctx, &out->aqid); } -LM_FLATTEN static void unmarshal_Tattach(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tattach *out) { +LM_FLATTEN static void unmarshal_Rremove(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rremove *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_fid(ctx, &out->afid); - unmarshal_s(ctx, &out->uname); - unmarshal_s(ctx, &out->aname); -#if CONFIG_9P_ENABLE_9P2000_u - if ( (ctx->ctx->version==LIB9P_VER_9P2000_u) ) unmarshal_4(ctx, &out->n_uname); -#endif /* CONFIG_9P_ENABLE_9P2000_u */ } -LM_FLATTEN static void unmarshal_Rattach(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rattach *out) { +LM_FLATTEN static void unmarshal_Rwstat(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rwstat *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; unmarshal_tag(ctx, &out->tag); - unmarshal_qid(ctx, &out->qid); } -LM_FLATTEN static void unmarshal_Rerror(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rerror *out) { +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_9P2000_e +LM_FLATTEN static void unmarshal_Tsession(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tsession *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 ( (ctx->ctx->version==LIB9P_VER_9P2000_u) ) unmarshal_4(ctx, &out->errno); -#endif /* CONFIG_9P_ENABLE_9P2000_u */ + unmarshal_8(ctx, &out->key); } -LM_FLATTEN static void unmarshal_Tflush(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tflush *out) { +LM_FLATTEN static void unmarshal_Rsession(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rsession *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; unmarshal_tag(ctx, &out->tag); - unmarshal_2(ctx, &out->oldtag); } -LM_FLATTEN static void unmarshal_Rflush(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rflush *out) { +LM_FLATTEN static void unmarshal_Rswrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rswrite *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; unmarshal_tag(ctx, &out->tag); + unmarshal_4(ctx, &out->count); } -LM_FLATTEN static void unmarshal_Twalk(struct _unmarshal_ctx *ctx, struct lib9p_msg_Twalk *out) { +#endif /* CONFIG_9P_ENABLE_9P2000_e */ +#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u +LM_FLATTEN static void unmarshal_Tread(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tread *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_fid(ctx, &out->newfid); - 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_8(ctx, &out->offset); + unmarshal_4(ctx, &out->count); } -LM_FLATTEN static void unmarshal_Rwalk(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rwalk *out) { +LM_FLATTEN static void unmarshal_Tclunk(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tclunk *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; unmarshal_tag(ctx, &out->tag); - unmarshal_2(ctx, &out->nwqid); - out->wqid = ctx->extra; - ctx->extra += sizeof(out->wqid[0]) * out->nwqid; - for (typeof(out->nwqid) i = 0; i < out->nwqid; i++) - unmarshal_qid(ctx, &out->wqid[i]); + unmarshal_fid(ctx, &out->fid); } -LM_FLATTEN static void unmarshal_Topen(struct _unmarshal_ctx *ctx, struct lib9p_msg_Topen *out) { +LM_FLATTEN static void unmarshal_Tremove(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tremove *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); } -LM_FLATTEN static void unmarshal_Ropen(struct _unmarshal_ctx *ctx, struct lib9p_msg_Ropen *out) { +LM_FLATTEN static void unmarshal_Tstat(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tstat *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; unmarshal_tag(ctx, &out->tag); - unmarshal_qid(ctx, &out->qid); - unmarshal_4(ctx, &out->iounit); + unmarshal_fid(ctx, &out->fid); } -LM_FLATTEN static void unmarshal_Tcreate(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tcreate *out) { +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_fid(ctx, &out->fid); - unmarshal_s(ctx, &out->name); - unmarshal_dm(ctx, &out->perm); - unmarshal_o(ctx, &out->mode); + unmarshal_d(ctx, &out->data); } -LM_FLATTEN static void unmarshal_Rcreate(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rcreate *out) { +LM_FLATTEN static void unmarshal_Twrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Twrite *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; unmarshal_tag(ctx, &out->tag); - unmarshal_qid(ctx, &out->qid); - unmarshal_4(ctx, &out->iounit); + unmarshal_fid(ctx, &out->fid); + unmarshal_8(ctx, &out->offset); + unmarshal_d(ctx, &out->data); } -LM_FLATTEN static void unmarshal_Tread(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tread *out) { +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */ +#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_fid(ctx, &out->fid); - unmarshal_8(ctx, &out->offset); - unmarshal_4(ctx, &out->count); + unmarshal_d(ctx, &out->data); } -LM_FLATTEN static void unmarshal_Rread(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rread *out) { +#endif /* CONFIG_9P_ENABLE_9P2000_e */ +#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u +LM_FLATTEN static void unmarshal_Tversion(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tversion *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_4(ctx, &out->max_msg_size); + unmarshal_s(ctx, &out->version); } -LM_FLATTEN static void unmarshal_Twrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Twrite *out) { +LM_FLATTEN static void unmarshal_Rversion(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rversion *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_8(ctx, &out->offset); - unmarshal_d(ctx, &out->data); + unmarshal_4(ctx, &out->max_msg_size); + unmarshal_s(ctx, &out->version); } -LM_FLATTEN static void unmarshal_Rwrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rwrite *out) { +LM_FLATTEN static void unmarshal_Tauth(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tauth *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; unmarshal_tag(ctx, &out->tag); - unmarshal_4(ctx, &out->count); + unmarshal_fid(ctx, &out->afid); + unmarshal_s(ctx, &out->uname); + unmarshal_s(ctx, &out->aname); +#if CONFIG_9P_ENABLE_9P2000_u + if ( (ctx->ctx->version==LIB9P_VER_9P2000_u) ) unmarshal_4(ctx, &out->n_uname); +#endif /* CONFIG_9P_ENABLE_9P2000_u */ } -LM_FLATTEN static void unmarshal_Tclunk(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tclunk *out) { +LM_FLATTEN static void unmarshal_Tattach(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tattach *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_fid(ctx, &out->afid); + unmarshal_s(ctx, &out->uname); + unmarshal_s(ctx, &out->aname); +#if CONFIG_9P_ENABLE_9P2000_u + if ( (ctx->ctx->version==LIB9P_VER_9P2000_u) ) unmarshal_4(ctx, &out->n_uname); +#endif /* CONFIG_9P_ENABLE_9P2000_u */ } -LM_FLATTEN static void unmarshal_Rclunk(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rclunk *out) { +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 ( (ctx->ctx->version==LIB9P_VER_9P2000_u) ) unmarshal_4(ctx, &out->errno); +#endif /* CONFIG_9P_ENABLE_9P2000_u */ } -LM_FLATTEN static void unmarshal_Tremove(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tremove *out) { +LM_FLATTEN static void unmarshal_Twalk(struct _unmarshal_ctx *ctx, struct lib9p_msg_Twalk *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_fid(ctx, &out->newfid); + 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]); } -LM_FLATTEN static void unmarshal_Rremove(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rremove *out) { +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_9P2000_e +LM_FLATTEN static void unmarshal_Tsread(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tsread *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]); } -LM_FLATTEN static void unmarshal_Tstat(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tstat *out) { +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_fid(ctx, &out->fid); + 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); } -LM_FLATTEN static void unmarshal_Rstat(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rstat *out) { +#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_qid(struct _unmarshal_ctx *ctx, struct lib9p_qid *out) { + memset(out, 0, sizeof(*out)); + unmarshal_qt(ctx, &out->type); + unmarshal_4(ctx, &out->vers); + unmarshal_8(ctx, &out->path); +} + +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); - ctx->net_offset += 2; - unmarshal_stat(ctx, &out->stat); + unmarshal_fid(ctx, &out->fid); + unmarshal_o(ctx, &out->mode); } -LM_FLATTEN static void unmarshal_Twstat(struct _unmarshal_ctx *ctx, struct lib9p_msg_Twstat *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->fid); + unmarshal_s(ctx, &out->name); + unmarshal_dm(ctx, &out->perm); + unmarshal_o(ctx, &out->mode); +} + +LM_ALWAYS_INLINE static void unmarshal_stat(struct _unmarshal_ctx *ctx, struct lib9p_stat *out) { + memset(out, 0, sizeof(*out)); ctx->net_offset += 2; - unmarshal_stat(ctx, &out->stat); + unmarshal_2(ctx, &out->kern_type); + unmarshal_4(ctx, &out->kern_dev); + unmarshal_qid(ctx, &out->file_qid); + unmarshal_dm(ctx, &out->file_mode); + unmarshal_4(ctx, &out->file_atime); + unmarshal_4(ctx, &out->file_mtime); + unmarshal_8(ctx, &out->file_size); + unmarshal_s(ctx, &out->file_name); + unmarshal_s(ctx, &out->file_owner_uid); + unmarshal_s(ctx, &out->file_owner_gid); + unmarshal_s(ctx, &out->file_last_modified_uid); +#if CONFIG_9P_ENABLE_9P2000_u + if ( (ctx->ctx->version==LIB9P_VER_9P2000_u) ) unmarshal_s(ctx, &out->file_extension); + if ( (ctx->ctx->version==LIB9P_VER_9P2000_u) ) unmarshal_4(ctx, &out->file_owner_n_uid); + if ( (ctx->ctx->version==LIB9P_VER_9P2000_u) ) unmarshal_4(ctx, &out->file_owner_n_gid); + if ( (ctx->ctx->version==LIB9P_VER_9P2000_u) ) unmarshal_4(ctx, &out->file_last_modified_n_uid); +#endif /* CONFIG_9P_ENABLE_9P2000_u */ } -LM_FLATTEN static void unmarshal_Rwstat(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rwstat *out) { +LM_FLATTEN static void unmarshal_Rauth(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rauth *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; unmarshal_tag(ctx, &out->tag); + unmarshal_qid(ctx, &out->aqid); } -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000_e -LM_FLATTEN static void unmarshal_Tsession(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tsession *out) { +LM_FLATTEN static void unmarshal_Rattach(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rattach *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; unmarshal_tag(ctx, &out->tag); - unmarshal_8(ctx, &out->key); + unmarshal_qid(ctx, &out->qid); } -LM_FLATTEN static void unmarshal_Rsession(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rsession *out) { +LM_FLATTEN static void unmarshal_Rwalk(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rwalk *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; unmarshal_tag(ctx, &out->tag); + unmarshal_2(ctx, &out->nwqid); + out->wqid = ctx->extra; + ctx->extra += sizeof(out->wqid[0]) * out->nwqid; + for (typeof(out->nwqid) i = 0; i < out->nwqid; i++) + unmarshal_qid(ctx, &out->wqid[i]); } -LM_FLATTEN static void unmarshal_Tsread(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tsread *out) { +LM_FLATTEN static void unmarshal_Ropen(struct _unmarshal_ctx *ctx, struct lib9p_msg_Ropen *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_qid(ctx, &out->qid); + unmarshal_4(ctx, &out->iounit); } -LM_FLATTEN static void unmarshal_Rsread(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rsread *out) { +LM_FLATTEN static void unmarshal_Rcreate(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rcreate *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_qid(ctx, &out->qid); + unmarshal_4(ctx, &out->iounit); } -LM_FLATTEN static void unmarshal_Tswrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tswrite *out) { +LM_FLATTEN static void unmarshal_Rstat(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rstat *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); + ctx->net_offset += 2; + unmarshal_stat(ctx, &out->stat); } -LM_FLATTEN static void unmarshal_Rswrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rswrite *out) { +LM_FLATTEN static void unmarshal_Twstat(struct _unmarshal_ctx *ctx, struct lib9p_msg_Twstat *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; unmarshal_tag(ctx, &out->tag); - unmarshal_4(ctx, &out->count); + unmarshal_fid(ctx, &out->fid); + ctx->net_offset += 2; + unmarshal_stat(ctx, &out->stat); } -#endif /* CONFIG_9P_ENABLE_9P2000_e */ +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */ /* marshal_* ******************************************************************/ @@ -1276,178 +1296,128 @@ LM_ALWAYS_INLINE static bool marshal_qt(struct _marshal_ctx *ctx, lib9p_qt_t *va return marshal_1(ctx, (uint8_t *)&masked_val); } -LM_ALWAYS_INLINE static bool marshal_qid(struct _marshal_ctx *ctx, struct lib9p_qid *val) { - return false - || marshal_qt(ctx, &val->type) - || marshal_4(ctx, &val->vers) - || marshal_8(ctx, &val->path) - ; -} - -LM_ALWAYS_INLINE static bool marshal_stat(struct _marshal_ctx *ctx, struct lib9p_stat *val) { - uint32_t _stat_size_offset; - uint32_t _kern_type_offset; - return false - || ({ _stat_size_offset = ctx->net_offset; ({ ctx->net_offset += 2; false; }); }) - || ({ _kern_type_offset = ctx->net_offset; marshal_2(ctx, &val->kern_type); }) - || marshal_4(ctx, &val->kern_dev) - || marshal_qid(ctx, &val->file_qid) - || marshal_dm(ctx, &val->file_mode) - || marshal_4(ctx, &val->file_atime) - || marshal_4(ctx, &val->file_mtime) - || marshal_8(ctx, &val->file_size) - || marshal_s(ctx, &val->file_name) - || marshal_s(ctx, &val->file_owner_uid) - || marshal_s(ctx, &val->file_owner_gid) - || marshal_s(ctx, &val->file_last_modified_uid) -#if CONFIG_9P_ENABLE_9P2000_u - || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_s(ctx, &val->file_extension) ) - || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_4(ctx, &val->file_owner_n_uid) ) - || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_4(ctx, &val->file_owner_n_gid) ) - || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_4(ctx, &val->file_last_modified_n_uid) ) -#endif /* CONFIG_9P_ENABLE_9P2000_u */ - || ({ encode_u16le(ctx->net_offset - _kern_type_offset, &ctx->net_bytes[_stat_size_offset]); false; }) - ; -} - LM_ALWAYS_INLINE static bool marshal_o(struct _marshal_ctx *ctx, lib9p_o_t *val) { lib9p_o_t masked_val = *val & o_masks[ctx->ctx->version]; return marshal_1(ctx, (uint8_t *)&masked_val); } -LM_FLATTEN static bool marshal_Tversion(struct _marshal_ctx *ctx, struct lib9p_msg_Tversion *val) { +LM_FLATTEN static bool marshal_Tflush(struct _marshal_ctx *ctx, struct lib9p_msg_Tflush *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->max_msg_size) - || marshal_s(ctx, &val->version) + || marshal_2(ctx, &val->oldtag) || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; }) - || ({ encode_u8le(100, &ctx->net_bytes[_typ_offset]); false; }) + || ({ encode_u8le(108, &ctx->net_bytes[_typ_offset]); false; }) ; } -LM_FLATTEN static bool marshal_Rversion(struct _marshal_ctx *ctx, struct lib9p_msg_Rversion *val) { +LM_FLATTEN static bool marshal_Rflush(struct _marshal_ctx *ctx, struct lib9p_msg_Rflush *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->max_msg_size) - || marshal_s(ctx, &val->version) || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; }) - || ({ encode_u8le(101, &ctx->net_bytes[_typ_offset]); false; }) + || ({ encode_u8le(109, &ctx->net_bytes[_typ_offset]); false; }) ; } -LM_FLATTEN static bool marshal_Tauth(struct _marshal_ctx *ctx, struct lib9p_msg_Tauth *val) { +LM_FLATTEN static bool marshal_Rwrite(struct _marshal_ctx *ctx, struct lib9p_msg_Rwrite *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_fid(ctx, &val->afid) - || marshal_s(ctx, &val->uname) - || marshal_s(ctx, &val->aname) -#if CONFIG_9P_ENABLE_9P2000_u - || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_4(ctx, &val->n_uname) ) -#endif /* CONFIG_9P_ENABLE_9P2000_u */ + || marshal_4(ctx, &val->count) || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; }) - || ({ encode_u8le(102, &ctx->net_bytes[_typ_offset]); false; }) + || ({ encode_u8le(119, &ctx->net_bytes[_typ_offset]); false; }) ; } -LM_FLATTEN static bool marshal_Rauth(struct _marshal_ctx *ctx, struct lib9p_msg_Rauth *val) { +LM_FLATTEN static bool marshal_Rclunk(struct _marshal_ctx *ctx, struct lib9p_msg_Rclunk *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_qid(ctx, &val->aqid) || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; }) - || ({ encode_u8le(103, &ctx->net_bytes[_typ_offset]); false; }) + || ({ encode_u8le(121, &ctx->net_bytes[_typ_offset]); false; }) ; } -LM_FLATTEN static bool marshal_Tattach(struct _marshal_ctx *ctx, struct lib9p_msg_Tattach *val) { +LM_FLATTEN static bool marshal_Rremove(struct _marshal_ctx *ctx, struct lib9p_msg_Rremove *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_fid(ctx, &val->fid) - || marshal_fid(ctx, &val->afid) - || marshal_s(ctx, &val->uname) - || marshal_s(ctx, &val->aname) -#if CONFIG_9P_ENABLE_9P2000_u - || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_4(ctx, &val->n_uname) ) -#endif /* CONFIG_9P_ENABLE_9P2000_u */ || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; }) - || ({ encode_u8le(104, &ctx->net_bytes[_typ_offset]); false; }) + || ({ encode_u8le(123, &ctx->net_bytes[_typ_offset]); false; }) ; } -LM_FLATTEN static bool marshal_Rattach(struct _marshal_ctx *ctx, struct lib9p_msg_Rattach *val) { +LM_FLATTEN static bool marshal_Rwstat(struct _marshal_ctx *ctx, struct lib9p_msg_Rwstat *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_qid(ctx, &val->qid) || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; }) - || ({ encode_u8le(105, &ctx->net_bytes[_typ_offset]); false; }) + || ({ encode_u8le(127, &ctx->net_bytes[_typ_offset]); false; }) ; } -LM_FLATTEN static bool marshal_Rerror(struct _marshal_ctx *ctx, struct lib9p_msg_Rerror *val) { +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_9P2000_e +LM_FLATTEN static bool marshal_Tsession(struct _marshal_ctx *ctx, struct lib9p_msg_Tsession *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_s(ctx, &val->ename) -#if CONFIG_9P_ENABLE_9P2000_u - || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_4(ctx, &val->errno) ) -#endif /* CONFIG_9P_ENABLE_9P2000_u */ + || marshal_8(ctx, &val->key) || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; }) - || ({ encode_u8le(107, &ctx->net_bytes[_typ_offset]); false; }) + || ({ encode_u8le(150, &ctx->net_bytes[_typ_offset]); false; }) ; } -LM_FLATTEN static bool marshal_Tflush(struct _marshal_ctx *ctx, struct lib9p_msg_Tflush *val) { +LM_FLATTEN static bool marshal_Rsession(struct _marshal_ctx *ctx, struct lib9p_msg_Rsession *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_2(ctx, &val->oldtag) || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; }) - || ({ encode_u8le(108, &ctx->net_bytes[_typ_offset]); false; }) + || ({ encode_u8le(151, &ctx->net_bytes[_typ_offset]); false; }) ; } -LM_FLATTEN static bool marshal_Rflush(struct _marshal_ctx *ctx, struct lib9p_msg_Rflush *val) { +LM_FLATTEN static bool marshal_Rswrite(struct _marshal_ctx *ctx, struct lib9p_msg_Rswrite *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) || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; }) - || ({ encode_u8le(109, &ctx->net_bytes[_typ_offset]); false; }) + || ({ encode_u8le(155, &ctx->net_bytes[_typ_offset]); false; }) ; } -LM_FLATTEN static bool marshal_Twalk(struct _marshal_ctx *ctx, struct lib9p_msg_Twalk *val) { +#endif /* CONFIG_9P_ENABLE_9P2000_e */ +#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u +LM_FLATTEN static bool marshal_Tread(struct _marshal_ctx *ctx, struct lib9p_msg_Tread *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1455,35 +1425,27 @@ LM_FLATTEN static bool marshal_Twalk(struct _marshal_ctx *ctx, struct lib9p_msg_ || ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); }) || marshal_tag(ctx, &val->tag) || marshal_fid(ctx, &val->fid) - || marshal_fid(ctx, &val->newfid) - || 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_8(ctx, &val->offset) + || marshal_4(ctx, &val->count) || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; }) - || ({ encode_u8le(110, &ctx->net_bytes[_typ_offset]); false; }) + || ({ encode_u8le(116, &ctx->net_bytes[_typ_offset]); false; }) ; } -LM_FLATTEN static bool marshal_Rwalk(struct _marshal_ctx *ctx, struct lib9p_msg_Rwalk *val) { +LM_FLATTEN static bool marshal_Tclunk(struct _marshal_ctx *ctx, struct lib9p_msg_Tclunk *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_2(ctx, &val->nwqid) - || ({ bool err = false; - for (typeof(val->nwqid) i = 0; i < val->nwqid && !err; i++) - err = marshal_qid(ctx, &val->wqid[i]); - err; }) + || marshal_fid(ctx, &val->fid) || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; }) - || ({ encode_u8le(111, &ctx->net_bytes[_typ_offset]); false; }) + || ({ encode_u8le(120, &ctx->net_bytes[_typ_offset]); false; }) ; } -LM_FLATTEN static bool marshal_Topen(struct _marshal_ctx *ctx, struct lib9p_msg_Topen *val) { +LM_FLATTEN static bool marshal_Tremove(struct _marshal_ctx *ctx, struct lib9p_msg_Tremove *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1491,113 +1453,116 @@ LM_FLATTEN static bool marshal_Topen(struct _marshal_ctx *ctx, struct lib9p_msg_ || ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); }) || marshal_tag(ctx, &val->tag) || marshal_fid(ctx, &val->fid) - || marshal_o(ctx, &val->mode) || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; }) - || ({ encode_u8le(112, &ctx->net_bytes[_typ_offset]); false; }) + || ({ encode_u8le(122, &ctx->net_bytes[_typ_offset]); false; }) ; } -LM_FLATTEN static bool marshal_Ropen(struct _marshal_ctx *ctx, struct lib9p_msg_Ropen *val) { +LM_FLATTEN static bool marshal_Tstat(struct _marshal_ctx *ctx, struct lib9p_msg_Tstat *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_qid(ctx, &val->qid) - || marshal_4(ctx, &val->iounit) + || marshal_fid(ctx, &val->fid) || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; }) - || ({ encode_u8le(113, &ctx->net_bytes[_typ_offset]); false; }) + || ({ encode_u8le(124, &ctx->net_bytes[_typ_offset]); false; }) ; } -LM_FLATTEN static bool marshal_Tcreate(struct _marshal_ctx *ctx, struct lib9p_msg_Tcreate *val) { +LM_FLATTEN static bool marshal_Rread(struct _marshal_ctx *ctx, struct lib9p_msg_Rread *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_fid(ctx, &val->fid) - || marshal_s(ctx, &val->name) - || marshal_dm(ctx, &val->perm) - || marshal_o(ctx, &val->mode) + || marshal_d(ctx, &val->data) || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; }) - || ({ encode_u8le(114, &ctx->net_bytes[_typ_offset]); false; }) + || ({ encode_u8le(117, &ctx->net_bytes[_typ_offset]); false; }) ; } -LM_FLATTEN static bool marshal_Rcreate(struct _marshal_ctx *ctx, struct lib9p_msg_Rcreate *val) { +LM_FLATTEN static bool marshal_Twrite(struct _marshal_ctx *ctx, struct lib9p_msg_Twrite *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_qid(ctx, &val->qid) - || marshal_4(ctx, &val->iounit) + || marshal_fid(ctx, &val->fid) + || marshal_8(ctx, &val->offset) + || marshal_d(ctx, &val->data) || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; }) - || ({ encode_u8le(115, &ctx->net_bytes[_typ_offset]); false; }) + || ({ encode_u8le(118, &ctx->net_bytes[_typ_offset]); false; }) ; } -LM_FLATTEN static bool marshal_Tread(struct _marshal_ctx *ctx, struct lib9p_msg_Tread *val) { +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */ +#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_fid(ctx, &val->fid) - || marshal_8(ctx, &val->offset) - || marshal_4(ctx, &val->count) + || marshal_d(ctx, &val->data) || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; }) - || ({ encode_u8le(116, &ctx->net_bytes[_typ_offset]); false; }) + || ({ encode_u8le(153, &ctx->net_bytes[_typ_offset]); false; }) ; } -LM_FLATTEN static bool marshal_Rread(struct _marshal_ctx *ctx, struct lib9p_msg_Rread *val) { +#endif /* CONFIG_9P_ENABLE_9P2000_e */ +#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u +LM_FLATTEN static bool marshal_Tversion(struct _marshal_ctx *ctx, struct lib9p_msg_Tversion *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) + || marshal_4(ctx, &val->max_msg_size) + || marshal_s(ctx, &val->version) || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; }) - || ({ encode_u8le(117, &ctx->net_bytes[_typ_offset]); false; }) + || ({ encode_u8le(100, &ctx->net_bytes[_typ_offset]); false; }) ; } -LM_FLATTEN static bool marshal_Twrite(struct _marshal_ctx *ctx, struct lib9p_msg_Twrite *val) { +LM_FLATTEN static bool marshal_Rversion(struct _marshal_ctx *ctx, struct lib9p_msg_Rversion *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_fid(ctx, &val->fid) - || marshal_8(ctx, &val->offset) - || marshal_d(ctx, &val->data) + || marshal_4(ctx, &val->max_msg_size) + || marshal_s(ctx, &val->version) || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; }) - || ({ encode_u8le(118, &ctx->net_bytes[_typ_offset]); false; }) + || ({ encode_u8le(101, &ctx->net_bytes[_typ_offset]); false; }) ; } -LM_FLATTEN static bool marshal_Rwrite(struct _marshal_ctx *ctx, struct lib9p_msg_Rwrite *val) { +LM_FLATTEN static bool marshal_Tauth(struct _marshal_ctx *ctx, struct lib9p_msg_Tauth *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) + || marshal_fid(ctx, &val->afid) + || marshal_s(ctx, &val->uname) + || marshal_s(ctx, &val->aname) +#if CONFIG_9P_ENABLE_9P2000_u + || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_4(ctx, &val->n_uname) ) +#endif /* CONFIG_9P_ENABLE_9P2000_u */ || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; }) - || ({ encode_u8le(119, &ctx->net_bytes[_typ_offset]); false; }) + || ({ encode_u8le(102, &ctx->net_bytes[_typ_offset]); false; }) ; } -LM_FLATTEN static bool marshal_Tclunk(struct _marshal_ctx *ctx, struct lib9p_msg_Tclunk *val) { +LM_FLATTEN static bool marshal_Tattach(struct _marshal_ctx *ctx, struct lib9p_msg_Tattach *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1605,24 +1570,34 @@ LM_FLATTEN static bool marshal_Tclunk(struct _marshal_ctx *ctx, struct lib9p_msg || ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); }) || marshal_tag(ctx, &val->tag) || marshal_fid(ctx, &val->fid) + || marshal_fid(ctx, &val->afid) + || marshal_s(ctx, &val->uname) + || marshal_s(ctx, &val->aname) +#if CONFIG_9P_ENABLE_9P2000_u + || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_4(ctx, &val->n_uname) ) +#endif /* CONFIG_9P_ENABLE_9P2000_u */ || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; }) - || ({ encode_u8le(120, &ctx->net_bytes[_typ_offset]); false; }) + || ({ encode_u8le(104, &ctx->net_bytes[_typ_offset]); false; }) ; } -LM_FLATTEN static bool marshal_Rclunk(struct _marshal_ctx *ctx, struct lib9p_msg_Rclunk *val) { +LM_FLATTEN static bool marshal_Rerror(struct _marshal_ctx *ctx, struct lib9p_msg_Rerror *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_s(ctx, &val->ename) +#if CONFIG_9P_ENABLE_9P2000_u + || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_4(ctx, &val->errno) ) +#endif /* CONFIG_9P_ENABLE_9P2000_u */ || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; }) - || ({ encode_u8le(121, &ctx->net_bytes[_typ_offset]); false; }) + || ({ encode_u8le(107, &ctx->net_bytes[_typ_offset]); false; }) ; } -LM_FLATTEN static bool marshal_Tremove(struct _marshal_ctx *ctx, struct lib9p_msg_Tremove *val) { +LM_FLATTEN static bool marshal_Twalk(struct _marshal_ctx *ctx, struct lib9p_msg_Twalk *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1630,173 +1605,228 @@ LM_FLATTEN static bool marshal_Tremove(struct _marshal_ctx *ctx, struct lib9p_ms || ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); }) || marshal_tag(ctx, &val->tag) || marshal_fid(ctx, &val->fid) + || marshal_fid(ctx, &val->newfid) + || 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; }) || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; }) - || ({ encode_u8le(122, &ctx->net_bytes[_typ_offset]); false; }) + || ({ encode_u8le(110, &ctx->net_bytes[_typ_offset]); false; }) ; } -LM_FLATTEN static bool marshal_Rremove(struct _marshal_ctx *ctx, struct lib9p_msg_Rremove *val) { +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_9P2000_e +LM_FLATTEN static bool marshal_Tsread(struct _marshal_ctx *ctx, struct lib9p_msg_Tsread *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; }) || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; }) - || ({ encode_u8le(123, &ctx->net_bytes[_typ_offset]); false; }) + || ({ encode_u8le(152, &ctx->net_bytes[_typ_offset]); false; }) ; } -LM_FLATTEN static bool marshal_Tstat(struct _marshal_ctx *ctx, struct lib9p_msg_Tstat *val) { +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_fid(ctx, &val->fid) + || 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) || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; }) - || ({ encode_u8le(124, &ctx->net_bytes[_typ_offset]); false; }) + || ({ encode_u8le(154, &ctx->net_bytes[_typ_offset]); false; }) ; } -LM_FLATTEN static bool marshal_Rstat(struct _marshal_ctx *ctx, struct lib9p_msg_Rstat *val) { +#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_qid(struct _marshal_ctx *ctx, struct lib9p_qid *val) { + return false + || marshal_qt(ctx, &val->type) + || marshal_4(ctx, &val->vers) + || marshal_8(ctx, &val->path) + ; +} + +LM_FLATTEN static bool marshal_Topen(struct _marshal_ctx *ctx, struct lib9p_msg_Topen *val) { uint32_t _size_offset; uint32_t _typ_offset; - uint32_t _nstat_offset; - uint32_t _stat_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) - || ({ _nstat_offset = ctx->net_offset; ({ ctx->net_offset += 2; false; }); }) - || ({ _stat_offset = ctx->net_offset; marshal_stat(ctx, &val->stat); }) + || marshal_fid(ctx, &val->fid) + || marshal_o(ctx, &val->mode) || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; }) - || ({ encode_u8le(125, &ctx->net_bytes[_typ_offset]); false; }) - || ({ encode_u16le(ctx->net_offset - _stat_offset, &ctx->net_bytes[_nstat_offset]); false; }) + || ({ encode_u8le(112, &ctx->net_bytes[_typ_offset]); false; }) ; } -LM_FLATTEN static bool marshal_Twstat(struct _marshal_ctx *ctx, struct lib9p_msg_Twstat *val) { +LM_FLATTEN static bool marshal_Tcreate(struct _marshal_ctx *ctx, struct lib9p_msg_Tcreate *val) { uint32_t _size_offset; uint32_t _typ_offset; - uint32_t _nstat_offset; - uint32_t _stat_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_fid(ctx, &val->fid) - || ({ _nstat_offset = ctx->net_offset; ({ ctx->net_offset += 2; false; }); }) - || ({ _stat_offset = ctx->net_offset; marshal_stat(ctx, &val->stat); }) + || marshal_s(ctx, &val->name) + || marshal_dm(ctx, &val->perm) + || marshal_o(ctx, &val->mode) || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; }) - || ({ encode_u8le(126, &ctx->net_bytes[_typ_offset]); false; }) - || ({ encode_u16le(ctx->net_offset - _stat_offset, &ctx->net_bytes[_nstat_offset]); false; }) + || ({ encode_u8le(114, &ctx->net_bytes[_typ_offset]); false; }) ; } -LM_FLATTEN static bool marshal_Rwstat(struct _marshal_ctx *ctx, struct lib9p_msg_Rwstat *val) { +LM_ALWAYS_INLINE static bool marshal_stat(struct _marshal_ctx *ctx, struct lib9p_stat *val) { + uint32_t _stat_size_offset; + uint32_t _kern_type_offset; + return false + || ({ _stat_size_offset = ctx->net_offset; ({ ctx->net_offset += 2; false; }); }) + || ({ _kern_type_offset = ctx->net_offset; marshal_2(ctx, &val->kern_type); }) + || marshal_4(ctx, &val->kern_dev) + || marshal_qid(ctx, &val->file_qid) + || marshal_dm(ctx, &val->file_mode) + || marshal_4(ctx, &val->file_atime) + || marshal_4(ctx, &val->file_mtime) + || marshal_8(ctx, &val->file_size) + || marshal_s(ctx, &val->file_name) + || marshal_s(ctx, &val->file_owner_uid) + || marshal_s(ctx, &val->file_owner_gid) + || marshal_s(ctx, &val->file_last_modified_uid) +#if CONFIG_9P_ENABLE_9P2000_u + || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_s(ctx, &val->file_extension) ) + || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_4(ctx, &val->file_owner_n_uid) ) + || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_4(ctx, &val->file_owner_n_gid) ) + || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_4(ctx, &val->file_last_modified_n_uid) ) +#endif /* CONFIG_9P_ENABLE_9P2000_u */ + || ({ encode_u16le(ctx->net_offset - _kern_type_offset, &ctx->net_bytes[_stat_size_offset]); false; }) + ; +} + +LM_FLATTEN static bool marshal_Rauth(struct _marshal_ctx *ctx, struct lib9p_msg_Rauth *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_qid(ctx, &val->aqid) || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; }) - || ({ encode_u8le(127, &ctx->net_bytes[_typ_offset]); false; }) + || ({ encode_u8le(103, &ctx->net_bytes[_typ_offset]); false; }) ; } -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000_e -LM_FLATTEN static bool marshal_Tsession(struct _marshal_ctx *ctx, struct lib9p_msg_Tsession *val) { +LM_FLATTEN static bool marshal_Rattach(struct _marshal_ctx *ctx, struct lib9p_msg_Rattach *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_8(ctx, &val->key) + || marshal_qid(ctx, &val->qid) || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; }) - || ({ encode_u8le(150, &ctx->net_bytes[_typ_offset]); false; }) + || ({ encode_u8le(105, &ctx->net_bytes[_typ_offset]); false; }) ; } -LM_FLATTEN static bool marshal_Rsession(struct _marshal_ctx *ctx, struct lib9p_msg_Rsession *val) { +LM_FLATTEN static bool marshal_Rwalk(struct _marshal_ctx *ctx, struct lib9p_msg_Rwalk *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_2(ctx, &val->nwqid) + || ({ bool err = false; + for (typeof(val->nwqid) i = 0; i < val->nwqid && !err; i++) + err = marshal_qid(ctx, &val->wqid[i]); + err; }) || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; }) - || ({ encode_u8le(151, &ctx->net_bytes[_typ_offset]); false; }) + || ({ encode_u8le(111, &ctx->net_bytes[_typ_offset]); false; }) ; } -LM_FLATTEN static bool marshal_Tsread(struct _marshal_ctx *ctx, struct lib9p_msg_Tsread *val) { +LM_FLATTEN static bool marshal_Ropen(struct _marshal_ctx *ctx, struct lib9p_msg_Ropen *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_qid(ctx, &val->qid) + || marshal_4(ctx, &val->iounit) || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; }) - || ({ encode_u8le(152, &ctx->net_bytes[_typ_offset]); false; }) + || ({ encode_u8le(113, &ctx->net_bytes[_typ_offset]); false; }) ; } -LM_FLATTEN static bool marshal_Rsread(struct _marshal_ctx *ctx, struct lib9p_msg_Rsread *val) { +LM_FLATTEN static bool marshal_Rcreate(struct _marshal_ctx *ctx, struct lib9p_msg_Rcreate *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) + || marshal_qid(ctx, &val->qid) + || marshal_4(ctx, &val->iounit) || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; }) - || ({ encode_u8le(153, &ctx->net_bytes[_typ_offset]); false; }) + || ({ encode_u8le(115, &ctx->net_bytes[_typ_offset]); false; }) ; } -LM_FLATTEN static bool marshal_Tswrite(struct _marshal_ctx *ctx, struct lib9p_msg_Tswrite *val) { +LM_FLATTEN static bool marshal_Rstat(struct _marshal_ctx *ctx, struct lib9p_msg_Rstat *val) { uint32_t _size_offset; uint32_t _typ_offset; + uint32_t _nstat_offset; + uint32_t _stat_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) + || ({ _nstat_offset = ctx->net_offset; ({ ctx->net_offset += 2; false; }); }) + || ({ _stat_offset = ctx->net_offset; marshal_stat(ctx, &val->stat); }) || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; }) - || ({ encode_u8le(154, &ctx->net_bytes[_typ_offset]); false; }) + || ({ encode_u8le(125, &ctx->net_bytes[_typ_offset]); false; }) + || ({ encode_u16le(ctx->net_offset - _stat_offset, &ctx->net_bytes[_nstat_offset]); false; }) ; } -LM_FLATTEN static bool marshal_Rswrite(struct _marshal_ctx *ctx, struct lib9p_msg_Rswrite *val) { +LM_FLATTEN static bool marshal_Twstat(struct _marshal_ctx *ctx, struct lib9p_msg_Twstat *val) { uint32_t _size_offset; uint32_t _typ_offset; + uint32_t _nstat_offset; + uint32_t _stat_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) + || marshal_fid(ctx, &val->fid) + || ({ _nstat_offset = ctx->net_offset; ({ ctx->net_offset += 2; false; }); }) + || ({ _stat_offset = ctx->net_offset; marshal_stat(ctx, &val->stat); }) || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; }) - || ({ encode_u8le(155, &ctx->net_bytes[_typ_offset]); false; }) + || ({ encode_u8le(126, &ctx->net_bytes[_typ_offset]); false; }) + || ({ encode_u16le(ctx->net_offset - _stat_offset, &ctx->net_bytes[_nstat_offset]); false; }) ; } -#endif /* CONFIG_9P_ENABLE_9P2000_e */ +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */ /* tables / exports ***********************************************************/ #define _MSG_NAME(typ) [LIB9P_TYP_##typ] = #typ diff --git a/lib9p/idl.gen b/lib9p/idl.gen index 27396b4..0a43583 100755 --- a/lib9p/idl.gen +++ b/lib9p/idl.gen @@ -5,8 +5,10 @@ # Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> # SPDX-License-Identifier: AGPL-3.0-or-later +import graphlib import os.path import sys +import typing sys.path.insert(0, os.path.normpath(os.path.join(__file__, ".."))) @@ -141,6 +143,24 @@ def ifdef_pop(n: int) -> str: return ret +def topo_sorted(typs: list[idl.Type]) -> typing.Iterable[idl.Type]: + ts: graphlib.TopologicalSorter[idl.Type] = graphlib.TopologicalSorter() + for typ in typs: + match typ: + case idl.Number(): + ts.add(typ) + case idl.Bitfield(): + ts.add(typ) + case idl.Struct(): # and idl.Message(): + deps = [ + member.typ + for member in typ.members + if not isinstance(member.typ, idl.Primitive) + ] + ts.add(typ, *deps) + return ts.static_order() + + # Generate .h ################################################################## @@ -201,7 +221,7 @@ enum {idprefix}version {{ ret += """ /* payload types **************************************************************/ """ - for typ in typs: + for typ in topo_sorted(typs): ret += "\n" ret += ifdef_push(1, c_ver_ifdef(typ.in_versions)) match typ: @@ -385,7 +405,7 @@ LM_ALWAYS_INLINE static bool _validate_list(struct _validate_ctx *ctx, #define validate_4(ctx) _validate_size_net(ctx, 4) #define validate_8(ctx) _validate_size_net(ctx, 8) """ - for typ in typs: + for typ in topo_sorted(typs): inline = "LM_FLATTEN" if isinstance(typ, idl.Message) else "LM_ALWAYS_INLINE" argfn = unused if (isinstance(typ, idl.Struct) and not typ.members) else used ret += "\n" @@ -525,7 +545,7 @@ LM_ALWAYS_INLINE static void unmarshal_8(struct _unmarshal_ctx *ctx, uint64_t *o \tctx->net_offset += 8; } """ - for typ in typs: + for typ in topo_sorted(typs): inline = "LM_FLATTEN" if isinstance(typ, idl.Message) else "LM_ALWAYS_INLINE" argfn = unused if (isinstance(typ, idl.Struct) and not typ.members) else used ret += "\n" @@ -618,7 +638,7 @@ LM_ALWAYS_INLINE static bool marshal_8(struct _marshal_ctx *ctx, uint64_t *val) \treturn false; } """ - for typ in typs: + for typ in topo_sorted(typs): inline = "LM_FLATTEN" if isinstance(typ, idl.Message) else "LM_ALWAYS_INLINE" argfn = unused if (isinstance(typ, idl.Struct) and not typ.members) else used ret += "\n" diff --git a/lib9p/include/lib9p/9p.generated.h b/lib9p/include/lib9p/9p.generated.h index a6dc13c..2d613c9 100644 --- a/lib9p/include/lib9p/9p.generated.h +++ b/lib9p/include/lib9p/9p.generated.h @@ -155,32 +155,6 @@ typedef uint8_t lib9p_qt_t; #define LIB9P_QT_FILE ((lib9p_qt_t)(0)) -struct lib9p_qid { - lib9p_qt_t type; - uint32_t vers; - uint64_t path; -}; - -struct lib9p_stat { - uint16_t kern_type; - uint32_t kern_dev; - struct lib9p_qid file_qid; - lib9p_dm_t file_mode; - uint32_t file_atime; - uint32_t file_mtime; - uint64_t file_size; - struct lib9p_s file_name; - struct lib9p_s file_owner_uid; - struct lib9p_s file_owner_gid; - struct lib9p_s file_last_modified_uid; -#if CONFIG_9P_ENABLE_9P2000_u - struct lib9p_s file_extension; - uint32_t file_owner_n_uid; - uint32_t file_owner_n_gid; - uint32_t file_last_modified_n_uid; -#endif /* CONFIG_9P_ENABLE_9P2000_u */ -}; - typedef uint8_t lib9p_o_t; /* unused ((lib9p_o_t)(1<<7)) */ @@ -199,6 +173,93 @@ typedef uint8_t lib9p_o_t; #define LIB9P_O_MODE_MASK ((lib9p_o_t)(0b00000011)) #define LIB9P_O_FLAG_MASK ((lib9p_o_t)(0b11111100)) +struct lib9p_msg_Tflush { + lib9p_tag_t tag; + uint16_t oldtag; +}; + +struct lib9p_msg_Rflush { + lib9p_tag_t tag; +}; + +struct lib9p_msg_Rwrite { + lib9p_tag_t tag; + uint32_t count; +}; + +struct lib9p_msg_Rclunk { + lib9p_tag_t tag; +}; + +struct lib9p_msg_Rremove { + lib9p_tag_t tag; +}; + +struct lib9p_msg_Rwstat { + lib9p_tag_t tag; +}; + +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_9P2000_e +struct lib9p_msg_Tsession { + lib9p_tag_t tag; + uint64_t key; +}; + +struct lib9p_msg_Rsession { + lib9p_tag_t tag; +}; + +struct lib9p_msg_Rswrite { + lib9p_tag_t tag; + uint32_t count; +}; + +#endif /* CONFIG_9P_ENABLE_9P2000_e */ +#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u +struct lib9p_msg_Tread { + lib9p_tag_t tag; + lib9p_fid_t fid; + uint64_t offset; + uint32_t count; +}; + +struct lib9p_msg_Tclunk { + lib9p_tag_t tag; + lib9p_fid_t fid; +}; + +struct lib9p_msg_Tremove { + lib9p_tag_t tag; + lib9p_fid_t fid; +}; + +struct lib9p_msg_Tstat { + lib9p_tag_t tag; + lib9p_fid_t fid; +}; + +struct lib9p_msg_Rread { + lib9p_tag_t tag; + struct lib9p_d data; +}; + +struct lib9p_msg_Twrite { + lib9p_tag_t tag; + lib9p_fid_t fid; + uint64_t offset; + struct lib9p_d data; +}; + +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_9P2000_e +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_e || CONFIG_9P_ENABLE_9P2000_u struct lib9p_msg_Tversion { lib9p_tag_t tag; uint32_t max_msg_size; @@ -221,11 +282,6 @@ struct lib9p_msg_Tauth { #endif /* CONFIG_9P_ENABLE_9P2000_u */ }; -struct lib9p_msg_Rauth { - lib9p_tag_t tag; - struct lib9p_qid aqid; -}; - struct lib9p_msg_Tattach { lib9p_tag_t tag; lib9p_fid_t fid; @@ -237,11 +293,6 @@ struct lib9p_msg_Tattach { #endif /* CONFIG_9P_ENABLE_9P2000_u */ }; -struct lib9p_msg_Rattach { - lib9p_tag_t tag; - struct lib9p_qid qid; -}; - struct lib9p_msg_Rerror { lib9p_tag_t tag; struct lib9p_s ename; @@ -250,27 +301,37 @@ struct lib9p_msg_Rerror { #endif /* CONFIG_9P_ENABLE_9P2000_u */ }; -struct lib9p_msg_Tflush { - lib9p_tag_t tag; - uint16_t oldtag; +struct lib9p_msg_Twalk { + lib9p_tag_t tag; + lib9p_fid_t fid; + lib9p_fid_t newfid; + uint16_t nwname; + struct lib9p_s *wname; }; -struct lib9p_msg_Rflush { - lib9p_tag_t tag; +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_9P2000_e +struct lib9p_msg_Tsread { + lib9p_tag_t tag; + uint32_t fid; + uint16_t nwname; + struct lib9p_s *wname; }; -struct lib9p_msg_Twalk { +struct lib9p_msg_Tswrite { lib9p_tag_t tag; - lib9p_fid_t fid; - lib9p_fid_t newfid; + uint32_t fid; uint16_t nwname; struct lib9p_s *wname; + struct lib9p_d data; }; -struct lib9p_msg_Rwalk { - lib9p_tag_t tag; - uint16_t nwqid; - struct lib9p_qid *wqid; +#endif /* CONFIG_9P_ENABLE_9P2000_e */ +#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u +struct lib9p_qid { + lib9p_qt_t type; + uint32_t vers; + uint64_t path; }; struct lib9p_msg_Topen { @@ -279,12 +340,6 @@ struct lib9p_msg_Topen { lib9p_o_t mode; }; -struct lib9p_msg_Ropen { - lib9p_tag_t tag; - struct lib9p_qid qid; - uint32_t iounit; -}; - struct lib9p_msg_Tcreate { lib9p_tag_t tag; lib9p_fid_t fid; @@ -293,57 +348,52 @@ struct lib9p_msg_Tcreate { lib9p_o_t mode; }; -struct lib9p_msg_Rcreate { - lib9p_tag_t tag; - struct lib9p_qid qid; - uint32_t iounit; -}; - -struct lib9p_msg_Tread { - lib9p_tag_t tag; - lib9p_fid_t fid; - uint64_t offset; - uint32_t count; -}; - -struct lib9p_msg_Rread { - lib9p_tag_t tag; - struct lib9p_d data; -}; - -struct lib9p_msg_Twrite { - lib9p_tag_t tag; - lib9p_fid_t fid; - uint64_t offset; - struct lib9p_d data; -}; - -struct lib9p_msg_Rwrite { - lib9p_tag_t tag; - uint32_t count; +struct lib9p_stat { + uint16_t kern_type; + uint32_t kern_dev; + struct lib9p_qid file_qid; + lib9p_dm_t file_mode; + uint32_t file_atime; + uint32_t file_mtime; + uint64_t file_size; + struct lib9p_s file_name; + struct lib9p_s file_owner_uid; + struct lib9p_s file_owner_gid; + struct lib9p_s file_last_modified_uid; +#if CONFIG_9P_ENABLE_9P2000_u + struct lib9p_s file_extension; + uint32_t file_owner_n_uid; + uint32_t file_owner_n_gid; + uint32_t file_last_modified_n_uid; +#endif /* CONFIG_9P_ENABLE_9P2000_u */ }; -struct lib9p_msg_Tclunk { - lib9p_tag_t tag; - lib9p_fid_t fid; +struct lib9p_msg_Rauth { + lib9p_tag_t tag; + struct lib9p_qid aqid; }; -struct lib9p_msg_Rclunk { - lib9p_tag_t tag; +struct lib9p_msg_Rattach { + lib9p_tag_t tag; + struct lib9p_qid qid; }; -struct lib9p_msg_Tremove { - lib9p_tag_t tag; - lib9p_fid_t fid; +struct lib9p_msg_Rwalk { + lib9p_tag_t tag; + uint16_t nwqid; + struct lib9p_qid *wqid; }; -struct lib9p_msg_Rremove { - lib9p_tag_t tag; +struct lib9p_msg_Ropen { + lib9p_tag_t tag; + struct lib9p_qid qid; + uint32_t iounit; }; -struct lib9p_msg_Tstat { - lib9p_tag_t tag; - lib9p_fid_t fid; +struct lib9p_msg_Rcreate { + lib9p_tag_t tag; + struct lib9p_qid qid; + uint32_t iounit; }; struct lib9p_msg_Rstat { @@ -356,44 +406,4 @@ struct lib9p_msg_Twstat { lib9p_fid_t fid; struct lib9p_stat stat; }; - -struct lib9p_msg_Rwstat { - lib9p_tag_t tag; -}; - #endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000_e -struct lib9p_msg_Tsession { - lib9p_tag_t tag; - uint64_t key; -}; - -struct lib9p_msg_Rsession { - lib9p_tag_t tag; -}; - -struct lib9p_msg_Tsread { - lib9p_tag_t tag; - uint32_t fid; - uint16_t nwname; - struct lib9p_s *wname; -}; - -struct lib9p_msg_Rsread { - lib9p_tag_t tag; - struct lib9p_d data; -}; - -struct lib9p_msg_Tswrite { - lib9p_tag_t tag; - uint32_t fid; - uint16_t nwname; - struct lib9p_s *wname; - struct lib9p_d data; -}; - -struct lib9p_msg_Rswrite { - lib9p_tag_t tag; - uint32_t count; -}; -#endif /* CONFIG_9P_ENABLE_9P2000_e */ |