summaryrefslogtreecommitdiff
path: root/lib9p
diff options
context:
space:
mode:
Diffstat (limited to 'lib9p')
-rw-r--r--lib9p/9p.c62
-rw-r--r--lib9p/9p.generated.c1205
-rwxr-xr-xlib9p/idl.gen219
-rw-r--r--lib9p/idl/2012-9P2000.e.9p9
-rw-r--r--lib9p/idl/__init__.py89
-rw-r--r--lib9p/include/lib9p/9p.generated.h156
-rw-r--r--lib9p/include/lib9p/9p.h17
-rw-r--r--lib9p/include/lib9p/srv.h12
-rw-r--r--lib9p/internal.h55
-rw-r--r--lib9p/srv.c57
-rw-r--r--lib9p/tests/test_server/config/config.h4
-rw-r--r--lib9p/tests/test_server/main.c2
12 files changed, 1065 insertions, 822 deletions
diff --git a/lib9p/9p.c b/lib9p/9p.c
index ecb75fd..51ff2eb 100644
--- a/lib9p/9p.c
+++ b/lib9p/9p.c
@@ -16,6 +16,54 @@
#include "internal.h"
+/* strings ********************************************************************/
+
+const char *lib9p_version_str(enum lib9p_version ver) {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wtype-limits"
+ assert(0 <= ver && ver < LIB9P_VER_NUM);
+#pragma GCC diagnostic pop
+ return _lib9p_table_ver_name[ver];
+}
+
+const char *lib9p_msgtype_str(enum lib9p_version ver, enum lib9p_msg_type typ) {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wtype-limits"
+ assert(0 <= ver && ver < LIB9P_VER_NUM);
+ assert(0 <= typ && typ <= 0xFF);
+#pragma GCC diagnostic pop
+ return _lib9p_table_msg_name[ver][typ] ?: const_byte_str(typ);
+}
+
+struct lib9p_s lib9p_str(char *s) {
+ if (!s)
+ return (struct lib9p_s){0};
+ return (struct lib9p_s){
+ .len = strlen(s),
+ .utf8 = s,
+ };
+}
+struct lib9p_s lib9p_strn(char *s, size_t maxlen) {
+ if (maxlen == 0 || !s)
+ return (struct lib9p_s){0};
+ return (struct lib9p_s){
+ .len = strnlen(s, maxlen),
+ .utf8 = s,
+ };
+}
+struct lib9p_s lib9p_str_slice(struct lib9p_s s, uint16_t beg, uint16_t end) {
+ assert(s.len == 0 || s.utf8);
+ assert(beg <= end && end <= s.len);
+ return (struct lib9p_s){
+ .len = end - beg,
+ .utf8 = &s.utf8[beg],
+ };
+}
+bool lib9p_str_eq(struct lib9p_s a, struct lib9p_s b) {
+ return a.len == b.len &&
+ (a.len == 0 || memcmp(a.utf8, b.utf8, a.len) == 0);
+}
+
/* ctx ************************************************************************/
void lib9p_ctx_clear_error(struct lib9p_ctx *ctx) {
@@ -67,14 +115,6 @@ int lib9p_errorf(struct lib9p_ctx *ctx, uint32_t linux_errno, char const *fmt, .
return -1;
}
-const char *lib9p_msg_type_str(struct lib9p_ctx *ctx, enum lib9p_msg_type typ) {
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wtype-limits"
- assert(0 <= typ && typ <= 0xFF);
-#pragma GCC diagnostic pop
- return _lib9p_table_msg_name[ctx->version][typ] ?: const_byte_str(typ);
-}
-
/* main message functions *****************************************************/
static
@@ -85,7 +125,7 @@ ssize_t _lib9p_validate(uint8_t xxx_low_typ_bit,
/* Inspect the first 5 bytes ourselves. */
struct _validate_ctx subctx = {
.ctx = ctx,
- .net_size = decode_u32le(net_bytes),
+ .net_size = uint32le_decode(net_bytes),
.net_bytes = net_bytes,
.net_offset = 0,
@@ -96,11 +136,11 @@ ssize_t _lib9p_validate(uint8_t xxx_low_typ_bit,
uint8_t typ = net_bytes[4];
if (typ % 2 != xxx_low_typ_bit)
return lib9p_errorf(ctx, LINUX_EOPNOTSUPP, "%s: message_type=%s", xxx_errmsg,
- lib9p_msg_type_str(ctx, typ));
+ lib9p_msgtype_str(ctx->version, typ));
struct _lib9p_recv_tentry tentry = xxx_table[ctx->version][typ/2];
if (!tentry.validate)
return lib9p_errorf(ctx, LINUX_EOPNOTSUPP, "unknown message type: %s (protocol_version=%s)",
- lib9p_msg_type_str(ctx, typ), lib9p_version_str(ctx->version));
+ lib9p_msgtype_str(ctx->version, typ), lib9p_version_str(ctx->version));
/* Now use the message-type-specific tentry to process the whole thing. */
if (tentry.validate(&subctx))
diff --git a/lib9p/9p.generated.c b/lib9p/9p.generated.c
index d809588..8d29a6d 100644
--- a/lib9p/9p.generated.c
+++ b/lib9p/9p.generated.c
@@ -12,14 +12,6 @@
#include "internal.h"
/* utilities ******************************************************************/
-
-/**
- * is_ver(ctx, ver) is essentially `(ctx->ctx->version == LIB9P_VER_##ver)`,
- * but compiles correctly (to `false`) even if `LIB9P_VER_##ver` isn't defined
- * (because `!CONFIG_9P_ENABLE_##ver`). This is useful when `||`ing
- * several version checks together.
- */
-#define is_ver(ctx, ver) _is_ver_##ver(ctx->ctx->version)
#if CONFIG_9P_ENABLE_9P2000
#define _is_ver_9P2000(v) (v == LIB9P_VER_9P2000)
#else
@@ -41,9 +33,17 @@
#define _is_ver_9P2000_u(v) false
#endif
+/**
+ * is_ver(ctx, ver) is essentially `(ctx->ctx->version == LIB9P_VER_##ver)`,
+ * but compiles correctly (to `false`) even if `LIB9P_VER_##ver` isn't defined
+ * (because `!CONFIG_9P_ENABLE_##ver`). This is useful when `||`ing
+ * several version checks together.
+ */
+#define is_ver(ctx, ver) _is_ver_##ver(ctx->ctx->version)
+
/* strings ********************************************************************/
-static const char *version_strs[LIB9P_VER_NUM] = {
+const char *_lib9p_table_ver_name[LIB9P_VER_NUM] = {
[LIB9P_VER_unknown] = "unknown",
#if CONFIG_9P_ENABLE_9P2000
[LIB9P_VER_9P2000] = "9P2000",
@@ -59,13 +59,172 @@ static const char *version_strs[LIB9P_VER_NUM] = {
#endif /* CONFIG_9P_ENABLE_9P2000_u */
};
-const char *lib9p_version_str(enum lib9p_version ver) {
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wtype-limits"
- assert(0 <= ver && ver < LIB9P_VER_NUM);
-#pragma GCC diagnostic pop
- return version_strs[ver];
-}
+#define _MSG_NAME(typ) [LIB9P_TYP_##typ] = #typ
+const char * _lib9p_table_msg_name[LIB9P_VER_NUM][0x100] = {
+ [LIB9P_VER_unknown] = {
+ _MSG_NAME(Tversion),
+ _MSG_NAME(Rversion),
+ _MSG_NAME(Rerror),
+ },
+#if CONFIG_9P_ENABLE_9P2000
+ [LIB9P_VER_9P2000] = {
+ _MSG_NAME(Tversion),
+ _MSG_NAME(Rversion),
+ _MSG_NAME(Tauth),
+ _MSG_NAME(Rauth),
+ _MSG_NAME(Tattach),
+ _MSG_NAME(Rattach),
+ _MSG_NAME(Rerror),
+ _MSG_NAME(Tflush),
+ _MSG_NAME(Rflush),
+ _MSG_NAME(Twalk),
+ _MSG_NAME(Rwalk),
+ _MSG_NAME(Topen),
+ _MSG_NAME(Ropen),
+ _MSG_NAME(Tcreate),
+ _MSG_NAME(Rcreate),
+ _MSG_NAME(Tread),
+ _MSG_NAME(Rread),
+ _MSG_NAME(Twrite),
+ _MSG_NAME(Rwrite),
+ _MSG_NAME(Tclunk),
+ _MSG_NAME(Rclunk),
+ _MSG_NAME(Tremove),
+ _MSG_NAME(Rremove),
+ _MSG_NAME(Tstat),
+ _MSG_NAME(Rstat),
+ _MSG_NAME(Twstat),
+ _MSG_NAME(Rwstat),
+ },
+#endif /* CONFIG_9P_ENABLE_9P2000 */
+#if CONFIG_9P_ENABLE_9P2000_L
+ [LIB9P_VER_9P2000_L] = {
+ _MSG_NAME(Rlerror),
+ _MSG_NAME(Tstatfs),
+ _MSG_NAME(Rstatfs),
+ _MSG_NAME(Tlopen),
+ _MSG_NAME(Rlopen),
+ _MSG_NAME(Tlcreate),
+ _MSG_NAME(Rlcreate),
+ _MSG_NAME(Tsymlink),
+ _MSG_NAME(Rsymlink),
+ _MSG_NAME(Tmknod),
+ _MSG_NAME(Rmknod),
+ _MSG_NAME(Trename),
+ _MSG_NAME(Rrename),
+ _MSG_NAME(Treadlink),
+ _MSG_NAME(Rreadlink),
+ _MSG_NAME(Tgetattr),
+ _MSG_NAME(Rgetattr),
+ _MSG_NAME(Tsetattr),
+ _MSG_NAME(Rsetattr),
+ _MSG_NAME(Txattrwalk),
+ _MSG_NAME(Rxattrwalk),
+ _MSG_NAME(Txattrcreate),
+ _MSG_NAME(Rxattrcreate),
+ _MSG_NAME(Treaddir),
+ _MSG_NAME(Rreaddir),
+ _MSG_NAME(Tfsync),
+ _MSG_NAME(Rfsync),
+ _MSG_NAME(Tlock),
+ _MSG_NAME(Rlock),
+ _MSG_NAME(Tgetlock),
+ _MSG_NAME(Rgetlock),
+ _MSG_NAME(Tlink),
+ _MSG_NAME(Rlink),
+ _MSG_NAME(Tmkdir),
+ _MSG_NAME(Trenameat),
+ _MSG_NAME(Rrenameat),
+ _MSG_NAME(Tunlinkat),
+ _MSG_NAME(Runlinkat),
+ _MSG_NAME(Tversion),
+ _MSG_NAME(Rversion),
+ _MSG_NAME(Tauth),
+ _MSG_NAME(Rauth),
+ _MSG_NAME(Tattach),
+ _MSG_NAME(Rattach),
+ _MSG_NAME(Tflush),
+ _MSG_NAME(Rflush),
+ _MSG_NAME(Twalk),
+ _MSG_NAME(Rwalk),
+ _MSG_NAME(Tread),
+ _MSG_NAME(Rread),
+ _MSG_NAME(Twrite),
+ _MSG_NAME(Rwrite),
+ _MSG_NAME(Tclunk),
+ _MSG_NAME(Tremove),
+ _MSG_NAME(Rremove),
+ },
+#endif /* CONFIG_9P_ENABLE_9P2000_L */
+#if CONFIG_9P_ENABLE_9P2000_e
+ [LIB9P_VER_9P2000_e] = {
+ _MSG_NAME(Tversion),
+ _MSG_NAME(Rversion),
+ _MSG_NAME(Tauth),
+ _MSG_NAME(Rauth),
+ _MSG_NAME(Tattach),
+ _MSG_NAME(Rattach),
+ _MSG_NAME(Rerror),
+ _MSG_NAME(Tflush),
+ _MSG_NAME(Rflush),
+ _MSG_NAME(Twalk),
+ _MSG_NAME(Rwalk),
+ _MSG_NAME(Topen),
+ _MSG_NAME(Ropen),
+ _MSG_NAME(Tcreate),
+ _MSG_NAME(Rcreate),
+ _MSG_NAME(Tread),
+ _MSG_NAME(Rread),
+ _MSG_NAME(Twrite),
+ _MSG_NAME(Rwrite),
+ _MSG_NAME(Tclunk),
+ _MSG_NAME(Rclunk),
+ _MSG_NAME(Tremove),
+ _MSG_NAME(Rremove),
+ _MSG_NAME(Tstat),
+ _MSG_NAME(Rstat),
+ _MSG_NAME(Twstat),
+ _MSG_NAME(Rwstat),
+ _MSG_NAME(Tsession),
+ _MSG_NAME(Rsession),
+ _MSG_NAME(Tsread),
+ _MSG_NAME(Rsread),
+ _MSG_NAME(Tswrite),
+ _MSG_NAME(Rswrite),
+ },
+#endif /* CONFIG_9P_ENABLE_9P2000_e */
+#if CONFIG_9P_ENABLE_9P2000_u
+ [LIB9P_VER_9P2000_u] = {
+ _MSG_NAME(Tversion),
+ _MSG_NAME(Rversion),
+ _MSG_NAME(Tauth),
+ _MSG_NAME(Rauth),
+ _MSG_NAME(Tattach),
+ _MSG_NAME(Rattach),
+ _MSG_NAME(Rerror),
+ _MSG_NAME(Tflush),
+ _MSG_NAME(Rflush),
+ _MSG_NAME(Twalk),
+ _MSG_NAME(Rwalk),
+ _MSG_NAME(Topen),
+ _MSG_NAME(Ropen),
+ _MSG_NAME(Tcreate),
+ _MSG_NAME(Rcreate),
+ _MSG_NAME(Tread),
+ _MSG_NAME(Rread),
+ _MSG_NAME(Twrite),
+ _MSG_NAME(Rwrite),
+ _MSG_NAME(Tclunk),
+ _MSG_NAME(Rclunk),
+ _MSG_NAME(Tremove),
+ _MSG_NAME(Rremove),
+ _MSG_NAME(Tstat),
+ _MSG_NAME(Rstat),
+ _MSG_NAME(Twstat),
+ _MSG_NAME(Rwstat),
+ },
+#endif /* CONFIG_9P_ENABLE_9P2000_u */
+};
/* bitmasks *******************************************************************/
@@ -212,7 +371,7 @@ LM_ALWAYS_INLINE static bool validate_d(struct _validate_ctx *ctx) {
uint32_t base_offset = ctx->net_offset;
if (validate_4(ctx))
return true;
- uint32_t len = decode_u32le(&ctx->net_bytes[base_offset]);
+ uint32_t len = uint32le_decode(&ctx->net_bytes[base_offset]);
return _validate_size_net(ctx, len) || _validate_size_host(ctx, len);
}
@@ -222,8 +381,8 @@ LM_ALWAYS_INLINE static bool validate_s(struct _validate_ctx *ctx) {
uint32_t base_offset = ctx->net_offset;
if (validate_2(ctx))
return true;
- uint16_t len = decode_u16le(&ctx->net_bytes[base_offset]);
- if (_validate_size_net(ctx, len) || _validate_size_host(ctx, ((size_t)len)+1))
+ uint16_t len = uint16le_decode(&ctx->net_bytes[base_offset]);
+ if (_validate_size_net(ctx, len) || _validate_size_host(ctx, ((size_t)len)))
return true;
if (!is_valid_utf8_without_nul(&ctx->net_bytes[base_offset+2], len))
return lib9p_error(ctx->ctx, LINUX_EBADMSG, "message contains invalid UTF-8");
@@ -236,7 +395,7 @@ LM_ALWAYS_INLINE static bool validate_dm(struct _validate_ctx *ctx) {
if (validate_4(ctx))
return true;
lib9p_dm_t mask = dm_masks[ctx->ctx->version];
- lib9p_dm_t val = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]);
+ lib9p_dm_t val = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]);
if (val & ~mask)
return lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "unknown bits in dm bitfield: %#04"PRIx32, val & ~mask);
return false;
@@ -248,7 +407,7 @@ LM_ALWAYS_INLINE static bool validate_qt(struct _validate_ctx *ctx) {
if (validate_1(ctx))
return true;
lib9p_qt_t mask = qt_masks[ctx->ctx->version];
- lib9p_qt_t val = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]);
+ lib9p_qt_t val = ctx->net_bytes[ctx->net_offset-1];
if (val & ~mask)
return lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "unknown bits in qt bitfield: %#01"PRIx8, val & ~mask);
return false;
@@ -266,7 +425,7 @@ LM_ALWAYS_INLINE static bool validate_o(struct _validate_ctx *ctx) {
if (validate_1(ctx))
return true;
lib9p_o_t mask = o_masks[ctx->ctx->version];
- lib9p_o_t val = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]);
+ lib9p_o_t val = ctx->net_bytes[ctx->net_offset-1];
if (val & ~mask)
return lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "unknown bits in o bitfield: %#01"PRIx8, val & ~mask);
return false;
@@ -278,7 +437,7 @@ LM_ALWAYS_INLINE static bool validate_getattr(struct _validate_ctx *ctx) {
if (validate_8(ctx))
return true;
lib9p_getattr_t mask = getattr_masks[ctx->ctx->version];
- lib9p_getattr_t val = decode_u64le(&ctx->net_bytes[ctx->net_offset-8]);
+ lib9p_getattr_t val = uint64le_decode(&ctx->net_bytes[ctx->net_offset-8]);
if (val & ~mask)
return lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "unknown bits in getattr bitfield: %#08"PRIx64, val & ~mask);
return false;
@@ -288,7 +447,7 @@ LM_ALWAYS_INLINE static bool validate_setattr(struct _validate_ctx *ctx) {
if (validate_4(ctx))
return true;
lib9p_setattr_t mask = setattr_masks[ctx->ctx->version];
- lib9p_setattr_t val = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]);
+ lib9p_setattr_t val = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]);
if (val & ~mask)
return lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "unknown bits in setattr bitfield: %#04"PRIx32, val & ~mask);
return false;
@@ -302,7 +461,7 @@ LM_ALWAYS_INLINE static bool validate_lock_flags(struct _validate_ctx *ctx) {
if (validate_4(ctx))
return true;
lib9p_lock_flags_t mask = lock_flags_masks[ctx->ctx->version];
- lib9p_lock_flags_t val = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]);
+ lib9p_lock_flags_t val = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]);
if (val & ~mask)
return lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "unknown bits in lock_flags bitfield: %#04"PRIx32, val & ~mask);
return false;
@@ -313,14 +472,23 @@ LM_ALWAYS_INLINE static bool validate_lock_status(struct _validate_ctx *ctx) {
}
#endif /* CONFIG_9P_ENABLE_9P2000_L */
+#if CONFIG_9P_ENABLE_9P2000_e
+LM_ALWAYS_INLINE static bool validate_d_e(struct _validate_ctx *ctx) {
+ return false
+ || validate_4(ctx)
+ || _validate_list(ctx, uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]), validate_1, sizeof(uint8_t))
+ ;
+}
+
+#endif /* CONFIG_9P_ENABLE_9P2000_e */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_FLATTEN static bool validate_Tflush(struct _validate_ctx *ctx) {
uint32_t size;
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; }))
+ || (({ _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_2(ctx)
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
@@ -335,8 +503,8 @@ LM_FLATTEN static bool validate_Rflush(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
|| ({ 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); })
@@ -350,8 +518,8 @@ LM_FLATTEN static bool validate_Rwrite(struct _validate_ctx *ctx) {
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; }))
+ || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; }))
+ || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; }))
|| validate_tag(ctx)
|| validate_4(ctx)
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
@@ -368,8 +536,8 @@ LM_FLATTEN static bool validate_Rclunk(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
|| ({ 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); })
@@ -385,8 +553,8 @@ LM_FLATTEN static bool validate_Rremove(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
|| ({ 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); })
@@ -402,8 +570,8 @@ LM_FLATTEN static bool validate_Rwstat(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
|| ({ 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); })
@@ -419,8 +587,8 @@ LM_FLATTEN static bool validate_Rlerror(struct _validate_ctx *ctx) {
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; }))
+ || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; }))
+ || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; }))
|| validate_tag(ctx)
|| validate_4(ctx)
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
@@ -435,8 +603,8 @@ LM_FLATTEN static bool validate_Rstatfs(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
@@ -459,8 +627,8 @@ LM_FLATTEN static bool validate_Rrename(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
|| ({ 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); })
@@ -474,8 +642,8 @@ LM_FLATTEN static bool validate_Rsetattr(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
|| ({ 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); })
@@ -489,8 +657,8 @@ LM_FLATTEN static bool validate_Rxattrwalk(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
@@ -505,8 +673,8 @@ LM_FLATTEN static bool validate_Rxattrcreate(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
|| ({ 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); })
@@ -520,11 +688,11 @@ LM_FLATTEN static bool validate_Rreaddir(struct _validate_ctx *ctx) {
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; }))
+ || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; }))
+ || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; }))
|| validate_tag(ctx)
|| validate_4(ctx)
- || _validate_list(ctx, decode_u32le(&ctx->net_bytes[ctx->net_offset-4]), validate_1, sizeof(uint8_t))
+ || _validate_list(ctx, uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]), validate_1, sizeof(uint8_t))
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
|| ({ uint8_t exp = 41; (((uint8_t)typ) != exp) &&
@@ -537,8 +705,8 @@ LM_FLATTEN static bool validate_Rfsync(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
|| ({ 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); })
@@ -552,8 +720,8 @@ LM_FLATTEN static bool validate_Rlink(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
|| ({ 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); })
@@ -567,8 +735,8 @@ LM_FLATTEN static bool validate_Rrenameat(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
|| ({ 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); })
@@ -582,8 +750,8 @@ LM_FLATTEN static bool validate_Runlinkat(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
|| ({ 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); })
@@ -599,8 +767,8 @@ LM_FLATTEN static bool validate_Tsession(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
@@ -615,8 +783,8 @@ LM_FLATTEN static bool validate_Rsession(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
|| ({ 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); })
@@ -630,8 +798,8 @@ LM_FLATTEN static bool validate_Rswrite(struct _validate_ctx *ctx) {
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; }))
+ || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; }))
+ || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; }))
|| validate_tag(ctx)
|| validate_4(ctx)
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
@@ -650,12 +818,12 @@ LM_FLATTEN static bool validate_Tread(struct _validate_ctx *ctx) {
uint32_t count;
uint32_t _size_offset;
return false
- || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; }))
- || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; }))
+ || (({ _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_8(ctx) || ({ offset = decode_u64le(&ctx->net_bytes[ctx->net_offset-8]); false; }))
- || (validate_4(ctx) || ({ count = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; }))
+ || (validate_8(ctx) || ({ offset = uint64le_decode(&ctx->net_bytes[ctx->net_offset-8]); false; }))
+ || (validate_4(ctx) || ({ count = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; }))
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
|| ({ uint8_t exp = 116; (((uint8_t)typ) != exp) &&
@@ -672,8 +840,8 @@ LM_FLATTEN static bool validate_Tclunk(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
@@ -688,8 +856,8 @@ LM_FLATTEN static bool validate_Tremove(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
@@ -706,8 +874,8 @@ LM_FLATTEN static bool validate_Tstat(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
@@ -724,8 +892,8 @@ LM_FLATTEN static bool validate_Tstatfs(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
@@ -740,8 +908,8 @@ LM_FLATTEN static bool validate_Tlopen(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
@@ -757,8 +925,8 @@ LM_FLATTEN static bool validate_Treadlink(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
@@ -773,8 +941,8 @@ LM_FLATTEN static bool validate_Treaddir(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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_8(ctx)
@@ -791,8 +959,8 @@ LM_FLATTEN static bool validate_Tfsync(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
@@ -810,8 +978,8 @@ LM_FLATTEN static bool validate_Rread(struct _validate_ctx *ctx) {
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; }))
+ || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; }))
+ || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; }))
|| validate_tag(ctx)
|| validate_d(ctx)
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
@@ -827,11 +995,11 @@ LM_FLATTEN static bool validate_Twrite(struct _validate_ctx *ctx) {
uint64_t offset;
uint32_t _size_offset;
return false
- || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; }))
- || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; }))
+ || (({ _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_8(ctx) || ({ offset = decode_u64le(&ctx->net_bytes[ctx->net_offset-8]); false; }))
+ || (validate_8(ctx) || ({ offset = uint64le_decode(&ctx->net_bytes[ctx->net_offset-8]); false; }))
|| validate_d(ctx)
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
@@ -842,33 +1010,13 @@ LM_FLATTEN static bool validate_Twrite(struct _validate_ctx *ctx) {
;
}
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000_e
-LM_FLATTEN static bool validate_Rsread(struct _validate_ctx *ctx) {
- uint32_t size;
- uint8_t typ;
- uint32_t _size_offset;
- return false
- || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = 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)
- || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
- lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
- || ({ uint8_t exp = 153; (((uint8_t)typ) != exp) &&
- lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); })
- ;
-}
-
-#endif /* CONFIG_9P_ENABLE_9P2000_e */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_FLATTEN static bool validate_Tversion(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; }))
+ || (({ _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_s(ctx)
@@ -884,8 +1032,8 @@ LM_FLATTEN static bool validate_Rversion(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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_s(ctx)
@@ -903,8 +1051,8 @@ LM_FLATTEN static bool validate_Rerror(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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
@@ -925,13 +1073,13 @@ LM_FLATTEN static bool validate_Twalk(struct _validate_ctx *ctx) {
uint16_t nwname;
uint32_t _size_offset;
return false
- || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; }))
- || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; }))
+ || (({ _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_fid(ctx)
- || (validate_2(ctx) || ({ nwname = decode_u16le(&ctx->net_bytes[ctx->net_offset-2]); false; }))
- || _validate_list(ctx, decode_u16le(&ctx->net_bytes[ctx->net_offset-2]), validate_s, sizeof(struct lib9p_s))
+ || (validate_2(ctx) || ({ nwname = uint16le_decode(&ctx->net_bytes[ctx->net_offset-2]); false; }))
+ || _validate_list(ctx, uint16le_decode(&ctx->net_bytes[ctx->net_offset-2]), validate_s, sizeof(struct lib9p_s))
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
|| ({ uint8_t exp = 110; (((uint8_t)typ) != exp) &&
@@ -948,8 +1096,8 @@ LM_FLATTEN static bool validate_Trename(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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_fid(ctx)
@@ -966,8 +1114,8 @@ LM_FLATTEN static bool validate_Rreadlink(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
@@ -982,8 +1130,8 @@ LM_FLATTEN static bool validate_Txattrwalk(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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_fid(ctx)
@@ -1000,8 +1148,8 @@ LM_FLATTEN static bool validate_Txattrcreate(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
@@ -1019,8 +1167,8 @@ LM_FLATTEN static bool validate_Tgetlock(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
@@ -1040,8 +1188,8 @@ LM_FLATTEN static bool validate_Rgetlock(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
@@ -1060,8 +1208,8 @@ LM_FLATTEN static bool validate_Tlink(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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_fid(ctx)
@@ -1078,8 +1226,8 @@ LM_FLATTEN static bool validate_Trenameat(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
@@ -1097,8 +1245,8 @@ LM_FLATTEN static bool validate_Tunlinkat(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
@@ -1117,12 +1265,12 @@ LM_FLATTEN static bool validate_Tsread(struct _validate_ctx *ctx) {
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; }))
+ || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; }))
+ || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; }))
|| validate_tag(ctx)
|| validate_4(ctx)
|| validate_2(ctx)
- || _validate_list(ctx, decode_u16le(&ctx->net_bytes[ctx->net_offset-2]), validate_s, sizeof(struct lib9p_s))
+ || _validate_list(ctx, uint16le_decode(&ctx->net_bytes[ctx->net_offset-2]), validate_s, sizeof(struct lib9p_s))
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
|| ({ uint8_t exp = 152; (((uint8_t)typ) != exp) &&
@@ -1130,25 +1278,6 @@ LM_FLATTEN static bool validate_Tsread(struct _validate_ctx *ctx) {
;
}
-LM_FLATTEN static bool validate_Tswrite(struct _validate_ctx *ctx) {
- uint32_t size;
- uint8_t typ;
- uint32_t _size_offset;
- return false
- || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = 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)
- || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
- lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
- || ({ uint8_t exp = 154; (((uint8_t)typ) != exp) &&
- lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); })
- ;
-}
-
#endif /* CONFIG_9P_ENABLE_9P2000_e */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_ALWAYS_INLINE static bool validate_qid(struct _validate_ctx *ctx) {
@@ -1164,8 +1293,8 @@ LM_FLATTEN static bool validate_Tauth(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
@@ -1185,8 +1314,8 @@ LM_FLATTEN static bool validate_Tattach(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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_fid(ctx)
@@ -1209,8 +1338,8 @@ LM_FLATTEN static bool validate_Tlcreate(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
@@ -1229,8 +1358,8 @@ LM_FLATTEN static bool validate_Tsymlink(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
@@ -1248,8 +1377,8 @@ LM_FLATTEN static bool validate_Tmknod(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
@@ -1271,8 +1400,8 @@ LM_FLATTEN static bool validate_Topen(struct _validate_ctx *ctx) {
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; }))
+ || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; }))
+ || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; }))
|| validate_tag(ctx)
|| validate_fid(ctx)
|| validate_o(ctx)
@@ -1288,8 +1417,8 @@ LM_FLATTEN static bool validate_Tcreate(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
@@ -1309,8 +1438,8 @@ LM_FLATTEN static bool validate_Tgetattr(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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_getattr(ctx)
@@ -1326,8 +1455,8 @@ LM_FLATTEN static bool validate_Tsetattr(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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_setattr(ctx)
@@ -1351,8 +1480,8 @@ LM_FLATTEN static bool validate_Tlock(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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)
@@ -1373,8 +1502,8 @@ LM_FLATTEN static bool validate_Rlock(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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_status(ctx)
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
@@ -1385,12 +1514,49 @@ LM_FLATTEN static bool validate_Rlock(struct _validate_ctx *ctx) {
}
#endif /* CONFIG_9P_ENABLE_9P2000_L */
+#if CONFIG_9P_ENABLE_9P2000_e
+LM_FLATTEN static bool validate_Rsread(struct _validate_ctx *ctx) {
+ uint32_t size;
+ uint8_t typ;
+ uint32_t _size_offset;
+ return false
+ || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; }))
+ || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; }))
+ || validate_tag(ctx)
+ || validate_d_e(ctx)
+ || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
+ lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
+ || ({ uint8_t exp = 153; (((uint8_t)typ) != exp) &&
+ lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); })
+ ;
+}
+
+LM_FLATTEN static bool validate_Tswrite(struct _validate_ctx *ctx) {
+ uint32_t size;
+ uint8_t typ;
+ uint32_t _size_offset;
+ return false
+ || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = uint32le_decode(&ctx->net_bytes[ctx->net_offset-4]); false; }))
+ || (validate_1(ctx) || ({ typ = ctx->net_bytes[ctx->net_offset-1]; false; }))
+ || validate_tag(ctx)
+ || validate_4(ctx)
+ || validate_2(ctx)
+ || _validate_list(ctx, uint16le_decode(&ctx->net_bytes[ctx->net_offset-2]), validate_s, sizeof(struct lib9p_s))
+ || validate_d_e(ctx)
+ || ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
+ lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
+ || ({ uint8_t exp = 154; (((uint8_t)typ) != exp) &&
+ lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "typ value is wrong (actual:%"PRIu8" != correct:%"PRIu8")", (uint8_t)typ, exp); })
+ ;
+}
+
+#endif /* CONFIG_9P_ENABLE_9P2000_e */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_ALWAYS_INLINE static bool validate_stat(struct _validate_ctx *ctx) {
uint16_t stat_size;
uint32_t _kern_type_offset;
return false
- || (validate_2(ctx) || ({ stat_size = decode_u16le(&ctx->net_bytes[ctx->net_offset-2]); false; }))
+ || (validate_2(ctx) || ({ stat_size = uint16le_decode(&ctx->net_bytes[ctx->net_offset-2]); false; }))
|| ({ _kern_type_offset = ctx->net_offset; validate_2(ctx); })
|| validate_4(ctx)
|| validate_qid(ctx)
@@ -1420,8 +1586,8 @@ LM_FLATTEN static bool validate_Rauth(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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_qid(ctx)
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
@@ -1436,8 +1602,8 @@ LM_FLATTEN static bool validate_Rattach(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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_qid(ctx)
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
@@ -1453,11 +1619,11 @@ LM_FLATTEN static bool validate_Rwalk(struct _validate_ctx *ctx) {
uint16_t nwqid;
uint32_t _size_offset;
return false
- || (({ _size_offset = ctx->net_offset; validate_4(ctx); }) || ({ size = decode_u32le(&ctx->net_bytes[ctx->net_offset-4]); false; }))
- || (validate_1(ctx) || ({ typ = decode_u8le(&ctx->net_bytes[ctx->net_offset-1]); false; }))
+ || (({ _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_2(ctx) || ({ nwqid = decode_u16le(&ctx->net_bytes[ctx->net_offset-2]); false; }))
- || _validate_list(ctx, decode_u16le(&ctx->net_bytes[ctx->net_offset-2]), validate_qid, sizeof(struct lib9p_qid))
+ || (validate_2(ctx) || ({ nwqid = uint16le_decode(&ctx->net_bytes[ctx->net_offset-2]); false; }))
+ || _validate_list(ctx, uint16le_decode(&ctx->net_bytes[ctx->net_offset-2]), validate_qid, sizeof(struct lib9p_qid))
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
|| ({ uint8_t exp = 111; (((uint8_t)typ) != exp) &&
@@ -1474,8 +1640,8 @@ LM_FLATTEN static bool validate_Ropen(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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_qid(ctx)
|| validate_4(ctx)
@@ -1491,8 +1657,8 @@ LM_FLATTEN static bool validate_Rcreate(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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_qid(ctx)
|| validate_4(ctx)
@@ -1510,8 +1676,8 @@ LM_FLATTEN static bool validate_Rlopen(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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_qid(ctx)
|| validate_4(ctx)
@@ -1527,8 +1693,8 @@ LM_FLATTEN static bool validate_Rlcreate(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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_qid(ctx)
|| validate_4(ctx)
@@ -1544,8 +1710,8 @@ LM_FLATTEN static bool validate_Rsymlink(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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_qid(ctx)
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
@@ -1560,8 +1726,8 @@ LM_FLATTEN static bool validate_Rmknod(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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_qid(ctx)
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
@@ -1576,8 +1742,8 @@ LM_FLATTEN static bool validate_Rgetattr(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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_qid(ctx)
@@ -1611,8 +1777,8 @@ LM_FLATTEN static bool validate_Tmkdir(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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_qid(ctx)
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
@@ -1631,10 +1797,10 @@ LM_FLATTEN static bool validate_Rstat(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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_2(ctx) || ({ nstat = decode_u16le(&ctx->net_bytes[ctx->net_offset-2]); false; }))
+ || (validate_2(ctx) || ({ nstat = uint16le_decode(&ctx->net_bytes[ctx->net_offset-2]); false; }))
|| ({ _stat_offset = ctx->net_offset; validate_stat(ctx); })
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
@@ -1652,11 +1818,11 @@ LM_FLATTEN static bool validate_Twstat(struct _validate_ctx *ctx) {
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; }))
+ || (({ _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_2(ctx) || ({ nstat = decode_u16le(&ctx->net_bytes[ctx->net_offset-2]); false; }))
+ || (validate_2(ctx) || ({ nstat = uint16le_decode(&ctx->net_bytes[ctx->net_offset-2]); false; }))
|| ({ _stat_offset = ctx->net_offset; validate_stat(ctx); })
|| ({ uint32_t exp = ctx->net_offset - _size_offset; (((uint32_t)size) != exp) &&
lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "size value is wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)size, exp); })
@@ -1671,22 +1837,22 @@ LM_FLATTEN static bool validate_Twstat(struct _validate_ctx *ctx) {
/* unmarshal_* ****************************************************************/
LM_ALWAYS_INLINE static void unmarshal_1(struct _unmarshal_ctx *ctx, uint8_t *out) {
- *out = decode_u8le(&ctx->net_bytes[ctx->net_offset]);
+ *out = ctx->net_bytes[ctx->net_offset];
ctx->net_offset += 1;
}
LM_ALWAYS_INLINE static void unmarshal_2(struct _unmarshal_ctx *ctx, uint16_t *out) {
- *out = decode_u16le(&ctx->net_bytes[ctx->net_offset]);
+ *out = uint16le_decode(&ctx->net_bytes[ctx->net_offset]);
ctx->net_offset += 2;
}
LM_ALWAYS_INLINE static void unmarshal_4(struct _unmarshal_ctx *ctx, uint32_t *out) {
- *out = decode_u32le(&ctx->net_bytes[ctx->net_offset]);
+ *out = uint32le_decode(&ctx->net_bytes[ctx->net_offset]);
ctx->net_offset += 4;
}
LM_ALWAYS_INLINE static void unmarshal_8(struct _unmarshal_ctx *ctx, uint64_t *out) {
- *out = decode_u64le(&ctx->net_bytes[ctx->net_offset]);
+ *out = uint64le_decode(&ctx->net_bytes[ctx->net_offset]);
ctx->net_offset += 8;
}
@@ -1719,8 +1885,6 @@ LM_ALWAYS_INLINE static void unmarshal_s(struct _unmarshal_ctx *ctx, struct lib9
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';
}
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
@@ -1770,6 +1934,17 @@ LM_ALWAYS_INLINE static void unmarshal_lock_status(struct _unmarshal_ctx *ctx, l
}
#endif /* CONFIG_9P_ENABLE_9P2000_L */
+#if CONFIG_9P_ENABLE_9P2000_e
+LM_ALWAYS_INLINE static void unmarshal_d_e(struct _unmarshal_ctx *ctx, struct lib9p_d_e *out) {
+ memset(out, 0, sizeof(*out));
+ unmarshal_4(ctx, &out->len);
+ out->dat = ctx->extra;
+ ctx->extra += sizeof(out->dat[0]) * out->len;
+ for (typeof(out->len) i = 0; i < out->len; i++)
+ unmarshal_1(ctx, &out->dat[i]);
+}
+
+#endif /* CONFIG_9P_ENABLE_9P2000_e */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_FLATTEN static void unmarshal_Tflush(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tflush *out) {
memset(out, 0, sizeof(*out));
@@ -2045,18 +2220,6 @@ LM_FLATTEN static void unmarshal_Twrite(struct _unmarshal_ctx *ctx, struct lib9p
unmarshal_d(ctx, &out->data);
}
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000_e
-LM_FLATTEN static void unmarshal_Rsread(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rsread *out) {
- memset(out, 0, sizeof(*out));
- ctx->net_offset += 4;
- ctx->net_offset += 1;
- unmarshal_tag(ctx, &out->tag);
- unmarshal_d(ctx, &out->data);
-}
-
-#endif /* CONFIG_9P_ENABLE_9P2000_e */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_FLATTEN static void unmarshal_Tversion(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tversion *out) {
memset(out, 0, sizeof(*out));
ctx->net_offset += 4;
@@ -2216,20 +2379,6 @@ LM_FLATTEN static void unmarshal_Tsread(struct _unmarshal_ctx *ctx, struct lib9p
unmarshal_s(ctx, &out->wname[i]);
}
-LM_FLATTEN static void unmarshal_Tswrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tswrite *out) {
- memset(out, 0, sizeof(*out));
- ctx->net_offset += 4;
- ctx->net_offset += 1;
- unmarshal_tag(ctx, &out->tag);
- unmarshal_4(ctx, &out->fid);
- unmarshal_2(ctx, &out->nwname);
- out->wname = ctx->extra;
- ctx->extra += sizeof(out->wname[0]) * out->nwname;
- for (typeof(out->nwname) i = 0; i < out->nwname; i++)
- unmarshal_s(ctx, &out->wname[i]);
- unmarshal_d(ctx, &out->data);
-}
-
#endif /* CONFIG_9P_ENABLE_9P2000_e */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_ALWAYS_INLINE static void unmarshal_qid(struct _unmarshal_ctx *ctx, struct lib9p_qid *out) {
@@ -2377,6 +2526,30 @@ LM_FLATTEN static void unmarshal_Rlock(struct _unmarshal_ctx *ctx, struct lib9p_
}
#endif /* CONFIG_9P_ENABLE_9P2000_L */
+#if CONFIG_9P_ENABLE_9P2000_e
+LM_FLATTEN static void unmarshal_Rsread(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rsread *out) {
+ memset(out, 0, sizeof(*out));
+ ctx->net_offset += 4;
+ ctx->net_offset += 1;
+ unmarshal_tag(ctx, &out->tag);
+ unmarshal_d_e(ctx, &out->data);
+}
+
+LM_FLATTEN static void unmarshal_Tswrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tswrite *out) {
+ memset(out, 0, sizeof(*out));
+ ctx->net_offset += 4;
+ ctx->net_offset += 1;
+ unmarshal_tag(ctx, &out->tag);
+ unmarshal_4(ctx, &out->fid);
+ unmarshal_2(ctx, &out->nwname);
+ out->wname = ctx->extra;
+ ctx->extra += sizeof(out->wname[0]) * out->nwname;
+ for (typeof(out->nwname) i = 0; i < out->nwname; i++)
+ unmarshal_s(ctx, &out->wname[i]);
+ unmarshal_d_e(ctx, &out->data);
+}
+
+#endif /* CONFIG_9P_ENABLE_9P2000_e */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_ALWAYS_INLINE static void unmarshal_stat(struct _unmarshal_ctx *ctx, struct lib9p_stat *out) {
memset(out, 0, sizeof(*out));
@@ -2564,7 +2737,7 @@ LM_ALWAYS_INLINE static bool marshal_1(struct _marshal_ctx *ctx, uint8_t *val) {
LM_ALWAYS_INLINE static 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]);
+ uint16le_encode(&ctx->net_bytes[ctx->net_offset], *val);
ctx->net_offset += 2;
return false;
}
@@ -2572,7 +2745,7 @@ LM_ALWAYS_INLINE static bool marshal_2(struct _marshal_ctx *ctx, uint16_t *val)
LM_ALWAYS_INLINE static 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]);
+ uint32le_encode(&ctx->net_bytes[ctx->net_offset], *val);
ctx->net_offset += 4;
return false;
}
@@ -2580,7 +2753,7 @@ LM_ALWAYS_INLINE static bool marshal_4(struct _marshal_ctx *ctx, uint32_t *val)
LM_ALWAYS_INLINE static 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]);
+ uint64le_encode(&ctx->net_bytes[ctx->net_offset], *val);
ctx->net_offset += 8;
return false;
}
@@ -2671,6 +2844,18 @@ LM_ALWAYS_INLINE static bool marshal_lock_status(struct _marshal_ctx *ctx, lib9p
}
#endif /* CONFIG_9P_ENABLE_9P2000_L */
+#if CONFIG_9P_ENABLE_9P2000_e
+LM_ALWAYS_INLINE static bool marshal_d_e(struct _marshal_ctx *ctx, struct lib9p_d_e *val) {
+ return false
+ || marshal_4(ctx, &val->len)
+ || ({ bool err = false;
+ for (typeof(val->len) i = 0; i < val->len && !err; i++)
+ err = marshal_1(ctx, &val->dat[i]);
+ err; })
+ ;
+}
+
+#endif /* CONFIG_9P_ENABLE_9P2000_e */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_FLATTEN static bool marshal_Tflush(struct _marshal_ctx *ctx, struct lib9p_msg_Tflush *val) {
uint32_t _size_offset;
@@ -2680,8 +2865,8 @@ LM_FLATTEN static bool marshal_Tflush(struct _marshal_ctx *ctx, struct lib9p_msg
|| ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
|| marshal_tag(ctx, &val->tag)
|| marshal_2(ctx, &val->oldtag)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(108, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 108; false; })
;
}
@@ -2692,8 +2877,8 @@ LM_FLATTEN static bool marshal_Rflush(struct _marshal_ctx *ctx, struct lib9p_msg
|| ({ _size_offset = ctx->net_offset; ({ ctx->net_offset += 4; false; }); })
|| ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
|| marshal_tag(ctx, &val->tag)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(109, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 109; false; })
;
}
@@ -2705,8 +2890,8 @@ LM_FLATTEN static bool marshal_Rwrite(struct _marshal_ctx *ctx, struct lib9p_msg
|| ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
|| marshal_tag(ctx, &val->tag)
|| marshal_4(ctx, &val->count)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(119, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 119; false; })
;
}
@@ -2719,8 +2904,8 @@ LM_FLATTEN static bool marshal_Rclunk(struct _marshal_ctx *ctx, struct lib9p_msg
|| ({ _size_offset = ctx->net_offset; ({ ctx->net_offset += 4; false; }); })
|| ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
|| marshal_tag(ctx, &val->tag)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(121, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 121; false; })
;
}
@@ -2733,8 +2918,8 @@ LM_FLATTEN static bool marshal_Rremove(struct _marshal_ctx *ctx, struct lib9p_ms
|| ({ _size_offset = ctx->net_offset; ({ ctx->net_offset += 4; false; }); })
|| ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
|| marshal_tag(ctx, &val->tag)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(123, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 123; false; })
;
}
@@ -2747,8 +2932,8 @@ LM_FLATTEN static bool marshal_Rwstat(struct _marshal_ctx *ctx, struct lib9p_msg
|| ({ _size_offset = ctx->net_offset; ({ ctx->net_offset += 4; false; }); })
|| ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
|| marshal_tag(ctx, &val->tag)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(127, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 127; false; })
;
}
@@ -2762,8 +2947,8 @@ LM_FLATTEN static bool marshal_Rlerror(struct _marshal_ctx *ctx, struct lib9p_ms
|| ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
|| marshal_tag(ctx, &val->tag)
|| marshal_4(ctx, &val->ecode)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(7, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 7; false; })
;
}
@@ -2783,8 +2968,8 @@ LM_FLATTEN static bool marshal_Rstatfs(struct _marshal_ctx *ctx, struct lib9p_ms
|| marshal_8(ctx, &val->ffree)
|| marshal_8(ctx, &val->fsid)
|| marshal_4(ctx, &val->namelen)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(9, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 9; false; })
;
}
@@ -2795,8 +2980,8 @@ LM_FLATTEN static bool marshal_Rrename(struct _marshal_ctx *ctx, struct lib9p_ms
|| ({ _size_offset = ctx->net_offset; ({ ctx->net_offset += 4; false; }); })
|| ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
|| marshal_tag(ctx, &val->tag)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(21, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 21; false; })
;
}
@@ -2807,8 +2992,8 @@ LM_FLATTEN static bool marshal_Rsetattr(struct _marshal_ctx *ctx, struct lib9p_m
|| ({ _size_offset = ctx->net_offset; ({ ctx->net_offset += 4; false; }); })
|| ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
|| marshal_tag(ctx, &val->tag)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(27, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 27; false; })
;
}
@@ -2820,8 +3005,8 @@ LM_FLATTEN static bool marshal_Rxattrwalk(struct _marshal_ctx *ctx, struct lib9p
|| ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
|| marshal_tag(ctx, &val->tag)
|| marshal_8(ctx, &val->attr_size)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(31, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 31; false; })
;
}
@@ -2832,8 +3017,8 @@ LM_FLATTEN static bool marshal_Rxattrcreate(struct _marshal_ctx *ctx, struct lib
|| ({ _size_offset = ctx->net_offset; ({ ctx->net_offset += 4; false; }); })
|| ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
|| marshal_tag(ctx, &val->tag)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(33, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 33; false; })
;
}
@@ -2849,8 +3034,8 @@ LM_FLATTEN static bool marshal_Rreaddir(struct _marshal_ctx *ctx, struct lib9p_m
for (typeof(val->count) i = 0; i < val->count && !err; i++)
err = marshal_1(ctx, &val->data[i]);
err; })
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(41, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 41; false; })
;
}
@@ -2861,8 +3046,8 @@ LM_FLATTEN static bool marshal_Rfsync(struct _marshal_ctx *ctx, struct lib9p_msg
|| ({ _size_offset = ctx->net_offset; ({ ctx->net_offset += 4; false; }); })
|| ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
|| marshal_tag(ctx, &val->tag)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(51, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 51; false; })
;
}
@@ -2873,8 +3058,8 @@ LM_FLATTEN static bool marshal_Rlink(struct _marshal_ctx *ctx, struct lib9p_msg_
|| ({ _size_offset = ctx->net_offset; ({ ctx->net_offset += 4; false; }); })
|| ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
|| marshal_tag(ctx, &val->tag)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(71, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 71; false; })
;
}
@@ -2885,8 +3070,8 @@ LM_FLATTEN static bool marshal_Rrenameat(struct _marshal_ctx *ctx, struct lib9p_
|| ({ _size_offset = ctx->net_offset; ({ ctx->net_offset += 4; false; }); })
|| ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
|| marshal_tag(ctx, &val->tag)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(75, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 75; false; })
;
}
@@ -2897,8 +3082,8 @@ LM_FLATTEN static bool marshal_Runlinkat(struct _marshal_ctx *ctx, struct lib9p_
|| ({ _size_offset = ctx->net_offset; ({ ctx->net_offset += 4; false; }); })
|| ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
|| marshal_tag(ctx, &val->tag)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(77, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 77; false; })
;
}
@@ -2912,8 +3097,8 @@ LM_FLATTEN static bool marshal_Tsession(struct _marshal_ctx *ctx, struct lib9p_m
|| ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
|| marshal_tag(ctx, &val->tag)
|| marshal_8(ctx, &val->key)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(150, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 150; false; })
;
}
@@ -2924,8 +3109,8 @@ LM_FLATTEN static bool marshal_Rsession(struct _marshal_ctx *ctx, struct lib9p_m
|| ({ _size_offset = ctx->net_offset; ({ ctx->net_offset += 4; false; }); })
|| ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
|| marshal_tag(ctx, &val->tag)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(151, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 151; false; })
;
}
@@ -2937,8 +3122,8 @@ LM_FLATTEN static bool marshal_Rswrite(struct _marshal_ctx *ctx, struct lib9p_ms
|| ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
|| marshal_tag(ctx, &val->tag)
|| marshal_4(ctx, &val->count)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(155, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 155; false; })
;
}
@@ -2954,8 +3139,8 @@ LM_FLATTEN static bool marshal_Tread(struct _marshal_ctx *ctx, struct lib9p_msg_
|| marshal_fid(ctx, &val->fid)
|| marshal_8(ctx, &val->offset)
|| marshal_4(ctx, &val->count)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(116, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 116; false; })
;
}
@@ -2967,8 +3152,8 @@ LM_FLATTEN static bool marshal_Tclunk(struct _marshal_ctx *ctx, struct lib9p_msg
|| ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
|| marshal_tag(ctx, &val->tag)
|| marshal_fid(ctx, &val->fid)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(120, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 120; false; })
;
}
@@ -2980,8 +3165,8 @@ LM_FLATTEN static bool marshal_Tremove(struct _marshal_ctx *ctx, struct lib9p_ms
|| ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
|| marshal_tag(ctx, &val->tag)
|| marshal_fid(ctx, &val->fid)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(122, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 122; false; })
;
}
@@ -2995,8 +3180,8 @@ LM_FLATTEN static bool marshal_Tstat(struct _marshal_ctx *ctx, struct lib9p_msg_
|| ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
|| marshal_tag(ctx, &val->tag)
|| marshal_fid(ctx, &val->fid)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(124, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 124; false; })
;
}
@@ -3010,8 +3195,8 @@ LM_FLATTEN static bool marshal_Tstatfs(struct _marshal_ctx *ctx, struct lib9p_ms
|| ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
|| marshal_tag(ctx, &val->tag)
|| marshal_fid(ctx, &val->fid)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(8, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 8; false; })
;
}
@@ -3024,8 +3209,8 @@ LM_FLATTEN static bool marshal_Tlopen(struct _marshal_ctx *ctx, struct lib9p_msg
|| marshal_tag(ctx, &val->tag)
|| marshal_fid(ctx, &val->fid)
|| marshal_4(ctx, &val->flags)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(12, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 12; false; })
;
}
@@ -3037,8 +3222,8 @@ LM_FLATTEN static bool marshal_Treadlink(struct _marshal_ctx *ctx, struct lib9p_
|| ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
|| marshal_tag(ctx, &val->tag)
|| marshal_fid(ctx, &val->fid)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(22, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 22; false; })
;
}
@@ -3052,8 +3237,8 @@ LM_FLATTEN static bool marshal_Treaddir(struct _marshal_ctx *ctx, struct lib9p_m
|| marshal_fid(ctx, &val->fid)
|| marshal_8(ctx, &val->offset)
|| marshal_4(ctx, &val->count)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(40, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 40; false; })
;
}
@@ -3066,8 +3251,8 @@ LM_FLATTEN static bool marshal_Tfsync(struct _marshal_ctx *ctx, struct lib9p_msg
|| marshal_tag(ctx, &val->tag)
|| marshal_fid(ctx, &val->fid)
|| marshal_4(ctx, &val->datasync)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(50, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 50; false; })
;
}
@@ -3081,8 +3266,8 @@ LM_FLATTEN static bool marshal_Rread(struct _marshal_ctx *ctx, struct lib9p_msg_
|| ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
|| marshal_tag(ctx, &val->tag)
|| marshal_d(ctx, &val->data)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(117, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 117; false; })
;
}
@@ -3096,28 +3281,11 @@ LM_FLATTEN static bool marshal_Twrite(struct _marshal_ctx *ctx, struct lib9p_msg
|| marshal_fid(ctx, &val->fid)
|| marshal_8(ctx, &val->offset)
|| marshal_d(ctx, &val->data)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(118, &ctx->net_bytes[_typ_offset]); false; })
- ;
-}
-
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000_e
-LM_FLATTEN static bool marshal_Rsread(struct _marshal_ctx *ctx, struct lib9p_msg_Rsread *val) {
- uint32_t _size_offset;
- uint32_t _typ_offset;
- return false
- || ({ _size_offset = ctx->net_offset; ({ ctx->net_offset += 4; false; }); })
- || ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
- || marshal_tag(ctx, &val->tag)
- || marshal_d(ctx, &val->data)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(153, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 118; false; })
;
}
-#endif /* CONFIG_9P_ENABLE_9P2000_e */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_FLATTEN static bool marshal_Tversion(struct _marshal_ctx *ctx, struct lib9p_msg_Tversion *val) {
uint32_t _size_offset;
uint32_t _typ_offset;
@@ -3127,8 +3295,8 @@ LM_FLATTEN static bool marshal_Tversion(struct _marshal_ctx *ctx, struct lib9p_m
|| marshal_tag(ctx, &val->tag)
|| marshal_4(ctx, &val->max_msg_size)
|| marshal_s(ctx, &val->version)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(100, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 100; false; })
;
}
@@ -3141,8 +3309,8 @@ LM_FLATTEN static bool marshal_Rversion(struct _marshal_ctx *ctx, struct lib9p_m
|| marshal_tag(ctx, &val->tag)
|| marshal_4(ctx, &val->max_msg_size)
|| marshal_s(ctx, &val->version)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(101, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 101; false; })
;
}
@@ -3159,8 +3327,8 @@ LM_FLATTEN static bool marshal_Rerror(struct _marshal_ctx *ctx, struct lib9p_msg
#if CONFIG_9P_ENABLE_9P2000_u
|| ( is_ver(ctx, 9P2000_u) && marshal_4(ctx, &val->errno) )
#endif /* CONFIG_9P_ENABLE_9P2000_u */
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(107, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 107; false; })
;
}
@@ -3180,8 +3348,8 @@ LM_FLATTEN static bool marshal_Twalk(struct _marshal_ctx *ctx, struct lib9p_msg_
for (typeof(val->nwname) i = 0; i < val->nwname && !err; i++)
err = marshal_s(ctx, &val->wname[i]);
err; })
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(110, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 110; false; })
;
}
@@ -3197,8 +3365,8 @@ LM_FLATTEN static bool marshal_Trename(struct _marshal_ctx *ctx, struct lib9p_ms
|| marshal_fid(ctx, &val->fid)
|| marshal_fid(ctx, &val->dfid)
|| marshal_s(ctx, &val->name)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(20, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 20; false; })
;
}
@@ -3210,8 +3378,8 @@ LM_FLATTEN static bool marshal_Rreadlink(struct _marshal_ctx *ctx, struct lib9p_
|| ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
|| marshal_tag(ctx, &val->tag)
|| marshal_s(ctx, &val->target)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(23, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 23; false; })
;
}
@@ -3225,8 +3393,8 @@ LM_FLATTEN static bool marshal_Txattrwalk(struct _marshal_ctx *ctx, struct lib9p
|| marshal_fid(ctx, &val->fid)
|| marshal_fid(ctx, &val->newfid)
|| marshal_s(ctx, &val->name)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(30, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 30; false; })
;
}
@@ -3241,8 +3409,8 @@ LM_FLATTEN static bool marshal_Txattrcreate(struct _marshal_ctx *ctx, struct lib
|| marshal_s(ctx, &val->name)
|| marshal_8(ctx, &val->attr_size)
|| marshal_4(ctx, &val->flags)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(32, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 32; false; })
;
}
@@ -3259,8 +3427,8 @@ LM_FLATTEN static bool marshal_Tgetlock(struct _marshal_ctx *ctx, struct lib9p_m
|| marshal_8(ctx, &val->length)
|| marshal_4(ctx, &val->proc_id)
|| marshal_s(ctx, &val->client_id)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(54, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 54; false; })
;
}
@@ -3276,8 +3444,8 @@ LM_FLATTEN static bool marshal_Rgetlock(struct _marshal_ctx *ctx, struct lib9p_m
|| marshal_8(ctx, &val->length)
|| marshal_4(ctx, &val->proc_id)
|| marshal_s(ctx, &val->client_id)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(55, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 55; false; })
;
}
@@ -3291,8 +3459,8 @@ LM_FLATTEN static bool marshal_Tlink(struct _marshal_ctx *ctx, struct lib9p_msg_
|| marshal_fid(ctx, &val->dfid)
|| marshal_fid(ctx, &val->fid)
|| marshal_s(ctx, &val->name)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(70, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 70; false; })
;
}
@@ -3307,8 +3475,8 @@ LM_FLATTEN static bool marshal_Trenameat(struct _marshal_ctx *ctx, struct lib9p_
|| marshal_s(ctx, &val->oldname)
|| marshal_fid(ctx, &val->newdirfid)
|| marshal_s(ctx, &val->newname)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(74, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 74; false; })
;
}
@@ -3322,8 +3490,8 @@ LM_FLATTEN static bool marshal_Tunlinkat(struct _marshal_ctx *ctx, struct lib9p_
|| marshal_fid(ctx, &val->dirfd)
|| marshal_s(ctx, &val->name)
|| marshal_4(ctx, &val->flags)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(76, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 76; false; })
;
}
@@ -3342,27 +3510,8 @@ LM_FLATTEN static bool marshal_Tsread(struct _marshal_ctx *ctx, struct lib9p_msg
for (typeof(val->nwname) i = 0; i < val->nwname && !err; i++)
err = marshal_s(ctx, &val->wname[i]);
err; })
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(152, &ctx->net_bytes[_typ_offset]); false; })
- ;
-}
-
-LM_FLATTEN static bool marshal_Tswrite(struct _marshal_ctx *ctx, struct lib9p_msg_Tswrite *val) {
- uint32_t _size_offset;
- uint32_t _typ_offset;
- return false
- || ({ _size_offset = ctx->net_offset; ({ ctx->net_offset += 4; false; }); })
- || ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
- || marshal_tag(ctx, &val->tag)
- || marshal_4(ctx, &val->fid)
- || marshal_2(ctx, &val->nwname)
- || ({ bool err = false;
- for (typeof(val->nwname) i = 0; i < val->nwname && !err; i++)
- err = marshal_s(ctx, &val->wname[i]);
- err; })
- || marshal_d(ctx, &val->data)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(154, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 152; false; })
;
}
@@ -3389,8 +3538,8 @@ LM_FLATTEN static bool marshal_Tauth(struct _marshal_ctx *ctx, struct lib9p_msg_
#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u
|| ( ( is_ver(ctx, 9P2000_L) || is_ver(ctx, 9P2000_u) ) && marshal_nuid(ctx, &val->n_uid) )
#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(102, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 102; false; })
;
}
@@ -3408,8 +3557,8 @@ LM_FLATTEN static bool marshal_Tattach(struct _marshal_ctx *ctx, struct lib9p_ms
#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u
|| ( ( is_ver(ctx, 9P2000_L) || is_ver(ctx, 9P2000_u) ) && marshal_nuid(ctx, &val->n_uid) )
#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(104, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 104; false; })
;
}
@@ -3427,8 +3576,8 @@ LM_FLATTEN static bool marshal_Tlcreate(struct _marshal_ctx *ctx, struct lib9p_m
|| marshal_4(ctx, &val->flags)
|| marshal_4(ctx, &val->mode)
|| marshal_nuid(ctx, &val->gid)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(14, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 14; false; })
;
}
@@ -3443,8 +3592,8 @@ LM_FLATTEN static bool marshal_Tsymlink(struct _marshal_ctx *ctx, struct lib9p_m
|| marshal_s(ctx, &val->name)
|| marshal_s(ctx, &val->symtgt)
|| marshal_nuid(ctx, &val->gid)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(16, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 16; false; })
;
}
@@ -3461,8 +3610,8 @@ LM_FLATTEN static bool marshal_Tmknod(struct _marshal_ctx *ctx, struct lib9p_msg
|| marshal_4(ctx, &val->major)
|| marshal_4(ctx, &val->minor)
|| marshal_nuid(ctx, &val->gid)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(18, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 18; false; })
;
}
@@ -3477,8 +3626,8 @@ LM_FLATTEN static bool marshal_Topen(struct _marshal_ctx *ctx, struct lib9p_msg_
|| marshal_tag(ctx, &val->tag)
|| marshal_fid(ctx, &val->fid)
|| marshal_o(ctx, &val->mode)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(112, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 112; false; })
;
}
@@ -3493,8 +3642,8 @@ LM_FLATTEN static bool marshal_Tcreate(struct _marshal_ctx *ctx, struct lib9p_ms
|| marshal_s(ctx, &val->name)
|| marshal_dm(ctx, &val->perm)
|| marshal_o(ctx, &val->mode)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(114, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 114; false; })
;
}
@@ -3509,8 +3658,8 @@ LM_FLATTEN static bool marshal_Tgetattr(struct _marshal_ctx *ctx, struct lib9p_m
|| marshal_tag(ctx, &val->tag)
|| marshal_fid(ctx, &val->fid)
|| marshal_getattr(ctx, &val->request_mask)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(24, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 24; false; })
;
}
@@ -3531,8 +3680,8 @@ LM_FLATTEN static bool marshal_Tsetattr(struct _marshal_ctx *ctx, struct lib9p_m
|| marshal_8(ctx, &val->atime_nsec)
|| marshal_8(ctx, &val->mtime_sec)
|| marshal_8(ctx, &val->mtime_nsec)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(26, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 26; false; })
;
}
@@ -3550,8 +3699,8 @@ LM_FLATTEN static bool marshal_Tlock(struct _marshal_ctx *ctx, struct lib9p_msg_
|| marshal_8(ctx, &val->length)
|| marshal_4(ctx, &val->proc_id)
|| marshal_s(ctx, &val->client_id)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(52, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 52; false; })
;
}
@@ -3563,12 +3712,46 @@ LM_FLATTEN static bool marshal_Rlock(struct _marshal_ctx *ctx, struct lib9p_msg_
|| ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
|| marshal_tag(ctx, &val->tag)
|| marshal_lock_status(ctx, &val->status)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(53, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 53; false; })
;
}
#endif /* CONFIG_9P_ENABLE_9P2000_L */
+#if CONFIG_9P_ENABLE_9P2000_e
+LM_FLATTEN static bool marshal_Rsread(struct _marshal_ctx *ctx, struct lib9p_msg_Rsread *val) {
+ uint32_t _size_offset;
+ uint32_t _typ_offset;
+ return false
+ || ({ _size_offset = ctx->net_offset; ({ ctx->net_offset += 4; false; }); })
+ || ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
+ || marshal_tag(ctx, &val->tag)
+ || marshal_d_e(ctx, &val->data)
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 153; false; })
+ ;
+}
+
+LM_FLATTEN static bool marshal_Tswrite(struct _marshal_ctx *ctx, struct lib9p_msg_Tswrite *val) {
+ uint32_t _size_offset;
+ uint32_t _typ_offset;
+ return false
+ || ({ _size_offset = ctx->net_offset; ({ ctx->net_offset += 4; false; }); })
+ || ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
+ || marshal_tag(ctx, &val->tag)
+ || marshal_4(ctx, &val->fid)
+ || marshal_2(ctx, &val->nwname)
+ || ({ bool err = false;
+ for (typeof(val->nwname) i = 0; i < val->nwname && !err; i++)
+ err = marshal_s(ctx, &val->wname[i]);
+ err; })
+ || marshal_d_e(ctx, &val->data)
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 154; false; })
+ ;
+}
+
+#endif /* CONFIG_9P_ENABLE_9P2000_e */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_ALWAYS_INLINE static bool marshal_stat(struct _marshal_ctx *ctx, struct lib9p_stat *val) {
uint32_t _stat_size_offset;
@@ -3592,7 +3775,7 @@ LM_ALWAYS_INLINE static bool marshal_stat(struct _marshal_ctx *ctx, struct lib9p
|| ( is_ver(ctx, 9P2000_u) && marshal_nuid(ctx, &val->file_owner_n_gid) )
|| ( is_ver(ctx, 9P2000_u) && marshal_nuid(ctx, &val->file_last_modified_n_uid) )
#endif /* CONFIG_9P_ENABLE_9P2000_u */
- || ({ encode_u16le(ctx->net_offset - _kern_type_offset, &ctx->net_bytes[_stat_size_offset]); false; })
+ || ({ uint16le_encode(&ctx->net_bytes[_stat_size_offset], ctx->net_offset - _kern_type_offset); false; })
;
}
@@ -3606,8 +3789,8 @@ LM_FLATTEN static bool marshal_Rauth(struct _marshal_ctx *ctx, struct lib9p_msg_
|| ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
|| marshal_tag(ctx, &val->tag)
|| marshal_qid(ctx, &val->aqid)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(103, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 103; false; })
;
}
@@ -3619,8 +3802,8 @@ LM_FLATTEN static bool marshal_Rattach(struct _marshal_ctx *ctx, struct lib9p_ms
|| ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
|| marshal_tag(ctx, &val->tag)
|| marshal_qid(ctx, &val->qid)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(105, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 105; false; })
;
}
@@ -3636,8 +3819,8 @@ LM_FLATTEN static bool marshal_Rwalk(struct _marshal_ctx *ctx, struct lib9p_msg_
for (typeof(val->nwqid) i = 0; i < val->nwqid && !err; i++)
err = marshal_qid(ctx, &val->wqid[i]);
err; })
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(111, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 111; false; })
;
}
@@ -3652,8 +3835,8 @@ LM_FLATTEN static bool marshal_Ropen(struct _marshal_ctx *ctx, struct lib9p_msg_
|| marshal_tag(ctx, &val->tag)
|| marshal_qid(ctx, &val->qid)
|| marshal_4(ctx, &val->iounit)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(113, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 113; false; })
;
}
@@ -3666,8 +3849,8 @@ LM_FLATTEN static bool marshal_Rcreate(struct _marshal_ctx *ctx, struct lib9p_ms
|| marshal_tag(ctx, &val->tag)
|| marshal_qid(ctx, &val->qid)
|| marshal_4(ctx, &val->iounit)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(115, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 115; false; })
;
}
@@ -3682,8 +3865,8 @@ LM_FLATTEN static bool marshal_Rlopen(struct _marshal_ctx *ctx, struct lib9p_msg
|| marshal_tag(ctx, &val->tag)
|| marshal_qid(ctx, &val->qid)
|| marshal_4(ctx, &val->iounit)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(13, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 13; false; })
;
}
@@ -3696,8 +3879,8 @@ LM_FLATTEN static bool marshal_Rlcreate(struct _marshal_ctx *ctx, struct lib9p_m
|| marshal_tag(ctx, &val->tag)
|| marshal_qid(ctx, &val->qid)
|| marshal_4(ctx, &val->iounit)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(15, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 15; false; })
;
}
@@ -3709,8 +3892,8 @@ LM_FLATTEN static bool marshal_Rsymlink(struct _marshal_ctx *ctx, struct lib9p_m
|| ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
|| marshal_tag(ctx, &val->tag)
|| marshal_qid(ctx, &val->qid)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(17, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 17; false; })
;
}
@@ -3722,8 +3905,8 @@ LM_FLATTEN static bool marshal_Rmknod(struct _marshal_ctx *ctx, struct lib9p_msg
|| ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
|| marshal_tag(ctx, &val->tag)
|| marshal_qid(ctx, &val->qid)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(19, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 19; false; })
;
}
@@ -3754,8 +3937,8 @@ LM_FLATTEN static bool marshal_Rgetattr(struct _marshal_ctx *ctx, struct lib9p_m
|| marshal_8(ctx, &val->btime_nsec)
|| marshal_8(ctx, &val->gen)
|| marshal_8(ctx, &val->data_version)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(25, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 25; false; })
;
}
@@ -3767,8 +3950,8 @@ LM_FLATTEN static bool marshal_Tmkdir(struct _marshal_ctx *ctx, struct lib9p_msg
|| ({ _typ_offset = ctx->net_offset; ({ ctx->net_offset += 1; false; }); })
|| marshal_tag(ctx, &val->tag)
|| marshal_qid(ctx, &val->qid)
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(73, &ctx->net_bytes[_typ_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 73; false; })
;
}
@@ -3785,9 +3968,9 @@ LM_FLATTEN static bool marshal_Rstat(struct _marshal_ctx *ctx, struct lib9p_msg_
|| marshal_tag(ctx, &val->tag)
|| ({ _nstat_offset = ctx->net_offset; ({ ctx->net_offset += 2; false; }); })
|| ({ _stat_offset = ctx->net_offset; marshal_stat(ctx, &val->stat); })
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(125, &ctx->net_bytes[_typ_offset]); false; })
- || ({ encode_u16le(ctx->net_offset - _stat_offset, &ctx->net_bytes[_nstat_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 125; false; })
+ || ({ uint16le_encode(&ctx->net_bytes[_nstat_offset], ctx->net_offset - _stat_offset); false; })
;
}
@@ -3803,15 +3986,15 @@ LM_FLATTEN static bool marshal_Twstat(struct _marshal_ctx *ctx, struct lib9p_msg
|| marshal_fid(ctx, &val->fid)
|| ({ _nstat_offset = ctx->net_offset; ({ ctx->net_offset += 2; false; }); })
|| ({ _stat_offset = ctx->net_offset; marshal_stat(ctx, &val->stat); })
- || ({ encode_u32le(ctx->net_offset - _size_offset, &ctx->net_bytes[_size_offset]); false; })
- || ({ encode_u8le(126, &ctx->net_bytes[_typ_offset]); false; })
- || ({ encode_u16le(ctx->net_offset - _stat_offset, &ctx->net_bytes[_nstat_offset]); false; })
+ || ({ uint32le_encode(&ctx->net_bytes[_size_offset], ctx->net_offset - _size_offset); false; })
+ || ({ ctx->net_bytes[_typ_offset] = 126; false; })
+ || ({ uint16le_encode(&ctx->net_bytes[_nstat_offset], ctx->net_offset - _stat_offset); false; })
;
}
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
-/* tables / exports ***********************************************************/
-#define _MSG_NAME(typ) [LIB9P_TYP_##typ] = #typ
+/* function tables ************************************************************/
+
#define _MSG_RECV(typ) [LIB9P_TYP_##typ/2] = { \
.basesize = sizeof(struct lib9p_msg_##typ), \
.validate = validate_##typ, \
@@ -3821,172 +4004,6 @@ LM_FLATTEN static bool marshal_Twstat(struct _marshal_ctx *ctx, struct lib9p_msg
.marshal = (_marshal_fn_t)marshal_##typ, \
}
-const char * _lib9p_table_msg_name[LIB9P_VER_NUM][0x100] = {
- [LIB9P_VER_unknown] = {
- _MSG_NAME(Tversion),
- _MSG_NAME(Rversion),
- _MSG_NAME(Rerror),
- },
-#if CONFIG_9P_ENABLE_9P2000
- [LIB9P_VER_9P2000] = {
- _MSG_NAME(Tversion),
- _MSG_NAME(Rversion),
- _MSG_NAME(Tauth),
- _MSG_NAME(Rauth),
- _MSG_NAME(Tattach),
- _MSG_NAME(Rattach),
- _MSG_NAME(Rerror),
- _MSG_NAME(Tflush),
- _MSG_NAME(Rflush),
- _MSG_NAME(Twalk),
- _MSG_NAME(Rwalk),
- _MSG_NAME(Topen),
- _MSG_NAME(Ropen),
- _MSG_NAME(Tcreate),
- _MSG_NAME(Rcreate),
- _MSG_NAME(Tread),
- _MSG_NAME(Rread),
- _MSG_NAME(Twrite),
- _MSG_NAME(Rwrite),
- _MSG_NAME(Tclunk),
- _MSG_NAME(Rclunk),
- _MSG_NAME(Tremove),
- _MSG_NAME(Rremove),
- _MSG_NAME(Tstat),
- _MSG_NAME(Rstat),
- _MSG_NAME(Twstat),
- _MSG_NAME(Rwstat),
- },
-#endif /* CONFIG_9P_ENABLE_9P2000 */
-#if CONFIG_9P_ENABLE_9P2000_L
- [LIB9P_VER_9P2000_L] = {
- _MSG_NAME(Rlerror),
- _MSG_NAME(Tstatfs),
- _MSG_NAME(Rstatfs),
- _MSG_NAME(Tlopen),
- _MSG_NAME(Rlopen),
- _MSG_NAME(Tlcreate),
- _MSG_NAME(Rlcreate),
- _MSG_NAME(Tsymlink),
- _MSG_NAME(Rsymlink),
- _MSG_NAME(Tmknod),
- _MSG_NAME(Rmknod),
- _MSG_NAME(Trename),
- _MSG_NAME(Rrename),
- _MSG_NAME(Treadlink),
- _MSG_NAME(Rreadlink),
- _MSG_NAME(Tgetattr),
- _MSG_NAME(Rgetattr),
- _MSG_NAME(Tsetattr),
- _MSG_NAME(Rsetattr),
- _MSG_NAME(Txattrwalk),
- _MSG_NAME(Rxattrwalk),
- _MSG_NAME(Txattrcreate),
- _MSG_NAME(Rxattrcreate),
- _MSG_NAME(Treaddir),
- _MSG_NAME(Rreaddir),
- _MSG_NAME(Tfsync),
- _MSG_NAME(Rfsync),
- _MSG_NAME(Tlock),
- _MSG_NAME(Rlock),
- _MSG_NAME(Tgetlock),
- _MSG_NAME(Rgetlock),
- _MSG_NAME(Tlink),
- _MSG_NAME(Rlink),
- _MSG_NAME(Tmkdir),
- _MSG_NAME(Trenameat),
- _MSG_NAME(Rrenameat),
- _MSG_NAME(Tunlinkat),
- _MSG_NAME(Runlinkat),
- _MSG_NAME(Tversion),
- _MSG_NAME(Rversion),
- _MSG_NAME(Tauth),
- _MSG_NAME(Rauth),
- _MSG_NAME(Tattach),
- _MSG_NAME(Rattach),
- _MSG_NAME(Tflush),
- _MSG_NAME(Rflush),
- _MSG_NAME(Twalk),
- _MSG_NAME(Rwalk),
- _MSG_NAME(Tread),
- _MSG_NAME(Rread),
- _MSG_NAME(Twrite),
- _MSG_NAME(Rwrite),
- _MSG_NAME(Tclunk),
- _MSG_NAME(Tremove),
- _MSG_NAME(Rremove),
- },
-#endif /* CONFIG_9P_ENABLE_9P2000_L */
-#if CONFIG_9P_ENABLE_9P2000_e
- [LIB9P_VER_9P2000_e] = {
- _MSG_NAME(Tversion),
- _MSG_NAME(Rversion),
- _MSG_NAME(Tauth),
- _MSG_NAME(Rauth),
- _MSG_NAME(Tattach),
- _MSG_NAME(Rattach),
- _MSG_NAME(Rerror),
- _MSG_NAME(Tflush),
- _MSG_NAME(Rflush),
- _MSG_NAME(Twalk),
- _MSG_NAME(Rwalk),
- _MSG_NAME(Topen),
- _MSG_NAME(Ropen),
- _MSG_NAME(Tcreate),
- _MSG_NAME(Rcreate),
- _MSG_NAME(Tread),
- _MSG_NAME(Rread),
- _MSG_NAME(Twrite),
- _MSG_NAME(Rwrite),
- _MSG_NAME(Tclunk),
- _MSG_NAME(Rclunk),
- _MSG_NAME(Tremove),
- _MSG_NAME(Rremove),
- _MSG_NAME(Tstat),
- _MSG_NAME(Rstat),
- _MSG_NAME(Twstat),
- _MSG_NAME(Rwstat),
- _MSG_NAME(Tsession),
- _MSG_NAME(Rsession),
- _MSG_NAME(Tsread),
- _MSG_NAME(Rsread),
- _MSG_NAME(Tswrite),
- _MSG_NAME(Rswrite),
- },
-#endif /* CONFIG_9P_ENABLE_9P2000_e */
-#if CONFIG_9P_ENABLE_9P2000_u
- [LIB9P_VER_9P2000_u] = {
- _MSG_NAME(Tversion),
- _MSG_NAME(Rversion),
- _MSG_NAME(Tauth),
- _MSG_NAME(Rauth),
- _MSG_NAME(Tattach),
- _MSG_NAME(Rattach),
- _MSG_NAME(Rerror),
- _MSG_NAME(Tflush),
- _MSG_NAME(Rflush),
- _MSG_NAME(Twalk),
- _MSG_NAME(Rwalk),
- _MSG_NAME(Topen),
- _MSG_NAME(Ropen),
- _MSG_NAME(Tcreate),
- _MSG_NAME(Rcreate),
- _MSG_NAME(Tread),
- _MSG_NAME(Rread),
- _MSG_NAME(Twrite),
- _MSG_NAME(Rwrite),
- _MSG_NAME(Tclunk),
- _MSG_NAME(Rclunk),
- _MSG_NAME(Tremove),
- _MSG_NAME(Rremove),
- _MSG_NAME(Tstat),
- _MSG_NAME(Rstat),
- _MSG_NAME(Twstat),
- _MSG_NAME(Rwstat),
- },
-#endif /* CONFIG_9P_ENABLE_9P2000_u */
-};
-
const struct _lib9p_recv_tentry _lib9p_table_Tmsg_recv[LIB9P_VER_NUM][0x80] = {
[LIB9P_VER_unknown] = {
_MSG_RECV(Tversion),
diff --git a/lib9p/idl.gen b/lib9p/idl.gen
index 47ca49a..7c79a28 100755
--- a/lib9p/idl.gen
+++ b/lib9p/idl.gen
@@ -23,6 +23,9 @@ import idl
idprefix = "lib9p_"
+u32max = (1 << 32) - 1
+u64max = (1 << 64) - 1
+
def tab_ljust(s: str, width: int) -> str:
cur = len(s.expandtabs(tabsize=8))
@@ -67,9 +70,11 @@ def c_ver_cond(versions: set[str]) -> str:
return "( " + (" || ".join(c_ver_cond({v}) for v in sorted(versions))) + " )"
-def c_typename(typ: idl.Type) -> str:
+def c_typename(typ: idl.Type, parent: idl.Type | None = None) -> str:
match typ:
case idl.Primitive():
+ if typ.value == 1 and parent and parent.name in ["d", "s"]: # SPECIAL
+ return "[[gnu::nonstring]] char"
return f"uint{typ.value*8}_t"
case idl.Number():
return f"{idprefix}{typ.name}_t"
@@ -88,17 +93,17 @@ def c_expr(expr: idl.Expr) -> str:
for tok in expr.tokens:
match tok:
case idl.ExprOp():
- ret += [tok.op]
+ ret.append(tok.op)
case idl.ExprLit():
- ret += [str(tok.val)]
+ ret.append(str(tok.val))
case idl.ExprSym(name="end"):
- ret += ["ctx->net_offset"]
+ ret.append("ctx->net_offset")
case idl.ExprSym(name="s32_max"):
- ret += ["INT32_MAX"]
+ ret.append("INT32_MAX")
case idl.ExprSym(name="s64_max"):
- ret += ["INT64_MAX"]
+ ret.append("INT64_MAX")
case idl.ExprSym():
- ret += [f"_{tok.name[1:]}_offset"]
+ ret.append(f"_{tok.name[1:]}_offset")
return " ".join(ret)
@@ -109,7 +114,7 @@ def ifdef_push(n: int, _newval: str) -> str:
# Grow the stack as needed
global _ifdef_stack
while len(_ifdef_stack) < n:
- _ifdef_stack += [None]
+ _ifdef_stack.append(None)
# Set some variables
parentval: str | None = None
@@ -204,8 +209,6 @@ enum {idprefix}version {{
ret += ifdef_pop(0)
ret += f"\t{c_ver_enum('NUM')},\n"
ret += "};\n"
- ret += "\n"
- ret += f"const char *{idprefix}version_str(enum {idprefix}version);\n"
ret += """
/* enum msg_type **************************************************************/
@@ -222,9 +225,43 @@ enum {idprefix}version {{
ret += """
/* payload types **************************************************************/
"""
+
+ def per_version_comment(
+ typ: idl.Type, fn: typing.Callable[[idl.Type, str], str]
+ ) -> str:
+ lines: dict[str, str] = {}
+ for version in sorted(typ.in_versions):
+ lines[version] = fn(typ, version)
+ if len(set(lines.values())) == 1:
+ for _, line in lines.items():
+ return f"/* {line} */\n"
+ assert False
+ else:
+ ret = ""
+ v_width = max(len(c_ver_enum(v)) for v in typ.in_versions)
+ for version, line in lines.items():
+ ret += f"/* {c_ver_enum(version).ljust(v_width)}: {line} */\n"
+ return ret
+
for typ in topo_sorted(typs):
ret += "\n"
ret += ifdef_push(1, c_ver_ifdef(typ.in_versions))
+
+ def sum_size(typ: idl.Type, version: str) -> str:
+ min_size = typ.min_size(version)
+ max_size = typ.max_size(version)
+ assert min_size <= max_size and max_size < u64max
+ ret = ""
+ if min_size == max_size:
+ ret += f"size = {min_size:,}"
+ else:
+ ret += f"min_size = {min_size:,} ; max_size = {max_size:,}"
+ if max_size > u32max:
+ ret += " (warning: >UINT32_MAX)"
+ return ret
+
+ ret += per_version_comment(typ, sum_size)
+
match typ:
case idl.Number():
ret += f"typedef {c_typename(typ.prim)} {c_typename(typ)};\n"
@@ -281,16 +318,13 @@ enum {idprefix}version {{
continue
ret += "\n"
- typewidth = max(len(c_typename(m.typ)) for m in typ.members)
+ typewidth = max(len(c_typename(m.typ, typ)) for m in typ.members)
for member in typ.members:
if member.val:
continue
ret += ifdef_push(2, c_ver_ifdef(member.in_versions))
- c_type = c_typename(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"
+ ret += f"\t{c_typename(member.typ, typ).ljust(typewidth)} {'*' if member.cnt else ' '}{member.name};\n"
ret += ifdef_pop(1)
ret += "};\n"
ret += ifdef_pop(0)
@@ -330,6 +364,38 @@ def gen_c(versions: set[str], typs: list[idl.Type]) -> str:
def unused(arg: str) -> str:
return f"LM_UNUSED({arg})"
+ for v in sorted(versions):
+ ret += f"#if CONFIG_9P_ENABLE_{v.replace('.', '_')}\n"
+ ret += f"\t#define _is_ver_{v.replace('.', '_')}(v) (v == {c_ver_enum(v)})\n"
+ ret += "#else\n"
+ ret += f"\t#define _is_ver_{v.replace('.', '_')}(v) false\n"
+ ret += "#endif\n"
+ id2typ: dict[int, idl.Message] = {}
+ for msg in [msg for msg in typs if isinstance(msg, idl.Message)]:
+ id2typ[msg.msgid] = msg
+
+ def msg_table(grp: str, meth: str, tentry: str, rng: tuple[int, int, int]) -> str:
+ ret = f"const {tentry} _{idprefix}table_{grp}_{meth}[{c_ver_enum('NUM')}][{hex(len(range(*rng)))}] = {{\n"
+ for ver in ["unknown", *sorted(versions)]:
+ if ver != "unknown":
+ ret += ifdef_push(1, c_ver_ifdef({ver}))
+ ret += f"\t[{c_ver_enum(ver)}] = {{\n"
+ for n in range(*rng):
+ xmsg: idl.Message | None = id2typ.get(n, None)
+ if xmsg:
+ if ver == "unknown": # SPECIAL
+ if xmsg.name not in ["Tversion", "Rversion", "Rerror"]:
+ xmsg = None
+ else:
+ if ver not in xmsg.in_versions:
+ xmsg = None
+ if xmsg:
+ ret += f"\t\t_MSG_{meth.upper()}({xmsg.name}),\n"
+ ret += "\t},\n"
+ ret += ifdef_pop(0)
+ ret += "};\n"
+ return ret
+
ret += "\n"
ret += "/**\n"
ret += f" * is_ver(ctx, ver) is essentially `(ctx->ctx->version == {idprefix.upper()}VER_##ver)`,\n"
@@ -338,18 +404,12 @@ def gen_c(versions: set[str], typs: list[idl.Type]) -> str:
ret += " * several version checks together.\n"
ret += " */\n"
ret += "#define is_ver(ctx, ver) _is_ver_##ver(ctx->ctx->version)\n"
- for v in sorted(versions):
- ret += f"#if CONFIG_9P_ENABLE_{v.replace('.', '_')}\n"
- ret += f"\t#define _is_ver_{v.replace('.', '_')}(v) (v == {c_ver_enum(v)})\n"
- ret += "#else\n"
- ret += f"\t#define _is_ver_{v.replace('.', '_')}(v) false\n"
- ret += "#endif\n"
# strings ##################################################################
ret += f"""
/* strings ********************************************************************/
-static const char *version_strs[{c_ver_enum('NUM')}] = {{
+const char *_lib9p_table_ver_name[{c_ver_enum('NUM')}] = {{
"""
for ver in ["unknown", *sorted(versions)]:
if ver in versions:
@@ -357,15 +417,10 @@ static const char *version_strs[{c_ver_enum('NUM')}] = {{
ret += f'\t[{c_ver_enum(ver)}] = "{ver}",\n'
ret += ifdef_pop(0)
ret += "};\n"
- ret += f"""
-const char *{idprefix}version_str(enum {idprefix}version ver) {{
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wtype-limits"
- assert(0 <= ver && ver < {c_ver_enum('NUM')});
-#pragma GCC diagnostic pop
- return version_strs[ver];
-}}
-"""
+
+ ret += "\n"
+ ret += f"#define _MSG_NAME(typ) [{idprefix.upper()}TYP_##typ] = #typ\n"
+ ret += msg_table("msg", "name", "char *", (0, 0x100, 1))
# bitmasks #################################################################
ret += f"""
@@ -443,7 +498,7 @@ LM_ALWAYS_INLINE static bool _validate_list(struct _validate_ctx *ctx,
ret += "\tuint32_t base_offset = ctx->net_offset;\n"
ret += "\tif (validate_4(ctx))\n"
ret += "\t\treturn true;\n"
- ret += "\tuint32_t len = decode_u32le(&ctx->net_bytes[base_offset]);\n"
+ ret += "\tuint32_t len = uint32le_decode(&ctx->net_bytes[base_offset]);\n"
ret += "\treturn _validate_size_net(ctx, len) || _validate_size_host(ctx, len);\n"
ret += "}\n"
continue
@@ -453,8 +508,8 @@ LM_ALWAYS_INLINE static bool _validate_list(struct _validate_ctx *ctx,
ret += "\tuint32_t base_offset = ctx->net_offset;\n"
ret += "\tif (validate_2(ctx))\n"
ret += "\t\treturn true;\n"
- ret += "\tuint16_t len = decode_u16le(&ctx->net_bytes[base_offset]);\n"
- ret += "\tif (_validate_size_net(ctx, len) || _validate_size_host(ctx, ((size_t)len)+1))\n"
+ ret += "\tuint16_t len = uint16le_decode(&ctx->net_bytes[base_offset]);\n"
+ ret += "\tif (_validate_size_net(ctx, len) || _validate_size_host(ctx, ((size_t)len)))\n"
ret += "\t\treturn true;\n"
ret += "\tif (!is_valid_utf8_without_nul(&ctx->net_bytes[base_offset+2], len))\n"
ret += '\t\treturn lib9p_error(ctx->ctx, LINUX_EBADMSG, "message contains invalid UTF-8");\n'
@@ -471,7 +526,10 @@ LM_ALWAYS_INLINE static bool _validate_list(struct _validate_ctx *ctx,
ret += (
f"\t{c_typename(typ)} mask = {typ.name}_masks[ctx->ctx->version];\n"
)
- ret += f"\t{c_typename(typ)} val = decode_u{typ.static_size*8}le(&ctx->net_bytes[ctx->net_offset-{typ.static_size}]);\n"
+ if typ.static_size == 1:
+ ret += f"\t{c_typename(typ)} val = ctx->net_bytes[ctx->net_offset-1];\n"
+ else:
+ ret += f"\t{c_typename(typ)} val = uint{typ.static_size*8}le_decode(&ctx->net_bytes[ctx->net_offset-{typ.static_size}]);\n"
ret += f"\tif (val & ~mask)\n"
ret += f'\t\treturn lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "unknown bits in {typ.name} bitfield: %#0{typ.static_size}"PRIx{typ.static_size*8}, val & ~mask);\n'
ret += "\treturn false;\n"
@@ -507,7 +565,10 @@ LM_ALWAYS_INLINE static bool _validate_list(struct _validate_ctx *ctx,
ret += "( " + c_ver_cond(member.in_versions) + " && "
if member.cnt is not None:
assert prev_size
- ret += f"_validate_list(ctx, decode_u{prev_size*8}le(&ctx->net_bytes[ctx->net_offset-{prev_size}]), validate_{member.typ.name}, sizeof({c_typename(member.typ)}))"
+ if prev_size == 1:
+ ret += f"_validate_list(ctx, ctx->net_bytes[ctx->net_offset-1], validate_{member.typ.name}, sizeof({c_typename(member.typ)}))"
+ else:
+ ret += f"_validate_list(ctx, uint{prev_size*8}le_decode(&ctx->net_bytes[ctx->net_offset-{prev_size}]), validate_{member.typ.name}, sizeof({c_typename(member.typ)}))"
else:
if member.max or member.val:
ret += "("
@@ -517,10 +578,12 @@ LM_ALWAYS_INLINE static bool _validate_list(struct _validate_ctx *ctx,
if member.name in mark_offset:
ret += "; })"
if member.max or member.val:
- bytes = member.static_size
- assert bytes
- bits = bytes * 8
- ret += f" || ({{ {member.name} = decode_u{bits}le(&ctx->net_bytes[ctx->net_offset-{bytes}]); false; }}))"
+ nbytes = member.static_size
+ assert nbytes
+ if nbytes == 1:
+ ret += f" || ({{ {member.name} = ctx->net_bytes[ctx->net_offset-1]; false; }}))"
+ else:
+ ret += f" || ({{ {member.name} = uint{nbytes*8}le_decode(&ctx->net_bytes[ctx->net_offset-{nbytes}]); false; }}))"
if member.in_versions != typ.in_versions:
ret += " )"
ret += "\n"
@@ -551,22 +614,22 @@ LM_ALWAYS_INLINE static bool _validate_list(struct _validate_ctx *ctx,
/* unmarshal_* ****************************************************************/
LM_ALWAYS_INLINE static void unmarshal_1(struct _unmarshal_ctx *ctx, uint8_t *out) {
-\t*out = decode_u8le(&ctx->net_bytes[ctx->net_offset]);
+\t*out = ctx->net_bytes[ctx->net_offset];
\tctx->net_offset += 1;
}
LM_ALWAYS_INLINE static void unmarshal_2(struct _unmarshal_ctx *ctx, uint16_t *out) {
-\t*out = decode_u16le(&ctx->net_bytes[ctx->net_offset]);
+\t*out = uint16le_decode(&ctx->net_bytes[ctx->net_offset]);
\tctx->net_offset += 2;
}
LM_ALWAYS_INLINE static void unmarshal_4(struct _unmarshal_ctx *ctx, uint32_t *out) {
-\t*out = decode_u32le(&ctx->net_bytes[ctx->net_offset]);
+\t*out = uint32le_decode(&ctx->net_bytes[ctx->net_offset]);
\tctx->net_offset += 4;
}
LM_ALWAYS_INLINE static void unmarshal_8(struct _unmarshal_ctx *ctx, uint64_t *out) {
-\t*out = decode_u64le(&ctx->net_bytes[ctx->net_offset]);
+\t*out = uint64le_decode(&ctx->net_bytes[ctx->net_offset]);
\tctx->net_offset += 8;
}
"""
@@ -600,9 +663,10 @@ LM_ALWAYS_INLINE static void unmarshal_8(struct _unmarshal_ctx *ctx, uint64_t *o
ret += "{\n"
ret += prefix
ret += f"out->{member.name} = ctx->extra;\n"
- ret += f"{prefix}ctx->extra += sizeof(out->{member.name}[0]) * out->{member.cnt};\n"
- ret += f"{prefix}for (typeof(out->{member.cnt}) i = 0; i < out->{member.cnt}; i++)\n"
+ ret += f"{prefix}ctx->extra += sizeof(out->{member.name}[0]) * out->{member.cnt.name};\n"
+ ret += f"{prefix}for (typeof(out->{member.cnt.name}) i = 0; i < out->{member.cnt.name}; i++)\n"
if typ.name in ["d", "s"]: # SPECIAL
+ # Special-case is that we cast from `char` to `uint8_t`.
ret += f"{prefix}\tunmarshal_{member.typ.name}(ctx, (uint8_t *)&out->{member.name}[i]);\n"
else:
ret += f"{prefix}\tunmarshal_{member.typ.name}(ctx, &out->{member.name}[i]);\n"
@@ -612,9 +676,6 @@ LM_ALWAYS_INLINE static void unmarshal_8(struct _unmarshal_ctx *ctx, uint64_t *o
ret += (
f"unmarshal_{member.typ.name}(ctx, &out->{member.name});\n"
)
- if typ.name == "s": # SPECIAL
- ret += "\tctx->extra++;\n"
- ret += "\tout->utf8[out->len] = '\\0';\n"
ret += ifdef_pop(1)
ret += "}\n"
ret += ifdef_pop(0)
@@ -642,7 +703,7 @@ LM_ALWAYS_INLINE static bool marshal_1(struct _marshal_ctx *ctx, uint8_t *val) {
LM_ALWAYS_INLINE static bool marshal_2(struct _marshal_ctx *ctx, uint16_t *val) {
\tif (ctx->net_offset + 2 > ctx->ctx->max_msg_size)
\t\treturn _marshal_too_large(ctx);
-\tencode_u16le(*val, &ctx->net_bytes[ctx->net_offset]);
+\tuint16le_encode(&ctx->net_bytes[ctx->net_offset], *val);
\tctx->net_offset += 2;
\treturn false;
}
@@ -650,7 +711,7 @@ LM_ALWAYS_INLINE static bool marshal_2(struct _marshal_ctx *ctx, uint16_t *val)
LM_ALWAYS_INLINE static bool marshal_4(struct _marshal_ctx *ctx, uint32_t *val) {
\tif (ctx->net_offset + 4 > ctx->ctx->max_msg_size)
\t\treturn true;
-\tencode_u32le(*val, &ctx->net_bytes[ctx->net_offset]);
+\tuint32le_encode(&ctx->net_bytes[ctx->net_offset], *val);
\tctx->net_offset += 4;
\treturn false;
}
@@ -658,7 +719,7 @@ LM_ALWAYS_INLINE static bool marshal_4(struct _marshal_ctx *ctx, uint32_t *val)
LM_ALWAYS_INLINE static bool marshal_8(struct _marshal_ctx *ctx, uint64_t *val) {
\tif (ctx->net_offset + 8 > ctx->ctx->max_msg_size)
\t\treturn true;
-\tencode_u64le(*val, &ctx->net_bytes[ctx->net_offset]);
+\tuint64le_encode(&ctx->net_bytes[ctx->net_offset], *val);
\tctx->net_offset += 8;
\treturn false;
}
@@ -705,7 +766,7 @@ LM_ALWAYS_INLINE static bool marshal_8(struct _marshal_ctx *ctx, uint64_t *val)
ret += f"({{ _{member.name}_offset = ctx->net_offset; "
if member.cnt:
ret += "({ bool err = false;\n"
- ret += f"\t for (typeof(val->{member.cnt}) i = 0; i < val->{member.cnt} && !err; i++)\n"
+ ret += f"\t for (typeof(val->{member.cnt.name}) i = 0; i < val->{member.cnt.name} && !err; i++)\n"
ret += "\t \terr = "
if typ.name in ["d", "s"]: # SPECIAL
# Special-case is that we cast from `char` to `uint8_t`.
@@ -732,22 +793,21 @@ LM_ALWAYS_INLINE static bool marshal_8(struct _marshal_ctx *ctx, uint64_t *val)
if member.val:
assert member.static_size
ret += ifdef_push(2, c_ver_ifdef(member.in_versions))
- ret += f"\t || ({{ encode_u{member.static_size*8}le({c_expr(member.val)}, &ctx->net_bytes[_{member.name}_offset]); false; }})\n"
+ if member.static_size == 1:
+ ret += f"\t || ({{ ctx->net_bytes[_{member.name}_offset] = {c_expr(member.val)}; false; }})\n"
+ else:
+ ret += f"\t || ({{ uint{member.static_size*8}le_encode(&ctx->net_bytes[_{member.name}_offset], {c_expr(member.val)}); false; }})\n"
ret += ifdef_pop(1)
ret += "\t ;\n"
ret += "}\n"
ret += ifdef_pop(0)
- # tables / exports #########################################################
+ # function tables ##########################################################
ret += """
-/* tables / exports ***********************************************************/
-"""
- id2typ: dict[int, idl.Message] = {}
- for msg in [msg for msg in typs if isinstance(msg, idl.Message)]:
- id2typ[msg.msgid] = msg
+/* function tables ************************************************************/
- ret += f"#define _MSG_NAME(typ) [{idprefix.upper()}TYP_##typ] = #typ\n"
+"""
ret += c_macro(
f"#define _MSG_RECV(typ) [{idprefix.upper()}TYP_##typ/2] = {{",
f"\t\t.basesize = sizeof(struct {idprefix}msg_##typ),",
@@ -760,35 +820,14 @@ LM_ALWAYS_INLINE static bool marshal_8(struct _marshal_ctx *ctx, uint64_t *val)
f"\t\t.marshal = (_marshal_fn_t)marshal_##typ,",
f"\t}}",
)
-
- tables = [
- ("msg", "name", "char *", (0, 0x100, 1)),
- ("Tmsg", "recv", f"struct _{idprefix}recv_tentry", (0, 0x100, 2)),
- ("Rmsg", "recv", f"struct _{idprefix}recv_tentry", (1, 0x100, 2)),
- ("Tmsg", "send", f"struct _{idprefix}send_tentry", (0, 0x100, 2)),
- ("Rmsg", "send", f"struct _{idprefix}send_tentry", (1, 0x100, 2)),
- ]
- for grp, meth, tentry, rng in tables:
- ret += "\n"
- ret += f"const {tentry} _{idprefix}table_{grp}_{meth}[{c_ver_enum('NUM')}][{hex(len(range(*rng)))}] = {{\n"
- for ver in ["unknown", *sorted(versions)]:
- if ver != "unknown":
- ret += ifdef_push(1, c_ver_ifdef({ver}))
- ret += f"\t[{c_ver_enum(ver)}] = {{\n"
- for n in range(*rng):
- xmsg: idl.Message | None = id2typ.get(n, None)
- if xmsg:
- if ver == "unknown": # SPECIAL
- if xmsg.name not in ["Tversion", "Rversion", "Rerror"]:
- xmsg = None
- else:
- if ver not in xmsg.in_versions:
- xmsg = None
- if xmsg:
- ret += f"\t\t_MSG_{meth.upper()}({xmsg.name}),\n"
- ret += "\t},\n"
- ret += ifdef_pop(0)
- ret += "};\n"
+ ret += "\n"
+ ret += msg_table("Tmsg", "recv", f"struct _{idprefix}recv_tentry", (0, 0x100, 2))
+ ret += "\n"
+ ret += msg_table("Rmsg", "recv", f"struct _{idprefix}recv_tentry", (1, 0x100, 2))
+ ret += "\n"
+ ret += msg_table("Tmsg", "send", f"struct _{idprefix}send_tentry", (0, 0x100, 2))
+ ret += "\n"
+ ret += msg_table("Rmsg", "send", f"struct _{idprefix}send_tentry", (1, 0x100, 2))
ret += f"""
LM_FLATTEN bool _{idprefix}stat_validate(struct _validate_ctx *ctx) {{
diff --git a/lib9p/idl/2012-9P2000.e.9p b/lib9p/idl/2012-9P2000.e.9p
index c113618..aba4e66 100644
--- a/lib9p/idl/2012-9P2000.e.9p
+++ b/lib9p/idl/2012-9P2000.e.9p
@@ -1,6 +1,6 @@
# lib9p/idl/2012-9P2000.e.9p - Definitions of 9P2000.e messages
#
-# Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com>
+# Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com>
# SPDX-License-Identifier: AGPL-3.0-or-later
# "9P2000.e" Erlang extension
@@ -10,9 +10,12 @@ version "9P2000.e"
from ./2002-9P2000.9p import *
+# like 9P2000 `d`, but without the s32_max limit
+struct d_e = "len[4] len*(dat[1])"
+
msg Tsession = "size[4,val=end-&size] typ[1,val=150] tag[tag] key[8]"
msg Rsession = "size[4,val=end-&size] typ[1,val=151] tag[tag]"
msg Tsread = "size[4,val=end-&size] typ[1,val=152] tag[tag] fid[4] nwname[2] nwname*(wname[s])"
-msg Rsread = "size[4,val=end-&size] typ[1,val=153] tag[tag] data[d]"
-msg Tswrite = "size[4,val=end-&size] typ[1,val=154] tag[tag] fid[4] nwname[2] nwname*(wname[s]) data[d]"
+msg Rsread = "size[4,val=end-&size] typ[1,val=153] tag[tag] data[d_e]"
+msg Tswrite = "size[4,val=end-&size] typ[1,val=154] tag[tag] fid[4] nwname[2] nwname*(wname[s]) data[d_e]"
msg Rswrite = "size[4,val=end-&size] typ[1,val=155] tag[tag] count[4]"
diff --git a/lib9p/idl/__init__.py b/lib9p/idl/__init__.py
index ab45ed0..8fd7e25 100644
--- a/lib9p/idl/__init__.py
+++ b/lib9p/idl/__init__.py
@@ -43,6 +43,12 @@ class Primitive(enum.Enum):
def static_size(self) -> int:
return self.value
+ def min_size(self, version: str) -> int:
+ return self.value
+
+ def max_size(self, version: str) -> int:
+ return self.value
+
class Number:
name: str
@@ -60,6 +66,12 @@ class Number:
def static_size(self) -> int:
return self.prim.static_size
+ def min_size(self, version: str) -> int:
+ return self.static_size
+
+ def max_size(self, version: str) -> int:
+ return self.static_size
+
class BitfieldVal:
name: str
@@ -88,6 +100,12 @@ class Bitfield:
def static_size(self) -> int:
return self.prim.static_size
+ def min_size(self, version: str) -> int:
+ return self.static_size
+
+ def max_size(self, version: str) -> int:
+ return self.static_size
+
def bit_is_valid(self, bit: str | int, ver: str | None = None) -> bool:
"""Return whether the given bit is valid in the given protocol
version.
@@ -137,7 +155,7 @@ class Expr:
class StructMember:
# from left-to-right when parsing
- cnt: str | None = None
+ cnt: "StructMember | None" = None
name: str
typ: "Type"
max: Expr
@@ -146,11 +164,58 @@ class StructMember:
in_versions: set[str]
@property
+ def min_cnt(self) -> int:
+ assert self.cnt
+ if not isinstance(self.cnt.typ, Primitive):
+ raise ValueError(
+ f"list count must be an integer type: {repr(self.cnt.name)}"
+ )
+ if self.cnt.val: # TODO: allow this?
+ raise ValueError(f"list count may not have ,val=: {repr(self.cnt.name)}")
+ return 0
+
+ @property
+ def max_cnt(self) -> int:
+ assert self.cnt
+ if not isinstance(self.cnt.typ, Primitive):
+ raise ValueError(
+ f"list count must be an integer type: {repr(self.cnt.name)}"
+ )
+ if self.cnt.val: # TODO: allow this?
+ raise ValueError(f"list count may not have ,val=: {repr(self.cnt.name)}")
+ if self.cnt.max:
+ # TODO: be more flexible?
+ if len(self.cnt.max.tokens) != 1:
+ raise ValueError(
+ f"list count ,max= may only have 1 token: {repr(self.cnt.name)}"
+ )
+ match tok := self.cnt.max.tokens[0]:
+ case ExprLit():
+ return tok.val
+ case ExprSym(name="s32_max"):
+ return (1 << 31) - 1
+ case ExprSym(name="s64_max"):
+ return (1 << 63) - 1
+ case _:
+ raise ValueError(
+ f'list count ,max= only allows literal, "s32_max", and "s64_max" tokens: {repr(self.cnt.name)}'
+ )
+ return (1 << (self.cnt.typ.value * 8)) - 1
+
+ @property
def static_size(self) -> int | None:
if self.cnt:
return None
return self.typ.static_size
+ def min_size(self, version: str) -> int:
+ cnt = self.min_cnt if self.cnt else 1
+ return cnt * self.typ.min_size(version)
+
+ def max_size(self, version: str) -> int:
+ cnt = self.max_cnt if self.cnt else 1
+ return cnt * self.typ.max_size(version)
+
class Struct:
name: str
@@ -165,12 +230,28 @@ class Struct:
def static_size(self) -> int | None:
size = 0
for member in self.members:
+ if member.in_versions < self.in_versions:
+ return None
msize = member.static_size
if msize is None:
return None
size += msize
return size
+ def min_size(self, version: str) -> int:
+ return sum(
+ member.min_size(version)
+ for member in self.members
+ if (version in member.in_versions)
+ )
+
+ def max_size(self, version: str) -> int:
+ return sum(
+ member.max_size(version)
+ for member in self.members
+ if (version in member.in_versions)
+ )
+
class Message(Struct):
@property
@@ -289,9 +370,9 @@ def parse_members(ver: str, env: dict[str, Type], struct: Struct, specs: str) ->
if cnt := m.group("cnt"):
if len(struct.members) == 0 or struct.members[-1].name != cnt:
raise ValueError(f"list count must be previous item: {repr(cnt)}")
- if not isinstance(struct.members[-1].typ, Primitive):
- raise ValueError(f"list count must be an integer type: {repr(cnt)}")
- member.cnt = cnt
+ cnt_mem = struct.members[-1]
+ member.cnt = cnt_mem
+ _ = member.max_cnt # force validation
if maxstr := m.group("max"):
if (not isinstance(member.typ, Primitive)) or member.cnt:
diff --git a/lib9p/include/lib9p/9p.generated.h b/lib9p/include/lib9p/9p.generated.h
index cf30e00..f41b3ca 100644
--- a/lib9p/include/lib9p/9p.generated.h
+++ b/lib9p/include/lib9p/9p.generated.h
@@ -45,8 +45,6 @@ enum lib9p_version {
LIB9P_VER_NUM,
};
-const char *lib9p_version_str(enum lib9p_version);
-
/* enum msg_type **************************************************************/
enum lib9p_msg_type { /* uint8_t */
@@ -146,28 +144,33 @@ enum lib9p_msg_type { /* uint8_t */
/* payload types **************************************************************/
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
+/* size = 2 */
typedef uint16_t lib9p_tag_t;
#define LIB9P_TAG_NOTAG ((lib9p_tag_t)UINT16_C(~0))
+/* size = 4 */
typedef uint32_t lib9p_fid_t;
#define LIB9P_FID_NOFID ((lib9p_fid_t)UINT32_C(~0))
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
+/* min_size = 4 ; max_size = 2,147,483,651 */
struct lib9p_d {
- uint32_t len;
- char *dat;
+ uint32_t len;
+ [[gnu::nonstring]] char *dat;
};
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
+/* min_size = 2 ; max_size = 65,537 */
struct lib9p_s {
- uint16_t len;
- char *utf8;
+ uint16_t len;
+ [[gnu::nonstring]] char *utf8;
};
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
+/* size = 4 */
typedef uint32_t lib9p_dm_t;
#define LIB9P_DM_DIR ((lib9p_dm_t)(1<<31))
@@ -211,6 +214,7 @@ typedef uint32_t lib9p_dm_t;
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
+/* size = 1 */
typedef uint8_t lib9p_qt_t;
#define LIB9P_QT_DIR ((lib9p_qt_t)(1<<7))
@@ -228,11 +232,13 @@ typedef uint8_t lib9p_qt_t;
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u
+/* size = 4 */
typedef uint32_t lib9p_nuid_t;
#define LIB9P_NUID_NONUID ((lib9p_nuid_t)UINT32_C(~0))
#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
+/* size = 1 */
typedef uint8_t lib9p_o_t;
/* unused ((lib9p_o_t)(1<<7)) */
@@ -253,6 +259,7 @@ typedef uint8_t lib9p_o_t;
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000_L
+/* size = 8 */
typedef uint64_t lib9p_getattr_t;
/* unused ((lib9p_getattr_t)(1<<63)) */
@@ -323,6 +330,7 @@ typedef uint64_t lib9p_getattr_t;
#define LIB9P_GETATTR_BASIC ((lib9p_getattr_t)(0x000007ff))
#define LIB9P_GETATTR_ALL ((lib9p_getattr_t)(0x00003fff))
+/* size = 4 */
typedef uint32_t lib9p_setattr_t;
/* unused ((lib9p_setattr_t)(1<<31)) */
@@ -359,11 +367,13 @@ typedef uint32_t lib9p_setattr_t;
#define LIB9P_SETATTR_MODE ((lib9p_setattr_t)(1<<0))
+/* size = 1 */
typedef uint8_t lib9p_lock_type_t;
#define LIB9P_LOCK_TYPE_RDLCK ((lib9p_lock_type_t)UINT8_C(0))
#define LIB9P_LOCK_TYPE_WRLCK ((lib9p_lock_type_t)UINT8_C(1))
#define LIB9P_LOCK_TYPE_UNLCK ((lib9p_lock_type_t)UINT8_C(2))
+/* size = 4 */
typedef uint32_t lib9p_lock_flags_t;
/* unused ((lib9p_lock_flags_t)(1<<31)) */
@@ -400,6 +410,7 @@ typedef uint32_t lib9p_lock_flags_t;
#define LIB9P_LOCK_FLAGS_BLOCK ((lib9p_lock_flags_t)(1<<0))
+/* size = 1 */
typedef uint8_t lib9p_lock_status_t;
#define LIB9P_LOCK_STATUS_SUCCESS ((lib9p_lock_status_t)UINT8_C(0))
#define LIB9P_LOCK_STATUS_BLOCKED ((lib9p_lock_status_t)UINT8_C(1))
@@ -407,16 +418,27 @@ typedef uint8_t lib9p_lock_status_t;
#define LIB9P_LOCK_STATUS_GRACE ((lib9p_lock_status_t)UINT8_C(3))
#endif /* CONFIG_9P_ENABLE_9P2000_L */
+#if CONFIG_9P_ENABLE_9P2000_e
+/* min_size = 4 ; max_size = 4,294,967,299 (warning: >UINT32_MAX) */
+struct lib9p_d_e {
+ uint32_t len;
+ uint8_t *dat;
+};
+
+#endif /* CONFIG_9P_ENABLE_9P2000_e */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
+/* size = 9 */
struct lib9p_msg_Tflush {
lib9p_tag_t tag;
uint16_t oldtag;
};
+/* size = 7 */
struct lib9p_msg_Rflush {
lib9p_tag_t tag;
};
+/* size = 11 */
struct lib9p_msg_Rwrite {
lib9p_tag_t tag;
uint32_t count;
@@ -424,29 +446,34 @@ struct lib9p_msg_Rwrite {
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
+/* size = 7 */
struct lib9p_msg_Rclunk {
lib9p_tag_t tag;
};
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
+/* size = 7 */
struct lib9p_msg_Rremove {
lib9p_tag_t tag;
};
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
+/* size = 7 */
struct lib9p_msg_Rwstat {
lib9p_tag_t tag;
};
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000_L
+/* size = 11 */
struct lib9p_msg_Rlerror {
lib9p_tag_t tag;
uint32_t ecode;
};
+/* size = 67 */
struct lib9p_msg_Rstatfs {
lib9p_tag_t tag;
uint32_t type;
@@ -460,56 +487,68 @@ struct lib9p_msg_Rstatfs {
uint32_t namelen;
};
+/* size = 7 */
struct lib9p_msg_Rrename {
lib9p_tag_t tag;
};
+/* size = 7 */
struct lib9p_msg_Rsetattr {
lib9p_tag_t tag;
};
+/* size = 15 */
struct lib9p_msg_Rxattrwalk {
lib9p_tag_t tag;
uint64_t attr_size;
};
+/* size = 7 */
struct lib9p_msg_Rxattrcreate {
lib9p_tag_t tag;
};
+/* min_size = 11 ; max_size = 4,294,967,306 (warning: >UINT32_MAX) */
struct lib9p_msg_Rreaddir {
lib9p_tag_t tag;
uint32_t count;
uint8_t *data;
};
+/* size = 7 */
struct lib9p_msg_Rfsync {
lib9p_tag_t tag;
};
+/* size = 7 */
struct lib9p_msg_Rlink {
lib9p_tag_t tag;
};
+/* size = 7 */
struct lib9p_msg_Rrenameat {
lib9p_tag_t tag;
};
+/* size = 7 */
struct lib9p_msg_Runlinkat {
lib9p_tag_t tag;
};
#endif /* CONFIG_9P_ENABLE_9P2000_L */
#if CONFIG_9P_ENABLE_9P2000_e
+/* size = 15 */
struct lib9p_msg_Tsession {
lib9p_tag_t tag;
uint64_t key;
};
+/* size = 7 */
struct lib9p_msg_Rsession {
lib9p_tag_t tag;
};
+/* size = 11 */
struct lib9p_msg_Rswrite {
lib9p_tag_t tag;
uint32_t count;
@@ -517,6 +556,7 @@ struct lib9p_msg_Rswrite {
#endif /* CONFIG_9P_ENABLE_9P2000_e */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
+/* size = 23 */
struct lib9p_msg_Tread {
lib9p_tag_t tag;
lib9p_fid_t fid;
@@ -524,11 +564,13 @@ struct lib9p_msg_Tread {
uint32_t count;
};
+/* size = 11 */
struct lib9p_msg_Tclunk {
lib9p_tag_t tag;
lib9p_fid_t fid;
};
+/* size = 11 */
struct lib9p_msg_Tremove {
lib9p_tag_t tag;
lib9p_fid_t fid;
@@ -536,6 +578,7 @@ struct lib9p_msg_Tremove {
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
+/* size = 11 */
struct lib9p_msg_Tstat {
lib9p_tag_t tag;
lib9p_fid_t fid;
@@ -543,22 +586,26 @@ struct lib9p_msg_Tstat {
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000_L
+/* size = 11 */
struct lib9p_msg_Tstatfs {
lib9p_tag_t tag;
lib9p_fid_t fid;
};
+/* size = 15 */
struct lib9p_msg_Tlopen {
lib9p_tag_t tag;
lib9p_fid_t fid;
uint32_t flags;
};
+/* size = 11 */
struct lib9p_msg_Treadlink {
lib9p_tag_t tag;
lib9p_fid_t fid;
};
+/* size = 23 */
struct lib9p_msg_Treaddir {
lib9p_tag_t tag;
lib9p_fid_t fid;
@@ -566,6 +613,7 @@ struct lib9p_msg_Treaddir {
uint32_t count;
};
+/* size = 15 */
struct lib9p_msg_Tfsync {
lib9p_tag_t tag;
lib9p_fid_t fid;
@@ -574,11 +622,19 @@ struct lib9p_msg_Tfsync {
#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_u
+/* LIB9P_VER_9P2000 : min_size = 11 ; max_size = 2,147,483,658 */
+/* LIB9P_VER_9P2000_L: size = 7 */
+/* LIB9P_VER_9P2000_e: min_size = 11 ; max_size = 2,147,483,658 */
+/* LIB9P_VER_9P2000_u: min_size = 11 ; max_size = 2,147,483,658 */
struct lib9p_msg_Rread {
lib9p_tag_t tag;
struct lib9p_d data;
};
+/* LIB9P_VER_9P2000 : min_size = 23 ; max_size = 2,147,483,670 */
+/* LIB9P_VER_9P2000_L: size = 19 */
+/* LIB9P_VER_9P2000_e: min_size = 23 ; max_size = 2,147,483,670 */
+/* LIB9P_VER_9P2000_u: min_size = 23 ; max_size = 2,147,483,670 */
struct lib9p_msg_Twrite {
lib9p_tag_t tag;
lib9p_fid_t fid;
@@ -586,21 +642,14 @@ struct lib9p_msg_Twrite {
struct lib9p_d data;
};
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000_e
-struct lib9p_msg_Rsread {
- lib9p_tag_t tag;
- struct lib9p_d data;
-};
-
-#endif /* CONFIG_9P_ENABLE_9P2000_e */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
+/* min_size = 13 ; max_size = 65,548 */
struct lib9p_msg_Tversion {
lib9p_tag_t tag;
uint32_t max_msg_size;
struct lib9p_s version;
};
+/* min_size = 13 ; max_size = 65,548 */
struct lib9p_msg_Rversion {
lib9p_tag_t tag;
uint32_t max_msg_size;
@@ -609,6 +658,9 @@ struct lib9p_msg_Rversion {
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
+/* LIB9P_VER_9P2000 : min_size = 9 ; max_size = 65,544 */
+/* LIB9P_VER_9P2000_e: min_size = 9 ; max_size = 65,544 */
+/* LIB9P_VER_9P2000_u: min_size = 13 ; max_size = 65,548 */
struct lib9p_msg_Rerror {
lib9p_tag_t tag;
struct lib9p_s ename;
@@ -619,6 +671,7 @@ struct lib9p_msg_Rerror {
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
+/* min_size = 17 ; max_size = 1,048,609 */
struct lib9p_msg_Twalk {
lib9p_tag_t tag;
lib9p_fid_t fid;
@@ -629,6 +682,7 @@ struct lib9p_msg_Twalk {
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000_L
+/* min_size = 17 ; max_size = 65,552 */
struct lib9p_msg_Trename {
lib9p_tag_t tag;
lib9p_fid_t fid;
@@ -636,11 +690,13 @@ struct lib9p_msg_Trename {
struct lib9p_s name;
};
+/* min_size = 9 ; max_size = 65,544 */
struct lib9p_msg_Rreadlink {
lib9p_tag_t tag;
struct lib9p_s target;
};
+/* min_size = 17 ; max_size = 65,552 */
struct lib9p_msg_Txattrwalk {
lib9p_tag_t tag;
lib9p_fid_t fid;
@@ -648,6 +704,7 @@ struct lib9p_msg_Txattrwalk {
struct lib9p_s name;
};
+/* min_size = 25 ; max_size = 65,560 */
struct lib9p_msg_Txattrcreate {
lib9p_tag_t tag;
lib9p_fid_t fid;
@@ -656,6 +713,7 @@ struct lib9p_msg_Txattrcreate {
uint32_t flags;
};
+/* min_size = 34 ; max_size = 65,569 */
struct lib9p_msg_Tgetlock {
lib9p_tag_t tag;
lib9p_fid_t fid;
@@ -666,6 +724,7 @@ struct lib9p_msg_Tgetlock {
struct lib9p_s client_id;
};
+/* min_size = 30 ; max_size = 65,565 */
struct lib9p_msg_Rgetlock {
lib9p_tag_t tag;
uint8_t type;
@@ -675,6 +734,7 @@ struct lib9p_msg_Rgetlock {
struct lib9p_s client_id;
};
+/* min_size = 17 ; max_size = 65,552 */
struct lib9p_msg_Tlink {
lib9p_tag_t tag;
lib9p_fid_t dfid;
@@ -682,6 +742,7 @@ struct lib9p_msg_Tlink {
struct lib9p_s name;
};
+/* min_size = 19 ; max_size = 131,089 */
struct lib9p_msg_Trenameat {
lib9p_tag_t tag;
lib9p_fid_t olddirfid;
@@ -690,6 +751,7 @@ struct lib9p_msg_Trenameat {
struct lib9p_s newname;
};
+/* min_size = 17 ; max_size = 65,552 */
struct lib9p_msg_Tunlinkat {
lib9p_tag_t tag;
lib9p_fid_t dirfd;
@@ -699,6 +761,7 @@ struct lib9p_msg_Tunlinkat {
#endif /* CONFIG_9P_ENABLE_9P2000_L */
#if CONFIG_9P_ENABLE_9P2000_e
+/* min_size = 13 ; max_size = 4,294,967,308 (warning: >UINT32_MAX) */
struct lib9p_msg_Tsread {
lib9p_tag_t tag;
uint32_t fid;
@@ -706,22 +769,19 @@ struct lib9p_msg_Tsread {
struct lib9p_s *wname;
};
-struct lib9p_msg_Tswrite {
- lib9p_tag_t tag;
- uint32_t fid;
- uint16_t nwname;
- struct lib9p_s *wname;
- struct lib9p_d data;
-};
-
#endif /* CONFIG_9P_ENABLE_9P2000_e */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
+/* size = 13 */
struct lib9p_qid {
lib9p_qt_t type;
uint32_t vers;
uint64_t path;
};
+/* LIB9P_VER_9P2000 : min_size = 15 ; max_size = 131,085 */
+/* LIB9P_VER_9P2000_L: min_size = 19 ; max_size = 131,089 */
+/* LIB9P_VER_9P2000_e: min_size = 15 ; max_size = 131,085 */
+/* LIB9P_VER_9P2000_u: min_size = 19 ; max_size = 131,089 */
struct lib9p_msg_Tauth {
lib9p_tag_t tag;
lib9p_fid_t afid;
@@ -732,6 +792,10 @@ struct lib9p_msg_Tauth {
#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */
};
+/* LIB9P_VER_9P2000 : min_size = 19 ; max_size = 131,089 */
+/* LIB9P_VER_9P2000_L: min_size = 23 ; max_size = 131,093 */
+/* LIB9P_VER_9P2000_e: min_size = 19 ; max_size = 131,089 */
+/* LIB9P_VER_9P2000_u: min_size = 23 ; max_size = 131,093 */
struct lib9p_msg_Tattach {
lib9p_tag_t tag;
lib9p_fid_t fid;
@@ -745,6 +809,7 @@ struct lib9p_msg_Tattach {
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000_L
+/* min_size = 25 ; max_size = 65,560 */
struct lib9p_msg_Tlcreate {
lib9p_tag_t tag;
lib9p_fid_t fid;
@@ -754,6 +819,7 @@ struct lib9p_msg_Tlcreate {
lib9p_nuid_t gid;
};
+/* min_size = 19 ; max_size = 131,089 */
struct lib9p_msg_Tsymlink {
lib9p_tag_t tag;
lib9p_fid_t fid;
@@ -762,6 +828,7 @@ struct lib9p_msg_Tsymlink {
lib9p_nuid_t gid;
};
+/* min_size = 29 ; max_size = 65,564 */
struct lib9p_msg_Tmknod {
lib9p_tag_t tag;
lib9p_fid_t dfid;
@@ -774,12 +841,14 @@ struct lib9p_msg_Tmknod {
#endif /* CONFIG_9P_ENABLE_9P2000_L */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
+/* size = 12 */
struct lib9p_msg_Topen {
lib9p_tag_t tag;
lib9p_fid_t fid;
lib9p_o_t mode;
};
+/* min_size = 18 ; max_size = 65,553 */
struct lib9p_msg_Tcreate {
lib9p_tag_t tag;
lib9p_fid_t fid;
@@ -790,12 +859,14 @@ struct lib9p_msg_Tcreate {
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000_L
+/* size = 19 */
struct lib9p_msg_Tgetattr {
lib9p_tag_t tag;
lib9p_fid_t fid;
lib9p_getattr_t request_mask;
};
+/* size = 67 */
struct lib9p_msg_Tsetattr {
lib9p_tag_t tag;
lib9p_fid_t fid;
@@ -810,6 +881,7 @@ struct lib9p_msg_Tsetattr {
uint64_t mtime_nsec;
};
+/* min_size = 38 ; max_size = 65,573 */
struct lib9p_msg_Tlock {
lib9p_tag_t tag;
lib9p_fid_t fid;
@@ -821,13 +893,34 @@ struct lib9p_msg_Tlock {
struct lib9p_s client_id;
};
+/* size = 8 */
struct lib9p_msg_Rlock {
lib9p_tag_t tag;
lib9p_lock_status_t status;
};
#endif /* CONFIG_9P_ENABLE_9P2000_L */
+#if CONFIG_9P_ENABLE_9P2000_e
+/* min_size = 11 ; max_size = 4,294,967,306 (warning: >UINT32_MAX) */
+struct lib9p_msg_Rsread {
+ lib9p_tag_t tag;
+ struct lib9p_d_e data;
+};
+
+/* min_size = 17 ; max_size = 8,589,934,607 (warning: >UINT32_MAX) */
+struct lib9p_msg_Tswrite {
+ lib9p_tag_t tag;
+ uint32_t fid;
+ uint16_t nwname;
+ struct lib9p_s *wname;
+ struct lib9p_d_e data;
+};
+
+#endif /* CONFIG_9P_ENABLE_9P2000_e */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
+/* LIB9P_VER_9P2000 : min_size = 49 ; max_size = 262,189 */
+/* LIB9P_VER_9P2000_e: min_size = 49 ; max_size = 262,189 */
+/* LIB9P_VER_9P2000_u: min_size = 63 ; max_size = 327,738 */
struct lib9p_stat {
uint16_t kern_type;
uint32_t kern_dev;
@@ -850,16 +943,19 @@ struct lib9p_stat {
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
+/* size = 20 */
struct lib9p_msg_Rauth {
lib9p_tag_t tag;
struct lib9p_qid aqid;
};
+/* size = 20 */
struct lib9p_msg_Rattach {
lib9p_tag_t tag;
struct lib9p_qid qid;
};
+/* min_size = 9 ; max_size = 217 */
struct lib9p_msg_Rwalk {
lib9p_tag_t tag;
uint16_t nwqid;
@@ -868,12 +964,14 @@ struct lib9p_msg_Rwalk {
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
+/* size = 24 */
struct lib9p_msg_Ropen {
lib9p_tag_t tag;
struct lib9p_qid qid;
uint32_t iounit;
};
+/* size = 24 */
struct lib9p_msg_Rcreate {
lib9p_tag_t tag;
struct lib9p_qid qid;
@@ -882,28 +980,33 @@ struct lib9p_msg_Rcreate {
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000_L
+/* size = 24 */
struct lib9p_msg_Rlopen {
lib9p_tag_t tag;
struct lib9p_qid qid;
uint32_t iounit;
};
+/* size = 24 */
struct lib9p_msg_Rlcreate {
lib9p_tag_t tag;
struct lib9p_qid qid;
uint32_t iounit;
};
+/* size = 20 */
struct lib9p_msg_Rsymlink {
lib9p_tag_t tag;
struct lib9p_qid qid;
};
+/* size = 20 */
struct lib9p_msg_Rmknod {
lib9p_tag_t tag;
struct lib9p_qid qid;
};
+/* size = 160 */
struct lib9p_msg_Rgetattr {
lib9p_tag_t tag;
uint64_t valid;
@@ -928,6 +1031,7 @@ struct lib9p_msg_Rgetattr {
uint64_t data_version;
};
+/* size = 20 */
struct lib9p_msg_Tmkdir {
lib9p_tag_t tag;
struct lib9p_qid qid;
@@ -935,11 +1039,17 @@ struct lib9p_msg_Tmkdir {
#endif /* CONFIG_9P_ENABLE_9P2000_L */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
+/* LIB9P_VER_9P2000 : min_size = 58 ; max_size = 262,198 */
+/* LIB9P_VER_9P2000_e: min_size = 58 ; max_size = 262,198 */
+/* LIB9P_VER_9P2000_u: min_size = 72 ; max_size = 327,747 */
struct lib9p_msg_Rstat {
lib9p_tag_t tag;
struct lib9p_stat stat;
};
+/* LIB9P_VER_9P2000 : min_size = 62 ; max_size = 262,202 */
+/* LIB9P_VER_9P2000_e: min_size = 62 ; max_size = 262,202 */
+/* LIB9P_VER_9P2000_u: min_size = 76 ; max_size = 327,751 */
struct lib9p_msg_Twstat {
lib9p_tag_t tag;
lib9p_fid_t fid;
diff --git a/lib9p/include/lib9p/9p.h b/lib9p/include/lib9p/9p.h
index 21c10e0..d4764a2 100644
--- a/lib9p/include/lib9p/9p.h
+++ b/lib9p/include/lib9p/9p.h
@@ -19,6 +19,17 @@
#error config.h must define CONFIG_9P_MAX_ERR_SIZE
#endif
+/* strings ********************************************************************/
+
+const char *lib9p_version_str(enum lib9p_version);
+const char *lib9p_msgtype_str(enum lib9p_version, enum lib9p_msg_type);
+
+struct lib9p_s lib9p_str(char *s);
+struct lib9p_s lib9p_strn(char *s, size_t maxlen);
+struct lib9p_s lib9p_str_slice(struct lib9p_s s, uint16_t beg, uint16_t end);
+#define lib9p_str_sliceleft(s, beg) lib9p_str_slice(s, beg, (s).len)
+bool lib9p_str_eq(struct lib9p_s a, struct lib9p_s b);
+
/* ctx ************************************************************************/
struct lib9p_ctx {
@@ -30,7 +41,7 @@ struct lib9p_ctx {
#ifdef CONFIG_9P_ENABLE_9P2000_u
uint32_t err_num;
#endif
- char err_msg[CONFIG_9P_MAX_ERR_SIZE];
+ [[gnu::nonstring]] char err_msg[CONFIG_9P_MAX_ERR_SIZE];
};
void lib9p_ctx_clear_error(struct lib9p_ctx *ctx);
@@ -42,8 +53,6 @@ int lib9p_error(struct lib9p_ctx *ctx, uint32_t linux_errno, char const *msg);
/** Write a printf-style error into ctx, return -1. */
int lib9p_errorf(struct lib9p_ctx *ctx, uint32_t linux_errno, char const *fmt, ...);
-const char *lib9p_msg_type_str(struct lib9p_ctx *, enum lib9p_msg_type);
-
/* main T-message functions ***************************************************/
/**
@@ -52,7 +61,7 @@ const char *lib9p_msg_type_str(struct lib9p_ctx *, enum lib9p_msg_type);
*
* Return how much space the message will take when unmarshaled. This
* number may be larger than net_bytes due to (1) struct padding, (2)
- * nul-terminator bytes for strings.
+ * array pointers.
*
* Emits an error (return -1, set ctx->err_num and ctx->err_msg) if
* either the message type is unknown, or if net_bytes is too short
diff --git a/lib9p/include/lib9p/srv.h b/lib9p/include/lib9p/srv.h
index eb0e4f4..55cf5db 100644
--- a/lib9p/include/lib9p/srv.h
+++ b/lib9p/include/lib9p/srv.h
@@ -1,6 +1,6 @@
/* lib9p/srv.h - 9P server
*
- * Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com>
+ * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
@@ -22,7 +22,7 @@ CR_CHAN_DECLARE(_lib9p_srv_flushch, bool)
struct lib9p_srv_ctx {
struct lib9p_ctx basectx;
uint32_t uid;
- char *uname;
+ struct lib9p_s uname;
BEGIN_PRIVATE(LIB9P_SRV_H)
_lib9p_srv_flushch_t _flushch;
@@ -67,9 +67,9 @@ struct lib9p_srv_file_vtable {
/* directories - base */
implements_lib9p_srv_file *(*dopen )(implements_lib9p_srv_file *, struct lib9p_srv_ctx *,
- char *childname);
+ struct lib9p_s childname);
implements_lib9p_srv_file *(*dcreate)(implements_lib9p_srv_file *, struct lib9p_srv_ctx *,
- char *childname,
+ struct lib9p_s childname,
lib9p_dm_t perm, lib9p_o_t flags);
/* directories - once opened */
@@ -95,8 +95,8 @@ CR_RPC_DECLARE(_lib9p_srv_reqch, struct _lib9p_srv_req *, bool)
struct lib9p_srv {
/* Things you provide */
- void /*TODO*/ (*auth )(struct lib9p_srv_ctx *, char *treename); /* optional */
- implements_lib9p_srv_file *(*rootdir)(struct lib9p_srv_ctx *, char *treename);
+ void /*TODO*/ (*auth )(struct lib9p_srv_ctx *, struct lib9p_s treename); /* optional */
+ implements_lib9p_srv_file *(*rootdir)(struct lib9p_srv_ctx *, struct lib9p_s treename);
/* For internal use */
BEGIN_PRIVATE(LIB9P_SRV_H)
diff --git a/lib9p/internal.h b/lib9p/internal.h
index 57d61cb..eb67992 100644
--- a/lib9p/internal.h
+++ b/lib9p/internal.h
@@ -13,6 +13,7 @@
#define SSIZE_MAX (SIZE_MAX >> 1)
#endif
+#include <libmisc/endian.h>
#include <libmisc/macro.h>
#include <lib9p/9p.h>
@@ -85,6 +86,7 @@ struct _lib9p_send_tentry {
_marshal_fn_t marshal;
};
+extern const char * _lib9p_table_ver_name[LIB9P_VER_NUM];
extern const char * _lib9p_table_msg_name[LIB9P_VER_NUM][0x100];
extern const struct _lib9p_recv_tentry _lib9p_table_Tmsg_recv[LIB9P_VER_NUM][0x80];
extern const struct _lib9p_recv_tentry _lib9p_table_Rmsg_recv[LIB9P_VER_NUM][0x80];
@@ -97,33 +99,6 @@ bool _lib9p_stat_marshal(struct _marshal_ctx *ctx, struct lib9p_stat *val);
/* unmarshal utilities ********************************************************/
-LM_ALWAYS_INLINE static uint8_t decode_u8le(uint8_t *in) {
- return in[0];
-}
-LM_ALWAYS_INLINE static uint16_t decode_u16le(uint8_t *in) {
- return (((uint16_t)(in[0])) << 0)
- | (((uint16_t)(in[1])) << 8)
- ;
-}
-LM_ALWAYS_INLINE static uint32_t decode_u32le(uint8_t *in) {
- return (((uint32_t)(in[0])) << 0)
- | (((uint32_t)(in[1])) << 8)
- | (((uint32_t)(in[2])) << 16)
- | (((uint32_t)(in[3])) << 24)
- ;
-}
-LM_ALWAYS_INLINE static uint64_t decode_u64le(uint8_t *in) {
- return (((uint64_t)(in[0])) << 0)
- | (((uint64_t)(in[1])) << 8)
- | (((uint64_t)(in[2])) << 16)
- | (((uint64_t)(in[3])) << 24)
- | (((uint64_t)(in[4])) << 32)
- | (((uint64_t)(in[5])) << 40)
- | (((uint64_t)(in[6])) << 48)
- | (((uint64_t)(in[7])) << 56)
- ;
-}
-
static inline bool _is_valid_utf8(uint8_t *str, size_t len, bool forbid_nul) {
uint32_t ch;
uint8_t chlen;
@@ -148,30 +123,4 @@ static inline bool _is_valid_utf8(uint8_t *str, size_t len, bool forbid_nul) {
#define is_valid_utf8(str, len) _is_valid_utf8(str, len, false)
#define is_valid_utf8_without_nul(str, len) _is_valid_utf8(str, len, true)
-/* marshal utilities **********************************************************/
-
-LM_ALWAYS_INLINE static void encode_u8le(uint8_t in, uint8_t *out) {
- out[0] = in;
-}
-LM_ALWAYS_INLINE static void encode_u16le(uint16_t in, uint8_t *out) {
- out[0] = (uint8_t)((in >> 0) & 0xFF);
- out[1] = (uint8_t)((in >> 8) & 0xFF);
-}
-LM_ALWAYS_INLINE static void encode_u32le(uint32_t in, uint8_t *out) {
- out[0] = (uint8_t)((in >> 0) & 0xFF);
- out[1] = (uint8_t)((in >> 8) & 0xFF);
- out[2] = (uint8_t)((in >> 16) & 0xFF);
- out[3] = (uint8_t)((in >> 24) & 0xFF);
-}
-LM_ALWAYS_INLINE static void encode_u64le(uint64_t in, uint8_t *out) {
- out[0] = (uint8_t)((in >> 0) & 0xFF);
- out[1] = (uint8_t)((in >> 8) & 0xFF);
- out[2] = (uint8_t)((in >> 16) & 0xFF);
- out[3] = (uint8_t)((in >> 24) & 0xFF);
- out[4] = (uint8_t)((in >> 32) & 0xFF);
- out[5] = (uint8_t)((in >> 40) & 0xFF);
- out[6] = (uint8_t)((in >> 48) & 0xFF);
- out[7] = (uint8_t)((in >> 56) & 0xFF);
-}
-
#endif /* _LIB9P_INTERNAL_H_ */
diff --git a/lib9p/srv.c b/lib9p/srv.c
index d5b643d..f2d1315 100644
--- a/lib9p/srv.c
+++ b/lib9p/srv.c
@@ -121,7 +121,7 @@ static uint32_t rerror_overhead_for_version(enum lib9p_version version,
scratch); /* net_bytes */
assert(!e);
- uint32_t min_msg_size = decode_u32le(scratch);
+ uint32_t min_msg_size = uint32le_decode(scratch);
/* Assert that min_msg_size + biggest_possible_MAX_ERR_SIZE
* won't overflow uint32... because using
@@ -143,11 +143,8 @@ static void respond_error(struct _lib9p_srv_req *req) {
ssize_t r;
struct lib9p_msg_Rerror host = {
.tag = req->tag,
- .ename = {
- .len = strnlen(req->ctx.basectx.err_msg,
- CONFIG_9P_MAX_ERR_SIZE),
- .utf8 = req->ctx.basectx.err_msg,
- },
+ .ename = lib9p_strn(req->ctx.basectx.err_msg,
+ CONFIG_9P_MAX_ERR_SIZE),
#if CONFIG_9P_ENABLE_9P2000_u
.errno = req->ctx.basectx.err_num,
#endif
@@ -167,7 +164,7 @@ static void respond_error(struct _lib9p_srv_req *req) {
cr_mutex_lock(&sess->parent_conn->writelock);
r = VCALL(sess->parent_conn->fd, write,
- req->net_bytes, decode_u32le(req->net_bytes));
+ req->net_bytes, uint32le_decode(req->net_bytes));
cr_mutex_unlock(&sess->parent_conn->writelock);
if (r < 0)
nonrespond_errorf("write: %s", net_strerror(-r));
@@ -229,7 +226,7 @@ static void handle_message(struct _lib9p_srv_req *ctx);
size_t done = 0;
if (read_at_least(conn.fd, buf, 4, &done))
goto close;
- size_t goal = decode_u32le(buf);
+ size_t goal = uint32le_decode(buf);
if (goal < 7) {
nonrespond_errorf("T-message is impossibly small");
goto close;
@@ -238,7 +235,7 @@ static void handle_message(struct _lib9p_srv_req *ctx);
goto close;
struct _lib9p_srv_req req = {
.parent_sess = &sess,
- .tag = decode_u16le(&buf[5]),
+ .tag = uint16le_decode(&buf[5]),
.net_bytes = buf,
.ctx = {
.basectx = {
@@ -296,7 +293,7 @@ COROUTINE lib9p_srv_write_cr(void *_srv) {
/* Deep-copy the request from the reader coroutine's
* stack to our stack. */
req = *rpc_handle.req;
- memcpy(net, req.net_bytes, decode_u32le(req.net_bytes));
+ memcpy(net, req.net_bytes, uint32le_decode(req.net_bytes));
req.net_bytes = net;
/* Record that we have it. */
reqmap_store(&req.parent_sess->reqs, req.tag, &req);
@@ -395,7 +392,7 @@ static void handle_message(struct _lib9p_srv_req *ctx) {
cr_mutex_lock(&ctx->parent_sess->parent_conn->writelock);
VCALL(ctx->parent_sess->parent_conn->fd, write,
- ctx->net_bytes, decode_u32le(ctx->net_bytes));
+ ctx->net_bytes, uint32le_decode(ctx->net_bytes));
cr_mutex_unlock(&ctx->parent_sess->parent_conn->writelock);
}
}
@@ -443,14 +440,14 @@ static void handle_Tversion(struct _lib9p_srv_req *ctx,
'0' <= req->version.utf8[3] && req->version.utf8[3] <= '9' &&
'0' <= req->version.utf8[4] && req->version.utf8[4] <= '9' &&
'0' <= req->version.utf8[5] && req->version.utf8[5] <= '9' &&
- (req->version.utf8[6] == '\0' || req->version.utf8[6] == '.')) {
+ (req->version.len == 6 || req->version.utf8[6] == '.')) {
version = LIB9P_VER_9P2000;
#if CONFIG_9P_ENABLE_9P2000_u
- if (strcmp(&req->version.utf8[6], ".u") == 0)
+ if (lib9p_str_eq(lib9p_str_sliceleft(req->version, 6), lib9p_str(".u")))
version = LIB9P_VER_9P2000_u;
#endif
#if CONFIG_9P_ENABLE_9P2000_e
- if (strcmp(&req->version.utf8[6], ".e") == 0)
+ if (lib9p_str_eq(lib9p_str_sliceleft(req->version, 6), lib9p_str(".e")))
version = LIB9P_VER_9P2000_e;
#endif
}
@@ -463,11 +460,7 @@ static void handle_Tversion(struct _lib9p_srv_req *ctx,
return;
}
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
- resp->version.utf8 = lib9p_version_str(version);
-#pragma GCC diagnostic pop
- resp->version.len = strlen(resp->version.utf8);
+ resp->version = lib9p_str((char *)lib9p_version_str(version)); /* cast to discard "const" qualifier */
resp->max_msg_size = (CONFIG_9P_MAX_MSG_SIZE < req->max_msg_size)
? CONFIG_9P_MAX_MSG_SIZE
: req->max_msg_size;
@@ -511,7 +504,7 @@ static void handle_Tauth(struct _lib9p_srv_req *ctx,
util_handler_common(ctx, req, resp);
ctx->ctx.uid = req->n_uid;
- ctx->ctx.uname = req->uname.utf8;
+ ctx->ctx.uname = req->uname;
struct lib9p_srv *srv = ctx->parent_sess->parent_conn->parent_srv;
if (!srv->auth) {
@@ -520,7 +513,7 @@ static void handle_Tauth(struct _lib9p_srv_req *ctx,
return;
}
- srv->auth(&ctx->ctx, req->aname.utf8);
+ srv->auth(&ctx->ctx, req->aname);
lib9p_error(&ctx->ctx.basectx,
LINUX_EOPNOTSUPP, "TODO: auth not implemented");
}
@@ -531,7 +524,7 @@ static void handle_Tattach(struct _lib9p_srv_req *ctx,
util_handler_common(ctx, req, resp);
ctx->ctx.uid = req->n_uid;
- ctx->ctx.uname = req->uname.utf8;
+ ctx->ctx.uname = req->uname;
struct lib9p_srv *srv = ctx->parent_sess->parent_conn->parent_srv;
if (srv->auth) {
@@ -543,14 +536,16 @@ static void handle_Tattach(struct _lib9p_srv_req *ctx,
else if (fh->type != FH_AUTH)
lib9p_error(&ctx->ctx.basectx,
LINUX_EACCES, "FID provided as auth-file is not an auth-file");
- else if (strcmp(fh->data.auth.uname, req->uname.utf8) != 0)
+ else if (!lib9p_str_eq(fh->data.auth.uname, req->uname))
lib9p_errorf(&ctx->ctx.basectx,
- LINUX_EACCES, "FID provided as auth-file is for user=\"%s\" and cannot be used for user=\"%s\"",
- fh->data.auth.uname, req->uname.utf8);
- else if (strcmp(fh->data.auth.aname, req->aname.utf8) != 0)
+ LINUX_EACCES, "FID provided as auth-file is for user=\"%.*s\" and cannot be used for user=\"%.*s\"",
+ fh->data.auth.uname.len, fh->data.auth.uname.utf8,
+ req->uname.len, req->uname.utf8);
+ else if (!lib9p_str_eq(fh->data.auth.aname, req->aname))
lib9p_errorf(&ctx->ctx.basectx,
- LINUX_EACCES, "FID provided as auth-file is for tree=\"%s\" and cannot be used for tree=\"%s\"",
- fh->data.auth.aname, req->aname.utf8);
+ LINUX_EACCES, "FID provided as auth-file is for tree=\"%.*s\" and cannot be used for tree=\"%.*s\"",
+ fh->data.auth.aname.len, fh->data.auth.aname.utf8,
+ req->aname.len, req->aname.utf8);
else if (!fh->data.auth.authenticated)
lib9p_error(&ctx->ctx.basectx,
LINUX_EACCES, "FID provided as auth-file has not completed authentication");
@@ -575,7 +570,7 @@ static void handle_Tattach(struct _lib9p_srv_req *ctx,
return;
}
- implements_lib9p_srv_file *rootdir = srv->rootdir(&ctx->ctx, req->aname.utf8);
+ implements_lib9p_srv_file *rootdir = srv->rootdir(&ctx->ctx, req->aname);
assert((rootdir == NULL) == lib9p_ctx_has_error(&ctx->ctx.basectx));
if (lib9p_ctx_has_error(&ctx->ctx.basectx))
return;
@@ -647,7 +642,7 @@ static void handle_Twalk(struct _lib9p_srv_req *ctx,
resp->wqid = (struct lib9p_qid *)(&resp[1]);
for (resp->nwqid = 0; resp->nwqid < req->nwname; resp->nwqid++) {
implements_lib9p_srv_file *member;
- if (strcmp(req->wname[resp->nwqid].utf8, "..") == 0) {
+ if (lib9p_str_eq(req->wname[resp->nwqid], lib9p_str(".."))) {
member = dir->_parent_dir;
} else {
if (!isdir) {
@@ -656,7 +651,7 @@ static void handle_Twalk(struct _lib9p_srv_req *ctx,
break;
}
- member = VCALL(dir, dopen, &ctx->ctx, req->wname[resp->nwqid].utf8);
+ member = VCALL(dir, dopen, &ctx->ctx, req->wname[resp->nwqid]);
assert((member == NULL) == lib9p_ctx_has_error(&ctx->ctx.basectx));
if (lib9p_ctx_has_error(&ctx->ctx.basectx))
break;
diff --git a/lib9p/tests/test_server/config/config.h b/lib9p/tests/test_server/config/config.h
index e207f7e..971dda2 100644
--- a/lib9p/tests/test_server/config/config.h
+++ b/lib9p/tests/test_server/config/config.h
@@ -1,6 +1,6 @@
/* config.h - Compile-time configuration for srv9p
*
- * Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com>
+ * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
@@ -33,7 +33,7 @@
/**
* Maximum host-data-structure size. A message may be larger in
* unmarshaled-host-structures than marshaled-net-bytes due to (1)
- * struct padding, (2) nul-terminator byes for strings.
+ * struct padding, (2) array pointers.
*/
#define CONFIG_9P_MAX_HOSTMSG_SIZE CONFIG_9P_MAX_MSG_SIZE+16
#define CONFIG_9P_MAX_FIDS 16
diff --git a/lib9p/tests/test_server/main.c b/lib9p/tests/test_server/main.c
index a6e4eeb..8e5011a 100644
--- a/lib9p/tests/test_server/main.c
+++ b/lib9p/tests/test_server/main.c
@@ -78,7 +78,7 @@ static struct util9p_static_dir root = {
},
};
-static implements_lib9p_srv_file *get_root(struct lib9p_srv_ctx *LM_UNUSED(ctx), char *LM_UNUSED(treename)) {
+static implements_lib9p_srv_file *get_root(struct lib9p_srv_ctx *LM_UNUSED(ctx), struct lib9p_s LM_UNUSED(treename)) {
return &root;
}