diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-10-29 01:22:12 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-10-29 01:23:49 -0600 |
commit | affe77a2b068a9de236f0d7703092dbfafacff5e (patch) | |
tree | 996ad7216b10c0237657e947bbb7aafc24aef170 /lib9p/9p.c | |
parent | 4d185da010aea1d307c8ff7807ef3d4359083ed0 (diff) |
lib9p/9p.h: Tidy up
Diffstat (limited to 'lib9p/9p.c')
-rw-r--r-- | lib9p/9p.c | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -13,6 +13,21 @@ #include "internal.h" +/* ctx ************************************************************************/ + +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'; +} + +bool lib9p_ctx_has_error(struct lib9p_ctx *ctx) { + assert(ctx); + return ctx->err_msg[0]; +} + int lib9p_error(struct lib9p_ctx *ctx, uint32_t linux_errno, char const *msg) { if (lib9p_ctx_has_error(ctx)) return -1; @@ -49,12 +64,13 @@ int lib9p_errorf(struct lib9p_ctx *ctx, uint32_t linux_errno, char const *fmt, . return -1; } - const char *lib9p_msg_type_str(struct lib9p_ctx *ctx, enum lib9p_msg_type typ) { assert(0 <= typ && typ <= 0xFF); return _lib9p_versions[ctx->version].msgs[typ].name; } +/* main message functions *****************************************************/ + ssize_t lib9p_validate(struct lib9p_ctx *ctx, uint8_t *net_bytes) { /* Inspect the first 5 bytes ourselves. */ struct _validate_ctx subctx = { @@ -115,6 +131,8 @@ bool lib9p_marshal(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body, return table.marshal(&subctx, body); } +/* `struct lib9p_stat` helpers ************************************************/ + bool lib9p_validate_stat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes, uint32_t *ret_net_size, ssize_t *ret_host_size) { struct _validate_ctx subctx = { |