diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-03-20 18:58:21 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-03-22 19:32:44 -0600 |
commit | 6322636192c57a472176c65257b2b8487f79434e (patch) | |
tree | 9560a18fc2c0ea09fa35715541be24c11792ed23 | |
parent | 8f98e46ecb901df499010e77e17d044ce2f3f3a4 (diff) |
lib9p: idl: 9P2000.L: Document all the bitfields and enums
-rw-r--r-- | lib9p/9p.generated.c | 588 | ||||
-rw-r--r-- | lib9p/idl/2010-9P2000.L.9p | 218 | ||||
-rw-r--r-- | lib9p/include/lib9p/9p.generated.h | 274 | ||||
-rw-r--r-- | lib9p/tests/test_compile.c | 60 |
4 files changed, 759 insertions, 381 deletions
diff --git a/lib9p/9p.generated.c b/lib9p/9p.generated.c index 955429e..8d6c82f 100644 --- a/lib9p/9p.generated.c +++ b/lib9p/9p.generated.c @@ -333,6 +333,38 @@ static const lib9p_o_t o_masks[LIB9P_VER_NUM] = { #endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ #if CONFIG_9P_ENABLE_9P2000_L +static const lib9p_lo_t lo_masks[LIB9P_VER_NUM] = { +#if CONFIG_9P_ENABLE_9P2000 + [LIB9P_VER_9P2000] = 0b00000000000000000000000000000000, +#endif /* CONFIG_9P_ENABLE_9P2000 */ + [LIB9P_VER_9P2000_L] = 0b00000000000111111111111111000011, +#if CONFIG_9P_ENABLE_9P2000_e + [LIB9P_VER_9P2000_e] = 0b00000000000000000000000000000000, +#endif /* CONFIG_9P_ENABLE_9P2000_e */ +#if CONFIG_9P_ENABLE_9P2000_p9p + [LIB9P_VER_9P2000_p9p] = 0b00000000000000000000000000000000, +#endif /* CONFIG_9P_ENABLE_9P2000_p9p */ +#if CONFIG_9P_ENABLE_9P2000_u + [LIB9P_VER_9P2000_u] = 0b00000000000000000000000000000000, +#endif /* CONFIG_9P_ENABLE_9P2000_u */ +}; + +static const lib9p_mode_t mode_masks[LIB9P_VER_NUM] = { +#if CONFIG_9P_ENABLE_9P2000 + [LIB9P_VER_9P2000] = 0b00000000000000000000000000000000, +#endif /* CONFIG_9P_ENABLE_9P2000 */ + [LIB9P_VER_9P2000_L] = 0b00000000000000001111111111111111, +#if CONFIG_9P_ENABLE_9P2000_e + [LIB9P_VER_9P2000_e] = 0b00000000000000000000000000000000, +#endif /* CONFIG_9P_ENABLE_9P2000_e */ +#if CONFIG_9P_ENABLE_9P2000_p9p + [LIB9P_VER_9P2000_p9p] = 0b00000000000000000000000000000000, +#endif /* CONFIG_9P_ENABLE_9P2000_p9p */ +#if CONFIG_9P_ENABLE_9P2000_u + [LIB9P_VER_9P2000_u] = 0b00000000000000000000000000000000, +#endif /* CONFIG_9P_ENABLE_9P2000_u */ +}; + static const lib9p_getattr_t getattr_masks[LIB9P_VER_NUM] = { #if CONFIG_9P_ENABLE_9P2000 [LIB9P_VER_9P2000] = 0b0000000000000000000000000000000000000000000000000000000000000000, @@ -486,6 +518,38 @@ LM_ALWAYS_INLINE static bool validate_errno(struct _validate_ctx *ctx) { #endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ #if CONFIG_9P_ENABLE_9P2000_L +LM_ALWAYS_INLINE static bool validate_super_magic(struct _validate_ctx *ctx) { + return validate_4(ctx); +} + +LM_ALWAYS_INLINE static bool validate_lo(struct _validate_ctx *ctx) { + if (validate_4(ctx)) + return true; + lib9p_lo_t mask = lo_masks[ctx->ctx->version]; + lib9p_lo_t val = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); + if (val & ~mask) + return lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "unknown bits in lo bitfield: %#04"PRIx32, val & ~mask); + return false; +} + +LM_ALWAYS_INLINE static bool validate_dt(struct _validate_ctx *ctx) { + return validate_1(ctx); +} + +LM_ALWAYS_INLINE static bool validate_mode(struct _validate_ctx *ctx) { + if (validate_4(ctx)) + return true; + lib9p_mode_t mask = mode_masks[ctx->ctx->version]; + lib9p_mode_t val = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); + if (val & ~mask) + return lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "unknown bits in mode bitfield: %#04"PRIx32, val & ~mask); + return false; +} + +LM_ALWAYS_INLINE static bool validate_b4(struct _validate_ctx *ctx) { + return validate_4(ctx); +} + LM_ALWAYS_INLINE static bool validate_getattr(struct _validate_ctx *ctx) { if (validate_8(ctx)) return true; @@ -645,30 +709,6 @@ LM_FLATTEN static bool validate_Rwstat(struct _validate_ctx *ctx) { #endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ #if CONFIG_9P_ENABLE_9P2000_L -LM_FLATTEN static bool validate_Rstatfs(struct _validate_ctx *ctx) { - uint32_t size; - uint8_t typ; - uint32_t _size_offset; - return false - || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; })) - || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; })) - || validate_tag(ctx) - || validate_4(ctx) - || validate_4(ctx) - || validate_8(ctx) - || validate_8(ctx) - || validate_8(ctx) - || validate_8(ctx) - || validate_8(ctx) - || validate_8(ctx) - || validate_4(ctx) - || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && - lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) - || ({ uint8_t exp = 9; (((uint8_t)typ) != exp) && - lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); }) - ; -} - LM_FLATTEN static bool validate_Rrename(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; @@ -994,23 +1034,6 @@ LM_FLATTEN static bool validate_Tstatfs(struct _validate_ctx *ctx) { ; } -LM_FLATTEN static bool validate_Tlopen(struct _validate_ctx *ctx) { - uint32_t size; - uint8_t typ; - uint32_t _size_offset; - return false - || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; })) - || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; })) - || validate_tag(ctx) - || validate_fid(ctx) - || validate_4(ctx) - || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && - lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) - || ({ uint8_t exp = 12; (((uint8_t)typ) != exp) && - lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); }) - ; -} - LM_FLATTEN static bool validate_Treadlink(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; @@ -1045,23 +1068,6 @@ LM_FLATTEN static bool validate_Treaddir(struct _validate_ctx *ctx) { ; } -LM_FLATTEN static bool validate_Tfsync(struct _validate_ctx *ctx) { - uint32_t size; - uint8_t typ; - uint32_t _size_offset; - return false - || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; })) - || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; })) - || validate_tag(ctx) - || validate_fid(ctx) - || validate_4(ctx) - || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && - lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) - || ({ uint8_t exp = 50; (((uint8_t)typ) != exp) && - lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); }) - ; -} - #endif /* CONFIG_9P_ENABLE_9P2000_L */ #if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u LM_FLATTEN static bool validate_Tversion(struct _validate_ctx *ctx) { @@ -1193,47 +1199,6 @@ LM_FLATTEN static bool validate_Txattrcreate(struct _validate_ctx *ctx) { ; } -LM_FLATTEN static bool validate_Tgetlock(struct _validate_ctx *ctx) { - uint32_t size; - uint8_t typ; - uint32_t _size_offset; - return false - || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; })) - || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; })) - || validate_tag(ctx) - || validate_fid(ctx) - || validate_1(ctx) - || validate_8(ctx) - || validate_8(ctx) - || validate_4(ctx) - || validate_s(ctx) - || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && - lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) - || ({ uint8_t exp = 54; (((uint8_t)typ) != exp) && - lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); }) - ; -} - -LM_FLATTEN static bool validate_Rgetlock(struct _validate_ctx *ctx) { - uint32_t size; - uint8_t typ; - uint32_t _size_offset; - return false - || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; })) - || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; })) - || validate_tag(ctx) - || validate_1(ctx) - || validate_8(ctx) - || validate_8(ctx) - || validate_4(ctx) - || validate_s(ctx) - || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && - lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) - || ({ uint8_t exp = 55; (((uint8_t)typ) != exp) && - lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); }) - ; -} - LM_FLATTEN static bool validate_Tlink(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; @@ -1387,7 +1352,7 @@ LM_FLATTEN static bool validate_Tattach(struct _validate_ctx *ctx) { #endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ #if CONFIG_9P_ENABLE_9P2000_L -LM_FLATTEN static bool validate_Tlcreate(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Tsymlink(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -1397,17 +1362,18 @@ LM_FLATTEN static bool validate_Tlcreate(struct _validate_ctx *ctx) { || validate_tag(ctx) || validate_fid(ctx) || validate_s(ctx) - || validate_4(ctx) - || validate_4(ctx) + || validate_s(ctx) || validate_nuid(ctx) || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) - || ({ uint8_t exp = 14; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 16; (((uint8_t)typ) != exp) && lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); }) ; } -LM_FLATTEN static bool validate_Tsymlink(struct _validate_ctx *ctx) { +#endif /* CONFIG_9P_ENABLE_9P2000_L */ +#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u +LM_FLATTEN static bool validate_Topen(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -1416,17 +1382,15 @@ LM_FLATTEN static bool validate_Tsymlink(struct _validate_ctx *ctx) { || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; })) || validate_tag(ctx) || validate_fid(ctx) - || validate_s(ctx) - || validate_s(ctx) - || validate_nuid(ctx) + || validate_o(ctx) || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) - || ({ uint8_t exp = 16; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 112; (((uint8_t)typ) != exp) && lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); }) ; } -LM_FLATTEN static bool validate_Tmknod(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Tcreate(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -1436,18 +1400,18 @@ LM_FLATTEN static bool validate_Tmknod(struct _validate_ctx *ctx) { || validate_tag(ctx) || validate_fid(ctx) || validate_s(ctx) - || validate_4(ctx) - || validate_4(ctx) - || validate_4(ctx) - || validate_nuid(ctx) + || validate_dm(ctx) + || validate_o(ctx) || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) - || ({ uint8_t exp = 18; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 114; (((uint8_t)typ) != exp) && lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); }) ; } -LM_FLATTEN static bool validate_Tmkdir(struct _validate_ctx *ctx) { +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_9P2000_p9p +LM_FLATTEN static bool validate_Topenfd(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -1456,19 +1420,78 @@ LM_FLATTEN static bool validate_Tmkdir(struct _validate_ctx *ctx) { || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; })) || validate_tag(ctx) || validate_fid(ctx) + || validate_o(ctx) + || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) + || ({ uint8_t exp = 98; (((uint8_t)typ) != exp) && + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); }) + ; +} + +#endif /* CONFIG_9P_ENABLE_9P2000_p9p */ +#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u +LM_FLATTEN static bool validate_Rerror(struct _validate_ctx *ctx) { + uint32_t size; + uint8_t typ; + uint32_t _size_offset; + return false + || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; })) + || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; })) + || validate_tag(ctx) || validate_s(ctx) +#if CONFIG_9P_ENABLE_9P2000_u + || ( is_ver(ctx, 9P2000_u) && validate_errno(ctx) ) +#endif /* CONFIG_9P_ENABLE_9P2000_u */ + || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) + || ({ uint8_t exp = 107; (((uint8_t)typ) != exp) && + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); }) + ; +} + +#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ +#if CONFIG_9P_ENABLE_9P2000_L +LM_FLATTEN static bool validate_Rlerror(struct _validate_ctx *ctx) { + uint32_t size; + uint8_t typ; + uint32_t _size_offset; + return false + || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; })) + || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; })) + || validate_tag(ctx) + || validate_errno(ctx) + || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) + || ({ uint8_t exp = 7; (((uint8_t)typ) != exp) && + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); }) + ; +} + +LM_FLATTEN static bool validate_Rstatfs(struct _validate_ctx *ctx) { + uint32_t size; + uint8_t typ; + uint32_t _size_offset; + return false + || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; })) + || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; })) + || validate_tag(ctx) + || validate_super_magic(ctx) + || validate_4(ctx) + || validate_8(ctx) + || validate_8(ctx) + || validate_8(ctx) + || validate_8(ctx) + || validate_8(ctx) + || validate_8(ctx) || validate_4(ctx) - || validate_nuid(ctx) || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) - || ({ uint8_t exp = 72; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 9; (((uint8_t)typ) != exp) && lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); }) ; } -#endif /* CONFIG_9P_ENABLE_9P2000_L */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -LM_FLATTEN static bool validate_Topen(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Tlopen(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -1477,15 +1500,15 @@ LM_FLATTEN static bool validate_Topen(struct _validate_ctx *ctx) { || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; })) || validate_tag(ctx) || validate_fid(ctx) - || validate_o(ctx) + || validate_lo(ctx) || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) - || ({ uint8_t exp = 112; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 12; (((uint8_t)typ) != exp) && lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); }) ; } -LM_FLATTEN static bool validate_Tcreate(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Tlcreate(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -1495,18 +1518,17 @@ LM_FLATTEN static bool validate_Tcreate(struct _validate_ctx *ctx) { || validate_tag(ctx) || validate_fid(ctx) || validate_s(ctx) - || validate_dm(ctx) - || validate_o(ctx) + || validate_lo(ctx) + || validate_mode(ctx) + || validate_nuid(ctx) || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) - || ({ uint8_t exp = 114; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 14; (((uint8_t)typ) != exp) && lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); }) ; } -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000_p9p -LM_FLATTEN static bool validate_Topenfd(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Tmknod(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -1515,17 +1537,19 @@ LM_FLATTEN static bool validate_Topenfd(struct _validate_ctx *ctx) { || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; })) || validate_tag(ctx) || validate_fid(ctx) - || validate_o(ctx) + || validate_s(ctx) + || validate_mode(ctx) + || validate_4(ctx) + || validate_4(ctx) + || validate_nuid(ctx) || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) - || ({ uint8_t exp = 98; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 18; (((uint8_t)typ) != exp) && lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); }) ; } -#endif /* CONFIG_9P_ENABLE_9P2000_p9p */ -#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -LM_FLATTEN static bool validate_Rerror(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Tmkdir(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -1533,20 +1557,18 @@ LM_FLATTEN static bool validate_Rerror(struct _validate_ctx *ctx) { || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; })) || validate_tag(ctx) + || validate_fid(ctx) || validate_s(ctx) -#if CONFIG_9P_ENABLE_9P2000_u - || ( is_ver(ctx, 9P2000_u) && validate_errno(ctx) ) -#endif /* CONFIG_9P_ENABLE_9P2000_u */ + || validate_mode(ctx) + || validate_nuid(ctx) || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) - || ({ uint8_t exp = 107; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 72; (((uint8_t)typ) != exp) && lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); }) ; } -#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ -#if CONFIG_9P_ENABLE_9P2000_L -LM_FLATTEN static bool validate_Rlerror(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Tfsync(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -1554,10 +1576,11 @@ LM_FLATTEN static bool validate_Rlerror(struct _validate_ctx *ctx) { || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; })) || validate_tag(ctx) - || validate_errno(ctx) + || validate_fid(ctx) + || validate_b4(ctx) || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) - || ({ uint8_t exp = 7; (((uint8_t)typ) != exp) && + || ({ uint8_t exp = 50; (((uint8_t)typ) != exp) && lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); }) ; } @@ -1589,7 +1612,7 @@ LM_FLATTEN static bool validate_Tsetattr(struct _validate_ctx *ctx) { || validate_tag(ctx) || validate_fid(ctx) || validate_setattr(ctx) - || validate_4(ctx) + || validate_mode(ctx) || validate_nuid(ctx) || validate_nuid(ctx) || validate_8(ctx) @@ -1604,6 +1627,47 @@ LM_FLATTEN static bool validate_Tsetattr(struct _validate_ctx *ctx) { ; } +LM_FLATTEN static bool validate_Tgetlock(struct _validate_ctx *ctx) { + uint32_t size; + uint8_t typ; + uint32_t _size_offset; + return false + || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; })) + || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; })) + || validate_tag(ctx) + || validate_fid(ctx) + || validate_lock_type(ctx) + || validate_8(ctx) + || validate_8(ctx) + || validate_4(ctx) + || validate_s(ctx) + || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) + || ({ uint8_t exp = 54; (((uint8_t)typ) != exp) && + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); }) + ; +} + +LM_FLATTEN static bool validate_Rgetlock(struct _validate_ctx *ctx) { + uint32_t size; + uint8_t typ; + uint32_t _size_offset; + return false + || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; })) + || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; })) + || validate_tag(ctx) + || validate_lock_type(ctx) + || validate_8(ctx) + || validate_8(ctx) + || validate_4(ctx) + || validate_s(ctx) + || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) && + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); }) + || ({ uint8_t exp = 55; (((uint8_t)typ) != exp) && + lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); }) + ; +} + LM_FLATTEN static bool validate_Tlock(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; @@ -1857,9 +1921,9 @@ LM_FLATTEN static bool validate_Rgetattr(struct _validate_ctx *ctx) { || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; })) || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; })) || validate_tag(ctx) - || validate_8(ctx) + || validate_getattr(ctx) || validate_qid(ctx) - || validate_4(ctx) + || validate_mode(ctx) || validate_nuid(ctx) || validate_nuid(ctx) || validate_8(ctx) @@ -2016,6 +2080,26 @@ LM_ALWAYS_INLINE static void unmarshal_errno(struct _unmarshal_ctx *ctx, lib9p_e #endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ #if CONFIG_9P_ENABLE_9P2000_L +LM_ALWAYS_INLINE static void unmarshal_super_magic(struct _unmarshal_ctx *ctx, lib9p_super_magic_t *out) { + unmarshal_4(ctx, (uint32_t *)out); +} + +LM_ALWAYS_INLINE static void unmarshal_lo(struct _unmarshal_ctx *ctx, lib9p_lo_t *out) { + unmarshal_4(ctx, (uint32_t *)out); +} + +LM_ALWAYS_INLINE static void unmarshal_dt(struct _unmarshal_ctx *ctx, lib9p_dt_t *out) { + unmarshal_1(ctx, (uint8_t *)out); +} + +LM_ALWAYS_INLINE static void unmarshal_mode(struct _unmarshal_ctx *ctx, lib9p_mode_t *out) { + unmarshal_4(ctx, (uint32_t *)out); +} + +LM_ALWAYS_INLINE static void unmarshal_b4(struct _unmarshal_ctx *ctx, lib9p_b4_t *out) { + unmarshal_4(ctx, (uint32_t *)out); +} + LM_ALWAYS_INLINE static void unmarshal_getattr(struct _unmarshal_ctx *ctx, lib9p_getattr_t *out) { unmarshal_8(ctx, (uint64_t *)out); } @@ -2096,22 +2180,6 @@ LM_FLATTEN static void unmarshal_Rwstat(struct _unmarshal_ctx *ctx, struct lib9p #endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ #if CONFIG_9P_ENABLE_9P2000_L -LM_FLATTEN static void unmarshal_Rstatfs(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rstatfs *out) { - memset(out, 0, sizeof(*out)); - ctx->net_offset += 4; - ctx->net_offset += 1; - unmarshal_tag(ctx, &out->tag); - unmarshal_4(ctx, &out->type); - unmarshal_4(ctx, &out->bsize); - unmarshal_8(ctx, &out->blocks); - unmarshal_8(ctx, &out->bfree); - unmarshal_8(ctx, &out->bavail); - unmarshal_8(ctx, &out->files); - unmarshal_8(ctx, &out->ffree); - unmarshal_8(ctx, &out->fsid); - unmarshal_4(ctx, &out->namelen); -} - LM_FLATTEN static void unmarshal_Rrename(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rrename *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; @@ -2274,15 +2342,6 @@ LM_FLATTEN static void unmarshal_Tstatfs(struct _unmarshal_ctx *ctx, struct lib9 unmarshal_fid(ctx, &out->fid); } -LM_FLATTEN static void unmarshal_Tlopen(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tlopen *out) { - memset(out, 0, sizeof(*out)); - ctx->net_offset += 4; - ctx->net_offset += 1; - unmarshal_tag(ctx, &out->tag); - unmarshal_fid(ctx, &out->fid); - unmarshal_4(ctx, &out->flags); -} - LM_FLATTEN static void unmarshal_Treadlink(struct _unmarshal_ctx *ctx, struct lib9p_msg_Treadlink *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; @@ -2301,15 +2360,6 @@ LM_FLATTEN static void unmarshal_Treaddir(struct _unmarshal_ctx *ctx, struct lib unmarshal_4(ctx, &out->count); } -LM_FLATTEN static void unmarshal_Tfsync(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tfsync *out) { - memset(out, 0, sizeof(*out)); - ctx->net_offset += 4; - ctx->net_offset += 1; - unmarshal_tag(ctx, &out->tag); - unmarshal_fid(ctx, &out->fid); - unmarshal_4(ctx, &out->datasync); -} - #endif /* CONFIG_9P_ENABLE_9P2000_L */ #if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u LM_FLATTEN static void unmarshal_Tversion(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tversion *out) { @@ -2385,31 +2435,6 @@ LM_FLATTEN static void unmarshal_Txattrcreate(struct _unmarshal_ctx *ctx, struct unmarshal_4(ctx, &out->flags); } -LM_FLATTEN static void unmarshal_Tgetlock(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tgetlock *out) { - memset(out, 0, sizeof(*out)); - ctx->net_offset += 4; - ctx->net_offset += 1; - unmarshal_tag(ctx, &out->tag); - unmarshal_fid(ctx, &out->fid); - unmarshal_1(ctx, &out->type); - unmarshal_8(ctx, &out->start); - unmarshal_8(ctx, &out->length); - unmarshal_4(ctx, &out->proc_id); - unmarshal_s(ctx, &out->client_id); -} - -LM_FLATTEN static void unmarshal_Rgetlock(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rgetlock *out) { - memset(out, 0, sizeof(*out)); - ctx->net_offset += 4; - ctx->net_offset += 1; - unmarshal_tag(ctx, &out->tag); - unmarshal_1(ctx, &out->type); - unmarshal_8(ctx, &out->start); - unmarshal_8(ctx, &out->length); - unmarshal_4(ctx, &out->proc_id); - unmarshal_s(ctx, &out->client_id); -} - LM_FLATTEN static void unmarshal_Tlink(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tlink *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; @@ -2510,18 +2535,6 @@ LM_FLATTEN static void unmarshal_Tattach(struct _unmarshal_ctx *ctx, struct lib9 #endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ #if CONFIG_9P_ENABLE_9P2000_L -LM_FLATTEN static void unmarshal_Tlcreate(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tlcreate *out) { - memset(out, 0, sizeof(*out)); - ctx->net_offset += 4; - ctx->net_offset += 1; - unmarshal_tag(ctx, &out->tag); - unmarshal_fid(ctx, &out->fid); - unmarshal_s(ctx, &out->name); - unmarshal_4(ctx, &out->flags); - unmarshal_4(ctx, &out->mode); - unmarshal_nuid(ctx, &out->gid); -} - LM_FLATTEN static void unmarshal_Tsymlink(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tsymlink *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; @@ -2533,30 +2546,6 @@ LM_FLATTEN static void unmarshal_Tsymlink(struct _unmarshal_ctx *ctx, struct lib unmarshal_nuid(ctx, &out->gid); } -LM_FLATTEN static void unmarshal_Tmknod(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tmknod *out) { - memset(out, 0, sizeof(*out)); - ctx->net_offset += 4; - ctx->net_offset += 1; - unmarshal_tag(ctx, &out->tag); - unmarshal_fid(ctx, &out->dfid); - unmarshal_s(ctx, &out->name); - unmarshal_4(ctx, &out->mode); - unmarshal_4(ctx, &out->major); - unmarshal_4(ctx, &out->minor); - unmarshal_nuid(ctx, &out->gid); -} - -LM_FLATTEN static void unmarshal_Tmkdir(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tmkdir *out) { - memset(out, 0, sizeof(*out)); - ctx->net_offset += 4; - ctx->net_offset += 1; - unmarshal_tag(ctx, &out->tag); - unmarshal_fid(ctx, &out->dfid); - unmarshal_s(ctx, &out->name); - unmarshal_4(ctx, &out->mode); - unmarshal_nuid(ctx, &out->gid); -} - #endif /* CONFIG_9P_ENABLE_9P2000_L */ #if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u LM_FLATTEN static void unmarshal_Topen(struct _unmarshal_ctx *ctx, struct lib9p_msg_Topen *out) { @@ -2613,6 +2602,76 @@ LM_FLATTEN static void unmarshal_Rlerror(struct _unmarshal_ctx *ctx, struct lib9 unmarshal_errno(ctx, &out->ecode); } +LM_FLATTEN static void unmarshal_Rstatfs(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rstatfs *out) { + memset(out, 0, sizeof(*out)); + ctx->net_offset += 4; + ctx->net_offset += 1; + unmarshal_tag(ctx, &out->tag); + unmarshal_super_magic(ctx, &out->type); + unmarshal_4(ctx, &out->bsize); + unmarshal_8(ctx, &out->blocks); + unmarshal_8(ctx, &out->bfree); + unmarshal_8(ctx, &out->bavail); + unmarshal_8(ctx, &out->files); + unmarshal_8(ctx, &out->ffree); + unmarshal_8(ctx, &out->fsid); + unmarshal_4(ctx, &out->namelen); +} + +LM_FLATTEN static void unmarshal_Tlopen(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tlopen *out) { + memset(out, 0, sizeof(*out)); + ctx->net_offset += 4; + ctx->net_offset += 1; + unmarshal_tag(ctx, &out->tag); + unmarshal_fid(ctx, &out->fid); + unmarshal_lo(ctx, &out->flags); +} + +LM_FLATTEN static void unmarshal_Tlcreate(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tlcreate *out) { + memset(out, 0, sizeof(*out)); + ctx->net_offset += 4; + ctx->net_offset += 1; + unmarshal_tag(ctx, &out->tag); + unmarshal_fid(ctx, &out->fid); + unmarshal_s(ctx, &out->name); + unmarshal_lo(ctx, &out->flags); + unmarshal_mode(ctx, &out->mode); + unmarshal_nuid(ctx, &out->gid); +} + +LM_FLATTEN static void unmarshal_Tmknod(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tmknod *out) { + memset(out, 0, sizeof(*out)); + ctx->net_offset += 4; + ctx->net_offset += 1; + unmarshal_tag(ctx, &out->tag); + unmarshal_fid(ctx, &out->dfid); + unmarshal_s(ctx, &out->name); + unmarshal_mode(ctx, &out->mode); + unmarshal_4(ctx, &out->major); + unmarshal_4(ctx, &out->minor); + unmarshal_nuid(ctx, &out->gid); +} + +LM_FLATTEN static void unmarshal_Tmkdir(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tmkdir *out) { + memset(out, 0, sizeof(*out)); + ctx->net_offset += 4; + ctx->net_offset += 1; + unmarshal_tag(ctx, &out->tag); + unmarshal_fid(ctx, &out->dfid); + unmarshal_s(ctx, &out->name); + unmarshal_mode(ctx, &out->mode); + unmarshal_nuid(ctx, &out->gid); +} + +LM_FLATTEN static void unmarshal_Tfsync(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tfsync *out) { + memset(out, 0, sizeof(*out)); + ctx->net_offset += 4; + ctx->net_offset += 1; + unmarshal_tag(ctx, &out->tag); + unmarshal_fid(ctx, &out->fid); + unmarshal_b4(ctx, &out->datasync); +} + LM_FLATTEN static void unmarshal_Tgetattr(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tgetattr *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; @@ -2629,7 +2688,7 @@ LM_FLATTEN static void unmarshal_Tsetattr(struct _unmarshal_ctx *ctx, struct lib unmarshal_tag(ctx, &out->tag); unmarshal_fid(ctx, &out->fid); unmarshal_setattr(ctx, &out->valid); - unmarshal_4(ctx, &out->mode); + unmarshal_mode(ctx, &out->mode); unmarshal_nuid(ctx, &out->uid); unmarshal_nuid(ctx, &out->gid); unmarshal_8(ctx, &out->filesize); @@ -2639,6 +2698,31 @@ LM_FLATTEN static void unmarshal_Tsetattr(struct _unmarshal_ctx *ctx, struct lib unmarshal_8(ctx, &out->mtime_nsec); } +LM_FLATTEN static void unmarshal_Tgetlock(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tgetlock *out) { + memset(out, 0, sizeof(*out)); + ctx->net_offset += 4; + ctx->net_offset += 1; + unmarshal_tag(ctx, &out->tag); + unmarshal_fid(ctx, &out->fid); + unmarshal_lock_type(ctx, &out->type); + unmarshal_8(ctx, &out->start); + unmarshal_8(ctx, &out->length); + unmarshal_4(ctx, &out->proc_id); + unmarshal_s(ctx, &out->client_id); +} + +LM_FLATTEN static void unmarshal_Rgetlock(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rgetlock *out) { + memset(out, 0, sizeof(*out)); + ctx->net_offset += 4; + ctx->net_offset += 1; + unmarshal_tag(ctx, &out->tag); + unmarshal_lock_type(ctx, &out->type); + unmarshal_8(ctx, &out->start); + unmarshal_8(ctx, &out->length); + unmarshal_4(ctx, &out->proc_id); + unmarshal_s(ctx, &out->client_id); +} + LM_FLATTEN static void unmarshal_Tlock(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tlock *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; @@ -2788,9 +2872,9 @@ LM_FLATTEN static void unmarshal_Rgetattr(struct _unmarshal_ctx *ctx, struct lib ctx->net_offset += 4; ctx->net_offset += 1; unmarshal_tag(ctx, &out->tag); - unmarshal_8(ctx, &out->valid); + unmarshal_getattr(ctx, &out->valid); unmarshal_qid(ctx, &out->qid); - unmarshal_4(ctx, &out->mode); + unmarshal_mode(ctx, &out->mode); unmarshal_nuid(ctx, &out->uid); unmarshal_nuid(ctx, &out->gid); unmarshal_8(ctx, &out->nlink); @@ -3730,7 +3814,7 @@ static bool marshal_Tlopen(struct _marshal_ctx *ctx, struct lib9p_msg_Tlopen *va MARSHAL_U8LE(ctx, 12); MARSHAL_U16LE(ctx, val->tag); MARSHAL_U32LE(ctx, val->fid); - MARSHAL_U32LE(ctx, val->flags); + MARSHAL_U32LE(ctx, val->flags & lo_masks[ctx->ctx->version]); return false; } @@ -3772,8 +3856,8 @@ static bool marshal_Tlcreate(struct _marshal_ctx *ctx, struct lib9p_msg_Tlcreate MARSHAL_U32LE(ctx, val->fid); MARSHAL_U16LE(ctx, val->name.len); MARSHAL_BYTES_ZEROCOPY(ctx, val->name.utf8, val->name.len); - MARSHAL_U32LE(ctx, val->flags); - MARSHAL_U32LE(ctx, val->mode); + MARSHAL_U32LE(ctx, val->flags & lo_masks[ctx->ctx->version]); + MARSHAL_U32LE(ctx, val->mode & mode_masks[ctx->ctx->version]); MARSHAL_U32LE(ctx, val->gid); return false; } @@ -3859,7 +3943,7 @@ static bool marshal_Tmknod(struct _marshal_ctx *ctx, struct lib9p_msg_Tmknod *va MARSHAL_U32LE(ctx, val->dfid); MARSHAL_U16LE(ctx, val->name.len); MARSHAL_BYTES_ZEROCOPY(ctx, val->name.utf8, val->name.len); - MARSHAL_U32LE(ctx, val->mode); + MARSHAL_U32LE(ctx, val->mode & mode_masks[ctx->ctx->version]); MARSHAL_U32LE(ctx, val->major); MARSHAL_U32LE(ctx, val->minor); MARSHAL_U32LE(ctx, val->gid); @@ -3994,11 +4078,11 @@ static bool marshal_Rgetattr(struct _marshal_ctx *ctx, struct lib9p_msg_Rgetattr MARSHAL_U32LE(ctx, offsetof_end - offsetof_size); MARSHAL_U8LE(ctx, 25); MARSHAL_U16LE(ctx, val->tag); - MARSHAL_U64LE(ctx, val->valid); + MARSHAL_U64LE(ctx, val->valid & getattr_masks[ctx->ctx->version]); MARSHAL_U8LE(ctx, val->qid.type & qt_masks[ctx->ctx->version]); MARSHAL_U32LE(ctx, val->qid.vers); MARSHAL_U64LE(ctx, val->qid.path); - MARSHAL_U32LE(ctx, val->mode); + MARSHAL_U32LE(ctx, val->mode & mode_masks[ctx->ctx->version]); MARSHAL_U32LE(ctx, val->uid); MARSHAL_U32LE(ctx, val->gid); MARSHAL_U64LE(ctx, val->nlink); @@ -4035,7 +4119,7 @@ static bool marshal_Tsetattr(struct _marshal_ctx *ctx, struct lib9p_msg_Tsetattr MARSHAL_U16LE(ctx, val->tag); MARSHAL_U32LE(ctx, val->fid); MARSHAL_U32LE(ctx, val->valid & setattr_masks[ctx->ctx->version]); - MARSHAL_U32LE(ctx, val->mode); + MARSHAL_U32LE(ctx, val->mode & mode_masks[ctx->ctx->version]); MARSHAL_U32LE(ctx, val->uid); MARSHAL_U32LE(ctx, val->gid); MARSHAL_U64LE(ctx, val->filesize); @@ -4361,7 +4445,7 @@ static bool marshal_Tmkdir(struct _marshal_ctx *ctx, struct lib9p_msg_Tmkdir *va MARSHAL_U32LE(ctx, val->dfid); MARSHAL_U16LE(ctx, val->name.len); MARSHAL_BYTES_ZEROCOPY(ctx, val->name.utf8, val->name.len); - MARSHAL_U32LE(ctx, val->mode); + MARSHAL_U32LE(ctx, val->mode & mode_masks[ctx->ctx->version]); MARSHAL_U32LE(ctx, val->gid); return false; } diff --git a/lib9p/idl/2010-9P2000.L.9p b/lib9p/idl/2010-9P2000.L.9p index 9c095ad..7ac86a6 100644 --- a/lib9p/idl/2010-9P2000.L.9p +++ b/lib9p/idl/2010-9P2000.L.9p @@ -5,6 +5,7 @@ # "9P2000.L" Linux extension # https://github.com/chaos/diod/blob/master/protocol.md +# https://github.com/chaos/diod/blob/master/src/libnpfs/protocol.h version "9P2000.L" from ./2002-9P2000.9p import tag, fid, s, qt, qid @@ -12,75 +13,198 @@ from ./2002-9P2000.9p import Rerror from ./2002-9P2000.9p import Tversion, Rversion, Tflush, Rflush, Twalk, Rwalk, Tread, Rread, Twrite, Rwrite, Tclunk, Rclunk, Tremove, Rremove from ./2005-9P2000.u.9p import nuid, errno, Tauth, Rauth, Tattach, Rattach +#num errno += # TODO + +num super_magic = 4 + # See <linux/magic.h> (linux.git include/uapi/linux/magic.h). + # + # To quote `util-linux.git:include/statfs_magic.h`: + # "Unfortunately, Linux kernel header file <linux/magic.h> is + # incomplete mess and kernel returns by statfs f_type many numbers + # that are nowhere specified (in API)." + # + # util-linux <statfs_magic.h> is also incomplete. As is the + # statfs(2) man-page. + # + # I'm working on a patchset to the kernel to get <linux/magic.h> + # to be complete, but in the mean-time I'm just not going to + # bother with putting a list here. + # + # TODO + "V9FS_MAGIC=0x01021997" + +# "L"inux "O"pen flags (flags to pass to Tlopen and Tlcreate) +# +# The values are not specified in in protocol.md, but are specified in +# protocol.h (and are different than the Linux kernel's values, which +# vary by architecture). +bitfield lo = 4 + "0=subfield(mode)" # low bit of the 2-bit RDONLY/WRONLY/RDWR/NOACCESS enum + "1=subfield(mode)" # high bit of the 2-bit RDONLY/WRONLY/RDWR/NOACCESS enum + #"2=unused" + #"3=unused" + #"4=unused" + #"5=unused" + "6=CREATE" + "7=EXCL" + "8=NOCTTY" + "9=TRUNC" + "10=APPEND" + "11=NONBLOCK" + "12=DSYNC" + "13=BSD_FASYNC" + "14=DIRECT" + "15=LARGEFILE" + "16=DIRECTORY" + "17=NOFOLLOW" + "18=NOATIME" + "19=CLOEXEC" + "20=SYNC" + + "RDONLY = 0" + "WRONLY = 1" + "RDWR = 2" + "NOACCESS = 3" + + "MODE_MASK = 0b000000000000000000011" + "FLAG_MASK = 0b111111111111111000000" + +# "D"irentry "T"ype +# +# These match the Linux kernel's values. +num dt = 1 + "UNKNOWN = 0" + "NAMED_PIPE = 1" + "CHAR_DEV = 2" + "DIRECTORY = 4" + "BLOCK_DEV = 6" + "REGULAR = 8" + "SYMLINK = 10" + "SOCKET = 12" + "WHITEOUT = 14" + +# Mode +# +# These match the Linux kernel's values. Why is this 32-bits wide +# instead of just 16? Who knows? +bitfield mode = 4 + #... + "15=subfield(fmt)" # bit of the 4-bit FMT_ enum + "14=subfield(fmt)" # bit of the 4-bit FMT_ enum + "13=subfield(fmt)" # bit of the 4-bit FMT_ enum + "12=subfield(fmt)" # bit of the 4-bit FMT_ enum + #... + "11=PERM_SETGROUP" + "10=PERM_SETUSER" + "9=PERM_STICKY" + "8=PERM_OWNER_R" + "7=PERM_OWNER_W" + "6=PERM_OWNER_X" + "5=PERM_GROUP_R" + "4=PERM_GROUP_W" + "3=PERM_GROUP_X" + "2=PERM_OTHER_R" + "1=PERM_OTHER_W" + "0=PERM_OTHER_X" + + "FMT_NAMED_PIPE = LIB9P_DT_NAMED_PIPE<<12" + "FMT_CHAR_DEV = LIB9P_DT_CHAR_DEV<<12" + "FMT_DIRECTORY = LIB9P_DT_DIRECTORY<<12" + "FMT_BLOCK_DEV = LIB9P_DT_BLOCK_DEV<<12" + "FMT_REGULAR = LIB9P_DT_REGULAR<<12" + "FMT_SYMLINK = LIB9P_DT_SYMLINK<<12" + "FMT_SOCKET = LIB9P_DT_SOCKET<<12" + + "PERM_MASK = 0000777" # PERM_* + "FMT_MASK = 0170000" # _fmt_* + +# A boolean value that is for some reason 4 bytes wide. +num b4 = 4 + "FALSE=0" + "TRUE=1" + # all other values are true also + bitfield getattr = 8 - "0=MODE" - "1=NLINK" - "2=UID" - "3=GID" - "4=RDEV" - "5=ATIME" - "6=MTIME" - "7=CTIME" - "8=INO" - "9=SIZE" - "10=BLOCKS" - - "11=BTIME" - "12=GEN" - "13=DATA_VERSION" - - "BASIC=0x000007ff" # Mask for fields up to BLOCKS - "ALL =0x00003fff" # Mask for All fields above + "0=MODE" + "1=NLINK" + "2=UID" + "3=GID" + "4=RDEV" + "5=ATIME" + "6=MTIME" + "7=CTIME" + "8=INO" + "9=SIZE" + "10=BLOCKS" + + "11=BTIME" + "12=GEN" + "13=DATA_VERSION" + + "BASIC=0x000007ff" # Mask for fields up to BLOCKS + "ALL =0x00003fff" # Mask for All fields above bitfield setattr = 4 - "0=MODE" - "1=UID" - "2=GID" - "3=SIZE" - "4=ATIME" - "5=MTIME" - "6=CTIME" - "7=ATIME_SET" - "8=MTIME_SET" + "0=MODE" + "1=UID" + "2=GID" + "3=SIZE" + "4=ATIME" + "5=MTIME" + "6=CTIME" + "7=ATIME_SET" + "8=MTIME_SET" num lock_type = 1 - "RDLCK=0" - "WRLCK=1" - "UNLCK=2" + "RDLCK=0" + "WRLCK=1" + "UNLCK=2" bitfield lock_flags = 4 - "0=BLOCK" - "1=RECLAIM" + "0=BLOCK" + "1=RECLAIM" num lock_status = 1 - "SUCCESS=0" - "BLOCKED=1" - "ERROR=2" - "GRACE=3" + "SUCCESS=0" + "BLOCKED=1" + "ERROR=2" + "GRACE=3" #msg Tlerror = "size[4,val=end-&size] typ[1,val=6] tag[tag] illegal" # analogous to 106/Terror msg Rlerror = "size[4,val=end-&size] typ[1,val=7] tag[tag] ecode[errno]" # analogous to 107/Rerror msg Tstatfs = "size[4,val=end-&size] typ[1,val=8] tag[tag] fid[fid]" -msg Rstatfs = "size[4,val=end-&size] typ[1,val=9] tag[tag] type[4] bsize[4] blocks[8] bfree[8] bavail[8] files[8] ffree[8] fsid[8] namelen[4]" -msg Tlopen = "size[4,val=end-&size] typ[1,val=12] tag[tag] fid[fid] flags[4]" # analogous to 112/Topen +msg Rstatfs = "size[4,val=end-&size] typ[1,val=9] tag[tag]" # Description | statfs | statvfs + "type[super_magic]" # Type of filesystem | f_type | - + "bsize[4]" # Block size in bytes | f_bsize | f_bsize + # - # Fragment size in bytes | f_frsize (since Linux 2.6) | f_frsize + "blocks[8]" # Size of FS in f_frsize units | f_blocks | f_blocks + "bfree[8]" # Number of free blocks | f_bfree | f_bfree + "bavail[8]" # Number of free blocks for unprivileged users | f_bavail | b_avail + "files[8]" # Number of inodes | f_files | f_files + "ffree[8]" # Number of free inodes | f_ffree | f_ffree + # - # Number of free inodes for unprivileged users | - | f_favail + "fsid[8]" # Filesystem instance ID | f_fsid | f_fsid + # - # Mount flags | f_flags (since Linux 2.6.36) | f_flag + "namelen[4]" # Maximum filename length | f_namemax | f_namemax +msg Tlopen = "size[4,val=end-&size] typ[1,val=12] tag[tag] fid[fid] flags[lo]" # analogous to 112/Topen msg Rlopen = "size[4,val=end-&size] typ[1,val=13] tag[tag] qid[qid] iounit[4]" # analogous to 113/Ropen -msg Tlcreate = "size[4,val=end-&size] typ[1,val=14] tag[tag] fid[fid] name[s] flags[4] mode[4] gid[nuid]" # analogous to 114/Tcreate +msg Tlcreate = "size[4,val=end-&size] typ[1,val=14] tag[tag] fid[fid] name[s] flags[lo] mode[mode] gid[nuid]" # analogous to 114/Tcreate msg Rlcreate = "size[4,val=end-&size] typ[1,val=15] tag[tag] qid[qid] iounit[4]" # analogous to 115/Rcreate msg Tsymlink = "size[4,val=end-&size] typ[1,val=16] tag[tag] fid[fid] name[s] symtgt[s] gid[nuid]" msg Rsymlink = "size[4,val=end-&size] typ[1,val=17] tag[tag] qid[qid]" -msg Tmknod = "size[4,val=end-&size] typ[1,val=18] tag[tag] dfid[fid] name[s] mode[4] major[4] minor[4] gid[nuid]" +msg Tmknod = "size[4,val=end-&size] typ[1,val=18] tag[tag] dfid[fid] name[s] mode[mode] major[4] minor[4] gid[nuid]" msg Rmknod = "size[4,val=end-&size] typ[1,val=19] tag[tag] qid[qid]" msg Trename = "size[4,val=end-&size] typ[1,val=20] tag[tag] fid[fid] dfid[fid] name[s]" msg Rrename = "size[4,val=end-&size] typ[1,val=21] tag[tag]" msg Treadlink = "size[4,val=end-&size] typ[1,val=22] tag[tag] fid[fid]" msg Rreadlink = "size[4,val=end-&size] typ[1,val=23] tag[tag] target[s]" msg Tgetattr = "size[4,val=end-&size] typ[1,val=24] tag[tag] fid[fid] request_mask[getattr]" -msg Rgetattr = "size[4,val=end-&size] typ[1,val=25] tag[tag] valid[8] qid[qid] mode[4] uid[nuid] gid[nuid] nlink[8]" +msg Rgetattr = "size[4,val=end-&size] typ[1,val=25] tag[tag] valid[getattr] qid[qid] mode[mode] uid[nuid] gid[nuid] nlink[8]" "rdev[8] filesize[8] blksize[8] blocks[8]" "atime_sec[8] atime_nsec[8] mtime_sec[8] mtime_nsec[8]" "ctime_sec[8] ctime_nsec[8] btime_sec[8] btime_nsec[8]" "gen[8] data_version[8]" -msg Tsetattr = "size[4,val=end-&size] typ[1,val=26] tag[tag] fid[fid] valid[setattr] mode[4] uid[nuid] gid[nuid] filesize[8] atime_sec[8] atime_nsec[8] mtime_sec[8] mtime_nsec[8]" +msg Tsetattr = "size[4,val=end-&size] typ[1,val=26] tag[tag] fid[fid] valid[setattr] mode[mode] uid[nuid] gid[nuid] filesize[8] atime_sec[8] atime_nsec[8] mtime_sec[8] mtime_nsec[8]" msg Rsetattr = "size[4,val=end-&size] typ[1,val=27] tag[tag]" #... msg Txattrwalk = "size[4,val=end-&size] typ[1,val=30] tag[tag] fid[fid] newfid[fid] name[s]" @@ -89,18 +213,18 @@ msg Txattrcreate = "size[4,val=end-&size] typ[1,val=32] tag[tag] fid[fid] name[s msg Rxattrcreate = "size[4,val=end-&size] typ[1,val=33] tag[tag]" #... msg Treaddir = "size[4,val=end-&size] typ[1,val=40] tag[tag] fid[fid] offset[8] count[4]" -msg Rreaddir = "size[4,val=end-&size] typ[1,val=41] tag[tag] count[4] count*(data[1])" # data is "qid[qid] offset[8] type[1] name[s]" +msg Rreaddir = "size[4,val=end-&size] typ[1,val=41] tag[tag] count[4] count*(data[1])" # data is "qid[qid] offset[8] type[dt] name[s]" #... -msg Tfsync = "size[4,val=end-&size] typ[1,val=50] tag[tag] fid[fid] datasync[4]" +msg Tfsync = "size[4,val=end-&size] typ[1,val=50] tag[tag] fid[fid] datasync[b4]" msg Rfsync = "size[4,val=end-&size] typ[1,val=51] tag[tag]" msg Tlock = "size[4,val=end-&size] typ[1,val=52] tag[tag] fid[fid] type[lock_type] flags[lock_flags] start[8] length[8] proc_id[4] client_id[s]" msg Rlock = "size[4,val=end-&size] typ[1,val=53] tag[tag] status[lock_status]" -msg Tgetlock = "size[4,val=end-&size] typ[1,val=54] tag[tag] fid[fid] type[1] start[8] length[8] proc_id[4] client_id[s]" -msg Rgetlock = "size[4,val=end-&size] typ[1,val=55] tag[tag] type[1] start[8] length[8] proc_id[4] client_id[s]" +msg Tgetlock = "size[4,val=end-&size] typ[1,val=54] tag[tag] fid[fid] type[lock_type] start[8] length[8] proc_id[4] client_id[s]" +msg Rgetlock = "size[4,val=end-&size] typ[1,val=55] tag[tag] type[lock_type] start[8] length[8] proc_id[4] client_id[s]" # ... msg Tlink = "size[4,val=end-&size] typ[1,val=70] tag[tag] dfid[fid] fid[fid] name[s]" msg Rlink = "size[4,val=end-&size] typ[1,val=71] tag[tag]" -msg Tmkdir = "size[4,val=end-&size] typ[1,val=72] tag[tag] dfid[fid] name[s] mode[4] gid[nuid]" +msg Tmkdir = "size[4,val=end-&size] typ[1,val=72] tag[tag] dfid[fid] name[s] mode[mode] gid[nuid]" msg Rmkdir = "size[4,val=end-&size] typ[1,val=73] tag[tag] qid[qid]" msg Trenameat = "size[4,val=end-&size] typ[1,val=74] tag[tag] olddirfid[fid] oldname[s] newdirfid[fid] newname[s]" msg Rrenameat = "size[4,val=end-&size] typ[1,val=75] tag[tag]" diff --git a/lib9p/include/lib9p/9p.generated.h b/lib9p/include/lib9p/9p.generated.h index 9003416..725e781 100644 --- a/lib9p/include/lib9p/9p.generated.h +++ b/lib9p/include/lib9p/9p.generated.h @@ -268,6 +268,116 @@ typedef uint32_t lib9p_errno_t; #endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ #if CONFIG_9P_ENABLE_9P2000_L +/* size = 4 ; max_iov = 1 ; max_copy = 4 */ +typedef uint32_t lib9p_super_magic_t; +#define LIB9P_SUPER_MAGIC_V9FS_MAGIC ((lib9p_super_magic_t)UINT32_C(0x01021997)) + +/* size = 4 ; max_iov = 1 ; max_copy = 4 */ +typedef uint32_t lib9p_lo_t; + +/* unused ((lib9p_lo_t)(1<<31)) */ +/* unused ((lib9p_lo_t)(1<<30)) */ +/* unused ((lib9p_lo_t)(1<<29)) */ +/* unused ((lib9p_lo_t)(1<<28)) */ +/* unused ((lib9p_lo_t)(1<<27)) */ +/* unused ((lib9p_lo_t)(1<<26)) */ +/* unused ((lib9p_lo_t)(1<<25)) */ +/* unused ((lib9p_lo_t)(1<<24)) */ +/* unused ((lib9p_lo_t)(1<<23)) */ +/* unused ((lib9p_lo_t)(1<<22)) */ +/* unused ((lib9p_lo_t)(1<<21)) */ +#define LIB9P_LO_SYNC ((lib9p_lo_t)(1<<20)) +#define LIB9P_LO_CLOEXEC ((lib9p_lo_t)(1<<19)) +#define LIB9P_LO_NOATIME ((lib9p_lo_t)(1<<18)) +#define LIB9P_LO_NOFOLLOW ((lib9p_lo_t)(1<<17)) +#define LIB9P_LO_DIRECTORY ((lib9p_lo_t)(1<<16)) +#define LIB9P_LO_LARGEFILE ((lib9p_lo_t)(1<<15)) +#define LIB9P_LO_DIRECT ((lib9p_lo_t)(1<<14)) +#define LIB9P_LO_BSD_FASYNC ((lib9p_lo_t)(1<<13)) +#define LIB9P_LO_DSYNC ((lib9p_lo_t)(1<<12)) +#define LIB9P_LO_NONBLOCK ((lib9p_lo_t)(1<<11)) +#define LIB9P_LO_APPEND ((lib9p_lo_t)(1<<10)) +#define LIB9P_LO_TRUNC ((lib9p_lo_t)(1<<9)) +#define LIB9P_LO_NOCTTY ((lib9p_lo_t)(1<<8)) +#define LIB9P_LO_EXCL ((lib9p_lo_t)(1<<7)) +#define LIB9P_LO_CREATE ((lib9p_lo_t)(1<<6)) +/* unused ((lib9p_lo_t)(1<<5)) */ +/* unused ((lib9p_lo_t)(1<<4)) */ +/* unused ((lib9p_lo_t)(1<<3)) */ +/* unused ((lib9p_lo_t)(1<<2)) */ +#define _LIB9P_LO_mode_1 ((lib9p_lo_t)(1<<1)) +#define _LIB9P_LO_mode_0 ((lib9p_lo_t)(1<<0)) + +#define LIB9P_LO_RDONLY ((lib9p_lo_t)(0)) +#define LIB9P_LO_WRONLY ((lib9p_lo_t)(1)) +#define LIB9P_LO_RDWR ((lib9p_lo_t)(2)) +#define LIB9P_LO_NOACCESS ((lib9p_lo_t)(3)) +#define LIB9P_LO_MODE_MASK ((lib9p_lo_t)(0b000000000000000000011)) +#define LIB9P_LO_FLAG_MASK ((lib9p_lo_t)(0b111111111111111000000)) + +/* size = 1 ; max_iov = 1 ; max_copy = 1 */ +typedef uint8_t lib9p_dt_t; +#define LIB9P_DT_UNKNOWN ((lib9p_dt_t)UINT8_C(0)) +#define LIB9P_DT_NAMED_PIPE ((lib9p_dt_t)UINT8_C(1)) +#define LIB9P_DT_CHAR_DEV ((lib9p_dt_t)UINT8_C(2)) +#define LIB9P_DT_DIRECTORY ((lib9p_dt_t)UINT8_C(4)) +#define LIB9P_DT_BLOCK_DEV ((lib9p_dt_t)UINT8_C(6)) +#define LIB9P_DT_REGULAR ((lib9p_dt_t)UINT8_C(8)) +#define LIB9P_DT_SYMLINK ((lib9p_dt_t)UINT8_C(10)) +#define LIB9P_DT_SOCKET ((lib9p_dt_t)UINT8_C(12)) +#define LIB9P_DT_WHITEOUT ((lib9p_dt_t)UINT8_C(14)) + +/* size = 4 ; max_iov = 1 ; max_copy = 4 */ +typedef uint32_t lib9p_mode_t; + +/* unused ((lib9p_mode_t)(1<<31)) */ +/* unused ((lib9p_mode_t)(1<<30)) */ +/* unused ((lib9p_mode_t)(1<<29)) */ +/* unused ((lib9p_mode_t)(1<<28)) */ +/* unused ((lib9p_mode_t)(1<<27)) */ +/* unused ((lib9p_mode_t)(1<<26)) */ +/* unused ((lib9p_mode_t)(1<<25)) */ +/* unused ((lib9p_mode_t)(1<<24)) */ +/* unused ((lib9p_mode_t)(1<<23)) */ +/* unused ((lib9p_mode_t)(1<<22)) */ +/* unused ((lib9p_mode_t)(1<<21)) */ +/* unused ((lib9p_mode_t)(1<<20)) */ +/* unused ((lib9p_mode_t)(1<<19)) */ +/* unused ((lib9p_mode_t)(1<<18)) */ +/* unused ((lib9p_mode_t)(1<<17)) */ +/* unused ((lib9p_mode_t)(1<<16)) */ +#define _LIB9P_MODE_fmt_3 ((lib9p_mode_t)(1<<15)) +#define _LIB9P_MODE_fmt_2 ((lib9p_mode_t)(1<<14)) +#define _LIB9P_MODE_fmt_1 ((lib9p_mode_t)(1<<13)) +#define _LIB9P_MODE_fmt_0 ((lib9p_mode_t)(1<<12)) +#define LIB9P_MODE_PERM_SETGROUP ((lib9p_mode_t)(1<<11)) +#define LIB9P_MODE_PERM_SETUSER ((lib9p_mode_t)(1<<10)) +#define LIB9P_MODE_PERM_STICKY ((lib9p_mode_t)(1<<9)) +#define LIB9P_MODE_PERM_OWNER_R ((lib9p_mode_t)(1<<8)) +#define LIB9P_MODE_PERM_OWNER_W ((lib9p_mode_t)(1<<7)) +#define LIB9P_MODE_PERM_OWNER_X ((lib9p_mode_t)(1<<6)) +#define LIB9P_MODE_PERM_GROUP_R ((lib9p_mode_t)(1<<5)) +#define LIB9P_MODE_PERM_GROUP_W ((lib9p_mode_t)(1<<4)) +#define LIB9P_MODE_PERM_GROUP_X ((lib9p_mode_t)(1<<3)) +#define LIB9P_MODE_PERM_OTHER_R ((lib9p_mode_t)(1<<2)) +#define LIB9P_MODE_PERM_OTHER_W ((lib9p_mode_t)(1<<1)) +#define LIB9P_MODE_PERM_OTHER_X ((lib9p_mode_t)(1<<0)) + +#define LIB9P_MODE_FMT_NAMED_PIPE ((lib9p_mode_t)(LIB9P_DT_NAMED_PIPE<<12)) +#define LIB9P_MODE_FMT_CHAR_DEV ((lib9p_mode_t)(LIB9P_DT_CHAR_DEV<<12)) +#define LIB9P_MODE_FMT_DIRECTORY ((lib9p_mode_t)(LIB9P_DT_DIRECTORY<<12)) +#define LIB9P_MODE_FMT_BLOCK_DEV ((lib9p_mode_t)(LIB9P_DT_BLOCK_DEV<<12)) +#define LIB9P_MODE_FMT_REGULAR ((lib9p_mode_t)(LIB9P_DT_REGULAR<<12)) +#define LIB9P_MODE_FMT_SYMLINK ((lib9p_mode_t)(LIB9P_DT_SYMLINK<<12)) +#define LIB9P_MODE_FMT_SOCKET ((lib9p_mode_t)(LIB9P_DT_SOCKET<<12)) +#define LIB9P_MODE_PERM_MASK ((lib9p_mode_t)(0000777)) +#define LIB9P_MODE_FMT_MASK ((lib9p_mode_t)(0170000)) + +/* size = 4 ; max_iov = 1 ; max_copy = 4 */ +typedef uint32_t lib9p_b4_t; +#define LIB9P_B4_FALSE ((lib9p_b4_t)UINT32_C(0)) +#define LIB9P_B4_TRUE ((lib9p_b4_t)UINT32_C(1)) + /* size = 8 ; max_iov = 1 ; max_copy = 8 */ typedef uint64_t lib9p_getattr_t; @@ -469,20 +579,6 @@ struct lib9p_msg_Rwstat { #endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ #if CONFIG_9P_ENABLE_9P2000_L -/* size = 67 ; max_iov = 1 ; max_copy = 67 */ -struct lib9p_msg_Rstatfs { - lib9p_tag_t tag; - uint32_t type; - uint32_t bsize; - uint64_t blocks; - uint64_t bfree; - uint64_t bavail; - uint64_t files; - uint64_t ffree; - uint64_t fsid; - uint32_t namelen; -}; - /* size = 7 ; max_iov = 1 ; max_copy = 7 */ struct lib9p_msg_Rrename { lib9p_tag_t tag; @@ -604,13 +700,6 @@ struct lib9p_msg_Tstatfs { lib9p_fid_t fid; }; -/* size = 15 ; max_iov = 1 ; max_copy = 15 */ -struct lib9p_msg_Tlopen { - lib9p_tag_t tag; - lib9p_fid_t fid; - uint32_t flags; -}; - /* size = 11 ; max_iov = 1 ; max_copy = 11 */ struct lib9p_msg_Treadlink { lib9p_tag_t tag; @@ -625,13 +714,6 @@ struct lib9p_msg_Treaddir { uint32_t count; }; -/* size = 15 ; max_iov = 1 ; max_copy = 15 */ -struct lib9p_msg_Tfsync { - lib9p_tag_t tag; - lib9p_fid_t fid; - uint32_t datasync; -}; - #endif /* CONFIG_9P_ENABLE_9P2000_L */ #if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u /* min_size = 13 ; exp_size = 40 ; max_size = 65,548 ; max_iov = 2 ; max_copy = 13 */ @@ -690,27 +772,6 @@ struct lib9p_msg_Txattrcreate { uint32_t flags; }; -/* min_size = 34 ; exp_size = 61 ; max_size = 65,569 ; max_iov = 2 ; max_copy = 34 */ -struct lib9p_msg_Tgetlock { - lib9p_tag_t tag; - lib9p_fid_t fid; - uint8_t type; - uint64_t start; - uint64_t length; - uint32_t proc_id; - struct lib9p_s client_id; -}; - -/* min_size = 30 ; exp_size = 57 ; max_size = 65,565 ; max_iov = 2 ; max_copy = 30 */ -struct lib9p_msg_Rgetlock { - lib9p_tag_t tag; - uint8_t type; - uint64_t start; - uint64_t length; - uint32_t proc_id; - struct lib9p_s client_id; -}; - /* min_size = 17 ; exp_size = 44 ; max_size = 65,552 ; max_iov = 2 ; max_copy = 17 */ struct lib9p_msg_Tlink { lib9p_tag_t tag; @@ -798,16 +859,6 @@ struct lib9p_msg_Tattach { #endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ #if CONFIG_9P_ENABLE_9P2000_L -/* min_size = 25 ; exp_size = 52 ; max_size = 65,560 ; max_iov = 3 ; max_copy = 25 */ -struct lib9p_msg_Tlcreate { - lib9p_tag_t tag; - lib9p_fid_t fid; - struct lib9p_s name; - uint32_t flags; - uint32_t mode; - lib9p_nuid_t gid; -}; - /* min_size = 19 ; exp_size = 73 ; max_size = 131,089 ; max_iov = 5 ; max_copy = 19 */ struct lib9p_msg_Tsymlink { lib9p_tag_t tag; @@ -817,26 +868,6 @@ struct lib9p_msg_Tsymlink { lib9p_nuid_t gid; }; -/* min_size = 29 ; exp_size = 56 ; max_size = 65,564 ; max_iov = 3 ; max_copy = 29 */ -struct lib9p_msg_Tmknod { - lib9p_tag_t tag; - lib9p_fid_t dfid; - struct lib9p_s name; - uint32_t mode; - uint32_t major; - uint32_t minor; - lib9p_nuid_t gid; -}; - -/* min_size = 21 ; exp_size = 48 ; max_size = 65,556 ; max_iov = 3 ; max_copy = 21 */ -struct lib9p_msg_Tmkdir { - lib9p_tag_t tag; - lib9p_fid_t dfid; - struct lib9p_s name; - uint32_t mode; - lib9p_nuid_t gid; -}; - #endif /* CONFIG_9P_ENABLE_9P2000_L */ #if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u /* size = 12 ; max_iov = 1 ; max_copy = 12 */ @@ -887,6 +918,64 @@ struct lib9p_msg_Rlerror { lib9p_errno_t ecode; }; +/* size = 67 ; max_iov = 1 ; max_copy = 67 */ +struct lib9p_msg_Rstatfs { + lib9p_tag_t tag; + lib9p_super_magic_t type; + uint32_t bsize; + uint64_t blocks; + uint64_t bfree; + uint64_t bavail; + uint64_t files; + uint64_t ffree; + uint64_t fsid; + uint32_t namelen; +}; + +/* size = 15 ; max_iov = 1 ; max_copy = 15 */ +struct lib9p_msg_Tlopen { + lib9p_tag_t tag; + lib9p_fid_t fid; + lib9p_lo_t flags; +}; + +/* min_size = 25 ; exp_size = 52 ; max_size = 65,560 ; max_iov = 3 ; max_copy = 25 */ +struct lib9p_msg_Tlcreate { + lib9p_tag_t tag; + lib9p_fid_t fid; + struct lib9p_s name; + lib9p_lo_t flags; + lib9p_mode_t mode; + lib9p_nuid_t gid; +}; + +/* min_size = 29 ; exp_size = 56 ; max_size = 65,564 ; max_iov = 3 ; max_copy = 29 */ +struct lib9p_msg_Tmknod { + lib9p_tag_t tag; + lib9p_fid_t dfid; + struct lib9p_s name; + lib9p_mode_t mode; + uint32_t major; + uint32_t minor; + lib9p_nuid_t gid; +}; + +/* min_size = 21 ; exp_size = 48 ; max_size = 65,556 ; max_iov = 3 ; max_copy = 21 */ +struct lib9p_msg_Tmkdir { + lib9p_tag_t tag; + lib9p_fid_t dfid; + struct lib9p_s name; + lib9p_mode_t mode; + lib9p_nuid_t gid; +}; + +/* size = 15 ; max_iov = 1 ; max_copy = 15 */ +struct lib9p_msg_Tfsync { + lib9p_tag_t tag; + lib9p_fid_t fid; + lib9p_b4_t datasync; +}; + /* size = 19 ; max_iov = 1 ; max_copy = 19 */ struct lib9p_msg_Tgetattr { lib9p_tag_t tag; @@ -899,7 +988,7 @@ struct lib9p_msg_Tsetattr { lib9p_tag_t tag; lib9p_fid_t fid; lib9p_setattr_t valid; - uint32_t mode; + lib9p_mode_t mode; lib9p_nuid_t uid; lib9p_nuid_t gid; uint64_t filesize; @@ -909,6 +998,27 @@ struct lib9p_msg_Tsetattr { uint64_t mtime_nsec; }; +/* min_size = 34 ; exp_size = 61 ; max_size = 65,569 ; max_iov = 2 ; max_copy = 34 */ +struct lib9p_msg_Tgetlock { + lib9p_tag_t tag; + lib9p_fid_t fid; + lib9p_lock_type_t type; + uint64_t start; + uint64_t length; + uint32_t proc_id; + struct lib9p_s client_id; +}; + +/* min_size = 30 ; exp_size = 57 ; max_size = 65,565 ; max_iov = 2 ; max_copy = 30 */ +struct lib9p_msg_Rgetlock { + lib9p_tag_t tag; + lib9p_lock_type_t type; + uint64_t start; + uint64_t length; + uint32_t proc_id; + struct lib9p_s client_id; +}; + /* min_size = 38 ; exp_size = 65 ; max_size = 65,573 ; max_iov = 2 ; max_copy = 38 */ struct lib9p_msg_Tlock { lib9p_tag_t tag; @@ -1031,9 +1141,9 @@ struct lib9p_msg_Rmknod { /* size = 160 ; max_iov = 1 ; max_copy = 160 */ struct lib9p_msg_Rgetattr { lib9p_tag_t tag; - uint64_t valid; + lib9p_getattr_t valid; struct lib9p_qid qid; - uint32_t mode; + lib9p_mode_t mode; lib9p_nuid_t uid; lib9p_nuid_t gid; uint64_t nlink; diff --git a/lib9p/tests/test_compile.c b/lib9p/tests/test_compile.c index d001b2f..6abee05 100644 --- a/lib9p/tests/test_compile.c +++ b/lib9p/tests/test_compile.c @@ -47,6 +47,66 @@ int main(void) { x = LIB9P_O_MODE_MASK; x = LIB9P_O_FLAG_MASK; x = LIB9P_ERRNO_NOERROR; + x = LIB9P_SUPER_MAGIC_V9FS_MAGIC; + x = LIB9P_LO_SYNC; + x = LIB9P_LO_CLOEXEC; + x = LIB9P_LO_NOATIME; + x = LIB9P_LO_NOFOLLOW; + x = LIB9P_LO_DIRECTORY; + x = LIB9P_LO_LARGEFILE; + x = LIB9P_LO_DIRECT; + x = LIB9P_LO_BSD_FASYNC; + x = LIB9P_LO_DSYNC; + x = LIB9P_LO_NONBLOCK; + x = LIB9P_LO_APPEND; + x = LIB9P_LO_TRUNC; + x = LIB9P_LO_NOCTTY; + x = LIB9P_LO_EXCL; + x = LIB9P_LO_CREATE; + x = _LIB9P_LO_mode_1; + x = _LIB9P_LO_mode_0; + x = LIB9P_LO_RDONLY; + x = LIB9P_LO_WRONLY; + x = LIB9P_LO_RDWR; + x = LIB9P_LO_NOACCESS; + x = LIB9P_LO_MODE_MASK; + x = LIB9P_LO_FLAG_MASK; + x = LIB9P_DT_UNKNOWN; + x = LIB9P_DT_NAMED_PIPE; + x = LIB9P_DT_CHAR_DEV; + x = LIB9P_DT_DIRECTORY; + x = LIB9P_DT_BLOCK_DEV; + x = LIB9P_DT_REGULAR; + x = LIB9P_DT_SYMLINK; + x = LIB9P_DT_SOCKET; + x = LIB9P_DT_WHITEOUT; + x = _LIB9P_MODE_fmt_3; + x = _LIB9P_MODE_fmt_2; + x = _LIB9P_MODE_fmt_1; + x = _LIB9P_MODE_fmt_0; + x = LIB9P_MODE_PERM_SETGROUP; + x = LIB9P_MODE_PERM_SETUSER; + x = LIB9P_MODE_PERM_STICKY; + x = LIB9P_MODE_PERM_OWNER_R; + x = LIB9P_MODE_PERM_OWNER_W; + x = LIB9P_MODE_PERM_OWNER_X; + x = LIB9P_MODE_PERM_GROUP_R; + x = LIB9P_MODE_PERM_GROUP_W; + x = LIB9P_MODE_PERM_GROUP_X; + x = LIB9P_MODE_PERM_OTHER_R; + x = LIB9P_MODE_PERM_OTHER_W; + x = LIB9P_MODE_PERM_OTHER_X; + x = LIB9P_MODE_FMT_NAMED_PIPE; + x = LIB9P_MODE_FMT_CHAR_DEV; + x = LIB9P_MODE_FMT_DIRECTORY; + x = LIB9P_MODE_FMT_BLOCK_DEV; + x = LIB9P_MODE_FMT_REGULAR; + x = LIB9P_MODE_FMT_SYMLINK; + x = LIB9P_MODE_FMT_SOCKET; + x = LIB9P_MODE_PERM_MASK; + x = LIB9P_MODE_FMT_MASK; + x = LIB9P_B4_FALSE; + x = LIB9P_B4_TRUE; x = LIB9P_GETATTR_DATA_VERSION; x = LIB9P_GETATTR_GEN; x = LIB9P_GETATTR_BTIME; |