diff options
-rw-r--r-- | cmd/srv9p/config/config.h | 2 | ||||
-rw-r--r-- | lib9p/9p.c | 10 | ||||
-rw-r--r-- | lib9p/9p.generated.c | 2 | ||||
-rwxr-xr-x | lib9p/idl.gen | 1 | ||||
-rw-r--r-- | lib9p/include/lib9p/9p.h | 6 | ||||
-rw-r--r-- | lib9p/srv.c | 43 |
6 files changed, 46 insertions, 18 deletions
diff --git a/cmd/srv9p/config/config.h b/cmd/srv9p/config/config.h index 96aba1d..0f6c37e 100644 --- a/cmd/srv9p/config/config.h +++ b/cmd/srv9p/config/config.h @@ -38,7 +38,7 @@ #define CONFIG_9P_MAX_REQS 2 #define CONFIG_9P_MAX_ERR_SIZE 128 /* 128 is what Plan 9 4e uses */ #define CONFIG_9P_ENABLE_9P2000_u -#define CONFIG_9P_ENABLE_9P2000_e +/*#define CONFIG_9P_ENABLE_9P2000_e*/ #define CONFIG_COROUTINE_DEFAULT_STACK_SIZE (32*1024) #define CONFIG_COROUTINE_MEASURE_STACK 1 /* bool */ @@ -18,7 +18,13 @@ int lib9p_error(struct lib9p_ctx *ctx, uint32_t linux_errno, char const *msg) { return -1; strncpy(ctx->err_msg, msg, sizeof(ctx->err_msg)); ctx->err_msg[sizeof(ctx->err_msg)-1] = '\0'; + +#ifdef CONFIG_9P_ENABLE_9P2000_u ctx->err_num = linux_errno; +#else + (void)(linux_errno); +#endif + return -1; } @@ -34,7 +40,11 @@ int lib9p_errorf(struct lib9p_ctx *ctx, uint32_t linux_errno, char const *fmt, . if ((size_t)(n+1) < sizeof(ctx->err_msg)) memset(&ctx->err_msg[n+1], 0, sizeof(ctx->err_msg)-(n+1)); +#ifdef CONFIG_9P_ENABLE_9P2000_u ctx->err_num = linux_errno; +#else + (void)(linux_errno); +#endif return -1; } diff --git a/lib9p/9p.generated.c b/lib9p/9p.generated.c index 660c925..50ed53f 100644 --- a/lib9p/9p.generated.c +++ b/lib9p/9p.generated.c @@ -2040,6 +2040,7 @@ static FLATTEN bool marshal_Rswrite(struct _marshal_ctx *ctx, struct lib9p_msg_R || ({ encode_u8le(155, &ctx->net_bytes[_typ_offset]); false; }) ; } +#endif /* defined(CONFIG_9P_ENABLE_9P2000_e) */ /* vtables / exports **********************************************************/ @@ -2056,7 +2057,6 @@ struct _vtable_version _lib9p_vtables[LIB9P_VER_NUM] = { _MSG(Rversion), _MSG(Rerror), }}, -#endif /* defined(CONFIG_9P_ENABLE_9P2000_e) */ #if defined(CONFIG_9P_ENABLE_9P2000) [LIB9P_VER_9P2000] = { .msgs = { _MSG(Tversion), diff --git a/lib9p/idl.gen b/lib9p/idl.gen index c0a2444..e911ed7 100755 --- a/lib9p/idl.gen +++ b/lib9p/idl.gen @@ -1091,6 +1091,7 @@ static ALWAYS_INLINE bool marshal_8(struct _marshal_ctx *ctx, uint64_t *val) { ret += ifdef_pop(1) ret += "\t ;\n" ret += "}\n" + ret += ifdef_pop(0) # vtables / exports ######################################################## ret += f""" diff --git a/lib9p/include/lib9p/9p.h b/lib9p/include/lib9p/9p.h index 1e1667d..2511e3d 100644 --- a/lib9p/include/lib9p/9p.h +++ b/lib9p/include/lib9p/9p.h @@ -37,19 +37,23 @@ struct lib9p_ctx { uint32_t max_msg_size; /* state */ +#ifdef CONFIG_9P_ENABLE_9P2000_u uint32_t err_num; +#endif char err_msg[CONFIG_9P_MAX_ERR_SIZE]; }; static void lib9p_ctx_clear_error(struct lib9p_ctx *ctx) { assert(ctx); +#ifdef CONFIG_9P_ENABLE_9P2000_u ctx->err_num = 0; +#endif ctx->err_msg[0] = '\0'; } static bool lib9p_ctx_has_error(struct lib9p_ctx *ctx) { assert(ctx); - return ctx->err_num || ctx->err_msg[0]; + return ctx->err_msg[0]; } /** Write an static error into ctx, return -1. */ diff --git a/lib9p/srv.c b/lib9p/srv.c index 04cd119..74aa158 100644 --- a/lib9p/srv.c +++ b/lib9p/srv.c @@ -99,7 +99,9 @@ static uint32_t rerror_overhead_for_version(enum lib9p_version version, } static void respond_error(struct _lib9p_srv_req *req) { +#ifdef CONFIG_9P_ENABLE_9P2000_u assert(req->ctx.basectx.err_num); +#endif assert(req->ctx.basectx.err_msg[0]); ssize_t r; @@ -110,7 +112,9 @@ static void respond_error(struct _lib9p_srv_req *req) { CONFIG_9P_MAX_ERR_SIZE), .utf8 = req->ctx.basectx.err_msg, }, +#ifdef CONFIG_9P_ENABLE_9P2000_u .errno = req->ctx.basectx.err_num, +#endif }; struct _srv_sess *sess = req->parent_sess; @@ -298,9 +302,11 @@ _HANDLER_PROTO(clunk); _HANDLER_PROTO(remove); _HANDLER_PROTO(stat); _HANDLER_PROTO(wstat); -_HANDLER_PROTO(session); /* 9P2000.e */ -_HANDLER_PROTO(sread); /* 9P2000.e */ -_HANDLER_PROTO(swrite); /* 9P2000.e */ +#ifdef CONFIG_9P_ENABLE_9P2000_e +_HANDLER_PROTO(session); +_HANDLER_PROTO(sread); +_HANDLER_PROTO(swrite); +#endif typedef void (*tmessage_handler)(struct _lib9p_srv_req *, void *, void *); @@ -318,9 +324,11 @@ static tmessage_handler tmessage_handlers[0x100] = { [LIB9P_TYP_Tremove] = (tmessage_handler)handle_Tremove, [LIB9P_TYP_Tstat] = (tmessage_handler)handle_Tstat, [LIB9P_TYP_Twstat] = (tmessage_handler)handle_Twstat, - [LIB9P_TYP_Tsession] = (tmessage_handler)handle_Tsession, /* 9P2000.e */ - [LIB9P_TYP_Tsread] = (tmessage_handler)handle_Tsread, /* 9P2000.e */ - [LIB9P_TYP_Tswrite] = (tmessage_handler)handle_Tswrite, /* 9P2000.e */ +#ifdef CONFIG_9P_ENABLE_9P2000_e + [LIB9P_TYP_Tsession] = (tmessage_handler)handle_Tsession, + [LIB9P_TYP_Tsread] = (tmessage_handler)handle_Tsread, + [LIB9P_TYP_Tswrite] = (tmessage_handler)handle_Tswrite, +#endif }; static void handle_message(struct _lib9p_srv_req *ctx) { @@ -409,12 +417,15 @@ static void handle_Tversion(struct _lib9p_srv_req *ctx, '0' <= req->version.utf8[4] && req->version.utf8[4] <= '9' && '0' <= req->version.utf8[5] && req->version.utf8[5] <= '9' && (req->version.utf8[6] == '\0' || req->version.utf8[6] == '.')) { + version = LIB9P_VER_9P2000; +#ifdef CONFIG_9P_ENABLE_9P2000_u if (strcmp((char *)&req->version.utf8[6], ".u") == 0) version = LIB9P_VER_9P2000_u; - else if (strcmp((char *)&req->version.utf8[6], ".e") == 0) +#endif +#ifdef CONFIG_9P_ENABLE_9P2000_e + if (strcmp((char *)&req->version.utf8[6], ".e") == 0) version = LIB9P_VER_9P2000_e; - else - version = LIB9P_VER_9P2000; +#endif } uint32_t min_msg_size = rerror_overhead_for_version(version, ctx->net_bytes); @@ -741,7 +752,7 @@ static void handle_Tcreate(struct _lib9p_srv_req *ctx, handler_common(ctx, req, resp); lib9p_error(&ctx->ctx.basectx, - LINUX_EOPNOTSUPP, "create not yet implemented"); + LINUX_EOPNOTSUPP, "create not (yet?) implemented"); } static void handle_Tread(struct _lib9p_srv_req *ctx, @@ -826,7 +837,7 @@ static void handle_Tremove(struct _lib9p_srv_req *ctx, handler_common(ctx, req, resp); lib9p_error(&ctx->ctx.basectx, - LINUX_EOPNOTSUPP, "remove not yet implemented"); + LINUX_EOPNOTSUPP, "remove not (yet?) implemented"); } static void handle_Tstat(struct _lib9p_srv_req *ctx, @@ -850,16 +861,17 @@ static void handle_Twstat(struct _lib9p_srv_req *ctx, handler_common(ctx, req, resp); lib9p_error(&ctx->ctx.basectx, - LINUX_EOPNOTSUPP, "wstat not yet implemented"); + LINUX_EOPNOTSUPP, "wstat not (yet?) implemented"); } +#ifdef CONFIG_9P_ENABLE_9P2000_e static void handle_Tsession(struct _lib9p_srv_req *ctx, struct lib9p_msg_Tsession *req, struct lib9p_msg_Rsession *resp) { handler_common(ctx, req, resp); lib9p_error(&ctx->ctx.basectx, - LINUX_EOPNOTSUPP, "session not yet implemented"); + LINUX_EOPNOTSUPP, "session not (yet?) implemented"); } static void handle_Tsread(struct _lib9p_srv_req *ctx, @@ -868,7 +880,7 @@ static void handle_Tsread(struct _lib9p_srv_req *ctx, handler_common(ctx, req, resp); lib9p_error(&ctx->ctx.basectx, - LINUX_EOPNOTSUPP, "sread not yet implemented"); + LINUX_EOPNOTSUPP, "sread not (yet?) implemented"); } static void handle_Tswrite(struct _lib9p_srv_req *ctx, @@ -877,5 +889,6 @@ static void handle_Tswrite(struct _lib9p_srv_req *ctx, handler_common(ctx, req, resp); lib9p_error(&ctx->ctx.basectx, - LINUX_EOPNOTSUPP, "swrite not yet implemented"); + LINUX_EOPNOTSUPP, "swrite not (yet?) implemented"); } +#endif |