From cb8893dd08b7b359f45ef225acd2f6e103d38bba Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Wed, 9 Oct 2024 11:05:26 -0600 Subject: wip --- lib9p/9p.generated.c | 1300 +++++++++++++++++------------------- lib9p/idl.gen | 224 +++---- lib9p/idl/01-9P2000.9p | 2 +- lib9p/include/lib9p/9p.generated.h | 284 +++++--- 4 files changed, 885 insertions(+), 925 deletions(-) diff --git a/lib9p/9p.generated.c b/lib9p/9p.generated.c index b24c6e8..a93316b 100644 --- a/lib9p/9p.generated.c +++ b/lib9p/9p.generated.c @@ -1,4 +1,4 @@ -/* Generated by `./lib9p/9p.gen lib9p/9P2000.txt lib9p/9P2000.u.txt lib9p/9P2000.e.txt`. DO NOT EDIT! */ +/* Generated by `./lib9p/idl.gen lib9p/idl/01-9P2000.9p lib9p/idl/02-9P2000.e.9p lib9p/idl/02-9P2000.u.9p`. DO NOT EDIT! */ #include #include @@ -14,9 +14,15 @@ static const char *version_strs[LIB9P_VER_NUM] = { [LIB9P_VER_unknown] = "unknown", +#if defined(CONFIG_9P_ENABLE_9P2000) [LIB9P_VER_9P2000] = "9P2000", +#endif /* defined(CONFIG_9P_ENABLE_9P2000) */ +#if defined(CONFIG_9P_ENABLE_9P2000_e) [LIB9P_VER_9P2000_e] = "9P2000.e", +#endif /* defined(CONFIG_9P_ENABLE_9P2000_e) */ +#if defined(CONFIG_9P_ENABLE_9P2000_u) [LIB9P_VER_9P2000_u] = "9P2000.u", +#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */ }; const char *lib9p_version_str(enum lib9p_version ver) { @@ -324,6 +330,15 @@ static ALWAYS_INLINE 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) +#if defined(CONFIG_9P_ENABLE_9P2000) || defined(CONFIG_9P_ENABLE_9P2000_e) || defined(CONFIG_9P_ENABLE_9P2000_u) +static ALWAYS_INLINE bool validate_tag(struct _validate_ctx *ctx) { + return validate_2(ctx); +} + +static ALWAYS_INLINE bool validate_fid(struct _validate_ctx *ctx) { + return validate_4(ctx); +} + static ALWAYS_INLINE bool validate_d(struct _validate_ctx *ctx) { uint32_t base_offset = ctx->net_offset; if (validate_4(ctx)) @@ -348,14 +363,21 @@ static ALWAYS_INLINE bool validate_dm(struct _validate_ctx *ctx) { if (validate_4(ctx)) return true; static const lib9p_dm_t masks[LIB9P_VER_NUM] = { +#if defined(CONFIG_9P_ENABLE_9P2000) [LIB9P_VER_9P2000] = 0b11101100000000000000000111111111, +#endif /* defined(CONFIG_9P_ENABLE_9P2000) */ +#if defined(CONFIG_9P_ENABLE_9P2000_e) [LIB9P_VER_9P2000_e] = 0b11101100000000000000000111111111, +#endif /* defined(CONFIG_9P_ENABLE_9P2000_e) */ +#if defined(CONFIG_9P_ENABLE_9P2000_u) [LIB9P_VER_9P2000_u] = 0b11101100101111000000000111111111, +#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */ }; lib9p_dm_t mask = masks[ctx->ctx->version]; lib9p_dm_t val = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); if (val & ~mask) - return lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "unknown bits in dm bitfield: %#04"PRIx32, + return lib9p_errorf(ctx->ctx, + LINUX_EBADMSG, "unknown bits in dm bitfield: %#04"PRIx32, val & ~mask); return false; } @@ -364,28 +386,38 @@ static ALWAYS_INLINE bool validate_qt(struct _validate_ctx *ctx) { if (validate_1(ctx)) return true; static const lib9p_qt_t masks[LIB9P_VER_NUM] = { +#if defined(CONFIG_9P_ENABLE_9P2000) [LIB9P_VER_9P2000] = 0b11101100, +#endif /* defined(CONFIG_9P_ENABLE_9P2000) */ +#if defined(CONFIG_9P_ENABLE_9P2000_e) [LIB9P_VER_9P2000_e] = 0b11101100, +#endif /* defined(CONFIG_9P_ENABLE_9P2000_e) */ +#if defined(CONFIG_9P_ENABLE_9P2000_u) [LIB9P_VER_9P2000_u] = 0b11101110, +#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */ }; lib9p_qt_t mask = masks[ctx->ctx->version]; lib9p_qt_t val = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); if (val & ~mask) - return lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#01"PRIx8, + return lib9p_errorf(ctx->ctx, + LINUX_EBADMSG, "unknown bits in qt bitfield: %#01"PRIx8, val & ~mask); return false; } static ALWAYS_INLINE bool validate_qid(struct _validate_ctx *ctx) { - return validate_qt(ctx) + return false + || validate_qt(ctx) || validate_4(ctx) - || validate_8(ctx); + || validate_8(ctx) + ; } static ALWAYS_INLINE bool validate_stat(struct _validate_ctx *ctx) { uint16_t stat_size; uint32_t _kern_type_offset; - return (validate_2(ctx) || ({ stat_size = decode_u16le(&ctx->net_bytes[ctx->net_offset-2]); false; })) + 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) @@ -397,884 +429,756 @@ static ALWAYS_INLINE bool validate_stat(struct _validate_ctx *ctx) { || validate_s(ctx) || validate_s(ctx) || validate_s(ctx) +#if defined(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) ) - || ({ uint32_t correct = ctx->net_offset - _kern_type_offset; (((uint32_t)stat_size) != correct) && - lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "stat_size value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)stat_size, correct); }); +#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */ + + || ({ uint32_t exp = ctx->net_offset - _kern_type_offset; (((uint32_t)stat_size) != exp) && + + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "stat_size value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)stat_size, exp); }) + ; } static ALWAYS_INLINE bool validate_o(struct _validate_ctx *ctx) { if (validate_1(ctx)) return true; - static const lib9p_o_t mask = 0b01010011; + static const lib9p_o_t masks[LIB9P_VER_NUM] = { +#if defined(CONFIG_9P_ENABLE_9P2000) + [LIB9P_VER_9P2000] = 0b01010011, +#endif /* defined(CONFIG_9P_ENABLE_9P2000) */ +#if defined(CONFIG_9P_ENABLE_9P2000_e) + [LIB9P_VER_9P2000_e] = 0b01010011, +#endif /* defined(CONFIG_9P_ENABLE_9P2000_e) */ +#if defined(CONFIG_9P_ENABLE_9P2000_u) + [LIB9P_VER_9P2000_u] = 0b01010011, +#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */ + }; + lib9p_o_t mask = masks[ctx->ctx->version]; lib9p_o_t val = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); if (val & ~mask) - return lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "unknown bits in o bitfield: %#01"PRIx8, + return lib9p_errorf(ctx->ctx, + LINUX_EBADMSG, "unknown bits in o bitfield: %#01"PRIx8, val & ~mask); return false; } static FLATTEN bool validate_Tversion(struct _validate_ctx *ctx) { - return validate_4(ctx) - || validate_s(ctx); + uint32_t size; + uint8_t typ; + 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_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 wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) + + || ({ uint32_t exp = 100; (((uint32_t)typ) != exp) && + + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); }) + ; } static FLATTEN bool validate_Rversion(struct _validate_ctx *ctx) { - return validate_4(ctx) - || validate_s(ctx); + uint32_t size; + uint8_t typ; + 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_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 wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) + + || ({ uint32_t exp = 101; (((uint32_t)typ) != exp) && + + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); }) + ; } static FLATTEN bool validate_Tauth(struct _validate_ctx *ctx) { - return validate_4(ctx) + uint32_t size; + uint8_t typ; + 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_s(ctx) || validate_s(ctx) - || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && validate_4(ctx) ); +#if defined(CONFIG_9P_ENABLE_9P2000_u) + || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && validate_4(ctx) ) +#endif /* defined(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 wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) + + || ({ uint32_t exp = 102; (((uint32_t)typ) != exp) && + + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); }) + ; } static FLATTEN bool validate_Rauth(struct _validate_ctx *ctx) { - return validate_qid(ctx); + uint32_t size; + uint8_t typ; + 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) + + || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && + + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) + + || ({ uint32_t exp = 103; (((uint32_t)typ) != exp) && + + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); }) + ; } static FLATTEN bool validate_Tattach(struct _validate_ctx *ctx) { - return validate_4(ctx) - || validate_4(ctx) + uint32_t size; + uint8_t typ; + 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_s(ctx) || validate_s(ctx) - || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && validate_4(ctx) ); +#if defined(CONFIG_9P_ENABLE_9P2000_u) + || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && validate_4(ctx) ) +#endif /* defined(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 wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) + + || ({ uint32_t exp = 104; (((uint32_t)typ) != exp) && + + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); }) + ; } static FLATTEN bool validate_Rattach(struct _validate_ctx *ctx) { - return validate_qid(ctx); + uint32_t size; + uint8_t typ; + 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) + + || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && + + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) + + || ({ uint32_t exp = 105; (((uint32_t)typ) != exp) && + + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); }) + ; } static FLATTEN bool validate_Rerror(struct _validate_ctx *ctx) { - return validate_s(ctx) - || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && validate_4(ctx) ); + uint32_t size; + uint8_t typ; + 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_s(ctx) +#if defined(CONFIG_9P_ENABLE_9P2000_u) + || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && validate_4(ctx) ) +#endif /* defined(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 wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) + + || ({ uint32_t exp = 107; (((uint32_t)typ) != exp) && + + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); }) + ; } static FLATTEN bool validate_Tflush(struct _validate_ctx *ctx) { - return validate_2(ctx); + uint32_t size; + uint8_t typ; + 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) + + || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && + + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) + + || ({ uint32_t exp = 108; (((uint32_t)typ) != exp) && + + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); }) + ; } -static FLATTEN bool validate_Rflush(struct _validate_ctx *UNUSED(ctx)) { - return false; +static FLATTEN bool validate_Rflush(struct _validate_ctx *ctx) { + uint32_t size; + uint8_t typ; + uint32_t _size_offset; + return false + || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = 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) + + || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && + + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) + + || ({ uint32_t exp = 109; (((uint32_t)typ) != exp) && + + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); }) + ; } static FLATTEN bool validate_Twalk(struct _validate_ctx *ctx) { + uint32_t size; + uint8_t typ; uint16_t nwname; - return validate_4(ctx) - || validate_4(ctx) + 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; })) - || (nwname > UINT16_C(16) && lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "nwname value too large (%"PRIu16" > %"PRIu16")", nwname, UINT16_C(16))) - || _validate_list(ctx, decode_u16le(&ctx->net_bytes[ctx->net_offset-2]), validate_s, sizeof(struct lib9p_s)); + || _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 wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) + + || ({ uint32_t exp = 110; (((uint32_t)typ) != exp) && + + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); }) + + || ({ uint32_t max = 16; (((uint32_t)nwname) > max) && + + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "nwname value too large (%"PRIu32" > %"PRIu32")", nwname, max); }) + ; } static FLATTEN bool validate_Rwalk(struct _validate_ctx *ctx) { + uint32_t size; + uint8_t typ; uint16_t nwqid; - return (validate_2(ctx) || ({ nwqid = decode_u16le(&ctx->net_bytes[ctx->net_offset-2]); false; })) - || (nwqid > UINT16_C(16) && lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "nwqid value too large (%"PRIu16" > %"PRIu16")", nwqid, UINT16_C(16))) - || _validate_list(ctx, decode_u16le(&ctx->net_bytes[ctx->net_offset-2]), validate_qid, sizeof(struct lib9p_qid)); + 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 wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) + + || ({ uint32_t exp = 111; (((uint32_t)typ) != exp) && + + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); }) + + || ({ uint32_t max = 16; (((uint32_t)nwqid) > max) && + + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "nwqid value too large (%"PRIu32" > %"PRIu32")", nwqid, max); }) + ; } static FLATTEN bool validate_Topen(struct _validate_ctx *ctx) { - return validate_4(ctx) - || validate_o(ctx); -} + uint32_t size; + uint8_t typ; + 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_o(ctx) -static FLATTEN bool validate_Ropen(struct _validate_ctx *ctx) { - return validate_qid(ctx) - || validate_4(ctx); -} + || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && -static FLATTEN bool validate_Tcreate(struct _validate_ctx *ctx) { - return validate_4(ctx) - || validate_s(ctx) - || validate_dm(ctx) - || validate_o(ctx); -} + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) -static FLATTEN bool validate_Rcreate(struct _validate_ctx *ctx) { - return validate_qid(ctx) - || validate_4(ctx); -} + || ({ uint32_t exp = 112; (((uint32_t)typ) != exp) && -static FLATTEN bool validate_Tread(struct _validate_ctx *ctx) { - return validate_4(ctx) - || validate_8(ctx) - || validate_4(ctx); + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); }) + ; } -static FLATTEN bool validate_Rread(struct _validate_ctx *ctx) { - return validate_d(ctx); -} +static FLATTEN bool validate_Ropen(struct _validate_ctx *ctx) { + uint32_t size; + uint8_t typ; + uint32_t _size_offset; + return false + || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = 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) -static FLATTEN bool validate_Twrite(struct _validate_ctx *ctx) { - return validate_4(ctx) - || validate_8(ctx) - || validate_d(ctx); -} + || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && -static FLATTEN bool validate_Rwrite(struct _validate_ctx *ctx) { - return validate_4(ctx); -} + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) -static FLATTEN bool validate_Tclunk(struct _validate_ctx *ctx) { - return validate_4(ctx); -} + || ({ uint32_t exp = 113; (((uint32_t)typ) != exp) && -static FLATTEN bool validate_Rclunk(struct _validate_ctx *UNUSED(ctx)) { - return false; + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); }) + ; } -static FLATTEN bool validate_Tremove(struct _validate_ctx *ctx) { - return validate_4(ctx); -} +static FLATTEN bool validate_Tcreate(struct _validate_ctx *ctx) { + uint32_t size; + uint8_t typ; + uint32_t _size_offset; + return false + || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = 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) -static FLATTEN bool validate_Rremove(struct _validate_ctx *UNUSED(ctx)) { - return false; -} + || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && -static FLATTEN bool validate_Tstat(struct _validate_ctx *ctx) { - return validate_4(ctx); -} + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) -static FLATTEN bool validate_Rstat(struct _validate_ctx *ctx) { - uint16_t nstat; - uint32_t _stat_offset; - return (validate_2(ctx) || ({ nstat = decode_u16le(&ctx->net_bytes[ctx->net_offset-2]); false; })) - || ({ _stat_offset = ctx->net_offset; validate_stat(ctx); }) - || ({ uint32_t correct = ctx->net_offset - _stat_offset; (((uint32_t)nstat) != correct) && - lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "nstat value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)nstat, correct); }); -} + || ({ uint32_t exp = 114; (((uint32_t)typ) != exp) && -static FLATTEN bool validate_Twstat(struct _validate_ctx *ctx) { - uint16_t nstat; - uint32_t _stat_offset; - return validate_4(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 correct = ctx->net_offset - _stat_offset; (((uint32_t)nstat) != correct) && - lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "nstat value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)nstat, correct); }); + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); }) + ; } -static FLATTEN bool validate_Rwstat(struct _validate_ctx *UNUSED(ctx)) { - return false; -} +static FLATTEN bool validate_Rcreate(struct _validate_ctx *ctx) { + uint32_t size; + uint8_t typ; + uint32_t _size_offset; + return false + || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = 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) -static FLATTEN bool validate_Tsession(struct _validate_ctx *ctx) { - return validate_8(ctx); -} + || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && -static FLATTEN bool validate_Rsession(struct _validate_ctx *UNUSED(ctx)) { - return false; -} + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) -static FLATTEN bool validate_Tsread(struct _validate_ctx *ctx) { - return 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 = 115; (((uint32_t)typ) != exp) && -static FLATTEN bool validate_Rsread(struct _validate_ctx *ctx) { - return validate_d(ctx); + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); }) + ; } -static FLATTEN bool validate_Tswrite(struct _validate_ctx *ctx) { - return 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); -} +static FLATTEN bool validate_Tread(struct _validate_ctx *ctx) { + uint32_t size; + uint8_t typ; + uint32_t _size_offset; + return false + || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = 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) + || validate_4(ctx) -static FLATTEN bool validate_Rswrite(struct _validate_ctx *ctx) { - return validate_4(ctx); -} + || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && -/* unmarshal_* ****************************************************************/ + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) -static ALWAYS_INLINE void unmarshal_1(struct _unmarshal_ctx *ctx, uint8_t *out) { - *out = decode_u8le(&ctx->net_bytes[ctx->net_offset]); - ctx->net_offset += 1; -} + || ({ uint32_t exp = 116; (((uint32_t)typ) != exp) && -static ALWAYS_INLINE void unmarshal_2(struct _unmarshal_ctx *ctx, uint16_t *out) { - *out = decode_u16le(&ctx->net_bytes[ctx->net_offset]); - ctx->net_offset += 2; + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); }) + ; } -static ALWAYS_INLINE void unmarshal_4(struct _unmarshal_ctx *ctx, uint32_t *out) { - *out = decode_u32le(&ctx->net_bytes[ctx->net_offset]); - ctx->net_offset += 4; -} +static FLATTEN bool validate_Rread(struct _validate_ctx *ctx) { + uint32_t size; + uint8_t typ; + uint32_t _size_offset; + return false + || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = 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) -static ALWAYS_INLINE void unmarshal_8(struct _unmarshal_ctx *ctx, uint64_t *out) { - *out = decode_u64le(&ctx->net_bytes[ctx->net_offset]); - ctx->net_offset += 8; -} + || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && -static ALWAYS_INLINE void unmarshal_d(struct _unmarshal_ctx *ctx, struct lib9p_d *out) { - memset(out, 0, sizeof(*out)); - unmarshal_4(ctx, &out->len); - out->dat = ctx->extra; - ctx->extra += sizeof(out->dat[0]) * out->len; - for (typeof(out->len) i = 0; i < out->len; i++) - unmarshal_1(ctx, (uint8_t *)&out->dat[i]); -} + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) -static ALWAYS_INLINE void unmarshal_s(struct _unmarshal_ctx *ctx, struct lib9p_s *out) { - memset(out, 0, sizeof(*out)); - unmarshal_2(ctx, &out->len); - out->utf8 = ctx->extra; - ctx->extra += sizeof(out->utf8[0]) * out->len; - for (typeof(out->len) i = 0; i < out->len; i++) - unmarshal_1(ctx, (uint8_t *)&out->utf8[i]); - ctx->extra++; - out->utf8[out->len] = '\0'; -} + || ({ uint32_t exp = 117; (((uint32_t)typ) != exp) && -static ALWAYS_INLINE void unmarshal_dm(struct _unmarshal_ctx *ctx, lib9p_dm_t *out) { - unmarshal_4(ctx, (uint32_t *)out); + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); }) + ; } -static ALWAYS_INLINE void unmarshal_qt(struct _unmarshal_ctx *ctx, lib9p_qt_t *out) { - unmarshal_1(ctx, (uint8_t *)out); -} +static FLATTEN bool validate_Twrite(struct _validate_ctx *ctx) { + uint32_t size; + uint8_t typ; + uint32_t _size_offset; + return false + || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = 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) + || validate_d(ctx) -static ALWAYS_INLINE 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); -} + || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && -static ALWAYS_INLINE 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 ( (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); -} + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) -static ALWAYS_INLINE void unmarshal_o(struct _unmarshal_ctx *ctx, lib9p_o_t *out) { - unmarshal_1(ctx, (uint8_t *)out); -} + || ({ uint32_t exp = 118; (((uint32_t)typ) != exp) && -static FLATTEN void unmarshal_Tversion(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tversion *out) { - memset(out, 0, sizeof(*out)); - unmarshal_4(ctx, &out->max_msg_size); - unmarshal_s(ctx, &out->version); + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); }) + ; } -static FLATTEN void unmarshal_Rversion(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rversion *out) { - memset(out, 0, sizeof(*out)); - unmarshal_4(ctx, &out->max_msg_size); - unmarshal_s(ctx, &out->version); -} +static FLATTEN bool validate_Rwrite(struct _validate_ctx *ctx) { + uint32_t size; + uint8_t typ; + uint32_t _size_offset; + return false + || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = 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) -static FLATTEN void unmarshal_Tauth(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tauth *out) { - memset(out, 0, sizeof(*out)); - unmarshal_4(ctx, &out->afid); - unmarshal_s(ctx, &out->uname); - unmarshal_s(ctx, &out->aname); - if ( (ctx->ctx->version==LIB9P_VER_9P2000_u) ) unmarshal_4(ctx, &out->n_uname); -} + || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && -static FLATTEN void unmarshal_Rauth(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rauth *out) { - memset(out, 0, sizeof(*out)); - unmarshal_qid(ctx, &out->aqid); -} + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) -static FLATTEN void unmarshal_Tattach(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tattach *out) { - memset(out, 0, sizeof(*out)); - unmarshal_4(ctx, &out->fid); - unmarshal_4(ctx, &out->afid); - unmarshal_s(ctx, &out->uname); - unmarshal_s(ctx, &out->aname); - if ( (ctx->ctx->version==LIB9P_VER_9P2000_u) ) unmarshal_4(ctx, &out->n_uname); -} + || ({ uint32_t exp = 119; (((uint32_t)typ) != exp) && -static FLATTEN void unmarshal_Rattach(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rattach *out) { - memset(out, 0, sizeof(*out)); - unmarshal_qid(ctx, &out->qid); + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); }) + ; } -static FLATTEN void unmarshal_Rerror(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rerror *out) { - memset(out, 0, sizeof(*out)); - unmarshal_s(ctx, &out->ename); - if ( (ctx->ctx->version==LIB9P_VER_9P2000_u) ) unmarshal_4(ctx, &out->errno); -} +static FLATTEN bool validate_Tclunk(struct _validate_ctx *ctx) { + uint32_t size; + uint8_t typ; + uint32_t _size_offset; + return false + || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = 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) -static FLATTEN void unmarshal_Tflush(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tflush *out) { - memset(out, 0, sizeof(*out)); - unmarshal_2(ctx, &out->oldtag); -} + || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && -static FLATTEN void unmarshal_Rflush(struct _unmarshal_ctx *UNUSED(ctx), struct lib9p_msg_Rflush *out) { - memset(out, 0, sizeof(*out)); -} + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) -static FLATTEN void unmarshal_Twalk(struct _unmarshal_ctx *ctx, struct lib9p_msg_Twalk *out) { - memset(out, 0, sizeof(*out)); - unmarshal_4(ctx, &out->fid); - unmarshal_4(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]); -} + || ({ uint32_t exp = 120; (((uint32_t)typ) != exp) && -static FLATTEN void unmarshal_Rwalk(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rwalk *out) { - memset(out, 0, sizeof(*out)); - 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]); + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); }) + ; } -static FLATTEN void unmarshal_Topen(struct _unmarshal_ctx *ctx, struct lib9p_msg_Topen *out) { - memset(out, 0, sizeof(*out)); - unmarshal_4(ctx, &out->fid); - unmarshal_o(ctx, &out->mode); -} +static FLATTEN bool validate_Rclunk(struct _validate_ctx *ctx) { + uint32_t size; + uint8_t typ; + uint32_t _size_offset; + return false + || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = 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) -static FLATTEN void unmarshal_Ropen(struct _unmarshal_ctx *ctx, struct lib9p_msg_Ropen *out) { - memset(out, 0, sizeof(*out)); - unmarshal_qid(ctx, &out->qid); - unmarshal_4(ctx, &out->iounit); -} + || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && -static FLATTEN void unmarshal_Tcreate(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tcreate *out) { - memset(out, 0, sizeof(*out)); - unmarshal_4(ctx, &out->fid); - unmarshal_s(ctx, &out->name); - unmarshal_dm(ctx, &out->perm); - unmarshal_o(ctx, &out->mode); -} + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) -static FLATTEN void unmarshal_Rcreate(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rcreate *out) { - memset(out, 0, sizeof(*out)); - unmarshal_qid(ctx, &out->qid); - unmarshal_4(ctx, &out->iounit); -} + || ({ uint32_t exp = 121; (((uint32_t)typ) != exp) && -static FLATTEN void unmarshal_Tread(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tread *out) { - memset(out, 0, sizeof(*out)); - unmarshal_4(ctx, &out->fid); - unmarshal_8(ctx, &out->offset); - unmarshal_4(ctx, &out->count); + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); }) + ; } -static FLATTEN void unmarshal_Rread(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rread *out) { - memset(out, 0, sizeof(*out)); - unmarshal_d(ctx, &out->data); -} +static FLATTEN bool validate_Tremove(struct _validate_ctx *ctx) { + uint32_t size; + uint8_t typ; + uint32_t _size_offset; + return false + || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = 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) -static FLATTEN void unmarshal_Twrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Twrite *out) { - memset(out, 0, sizeof(*out)); - unmarshal_4(ctx, &out->fid); - unmarshal_8(ctx, &out->offset); - unmarshal_d(ctx, &out->data); -} + || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && -static FLATTEN void unmarshal_Rwrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rwrite *out) { - memset(out, 0, sizeof(*out)); - unmarshal_4(ctx, &out->count); -} + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) -static FLATTEN void unmarshal_Tclunk(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tclunk *out) { - memset(out, 0, sizeof(*out)); - unmarshal_4(ctx, &out->fid); -} + || ({ uint32_t exp = 122; (((uint32_t)typ) != exp) && -static FLATTEN void unmarshal_Rclunk(struct _unmarshal_ctx *UNUSED(ctx), struct lib9p_msg_Rclunk *out) { - memset(out, 0, sizeof(*out)); + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); }) + ; } -static FLATTEN void unmarshal_Tremove(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tremove *out) { - memset(out, 0, sizeof(*out)); - unmarshal_4(ctx, &out->fid); -} +static FLATTEN bool validate_Rremove(struct _validate_ctx *ctx) { + uint32_t size; + uint8_t typ; + uint32_t _size_offset; + return false + || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = 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) -static FLATTEN void unmarshal_Rremove(struct _unmarshal_ctx *UNUSED(ctx), struct lib9p_msg_Rremove *out) { - memset(out, 0, sizeof(*out)); -} + || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && -static FLATTEN void unmarshal_Tstat(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tstat *out) { - memset(out, 0, sizeof(*out)); - unmarshal_4(ctx, &out->fid); -} + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) -static FLATTEN void unmarshal_Rstat(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rstat *out) { - memset(out, 0, sizeof(*out)); - ctx->net_offset += 2; - unmarshal_stat(ctx, &out->stat); -} + || ({ uint32_t exp = 123; (((uint32_t)typ) != exp) && -static FLATTEN void unmarshal_Twstat(struct _unmarshal_ctx *ctx, struct lib9p_msg_Twstat *out) { - memset(out, 0, sizeof(*out)); - unmarshal_4(ctx, &out->fid); - ctx->net_offset += 2; - unmarshal_stat(ctx, &out->stat); + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); }) + ; } -static FLATTEN void unmarshal_Rwstat(struct _unmarshal_ctx *UNUSED(ctx), struct lib9p_msg_Rwstat *out) { - memset(out, 0, sizeof(*out)); -} +static FLATTEN bool validate_Tstat(struct _validate_ctx *ctx) { + uint32_t size; + uint8_t typ; + uint32_t _size_offset; + return false + || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = 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) -static FLATTEN void unmarshal_Tsession(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tsession *out) { - memset(out, 0, sizeof(*out)); - unmarshal_8(ctx, &out->key); -} + || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && -static FLATTEN void unmarshal_Rsession(struct _unmarshal_ctx *UNUSED(ctx), struct lib9p_msg_Rsession *out) { - memset(out, 0, sizeof(*out)); -} + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) -static FLATTEN void unmarshal_Tsread(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tsread *out) { - memset(out, 0, sizeof(*out)); - 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]); -} + || ({ uint32_t exp = 124; (((uint32_t)typ) != exp) && -static FLATTEN void unmarshal_Rsread(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rsread *out) { - memset(out, 0, sizeof(*out)); - unmarshal_d(ctx, &out->data); + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); }) + ; } -static FLATTEN void unmarshal_Tswrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tswrite *out) { - memset(out, 0, sizeof(*out)); - 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); -} +static FLATTEN 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_2(ctx) || ({ nstat = decode_u16le(&ctx->net_bytes[ctx->net_offset-2]); false; })) + || ({ _stat_offset = ctx->net_offset; validate_stat(ctx); }) -static FLATTEN void unmarshal_Rswrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rswrite *out) { - memset(out, 0, sizeof(*out)); - unmarshal_4(ctx, &out->count); -} + || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && -/* marshal_* ******************************************************************/ + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) -static ALWAYS_INLINE bool _marshal_too_large(struct _marshal_ctx *ctx) { - lib9p_errorf(ctx->ctx, LINUX_ERANGE, "%s too large to marshal into %s limit (limit=%"PRIu32")", - (ctx->net_bytes[4] % 2 == 0) ? "T-message" : "R-message", - ctx->ctx->version ? "negotiated" : ((ctx->net_bytes[4] % 2 == 0) ? "client" : "server"), - ctx->ctx->max_msg_size); - return true; -} + || ({ uint32_t exp = 125; (((uint32_t)typ) != exp) && -static ALWAYS_INLINE bool marshal_1(struct _marshal_ctx *ctx, uint8_t *val) { - if (ctx->net_offset + 1 > ctx->ctx->max_msg_size) - return _marshal_too_large(ctx); - ctx->net_bytes[ctx->net_offset] = *val; - ctx->net_offset += 1; - return false; -} + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); }) -static ALWAYS_INLINE bool marshal_2(struct _marshal_ctx *ctx, uint16_t *val) { - if (ctx->net_offset + 2 > ctx->ctx->max_msg_size) - return _marshal_too_large(ctx); - encode_u16le(*val, &ctx->net_bytes[ctx->net_offset]); - ctx->net_offset += 2; - return false; -} + || ({ uint32_t exp = ctx->net_offset - _stat_offset; (((uint32_t)nstat) != exp) && -static ALWAYS_INLINE bool marshal_4(struct _marshal_ctx *ctx, uint32_t *val) { - if (ctx->net_offset + 4 > ctx->ctx->max_msg_size) - return true; - encode_u32le(*val, &ctx->net_bytes[ctx->net_offset]); - ctx->net_offset += 4; - return false; + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "nstat value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)nstat, exp); }) + ; } -static ALWAYS_INLINE bool marshal_8(struct _marshal_ctx *ctx, uint64_t *val) { - if (ctx->net_offset + 8 > ctx->ctx->max_msg_size) - return true; - encode_u64le(*val, &ctx->net_bytes[ctx->net_offset]); - ctx->net_offset += 8; - return false; -} +static FLATTEN 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_fid(ctx) + || (validate_2(ctx) || ({ nstat = decode_u16le(&ctx->net_bytes[ctx->net_offset-2]); false; })) + || ({ _stat_offset = ctx->net_offset; validate_stat(ctx); }) -static ALWAYS_INLINE bool marshal_d(struct _marshal_ctx *ctx, struct lib9p_d *val) { - return marshal_4(ctx, &val->len) - || ({ - bool err = false; - for (typeof(val->len) i = 0; i < val->len && !err; i++) - err = marshal_1(ctx, (uint8_t *)&val->dat[i]); - err; - }); -} + || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && -static ALWAYS_INLINE bool marshal_s(struct _marshal_ctx *ctx, struct lib9p_s *val) { - return marshal_2(ctx, &val->len) - || ({ - bool err = false; - for (typeof(val->len) i = 0; i < val->len && !err; i++) - err = marshal_1(ctx, (uint8_t *)&val->utf8[i]); - err; - }); -} + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) -static ALWAYS_INLINE bool marshal_dm(struct _marshal_ctx *ctx, lib9p_dm_t *val) { - return marshal_4(ctx, (uint32_t *)val); -} + || ({ uint32_t exp = 126; (((uint32_t)typ) != exp) && -static ALWAYS_INLINE bool marshal_qt(struct _marshal_ctx *ctx, lib9p_qt_t *val) { - return marshal_1(ctx, (uint8_t *)val); -} + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); }) -static ALWAYS_INLINE bool marshal_qid(struct _marshal_ctx *ctx, struct lib9p_qid *val) { - return marshal_qt(ctx, &val->type) - || marshal_4(ctx, &val->vers) - || marshal_8(ctx, &val->path); -} + || ({ uint32_t exp = ctx->net_offset - _stat_offset; (((uint32_t)nstat) != exp) && -static ALWAYS_INLINE bool marshal_stat(struct _marshal_ctx *ctx, struct lib9p_stat *val) { - uint32_t _stat_size_offset; - uint32_t _kern_type_offset; - return ({ _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) - || ( (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) ) - || ({ encode_u16le( ctx->net_offset - _kern_type_offset, &ctx->net_bytes[_stat_size_offset]); false; }); + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "nstat value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)nstat, exp); }) + ; } -static ALWAYS_INLINE bool marshal_o(struct _marshal_ctx *ctx, lib9p_o_t *val) { - return marshal_1(ctx, (uint8_t *)val); -} +static FLATTEN bool validate_Rwstat(struct _validate_ctx *ctx) { + uint32_t size; + uint8_t typ; + uint32_t _size_offset; + return false + || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = 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) -static FLATTEN bool marshal_Tversion(struct _marshal_ctx *ctx, struct lib9p_msg_Tversion *val) { - return marshal_4(ctx, &val->max_msg_size) - || marshal_s(ctx, &val->version); -} + || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && -static FLATTEN bool marshal_Rversion(struct _marshal_ctx *ctx, struct lib9p_msg_Rversion *val) { - return marshal_4(ctx, &val->max_msg_size) - || marshal_s(ctx, &val->version); -} + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) -static FLATTEN bool marshal_Tauth(struct _marshal_ctx *ctx, struct lib9p_msg_Tauth *val) { - return marshal_4(ctx, &val->afid) - || marshal_s(ctx, &val->uname) - || marshal_s(ctx, &val->aname) - || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_4(ctx, &val->n_uname) ); -} + || ({ uint32_t exp = 127; (((uint32_t)typ) != exp) && -static FLATTEN bool marshal_Rauth(struct _marshal_ctx *ctx, struct lib9p_msg_Rauth *val) { - return marshal_qid(ctx, &val->aqid); + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); }) + ; } -static FLATTEN bool marshal_Tattach(struct _marshal_ctx *ctx, struct lib9p_msg_Tattach *val) { - return marshal_4(ctx, &val->fid) - || marshal_4(ctx, &val->afid) - || marshal_s(ctx, &val->uname) - || marshal_s(ctx, &val->aname) - || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_4(ctx, &val->n_uname) ); -} +#endif /* defined(CONFIG_9P_ENABLE_9P2000) || defined(CONFIG_9P_ENABLE_9P2000_e) || defined(CONFIG_9P_ENABLE_9P2000_u) */ +#if defined(CONFIG_9P_ENABLE_9P2000_e) +static FLATTEN bool validate_Tsession(struct _validate_ctx *ctx) { + uint32_t size; + uint8_t typ; + uint32_t _size_offset; + return false + || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = 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) -static FLATTEN bool marshal_Rattach(struct _marshal_ctx *ctx, struct lib9p_msg_Rattach *val) { - return marshal_qid(ctx, &val->qid); -} + || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && -static FLATTEN bool marshal_Rerror(struct _marshal_ctx *ctx, struct lib9p_msg_Rerror *val) { - return marshal_s(ctx, &val->ename) - || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_4(ctx, &val->errno) ); -} + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) -static FLATTEN bool marshal_Tflush(struct _marshal_ctx *ctx, struct lib9p_msg_Tflush *val) { - return marshal_2(ctx, &val->oldtag); -} + || ({ uint32_t exp = 150; (((uint32_t)typ) != exp) && -static FLATTEN bool marshal_Rflush(struct _marshal_ctx *UNUSED(ctx), struct lib9p_msg_Rflush *UNUSED(val)) { - return false; + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); }) + ; } -static FLATTEN bool marshal_Twalk(struct _marshal_ctx *ctx, struct lib9p_msg_Twalk *val) { - return marshal_4(ctx, &val->fid) - || marshal_4(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; - }); -} +static FLATTEN bool validate_Rsession(struct _validate_ctx *ctx) { + uint32_t size; + uint8_t typ; + uint32_t _size_offset; + return false + || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = 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) -static FLATTEN bool marshal_Rwalk(struct _marshal_ctx *ctx, struct lib9p_msg_Rwalk *val) { - return 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; - }); -} + || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && -static FLATTEN bool marshal_Topen(struct _marshal_ctx *ctx, struct lib9p_msg_Topen *val) { - return marshal_4(ctx, &val->fid) - || marshal_o(ctx, &val->mode); -} + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) -static FLATTEN bool marshal_Ropen(struct _marshal_ctx *ctx, struct lib9p_msg_Ropen *val) { - return marshal_qid(ctx, &val->qid) - || marshal_4(ctx, &val->iounit); -} + || ({ uint32_t exp = 151; (((uint32_t)typ) != exp) && -static FLATTEN bool marshal_Tcreate(struct _marshal_ctx *ctx, struct lib9p_msg_Tcreate *val) { - return marshal_4(ctx, &val->fid) - || marshal_s(ctx, &val->name) - || marshal_dm(ctx, &val->perm) - || marshal_o(ctx, &val->mode); + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); }) + ; } -static FLATTEN bool marshal_Rcreate(struct _marshal_ctx *ctx, struct lib9p_msg_Rcreate *val) { - return marshal_qid(ctx, &val->qid) - || marshal_4(ctx, &val->iounit); -} +static FLATTEN bool validate_Tsread(struct _validate_ctx *ctx) { + uint32_t size; + uint8_t typ; + uint32_t _size_offset; + return false + || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = 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)) -static FLATTEN bool marshal_Tread(struct _marshal_ctx *ctx, struct lib9p_msg_Tread *val) { - return marshal_4(ctx, &val->fid) - || marshal_8(ctx, &val->offset) - || marshal_4(ctx, &val->count); -} + || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && -static FLATTEN bool marshal_Rread(struct _marshal_ctx *ctx, struct lib9p_msg_Rread *val) { - return marshal_d(ctx, &val->data); -} + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) -static FLATTEN bool marshal_Twrite(struct _marshal_ctx *ctx, struct lib9p_msg_Twrite *val) { - return marshal_4(ctx, &val->fid) - || marshal_8(ctx, &val->offset) - || marshal_d(ctx, &val->data); -} + || ({ uint32_t exp = 152; (((uint32_t)typ) != exp) && -static FLATTEN bool marshal_Rwrite(struct _marshal_ctx *ctx, struct lib9p_msg_Rwrite *val) { - return marshal_4(ctx, &val->count); + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); }) + ; } -static FLATTEN bool marshal_Tclunk(struct _marshal_ctx *ctx, struct lib9p_msg_Tclunk *val) { - return marshal_4(ctx, &val->fid); -} +static FLATTEN bool validate_Rsread(struct _validate_ctx *ctx) { + uint32_t size; + uint8_t typ; + uint32_t _size_offset; + return false + || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = 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) -static FLATTEN bool marshal_Rclunk(struct _marshal_ctx *UNUSED(ctx), struct lib9p_msg_Rclunk *UNUSED(val)) { - return false; -} + || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && -static FLATTEN bool marshal_Tremove(struct _marshal_ctx *ctx, struct lib9p_msg_Tremove *val) { - return marshal_4(ctx, &val->fid); -} + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) -static FLATTEN bool marshal_Rremove(struct _marshal_ctx *UNUSED(ctx), struct lib9p_msg_Rremove *UNUSED(val)) { - return false; -} + || ({ uint32_t exp = 153; (((uint32_t)typ) != exp) && -static FLATTEN bool marshal_Tstat(struct _marshal_ctx *ctx, struct lib9p_msg_Tstat *val) { - return marshal_4(ctx, &val->fid); + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); }) + ; } -static FLATTEN bool marshal_Rstat(struct _marshal_ctx *ctx, struct lib9p_msg_Rstat *val) { - uint32_t _nstat_offset; - uint32_t _stat_offset; - return ({ _nstat_offset = ctx->net_offset; ({ ctx->net_offset += 2; false; }); }) - || ({ _stat_offset = ctx->net_offset; marshal_stat(ctx, &val->stat); }) - || ({ encode_u16le( ctx->net_offset - _stat_offset, &ctx->net_bytes[_nstat_offset]); false; }); -} +static FLATTEN bool validate_Tswrite(struct _validate_ctx *ctx) { + uint32_t size; + uint8_t typ; + uint32_t _size_offset; + return false + || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = 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) -static FLATTEN bool marshal_Twstat(struct _marshal_ctx *ctx, struct lib9p_msg_Twstat *val) { - uint32_t _nstat_offset; - uint32_t _stat_offset; - return marshal_4(ctx, &val->fid) - || ({ _nstat_offset = ctx->net_offset; ({ ctx->net_offset += 2; false; }); }) - || ({ _stat_offset = ctx->net_offset; marshal_stat(ctx, &val->stat); }) - || ({ encode_u16le( ctx->net_offset - _stat_offset, &ctx->net_bytes[_nstat_offset]); false; }); -} + || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && -static FLATTEN bool marshal_Rwstat(struct _marshal_ctx *UNUSED(ctx), struct lib9p_msg_Rwstat *UNUSED(val)) { - return false; -} + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) -static FLATTEN bool marshal_Tsession(struct _marshal_ctx *ctx, struct lib9p_msg_Tsession *val) { - return marshal_8(ctx, &val->key); -} + || ({ uint32_t exp = 154; (((uint32_t)typ) != exp) && -static FLATTEN bool marshal_Rsession(struct _marshal_ctx *UNUSED(ctx), struct lib9p_msg_Rsession *UNUSED(val)) { - return false; + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); }) + ; } -static FLATTEN bool marshal_Tsread(struct _marshal_ctx *ctx, struct lib9p_msg_Tsread *val) { - return 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; - }); -} +static FLATTEN bool validate_Rswrite(struct _validate_ctx *ctx) { + uint32_t size; + uint8_t typ; + uint32_t _size_offset; + return false + || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = 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) -static FLATTEN bool marshal_Rsread(struct _marshal_ctx *ctx, struct lib9p_msg_Rsread *val) { - return marshal_d(ctx, &val->data); -} + || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && -static FLATTEN bool marshal_Tswrite(struct _marshal_ctx *ctx, struct lib9p_msg_Tswrite *val) { - return 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); -} + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) -static FLATTEN bool marshal_Rswrite(struct _marshal_ctx *ctx, struct lib9p_msg_Rswrite *val) { - return marshal_4(ctx, &val->count); -} + || ({ uint32_t exp = 155; (((uint32_t)typ) != exp) && -/* vtables ********************************************************************/ - -#define _MSG(typ) [LIB9P_TYP_##typ] = { \ - .basesize = sizeof(struct lib9p_msg_##typ), \ - .validate = validate_##typ, \ - .unmarshal = (_unmarshal_fn_t)unmarshal_##typ, \ - .marshal = (_marshal_fn_t)marshal_##typ, \ - } - -struct _vtable_version _lib9p_vtables[LIB9P_VER_NUM] = { - [LIB9P_VER_unknown] = { .msgs = { - _MSG(Tversion), - _MSG(Rversion), - _MSG(Rerror), - }}, - [LIB9P_VER_9P2000] = { .msgs = { - _MSG(Tversion), - _MSG(Rversion), - _MSG(Tauth), - _MSG(Rauth), - _MSG(Tattach), - _MSG(Rattach), - _MSG(Rerror), - _MSG(Tflush), - _MSG(Rflush), - _MSG(Twalk), - _MSG(Rwalk), - _MSG(Topen), - _MSG(Ropen), - _MSG(Tcreate), - _MSG(Rcreate), - _MSG(Tread), - _MSG(Rread), - _MSG(Twrite), - _MSG(Rwrite), - _MSG(Tclunk), - _MSG(Rclunk), - _MSG(Tremove), - _MSG(Rremove), - _MSG(Tstat), - _MSG(Rstat), - _MSG(Twstat), - _MSG(Rwstat), - }}, - [LIB9P_VER_9P2000_e] = { .msgs = { - _MSG(Tversion), - _MSG(Rversion), - _MSG(Tauth), - _MSG(Rauth), - _MSG(Tattach), - _MSG(Rattach), - _MSG(Rerror), - _MSG(Tflush), - _MSG(Rflush), - _MSG(Twalk), - _MSG(Rwalk), - _MSG(Topen), - _MSG(Ropen), - _MSG(Tcreate), - _MSG(Rcreate), - _MSG(Tread), - _MSG(Rread), - _MSG(Twrite), - _MSG(Rwrite), - _MSG(Tclunk), - _MSG(Rclunk), - _MSG(Tremove), - _MSG(Rremove), - _MSG(Tstat), - _MSG(Rstat), - _MSG(Twstat), - _MSG(Rwstat), - _MSG(Tsession), - _MSG(Rsession), - _MSG(Tsread), - _MSG(Rsread), - _MSG(Tswrite), - _MSG(Rswrite), - }}, - [LIB9P_VER_9P2000_u] = { .msgs = { - _MSG(Tversion), - _MSG(Rversion), - _MSG(Tauth), - _MSG(Rauth), - _MSG(Tattach), - _MSG(Rattach), - _MSG(Rerror), - _MSG(Tflush), - _MSG(Rflush), - _MSG(Twalk), - _MSG(Rwalk), - _MSG(Topen), - _MSG(Ropen), - _MSG(Tcreate), - _MSG(Rcreate), - _MSG(Tread), - _MSG(Rread), - _MSG(Twrite), - _MSG(Rwrite), - _MSG(Tclunk), - _MSG(Rclunk), - _MSG(Tremove), - _MSG(Rremove), - _MSG(Tstat), - _MSG(Rstat), - _MSG(Twstat), - _MSG(Rwstat), - }}, -}; + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)typ, exp); }) + ; +} +#endif /* defined(CONFIG_9P_ENABLE_9P2000_e) */ diff --git a/lib9p/idl.gen b/lib9p/idl.gen index 1dafef9..1f5e48c 100755 --- a/lib9p/idl.gen +++ b/lib9p/idl.gen @@ -9,19 +9,14 @@ import enum import os.path import re from abc import ABC, abstractmethod -from typing import Callable, Literal, TypeAlias, TypeVar +from typing import Callable, Final, Literal, TypeAlias, TypeVar, cast # This strives to be "general-purpose" in that it just acts on the # *.9p inputs; but (unfortunately?) there are a few special-cases in # this script, marked with "SPECIAL". -T = TypeVar("T") - # Types ######################################################################## -Type: TypeAlias = "Primitive | Number | Bitfield | Struct | Message" - - class Primitive(enum.Enum): u8 = 1 u16 = 2 @@ -133,7 +128,7 @@ class StructMember: # from left-to-right when parsing cnt: str | None = None name: str - typ: Type + typ: 'Type' max: Expr val: Expr @@ -178,6 +173,10 @@ class Message(Struct): return self.members[1].val.tokens[0].val +Type: TypeAlias = Primitive | Number | Bitfield | Struct | Message +#type Type = Primitive | Number | Bitfield | Struct | Message # Change to this once we have Python 3.13 +T = TypeVar("T", Number, Bitfield, Struct, Message) + # Parse *.9p ################################################################### re_priname = "(?:1|2|4|8)" # primitive names @@ -235,7 +234,7 @@ def parse_expr(expr: str) -> Expr: ret = Expr() for tok in re.split("([-+])", expr): if tok == "-" or tok == "+": - ret.tokens += [ExprOp(tok)] + ret.tokens += [ExprOp(cast(Literal["-", "+"], tok))] elif re.fullmatch("[0-9]+", tok): ret.tokens += [ExprLit(int(tok))] else: @@ -292,7 +291,9 @@ re_line_version = f"version\\s+{re_string('version')}" re_line_import = f"from\\s+(?P\\S+)\\s+import\\s+(?P{re_impname}(?:\\s*,\\s*{re_impname})*)" re_line_num = f"num\\s+(?P{re_symname})\\s*=\\s*(?P{re_priname})" re_line_bitfield = f"bitfield\\s+(?P{re_symname})\\s*=\\s*(?P{re_priname})" -re_line_bitfield_ = f"bitfield\\s+(?P{re_symname})\\s*\\+=\\s*{re_string('member')}" +re_line_bitfield_ = ( + f"bitfield\\s+(?P{re_symname})\\s*\\+=\\s*{re_string('member')}" +) re_line_struct = ( f"struct\\s+(?P{re_symname})\\s*(?P\\+?=)\\s*{re_string('members')}" ) @@ -372,6 +373,7 @@ def parse_file( elif m := re.fullmatch(re_line_bitfield, line): bf = Bitfield() bf.name = m.group("name") + bf.in_versions.add(version) prim = env[m.group("prim")] assert isinstance(prim, Primitive) @@ -454,10 +456,9 @@ def c_ver_enum(idprefix: str, ver: str) -> str: return f"{idprefix.upper()}VER_{ver.replace('.', '_')}" -def c_ver_ifdef(idprefix: str, versions: set[str]) -> str: +def c_ver_ifdef(versions: set[str]) -> str: return " || ".join( - f"defined(CONFIG_{idprefix.upper()}ENABLE_{c_ver_enum('', v)})" - for v in sorted(versions) + f"defined(CONFIG_9P_ENABLE_{v.replace('.', '_')})" for v in sorted(versions) ) @@ -485,7 +486,51 @@ def c_typename(idprefix: str, typ: Type) -> str: raise ValueError(f"not a type: {typ.__class__.__name__}") +_ifdef_stack: list[str | None] = [] + + +def ifdef_push(n: int, _newval: str) -> str: + # Grow the stack as needed + global _ifdef_stack + while len(_ifdef_stack) < n: + _ifdef_stack += [None] + + # Set some variables + parentval: str | None = None + for x in _ifdef_stack[:-1]: + if x is not None: + parentval = x + oldval = _ifdef_stack[-1] + newval: str | None = _newval + if newval == parentval: + newval = None + + # Put newval on the stack. + _ifdef_stack[-1] = newval + + # Build output. + ret = "" + if newval != oldval: + if oldval is not None: + ret += f"#endif /* {oldval} */\n" + if newval is not None: + ret += f"#if {newval}\n" + return ret + +def ifdef_pop(n: int) -> str: + global _ifdef_stack + ret = "" + while len(_ifdef_stack) > n: + if _ifdef_stack[-1] is not None: + ret += f"#endif /* {_ifdef_stack[-1]} */\n" + _ifdef_stack = _ifdef_stack[:-1] + return ret + + def gen_h(idprefix: str, versions: set[str], typs: list[Type]) -> str: + global _ifdef_stack + _ifdef_stack = [] + ret = f"""/* Generated by `{' '.join(sys.argv)}`. DO NOT EDIT! */ #ifndef _LIB9P_9P_H_ @@ -495,36 +540,6 @@ def gen_h(idprefix: str, versions: set[str], typs: list[Type]) -> str: #include /* for uint{{n}}_t types */ """ - _ifdef: list[str] = [] - - def push_ifdef(v: str) -> None: - nonlocal _ifdef - nonlocal ret - ret += f"#if {v}\n" - _ifdef += [v] - - def pop_ifdef(n: int) -> None: - nonlocal _ifdef - nonlocal ret - while len(_ifdef) > n: - ret += f"#endif /* {_ifdef[-1]}\n" - _ifdef = _ifdef[:-1] - - def set_ifdef(v: str) -> None: - nonlocal _ifdef - nonlocal ret - if v != _ifdef[-1]: - ret += f"#elif {v}\n" - _ifdef[-1] = v - - def pushorset_ifdef(n: int, v: str) -> None: - nonlocal _ifdef - nonlocal ret - if len(_ifdef) < n: - push_ifdef(v) - else: - set_ifdef(v) - ret += f""" /* versions *******************************************************************/ @@ -534,10 +549,10 @@ enum {idprefix}version {{ verwidth = max(len(v) for v in fullversions) for ver in fullversions: if ver in versions: - pushorset_ifdef(1, c_ver_ifdef(idprefix, {ver})) + ret += ifdef_push(1, c_ver_ifdef({ver})) ret += f"\t{c_ver_enum(idprefix, ver)}," ret += (" " * (verwidth - len(ver))) + ' /* "' + ver.split()[0] + '" */\n' - pop_ifdef(0) + ret += ifdef_pop(0) ret += f"\t{c_ver_enum(idprefix, 'NUM')},\n" ret += "};\n" ret += "\n" @@ -548,7 +563,7 @@ enum {idprefix}version {{ """ for typ in [typ for typ in typs if not isinstance(typ, Message)]: ret += "\n" - pushorset_ifdef(1, c_ver_ifdef(idprefix, typ.in_versions)) + ret += ifdef_push(1, c_ver_ifdef(typ.in_versions)) match typ: case Number(): ret += f"typedef {c_typename(idprefix, typ.prim)} {c_typename(idprefix, typ)};\n" @@ -556,7 +571,7 @@ enum {idprefix}version {{ ret += f"typedef {c_typename(idprefix, typ.prim)} {c_typename(idprefix, typ)};\n" names = [ *reversed( - [typ.bits[n] or f"_UNUSED_{n}" for n in range(0, len(typ.bits))] + [typ.bits[n] or f" {n}" for n in range(0, len(typ.bits))] ), "", *[k for k in typ.names if k not in typ.bits], @@ -567,21 +582,21 @@ enum {idprefix}version {{ for name in names: if name == "": ret += "\n" - continue - pushorset_ifdef( - 2, c_ver_ifdef(idprefix, typ.names[name].in_versions) - ) - if name.startswith("_"): - c_name = f"_{idprefix.upper()}{typ.name.upper()}_{name[1:]}" - else: - c_name = f"{idprefix.upper()}{typ.name.upper()}_{name}" - if name in typ.names: - val = typ.names[name].val + elif name.startswith(" "): + ret += ifdef_push(2, c_ver_ifdef(typ.in_versions)) + sp = ' '*(len('# define ')+len(idprefix)+len(typ.name)+1+namewidth+2-len("/* unused")) + ret += f"/* unused{sp}(({c_typename(idprefix, typ)})(1<<{name[1:]})) */\n" else: - assert name.startswith("_UNUSED_") - val = f"1<<{name[len('_UNUSED_'):]}" - ret += f"#define {c_name}{' '*(namewidth-len(name))} (({c_typename(idprefix, typ)})({val}))\n" - pop_ifdef(1) + ret += ifdef_push(2, c_ver_ifdef(typ.names[name].in_versions)) + if name.startswith("_"): + c_name = f"_{idprefix.upper()}{typ.name.upper()}_{name[1:]}" + else: + c_name = f"{idprefix.upper()}{typ.name.upper()}_{name}" + sp1 = ' ' if _ifdef_stack[-1] else '' + sp2 = ' ' if _ifdef_stack[-1] else ' ' + sp3 = ' '*(2+namewidth-len(name)) + ret += f"#{sp1}define{sp2}{c_name}{sp3}(({c_typename(idprefix, typ)})({typ.names[name].val}))\n" + ret += ifdef_pop(1) case Struct(): typewidth = max(len(c_typename(idprefix, m.typ)) for m in typ.members) @@ -589,14 +604,14 @@ enum {idprefix}version {{ for member in typ.members: if member.val: continue - pushorset_ifdef(2, c_ver_ifdef(idprefix, member.in_versions)) + ret += ifdef_push(2, c_ver_ifdef(member.in_versions)) c_type = c_typename(idprefix, member.typ) if (typ.name in ["d", "s"]) and member.cnt: # SPECIAL c_type = "char" ret += f"\t{c_type.ljust(typewidth)} {'*' if member.cnt else ' '}{member.name};\n" - pop_ifdef(1) + ret += ifdef_pop(1) ret += "};\n" - pop_ifdef(0) + ret += ifdef_pop(0) ret += """ /* messages *******************************************************************/ @@ -605,16 +620,16 @@ enum {idprefix}version {{ ret += f"enum {idprefix}msg_type {{ /* uint8_t */\n" namewidth = max(len(msg.name) for msg in typs if isinstance(msg, Message)) for msg in [msg for msg in typs if isinstance(msg, Message)]: - pushorset_ifdef(1, c_ver_ifdef(idprefix, msg.in_versions)) + ret += ifdef_push(1, c_ver_ifdef(msg.in_versions)) ret += f"\t{idprefix.upper()}TYP_{msg.name.ljust(namewidth)} = {msg.msgid},\n" - pop_ifdef(0) + ret += ifdef_pop(0) ret += "};\n" ret += "\n" ret += f"const char *{idprefix}msg_type_str(enum {idprefix}msg_type);\n" for msg in [msg for msg in typs if isinstance(msg, Message)]: ret += "\n" - pushorset_ifdef(1, c_ver_ifdef(idprefix, msg.in_versions)) + ret += ifdef_push(1, c_ver_ifdef(msg.in_versions)) ret += c_typename(idprefix, msg) + " {" if not msg.members: ret += "};\n" @@ -626,11 +641,11 @@ enum {idprefix}version {{ for member in msg.members: if member.val: continue - pushorset_ifdef(2, c_ver_ifdef(idprefix, member.in_versions)) + ret += ifdef_push(2, c_ver_ifdef(member.in_versions)) ret += f"\t{c_typename(idprefix, member.typ).ljust(typewidth)} {'*' if member.cnt else ' '}{member.name};\n" - pop_ifdef(1) + ret += ifdef_pop(1) ret += "};\n" - pop_ifdef(0) + ret += ifdef_pop(0) return ret @@ -651,6 +666,9 @@ def c_expr(expr: Expr) -> str: def gen_c(idprefix: str, versions: set[str], typs: list[Type]) -> str: + global _ifdef_stack + _ifdef_stack = [] + ret = f"""/* Generated by `{' '.join(sys.argv)}`. DO NOT EDIT! */ #include @@ -664,36 +682,6 @@ def gen_c(idprefix: str, versions: set[str], typs: list[Type]) -> str: #include "internal.h" """ - _ifdef: list[str] = [] - - def push_ifdef(v: str) -> None: - nonlocal _ifdef - nonlocal ret - ret += f"#if {v}\n" - _ifdef += [v] - - def pop_ifdef(n: int) -> None: - nonlocal _ifdef - nonlocal ret - while len(_ifdef) > n: - ret += f"#endif /* {_ifdef[-1]}\n" - _ifdef = _ifdef[:-1] - - def set_ifdef(v: str) -> None: - nonlocal _ifdef - nonlocal ret - if v != _ifdef[-1]: - ret += f"#elif {v}\n" - _ifdef[-1] = v - - def pushorset_ifdef(n: int, v: str) -> None: - nonlocal _ifdef - nonlocal ret - if len(_ifdef) < n: - push_ifdef(v) - else: - set_ifdef(v) - def used(arg: str) -> str: return arg @@ -707,9 +695,10 @@ def gen_c(idprefix: str, versions: set[str], typs: list[Type]) -> str: static const char *version_strs[{c_ver_enum(idprefix, 'NUM')}] = {{ """ for ver in ["unknown", *sorted(versions)]: - pushorset_ifdef(1, c_ver_ifdef(idprefix, {ver})) + if ver in versions: + ret += ifdef_push(1, c_ver_ifdef({ver})) ret += f'\t[{c_ver_enum(idprefix, ver)}] = "{ver}",\n' - pop_ifdef(0) + ret += ifdef_pop(0) ret += "};\n" ret += f""" const char *{idprefix}version_str(enum {idprefix}version ver) {{ @@ -774,7 +763,7 @@ static ALWAYS_INLINE bool _validate_list(struct _validate_ctx *ctx, inline = "FLATTEN" if isinstance(typ, Message) else "ALWAYS_INLINE" argfn = unused if (isinstance(typ, Struct) and not typ.members) else used ret += "\n" - pushorset_ifdef(1, c_ver_ifdef(idprefix, typ.in_versions)) + ret += ifdef_push(1, c_ver_ifdef(typ.in_versions)) ret += f"static {inline} bool validate_{typ.name}(struct _validate_ctx *{argfn('ctx')}) {{\n" if typ.name == "d": # SPECIAL @@ -811,7 +800,7 @@ static ALWAYS_INLINE bool _validate_list(struct _validate_ctx *ctx, ret += f"\tstatic const {c_typename(idprefix, typ)} masks[{c_ver_enum(idprefix, 'NUM')}] = {{\n" verwidth = max(len(ver) for ver in versions) for ver in sorted(versions): - pushorset_ifdef(2, c_ver_ifdef(idprefix, {ver})) + ret += ifdef_push(2, c_ver_ifdef({ver})) ret += ( f"\t\t[{c_ver_enum(idprefix, ver)}]{' '*(verwidth-len(ver))} = 0b" + "".join( @@ -820,7 +809,7 @@ static ALWAYS_INLINE bool _validate_list(struct _validate_ctx *ctx, ) + ",\n" ) - pop_ifdef(1) + ret += ifdef_pop(1) ret += "\t};\n" ret += ( f"\t{c_typename(idprefix, typ)} mask = masks[ctx->ctx->version];\n" @@ -839,10 +828,10 @@ static ALWAYS_INLINE bool _validate_list(struct _validate_ctx *ctx, # Pass 1 for member in typ.members: - pushorset_ifdef(2, c_ver_ifdef(idprefix, member.in_versions)) if member.max or member.val: + ret += ifdef_push(2, c_ver_ifdef(member.in_versions)) ret += f"\t{c_typename(idprefix, member.typ)} {member.name};\n" - pop_ifdef(1) + ret += ifdef_pop(1) # Pass 2 mark_offset: set[str] = set() @@ -857,8 +846,8 @@ static ALWAYS_INLINE bool _validate_list(struct _validate_ctx *ctx, ret += "\treturn false\n" prev_size: int | None = None for member in typ.members: - pushorset_ifdef(2, c_ver_ifdef(idprefix, member.in_versions)) - ret += f"\n\t|| " + ret += ifdef_push(2, c_ver_ifdef(member.in_versions)) + ret += f"\t || " if member.in_versions != typ.in_versions: ret += "( " + c_ver_cond(idprefix, member.in_versions) + " && " if member.cnt is not None: @@ -879,23 +868,24 @@ static ALWAYS_INLINE bool _validate_list(struct _validate_ctx *ctx, ret += f" || ({{ {member.name} = decode_u{bits}le(&ctx->net_bytes[ctx->net_offset-{bytes}]); false; }}))" if member.in_versions != typ.in_versions: ret += " )" + ret += "\n" prev_size = member.static_size # Pass 4 for member in typ.members: if member.max: - pushorset_ifdef(2, c_ver_ifdef(idprefix, member.in_versions)) - ret += f"\n\t|| ({{ uint32_t max = {c_expr(member.max)}; (((uint32_t){member.name}) > max) &&\n" - ret += f'\n\t lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "{member.name} value too large (%"PRIu32" > %"PRIu32")", {member.name}, max); }})\n' + ret += ifdef_push(2, c_ver_ifdef(member.in_versions)) + ret += f"\n\t || ({{ uint32_t max = {c_expr(member.max)}; (((uint32_t){member.name}) > max) &&\n" + ret += f'\n\t lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "{member.name} value too large (%"PRIu32" > %"PRIu32")", {member.name}, max); }})\n' if member.val: - pushorset_ifdef(2, c_ver_ifdef(idprefix, member.in_versions)) - ret += f"\n\t|| ({{ uint32_t exp = {c_expr(member.val)}; (((uint32_t){member.name}) != exp) &&\n" - ret += f'\n\t lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "{member.name} value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t){member.name}, exp); }})\n' + ret += ifdef_push(2, c_ver_ifdef(member.in_versions)) + ret += f"\n\t || ({{ uint32_t exp = {c_expr(member.val)}; (((uint32_t){member.name}) != exp) &&\n" + ret += f'\n\t lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "{member.name} value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t){member.name}, exp); }})\n' - pop_ifdef(1) - ret += "\t;\n" + ret += ifdef_pop(1) + ret += "\t ;\n" ret += "}\n" - pop_ifdef(0) + ret += ifdef_pop(0) # # unmarshal_* ############################################################## # ret += """ diff --git a/lib9p/idl/01-9P2000.9p b/lib9p/idl/01-9P2000.9p index 680d243..426a8c6 100644 --- a/lib9p/idl/01-9P2000.9p +++ b/lib9p/idl/01-9P2000.9p @@ -84,7 +84,7 @@ bitfield qt = 1 # incremented every time the file is modified. # # - "type" indicates "whether the file is a directory, append-only -# file, etc."; is an instance of the qid_type bitfield. +# file, etc."; is an instance of the qt bitfield. struct qid = "type[qt] vers[4] path[8]" # stat - file status diff --git a/lib9p/include/lib9p/9p.generated.h b/lib9p/include/lib9p/9p.generated.h index 6d44472..2fb7a3e 100644 --- a/lib9p/include/lib9p/9p.generated.h +++ b/lib9p/include/lib9p/9p.generated.h @@ -1,4 +1,4 @@ -/* Generated by `./lib9p/9p.gen lib9p/9P2000.txt lib9p/9P2000.u.txt lib9p/9P2000.e.txt`. DO NOT EDIT! */ +/* Generated by `./lib9p/idl.gen lib9p/idl/01-9P2000.9p lib9p/idl/02-9P2000.e.9p lib9p/idl/02-9P2000.u.9p`. DO NOT EDIT! */ #ifndef _LIB9P_9P_H_ # error Do not include directly; include instead @@ -10,9 +10,15 @@ enum lib9p_version { LIB9P_VER_unknown = 0, /* "unknown" */ +#if defined(CONFIG_9P_ENABLE_9P2000) LIB9P_VER_9P2000, /* "9P2000" */ +#endif /* defined(CONFIG_9P_ENABLE_9P2000) */ +#if defined(CONFIG_9P_ENABLE_9P2000_e) LIB9P_VER_9P2000_e, /* "9P2000.e" */ +#endif /* defined(CONFIG_9P_ENABLE_9P2000_e) */ +#if defined(CONFIG_9P_ENABLE_9P2000_u) LIB9P_VER_9P2000_u, /* "9P2000.u" */ +#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */ LIB9P_VER_NUM, }; @@ -20,71 +26,10 @@ const char *lib9p_version_str(enum lib9p_version); /* non-message types **********************************************************/ -typedef uint32_t lib9p_dm_t; - -#define LIB9P_DM_DIR ((lib9p_dm_t)(1<<31)) -#define LIB9P_DM_APPEND ((lib9p_dm_t)(1<<30)) -#define LIB9P_DM_EXCL ((lib9p_dm_t)(1<<29)) -#define _LIB9P_DM_PLAN9_MOUNT ((lib9p_dm_t)(1<<28)) -#define LIB9P_DM_AUTH ((lib9p_dm_t)(1<<27)) -#define LIB9P_DM_TMP ((lib9p_dm_t)(1<<26)) -#define _LIB9P_DM_UNUSED_25 ((lib9p_dm_t)(1<<25)) -#define _LIB9P_DM_UNUSED_24 ((lib9p_dm_t)(1<<24)) -#define LIB9P_DM_DEVICE ((lib9p_dm_t)(1<<23)) /* 9P2000.u */ -#define _LIB9P_DM_UNUSED_22 ((lib9p_dm_t)(1<<22)) -#define LIB9P_DM_NAMEDPIPE ((lib9p_dm_t)(1<<21)) /* 9P2000.u */ -#define LIB9P_DM_SOCKET ((lib9p_dm_t)(1<<20)) /* 9P2000.u */ -#define LIB9P_DM_SETUID ((lib9p_dm_t)(1<<19)) /* 9P2000.u */ -#define LIB9P_DM_SETGID ((lib9p_dm_t)(1<<18)) /* 9P2000.u */ -#define _LIB9P_DM_UNUSED_17 ((lib9p_dm_t)(1<<17)) -#define _LIB9P_DM_UNUSED_16 ((lib9p_dm_t)(1<<16)) -#define _LIB9P_DM_UNUSED_15 ((lib9p_dm_t)(1<<15)) -#define _LIB9P_DM_UNUSED_14 ((lib9p_dm_t)(1<<14)) -#define _LIB9P_DM_UNUSED_13 ((lib9p_dm_t)(1<<13)) -#define _LIB9P_DM_UNUSED_12 ((lib9p_dm_t)(1<<12)) -#define _LIB9P_DM_UNUSED_11 ((lib9p_dm_t)(1<<11)) -#define _LIB9P_DM_UNUSED_10 ((lib9p_dm_t)(1<<10)) -#define _LIB9P_DM_UNUSED_9 ((lib9p_dm_t)(1<<9)) -#define LIB9P_DM_OWNER_R ((lib9p_dm_t)(1<<8)) -#define LIB9P_DM_OWNER_W ((lib9p_dm_t)(1<<7)) -#define LIB9P_DM_OWNER_X ((lib9p_dm_t)(1<<6)) -#define LIB9P_DM_GROUP_R ((lib9p_dm_t)(1<<5)) -#define LIB9P_DM_GROUP_W ((lib9p_dm_t)(1<<4)) -#define LIB9P_DM_GROUP_X ((lib9p_dm_t)(1<<3)) -#define LIB9P_DM_OTHER_R ((lib9p_dm_t)(1<<2)) -#define LIB9P_DM_OTHER_W ((lib9p_dm_t)(1<<1)) -#define LIB9P_DM_OTHER_X ((lib9p_dm_t)(1<<0)) - -#define LIB9P_DM_PERM ((lib9p_dm_t)(0777)) - -typedef uint8_t lib9p_qt_t; - -#define LIB9P_QT_DIR ((lib9p_qt_t)(1<<7)) -#define LIB9P_QT_APPEND ((lib9p_qt_t)(1<<6)) -#define LIB9P_QT_EXCL ((lib9p_qt_t)(1<<5)) -#define _LIB9P_QT_PLAN9_MOUNT ((lib9p_qt_t)(1<<4)) -#define LIB9P_QT_AUTH ((lib9p_qt_t)(1<<3)) -#define LIB9P_QT_TMP ((lib9p_qt_t)(1<<2)) -#define LIB9P_QT_SYMLINK ((lib9p_qt_t)(1<<1)) /* 9P2000.u */ -#define _LIB9P_QT_UNUSED_0 ((lib9p_qt_t)(1<<0)) - -#define LIB9P_QT_FILE ((lib9p_qt_t)(0)) - -typedef uint8_t lib9p_o_t; - -#define _LIB9P_O_UNUSED_7 ((lib9p_o_t)(1<<7)) -#define LIB9P_O_RCLOSE ((lib9p_o_t)(1<<6)) -#define _LIB9P_O_UNUSED_5 ((lib9p_o_t)(1<<5)) -#define LIB9P_O_TRUNC ((lib9p_o_t)(1<<4)) -#define _LIB9P_O_UNUSED_3 ((lib9p_o_t)(1<<3)) -#define _LIB9P_O_UNUSED_2 ((lib9p_o_t)(1<<2)) -#define LIB9P_O_rwx_1 ((lib9p_o_t)(1<<1)) -#define LIB9P_O_rwx_0 ((lib9p_o_t)(1<<0)) +#if defined(CONFIG_9P_ENABLE_9P2000) || defined(CONFIG_9P_ENABLE_9P2000_e) || defined(CONFIG_9P_ENABLE_9P2000_u) +typedef uint16_t lib9p_tag_t; -#define LIB9P_O_READ ((lib9p_o_t)(0)) -#define LIB9P_O_WRITE ((lib9p_o_t)(1)) -#define LIB9P_O_RDWR ((lib9p_o_t)(2)) -#define LIB9P_O_EXEC ((lib9p_o_t)(3)) +typedef uint32_t lib9p_fid_t; struct lib9p_d { uint32_t len; @@ -96,6 +41,62 @@ struct lib9p_s { char *utf8; }; +typedef uint32_t lib9p_dm_t; + +#define LIB9P_DM_DIR ((lib9p_dm_t)(1<<31)) +#define LIB9P_DM_APPEND ((lib9p_dm_t)(1<<30)) +#define LIB9P_DM_EXCL ((lib9p_dm_t)(1<<29)) +#define _LIB9P_DM_PLAN9_MOUNT ((lib9p_dm_t)(1<<28)) +#define LIB9P_DM_AUTH ((lib9p_dm_t)(1<<27)) +#define LIB9P_DM_TMP ((lib9p_dm_t)(1<<26)) +/* unused ((lib9p_dm_t)(1<<25)) */ +/* unused ((lib9p_dm_t)(1<<24)) */ +#if defined(CONFIG_9P_ENABLE_9P2000_u) +# define LIB9P_DM_DEVICE ((lib9p_dm_t)(1<<23)) +#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */ +/* unused ((lib9p_dm_t)(1<<22)) */ +#if defined(CONFIG_9P_ENABLE_9P2000_u) +# define LIB9P_DM_NAMEDPIPE ((lib9p_dm_t)(1<<21)) +# define LIB9P_DM_SOCKET ((lib9p_dm_t)(1<<20)) +# define LIB9P_DM_SETUID ((lib9p_dm_t)(1<<19)) +# define LIB9P_DM_SETGID ((lib9p_dm_t)(1<<18)) +#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */ +/* unused ((lib9p_dm_t)(1<<17)) */ +/* unused ((lib9p_dm_t)(1<<16)) */ +/* unused ((lib9p_dm_t)(1<<15)) */ +/* unused ((lib9p_dm_t)(1<<14)) */ +/* unused ((lib9p_dm_t)(1<<13)) */ +/* unused ((lib9p_dm_t)(1<<12)) */ +/* unused ((lib9p_dm_t)(1<<11)) */ +/* unused ((lib9p_dm_t)(1<<10)) */ +/* unused ((lib9p_dm_t)(1<<9)) */ +#define LIB9P_DM_OWNER_R ((lib9p_dm_t)(1<<8)) +#define LIB9P_DM_OWNER_W ((lib9p_dm_t)(1<<7)) +#define LIB9P_DM_OWNER_X ((lib9p_dm_t)(1<<6)) +#define LIB9P_DM_GROUP_R ((lib9p_dm_t)(1<<5)) +#define LIB9P_DM_GROUP_W ((lib9p_dm_t)(1<<4)) +#define LIB9P_DM_GROUP_X ((lib9p_dm_t)(1<<3)) +#define LIB9P_DM_OTHER_R ((lib9p_dm_t)(1<<2)) +#define LIB9P_DM_OTHER_W ((lib9p_dm_t)(1<<1)) +#define LIB9P_DM_OTHER_X ((lib9p_dm_t)(1<<0)) + +#define LIB9P_DM_PERM ((lib9p_dm_t)(0777)) + +typedef uint8_t lib9p_qt_t; + +#define LIB9P_QT_DIR ((lib9p_qt_t)(1<<7)) +#define LIB9P_QT_APPEND ((lib9p_qt_t)(1<<6)) +#define LIB9P_QT_EXCL ((lib9p_qt_t)(1<<5)) +#define _LIB9P_QT_PLAN9_MOUNT ((lib9p_qt_t)(1<<4)) +#define LIB9P_QT_AUTH ((lib9p_qt_t)(1<<3)) +#define LIB9P_QT_TMP ((lib9p_qt_t)(1<<2)) +#if defined(CONFIG_9P_ENABLE_9P2000_u) +# define LIB9P_QT_SYMLINK ((lib9p_qt_t)(1<<1)) +#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */ +/* unused ((lib9p_qt_t)(1<<0)) */ + +#define LIB9P_QT_FILE ((lib9p_qt_t)(0)) + struct lib9p_qid { lib9p_qt_t type; uint32_t vers; @@ -114,15 +115,35 @@ struct lib9p_stat { struct lib9p_s file_owner_uid; struct lib9p_s file_owner_gid; struct lib9p_s file_last_modified_uid; - struct lib9p_s file_extension; /* 9P2000.u */ - uint32_t file_owner_n_uid; /* 9P2000.u */ - uint32_t file_owner_n_gid; /* 9P2000.u */ - uint32_t file_last_modified_n_uid; /* 9P2000.u */ +#if defined(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 /* defined(CONFIG_9P_ENABLE_9P2000_u) */ }; +typedef uint8_t lib9p_o_t; + +/* unused ((lib9p_o_t)(1<<7)) */ +#define LIB9P_O_RCLOSE ((lib9p_o_t)(1<<6)) +/* unused ((lib9p_o_t)(1<<5)) */ +#define LIB9P_O_TRUNC ((lib9p_o_t)(1<<4)) +/* unused ((lib9p_o_t)(1<<3)) */ +/* unused ((lib9p_o_t)(1<<2)) */ +#define LIB9P_O_rwx_1 ((lib9p_o_t)(1<<1)) +#define LIB9P_O_rwx_0 ((lib9p_o_t)(1<<0)) + +#define LIB9P_O_READ ((lib9p_o_t)(0)) +#define LIB9P_O_WRITE ((lib9p_o_t)(1)) +#define LIB9P_O_RDWR ((lib9p_o_t)(2)) +#define LIB9P_O_EXEC ((lib9p_o_t)(3)) +#endif /* defined(CONFIG_9P_ENABLE_9P2000) || defined(CONFIG_9P_ENABLE_9P2000_e) || defined(CONFIG_9P_ENABLE_9P2000_u) */ + /* messages *******************************************************************/ enum lib9p_msg_type { /* uint8_t */ +#if defined(CONFIG_9P_ENABLE_9P2000) || defined(CONFIG_9P_ENABLE_9P2000_e) || defined(CONFIG_9P_ENABLE_9P2000_u) LIB9P_TYP_Tversion = 100, LIB9P_TYP_Rversion = 101, LIB9P_TYP_Tauth = 102, @@ -150,170 +171,215 @@ enum lib9p_msg_type { /* uint8_t */ LIB9P_TYP_Rstat = 125, LIB9P_TYP_Twstat = 126, LIB9P_TYP_Rwstat = 127, - LIB9P_TYP_Tsession = 150, /* 9P2000.e */ - LIB9P_TYP_Rsession = 151, /* 9P2000.e */ - LIB9P_TYP_Tsread = 152, /* 9P2000.e */ - LIB9P_TYP_Rsread = 153, /* 9P2000.e */ - LIB9P_TYP_Tswrite = 154, /* 9P2000.e */ - LIB9P_TYP_Rswrite = 155, /* 9P2000.e */ +#endif /* defined(CONFIG_9P_ENABLE_9P2000) || defined(CONFIG_9P_ENABLE_9P2000_e) || defined(CONFIG_9P_ENABLE_9P2000_u) */ +#if defined(CONFIG_9P_ENABLE_9P2000_e) + LIB9P_TYP_Tsession = 150, + LIB9P_TYP_Rsession = 151, + LIB9P_TYP_Tsread = 152, + LIB9P_TYP_Rsread = 153, + LIB9P_TYP_Tswrite = 154, + LIB9P_TYP_Rswrite = 155, +#endif /* defined(CONFIG_9P_ENABLE_9P2000_e) */ }; const char *lib9p_msg_type_str(enum lib9p_msg_type); +#if defined(CONFIG_9P_ENABLE_9P2000) || defined(CONFIG_9P_ENABLE_9P2000_e) || defined(CONFIG_9P_ENABLE_9P2000_u) struct lib9p_msg_Tversion { + lib9p_tag_t tag; uint32_t max_msg_size; struct lib9p_s version; }; struct lib9p_msg_Rversion { + lib9p_tag_t tag; uint32_t max_msg_size; struct lib9p_s version; }; struct lib9p_msg_Tauth { - uint32_t afid; + lib9p_tag_t tag; + lib9p_fid_t afid; struct lib9p_s uname; struct lib9p_s aname; - uint32_t n_uname; /* 9P2000.u */ +#if defined(CONFIG_9P_ENABLE_9P2000_u) + uint32_t n_uname; +#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */ }; struct lib9p_msg_Rauth { + lib9p_tag_t tag; struct lib9p_qid aqid; }; struct lib9p_msg_Tattach { - uint32_t fid; - uint32_t afid; + lib9p_tag_t tag; + lib9p_fid_t fid; + lib9p_fid_t afid; struct lib9p_s uname; struct lib9p_s aname; - uint32_t n_uname; /* 9P2000.u */ +#if defined(CONFIG_9P_ENABLE_9P2000_u) + uint32_t n_uname; +#endif /* defined(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; - uint32_t errno; /* 9P2000.u */ +#if defined(CONFIG_9P_ENABLE_9P2000_u) + uint32_t errno; +#endif /* defined(CONFIG_9P_ENABLE_9P2000_u) */ }; struct lib9p_msg_Tflush { - uint16_t oldtag; + lib9p_tag_t tag; + uint16_t oldtag; }; -struct lib9p_msg_Rflush {}; +struct lib9p_msg_Rflush { + lib9p_tag_t tag; +}; struct lib9p_msg_Twalk { - uint32_t fid; - uint32_t newfid; + lib9p_tag_t tag; + lib9p_fid_t fid; + lib9p_fid_t newfid; uint16_t nwname; struct lib9p_s *wname; }; struct lib9p_msg_Rwalk { + lib9p_tag_t tag; uint16_t nwqid; struct lib9p_qid *wqid; }; struct lib9p_msg_Topen { - uint32_t fid; - lib9p_o_t mode; + lib9p_tag_t tag; + lib9p_fid_t fid; + lib9p_o_t mode; }; struct lib9p_msg_Ropen { + lib9p_tag_t tag; struct lib9p_qid qid; uint32_t iounit; }; struct lib9p_msg_Tcreate { - uint32_t fid; + lib9p_tag_t tag; + lib9p_fid_t fid; struct lib9p_s name; lib9p_dm_t perm; lib9p_o_t mode; }; struct lib9p_msg_Rcreate { + lib9p_tag_t tag; struct lib9p_qid qid; uint32_t iounit; }; struct lib9p_msg_Tread { - uint32_t fid; - uint64_t offset; - uint32_t count; + 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 { - uint32_t fid; + lib9p_tag_t tag; + lib9p_fid_t fid; uint64_t offset; struct lib9p_d data; }; struct lib9p_msg_Rwrite { - uint32_t count; + lib9p_tag_t tag; + uint32_t count; }; struct lib9p_msg_Tclunk { - uint32_t fid; + lib9p_tag_t tag; + lib9p_fid_t fid; }; -struct lib9p_msg_Rclunk {}; +struct lib9p_msg_Rclunk { + lib9p_tag_t tag; +}; struct lib9p_msg_Tremove { - uint32_t fid; + lib9p_tag_t tag; + lib9p_fid_t fid; }; -struct lib9p_msg_Rremove {}; +struct lib9p_msg_Rremove { + lib9p_tag_t tag; +}; struct lib9p_msg_Tstat { - uint32_t fid; + lib9p_tag_t tag; + lib9p_fid_t fid; }; struct lib9p_msg_Rstat { + lib9p_tag_t tag; struct lib9p_stat stat; }; struct lib9p_msg_Twstat { - uint32_t fid; + lib9p_tag_t tag; + lib9p_fid_t fid; struct lib9p_stat stat; }; -struct lib9p_msg_Rwstat {}; +struct lib9p_msg_Rwstat { + lib9p_tag_t tag; +}; -/* 9P2000.e */ +#endif /* defined(CONFIG_9P_ENABLE_9P2000) || defined(CONFIG_9P_ENABLE_9P2000_e) || defined(CONFIG_9P_ENABLE_9P2000_u) */ +#if defined(CONFIG_9P_ENABLE_9P2000_e) struct lib9p_msg_Tsession { - uint64_t key; + lib9p_tag_t tag; + uint64_t key; }; -/* 9P2000.e */ -struct lib9p_msg_Rsession {}; +struct lib9p_msg_Rsession { + lib9p_tag_t tag; +}; -/* 9P2000.e */ struct lib9p_msg_Tsread { + lib9p_tag_t tag; uint32_t fid; uint16_t nwname; struct lib9p_s *wname; }; -/* 9P2000.e */ struct lib9p_msg_Rsread { + lib9p_tag_t tag; struct lib9p_d data; }; -/* 9P2000.e */ struct lib9p_msg_Tswrite { + lib9p_tag_t tag; uint32_t fid; uint16_t nwname; struct lib9p_s *wname; struct lib9p_d data; }; -/* 9P2000.e */ struct lib9p_msg_Rswrite { - uint32_t count; + lib9p_tag_t tag; + uint32_t count; }; +#endif /* defined(CONFIG_9P_ENABLE_9P2000_e) */ -- cgit v1.2.3-2-g168b