summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/sbc_harness/config/config.h3
-rw-r--r--cmd/sbc_harness/fs_harness_flash_bin.c13
-rw-r--r--cmd/sbc_harness/fs_harness_uptime_txt.c9
-rw-r--r--lib9p/core.c71
-rw-r--r--lib9p/core_gen/c.py2
-rw-r--r--lib9p/core_gen/c_marshal.py17
-rw-r--r--lib9p/core_gen/c_validate.py26
-rw-r--r--lib9p/core_generated.c1466
-rw-r--r--lib9p/core_include/lib9p/core.h57
-rw-r--r--lib9p/core_tables.h6
-rw-r--r--lib9p/srv.c221
-rw-r--r--lib9p/srv_include/lib9p/srv.h28
-rw-r--r--lib9p/tests/client_config/config.h1
-rw-r--r--lib9p/tests/test_compile_config/config.h2
-rw-r--r--lib9p/tests/test_server/config/config.h3
-rw-r--r--lib9p/tests/test_server/fs_flush.c6
-rw-r--r--lib9p/tests/test_server/fs_shutdown.c4
-rw-r--r--lib9p/tests/test_server/fs_whoami.c7
-rw-r--r--lib9p/tests/testclient-hangup.c4
-rw-r--r--lib9p/tests/testclient-sess.c4
-rw-r--r--lib9p_util/static.c22
21 files changed, 931 insertions, 1041 deletions
diff --git a/cmd/sbc_harness/config/config.h b/cmd/sbc_harness/config/config.h
index 7a91001..61745e5 100644
--- a/cmd/sbc_harness/config/config.h
+++ b/cmd/sbc_harness/config/config.h
@@ -37,8 +37,6 @@
/* 9P *************************************************************************/
-#define CONFIG_9P_MAX_ERR_SIZE 128 /* 128 is what Plan 9 4e uses */
-
#define CONFIG_9P_ENABLE_9P2000 1 /* bool */
#define CONFIG_9P_ENABLE_9P2000_u 1 /* bool */
#define CONFIG_9P_ENABLE_9P2000_e 0 /* bool */
@@ -67,6 +65,7 @@
* (8*1024)+160 in 2e and 3e.
*/
#define CONFIG_9P_SRV_MAX_MSG_SIZE ((4*1024)+24)
+#define CONFIG_9P_SRV_MAX_ERR_SIZE 128 /* 128 is what Plan 9 4e uses */
/**
* Maximum host-data-structure size. A message may be larger in
* unmarshaled-host-structures than marshaled-net-bytes due to (1)
diff --git a/cmd/sbc_harness/fs_harness_flash_bin.c b/cmd/sbc_harness/fs_harness_flash_bin.c
index 0a7364a..d3f90b9 100644
--- a/cmd/sbc_harness/fs_harness_flash_bin.c
+++ b/cmd/sbc_harness/fs_harness_flash_bin.c
@@ -170,13 +170,13 @@ static void flash_file_wstat(struct flash_file *self, struct lib9p_srv_ctx *ctx,
assert(self);
assert(ctx);
- lib9p_error(&ctx->basectx, E_POSIX_EROFS, "read-only part of filesystem");
+ lib9p_error(ctx, E_POSIX_EROFS, "read-only part of filesystem");
}
static void flash_file_remove(struct flash_file *self, struct lib9p_srv_ctx *ctx) {
assert(self);
assert(ctx);
- lib9p_error(&ctx->basectx, E_POSIX_EROFS, "read-only part of filesystem");
+ lib9p_error(ctx, E_POSIX_EROFS, "read-only part of filesystem");
}
LIB9P_SRV_NOTDIR(struct flash_file, flash_file);
@@ -229,8 +229,7 @@ static void flash_file_pread(struct flash_file *self, struct lib9p_srv_ctx *ctx,
assert(ret);
if (byte_offset > DATA_SIZE) {
- lib9p_error(&ctx->basectx,
- E_POSIX_EINVAL, "offset is past the chip size");
+ lib9p_error(ctx, E_POSIX_EINVAL, "offset is past the chip size");
return;
}
@@ -275,15 +274,13 @@ static uint32_t flash_file_pwrite(struct flash_file *self, struct lib9p_srv_ctx
assert(ctx);
if (byte_offset > DATA_HSIZE) {
- lib9p_error(&ctx->basectx,
- E_POSIX_EINVAL, "offset is past half the chip size");
+ lib9p_error(ctx, E_POSIX_EINVAL, "offset is past half the chip size");
return 0;
}
if (byte_count == 0)
return 0;
if (byte_offset == DATA_HSIZE) {
- lib9p_error(&ctx->basectx,
- E_POSIX_EINVAL, "offset is at half the chip size");
+ lib9p_error(ctx, E_POSIX_EINVAL, "offset is at half the chip size");
return 0;
}
diff --git a/cmd/sbc_harness/fs_harness_uptime_txt.c b/cmd/sbc_harness/fs_harness_uptime_txt.c
index 848c34f..2533558 100644
--- a/cmd/sbc_harness/fs_harness_uptime_txt.c
+++ b/cmd/sbc_harness/fs_harness_uptime_txt.c
@@ -69,13 +69,13 @@ static void uptime_file_wstat(struct uptime_file *self, struct lib9p_srv_ctx *ct
assert(self);
assert(ctx);
- lib9p_error(&ctx->basectx, E_POSIX_EROFS, "read-only part of filesystem");
+ lib9p_error(ctx, E_POSIX_EROFS, "read-only part of filesystem");
}
static void uptime_file_remove(struct uptime_file *self, struct lib9p_srv_ctx *ctx) {
assert(self);
assert(ctx);
- lib9p_error(&ctx->basectx, E_POSIX_EROFS, "read-only part of filesystem");
+ lib9p_error(ctx, E_POSIX_EROFS, "read-only part of filesystem");
}
LIB9P_SRV_NOTDIR(struct uptime_file, uptime_file);
@@ -123,8 +123,7 @@ static void uptime_fio_pread(struct uptime_fio *self, struct lib9p_srv_ctx *ctx,
}
if (byte_offset > (uint64_t)self->buf_len) {
- lib9p_error(&ctx->basectx,
- E_POSIX_EINVAL, "offset is past end-of-file length");
+ lib9p_error(ctx, E_POSIX_EINVAL, "offset is past end-of-file length");
return;
}
@@ -145,6 +144,6 @@ static uint32_t uptime_fio_pwrite(struct uptime_fio *self, struct lib9p_srv_ctx
assert(self);
assert(ctx);
- lib9p_error(&ctx->basectx, E_POSIX_EROFS, "read-only part of filesystem");
+ lib9p_error(ctx, E_POSIX_EROFS, "read-only part of filesystem");
return 0;
}
diff --git a/lib9p/core.c b/lib9p/core.c
index f638c12..58fe538 100644
--- a/lib9p/core.c
+++ b/lib9p/core.c
@@ -45,19 +45,6 @@ bool lib9p_str_eq(struct lib9p_s a, struct lib9p_s b) {
(a.len == 0 || memcmp(a.utf8, b.utf8, a.len) == 0);
}
-/* ctx ************************************************************************/
-
-void lib9p_ctx_clear_error(struct lib9p_ctx *ctx) {
- assert(ctx);
- ctx->err_num = 0;
- ctx->err_msg[0] = '\0';
-}
-
-bool lib9p_ctx_has_error(struct lib9p_ctx *ctx) {
- assert(ctx);
- return ctx->err_msg[0];
-}
-
/* bounds checks **************************************************************/
static inline void assert_ver(enum lib9p_version ver) {
@@ -107,29 +94,31 @@ void fmt_print_lib9p_msg(lo_interface fmt_dest w, struct lib9p_ctx *ctx, enum li
_lib9p_table_msg[ctx->version][typ].print(w, ctx, body);
}
-#define _lib9p_validate(LOW_TYP_BIT, ERRMSG, TABLE) do { \
- assert_ver(ctx->version); \
- /* Inspect the first 5 bytes ourselves. */ \
- uint32_t net_size = uint32le_decode(net_bytes); \
- if (net_size < 5) \
- return lib9p_error(ctx, E_POSIX_EBADMSG, "message is impossibly short"); \
- uint8_t typ = net_bytes[4]; \
- if (typ % 2 != LOW_TYP_BIT) \
- return lib9p_error(ctx, E_POSIX_EOPNOTSUPP, ERRMSG ": message_type=", lib9p_msgtype_str(ctx->version, typ)); \
- struct _lib9p_recv_tentry tentry = TABLE[ctx->version][typ/2]; \
- if (!tentry.validate) \
- return lib9p_error(ctx, E_POSIX_EOPNOTSUPP, "unknown message type: ", lib9p_msgtype_str(ctx->version, typ), \
- " (protocol_version=", lib9p_version_str(ctx->version), ")"); \
- \
- /* Now use the message-type-specific tentry to process the whole thing. */ \
- return tentry.validate(ctx, net_size, net_bytes); \
+#define _lib9p_validate(LOW_TYP_BIT, ERRMSG, TABLE) do { \
+ assert_ver(ctx->version); \
+ /* Inspect the first 5 bytes ourselves. */ \
+ uint32_t net_size = uint32le_decode(net_bytes); \
+ if (net_size < 5) \
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "message is impossibly short")); \
+ uint8_t typ = net_bytes[4]; \
+ if (typ % 2 != LOW_TYP_BIT) \
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EOPNOTSUPP, ERRMSG ": message_type=", \
+ lib9p_msgtype_str(ctx->version, typ))); \
+ struct _lib9p_recv_tentry tentry = TABLE[ctx->version][typ/2]; \
+ if (!tentry.validate) \
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EOPNOTSUPP, "unknown message type: ", \
+ lib9p_msgtype_str(ctx->version, typ), \
+ " (protocol_version=", lib9p_version_str(ctx->version), ")")); \
+ \
+ /* Now use the message-type-specific tentry to process the whole thing. */ \
+ return tentry.validate(ctx, net_size, net_bytes); \
} while (0)
-ssize_t lib9p_Tmsg_validate(struct lib9p_ctx *ctx, uint8_t *net_bytes) {
+size_t_or_error lib9p_Tmsg_validate(struct lib9p_ctx *ctx, uint8_t *net_bytes) {
_lib9p_validate(0, "expected a T-message but got an R-message", _lib9p_table_Tmsg_recv);
}
-ssize_t lib9p_Rmsg_validate(struct lib9p_ctx *ctx, uint8_t *net_bytes) {
+size_t_or_error lib9p_Rmsg_validate(struct lib9p_ctx *ctx, uint8_t *net_bytes) {
_lib9p_validate(1, "expected an R-message but got a T-message", _lib9p_table_Rmsg_recv);
}
@@ -169,20 +158,20 @@ void lib9p_Rmsg_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes,
struct _lib9p_send_tentry tentry = TABLE[ctx->version][typ/2]; \
assert(tentry.marshal); \
\
- bool ret_erred = tentry.marshal(ctx, body, &_ret); \
+ error ret_err = tentry.marshal(ctx, body, &_ret); \
if (_ret.net_iov[_ret.net_iov_cnt-1].iov_len == 0) \
_ret.net_iov_cnt--; \
\
ret->iov_cnt = _ret.net_iov_cnt; \
- return ret_erred; \
+ return ret_err; \
} while (0)
-bool lib9p_Tmsg_marshal(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body,
+error lib9p_Tmsg_marshal(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body,
struct lib9p_Tmsg_send_buf *ret) {
_lib9p_marshal(0, _lib9p_table_Tmsg_send);
}
-bool lib9p_Rmsg_marshal(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body,
+error lib9p_Rmsg_marshal(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body,
struct lib9p_Rmsg_send_buf *ret) {
_lib9p_marshal(1, _lib9p_table_Rmsg_send);
}
@@ -190,14 +179,14 @@ bool lib9p_Rmsg_marshal(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *bo
/* `struct lib9p_stat` helpers ************************************************/
#if _LIB9P_ENABLE_stat
-bool lib9p_stat_validate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes,
+error lib9p_stat_validate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes,
uint32_t *ret_net_size, size_t *ret_host_size) {
- ssize_t host_size = _lib9p_stat_validate(ctx, net_size, net_bytes, ret_net_size);
- if (host_size < 0)
- return true;
+ size_t_or_error host_size = _lib9p_stat_validate(ctx, net_size, net_bytes, ret_net_size);
+ if (host_size.is_err)
+ return host_size.err;
if (ret_host_size)
- *ret_host_size = (size_t)host_size;
- return false;
+ *ret_host_size = host_size.size_t;
+ return ERROR_NULL;
}
void lib9p_stat_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes,
diff --git a/lib9p/core_gen/c.py b/lib9p/core_gen/c.py
index 0947ec2..ab34387 100644
--- a/lib9p/core_gen/c.py
+++ b/lib9p/core_gen/c.py
@@ -175,7 +175,7 @@ def gen_c(versions: set[str], typs: list[idl.UserType]) -> str:
ret += f"""
{cutil.ifdef_push(1, c9util.ver_ifdef(next(typ for typ in typs if typ.typname == 'stat').in_versions)).rstrip()}
-LM_FLATTEN ssize_t {c9util.ident('_stat_validate')}(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes, uint32_t *ret_net_size) {{
+LM_FLATTEN size_t_or_error {c9util.ident('_stat_validate')}(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes, uint32_t *ret_net_size) {{
\treturn validate_stat(ctx, net_size, net_bytes, ret_net_size);
}}
LM_FLATTEN void {c9util.ident('_stat_unmarshal')}(struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out) {{
diff --git a/lib9p/core_gen/c_marshal.py b/lib9p/core_gen/c_marshal.py
index 6321837..86d82e4 100644
--- a/lib9p/core_gen/c_marshal.py
+++ b/lib9p/core_gen/c_marshal.py
@@ -365,7 +365,10 @@ def gen_c_marshal(versions: set[str], typs: list[idl.UserType]) -> str:
assert isinstance(typ, idl.Struct)
ret += "\n"
ret += cutil.ifdef_push(1, c9util.ver_ifdef(typ.in_versions))
- ret += f"static bool marshal_{typ.typname}(struct lib9p_ctx *ctx, {c9util.typename(typ)} *val, struct _marshal_ret *ret) {{\n"
+ if not isinstance(typ, idl.Message): # SPECIAL (bool for stat)
+ ret += f"static bool marshal_{typ.typname}(struct lib9p_ctx *ctx, {c9util.typename(typ)} *val, struct _marshal_ret *ret) {{\n"
+ else:
+ ret += f"static error marshal_{typ.typname}(struct lib9p_ctx *ctx, {c9util.typename(typ)} *val, struct _marshal_ret *ret) {{\n"
# Pass 1 - check size
max_size = max(typ.max_size(v) for v in typ.in_versions)
@@ -380,11 +383,12 @@ def gen_c_marshal(versions: set[str], typs: list[idl.UserType]) -> str:
ret += "\tif (needed_size > (uint64_t)(ctx->max_msg_size)) {\n"
else:
ret += "\tif (needed_size > ctx->max_msg_size) {\n"
- if isinstance(typ, idl.Message): # SPECIAL (disable for stat)
- ret += f'\t\tlib9p_error(ctx, E_POSIX_ERANGE, "{typ.typname} message too large to marshal into ",\n'
+ if not isinstance(typ, idl.Message): # SPECIAL (bool for stat)
+ ret += "\t\treturn true;\n"
+ else:
+ ret += f'\t\treturn error_new(E_POSIX_ERANGE, "{typ.typname} message too large to marshal into ",\n'
ret += f'\t\t\tctx->version ? "negotiated" : "{'client' if typ.msgid % 2 == 0 else 'server'}", " limit",\n'
ret += '\t\t\t" (", needed_size, " > ", ctx->max_msg_size, ")");\n'
- ret += "\t\treturn true;\n"
ret += "\t}\n"
# Pass 2 - write data
@@ -396,7 +400,10 @@ def gen_c_marshal(versions: set[str], typs: list[idl.UserType]) -> str:
ret += cutil.ifdef_pop(ifdef_lvl())
# Return
- ret += "\treturn false;\n"
+ if not isinstance(typ, idl.Message): # SPECIAL (bool for stat)
+ ret += "\treturn false;\n"
+ else:
+ ret += "\treturn ERROR_NULL;\n"
ret += "}\n"
ret += cutil.ifdef_pop(0)
return ret
diff --git a/lib9p/core_gen/c_validate.py b/lib9p/core_gen/c_validate.py
index 29567ae..1bfe329 100644
--- a/lib9p/core_gen/c_validate.py
+++ b/lib9p/core_gen/c_validate.py
@@ -57,9 +57,9 @@ def gen_c_validate(versions: set[str], typs: list[idl.UserType]) -> str:
"\t\t/* If needed-net-size overflowed uint32_t, then\n"
"\t\t * there's no way that actual-net-size will live up to\n"
"\t\t * that. */\n"
- '\t\treturn lib9p_error(ctx, E_POSIX_EBADMSG, "message is too short for content");\n'
+ '\t\treturn ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "message is too short for content"));\n'
"\tif (net_offset > net_size)\n"
- '\t\treturn lib9p_error(ctx, E_POSIX_EBADMSG, "message is too short for content (", net_offset, " > ", net_size, ")");\n'
+ '\t\treturn ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "message is too short for content (", net_offset, " > ", net_size, ")"));\n'
)
ret += cutil.macro(
"#define VALIDATE_NET_UTF8(n)\n"
@@ -67,16 +67,16 @@ def gen_c_validate(versions: set[str], typs: list[idl.UserType]) -> str:
"\t\tsize_t len = n;\n"
"\t\tVALIDATE_NET_BYTES(len);\n"
"\t\tif (!utf8_is_valid_without_nul(&net_bytes[net_offset-len], len))\n"
- '\t\t\treturn lib9p_error(ctx, E_POSIX_EILSEQ, "message contains invalid UTF-8");\n'
+ '\t\t\treturn ERROR_NEW_ERR(size_t, error_new(E_POSIX_EILSEQ, "message contains invalid UTF-8"));\n'
"\t}\n"
)
ret += cutil.macro(
"#define RESERVE_HOST_BYTES(n)\n"
"\tif (__builtin_add_overflow(host_size, n, &host_size))\n"
- "\t\t/* If needed-host-size overflowed ssize_t, then there's\n"
+ "\t\t/* If needed-host-size overflowed size_t, then there's\n"
"\t\t * no way that actual-net-size will live up to\n"
"\t\t * that. */\n"
- '\t\treturn lib9p_error(ctx, E_POSIX_EBADMSG, "message is too short for content");\n'
+ '\t\treturn ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "message is too short for content"));\n'
)
ret += "#define GET_U8LE(off) (net_bytes[off])\n"
@@ -193,7 +193,7 @@ def gen_c_validate(versions: set[str], typs: list[idl.UserType]) -> str:
act = f"GET_U{nbits}LE({lookup_sym(f'&{child.membname}')})"
exp = f"{c9util.idl_expr(child.val, lookup_sym)}"
ret += f"{'\t'*indent_lvl()}if ({act} != {exp})\n"
- ret += f'{"\t"*(indent_lvl()+1)}return lib9p_error(ctx, E_POSIX_EBADMSG, "{path} value is wrong: actual:", (base10, {act}), " != correct:", (base10, {exp}));\n'
+ ret += f'{"\t"*(indent_lvl()+1)}return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "{path} value is wrong: actual:", (base10, {act}), " != correct:", (base10, {exp})));\n'
if child.max:
incr_flush()
assert child.typ.static_size
@@ -207,15 +207,15 @@ def gen_c_validate(versions: set[str], typs: list[idl.UserType]) -> str:
act = f"GET_U{nbits}LE({lookup_sym(f'&{child.membname}')})"
exp = f"{c9util.idl_expr(child.max, lookup_sym)}"
ret += f"{'\t'*indent_lvl()}if ({act} > {exp})\n"
- ret += f'{"\t"*(indent_lvl()+1)}return lib9p_error(ctx, E_POSIX_EBADMSG, "{path} value is too large: ", (base10, {act}), " > ", (base10, {exp}));\n'
+ ret += f'{"\t"*(indent_lvl()+1)}return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "{path} value is too large: ", (base10, {act}), " > ", (base10, {exp})));\n'
if isinstance(child.typ, idl.Bitfield):
incr_flush()
nbytes = child.typ.static_size
nbits = nbytes * 8
act = f"GET_U{nbits}LE({lookup_sym(f'&{child.membname}')})"
ret += f"{'\t'*indent_lvl()}if ({act} & ~{child.typ.typname}_masks[ctx->version])\n"
- ret += f'{"\t"*(indent_lvl()+1)}return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in {child.typ.typname} bitfield: ",\n'
- ret += f"{'\t'*(indent_lvl()+2)}(base16_u{nbits}_, {act} & ~{child.typ.typname}_masks[ctx->version]));\n"
+ ret += f'{"\t"*(indent_lvl()+1)}return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in {child.typ.typname} bitfield: ",\n'
+ ret += f"{'\t'*(indent_lvl()+2)}(base16_u{nbits}_, {act} & ~{child.typ.typname}_masks[ctx->version])));\n"
def handle(
path: idlutil.Path,
@@ -271,12 +271,12 @@ def gen_c_validate(versions: set[str], typs: list[idl.UserType]) -> str:
ret += "\n"
ret += cutil.ifdef_push(1, c9util.ver_ifdef(typ.in_versions))
if typ.typname == "stat": # SPECIAL (stat)
- ret += f"static ssize_t validate_{typ.typname}(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes, uint32_t *ret_net_size) {{\n"
+ ret += f"static size_t_or_error validate_{typ.typname}(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes, uint32_t *ret_net_size) {{\n"
else:
- ret += f"static ssize_t validate_{typ.typname}(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {{\n"
+ ret += f"static size_t_or_error validate_{typ.typname}([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {{\n"
ret += "\tuint32_t net_offset = 0;\n"
- ret += f"\tssize_t host_size = sizeof({c9util.typename(typ)});\n"
+ ret += f"\tsize_t host_size = sizeof({c9util.typename(typ)});\n"
incr_buf = 0
indent_stack = [IndentLevel(ifdef=True)]
@@ -291,7 +291,7 @@ def gen_c_validate(versions: set[str], typs: list[idl.UserType]) -> str:
if typ.typname == "stat": # SPECIAL (stat)
ret += "\tif (ret_net_size)\n"
ret += "\t\t*ret_net_size = net_offset;\n"
- ret += "\treturn (ssize_t)host_size;\n"
+ ret += "\treturn ERROR_NEW_VAL(size_t, host_size);\n"
ret += "}\n"
ret += cutil.ifdef_pop(0)
return ret
diff --git a/lib9p/core_generated.c b/lib9p/core_generated.c
index 493bbc2..08ab4f0 100644
--- a/lib9p/core_generated.c
+++ b/lib9p/core_generated.c
@@ -221,27 +221,27 @@ static const lib9p_lock_flags_t lock_flags_masks[LIB9P_VER_NUM] = {
/* validate_* *****************************************************************/
-#define VALIDATE_NET_BYTES(n) \
- if (__builtin_add_overflow(net_offset, n, &net_offset)) \
- /* If needed-net-size overflowed uint32_t, then \
- * there's no way that actual-net-size will live up to \
- * that. */ \
- return lib9p_error(ctx, E_POSIX_EBADMSG, "message is too short for content"); \
- if (net_offset > net_size) \
- return lib9p_error(ctx, E_POSIX_EBADMSG, "message is too short for content (", net_offset, " > ", net_size, ")");
-#define VALIDATE_NET_UTF8(n) \
- { \
- size_t len = n; \
- VALIDATE_NET_BYTES(len); \
- if (!utf8_is_valid_without_nul(&net_bytes[net_offset-len], len)) \
- return lib9p_error(ctx, E_POSIX_EILSEQ, "message contains invalid UTF-8"); \
- }
-#define RESERVE_HOST_BYTES(n) \
- if (__builtin_add_overflow(host_size, n, &host_size)) \
- /* If needed-host-size overflowed ssize_t, then there's \
- * no way that actual-net-size will live up to \
- * that. */ \
- return lib9p_error(ctx, E_POSIX_EBADMSG, "message is too short for content");
+#define VALIDATE_NET_BYTES(n) \
+ if (__builtin_add_overflow(net_offset, n, &net_offset)) \
+ /* If needed-net-size overflowed uint32_t, then \
+ * there's no way that actual-net-size will live up to \
+ * that. */ \
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "message is too short for content")); \
+ if (net_offset > net_size) \
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "message is too short for content (", net_offset, " > ", net_size, ")"));
+#define VALIDATE_NET_UTF8(n) \
+ { \
+ size_t len = n; \
+ VALIDATE_NET_BYTES(len); \
+ if (!utf8_is_valid_without_nul(&net_bytes[net_offset-len], len)) \
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EILSEQ, "message contains invalid UTF-8")); \
+ }
+#define RESERVE_HOST_BYTES(n) \
+ if (__builtin_add_overflow(host_size, n, &host_size)) \
+ /* If needed-host-size overflowed size_t, then there's \
+ * no way that actual-net-size will live up to \
+ * that. */ \
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "message is too short for content"));
#define GET_U8LE(off) (net_bytes[off])
#define GET_U16LE(off) uint16le_decode(&net_bytes[off])
#define GET_U32LE(off) uint32le_decode(&net_bytes[off])
@@ -252,16 +252,16 @@ static const lib9p_lock_flags_t lock_flags_masks[LIB9P_VER_NUM] = {
#define LAST_U64LE() GET_U64LE(net_offset-8)
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
-static ssize_t validate_stat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes, uint32_t *ret_net_size) {
+static size_t_or_error validate_stat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes, uint32_t *ret_net_size) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_stat);
+ size_t host_size = sizeof(struct lib9p_stat);
uint32_t offsetof__stat_size = net_offset + 0;
uint32_t offsetof_fstype = net_offset + 2;
uint32_t offsetof_qid_type = net_offset + 8;
VALIDATE_NET_BYTES(21);
if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])
- return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in qt bitfield: ",
- (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in qt bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])));
uint32_t offsetof_mode = net_offset + 0;
VALIDATE_NET_BYTES(22);
VALIDATE_NET_UTF8(LAST_U16LE());
@@ -280,52 +280,52 @@ static ssize_t validate_stat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *
#endif /* CONFIG_9P_ENABLE_9P2000_u */
uint32_t offsetof_end = net_offset + 0;
if (GET_U32LE(offsetof__stat_size) != offsetof_end - offsetof_fstype)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "stat->_stat_size value is wrong: actual:", (base10, GET_U32LE(offsetof__stat_size)), " != correct:", (base10, offsetof_end - offsetof_fstype));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "stat->_stat_size value is wrong: actual:", (base10, GET_U32LE(offsetof__stat_size)), " != correct:", (base10, offsetof_end - offsetof_fstype)));
if (GET_U32LE(offsetof_mode) & ~dm_masks[ctx->version])
- return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in dm bitfield: ",
- (base16_u32_, GET_U32LE(offsetof_mode) & ~dm_masks[ctx->version]));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in dm bitfield: ",
+ (base16_u32_, GET_U32LE(offsetof_mode) & ~dm_masks[ctx->version])));
if (ret_net_size)
*ret_net_size = net_offset;
- return (ssize_t)host_size;
+ return ERROR_NEW_VAL(size_t, host_size);
}
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized
-static ssize_t validate_Tversion(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Tversion([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Tversion);
+ size_t host_size = sizeof(struct lib9p_msg_Tversion);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
VALIDATE_NET_BYTES(13);
VALIDATE_NET_UTF8(LAST_U16LE());
uint32_t offsetof_end = net_offset + 0;
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tversion->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tversion->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 100)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tversion->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 100));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tversion->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 100)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Rversion(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rversion([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rversion);
+ size_t host_size = sizeof(struct lib9p_msg_Rversion);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
VALIDATE_NET_BYTES(13);
VALIDATE_NET_UTF8(LAST_U16LE());
uint32_t offsetof_end = net_offset + 0;
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rversion->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rversion->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 101)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rversion->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 101));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rversion->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 101)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
-static ssize_t validate_Tauth(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Tauth([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Tauth);
+ size_t host_size = sizeof(struct lib9p_msg_Tauth);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
VALIDATE_NET_BYTES(13);
@@ -339,33 +339,33 @@ static ssize_t validate_Tauth(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */
uint32_t offsetof_end = net_offset + 0;
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tauth->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tauth->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 102)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tauth->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 102));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tauth->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 102)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Rauth(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rauth([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rauth);
+ size_t host_size = sizeof(struct lib9p_msg_Rauth);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_aqid_type = net_offset + 7;
VALIDATE_NET_BYTES(20);
if (GET_U8LE(offsetof_aqid_type) & ~qt_masks[ctx->version])
- return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in qt bitfield: ",
- (base16_u8_, GET_U8LE(offsetof_aqid_type) & ~qt_masks[ctx->version]));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in qt bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_aqid_type) & ~qt_masks[ctx->version])));
uint32_t offsetof_end = net_offset + 0;
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rauth->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rauth->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 103)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rauth->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 103));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rauth->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 103)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Tattach(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Tattach([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Tattach);
+ size_t host_size = sizeof(struct lib9p_msg_Tattach);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
VALIDATE_NET_BYTES(17);
@@ -379,35 +379,35 @@ static ssize_t validate_Tattach(struct lib9p_ctx *ctx, uint32_t net_size, uint8_
#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */
uint32_t offsetof_end = net_offset + 0;
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tattach->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tattach->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 104)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tattach->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 104));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tattach->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 104)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Rattach(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rattach([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rattach);
+ size_t host_size = sizeof(struct lib9p_msg_Rattach);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_qid_type = net_offset + 7;
VALIDATE_NET_BYTES(20);
if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])
- return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in qt bitfield: ",
- (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in qt bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])));
uint32_t offsetof_end = net_offset + 0;
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rattach->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rattach->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 105)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rattach->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 105));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rattach->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 105)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized
-static ssize_t validate_Rerror(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rerror([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rerror);
+ size_t host_size = sizeof(struct lib9p_msg_Rerror);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
VALIDATE_NET_BYTES(9);
@@ -419,45 +419,45 @@ static ssize_t validate_Rerror(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
#endif /* CONFIG_9P_ENABLE_9P2000_u */
uint32_t offsetof_end = net_offset + 0;
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rerror->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rerror->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 107)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rerror->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 107));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rerror->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 107)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
-static ssize_t validate_Tflush(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Tflush([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Tflush);
+ size_t host_size = sizeof(struct lib9p_msg_Tflush);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 9;
VALIDATE_NET_BYTES(9);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tflush->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tflush->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 108)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tflush->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 108));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tflush->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 108)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Rflush(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rflush([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rflush);
+ size_t host_size = sizeof(struct lib9p_msg_Rflush);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 7;
VALIDATE_NET_BYTES(7);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rflush->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rflush->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 109)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rflush->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 109));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rflush->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 109)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Twalk(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Twalk([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Twalk);
+ size_t host_size = sizeof(struct lib9p_msg_Twalk);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_nwname = net_offset + 15;
@@ -469,17 +469,17 @@ static ssize_t validate_Twalk(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
}
uint32_t offsetof_end = net_offset + 0;
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Twalk->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Twalk->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 110)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Twalk->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 110));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Twalk->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 110)));
if (GET_U16LE(offsetof_nwname) > 16)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Twalk->nwname value is too large: ", (base10, GET_U16LE(offsetof_nwname)), " > ", (base10, 16));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Twalk->nwname value is too large: ", (base10, GET_U16LE(offsetof_nwname)), " > ", (base10, 16)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Rwalk(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rwalk([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rwalk);
+ size_t host_size = sizeof(struct lib9p_msg_Rwalk);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_nwqid = net_offset + 7;
@@ -489,61 +489,61 @@ static ssize_t validate_Rwalk(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
uint32_t offsetof_wqid_type = net_offset + 0;
VALIDATE_NET_BYTES(13);
if (GET_U8LE(offsetof_wqid_type) & ~qt_masks[ctx->version])
- return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in qt bitfield: ",
- (base16_u8_, GET_U8LE(offsetof_wqid_type) & ~qt_masks[ctx->version]));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in qt bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_wqid_type) & ~qt_masks[ctx->version])));
}
uint32_t offsetof_end = net_offset + 0;
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rwalk->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rwalk->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 111)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rwalk->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 111));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rwalk->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 111)));
if (GET_U16LE(offsetof_nwqid) > 16)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rwalk->nwqid value is too large: ", (base10, GET_U16LE(offsetof_nwqid)), " > ", (base10, 16));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rwalk->nwqid value is too large: ", (base10, GET_U16LE(offsetof_nwqid)), " > ", (base10, 16)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
-static ssize_t validate_Topen(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Topen([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Topen);
+ size_t host_size = sizeof(struct lib9p_msg_Topen);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_mode = net_offset + 11;
uint32_t offsetof_end = net_offset + 12;
VALIDATE_NET_BYTES(12);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Topen->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Topen->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 112)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Topen->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 112));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Topen->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 112)));
if (GET_U8LE(offsetof_mode) & ~o_masks[ctx->version])
- return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in o bitfield: ",
- (base16_u8_, GET_U8LE(offsetof_mode) & ~o_masks[ctx->version]));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in o bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_mode) & ~o_masks[ctx->version])));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Ropen(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Ropen([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Ropen);
+ size_t host_size = sizeof(struct lib9p_msg_Ropen);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_qid_type = net_offset + 7;
VALIDATE_NET_BYTES(20);
if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])
- return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in qt bitfield: ",
- (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in qt bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])));
uint32_t offsetof_end = net_offset + 4;
VALIDATE_NET_BYTES(4);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Ropen->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Ropen->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 113)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Ropen->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 113));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Ropen->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 113)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Tcreate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Tcreate([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Tcreate);
+ size_t host_size = sizeof(struct lib9p_msg_Tcreate);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
VALIDATE_NET_BYTES(13);
@@ -553,42 +553,42 @@ static ssize_t validate_Tcreate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_
uint32_t offsetof_end = net_offset + 5;
VALIDATE_NET_BYTES(5);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tcreate->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tcreate->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 114)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tcreate->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 114));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tcreate->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 114)));
if (GET_U32LE(offsetof_perm) & ~dm_masks[ctx->version])
- return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in dm bitfield: ",
- (base16_u32_, GET_U32LE(offsetof_perm) & ~dm_masks[ctx->version]));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in dm bitfield: ",
+ (base16_u32_, GET_U32LE(offsetof_perm) & ~dm_masks[ctx->version])));
if (GET_U8LE(offsetof_mode) & ~o_masks[ctx->version])
- return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in o bitfield: ",
- (base16_u8_, GET_U8LE(offsetof_mode) & ~o_masks[ctx->version]));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in o bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_mode) & ~o_masks[ctx->version])));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Rcreate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rcreate([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rcreate);
+ size_t host_size = sizeof(struct lib9p_msg_Rcreate);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_qid_type = net_offset + 7;
VALIDATE_NET_BYTES(20);
if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])
- return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in qt bitfield: ",
- (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in qt bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])));
uint32_t offsetof_end = net_offset + 4;
VALIDATE_NET_BYTES(4);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rcreate->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rcreate->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 115)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rcreate->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 115));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rcreate->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 115)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
-static ssize_t validate_Tread(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Tread([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Tread);
+ size_t host_size = sizeof(struct lib9p_msg_Tread);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_offset = net_offset + 11;
@@ -596,19 +596,19 @@ static ssize_t validate_Tread(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
uint32_t offsetof_end = net_offset + 23;
VALIDATE_NET_BYTES(23);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tread->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tread->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 116)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tread->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 116));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tread->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 116)));
if (GET_U64LE(offsetof_offset) > INT64_MAX)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tread->offset value is too large: ", (base10, GET_U64LE(offsetof_offset)), " > ", (base10, INT64_MAX));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tread->offset value is too large: ", (base10, GET_U64LE(offsetof_offset)), " > ", (base10, INT64_MAX)));
if (GET_U32LE(offsetof_count) > INT32_MAX)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tread->count value is too large: ", (base10, GET_U32LE(offsetof_count)), " > ", (base10, INT32_MAX));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tread->count value is too large: ", (base10, GET_U32LE(offsetof_count)), " > ", (base10, INT32_MAX)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Rread(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rread([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rread);
+ size_t host_size = sizeof(struct lib9p_msg_Rread);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_count = net_offset + 7;
@@ -616,17 +616,17 @@ static ssize_t validate_Rread(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
VALIDATE_NET_BYTES(LAST_U32LE());
uint32_t offsetof_end = net_offset + 0;
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rread->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rread->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 117)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rread->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 117));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rread->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 117)));
if (GET_U32LE(offsetof_count) > INT32_MAX)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rread->count value is too large: ", (base10, GET_U32LE(offsetof_count)), " > ", (base10, INT32_MAX));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rread->count value is too large: ", (base10, GET_U32LE(offsetof_count)), " > ", (base10, INT32_MAX)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Twrite(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Twrite([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Twrite);
+ size_t host_size = sizeof(struct lib9p_msg_Twrite);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_offset = net_offset + 11;
@@ -635,108 +635,108 @@ static ssize_t validate_Twrite(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
VALIDATE_NET_BYTES(LAST_U32LE());
uint32_t offsetof_end = net_offset + 0;
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Twrite->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Twrite->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 118)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Twrite->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 118));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Twrite->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 118)));
if (GET_U64LE(offsetof_offset) > INT64_MAX)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Twrite->offset value is too large: ", (base10, GET_U64LE(offsetof_offset)), " > ", (base10, INT64_MAX));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Twrite->offset value is too large: ", (base10, GET_U64LE(offsetof_offset)), " > ", (base10, INT64_MAX)));
if (GET_U32LE(offsetof_count) > INT32_MAX)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Twrite->count value is too large: ", (base10, GET_U32LE(offsetof_count)), " > ", (base10, INT32_MAX));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Twrite->count value is too large: ", (base10, GET_U32LE(offsetof_count)), " > ", (base10, INT32_MAX)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Rwrite(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rwrite([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rwrite);
+ size_t host_size = sizeof(struct lib9p_msg_Rwrite);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_count = net_offset + 7;
uint32_t offsetof_end = net_offset + 11;
VALIDATE_NET_BYTES(11);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rwrite->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rwrite->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 119)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rwrite->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 119));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rwrite->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 119)));
if (GET_U32LE(offsetof_count) > INT32_MAX)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rwrite->count value is too large: ", (base10, GET_U32LE(offsetof_count)), " > ", (base10, INT32_MAX));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rwrite->count value is too large: ", (base10, GET_U32LE(offsetof_count)), " > ", (base10, INT32_MAX)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Tclunk(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Tclunk([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Tclunk);
+ size_t host_size = sizeof(struct lib9p_msg_Tclunk);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 11;
VALIDATE_NET_BYTES(11);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tclunk->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tclunk->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 120)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tclunk->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 120));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tclunk->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 120)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Rclunk(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rclunk([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rclunk);
+ size_t host_size = sizeof(struct lib9p_msg_Rclunk);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 7;
VALIDATE_NET_BYTES(7);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rclunk->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rclunk->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 121)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rclunk->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 121));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rclunk->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 121)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Tremove(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Tremove([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Tremove);
+ size_t host_size = sizeof(struct lib9p_msg_Tremove);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 11;
VALIDATE_NET_BYTES(11);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tremove->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tremove->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 122)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tremove->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 122));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tremove->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 122)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Rremove(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rremove([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rremove);
+ size_t host_size = sizeof(struct lib9p_msg_Rremove);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 7;
VALIDATE_NET_BYTES(7);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rremove->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rremove->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 123)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rremove->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 123));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rremove->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 123)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
-static ssize_t validate_Tstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Tstat([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Tstat);
+ size_t host_size = sizeof(struct lib9p_msg_Tstat);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 11;
VALIDATE_NET_BYTES(11);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tstat->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tstat->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 124)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tstat->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 124));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tstat->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 124)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Rstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rstat([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rstat);
+ size_t host_size = sizeof(struct lib9p_msg_Rstat);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_nstat = net_offset + 7;
@@ -746,8 +746,8 @@ static ssize_t validate_Rstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
uint32_t offsetof_stat_qid_type = net_offset + 17;
VALIDATE_NET_BYTES(30);
if (GET_U8LE(offsetof_stat_qid_type) & ~qt_masks[ctx->version])
- return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in qt bitfield: ",
- (base16_u8_, GET_U8LE(offsetof_stat_qid_type) & ~qt_masks[ctx->version]));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in qt bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_stat_qid_type) & ~qt_masks[ctx->version])));
uint32_t offsetof_stat_mode = net_offset + 0;
VALIDATE_NET_BYTES(22);
VALIDATE_NET_UTF8(LAST_U16LE());
@@ -766,23 +766,23 @@ static ssize_t validate_Rstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
#endif /* CONFIG_9P_ENABLE_9P2000_u */
uint32_t offsetof_stat_end = net_offset + 0;
if (GET_U32LE(offsetof_stat__stat_size) != offsetof_stat_end - offsetof_stat_fstype)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rstat->stat._stat_size value is wrong: actual:", (base10, GET_U32LE(offsetof_stat__stat_size)), " != correct:", (base10, offsetof_stat_end - offsetof_stat_fstype));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rstat->stat._stat_size value is wrong: actual:", (base10, GET_U32LE(offsetof_stat__stat_size)), " != correct:", (base10, offsetof_stat_end - offsetof_stat_fstype)));
if (GET_U32LE(offsetof_stat_mode) & ~dm_masks[ctx->version])
- return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in dm bitfield: ",
- (base16_u32_, GET_U32LE(offsetof_stat_mode) & ~dm_masks[ctx->version]));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in dm bitfield: ",
+ (base16_u32_, GET_U32LE(offsetof_stat_mode) & ~dm_masks[ctx->version])));
uint32_t offsetof_end = net_offset + 0;
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rstat->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rstat->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 125)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rstat->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 125));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rstat->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 125)));
if (GET_U32LE(offsetof_nstat) != offsetof_end - offsetof_stat)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rstat->nstat value is wrong: actual:", (base10, GET_U32LE(offsetof_nstat)), " != correct:", (base10, offsetof_end - offsetof_stat));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rstat->nstat value is wrong: actual:", (base10, GET_U32LE(offsetof_nstat)), " != correct:", (base10, offsetof_end - offsetof_stat)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Twstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Twstat([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Twstat);
+ size_t host_size = sizeof(struct lib9p_msg_Twstat);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_nstat = net_offset + 11;
@@ -792,8 +792,8 @@ static ssize_t validate_Twstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
uint32_t offsetof_stat_qid_type = net_offset + 21;
VALIDATE_NET_BYTES(34);
if (GET_U8LE(offsetof_stat_qid_type) & ~qt_masks[ctx->version])
- return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in qt bitfield: ",
- (base16_u8_, GET_U8LE(offsetof_stat_qid_type) & ~qt_masks[ctx->version]));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in qt bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_stat_qid_type) & ~qt_masks[ctx->version])));
uint32_t offsetof_stat_mode = net_offset + 0;
VALIDATE_NET_BYTES(22);
VALIDATE_NET_UTF8(LAST_U16LE());
@@ -812,157 +812,157 @@ static ssize_t validate_Twstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
#endif /* CONFIG_9P_ENABLE_9P2000_u */
uint32_t offsetof_stat_end = net_offset + 0;
if (GET_U32LE(offsetof_stat__stat_size) != offsetof_stat_end - offsetof_stat_fstype)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Twstat->stat._stat_size value is wrong: actual:", (base10, GET_U32LE(offsetof_stat__stat_size)), " != correct:", (base10, offsetof_stat_end - offsetof_stat_fstype));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Twstat->stat._stat_size value is wrong: actual:", (base10, GET_U32LE(offsetof_stat__stat_size)), " != correct:", (base10, offsetof_stat_end - offsetof_stat_fstype)));
if (GET_U32LE(offsetof_stat_mode) & ~dm_masks[ctx->version])
- return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in dm bitfield: ",
- (base16_u32_, GET_U32LE(offsetof_stat_mode) & ~dm_masks[ctx->version]));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in dm bitfield: ",
+ (base16_u32_, GET_U32LE(offsetof_stat_mode) & ~dm_masks[ctx->version])));
uint32_t offsetof_end = net_offset + 0;
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Twstat->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Twstat->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 126)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Twstat->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 126));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Twstat->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 126)));
if (GET_U32LE(offsetof_nstat) != offsetof_end - offsetof_stat)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Twstat->nstat value is wrong: actual:", (base10, GET_U32LE(offsetof_nstat)), " != correct:", (base10, offsetof_end - offsetof_stat));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Twstat->nstat value is wrong: actual:", (base10, GET_U32LE(offsetof_nstat)), " != correct:", (base10, offsetof_end - offsetof_stat)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Rwstat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rwstat([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rwstat);
+ size_t host_size = sizeof(struct lib9p_msg_Rwstat);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 7;
VALIDATE_NET_BYTES(7);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rwstat->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rwstat->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 127)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rwstat->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 127));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rwstat->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 127)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000_p9p
-static ssize_t validate_Topenfd(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Topenfd([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Topenfd);
+ size_t host_size = sizeof(struct lib9p_msg_Topenfd);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_mode = net_offset + 11;
uint32_t offsetof_end = net_offset + 12;
VALIDATE_NET_BYTES(12);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Topenfd->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Topenfd->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 98)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Topenfd->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 98));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Topenfd->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 98)));
if (GET_U8LE(offsetof_mode) & ~o_masks[ctx->version])
- return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in o bitfield: ",
- (base16_u8_, GET_U8LE(offsetof_mode) & ~o_masks[ctx->version]));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in o bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_mode) & ~o_masks[ctx->version])));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Ropenfd(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Ropenfd([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Ropenfd);
+ size_t host_size = sizeof(struct lib9p_msg_Ropenfd);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_qid_type = net_offset + 7;
VALIDATE_NET_BYTES(20);
if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])
- return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in qt bitfield: ",
- (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in qt bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])));
uint32_t offsetof_end = net_offset + 8;
VALIDATE_NET_BYTES(8);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Ropenfd->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Ropenfd->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 99)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Ropenfd->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 99));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Ropenfd->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 99)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
#endif /* CONFIG_9P_ENABLE_9P2000_p9p */
#if CONFIG_9P_ENABLE_9P2000_L
-static ssize_t validate_Rlerror(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rlerror([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rlerror);
+ size_t host_size = sizeof(struct lib9p_msg_Rlerror);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 11;
VALIDATE_NET_BYTES(11);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rlerror->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rlerror->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 7)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rlerror->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 7));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rlerror->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 7)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Tstatfs(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Tstatfs([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Tstatfs);
+ size_t host_size = sizeof(struct lib9p_msg_Tstatfs);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 11;
VALIDATE_NET_BYTES(11);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tstatfs->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tstatfs->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 8)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tstatfs->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 8));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tstatfs->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 8)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Rstatfs(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rstatfs([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rstatfs);
+ size_t host_size = sizeof(struct lib9p_msg_Rstatfs);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 67;
VALIDATE_NET_BYTES(67);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rstatfs->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rstatfs->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 9)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rstatfs->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 9));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rstatfs->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 9)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Tlopen(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Tlopen([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Tlopen);
+ size_t host_size = sizeof(struct lib9p_msg_Tlopen);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_flags = net_offset + 11;
uint32_t offsetof_end = net_offset + 15;
VALIDATE_NET_BYTES(15);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tlopen->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tlopen->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 12)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tlopen->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 12));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tlopen->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 12)));
if (GET_U32LE(offsetof_flags) & ~lo_masks[ctx->version])
- return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in lo bitfield: ",
- (base16_u32_, GET_U32LE(offsetof_flags) & ~lo_masks[ctx->version]));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in lo bitfield: ",
+ (base16_u32_, GET_U32LE(offsetof_flags) & ~lo_masks[ctx->version])));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Rlopen(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rlopen([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rlopen);
+ size_t host_size = sizeof(struct lib9p_msg_Rlopen);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_qid_type = net_offset + 7;
VALIDATE_NET_BYTES(20);
if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])
- return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in qt bitfield: ",
- (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in qt bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])));
uint32_t offsetof_end = net_offset + 4;
VALIDATE_NET_BYTES(4);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rlopen->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rlopen->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 13)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rlopen->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 13));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rlopen->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 13)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Tlcreate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Tlcreate([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Tlcreate);
+ size_t host_size = sizeof(struct lib9p_msg_Tlcreate);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
VALIDATE_NET_BYTES(13);
@@ -972,40 +972,40 @@ static ssize_t validate_Tlcreate(struct lib9p_ctx *ctx, uint32_t net_size, uint8
uint32_t offsetof_end = net_offset + 12;
VALIDATE_NET_BYTES(12);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tlcreate->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tlcreate->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 14)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tlcreate->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 14));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tlcreate->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 14)));
if (GET_U32LE(offsetof_flags) & ~lo_masks[ctx->version])
- return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in lo bitfield: ",
- (base16_u32_, GET_U32LE(offsetof_flags) & ~lo_masks[ctx->version]));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in lo bitfield: ",
+ (base16_u32_, GET_U32LE(offsetof_flags) & ~lo_masks[ctx->version])));
if (GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version])
- return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in mode bitfield: ",
- (base16_u32_, GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in mode bitfield: ",
+ (base16_u32_, GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version])));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Rlcreate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rlcreate([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rlcreate);
+ size_t host_size = sizeof(struct lib9p_msg_Rlcreate);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_qid_type = net_offset + 7;
VALIDATE_NET_BYTES(20);
if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])
- return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in qt bitfield: ",
- (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in qt bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])));
uint32_t offsetof_end = net_offset + 4;
VALIDATE_NET_BYTES(4);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rlcreate->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rlcreate->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 15)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rlcreate->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 15));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rlcreate->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 15)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Tsymlink(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Tsymlink([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Tsymlink);
+ size_t host_size = sizeof(struct lib9p_msg_Tsymlink);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
VALIDATE_NET_BYTES(13);
@@ -1015,33 +1015,33 @@ static ssize_t validate_Tsymlink(struct lib9p_ctx *ctx, uint32_t net_size, uint8
uint32_t offsetof_end = net_offset + 4;
VALIDATE_NET_BYTES(4);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tsymlink->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tsymlink->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 16)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tsymlink->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 16));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tsymlink->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 16)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Rsymlink(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rsymlink([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rsymlink);
+ size_t host_size = sizeof(struct lib9p_msg_Rsymlink);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_qid_type = net_offset + 7;
VALIDATE_NET_BYTES(20);
if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])
- return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in qt bitfield: ",
- (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in qt bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])));
uint32_t offsetof_end = net_offset + 0;
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rsymlink->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rsymlink->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 17)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rsymlink->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 17));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rsymlink->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 17)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Tmknod(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Tmknod([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Tmknod);
+ size_t host_size = sizeof(struct lib9p_msg_Tmknod);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
VALIDATE_NET_BYTES(13);
@@ -1050,139 +1050,139 @@ static ssize_t validate_Tmknod(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
uint32_t offsetof_end = net_offset + 16;
VALIDATE_NET_BYTES(16);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tmknod->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tmknod->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 18)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tmknod->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 18));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tmknod->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 18)));
if (GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version])
- return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in mode bitfield: ",
- (base16_u32_, GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in mode bitfield: ",
+ (base16_u32_, GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version])));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Rmknod(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rmknod([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rmknod);
+ size_t host_size = sizeof(struct lib9p_msg_Rmknod);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_qid_type = net_offset + 7;
VALIDATE_NET_BYTES(20);
if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])
- return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in qt bitfield: ",
- (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in qt bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])));
uint32_t offsetof_end = net_offset + 0;
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rmknod->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rmknod->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 19)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rmknod->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 19));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rmknod->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 19)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Trename(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Trename([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Trename);
+ size_t host_size = sizeof(struct lib9p_msg_Trename);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
VALIDATE_NET_BYTES(17);
VALIDATE_NET_UTF8(LAST_U16LE());
uint32_t offsetof_end = net_offset + 0;
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Trename->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Trename->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 20)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Trename->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 20));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Trename->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 20)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Rrename(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rrename([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rrename);
+ size_t host_size = sizeof(struct lib9p_msg_Rrename);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 7;
VALIDATE_NET_BYTES(7);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rrename->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rrename->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 21)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rrename->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 21));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rrename->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 21)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Treadlink(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Treadlink([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Treadlink);
+ size_t host_size = sizeof(struct lib9p_msg_Treadlink);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 11;
VALIDATE_NET_BYTES(11);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Treadlink->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Treadlink->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 22)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Treadlink->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 22));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Treadlink->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 22)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Rreadlink(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rreadlink([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rreadlink);
+ size_t host_size = sizeof(struct lib9p_msg_Rreadlink);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
VALIDATE_NET_BYTES(9);
VALIDATE_NET_UTF8(LAST_U16LE());
uint32_t offsetof_end = net_offset + 0;
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rreadlink->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rreadlink->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 23)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rreadlink->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 23));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rreadlink->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 23)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Tgetattr(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Tgetattr([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Tgetattr);
+ size_t host_size = sizeof(struct lib9p_msg_Tgetattr);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_request_mask = net_offset + 11;
uint32_t offsetof_end = net_offset + 19;
VALIDATE_NET_BYTES(19);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tgetattr->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tgetattr->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 24)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tgetattr->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 24));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tgetattr->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 24)));
if (GET_U64LE(offsetof_request_mask) & ~getattr_masks[ctx->version])
- return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in getattr bitfield: ",
- (base16_u64_, GET_U64LE(offsetof_request_mask) & ~getattr_masks[ctx->version]));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in getattr bitfield: ",
+ (base16_u64_, GET_U64LE(offsetof_request_mask) & ~getattr_masks[ctx->version])));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Rgetattr(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rgetattr([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rgetattr);
+ size_t host_size = sizeof(struct lib9p_msg_Rgetattr);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_valid = net_offset + 7;
uint32_t offsetof_qid_type = net_offset + 15;
VALIDATE_NET_BYTES(28);
if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])
- return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in qt bitfield: ",
- (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in qt bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])));
uint32_t offsetof_mode = net_offset + 0;
uint32_t offsetof_end = net_offset + 132;
VALIDATE_NET_BYTES(132);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rgetattr->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rgetattr->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 25)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rgetattr->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 25));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rgetattr->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 25)));
if (GET_U64LE(offsetof_valid) & ~getattr_masks[ctx->version])
- return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in getattr bitfield: ",
- (base16_u64_, GET_U64LE(offsetof_valid) & ~getattr_masks[ctx->version]));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in getattr bitfield: ",
+ (base16_u64_, GET_U64LE(offsetof_valid) & ~getattr_masks[ctx->version])));
if (GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version])
- return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in mode bitfield: ",
- (base16_u32_, GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in mode bitfield: ",
+ (base16_u32_, GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version])));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Tsetattr(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Tsetattr([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Tsetattr);
+ size_t host_size = sizeof(struct lib9p_msg_Tsetattr);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_valid = net_offset + 11;
@@ -1190,64 +1190,64 @@ static ssize_t validate_Tsetattr(struct lib9p_ctx *ctx, uint32_t net_size, uint8
uint32_t offsetof_end = net_offset + 67;
VALIDATE_NET_BYTES(67);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tsetattr->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tsetattr->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 26)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tsetattr->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 26));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tsetattr->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 26)));
if (GET_U32LE(offsetof_valid) & ~setattr_masks[ctx->version])
- return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in setattr bitfield: ",
- (base16_u32_, GET_U32LE(offsetof_valid) & ~setattr_masks[ctx->version]));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in setattr bitfield: ",
+ (base16_u32_, GET_U32LE(offsetof_valid) & ~setattr_masks[ctx->version])));
if (GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version])
- return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in mode bitfield: ",
- (base16_u32_, GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in mode bitfield: ",
+ (base16_u32_, GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version])));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Rsetattr(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rsetattr([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rsetattr);
+ size_t host_size = sizeof(struct lib9p_msg_Rsetattr);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 7;
VALIDATE_NET_BYTES(7);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rsetattr->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rsetattr->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 27)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rsetattr->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 27));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rsetattr->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 27)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Txattrwalk(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Txattrwalk([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Txattrwalk);
+ size_t host_size = sizeof(struct lib9p_msg_Txattrwalk);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
VALIDATE_NET_BYTES(17);
VALIDATE_NET_UTF8(LAST_U16LE());
uint32_t offsetof_end = net_offset + 0;
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Txattrwalk->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Txattrwalk->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 30)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Txattrwalk->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 30));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Txattrwalk->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 30)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Rxattrwalk(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rxattrwalk([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rxattrwalk);
+ size_t host_size = sizeof(struct lib9p_msg_Rxattrwalk);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 15;
VALIDATE_NET_BYTES(15);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rxattrwalk->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rxattrwalk->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 31)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rxattrwalk->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 31));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rxattrwalk->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 31)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Txattrcreate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Txattrcreate([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Txattrcreate);
+ size_t host_size = sizeof(struct lib9p_msg_Txattrcreate);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
VALIDATE_NET_BYTES(13);
@@ -1255,86 +1255,86 @@ static ssize_t validate_Txattrcreate(struct lib9p_ctx *ctx, uint32_t net_size, u
uint32_t offsetof_end = net_offset + 12;
VALIDATE_NET_BYTES(12);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Txattrcreate->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Txattrcreate->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 32)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Txattrcreate->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 32));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Txattrcreate->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 32)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Rxattrcreate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rxattrcreate([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rxattrcreate);
+ size_t host_size = sizeof(struct lib9p_msg_Rxattrcreate);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 7;
VALIDATE_NET_BYTES(7);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rxattrcreate->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rxattrcreate->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 33)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rxattrcreate->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 33));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rxattrcreate->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 33)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Treaddir(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Treaddir([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Treaddir);
+ size_t host_size = sizeof(struct lib9p_msg_Treaddir);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 23;
VALIDATE_NET_BYTES(23);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Treaddir->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Treaddir->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 40)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Treaddir->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 40));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Treaddir->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 40)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Rreaddir(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rreaddir([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rreaddir);
+ size_t host_size = sizeof(struct lib9p_msg_Rreaddir);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
VALIDATE_NET_BYTES(11);
VALIDATE_NET_BYTES(LAST_U32LE());
uint32_t offsetof_end = net_offset + 0;
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rreaddir->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rreaddir->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 41)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rreaddir->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 41));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rreaddir->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 41)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Tfsync(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Tfsync([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Tfsync);
+ size_t host_size = sizeof(struct lib9p_msg_Tfsync);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 15;
VALIDATE_NET_BYTES(15);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tfsync->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tfsync->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 50)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tfsync->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 50));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tfsync->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 50)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Rfsync(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rfsync([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rfsync);
+ size_t host_size = sizeof(struct lib9p_msg_Rfsync);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 7;
VALIDATE_NET_BYTES(7);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rfsync->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rfsync->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 51)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rfsync->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 51));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rfsync->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 51)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Tlock(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Tlock([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Tlock);
+ size_t host_size = sizeof(struct lib9p_msg_Tlock);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_flags = net_offset + 12;
@@ -1342,91 +1342,91 @@ static ssize_t validate_Tlock(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
VALIDATE_NET_UTF8(LAST_U16LE());
uint32_t offsetof_end = net_offset + 0;
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tlock->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tlock->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 52)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tlock->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 52));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tlock->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 52)));
if (GET_U32LE(offsetof_flags) & ~lock_flags_masks[ctx->version])
- return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in lock_flags bitfield: ",
- (base16_u32_, GET_U32LE(offsetof_flags) & ~lock_flags_masks[ctx->version]));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in lock_flags bitfield: ",
+ (base16_u32_, GET_U32LE(offsetof_flags) & ~lock_flags_masks[ctx->version])));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Rlock(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rlock([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rlock);
+ size_t host_size = sizeof(struct lib9p_msg_Rlock);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 8;
VALIDATE_NET_BYTES(8);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rlock->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rlock->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 53)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rlock->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 53));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rlock->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 53)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Tgetlock(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Tgetlock([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Tgetlock);
+ size_t host_size = sizeof(struct lib9p_msg_Tgetlock);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
VALIDATE_NET_BYTES(34);
VALIDATE_NET_UTF8(LAST_U16LE());
uint32_t offsetof_end = net_offset + 0;
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tgetlock->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tgetlock->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 54)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tgetlock->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 54));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tgetlock->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 54)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Rgetlock(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rgetlock([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rgetlock);
+ size_t host_size = sizeof(struct lib9p_msg_Rgetlock);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
VALIDATE_NET_BYTES(30);
VALIDATE_NET_UTF8(LAST_U16LE());
uint32_t offsetof_end = net_offset + 0;
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rgetlock->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rgetlock->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 55)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rgetlock->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 55));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rgetlock->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 55)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Tlink(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Tlink([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Tlink);
+ size_t host_size = sizeof(struct lib9p_msg_Tlink);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
VALIDATE_NET_BYTES(17);
VALIDATE_NET_UTF8(LAST_U16LE());
uint32_t offsetof_end = net_offset + 0;
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tlink->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tlink->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 70)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tlink->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 70));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tlink->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 70)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Rlink(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rlink([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rlink);
+ size_t host_size = sizeof(struct lib9p_msg_Rlink);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 7;
VALIDATE_NET_BYTES(7);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rlink->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rlink->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 71)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rlink->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 71));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rlink->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 71)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Tmkdir(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Tmkdir([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Tmkdir);
+ size_t host_size = sizeof(struct lib9p_msg_Tmkdir);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
VALIDATE_NET_BYTES(13);
@@ -1435,36 +1435,36 @@ static ssize_t validate_Tmkdir(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
uint32_t offsetof_end = net_offset + 8;
VALIDATE_NET_BYTES(8);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tmkdir->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tmkdir->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 72)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tmkdir->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 72));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tmkdir->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 72)));
if (GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version])
- return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in mode bitfield: ",
- (base16_u32_, GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version]));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in mode bitfield: ",
+ (base16_u32_, GET_U32LE(offsetof_mode) & ~mode_masks[ctx->version])));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Rmkdir(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rmkdir([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rmkdir);
+ size_t host_size = sizeof(struct lib9p_msg_Rmkdir);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_qid_type = net_offset + 7;
VALIDATE_NET_BYTES(20);
if (GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])
- return lib9p_error(ctx, E_POSIX_EBADMSG, "unknown bits in qt bitfield: ",
- (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version]));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "unknown bits in qt bitfield: ",
+ (base16_u8_, GET_U8LE(offsetof_qid_type) & ~qt_masks[ctx->version])));
uint32_t offsetof_end = net_offset + 0;
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rmkdir->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rmkdir->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 73)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rmkdir->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 73));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rmkdir->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 73)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Trenameat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Trenameat([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Trenameat);
+ size_t host_size = sizeof(struct lib9p_msg_Trenameat);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
VALIDATE_NET_BYTES(13);
@@ -1473,29 +1473,29 @@ static ssize_t validate_Trenameat(struct lib9p_ctx *ctx, uint32_t net_size, uint
VALIDATE_NET_UTF8(LAST_U16LE());
uint32_t offsetof_end = net_offset + 0;
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Trenameat->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Trenameat->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 74)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Trenameat->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 74));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Trenameat->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 74)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Rrenameat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rrenameat([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rrenameat);
+ size_t host_size = sizeof(struct lib9p_msg_Rrenameat);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 7;
VALIDATE_NET_BYTES(7);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rrenameat->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rrenameat->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 75)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rrenameat->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 75));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rrenameat->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 75)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Tunlinkat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Tunlinkat([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Tunlinkat);
+ size_t host_size = sizeof(struct lib9p_msg_Tunlinkat);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
VALIDATE_NET_BYTES(13);
@@ -1503,59 +1503,59 @@ static ssize_t validate_Tunlinkat(struct lib9p_ctx *ctx, uint32_t net_size, uint
uint32_t offsetof_end = net_offset + 4;
VALIDATE_NET_BYTES(4);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tunlinkat->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tunlinkat->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 76)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tunlinkat->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 76));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tunlinkat->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 76)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Runlinkat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Runlinkat([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Runlinkat);
+ size_t host_size = sizeof(struct lib9p_msg_Runlinkat);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 7;
VALIDATE_NET_BYTES(7);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Runlinkat->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Runlinkat->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 77)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Runlinkat->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 77));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Runlinkat->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 77)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
#endif /* CONFIG_9P_ENABLE_9P2000_L */
#if CONFIG_9P_ENABLE_9P2000_e
-static ssize_t validate_Tsession(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Tsession([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Tsession);
+ size_t host_size = sizeof(struct lib9p_msg_Tsession);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 15;
VALIDATE_NET_BYTES(15);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tsession->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tsession->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 150)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tsession->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 150));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tsession->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 150)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Rsession(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rsession([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rsession);
+ size_t host_size = sizeof(struct lib9p_msg_Rsession);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 7;
VALIDATE_NET_BYTES(7);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rsession->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rsession->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 151)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rsession->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 151));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rsession->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 151)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Tsread(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Tsread([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Tsread);
+ size_t host_size = sizeof(struct lib9p_msg_Tsread);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
VALIDATE_NET_BYTES(13);
@@ -1566,30 +1566,30 @@ static ssize_t validate_Tsread(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t
}
uint32_t offsetof_end = net_offset + 0;
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tsread->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tsread->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 152)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tsread->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 152));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tsread->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 152)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Rsread(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rsread([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rsread);
+ size_t host_size = sizeof(struct lib9p_msg_Rsread);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
VALIDATE_NET_BYTES(11);
VALIDATE_NET_BYTES(LAST_U32LE());
uint32_t offsetof_end = net_offset + 0;
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rsread->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rsread->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 153)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rsread->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 153));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rsread->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 153)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Tswrite(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Tswrite([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Tswrite);
+ size_t host_size = sizeof(struct lib9p_msg_Tswrite);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
VALIDATE_NET_BYTES(13);
@@ -1602,24 +1602,24 @@ static ssize_t validate_Tswrite(struct lib9p_ctx *ctx, uint32_t net_size, uint8_
VALIDATE_NET_BYTES(LAST_U32LE());
uint32_t offsetof_end = net_offset + 0;
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tswrite->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tswrite->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 154)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Tswrite->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 154));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Tswrite->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 154)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
-static ssize_t validate_Rswrite(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
+static size_t_or_error validate_Rswrite([[maybe_unused]] struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes) {
uint32_t net_offset = 0;
- ssize_t host_size = sizeof(struct lib9p_msg_Rswrite);
+ size_t host_size = sizeof(struct lib9p_msg_Rswrite);
uint32_t offsetof_size = net_offset + 0;
uint32_t offsetof_typ = net_offset + 4;
uint32_t offsetof_end = net_offset + 11;
VALIDATE_NET_BYTES(11);
if (GET_U32LE(offsetof_size) != offsetof_end - offsetof_size)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rswrite->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size));
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rswrite->size value is wrong: actual:", (base10, GET_U32LE(offsetof_size)), " != correct:", (base10, offsetof_end - offsetof_size)));
if (GET_U8LE(offsetof_typ) != 155)
- return lib9p_error(ctx, E_POSIX_EBADMSG, "Rswrite->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 155));
- return (ssize_t)host_size;
+ return ERROR_NEW_ERR(size_t, error_new(E_POSIX_EBADMSG, "Rswrite->typ value is wrong: actual:", (base10, GET_U8LE(offsetof_typ)), " != correct:", (base10, 155)));
+ return ERROR_NEW_VAL(size_t, host_size);
}
#endif /* CONFIG_9P_ENABLE_9P2000_e */
@@ -2766,13 +2766,12 @@ static bool marshal_stat(struct lib9p_ctx *ctx, struct lib9p_stat *val, struct _
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized
-static bool marshal_Tversion(struct lib9p_ctx *ctx, struct lib9p_msg_Tversion *val, struct _marshal_ret *ret) {
+static error marshal_Tversion(struct lib9p_ctx *ctx, struct lib9p_msg_Tversion *val, struct _marshal_ret *ret) {
uint32_t needed_size = 13 + val->version.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Tversion message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Tversion message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -2782,16 +2781,15 @@ static bool marshal_Tversion(struct lib9p_ctx *ctx, struct lib9p_msg_Tversion *v
MARSHAL_U32LE(ctx, val->max_msg_size);
MARSHAL_U16LE(ctx, val->version.len);
MARSHAL_BYTES_ZEROCOPY(ctx, val->version.utf8, val->version.len);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Rversion(struct lib9p_ctx *ctx, struct lib9p_msg_Rversion *val, struct _marshal_ret *ret) {
+static error marshal_Rversion(struct lib9p_ctx *ctx, struct lib9p_msg_Rversion *val, struct _marshal_ret *ret) {
uint32_t needed_size = 13 + val->version.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rversion message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rversion message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -2801,12 +2799,12 @@ static bool marshal_Rversion(struct lib9p_ctx *ctx, struct lib9p_msg_Rversion *v
MARSHAL_U32LE(ctx, val->max_msg_size);
MARSHAL_U16LE(ctx, val->version.len);
MARSHAL_BYTES_ZEROCOPY(ctx, val->version.utf8, val->version.len);
- return false;
+ return ERROR_NULL;
}
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
-static bool marshal_Tauth(struct lib9p_ctx *ctx, struct lib9p_msg_Tauth *val, struct _marshal_ret *ret) {
+static error marshal_Tauth(struct lib9p_ctx *ctx, struct lib9p_msg_Tauth *val, struct _marshal_ret *ret) {
uint32_t needed_size = 15 + val->uname.len + val->aname.len;
#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u
if ( is_ver(ctx, 9P2000_L) || is_ver(ctx, 9P2000_u) ) {
@@ -2814,10 +2812,9 @@ static bool marshal_Tauth(struct lib9p_ctx *ctx, struct lib9p_msg_Tauth *val, st
}
#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Tauth message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Tauth message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -2834,16 +2831,15 @@ static bool marshal_Tauth(struct lib9p_ctx *ctx, struct lib9p_msg_Tauth *val, st
MARSHAL_U32LE(ctx, val->unum);
}
#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Rauth(struct lib9p_ctx *ctx, struct lib9p_msg_Rauth *val, struct _marshal_ret *ret) {
+static error marshal_Rauth(struct lib9p_ctx *ctx, struct lib9p_msg_Rauth *val, struct _marshal_ret *ret) {
uint32_t needed_size = 20;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rauth message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rauth message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -2853,10 +2849,10 @@ static bool marshal_Rauth(struct lib9p_ctx *ctx, struct lib9p_msg_Rauth *val, st
MARSHAL_U8LE(ctx, val->aqid.type & qt_masks[ctx->version]);
MARSHAL_U32LE(ctx, val->aqid.vers);
MARSHAL_U64LE(ctx, val->aqid.path);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Tattach(struct lib9p_ctx *ctx, struct lib9p_msg_Tattach *val, struct _marshal_ret *ret) {
+static error marshal_Tattach(struct lib9p_ctx *ctx, struct lib9p_msg_Tattach *val, struct _marshal_ret *ret) {
uint32_t needed_size = 19 + val->uname.len + val->aname.len;
#if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u
if ( is_ver(ctx, 9P2000_L) || is_ver(ctx, 9P2000_u) ) {
@@ -2864,10 +2860,9 @@ static bool marshal_Tattach(struct lib9p_ctx *ctx, struct lib9p_msg_Tattach *val
}
#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Tattach message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Tattach message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -2885,16 +2880,15 @@ static bool marshal_Tattach(struct lib9p_ctx *ctx, struct lib9p_msg_Tattach *val
MARSHAL_U32LE(ctx, val->unum);
}
#endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Rattach(struct lib9p_ctx *ctx, struct lib9p_msg_Rattach *val, struct _marshal_ret *ret) {
+static error marshal_Rattach(struct lib9p_ctx *ctx, struct lib9p_msg_Rattach *val, struct _marshal_ret *ret) {
uint32_t needed_size = 20;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rattach message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rattach message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -2904,12 +2898,12 @@ static bool marshal_Rattach(struct lib9p_ctx *ctx, struct lib9p_msg_Rattach *val
MARSHAL_U8LE(ctx, val->qid.type & qt_masks[ctx->version]);
MARSHAL_U32LE(ctx, val->qid.vers);
MARSHAL_U64LE(ctx, val->qid.path);
- return false;
+ return ERROR_NULL;
}
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized
-static bool marshal_Rerror(struct lib9p_ctx *ctx, struct lib9p_msg_Rerror *val, struct _marshal_ret *ret) {
+static error marshal_Rerror(struct lib9p_ctx *ctx, struct lib9p_msg_Rerror *val, struct _marshal_ret *ret) {
uint32_t needed_size = 9 + val->errstr.len;
#if CONFIG_9P_ENABLE_9P2000_u
if is_ver(ctx, 9P2000_u) {
@@ -2917,10 +2911,9 @@ static bool marshal_Rerror(struct lib9p_ctx *ctx, struct lib9p_msg_Rerror *val,
}
#endif /* CONFIG_9P_ENABLE_9P2000_u */
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rerror message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rerror message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -2934,18 +2927,17 @@ static bool marshal_Rerror(struct lib9p_ctx *ctx, struct lib9p_msg_Rerror *val,
MARSHAL_U32LE(ctx, val->errnum);
}
#endif /* CONFIG_9P_ENABLE_9P2000_u */
- return false;
+ return ERROR_NULL;
}
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
-static bool marshal_Tflush(struct lib9p_ctx *ctx, struct lib9p_msg_Tflush *val, struct _marshal_ret *ret) {
+static error marshal_Tflush(struct lib9p_ctx *ctx, struct lib9p_msg_Tflush *val, struct _marshal_ret *ret) {
uint32_t needed_size = 9;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Tflush message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Tflush message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -2953,35 +2945,33 @@ static bool marshal_Tflush(struct lib9p_ctx *ctx, struct lib9p_msg_Tflush *val,
MARSHAL_U8LE(ctx, 108);
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U16LE(ctx, val->oldtag);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Rflush(struct lib9p_ctx *ctx, struct lib9p_msg_Rflush *val, struct _marshal_ret *ret) {
+static error marshal_Rflush(struct lib9p_ctx *ctx, struct lib9p_msg_Rflush *val, struct _marshal_ret *ret) {
uint32_t needed_size = 7;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rflush message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rflush message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
MARSHAL_U8LE(ctx, 109);
MARSHAL_U16LE(ctx, val->tag);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Twalk(struct lib9p_ctx *ctx, struct lib9p_msg_Twalk *val, struct _marshal_ret *ret) {
+static error marshal_Twalk(struct lib9p_ctx *ctx, struct lib9p_msg_Twalk *val, struct _marshal_ret *ret) {
uint32_t needed_size = 17;
for (uint16_t i = 0; i < val->nwname; i++) {
needed_size += 2 + val->wname[i].len;
}
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Twalk message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Twalk message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -2995,16 +2985,15 @@ static bool marshal_Twalk(struct lib9p_ctx *ctx, struct lib9p_msg_Twalk *val, st
MARSHAL_U16LE(ctx, val->wname[i].len);
MARSHAL_BYTES_ZEROCOPY(ctx, val->wname[i].utf8, val->wname[i].len);
}
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Rwalk(struct lib9p_ctx *ctx, struct lib9p_msg_Rwalk *val, struct _marshal_ret *ret) {
+static error marshal_Rwalk(struct lib9p_ctx *ctx, struct lib9p_msg_Rwalk *val, struct _marshal_ret *ret) {
uint32_t needed_size = 9 + (val->nwqid)*13;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rwalk message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rwalk message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3017,18 +3006,17 @@ static bool marshal_Rwalk(struct lib9p_ctx *ctx, struct lib9p_msg_Rwalk *val, st
MARSHAL_U32LE(ctx, val->wqid[i].vers);
MARSHAL_U64LE(ctx, val->wqid[i].path);
}
- return false;
+ return ERROR_NULL;
}
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
-static bool marshal_Topen(struct lib9p_ctx *ctx, struct lib9p_msg_Topen *val, struct _marshal_ret *ret) {
+static error marshal_Topen(struct lib9p_ctx *ctx, struct lib9p_msg_Topen *val, struct _marshal_ret *ret) {
uint32_t needed_size = 12;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Topen message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Topen message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3037,16 +3025,15 @@ static bool marshal_Topen(struct lib9p_ctx *ctx, struct lib9p_msg_Topen *val, st
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
MARSHAL_U8LE(ctx, val->mode & o_masks[ctx->version]);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Ropen(struct lib9p_ctx *ctx, struct lib9p_msg_Ropen *val, struct _marshal_ret *ret) {
+static error marshal_Ropen(struct lib9p_ctx *ctx, struct lib9p_msg_Ropen *val, struct _marshal_ret *ret) {
uint32_t needed_size = 24;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Ropen message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Ropen message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3057,16 +3044,15 @@ static bool marshal_Ropen(struct lib9p_ctx *ctx, struct lib9p_msg_Ropen *val, st
MARSHAL_U32LE(ctx, val->qid.vers);
MARSHAL_U64LE(ctx, val->qid.path);
MARSHAL_U32LE(ctx, val->iounit);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Tcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Tcreate *val, struct _marshal_ret *ret) {
+static error marshal_Tcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Tcreate *val, struct _marshal_ret *ret) {
uint32_t needed_size = 18 + val->name.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Tcreate message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Tcreate message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3078,16 +3064,15 @@ static bool marshal_Tcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Tcreate *val
MARSHAL_BYTES_ZEROCOPY(ctx, val->name.utf8, val->name.len);
MARSHAL_U32LE(ctx, val->perm & dm_masks[ctx->version]);
MARSHAL_U8LE(ctx, val->mode & o_masks[ctx->version]);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Rcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Rcreate *val, struct _marshal_ret *ret) {
+static error marshal_Rcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Rcreate *val, struct _marshal_ret *ret) {
uint32_t needed_size = 24;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rcreate message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rcreate message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3098,18 +3083,17 @@ static bool marshal_Rcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Rcreate *val
MARSHAL_U32LE(ctx, val->qid.vers);
MARSHAL_U64LE(ctx, val->qid.path);
MARSHAL_U32LE(ctx, val->iounit);
- return false;
+ return ERROR_NULL;
}
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
-static bool marshal_Tread(struct lib9p_ctx *ctx, struct lib9p_msg_Tread *val, struct _marshal_ret *ret) {
+static error marshal_Tread(struct lib9p_ctx *ctx, struct lib9p_msg_Tread *val, struct _marshal_ret *ret) {
uint32_t needed_size = 23;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Tread message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Tread message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3119,16 +3103,15 @@ static bool marshal_Tread(struct lib9p_ctx *ctx, struct lib9p_msg_Tread *val, st
MARSHAL_U32LE(ctx, val->fid);
MARSHAL_U64LE(ctx, val->offset);
MARSHAL_U32LE(ctx, val->count);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Rread(struct lib9p_ctx *ctx, struct lib9p_msg_Rread *val, struct _marshal_ret *ret) {
+static error marshal_Rread(struct lib9p_ctx *ctx, struct lib9p_msg_Rread *val, struct _marshal_ret *ret) {
uint32_t needed_size = 11 + val->count;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rread message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rread message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3137,16 +3120,15 @@ static bool marshal_Rread(struct lib9p_ctx *ctx, struct lib9p_msg_Rread *val, st
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->count);
MARSHAL_BYTES_ZEROCOPY(ctx, val->data, val->count);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Twrite(struct lib9p_ctx *ctx, struct lib9p_msg_Twrite *val, struct _marshal_ret *ret) {
+static error marshal_Twrite(struct lib9p_ctx *ctx, struct lib9p_msg_Twrite *val, struct _marshal_ret *ret) {
uint32_t needed_size = 23 + val->count;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Twrite message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Twrite message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3157,16 +3139,15 @@ static bool marshal_Twrite(struct lib9p_ctx *ctx, struct lib9p_msg_Twrite *val,
MARSHAL_U64LE(ctx, val->offset);
MARSHAL_U32LE(ctx, val->count);
MARSHAL_BYTES_ZEROCOPY(ctx, val->data, val->count);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Rwrite(struct lib9p_ctx *ctx, struct lib9p_msg_Rwrite *val, struct _marshal_ret *ret) {
+static error marshal_Rwrite(struct lib9p_ctx *ctx, struct lib9p_msg_Rwrite *val, struct _marshal_ret *ret) {
uint32_t needed_size = 11;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rwrite message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rwrite message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3174,16 +3155,15 @@ static bool marshal_Rwrite(struct lib9p_ctx *ctx, struct lib9p_msg_Rwrite *val,
MARSHAL_U8LE(ctx, 119);
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->count);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Tclunk(struct lib9p_ctx *ctx, struct lib9p_msg_Tclunk *val, struct _marshal_ret *ret) {
+static error marshal_Tclunk(struct lib9p_ctx *ctx, struct lib9p_msg_Tclunk *val, struct _marshal_ret *ret) {
uint32_t needed_size = 11;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Tclunk message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Tclunk message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3191,32 +3171,30 @@ static bool marshal_Tclunk(struct lib9p_ctx *ctx, struct lib9p_msg_Tclunk *val,
MARSHAL_U8LE(ctx, 120);
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Rclunk(struct lib9p_ctx *ctx, struct lib9p_msg_Rclunk *val, struct _marshal_ret *ret) {
+static error marshal_Rclunk(struct lib9p_ctx *ctx, struct lib9p_msg_Rclunk *val, struct _marshal_ret *ret) {
uint32_t needed_size = 7;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rclunk message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rclunk message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
MARSHAL_U8LE(ctx, 121);
MARSHAL_U16LE(ctx, val->tag);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Tremove(struct lib9p_ctx *ctx, struct lib9p_msg_Tremove *val, struct _marshal_ret *ret) {
+static error marshal_Tremove(struct lib9p_ctx *ctx, struct lib9p_msg_Tremove *val, struct _marshal_ret *ret) {
uint32_t needed_size = 11;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Tremove message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Tremove message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3224,34 +3202,32 @@ static bool marshal_Tremove(struct lib9p_ctx *ctx, struct lib9p_msg_Tremove *val
MARSHAL_U8LE(ctx, 122);
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Rremove(struct lib9p_ctx *ctx, struct lib9p_msg_Rremove *val, struct _marshal_ret *ret) {
+static error marshal_Rremove(struct lib9p_ctx *ctx, struct lib9p_msg_Rremove *val, struct _marshal_ret *ret) {
uint32_t needed_size = 7;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rremove message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rremove message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
MARSHAL_U8LE(ctx, 123);
MARSHAL_U16LE(ctx, val->tag);
- return false;
+ return ERROR_NULL;
}
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
-static bool marshal_Tstat(struct lib9p_ctx *ctx, struct lib9p_msg_Tstat *val, struct _marshal_ret *ret) {
+static error marshal_Tstat(struct lib9p_ctx *ctx, struct lib9p_msg_Tstat *val, struct _marshal_ret *ret) {
uint32_t needed_size = 11;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Tstat message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Tstat message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3259,10 +3235,10 @@ static bool marshal_Tstat(struct lib9p_ctx *ctx, struct lib9p_msg_Tstat *val, st
MARSHAL_U8LE(ctx, 124);
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Rstat(struct lib9p_ctx *ctx, struct lib9p_msg_Rstat *val, struct _marshal_ret *ret) {
+static error marshal_Rstat(struct lib9p_ctx *ctx, struct lib9p_msg_Rstat *val, struct _marshal_ret *ret) {
uint32_t needed_size = 58 + val->stat.name.len + val->stat.owner_uname.len + val->stat.owner_gname.len + val->stat.last_modifier_uname.len;
#if CONFIG_9P_ENABLE_9P2000_u
if is_ver(ctx, 9P2000_u) {
@@ -3270,10 +3246,9 @@ static bool marshal_Rstat(struct lib9p_ctx *ctx, struct lib9p_msg_Rstat *val, st
}
#endif /* CONFIG_9P_ENABLE_9P2000_u */
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rstat message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rstat message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3316,10 +3291,10 @@ static bool marshal_Rstat(struct lib9p_ctx *ctx, struct lib9p_msg_Rstat *val, st
MARSHAL_U32LE(ctx, val->stat.last_modifier_unum);
}
#endif /* CONFIG_9P_ENABLE_9P2000_u */
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Twstat(struct lib9p_ctx *ctx, struct lib9p_msg_Twstat *val, struct _marshal_ret *ret) {
+static error marshal_Twstat(struct lib9p_ctx *ctx, struct lib9p_msg_Twstat *val, struct _marshal_ret *ret) {
uint32_t needed_size = 62 + val->stat.name.len + val->stat.owner_uname.len + val->stat.owner_gname.len + val->stat.last_modifier_uname.len;
#if CONFIG_9P_ENABLE_9P2000_u
if is_ver(ctx, 9P2000_u) {
@@ -3327,10 +3302,9 @@ static bool marshal_Twstat(struct lib9p_ctx *ctx, struct lib9p_msg_Twstat *val,
}
#endif /* CONFIG_9P_ENABLE_9P2000_u */
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Twstat message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Twstat message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3374,34 +3348,32 @@ static bool marshal_Twstat(struct lib9p_ctx *ctx, struct lib9p_msg_Twstat *val,
MARSHAL_U32LE(ctx, val->stat.last_modifier_unum);
}
#endif /* CONFIG_9P_ENABLE_9P2000_u */
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Rwstat(struct lib9p_ctx *ctx, struct lib9p_msg_Rwstat *val, struct _marshal_ret *ret) {
+static error marshal_Rwstat(struct lib9p_ctx *ctx, struct lib9p_msg_Rwstat *val, struct _marshal_ret *ret) {
uint32_t needed_size = 7;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rwstat message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rwstat message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
MARSHAL_U8LE(ctx, 127);
MARSHAL_U16LE(ctx, val->tag);
- return false;
+ return ERROR_NULL;
}
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */
#if CONFIG_9P_ENABLE_9P2000_p9p
-static bool marshal_Topenfd(struct lib9p_ctx *ctx, struct lib9p_msg_Topenfd *val, struct _marshal_ret *ret) {
+static error marshal_Topenfd(struct lib9p_ctx *ctx, struct lib9p_msg_Topenfd *val, struct _marshal_ret *ret) {
uint32_t needed_size = 12;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Topenfd message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Topenfd message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3410,16 +3382,15 @@ static bool marshal_Topenfd(struct lib9p_ctx *ctx, struct lib9p_msg_Topenfd *val
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
MARSHAL_U8LE(ctx, val->mode & o_masks[ctx->version]);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Ropenfd(struct lib9p_ctx *ctx, struct lib9p_msg_Ropenfd *val, struct _marshal_ret *ret) {
+static error marshal_Ropenfd(struct lib9p_ctx *ctx, struct lib9p_msg_Ropenfd *val, struct _marshal_ret *ret) {
uint32_t needed_size = 28;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Ropenfd message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Ropenfd message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3431,18 +3402,17 @@ static bool marshal_Ropenfd(struct lib9p_ctx *ctx, struct lib9p_msg_Ropenfd *val
MARSHAL_U64LE(ctx, val->qid.path);
MARSHAL_U32LE(ctx, val->iounit);
MARSHAL_U32LE(ctx, val->unixfd);
- return false;
+ return ERROR_NULL;
}
#endif /* CONFIG_9P_ENABLE_9P2000_p9p */
#if CONFIG_9P_ENABLE_9P2000_L
-static bool marshal_Rlerror(struct lib9p_ctx *ctx, struct lib9p_msg_Rlerror *val, struct _marshal_ret *ret) {
+static error marshal_Rlerror(struct lib9p_ctx *ctx, struct lib9p_msg_Rlerror *val, struct _marshal_ret *ret) {
uint32_t needed_size = 11;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rlerror message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rlerror message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3450,16 +3420,15 @@ static bool marshal_Rlerror(struct lib9p_ctx *ctx, struct lib9p_msg_Rlerror *val
MARSHAL_U8LE(ctx, 7);
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->errnum);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Tstatfs(struct lib9p_ctx *ctx, struct lib9p_msg_Tstatfs *val, struct _marshal_ret *ret) {
+static error marshal_Tstatfs(struct lib9p_ctx *ctx, struct lib9p_msg_Tstatfs *val, struct _marshal_ret *ret) {
uint32_t needed_size = 11;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Tstatfs message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Tstatfs message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3467,16 +3436,15 @@ static bool marshal_Tstatfs(struct lib9p_ctx *ctx, struct lib9p_msg_Tstatfs *val
MARSHAL_U8LE(ctx, 8);
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Rstatfs(struct lib9p_ctx *ctx, struct lib9p_msg_Rstatfs *val, struct _marshal_ret *ret) {
+static error marshal_Rstatfs(struct lib9p_ctx *ctx, struct lib9p_msg_Rstatfs *val, struct _marshal_ret *ret) {
uint32_t needed_size = 67;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rstatfs message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rstatfs message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3492,16 +3460,15 @@ static bool marshal_Rstatfs(struct lib9p_ctx *ctx, struct lib9p_msg_Rstatfs *val
MARSHAL_U64LE(ctx, val->ffree);
MARSHAL_U64LE(ctx, val->fsid);
MARSHAL_U32LE(ctx, val->namelen);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Tlopen(struct lib9p_ctx *ctx, struct lib9p_msg_Tlopen *val, struct _marshal_ret *ret) {
+static error marshal_Tlopen(struct lib9p_ctx *ctx, struct lib9p_msg_Tlopen *val, struct _marshal_ret *ret) {
uint32_t needed_size = 15;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Tlopen message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Tlopen message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3510,16 +3477,15 @@ static bool marshal_Tlopen(struct lib9p_ctx *ctx, struct lib9p_msg_Tlopen *val,
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
MARSHAL_U32LE(ctx, val->flags & lo_masks[ctx->version]);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Rlopen(struct lib9p_ctx *ctx, struct lib9p_msg_Rlopen *val, struct _marshal_ret *ret) {
+static error marshal_Rlopen(struct lib9p_ctx *ctx, struct lib9p_msg_Rlopen *val, struct _marshal_ret *ret) {
uint32_t needed_size = 24;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rlopen message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rlopen message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3530,16 +3496,15 @@ static bool marshal_Rlopen(struct lib9p_ctx *ctx, struct lib9p_msg_Rlopen *val,
MARSHAL_U32LE(ctx, val->qid.vers);
MARSHAL_U64LE(ctx, val->qid.path);
MARSHAL_U32LE(ctx, val->iounit);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Tlcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Tlcreate *val, struct _marshal_ret *ret) {
+static error marshal_Tlcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Tlcreate *val, struct _marshal_ret *ret) {
uint32_t needed_size = 25 + val->name.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Tlcreate message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Tlcreate message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3552,16 +3517,15 @@ static bool marshal_Tlcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Tlcreate *v
MARSHAL_U32LE(ctx, val->flags & lo_masks[ctx->version]);
MARSHAL_U32LE(ctx, val->mode & mode_masks[ctx->version]);
MARSHAL_U32LE(ctx, val->gid);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Rlcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Rlcreate *val, struct _marshal_ret *ret) {
+static error marshal_Rlcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Rlcreate *val, struct _marshal_ret *ret) {
uint32_t needed_size = 24;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rlcreate message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rlcreate message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3572,16 +3536,15 @@ static bool marshal_Rlcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Rlcreate *v
MARSHAL_U32LE(ctx, val->qid.vers);
MARSHAL_U64LE(ctx, val->qid.path);
MARSHAL_U32LE(ctx, val->iounit);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Tsymlink(struct lib9p_ctx *ctx, struct lib9p_msg_Tsymlink *val, struct _marshal_ret *ret) {
+static error marshal_Tsymlink(struct lib9p_ctx *ctx, struct lib9p_msg_Tsymlink *val, struct _marshal_ret *ret) {
uint32_t needed_size = 19 + val->name.len + val->symtgt.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Tsymlink message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Tsymlink message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3594,16 +3557,15 @@ static bool marshal_Tsymlink(struct lib9p_ctx *ctx, struct lib9p_msg_Tsymlink *v
MARSHAL_U16LE(ctx, val->symtgt.len);
MARSHAL_BYTES_ZEROCOPY(ctx, val->symtgt.utf8, val->symtgt.len);
MARSHAL_U32LE(ctx, val->gid);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Rsymlink(struct lib9p_ctx *ctx, struct lib9p_msg_Rsymlink *val, struct _marshal_ret *ret) {
+static error marshal_Rsymlink(struct lib9p_ctx *ctx, struct lib9p_msg_Rsymlink *val, struct _marshal_ret *ret) {
uint32_t needed_size = 20;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rsymlink message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rsymlink message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3613,16 +3575,15 @@ static bool marshal_Rsymlink(struct lib9p_ctx *ctx, struct lib9p_msg_Rsymlink *v
MARSHAL_U8LE(ctx, val->qid.type & qt_masks[ctx->version]);
MARSHAL_U32LE(ctx, val->qid.vers);
MARSHAL_U64LE(ctx, val->qid.path);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Tmknod(struct lib9p_ctx *ctx, struct lib9p_msg_Tmknod *val, struct _marshal_ret *ret) {
+static error marshal_Tmknod(struct lib9p_ctx *ctx, struct lib9p_msg_Tmknod *val, struct _marshal_ret *ret) {
uint32_t needed_size = 29 + val->name.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Tmknod message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Tmknod message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3636,16 +3597,15 @@ static bool marshal_Tmknod(struct lib9p_ctx *ctx, struct lib9p_msg_Tmknod *val,
MARSHAL_U32LE(ctx, val->major);
MARSHAL_U32LE(ctx, val->minor);
MARSHAL_U32LE(ctx, val->gid);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Rmknod(struct lib9p_ctx *ctx, struct lib9p_msg_Rmknod *val, struct _marshal_ret *ret) {
+static error marshal_Rmknod(struct lib9p_ctx *ctx, struct lib9p_msg_Rmknod *val, struct _marshal_ret *ret) {
uint32_t needed_size = 20;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rmknod message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rmknod message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3655,16 +3615,15 @@ static bool marshal_Rmknod(struct lib9p_ctx *ctx, struct lib9p_msg_Rmknod *val,
MARSHAL_U8LE(ctx, val->qid.type & qt_masks[ctx->version]);
MARSHAL_U32LE(ctx, val->qid.vers);
MARSHAL_U64LE(ctx, val->qid.path);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Trename(struct lib9p_ctx *ctx, struct lib9p_msg_Trename *val, struct _marshal_ret *ret) {
+static error marshal_Trename(struct lib9p_ctx *ctx, struct lib9p_msg_Trename *val, struct _marshal_ret *ret) {
uint32_t needed_size = 17 + val->name.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Trename message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Trename message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3675,32 +3634,30 @@ static bool marshal_Trename(struct lib9p_ctx *ctx, struct lib9p_msg_Trename *val
MARSHAL_U32LE(ctx, val->dfid);
MARSHAL_U16LE(ctx, val->name.len);
MARSHAL_BYTES_ZEROCOPY(ctx, val->name.utf8, val->name.len);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Rrename(struct lib9p_ctx *ctx, struct lib9p_msg_Rrename *val, struct _marshal_ret *ret) {
+static error marshal_Rrename(struct lib9p_ctx *ctx, struct lib9p_msg_Rrename *val, struct _marshal_ret *ret) {
uint32_t needed_size = 7;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rrename message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rrename message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
MARSHAL_U8LE(ctx, 21);
MARSHAL_U16LE(ctx, val->tag);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Treadlink(struct lib9p_ctx *ctx, struct lib9p_msg_Treadlink *val, struct _marshal_ret *ret) {
+static error marshal_Treadlink(struct lib9p_ctx *ctx, struct lib9p_msg_Treadlink *val, struct _marshal_ret *ret) {
uint32_t needed_size = 11;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Treadlink message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Treadlink message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3708,16 +3665,15 @@ static bool marshal_Treadlink(struct lib9p_ctx *ctx, struct lib9p_msg_Treadlink
MARSHAL_U8LE(ctx, 22);
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Rreadlink(struct lib9p_ctx *ctx, struct lib9p_msg_Rreadlink *val, struct _marshal_ret *ret) {
+static error marshal_Rreadlink(struct lib9p_ctx *ctx, struct lib9p_msg_Rreadlink *val, struct _marshal_ret *ret) {
uint32_t needed_size = 9 + val->target.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rreadlink message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rreadlink message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3726,16 +3682,15 @@ static bool marshal_Rreadlink(struct lib9p_ctx *ctx, struct lib9p_msg_Rreadlink
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U16LE(ctx, val->target.len);
MARSHAL_BYTES_ZEROCOPY(ctx, val->target.utf8, val->target.len);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Tgetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Tgetattr *val, struct _marshal_ret *ret) {
+static error marshal_Tgetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Tgetattr *val, struct _marshal_ret *ret) {
uint32_t needed_size = 19;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Tgetattr message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Tgetattr message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3744,16 +3699,15 @@ static bool marshal_Tgetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Tgetattr *v
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
MARSHAL_U64LE(ctx, val->request_mask & getattr_masks[ctx->version]);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Rgetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Rgetattr *val, struct _marshal_ret *ret) {
+static error marshal_Rgetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Rgetattr *val, struct _marshal_ret *ret) {
uint32_t needed_size = 160;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rgetattr message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rgetattr message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3782,16 +3736,15 @@ static bool marshal_Rgetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Rgetattr *v
MARSHAL_U64LE(ctx, val->btime_nsec);
MARSHAL_U64LE(ctx, val->gen);
MARSHAL_U64LE(ctx, val->data_version);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Tsetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Tsetattr *val, struct _marshal_ret *ret) {
+static error marshal_Tsetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Tsetattr *val, struct _marshal_ret *ret) {
uint32_t needed_size = 67;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Tsetattr message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Tsetattr message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3808,32 +3761,30 @@ static bool marshal_Tsetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Tsetattr *v
MARSHAL_U64LE(ctx, val->atime_nsec);
MARSHAL_U64LE(ctx, val->mtime_sec);
MARSHAL_U64LE(ctx, val->mtime_nsec);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Rsetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Rsetattr *val, struct _marshal_ret *ret) {
+static error marshal_Rsetattr(struct lib9p_ctx *ctx, struct lib9p_msg_Rsetattr *val, struct _marshal_ret *ret) {
uint32_t needed_size = 7;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rsetattr message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rsetattr message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
MARSHAL_U8LE(ctx, 27);
MARSHAL_U16LE(ctx, val->tag);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Txattrwalk(struct lib9p_ctx *ctx, struct lib9p_msg_Txattrwalk *val, struct _marshal_ret *ret) {
+static error marshal_Txattrwalk(struct lib9p_ctx *ctx, struct lib9p_msg_Txattrwalk *val, struct _marshal_ret *ret) {
uint32_t needed_size = 17 + val->name.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Txattrwalk message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Txattrwalk message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3844,16 +3795,15 @@ static bool marshal_Txattrwalk(struct lib9p_ctx *ctx, struct lib9p_msg_Txattrwal
MARSHAL_U32LE(ctx, val->newfid);
MARSHAL_U16LE(ctx, val->name.len);
MARSHAL_BYTES_ZEROCOPY(ctx, val->name.utf8, val->name.len);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Rxattrwalk(struct lib9p_ctx *ctx, struct lib9p_msg_Rxattrwalk *val, struct _marshal_ret *ret) {
+static error marshal_Rxattrwalk(struct lib9p_ctx *ctx, struct lib9p_msg_Rxattrwalk *val, struct _marshal_ret *ret) {
uint32_t needed_size = 15;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rxattrwalk message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rxattrwalk message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3861,16 +3811,15 @@ static bool marshal_Rxattrwalk(struct lib9p_ctx *ctx, struct lib9p_msg_Rxattrwal
MARSHAL_U8LE(ctx, 31);
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U64LE(ctx, val->attr_size);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Txattrcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Txattrcreate *val, struct _marshal_ret *ret) {
+static error marshal_Txattrcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Txattrcreate *val, struct _marshal_ret *ret) {
uint32_t needed_size = 25 + val->name.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Txattrcreate message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Txattrcreate message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3882,32 +3831,30 @@ static bool marshal_Txattrcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Txattrc
MARSHAL_BYTES_ZEROCOPY(ctx, val->name.utf8, val->name.len);
MARSHAL_U64LE(ctx, val->attr_size);
MARSHAL_U32LE(ctx, val->flags);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Rxattrcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Rxattrcreate *val, struct _marshal_ret *ret) {
+static error marshal_Rxattrcreate(struct lib9p_ctx *ctx, struct lib9p_msg_Rxattrcreate *val, struct _marshal_ret *ret) {
uint32_t needed_size = 7;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rxattrcreate message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rxattrcreate message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
MARSHAL_U8LE(ctx, 33);
MARSHAL_U16LE(ctx, val->tag);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Treaddir(struct lib9p_ctx *ctx, struct lib9p_msg_Treaddir *val, struct _marshal_ret *ret) {
+static error marshal_Treaddir(struct lib9p_ctx *ctx, struct lib9p_msg_Treaddir *val, struct _marshal_ret *ret) {
uint32_t needed_size = 23;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Treaddir message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Treaddir message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3917,16 +3864,15 @@ static bool marshal_Treaddir(struct lib9p_ctx *ctx, struct lib9p_msg_Treaddir *v
MARSHAL_U32LE(ctx, val->fid);
MARSHAL_U64LE(ctx, val->offset);
MARSHAL_U32LE(ctx, val->count);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Rreaddir(struct lib9p_ctx *ctx, struct lib9p_msg_Rreaddir *val, struct _marshal_ret *ret) {
+static error marshal_Rreaddir(struct lib9p_ctx *ctx, struct lib9p_msg_Rreaddir *val, struct _marshal_ret *ret) {
uint64_t needed_size = 11 + val->count;
if (needed_size > (uint64_t)(ctx->max_msg_size)) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rreaddir message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rreaddir message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = (uint32_t)needed_size;
uint32_t offsetof_size = 0;
@@ -3935,16 +3881,15 @@ static bool marshal_Rreaddir(struct lib9p_ctx *ctx, struct lib9p_msg_Rreaddir *v
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->count);
MARSHAL_BYTES_ZEROCOPY(ctx, val->data, val->count);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Tfsync(struct lib9p_ctx *ctx, struct lib9p_msg_Tfsync *val, struct _marshal_ret *ret) {
+static error marshal_Tfsync(struct lib9p_ctx *ctx, struct lib9p_msg_Tfsync *val, struct _marshal_ret *ret) {
uint32_t needed_size = 15;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Tfsync message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Tfsync message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3953,32 +3898,30 @@ static bool marshal_Tfsync(struct lib9p_ctx *ctx, struct lib9p_msg_Tfsync *val,
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->fid);
MARSHAL_U32LE(ctx, val->datasync);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Rfsync(struct lib9p_ctx *ctx, struct lib9p_msg_Rfsync *val, struct _marshal_ret *ret) {
+static error marshal_Rfsync(struct lib9p_ctx *ctx, struct lib9p_msg_Rfsync *val, struct _marshal_ret *ret) {
uint32_t needed_size = 7;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rfsync message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rfsync message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
MARSHAL_U8LE(ctx, 51);
MARSHAL_U16LE(ctx, val->tag);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Tlock(struct lib9p_ctx *ctx, struct lib9p_msg_Tlock *val, struct _marshal_ret *ret) {
+static error marshal_Tlock(struct lib9p_ctx *ctx, struct lib9p_msg_Tlock *val, struct _marshal_ret *ret) {
uint32_t needed_size = 38 + val->client_id.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Tlock message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Tlock message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -3993,16 +3936,15 @@ static bool marshal_Tlock(struct lib9p_ctx *ctx, struct lib9p_msg_Tlock *val, st
MARSHAL_U32LE(ctx, val->proc_id);
MARSHAL_U16LE(ctx, val->client_id.len);
MARSHAL_BYTES_ZEROCOPY(ctx, val->client_id.utf8, val->client_id.len);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Rlock(struct lib9p_ctx *ctx, struct lib9p_msg_Rlock *val, struct _marshal_ret *ret) {
+static error marshal_Rlock(struct lib9p_ctx *ctx, struct lib9p_msg_Rlock *val, struct _marshal_ret *ret) {
uint32_t needed_size = 8;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rlock message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rlock message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -4010,16 +3952,15 @@ static bool marshal_Rlock(struct lib9p_ctx *ctx, struct lib9p_msg_Rlock *val, st
MARSHAL_U8LE(ctx, 53);
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U8LE(ctx, val->status);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Tgetlock(struct lib9p_ctx *ctx, struct lib9p_msg_Tgetlock *val, struct _marshal_ret *ret) {
+static error marshal_Tgetlock(struct lib9p_ctx *ctx, struct lib9p_msg_Tgetlock *val, struct _marshal_ret *ret) {
uint32_t needed_size = 34 + val->client_id.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Tgetlock message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Tgetlock message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -4033,16 +3974,15 @@ static bool marshal_Tgetlock(struct lib9p_ctx *ctx, struct lib9p_msg_Tgetlock *v
MARSHAL_U32LE(ctx, val->proc_id);
MARSHAL_U16LE(ctx, val->client_id.len);
MARSHAL_BYTES_ZEROCOPY(ctx, val->client_id.utf8, val->client_id.len);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Rgetlock(struct lib9p_ctx *ctx, struct lib9p_msg_Rgetlock *val, struct _marshal_ret *ret) {
+static error marshal_Rgetlock(struct lib9p_ctx *ctx, struct lib9p_msg_Rgetlock *val, struct _marshal_ret *ret) {
uint32_t needed_size = 30 + val->client_id.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rgetlock message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rgetlock message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -4055,16 +3995,15 @@ static bool marshal_Rgetlock(struct lib9p_ctx *ctx, struct lib9p_msg_Rgetlock *v
MARSHAL_U32LE(ctx, val->proc_id);
MARSHAL_U16LE(ctx, val->client_id.len);
MARSHAL_BYTES_ZEROCOPY(ctx, val->client_id.utf8, val->client_id.len);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Tlink(struct lib9p_ctx *ctx, struct lib9p_msg_Tlink *val, struct _marshal_ret *ret) {
+static error marshal_Tlink(struct lib9p_ctx *ctx, struct lib9p_msg_Tlink *val, struct _marshal_ret *ret) {
uint32_t needed_size = 17 + val->name.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Tlink message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Tlink message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -4075,32 +4014,30 @@ static bool marshal_Tlink(struct lib9p_ctx *ctx, struct lib9p_msg_Tlink *val, st
MARSHAL_U32LE(ctx, val->fid);
MARSHAL_U16LE(ctx, val->name.len);
MARSHAL_BYTES_ZEROCOPY(ctx, val->name.utf8, val->name.len);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Rlink(struct lib9p_ctx *ctx, struct lib9p_msg_Rlink *val, struct _marshal_ret *ret) {
+static error marshal_Rlink(struct lib9p_ctx *ctx, struct lib9p_msg_Rlink *val, struct _marshal_ret *ret) {
uint32_t needed_size = 7;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rlink message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rlink message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
MARSHAL_U8LE(ctx, 71);
MARSHAL_U16LE(ctx, val->tag);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Tmkdir(struct lib9p_ctx *ctx, struct lib9p_msg_Tmkdir *val, struct _marshal_ret *ret) {
+static error marshal_Tmkdir(struct lib9p_ctx *ctx, struct lib9p_msg_Tmkdir *val, struct _marshal_ret *ret) {
uint32_t needed_size = 21 + val->name.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Tmkdir message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Tmkdir message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -4112,16 +4049,15 @@ static bool marshal_Tmkdir(struct lib9p_ctx *ctx, struct lib9p_msg_Tmkdir *val,
MARSHAL_BYTES_ZEROCOPY(ctx, val->name.utf8, val->name.len);
MARSHAL_U32LE(ctx, val->mode & mode_masks[ctx->version]);
MARSHAL_U32LE(ctx, val->gid);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Rmkdir(struct lib9p_ctx *ctx, struct lib9p_msg_Rmkdir *val, struct _marshal_ret *ret) {
+static error marshal_Rmkdir(struct lib9p_ctx *ctx, struct lib9p_msg_Rmkdir *val, struct _marshal_ret *ret) {
uint32_t needed_size = 20;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rmkdir message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rmkdir message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -4131,16 +4067,15 @@ static bool marshal_Rmkdir(struct lib9p_ctx *ctx, struct lib9p_msg_Rmkdir *val,
MARSHAL_U8LE(ctx, val->qid.type & qt_masks[ctx->version]);
MARSHAL_U32LE(ctx, val->qid.vers);
MARSHAL_U64LE(ctx, val->qid.path);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Trenameat(struct lib9p_ctx *ctx, struct lib9p_msg_Trenameat *val, struct _marshal_ret *ret) {
+static error marshal_Trenameat(struct lib9p_ctx *ctx, struct lib9p_msg_Trenameat *val, struct _marshal_ret *ret) {
uint32_t needed_size = 19 + val->oldname.len + val->newname.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Trenameat message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Trenameat message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -4153,32 +4088,30 @@ static bool marshal_Trenameat(struct lib9p_ctx *ctx, struct lib9p_msg_Trenameat
MARSHAL_U32LE(ctx, val->newdirfid);
MARSHAL_U16LE(ctx, val->newname.len);
MARSHAL_BYTES_ZEROCOPY(ctx, val->newname.utf8, val->newname.len);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Rrenameat(struct lib9p_ctx *ctx, struct lib9p_msg_Rrenameat *val, struct _marshal_ret *ret) {
+static error marshal_Rrenameat(struct lib9p_ctx *ctx, struct lib9p_msg_Rrenameat *val, struct _marshal_ret *ret) {
uint32_t needed_size = 7;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rrenameat message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rrenameat message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
MARSHAL_U8LE(ctx, 75);
MARSHAL_U16LE(ctx, val->tag);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Tunlinkat(struct lib9p_ctx *ctx, struct lib9p_msg_Tunlinkat *val, struct _marshal_ret *ret) {
+static error marshal_Tunlinkat(struct lib9p_ctx *ctx, struct lib9p_msg_Tunlinkat *val, struct _marshal_ret *ret) {
uint32_t needed_size = 17 + val->name.len;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Tunlinkat message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Tunlinkat message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -4189,34 +4122,32 @@ static bool marshal_Tunlinkat(struct lib9p_ctx *ctx, struct lib9p_msg_Tunlinkat
MARSHAL_U16LE(ctx, val->name.len);
MARSHAL_BYTES_ZEROCOPY(ctx, val->name.utf8, val->name.len);
MARSHAL_U32LE(ctx, val->flags);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Runlinkat(struct lib9p_ctx *ctx, struct lib9p_msg_Runlinkat *val, struct _marshal_ret *ret) {
+static error marshal_Runlinkat(struct lib9p_ctx *ctx, struct lib9p_msg_Runlinkat *val, struct _marshal_ret *ret) {
uint32_t needed_size = 7;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Runlinkat message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Runlinkat message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
MARSHAL_U8LE(ctx, 77);
MARSHAL_U16LE(ctx, val->tag);
- return false;
+ return ERROR_NULL;
}
#endif /* CONFIG_9P_ENABLE_9P2000_L */
#if CONFIG_9P_ENABLE_9P2000_e
-static bool marshal_Tsession(struct lib9p_ctx *ctx, struct lib9p_msg_Tsession *val, struct _marshal_ret *ret) {
+static error marshal_Tsession(struct lib9p_ctx *ctx, struct lib9p_msg_Tsession *val, struct _marshal_ret *ret) {
uint32_t needed_size = 15;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Tsession message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Tsession message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -4224,35 +4155,33 @@ static bool marshal_Tsession(struct lib9p_ctx *ctx, struct lib9p_msg_Tsession *v
MARSHAL_U8LE(ctx, 150);
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U64LE(ctx, val->key);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Rsession(struct lib9p_ctx *ctx, struct lib9p_msg_Rsession *val, struct _marshal_ret *ret) {
+static error marshal_Rsession(struct lib9p_ctx *ctx, struct lib9p_msg_Rsession *val, struct _marshal_ret *ret) {
uint32_t needed_size = 7;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rsession message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rsession message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
MARSHAL_U32LE(ctx, offsetof_end - offsetof_size);
MARSHAL_U8LE(ctx, 151);
MARSHAL_U16LE(ctx, val->tag);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Tsread(struct lib9p_ctx *ctx, struct lib9p_msg_Tsread *val, struct _marshal_ret *ret) {
+static error marshal_Tsread(struct lib9p_ctx *ctx, struct lib9p_msg_Tsread *val, struct _marshal_ret *ret) {
uint64_t needed_size = 13;
for (uint16_t i = 0; i < val->nwname; i++) {
needed_size += 2 + val->wname[i].len;
}
if (needed_size > (uint64_t)(ctx->max_msg_size)) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Tsread message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Tsread message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = (uint32_t)needed_size;
uint32_t offsetof_size = 0;
@@ -4265,16 +4194,15 @@ static bool marshal_Tsread(struct lib9p_ctx *ctx, struct lib9p_msg_Tsread *val,
MARSHAL_U16LE(ctx, val->wname[i].len);
MARSHAL_BYTES_ZEROCOPY(ctx, val->wname[i].utf8, val->wname[i].len);
}
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Rsread(struct lib9p_ctx *ctx, struct lib9p_msg_Rsread *val, struct _marshal_ret *ret) {
+static error marshal_Rsread(struct lib9p_ctx *ctx, struct lib9p_msg_Rsread *val, struct _marshal_ret *ret) {
uint64_t needed_size = 11 + val->count;
if (needed_size > (uint64_t)(ctx->max_msg_size)) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rsread message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rsread message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = (uint32_t)needed_size;
uint32_t offsetof_size = 0;
@@ -4283,19 +4211,18 @@ static bool marshal_Rsread(struct lib9p_ctx *ctx, struct lib9p_msg_Rsread *val,
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->count);
MARSHAL_BYTES_ZEROCOPY(ctx, val->data, val->count);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Tswrite(struct lib9p_ctx *ctx, struct lib9p_msg_Tswrite *val, struct _marshal_ret *ret) {
+static error marshal_Tswrite(struct lib9p_ctx *ctx, struct lib9p_msg_Tswrite *val, struct _marshal_ret *ret) {
uint64_t needed_size = 17 + val->count;
for (uint16_t i = 0; i < val->nwname; i++) {
needed_size += 2 + val->wname[i].len;
}
if (needed_size > (uint64_t)(ctx->max_msg_size)) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Tswrite message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Tswrite message too large to marshal into ",
ctx->version ? "negotiated" : "client", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = (uint32_t)needed_size;
uint32_t offsetof_size = 0;
@@ -4310,16 +4237,15 @@ static bool marshal_Tswrite(struct lib9p_ctx *ctx, struct lib9p_msg_Tswrite *val
}
MARSHAL_U32LE(ctx, val->count);
MARSHAL_BYTES_ZEROCOPY(ctx, val->data, val->count);
- return false;
+ return ERROR_NULL;
}
-static bool marshal_Rswrite(struct lib9p_ctx *ctx, struct lib9p_msg_Rswrite *val, struct _marshal_ret *ret) {
+static error marshal_Rswrite(struct lib9p_ctx *ctx, struct lib9p_msg_Rswrite *val, struct _marshal_ret *ret) {
uint32_t needed_size = 11;
if (needed_size > ctx->max_msg_size) {
- lib9p_error(ctx, E_POSIX_ERANGE, "Rswrite message too large to marshal into ",
+ return error_new(E_POSIX_ERANGE, "Rswrite message too large to marshal into ",
ctx->version ? "negotiated" : "server", " limit",
" (", needed_size, " > ", ctx->max_msg_size, ")");
- return true;
}
uint32_t offsetof_end = needed_size;
uint32_t offsetof_size = 0;
@@ -4327,7 +4253,7 @@ static bool marshal_Rswrite(struct lib9p_ctx *ctx, struct lib9p_msg_Rswrite *val
MARSHAL_U8LE(ctx, 155);
MARSHAL_U16LE(ctx, val->tag);
MARSHAL_U32LE(ctx, val->count);
- return false;
+ return ERROR_NULL;
}
#endif /* CONFIG_9P_ENABLE_9P2000_e */
@@ -8177,7 +8103,7 @@ const struct _lib9p_send_tentry _lib9p_table_Rmsg_send[LIB9P_VER_NUM][0x80] = {
};
#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u
-LM_FLATTEN ssize_t _lib9p_stat_validate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes, uint32_t *ret_net_size) {
+LM_FLATTEN size_t_or_error _lib9p_stat_validate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes, uint32_t *ret_net_size) {
return validate_stat(ctx, net_size, net_bytes, ret_net_size);
}
LM_FLATTEN void _lib9p_stat_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out) {
diff --git a/lib9p/core_include/lib9p/core.h b/lib9p/core_include/lib9p/core.h
index 7bee2f1..9d92312 100644
--- a/lib9p/core_include/lib9p/core.h
+++ b/lib9p/core_include/lib9p/core.h
@@ -20,11 +20,6 @@
#include <lib9p/_core_generated.h> /* _after_ other includes, including config.h */
-#ifndef CONFIG_9P_MAX_ERR_SIZE
- #error config.h must define CONFIG_9P_MAX_ERR_SIZE
-#endif
-static_assert(CONFIG_9P_MAX_ERR_SIZE <= UINT16_MAX);
-
/* constants ******************************************************************/
enum {
@@ -49,32 +44,8 @@ struct lib9p_ctx {
/* negotiated */
enum lib9p_version version;
uint32_t max_msg_size;
-
- /* state */
- _errnum err_num;
- [[gnu::nonstring]] char err_msg[CONFIG_9P_MAX_ERR_SIZE];
};
-void lib9p_ctx_clear_error(struct lib9p_ctx *ctx);
-
-bool lib9p_ctx_has_error(struct lib9p_ctx *ctx);
-
-/** Write a <libmisc/fmt.h>-style error into ctx, return -1. */
-#define lib9p_error(ctx, libmisc_errno, ...) ({ \
- if (!lib9p_ctx_has_error(ctx)) { \
- (ctx)->err_num = libmisc_errno; \
- struct fmt_buf _w = { \
- .dat = (ctx)->err_msg, \
- .cap = sizeof((ctx)->err_msg), \
- }; \
- lo_interface fmt_dest w = LO_BOX(fmt_dest, &_w); \
- fmt_print(w, __VA_ARGS__); \
- if (_w.len < _w.cap) \
- memset(_w.dat + _w.len, 0, _w.cap - _w.len); \
- } \
- -1; \
-})
-
/* misc utilities *************************************************************/
uint32_t lib9p_version_min_Rerror_size(enum lib9p_version);
@@ -92,10 +63,10 @@ void fmt_print_lib9p_msg(lo_interface fmt_dest w, struct lib9p_ctx *ctx, enum li
* number may be larger than net_bytes due to (1) struct padding, (2)
* array pointers.
*
- * @param ctx : negotiated protocol parameters, where to record errors
+ * @param ctx : negotiated protocol parameters
* @param net_bytes : the complete request, starting with the "size[4]"
*
- * @return required size, or -1 on error
+ * @return required size, or an error
*
* @errno E_POSIX_EOPNOTSUPP: message is an R-message
* @errno E_POSIX_EOPNOTSUPP: message has unknown type
@@ -104,7 +75,7 @@ void fmt_print_lib9p_msg(lo_interface fmt_dest w, struct lib9p_ctx *ctx, enum li
* @errno E_POSIX_EBADMSG: message contains a bitfield with unknown bits
* @errno E_POSIX_EMSGSIZE: would-be return value overflows SSIZE_MAX
*/
-ssize_t lib9p_Tmsg_validate(struct lib9p_ctx *ctx, uint8_t *net_bytes);
+size_t_or_error lib9p_Tmsg_validate(struct lib9p_ctx *ctx, uint8_t *net_bytes);
/**
* Unmarshal the 9P message `net_bytes` into the C struct `ret_body`.
@@ -130,27 +101,27 @@ void lib9p_Tmsg_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes,
* marshal bitfield bits that aren't in ctx->version; it applies a
* version-specific mask to bitfields.
*
- * @param ctx : negotiated protocol parameters, where to record errors
+ * @param ctx : negotiated protocol parameters
* @param typ : the message type
* @param msg : the message to encode (`struct lib9p_msg_XXXX` according to `typ`)
*
* @return ret : the buffer to encode to
- * @return whether there was an error (false=success, true=error)
+ * @return error
*
* @errno E_POSIX_ERANGE: reply does not fit in ctx->max_msg_size
*/
-bool lib9p_Tmsg_marshal(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body,
- struct lib9p_Tmsg_send_buf *ret);
+error lib9p_Tmsg_marshal(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body,
+ struct lib9p_Tmsg_send_buf *ret);
/* main R-message functions ***************************************************/
/** Same as above, but for R-messages instead of T-messages. */
-ssize_t lib9p_Rmsg_validate(struct lib9p_ctx *ctx, uint8_t *net_bytes);
+size_t_or_error lib9p_Rmsg_validate(struct lib9p_ctx *ctx, uint8_t *net_bytes);
void lib9p_Rmsg_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes,
enum lib9p_msg_type *ret_typ, void *ret_body);
-bool lib9p_Rmsg_marshal(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body,
- struct lib9p_Rmsg_send_buf *ret);
+error lib9p_Rmsg_marshal(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body,
+ struct lib9p_Rmsg_send_buf *ret);
/* `struct lib9p_stat` helpers ************************************************/
@@ -162,16 +133,16 @@ void fmt_print_lib9p_stat(lo_interface fmt_dest w, struct lib9p_ctx *ctx, struct
/**
* Validate a message's `stat` structure.
*
- * @param ctx : negotiated protocol parameters, where to record errors
+ * @param ctx : negotiated protocol parameters
* @param net_bytes : network-encoded stat structure
* @param net_size : the number of net_bytes that may be read
*
* @return ret_net_size : number of bytes consumed; <=net_size
* @return ret_host_size : number of bytes that lib9p_stat_unmarshal would take
- * @return whether there was an error
+ * @return error
*/
-bool lib9p_stat_validate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes,
- uint32_t *ret_net_size, size_t *ret_host_size);
+error lib9p_stat_validate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes,
+ uint32_t *ret_net_size, size_t *ret_host_size);
/**
* Unmarshal the 9P `net_bytes` into the C struct `ret_obj`.
diff --git a/lib9p/core_tables.h b/lib9p/core_tables.h
index e3dc8f4..8f8c8d6 100644
--- a/lib9p/core_tables.h
+++ b/lib9p/core_tables.h
@@ -27,7 +27,7 @@ struct _lib9p_msg_tentry {
_print_fn_t print;
};
-typedef ssize_t (*_validate_fn_t)(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes);
+typedef size_t_or_error (*_validate_fn_t)(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes);
typedef void (*_unmarshal_fn_t)(struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out);
struct _lib9p_recv_tentry {
_validate_fn_t validate;
@@ -40,7 +40,7 @@ struct _marshal_ret {
size_t net_copied_size;
uint8_t *net_copied;
};
-typedef bool (*_marshal_fn_t)(struct lib9p_ctx *ctx, void *host_val, struct _marshal_ret *ret);
+typedef error (*_marshal_fn_t)(struct lib9p_ctx *ctx, void *host_val, struct _marshal_ret *ret);
struct _lib9p_send_tentry {
_marshal_fn_t marshal;
};
@@ -54,7 +54,7 @@ extern const struct _lib9p_send_tentry _lib9p_table_Rmsg_send[LIB9P_VER_NUM][0x8
/* stat ***********************************************************************/
#if _LIB9P_ENABLE_stat
-ssize_t _lib9p_stat_validate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes, uint32_t *ret_net_size);
+size_t_or_error _lib9p_stat_validate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes, uint32_t *ret_net_size);
void _lib9p_stat_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out);
bool _lib9p_stat_marshal(struct lib9p_ctx *ctx, struct lib9p_stat *val, struct _marshal_ret *ret);
#endif
diff --git a/lib9p/srv.c b/lib9p/srv.c
index d29479f..917b41e 100644
--- a/lib9p/srv.c
+++ b/lib9p/srv.c
@@ -44,6 +44,17 @@ static_assert(CONFIG_9P_SRV_MAX_HOSTMSG_SIZE <= SSIZE_MAX);
/* context ********************************************************************/
+void lib9p_ctx_clear_error(struct lib9p_srv_ctx *ctx) {
+ assert(ctx);
+ ctx->err_num = 0;
+ ctx->err_msg[0] = '\0';
+}
+
+bool lib9p_ctx_has_error(struct lib9p_srv_ctx *ctx) {
+ assert(ctx);
+ return ctx->err_msg[0];
+}
+
bool lib9p_srv_flush_requested(struct lib9p_srv_ctx *ctx) {
assert(ctx);
return cr_chan_can_send(&ctx->flush_ch);
@@ -343,8 +354,7 @@ static inline struct srv_fidinfo *srv_fid_store(struct srv_req *ctx, lib9p_fid_t
srv_path_decref(ctx, old_fidinfo->path);
map_del(&ctx->parent_sess->fids, fid);
} else {
- lib9p_error(&ctx->basectx,
- E_POSIX_EBADF, "FID already in use");
+ lib9p_error(ctx, E_POSIX_EBADF, "FID already in use");
return NULL;
}
}
@@ -381,16 +391,16 @@ static void srv_write_Rmsg(struct srv_req *req, struct lib9p_Rmsg_send_buf *resp
static void srv_respond_error(struct srv_req *req) {
#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L
- assert(req->basectx.err_num);
+ assert(req->err_num);
#endif
- assert(req->basectx.err_msg[0]);
+ assert(req->err_msg[0]);
struct lib9p_msg_Rerror host = {
.tag = req->tag,
- .errstr = lib9p_strn(req->basectx.err_msg,
- CONFIG_9P_MAX_ERR_SIZE),
+ .errstr = lib9p_strn(req->err_msg,
+ CONFIG_9P_SRV_MAX_ERR_SIZE),
#if CONFIG_9P_ENABLE_9P2000_u
- .errnum = libmisc_to_linuxgeneric_errno(req->basectx.err_num),
+ .errnum = libmisc_to_linuxgeneric_errno(req->err_num),
#endif
};
@@ -499,7 +509,7 @@ void lib9p_srv_read(struct lib9p_srv *srv, lo_interface net_stream_conn _conn) {
.net_bytes = buf,
};
if (goal > sess.max_msg_size) {
- lib9p_error(&req.basectx, E_POSIX_EMSGSIZE,
+ lib9p_error(&req, E_POSIX_EMSGSIZE,
"T-message larger than ", sess.initialized ? "negotiated" : "server", " limit",
" (", goal, " > ", sess.max_msg_size, ")");
srv_respond_error(&req);
@@ -555,9 +565,9 @@ void lib9p_srv_read(struct lib9p_srv *srv, lo_interface net_stream_conn _conn) {
};
MAP_FOREACH(&sess.fids, fid, fidinfo) {
srv_fid_del(&pseudoreq, fid, fidinfo, false);
- if (lib9p_ctx_has_error(&pseudoreq.basectx)) {
- srv_nonrespond_error("clunk: ", (strn, pseudoreq.basectx.err_msg, CONFIG_9P_MAX_ERR_SIZE));
- lib9p_ctx_clear_error(&pseudoreq.basectx);
+ if (lib9p_ctx_has_error(&pseudoreq)) {
+ srv_nonrespond_error("clunk: ", (strn, pseudoreq.err_msg, CONFIG_9P_SRV_MAX_ERR_SIZE));
+ lib9p_ctx_clear_error(&pseudoreq);
}
}
map_free(&sess.fids);
@@ -631,11 +641,14 @@ void lib9p_srv_worker(struct srv_req *ctx) {
uint8_t *host_req = NULL;
/* Unmarshal it. *****************************************************/
- ssize_t host_size = lib9p_Tmsg_validate(&ctx->basectx, ctx->net_bytes);
- if (host_size < 0) {
+ size_t_or_error r = lib9p_Tmsg_validate(&ctx->basectx, ctx->net_bytes);
+ if (r.is_err) {
+ lib9p_error(ctx, r.err.num, (error, r.err));
+ error_cleanup(&r.err);
srv_respond_error(ctx);
goto release;
}
+ size_t host_size = r.size_t;
host_req = calloc(1, host_size);
assert(host_req);
enum lib9p_msg_type typ;
@@ -693,7 +706,7 @@ void lib9p_srv_worker(struct srv_req *ctx) {
static inline void _srv_respond(struct srv_req *ctx, enum lib9p_msg_type resp_typ, void *host_resp) {
assert(!ctx->responded);
- if (lib9p_ctx_has_error(&ctx->basectx)) {
+ if (lib9p_ctx_has_error(ctx)) {
error:
srv_respond_error(ctx);
} else if (ctx->flush_acknowledged) {
@@ -701,10 +714,14 @@ static inline void _srv_respond(struct srv_req *ctx, enum lib9p_msg_type resp_ty
} else {
assert(host_resp);
struct lib9p_Rmsg_send_buf net_resp;
- if (lib9p_Rmsg_marshal(&ctx->basectx,
- resp_typ, host_resp,
- &net_resp))
+ error err = lib9p_Rmsg_marshal(&ctx->basectx,
+ resp_typ, host_resp,
+ &net_resp);
+ if (!ERROR_IS_NULL(err)) {
+ lib9p_error(ctx, err.num, (error, err));
+ error_cleanup(&err);
goto error;
+ }
srv_msglog(ctx, resp_typ, host_resp);
srv_write_Rmsg(ctx, &net_resp);
}
@@ -761,7 +778,7 @@ static void handle_Tversion(struct srv_req *ctx,
uint32_t min_msg_size = _LIB9P_MAX(lib9p_version_min_Rerror_size(ctx->basectx.version),
lib9p_version_min_Rread_size(ctx->basectx.version)+1);
if (req->max_msg_size < min_msg_size) {
- lib9p_error(&ctx->basectx,
+ lib9p_error(ctx,
E_POSIX_EDOM, "requested max_msg_size is less than minimum for ", lib9p_version_str(version),
" (", req->max_msg_size, " < ", min_msg_size, ")");
goto tversion_return;
@@ -794,9 +811,9 @@ static void handle_Tversion(struct srv_req *ctx,
/* Close all FIDs. */
MAP_FOREACH(&ctx->parent_sess->fids, fid, fidinfo) {
srv_fid_del(ctx, fid, fidinfo, false);
- if (lib9p_ctx_has_error(&ctx->basectx)) {
- srv_nonrespond_error("clunk: ", (strn, ctx->basectx.err_msg, CONFIG_9P_MAX_ERR_SIZE));
- lib9p_ctx_clear_error(&ctx->basectx);
+ if (lib9p_ctx_has_error(ctx)) {
+ srv_nonrespond_error("clunk: ", (strn, ctx->err_msg, CONFIG_9P_SRV_MAX_ERR_SIZE));
+ lib9p_ctx_clear_error(ctx);
}
}
@@ -815,8 +832,7 @@ static void handle_Tauth(struct srv_req *ctx,
struct lib9p_srv *srv = ctx->parent_sess->parent_conn->parent_srv;
if (!srv->auth) {
- lib9p_error(&ctx->basectx,
- E_POSIX_EOPNOTSUPP, "authentication not required");
+ lib9p_error(ctx, E_POSIX_EOPNOTSUPP, "authentication not required");
goto tauth_return;
}
@@ -824,10 +840,9 @@ static void handle_Tauth(struct srv_req *ctx,
srv->auth(ctx, req->aname);
- lib9p_error(&ctx->basectx,
- E_POSIX_EOPNOTSUPP, "TODO: auth not implemented");
+ lib9p_error(ctx, E_POSIX_EOPNOTSUPP, "TODO: auth not implemented");
- if (lib9p_ctx_has_error(&ctx->basectx))
+ if (lib9p_ctx_has_error(ctx))
ctx->user = srv_userid_decref(ctx->user);
tauth_return:
@@ -839,8 +854,7 @@ static void handle_Tattach(struct srv_req *ctx,
srv_handler_common(ctx, attach, req);
if (req->fid == LIB9P_FID_NOFID) {
- lib9p_error(&ctx->basectx,
- E_POSIX_EBADF, "cannot assign to NOFID");
+ lib9p_error(ctx, E_POSIX_EBADF, "cannot assign to NOFID");
goto tattach_return;
}
@@ -848,38 +862,31 @@ static void handle_Tattach(struct srv_req *ctx,
if (srv->auth) {
struct srv_fidinfo *afid = map_load(&ctx->parent_sess->fids, req->afid);
if (!afid)
- lib9p_error(&ctx->basectx,
- E_POSIX_EACCES, "FID provided as auth-file is not a valid FID");
+ lib9p_error(ctx, E_POSIX_EACCES, "FID provided as auth-file is not a valid FID");
else if (afid->type != SRV_FILETYPE_AUTH)
- lib9p_error(&ctx->basectx,
- E_POSIX_EACCES, "FID provided as auth-file is not an auth-file");
+ lib9p_error(ctx, E_POSIX_EACCES, "FID provided as auth-file is not an auth-file");
else if (!lib9p_str_eq(afid->user->name, req->uname))
- lib9p_error(&ctx->basectx,
- E_POSIX_EACCES,
+ lib9p_error(ctx, E_POSIX_EACCES,
"FID provided as auth-file is for user=", (qmem, afid->user->name.utf8, afid->user->name.len),
" and cannot be used for user=", (qmem, req->uname.utf8, req->uname.len));
#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L
else if (afid->user->num != req->unum)
- lib9p_error(&ctx->basectx,
- E_POSIX_EACCES,
+ lib9p_error(ctx, E_POSIX_EACCES,
"FID provided as auth-file is for user=", afid->user->num,
" and cannot be used for user=", req->unum);
#endif
else if (!lib9p_str_eq(afid->auth.aname, req->aname))
- lib9p_error(&ctx->basectx,
- E_POSIX_EACCES,
+ lib9p_error(ctx, E_POSIX_EACCES,
"FID provided as auth-file is for tree=", (qmem, afid->auth.aname.utf8, afid->auth.aname.len),
" and cannot be used for tree=", (qmem, req->aname.utf8, req->aname.len));
else if (!afid->auth.completed)
- lib9p_error(&ctx->basectx,
- E_POSIX_EACCES, "FID provided as auth-file has not completed authentication");
- if (lib9p_ctx_has_error(&ctx->basectx))
+ lib9p_error(ctx, E_POSIX_EACCES, "FID provided as auth-file has not completed authentication");
+ if (lib9p_ctx_has_error(ctx))
goto tattach_return;
ctx->user = srv_userid_incref(afid->user);
} else {
if (req->afid != LIB9P_FID_NOFID) {
- lib9p_error(&ctx->basectx,
- E_POSIX_EACCES, "FID provided as auth-file, but no auth-file is required");
+ lib9p_error(ctx, E_POSIX_EACCES, "FID provided as auth-file, but no auth-file is required");
goto tattach_return;
}
ctx->user = srv_userid_new(req->uname, req->unum);
@@ -887,8 +894,8 @@ static void handle_Tattach(struct srv_req *ctx,
/* 1. File object */
lo_interface lib9p_srv_file root_file = srv->rootdir(ctx, req->aname);
- assert(LO_IS_NULL(root_file) == lib9p_ctx_has_error(&ctx->basectx));
- if (lib9p_ctx_has_error(&ctx->basectx))
+ assert(LO_IS_NULL(root_file) == lib9p_ctx_has_error(ctx));
+ if (lib9p_ctx_has_error(ctx))
goto tattach_return;
struct lib9p_qid root_qid = LO_CALL(root_file, qid);
@@ -938,20 +945,17 @@ static void handle_Twalk(struct srv_req *ctx,
srv_handler_common(ctx, walk, req);
if (req->newfid == LIB9P_FID_NOFID) {
- lib9p_error(&ctx->basectx,
- E_POSIX_EBADF, "cannot assign to NOFID");
+ lib9p_error(ctx, E_POSIX_EBADF, "cannot assign to NOFID");
goto twalk_return;
}
struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid);
if (!fidinfo) {
- lib9p_error(&ctx->basectx,
- E_POSIX_EBADF, "bad file number ", req->fid);
+ lib9p_error(ctx, E_POSIX_EBADF, "bad file number ", req->fid);
goto twalk_return;
}
if (fidinfo->flags & FIDFLAG_OPEN) {
- lib9p_error(&ctx->basectx,
- E_POSIX_EALREADY, "cannot walk on FID open for I/O");
+ lib9p_error(ctx, E_POSIX_EALREADY, "cannot walk on FID open for I/O");
goto twalk_return;
}
ctx->user = srv_userid_incref(fidinfo->user);
@@ -964,8 +968,7 @@ static void handle_Twalk(struct srv_req *ctx,
resp.wqid = _resp_qid;
for (resp.nwqid = 0; resp.nwqid < req->nwname; resp.nwqid++) {
if (pathinfo->type != SRV_FILETYPE_DIR) {
- lib9p_error(&ctx->basectx,
- E_POSIX_ENOTDIR, "not a directory");
+ lib9p_error(ctx, E_POSIX_ENOTDIR, "not a directory");
break;
}
@@ -976,8 +979,8 @@ static void handle_Twalk(struct srv_req *ctx,
new_pathinfo->gc_refcount++;
} else {
lo_interface lib9p_srv_file member_file = LO_CALL(pathinfo->file, dwalk, ctx, req->wname[resp.nwqid]);
- assert(LO_IS_NULL(member_file) == lib9p_ctx_has_error(&ctx->basectx));
- if (lib9p_ctx_has_error(&ctx->basectx))
+ assert(LO_IS_NULL(member_file) == lib9p_ctx_has_error(ctx));
+ if (lib9p_ctx_has_error(ctx))
break;
new_pathinfo = srv_path_save(ctx, member_file, LO_CALL(pathinfo->file, qid).path);
assert(new_pathinfo);
@@ -985,12 +988,11 @@ static void handle_Twalk(struct srv_req *ctx,
if (new_pathinfo->type == SRV_FILETYPE_DIR) {
struct lib9p_srv_stat stat = LO_CALL(new_pathinfo->file, stat, ctx);
- if (lib9p_ctx_has_error(&ctx->basectx))
+ if (lib9p_ctx_has_error(ctx))
break;
lib9p_srv_stat_assert(stat);
if (!srv_check_perm(ctx, &stat, 0b001)) {
- lib9p_error(&ctx->basectx,
- E_POSIX_EACCES, "you do not have execute permission on that directory");
+ lib9p_error(ctx, E_POSIX_EACCES, "you do not have execute permission on that directory");
srv_path_decref(ctx, LO_CALL(new_pathinfo->file, qid).path);
break;
}
@@ -1005,10 +1007,10 @@ static void handle_Twalk(struct srv_req *ctx,
if (!srv_fid_store(ctx, req->newfid, pathinfo, req->newfid == req->fid))
srv_path_decref(ctx, LO_CALL(pathinfo->file, qid).path);
} else {
- assert(lib9p_ctx_has_error(&ctx->basectx));
+ assert(lib9p_ctx_has_error(ctx));
srv_path_decref(ctx, LO_CALL(pathinfo->file, qid).path);
if (resp.nwqid > 0)
- lib9p_ctx_clear_error(&ctx->basectx);
+ lib9p_ctx_clear_error(ctx);
}
twalk_return:
if (ctx->user)
@@ -1023,21 +1025,18 @@ static void handle_Topen(struct srv_req *ctx,
/* Check that the FID is valid for this. */
struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid);
if (!fidinfo) {
- lib9p_error(&ctx->basectx,
- E_POSIX_EBADF, "bad file number ", req->fid);
+ lib9p_error(ctx, E_POSIX_EBADF, "bad file number ", req->fid);
goto topen_return;
}
if (fidinfo->flags & FIDFLAG_OPEN) {
- lib9p_error(&ctx->basectx,
- E_POSIX_EALREADY, "FID is already open");
+ lib9p_error(ctx, E_POSIX_EALREADY, "FID is already open");
goto topen_return;
}
if (fidinfo->type == SRV_FILETYPE_DIR) {
if ( ((req->mode & LIB9P_O_MODE_MASK) != LIB9P_O_MODE_READ) ||
(req->mode & LIB9P_O_TRUNC) ||
(req->mode & LIB9P_O_RCLOSE) ) {
- lib9p_error(&ctx->basectx,
- E_POSIX_EISDIR, "directories cannot be written, executed, truncated, or removed-on-close");
+ lib9p_error(ctx, E_POSIX_EISDIR, "directories cannot be written, executed, truncated, or removed-on-close");
goto topen_return;
}
}
@@ -1054,23 +1053,21 @@ static void handle_Topen(struct srv_req *ctx,
struct srv_pathinfo *parent = map_load(&ctx->parent_sess->paths, pathinfo->parent_dir);
assert(parent);
struct lib9p_srv_stat parent_stat = LO_CALL(parent->file, stat, ctx);
- if (lib9p_ctx_has_error(&ctx->basectx))
+ if (lib9p_ctx_has_error(ctx))
goto topen_return;
lib9p_srv_stat_assert(parent_stat);
if (!srv_check_perm(ctx, &parent_stat, 0b010)) {
- lib9p_error(&ctx->basectx,
- E_POSIX_EACCES, "permission denied to remove-on-close");
+ lib9p_error(ctx, E_POSIX_EACCES, "permission denied to remove-on-close");
goto topen_return;
}
fidflags |= FIDFLAG_RCLOSE;
}
struct lib9p_srv_stat stat = LO_CALL(pathinfo->file, stat, ctx);
- if (lib9p_ctx_has_error(&ctx->basectx))
+ if (lib9p_ctx_has_error(ctx))
goto topen_return;
lib9p_srv_stat_assert(stat);
if ((stat.mode & LIB9P_DM_EXCL) && pathinfo->io_refcount) {
- lib9p_error(&ctx->basectx,
- E_POSIX_EEXIST, "exclusive file is already opened");
+ lib9p_error(ctx, E_POSIX_EEXIST, "exclusive file is already opened");
goto topen_return;
}
if (stat.mode & LIB9P_DM_APPEND) {
@@ -1098,8 +1095,7 @@ static void handle_Topen(struct srv_req *ctx,
break;
}
if (!srv_check_perm(ctx, &stat, perm_bits)) {
- lib9p_error(&ctx->basectx,
- E_POSIX_EACCES, "permission denied");
+ lib9p_error(ctx, E_POSIX_EACCES, "permission denied");
goto topen_return;
}
@@ -1109,8 +1105,8 @@ static void handle_Topen(struct srv_req *ctx,
switch (pathinfo->type) {
case SRV_FILETYPE_DIR:
fidinfo->dir.io = LO_CALL(pathinfo->file, dopen, ctx);
- assert(LO_IS_NULL(fidinfo->dir.io) == lib9p_ctx_has_error(&ctx->basectx));
- if (lib9p_ctx_has_error(&ctx->basectx))
+ assert(LO_IS_NULL(fidinfo->dir.io) == lib9p_ctx_has_error(ctx));
+ if (lib9p_ctx_has_error(ctx))
goto topen_return;
fidinfo->dir.idx = 0;
fidinfo->dir.off = 0;
@@ -1121,8 +1117,8 @@ static void handle_Topen(struct srv_req *ctx,
fidinfo->file.io = LO_CALL(pathinfo->file, fopen, ctx,
rd, wr,
reqmode & LIB9P_O_TRUNC);
- assert(LO_IS_NULL(fidinfo->file.io) == lib9p_ctx_has_error(&ctx->basectx));
- if (lib9p_ctx_has_error(&ctx->basectx))
+ assert(LO_IS_NULL(fidinfo->file.io) == lib9p_ctx_has_error(ctx));
+ if (lib9p_ctx_has_error(ctx))
goto topen_return;
qid = LO_CALL(fidinfo->file.io, qid);
iounit = LO_CALL(fidinfo->file.io, iounit);
@@ -1154,8 +1150,7 @@ static void handle_Tcreate(struct srv_req *ctx,
struct lib9p_msg_Tcreate *req) {
srv_handler_common(ctx, create, req);
- lib9p_error(&ctx->basectx,
- E_POSIX_EOPNOTSUPP, "create not (yet?) implemented");
+ lib9p_error(ctx, E_POSIX_EOPNOTSUPP, "create not (yet?) implemented");
srv_respond(ctx, create, &resp);
}
@@ -1193,13 +1188,11 @@ static void handle_Tread(struct srv_req *ctx,
/* Check that the FID is valid for this. */
struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid);
if (!fidinfo) {
- lib9p_error(&ctx->basectx,
- E_POSIX_EBADF, "bad file number ", req->fid);
+ lib9p_error(ctx, E_POSIX_EBADF, "bad file number ", req->fid);
goto tread_return;
}
if (!(fidinfo->flags & FIDFLAG_OPEN_R)) {
- lib9p_error(&ctx->basectx,
- E_POSIX_EINVAL, "FID not open for reading");
+ lib9p_error(ctx, E_POSIX_EINVAL, "FID not open for reading");
goto tread_return;
}
@@ -1214,8 +1207,7 @@ static void handle_Tread(struct srv_req *ctx,
fidinfo->dir.off = 0;
fidinfo->dir.buffered_dirent = (struct lib9p_srv_dirent){};
} else if (req->offset != fidinfo->dir.off) {
- lib9p_error(&ctx->basectx,
- E_POSIX_EINVAL, "invalid offset (must be 0 or ", fidinfo->dir.off, "): ", req->offset);
+ lib9p_error(ctx, E_POSIX_EINVAL, "invalid offset (must be 0 or ", fidinfo->dir.off, "): ", req->offset);
goto tread_return;
}
/* Read. */
@@ -1229,10 +1221,10 @@ static void handle_Tread(struct srv_req *ctx,
member_dirent = fidinfo->dir.buffered_dirent;
} else {
member_dirent = LO_CALL(fidinfo->dir.io, dread, ctx, fidinfo->dir.idx);
- if (lib9p_ctx_has_error(&ctx->basectx)) {
+ if (lib9p_ctx_has_error(ctx)) {
if (!resp.count)
goto tread_return;
- lib9p_ctx_clear_error(&ctx->basectx);
+ lib9p_ctx_clear_error(ctx);
break;
}
}
@@ -1247,16 +1239,16 @@ static void handle_Tread(struct srv_req *ctx,
dir_pathinfo = map_load(&ctx->parent_sess->paths, fidinfo->path);
assert(dir_pathinfo);
member_file = LO_CALL(dir_pathinfo->file, dwalk, ctx, member_dirent.name);
- assert(LO_IS_NULL(member_file) == lib9p_ctx_has_error(&ctx->basectx));
- if (!lib9p_ctx_has_error(&ctx->basectx))
+ assert(LO_IS_NULL(member_file) == lib9p_ctx_has_error(ctx));
+ if (!lib9p_ctx_has_error(ctx))
member_stat = LO_CALL(member_file, stat, ctx);
}
- if (lib9p_ctx_has_error(&ctx->basectx)) {
+ if (lib9p_ctx_has_error(ctx)) {
if (!LO_IS_NULL(member_file))
LO_CALL(member_file, free);
if (!resp.count)
goto tread_return;
- lib9p_ctx_clear_error(&ctx->basectx);
+ lib9p_ctx_clear_error(ctx);
break;
}
lib9p_srv_stat_assert(member_stat);
@@ -1267,8 +1259,7 @@ static void handle_Tread(struct srv_req *ctx,
LO_CALL(member_file, free);
if (!nbytes) {
if (!resp.count) {
- lib9p_error(&ctx->basectx,
- E_POSIX_ERANGE, "stat object does not fit into negotiated max message size");
+ lib9p_error(ctx, E_POSIX_ERANGE, "stat object does not fit into negotiated max message size");
goto tread_return;
}
fidinfo->dir.buffered_dirent = member_dirent;
@@ -1286,7 +1277,7 @@ static void handle_Tread(struct srv_req *ctx,
case SRV_FILETYPE_FILE:
struct iovec iov;
LO_CALL(fidinfo->file.io, pread, ctx, req->count, req->offset, &iov);
- if (!lib9p_ctx_has_error(&ctx->basectx) && !ctx->flush_acknowledged) {
+ if (!lib9p_ctx_has_error(ctx) && !ctx->flush_acknowledged) {
resp.count = iov.iov_len;
resp.data = iov.iov_base;
if (resp.count > req->count)
@@ -1314,13 +1305,11 @@ static void handle_Twrite(struct srv_req *ctx,
/* Check that the FID is valid for this. */
struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid);
if (!fidinfo) {
- lib9p_error(&ctx->basectx,
- E_POSIX_EBADF, "bad file number ", req->fid);
+ lib9p_error(ctx, E_POSIX_EBADF, "bad file number ", req->fid);
goto twrite_return;
}
if (!(fidinfo->flags & FIDFLAG_OPEN_W)) {
- lib9p_error(&ctx->basectx,
- E_POSIX_EINVAL, "FID not open for writing");
+ lib9p_error(ctx, E_POSIX_EINVAL, "FID not open for writing");
goto twrite_return;
}
if (fidinfo->flags & FIDFLAG_APPEND)
@@ -1341,8 +1330,7 @@ static void handle_Tclunk(struct srv_req *ctx,
struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid);
if (!fidinfo) {
- lib9p_error(&ctx->basectx,
- E_POSIX_EBADF, "bad file number ", req->fid);
+ lib9p_error(ctx, E_POSIX_EBADF, "bad file number ", req->fid);
goto tclunk_return;
}
@@ -1358,8 +1346,7 @@ static void handle_Tremove(struct srv_req *ctx,
struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid);
if (!fidinfo) {
- lib9p_error(&ctx->basectx,
- E_POSIX_EBADF, "bad file number ", req->fid);
+ lib9p_error(ctx, E_POSIX_EBADF, "bad file number ", req->fid);
goto tremove_return;
}
@@ -1367,17 +1354,15 @@ static void handle_Tremove(struct srv_req *ctx,
struct srv_pathinfo *pathinfo = map_load(&ctx->parent_sess->paths, fidinfo->path);
assert(pathinfo);
if (pathinfo->parent_dir == fidinfo->path) {
- lib9p_error(&ctx->basectx,
- E_POSIX_EBUSY, "cannot remove root");
+ lib9p_error(ctx, E_POSIX_EBUSY, "cannot remove root");
remove = false;
goto tremove_main;
}
struct srv_pathinfo *parent = map_load(&ctx->parent_sess->paths, pathinfo->parent_dir);
assert(parent);
struct lib9p_srv_stat parent_stat = LO_CALL(parent->file, stat, ctx);
- if (!lib9p_ctx_has_error(&ctx->basectx) && !srv_check_perm(ctx, &parent_stat, 0b010)) {
- lib9p_error(&ctx->basectx,
- E_POSIX_EACCES, "you do not have write permission on the parent directory");
+ if (!lib9p_ctx_has_error(ctx) && !srv_check_perm(ctx, &parent_stat, 0b010)) {
+ lib9p_error(ctx, E_POSIX_EACCES, "you do not have write permission on the parent directory");
remove = false;
goto tremove_main;
}
@@ -1394,8 +1379,7 @@ static void handle_Tstat(struct srv_req *ctx,
struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid);
if (!fidinfo) {
- lib9p_error(&ctx->basectx,
- E_POSIX_EBADF, "bad file number ", req->fid);
+ lib9p_error(ctx, E_POSIX_EBADF, "bad file number ", req->fid);
goto tstat_return;
}
struct srv_pathinfo *pathinfo = map_load(&ctx->parent_sess->paths, fidinfo->path);
@@ -1403,7 +1387,7 @@ static void handle_Tstat(struct srv_req *ctx,
ctx->user = srv_userid_incref(fidinfo->user);
struct lib9p_srv_stat stat = LO_CALL(pathinfo->file, stat, ctx);
- if (lib9p_ctx_has_error(&ctx->basectx))
+ if (lib9p_ctx_has_error(ctx))
goto tstat_return;
lib9p_srv_stat_assert(stat);
resp.stat = srv_stat_to_net_stat(stat);
@@ -1417,8 +1401,7 @@ static void handle_Twstat(struct srv_req *ctx,
struct lib9p_msg_Twstat *req) {
srv_handler_common(ctx, wstat, req);
- lib9p_error(&ctx->basectx,
- E_POSIX_EOPNOTSUPP, "wstat not (yet?) implemented");
+ lib9p_error(ctx, E_POSIX_EOPNOTSUPP, "wstat not (yet?) implemented");
srv_respond(ctx, wstat, &resp);
}
@@ -1429,8 +1412,7 @@ static void handle_Topenfd(struct srv_req *ctx,
struct lib9p_msg_Topenfd *req) {
srv_handler_common(ctx, openfd, req);
- lib9p_error(&ctx->basectx,
- E_POSIX_EOPNOTSUPP, "openfd not (yet?) implemented");
+ lib9p_error(ctx, E_POSIX_EOPNOTSUPP, "openfd not (yet?) implemented");
srv_respond(ctx, openfd, &resp);
}
@@ -1441,8 +1423,7 @@ static void handle_Tsession(struct srv_req *ctx,
struct lib9p_msg_Tsession *req) {
srv_handler_common(ctx, session, req);
- lib9p_error(&ctx->basectx,
- E_POSIX_EOPNOTSUPP, "session not (yet?) implemented");
+ lib9p_error(ctx, E_POSIX_EOPNOTSUPP, "session not (yet?) implemented");
srv_respond(ctx, session, &resp);
}
@@ -1451,8 +1432,7 @@ static void handle_Tsread(struct srv_req *ctx,
struct lib9p_msg_Tsread *req) {
srv_handler_common(ctx, sread, req);
- lib9p_error(&ctx->basectx,
- E_POSIX_EOPNOTSUPP, "sread not (yet?) implemented");
+ lib9p_error(ctx, E_POSIX_EOPNOTSUPP, "sread not (yet?) implemented");
srv_respond(ctx, sread, &resp);
}
@@ -1461,8 +1441,7 @@ static void handle_Tswrite(struct srv_req *ctx,
struct lib9p_msg_Tswrite *req) {
srv_handler_common(ctx, swrite, req);
- lib9p_error(&ctx->basectx,
- E_POSIX_EOPNOTSUPP, "swrite not (yet?) implemented");
+ lib9p_error(ctx, E_POSIX_EOPNOTSUPP, "swrite not (yet?) implemented");
srv_respond(ctx, swrite, &resp);
}
diff --git a/lib9p/srv_include/lib9p/srv.h b/lib9p/srv_include/lib9p/srv.h
index 349a413..77a6b12 100644
--- a/lib9p/srv_include/lib9p/srv.h
+++ b/lib9p/srv_include/lib9p/srv.h
@@ -17,6 +17,11 @@
#include <lib9p/core.h>
+#ifndef CONFIG_9P_SRV_MAX_ERR_SIZE
+ #error config.h must define CONFIG_9P_SRV_MAX_ERR_SIZE
+#endif
+static_assert(CONFIG_9P_SRV_MAX_ERR_SIZE <= UINT16_MAX);
+
/* context ********************************************************************/
struct lib9p_srv_userid {
@@ -41,6 +46,9 @@ struct lib9p_srv_ctx {
struct lib9p_ctx basectx;
struct lib9p_srv_userid *user;
+ _errnum err_num;
+ [[gnu::nonstring]] char err_msg[CONFIG_9P_SRV_MAX_ERR_SIZE];
+
BEGIN_PRIVATE(LIB9P_SRV_H);
struct _lib9p_srv_sess *parent_sess;
lib9p_tag_t tag;
@@ -51,6 +59,26 @@ struct lib9p_srv_ctx {
END_PRIVATE(LIB9P_SRV_H);
};
+void lib9p_ctx_clear_error(struct lib9p_srv_ctx *ctx);
+
+bool lib9p_ctx_has_error(struct lib9p_srv_ctx *ctx);
+
+/** Write a <libmisc/fmt.h>-style error into ctx, return -1. */
+#define lib9p_error(ctx, libmisc_errno, ...) ({ \
+ if (!lib9p_ctx_has_error(ctx)) { \
+ (ctx)->err_num = libmisc_errno; \
+ struct fmt_buf _w = { \
+ .dat = (ctx)->err_msg, \
+ .cap = sizeof((ctx)->err_msg), \
+ }; \
+ lo_interface fmt_dest w = LO_BOX(fmt_dest, &_w); \
+ fmt_print(w, __VA_ARGS__); \
+ if (_w.len < _w.cap) \
+ memset(_w.dat + _w.len, 0, _w.cap - _w.len); \
+ } \
+ -1; \
+})
+
/**
* Return whether there is an outstanding Tflush or Tversion
* cancellation of this request. After becoming true, this may go
diff --git a/lib9p/tests/client_config/config.h b/lib9p/tests/client_config/config.h
index bcf030d..4bba4ec 100644
--- a/lib9p/tests/client_config/config.h
+++ b/lib9p/tests/client_config/config.h
@@ -7,7 +7,6 @@
#ifndef _CONFIG_H_
#define _CONFIG_H_
-#define CONFIG_9P_MAX_ERR_SIZE 128
#define CONFIG_9P_MAX_9P2000_e_WELEM 16
#define CONFIG_9P_ENABLE_9P2000 1 /* bool */
diff --git a/lib9p/tests/test_compile_config/config.h b/lib9p/tests/test_compile_config/config.h
index 02cb8e5..cb3709e 100644
--- a/lib9p/tests/test_compile_config/config.h
+++ b/lib9p/tests/test_compile_config/config.h
@@ -9,11 +9,11 @@
/* 9P *************************************************************************/
-#define CONFIG_9P_MAX_ERR_SIZE 128
#define CONFIG_9P_MAX_9P2000_e_WELEM 16
/* 9P_SRV *********************************************************************/
+#define CONFIG_9P_SRV_MAX_ERR_SIZE 128
#define CONFIG_9P_SRV_MAX_MSG_SIZE ((4*1024)+24)
#define CONFIG_9P_SRV_MAX_HOSTMSG_SIZE CONFIG_9P_SRV_MAX_MSG_SIZE+16
diff --git a/lib9p/tests/test_server/config/config.h b/lib9p/tests/test_server/config/config.h
index f49894b..a657f60 100644
--- a/lib9p/tests/test_server/config/config.h
+++ b/lib9p/tests/test_server/config/config.h
@@ -12,8 +12,6 @@
/* 9P *************************************************************************/
-#define CONFIG_9P_MAX_ERR_SIZE 128 /* 128 is what Plan 9 4e uses */
-
#define CONFIG_9P_ENABLE_9P2000 1 /* bool */
#define CONFIG_9P_ENABLE_9P2000_u 1 /* bool */
#define CONFIG_9P_ENABLE_9P2000_e 0 /* bool */
@@ -42,6 +40,7 @@
* (8*1024)+160 in 2e and 3e.
*/
#define CONFIG_9P_SRV_MAX_MSG_SIZE ((4*1024)+24)
+#define CONFIG_9P_SRV_MAX_ERR_SIZE 128 /* 128 is what Plan 9 4e uses */
/**
* Maximum host-data-structure size. A message may be larger in
* unmarshaled-host-structures than marshaled-net-bytes due to (1)
diff --git a/lib9p/tests/test_server/fs_flush.c b/lib9p/tests/test_server/fs_flush.c
index 6b677ea..eef9891 100644
--- a/lib9p/tests/test_server/fs_flush.c
+++ b/lib9p/tests/test_server/fs_flush.c
@@ -50,12 +50,12 @@ static struct lib9p_srv_stat flush_file_stat(struct flush_file *self, struct lib
static void flush_file_wstat(struct flush_file *self, struct lib9p_srv_ctx *ctx, struct lib9p_srv_stat) {
assert(self);
assert(ctx);
- lib9p_error(&ctx->basectx, E_POSIX_EROFS, "cannot wstat API file");
+ lib9p_error(ctx, E_POSIX_EROFS, "cannot wstat API file");
}
static void flush_file_remove(struct flush_file *self, struct lib9p_srv_ctx *ctx) {
assert(self);
assert(ctx);
- lib9p_error(&ctx->basectx, E_POSIX_EROFS, "cannot remove API file");
+ lib9p_error(ctx, E_POSIX_EROFS, "cannot remove API file");
}
LIB9P_SRV_NOTDIR(struct flush_file, flush_file)
@@ -121,7 +121,7 @@ static void flush_fio_pread(struct flush_fio *self, struct lib9p_srv_ctx *ctx,
break;
case FLUSH_ERROR:
lib9p_srv_acknowledge_flush(ctx);
- lib9p_error(&ctx->basectx, E_POSIX_ECANCELED, "request canceled by flush");
+ lib9p_error(ctx, E_POSIX_ECANCELED, "request canceled by flush");
break;
case FLUSH_SILENT:
lib9p_srv_acknowledge_flush(ctx);
diff --git a/lib9p/tests/test_server/fs_shutdown.c b/lib9p/tests/test_server/fs_shutdown.c
index 11a941f..5b3bc71 100644
--- a/lib9p/tests/test_server/fs_shutdown.c
+++ b/lib9p/tests/test_server/fs_shutdown.c
@@ -49,12 +49,12 @@ static struct lib9p_srv_stat shutdown_file_stat(struct shutdown_file *self, stru
static void shutdown_file_wstat(struct shutdown_file *self, struct lib9p_srv_ctx *ctx, struct lib9p_srv_stat) {
assert(self);
assert(ctx);
- lib9p_error(&ctx->basectx, E_POSIX_EROFS, "cannot wstat API file");
+ lib9p_error(ctx, E_POSIX_EROFS, "cannot wstat API file");
}
static void shutdown_file_remove(struct shutdown_file *self, struct lib9p_srv_ctx *ctx) {
assert(self);
assert(ctx);
- lib9p_error(&ctx->basectx, E_POSIX_EROFS, "cannot remove API file");
+ lib9p_error(ctx, E_POSIX_EROFS, "cannot remove API file");
}
LIB9P_SRV_NOTDIR(struct shutdown_file, shutdown_file)
diff --git a/lib9p/tests/test_server/fs_whoami.c b/lib9p/tests/test_server/fs_whoami.c
index 273d659..14dd0ba 100644
--- a/lib9p/tests/test_server/fs_whoami.c
+++ b/lib9p/tests/test_server/fs_whoami.c
@@ -73,12 +73,12 @@ static struct lib9p_srv_stat whoami_file_stat(struct whoami_file *self, struct l
static void whoami_file_wstat(struct whoami_file *self, struct lib9p_srv_ctx *ctx, struct lib9p_srv_stat) {
assert(self);
assert(ctx);
- lib9p_error(&ctx->basectx, E_POSIX_EROFS, "cannot wstat API file");
+ lib9p_error(ctx, E_POSIX_EROFS, "cannot wstat API file");
}
static void whoami_file_remove(struct whoami_file *self, struct lib9p_srv_ctx *ctx) {
assert(self);
assert(ctx);
- lib9p_error(&ctx->basectx, E_POSIX_EROFS, "cannot remove API file");
+ lib9p_error(ctx, E_POSIX_EROFS, "cannot remove API file");
}
LIB9P_SRV_NOTDIR(struct whoami_file, whoami_file)
@@ -137,8 +137,7 @@ static void whoami_fio_pread(struct whoami_fio *self, struct lib9p_srv_ctx *ctx,
ctx->user->num, ctx->user->name.len, ctx->user->name.utf8);
if (byte_offset > (uint64_t)data_size) {
- lib9p_error(&ctx->basectx,
- E_POSIX_EINVAL, "offset is past end-of-file length");
+ lib9p_error(ctx, E_POSIX_EINVAL, "offset is past end-of-file length");
return;
}
diff --git a/lib9p/tests/testclient-hangup.c b/lib9p/tests/testclient-hangup.c
index a819e80..2efb49a 100644
--- a/lib9p/tests/testclient-hangup.c
+++ b/lib9p/tests/testclient-hangup.c
@@ -24,8 +24,8 @@
static void _send9p(int fd, struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body) {
struct lib9p_Tmsg_send_buf buf;
- bool err = lib9p_Tmsg_marshal(ctx, typ, body, &buf);
- assert(!err);
+ error err = lib9p_Tmsg_marshal(ctx, typ, body, &buf);
+ assert(ERROR_IS_NULL(err));
size_t exp = 0;
for (size_t i = 0; i < buf.iov_cnt; i++)
exp += buf.iov[i].iov_len;
diff --git a/lib9p/tests/testclient-sess.c b/lib9p/tests/testclient-sess.c
index d466eea..0cec6c6 100644
--- a/lib9p/tests/testclient-sess.c
+++ b/lib9p/tests/testclient-sess.c
@@ -24,8 +24,8 @@
static void _send9p(int fd, struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body) {
struct lib9p_Tmsg_send_buf buf;
- bool err = lib9p_Tmsg_marshal(ctx, typ, body, &buf);
- assert(!err);
+ error err = lib9p_Tmsg_marshal(ctx, typ, body, &buf);
+ assert(ERROR_IS_NULL(err));
size_t exp = 0;
for (size_t i = 0; i < buf.iov_cnt; i++)
exp += buf.iov[i].iov_len;
diff --git a/lib9p_util/static.c b/lib9p_util/static.c
index 7196813..4354166 100644
--- a/lib9p_util/static.c
+++ b/lib9p_util/static.c
@@ -55,13 +55,13 @@ static void util9p_static_dir_wstat(struct util9p_static_dir *self, struct lib9p
assert(self);
assert(ctx);
- lib9p_error(&ctx->basectx, E_POSIX_EROFS, "read-only part of filesystem");
+ lib9p_error(ctx, E_POSIX_EROFS, "read-only part of filesystem");
}
static void util9p_static_dir_remove(struct util9p_static_dir *self, struct lib9p_srv_ctx *ctx) {
assert(self);
assert(ctx);
- lib9p_error(&ctx->basectx, E_POSIX_EROFS, "read-only part of filesystem");
+ lib9p_error(ctx, E_POSIX_EROFS, "read-only part of filesystem");
}
static lo_interface lib9p_srv_file util9p_static_dir_dwalk(struct util9p_static_dir *self, struct lib9p_srv_ctx *ctx,
@@ -72,14 +72,13 @@ static lo_interface lib9p_srv_file util9p_static_dir_dwalk(struct util9p_static_
for (size_t i = 0; !LO_IS_NULL(self->members[i]); i++) {
lo_interface lib9p_srv_file file = self->members[i];
struct lib9p_srv_stat stat = LO_CALL(file, stat, ctx);
- if (lib9p_ctx_has_error(&ctx->basectx))
+ if (lib9p_ctx_has_error(ctx))
break;
lib9p_srv_stat_assert(stat);
if (lib9p_str_eq(stat.name, childname))
return file;
}
- lib9p_error(&ctx->basectx,
- E_POSIX_ENOENT, "no such file or directory");
+ lib9p_error(ctx, E_POSIX_ENOENT, "no such file or directory");
return LO_NULL(lib9p_srv_file);
}
@@ -91,7 +90,7 @@ static lo_interface lib9p_srv_file util9p_static_dir_dcreate(struct util9p_stati
assert(self);
assert(ctx);
- lib9p_error(&ctx->basectx, E_POSIX_EROFS, "read-only part of filesystem");
+ lib9p_error(ctx, E_POSIX_EROFS, "read-only part of filesystem");
return LO_NULL(lib9p_srv_file);
}
@@ -114,7 +113,7 @@ static struct lib9p_srv_dirent util9p_static_dir_dread(struct util9p_static_dir
return (struct lib9p_srv_dirent){};
struct lib9p_srv_stat stat = LO_CALL(file, stat, ctx);
- if (lib9p_ctx_has_error(&ctx->basectx))
+ if (lib9p_ctx_has_error(ctx))
return (struct lib9p_srv_dirent){};
lib9p_srv_stat_assert(stat);
@@ -173,13 +172,13 @@ static void util9p_static_file_wstat(struct util9p_static_file *self, struct lib
assert(self);
assert(ctx);
- lib9p_error(&ctx->basectx, E_POSIX_EROFS, "read-only part of filesystem");
+ lib9p_error(ctx, E_POSIX_EROFS, "read-only part of filesystem");
}
static void util9p_static_file_remove(struct util9p_static_file *self, struct lib9p_srv_ctx *ctx) {
assert(self);
assert(ctx);
- lib9p_error(&ctx->basectx, E_POSIX_EROFS, "read-only part of filesystem");
+ lib9p_error(ctx, E_POSIX_EROFS, "read-only part of filesystem");
}
LIB9P_SRV_NOTDIR(struct util9p_static_file, util9p_static_file);
@@ -210,8 +209,7 @@ static void util9p_static_file_pread(struct util9p_static_file *self, struct lib
size_t data_size = util9p_static_file_size(self);
if (byte_offset > (uint64_t)data_size) {
- lib9p_error(&ctx->basectx,
- E_POSIX_EINVAL, "offset is past end-of-file length");
+ lib9p_error(ctx, E_POSIX_EINVAL, "offset is past end-of-file length");
return;
}
@@ -229,6 +227,6 @@ static uint32_t util9p_static_file_pwrite(struct util9p_static_file *self, struc
assert(self);
assert(ctx);
- lib9p_error(&ctx->basectx, E_POSIX_EROFS, "read-only part of filesystem");
+ lib9p_error(ctx, E_POSIX_EROFS, "read-only part of filesystem");
return 0;
}