diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-12-16 14:56:05 -0500 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-01-11 23:34:14 -0700 |
commit | f263b08d4457e36126f150566219472f3a05c906 (patch) | |
tree | d699f327bb9ab53b6e110dcc878afbe9c290551e | |
parent | c3b9d7e802d7d2e31131692d621515ac88178ebb (diff) |
lib9p: Rename `lib9p_*_stat()` to `lib9p_stat_*()` for consistency
-rw-r--r-- | lib9p/9p.c | 12 | ||||
-rw-r--r-- | lib9p/9p.generated.c | 6 | ||||
-rwxr-xr-x | lib9p/idl.gen | 6 | ||||
-rw-r--r-- | lib9p/include/lib9p/9p.h | 10 | ||||
-rw-r--r-- | lib9p/internal.h | 6 | ||||
-rw-r--r-- | lib9p/srv.c | 12 | ||||
-rw-r--r-- | lib9p_util/static.c | 8 |
7 files changed, 30 insertions, 30 deletions
@@ -185,7 +185,7 @@ bool lib9p_Rmsg_marshal(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *bo /* `struct lib9p_stat` helpers ************************************************/ -bool lib9p_validate_stat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes, +bool lib9p_stat_validate(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 = { .ctx = ctx, @@ -195,7 +195,7 @@ bool lib9p_validate_stat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_ .net_offset = 0, .host_extra = 0, }; - if (_lib9p_validate_stat(&subctx)) + if (_lib9p_stat_validate(&subctx)) return true; if (ret_net_size) *ret_net_size = subctx.net_offset; @@ -205,7 +205,7 @@ bool lib9p_validate_stat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_ return false; } -uint32_t lib9p_unmarshal_stat(struct lib9p_ctx *ctx, uint8_t *net_bytes, +uint32_t lib9p_stat_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes, struct lib9p_stat *ret_obj, void *ret_extra) { struct _unmarshal_ctx subctx = { .ctx = ctx, @@ -214,11 +214,11 @@ uint32_t lib9p_unmarshal_stat(struct lib9p_ctx *ctx, uint8_t *net_bytes, .extra = ret_extra, }; - _lib9p_unmarshal_stat(&subctx, ret_obj); + _lib9p_stat_unmarshal(&subctx, ret_obj); return subctx.net_offset; } -uint32_t lib9p_marshal_stat(struct lib9p_ctx *ctx, uint32_t max_net_size, struct lib9p_stat *obj, +uint32_t lib9p_stat_marshal(struct lib9p_ctx *ctx, uint32_t max_net_size, struct lib9p_stat *obj, uint8_t *ret_bytes) { struct lib9p_ctx _ctx = *ctx; _ctx.max_msg_size = max_net_size; @@ -227,7 +227,7 @@ uint32_t lib9p_marshal_stat(struct lib9p_ctx *ctx, uint32_t max_net_size, struct .net_bytes = ret_bytes, .net_offset = 0, }; - if (_lib9p_marshal_stat(&subctx, obj)) + if (_lib9p_stat_marshal(&subctx, obj)) return 0; return subctx.net_offset; } diff --git a/lib9p/9p.generated.c b/lib9p/9p.generated.c index 85e0e2b..984ba7f 100644 --- a/lib9p/9p.generated.c +++ b/lib9p/9p.generated.c @@ -2155,12 +2155,12 @@ const struct _lib9p_send_tentry _lib9p_table_Rmsg_send[LIB9P_VER_NUM][0x80] = { #endif /* CONFIG_9P_ENABLE_9P2000_u */ }; -LM_FLATTEN bool _lib9p_validate_stat(struct _validate_ctx *ctx) { +LM_FLATTEN bool _lib9p_stat_validate(struct _validate_ctx *ctx) { return validate_stat(ctx); } -LM_FLATTEN void _lib9p_unmarshal_stat(struct _unmarshal_ctx *ctx, struct lib9p_stat *out) { +LM_FLATTEN void _lib9p_stat_unmarshal(struct _unmarshal_ctx *ctx, struct lib9p_stat *out) { unmarshal_stat(ctx, out); } -LM_FLATTEN bool _lib9p_marshal_stat(struct _marshal_ctx *ctx, struct lib9p_stat *val) { +LM_FLATTEN bool _lib9p_stat_marshal(struct _marshal_ctx *ctx, struct lib9p_stat *val) { return marshal_stat(ctx, val); } diff --git a/lib9p/idl.gen b/lib9p/idl.gen index 47aa608..e796855 100755 --- a/lib9p/idl.gen +++ b/lib9p/idl.gen @@ -738,13 +738,13 @@ LM_ALWAYS_INLINE static bool marshal_8(struct _marshal_ctx *ctx, uint64_t *val) ret += "};\n" ret += f""" -LM_FLATTEN bool _{idprefix}validate_stat(struct _validate_ctx *ctx) {{ +LM_FLATTEN bool _{idprefix}stat_validate(struct _validate_ctx *ctx) {{ \treturn validate_stat(ctx); }} -LM_FLATTEN void _{idprefix}unmarshal_stat(struct _unmarshal_ctx *ctx, struct lib9p_stat *out) {{ +LM_FLATTEN void _{idprefix}stat_unmarshal(struct _unmarshal_ctx *ctx, struct lib9p_stat *out) {{ \tunmarshal_stat(ctx, out); }} -LM_FLATTEN bool _{idprefix}marshal_stat(struct _marshal_ctx *ctx, struct lib9p_stat *val) {{ +LM_FLATTEN bool _{idprefix}stat_marshal(struct _marshal_ctx *ctx, struct lib9p_stat *val) {{ \treturn marshal_stat(ctx, val); }} """ diff --git a/lib9p/include/lib9p/9p.h b/lib9p/include/lib9p/9p.h index 3d89370..72a8292 100644 --- a/lib9p/include/lib9p/9p.h +++ b/lib9p/include/lib9p/9p.h @@ -130,7 +130,7 @@ bool lib9p_Rmsg_marshal(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *bo /* `struct lib9p_stat` helpers ************************************************/ /** Assert that a `struct lib9p_stat` object looks valid. */ -static inline void lib9p_assert_stat(struct lib9p_stat stat) { +static inline void lib9p_stat_assert(struct lib9p_stat stat) { assert( ((bool)(stat.file_mode & LIB9P_DM_DIR )) == ((bool)(stat.file_qid.type & LIB9P_QT_DIR )) ); assert( ((bool)(stat.file_mode & LIB9P_DM_APPEND )) == ((bool)(stat.file_qid.type & LIB9P_QT_APPEND )) ); assert( ((bool)(stat.file_mode & LIB9P_DM_EXCL )) == ((bool)(stat.file_qid.type & LIB9P_QT_EXCL )) ); @@ -144,10 +144,10 @@ static inline void lib9p_assert_stat(struct lib9p_stat stat) { * TODO * * @return ret_net_size: number of bytes consumed; <=net_size - * @return ret_host_size: number of bytes that lib9p_unmarshal_stat would take + * @return ret_host_size: number of bytes that lib9p_stat_unmarshal would take * @return whether there was an error */ -bool lib9p_validate_stat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes, +bool lib9p_stat_validate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes, uint32_t *ret_net_size, ssize_t *ret_host_size); /** @@ -157,14 +157,14 @@ bool lib9p_validate_stat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_ * @return ret_extra : where to put strings for the stat object * @return consumed net_bytes */ -uint32_t lib9p_unmarshal_stat(struct lib9p_ctx *ctx, uint8_t *net_bytes, +uint32_t lib9p_stat_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes, struct lib9p_stat *ret_obj, void *ret_extra); /** * @return ret_bytes: the buffer to encode into * @return the number of bytes written, or 0 if the stat object does not fit in max_net_size */ -uint32_t lib9p_marshal_stat(struct lib9p_ctx *ctx, uint32_t max_net_size, struct lib9p_stat *obj, +uint32_t lib9p_stat_marshal(struct lib9p_ctx *ctx, uint32_t max_net_size, struct lib9p_stat *obj, uint8_t *ret_bytes); #endif /* _LIB9P_9P_H_ */ diff --git a/lib9p/internal.h b/lib9p/internal.h index 5f49131..57d61cb 100644 --- a/lib9p/internal.h +++ b/lib9p/internal.h @@ -91,9 +91,9 @@ extern const struct _lib9p_recv_tentry _lib9p_table_Rmsg_recv[LIB9P_VER_NUM][0x8 extern const struct _lib9p_send_tentry _lib9p_table_Tmsg_send[LIB9P_VER_NUM][0x80]; extern const struct _lib9p_send_tentry _lib9p_table_Rmsg_send[LIB9P_VER_NUM][0x80]; -bool _lib9p_validate_stat(struct _validate_ctx *ctx); -void _lib9p_unmarshal_stat(struct _unmarshal_ctx *ctx, struct lib9p_stat *out); -bool _lib9p_marshal_stat(struct _marshal_ctx *ctx, struct lib9p_stat *val); +bool _lib9p_stat_validate(struct _validate_ctx *ctx); +void _lib9p_stat_unmarshal(struct _unmarshal_ctx *ctx, struct lib9p_stat *out); +bool _lib9p_stat_marshal(struct _marshal_ctx *ctx, struct lib9p_stat *val); /* unmarshal utilities ********************************************************/ diff --git a/lib9p/srv.c b/lib9p/srv.c index f98db67..e7fdb03 100644 --- a/lib9p/srv.c +++ b/lib9p/srv.c @@ -599,7 +599,7 @@ static void handle_Tattach(struct _lib9p_srv_req *ctx, &(struct lib9p_msg_Rclunk){}); return; } - lib9p_assert_stat(stat); + lib9p_stat_assert(stat); assert(stat.file_mode & LIB9P_DM_DIR); @@ -670,7 +670,7 @@ static void handle_Twalk(struct _lib9p_srv_req *ctx, util_release(&ctx->ctx, member); /* presumption of taking ref-A failed */ break; } - lib9p_assert_stat(stat); + lib9p_stat_assert(stat); isdir = stat.file_mode & LIB9P_DM_DIR; if (isdir && !util_check_perm(&ctx->ctx, &stat, 0b001)) { lib9p_error(&ctx->ctx.basectx, @@ -745,7 +745,7 @@ static void handle_Topen(struct _lib9p_srv_req *ctx, struct lib9p_stat parent_stat = VCALL(file->_parent_dir, stat, &ctx->ctx); if (lib9p_ctx_has_error(&ctx->ctx.basectx)) return; - lib9p_assert_stat(parent_stat); + lib9p_stat_assert(parent_stat); if (!util_check_perm(&ctx->ctx, &parent_stat, 0b010)) { lib9p_error(&ctx->ctx.basectx, LINUX_EACCES, "permission denied to remove-on-close"); @@ -756,7 +756,7 @@ static void handle_Topen(struct _lib9p_srv_req *ctx, struct lib9p_stat stat = VCALL(file, stat, &ctx->ctx); if (lib9p_ctx_has_error(&ctx->ctx.basectx)) return; - lib9p_assert_stat(stat); + lib9p_stat_assert(stat); if (stat.file_mode & LIB9P_QT_APPEND) reqmode = reqmode & ~LIB9P_O_TRUNC; uint8_t perm_bits = 0; @@ -845,7 +845,7 @@ static void handle_Tread(struct _lib9p_srv_req *ctx, uint32_t len = 0; for (size_t i = 0; i < num; i++) { uint32_t i_len; - lib9p_validate_stat(&ctx->ctx.basectx, req->count, &((uint8_t *)resp->data.dat)[len], &i_len, NULL); + lib9p_stat_validate(&ctx->ctx.basectx, req->count, &((uint8_t *)resp->data.dat)[len], &i_len, NULL); len += i_len; } resp->data.len = len; @@ -926,7 +926,7 @@ static void handle_Tstat(struct _lib9p_srv_req *ctx, resp->stat = VCALL(fidinfo->file, stat, &ctx->ctx); if (!lib9p_ctx_has_error(&ctx->ctx.basectx)) - lib9p_assert_stat(resp->stat); + lib9p_stat_assert(resp->stat); } static void handle_Twstat(struct _lib9p_srv_req *ctx, diff --git a/lib9p_util/static.c b/lib9p_util/static.c index 454b57e..62cb147 100644 --- a/lib9p_util/static.c +++ b/lib9p_util/static.c @@ -1,6 +1,6 @@ /* lib9p_util/static.c - Serve static files over 9P * - * Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com> + * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> * SPDX-License-Identifier: AGPL-3.0-or-later */ @@ -97,7 +97,7 @@ static implements_lib9p_srv_file *util9p_static_dir_dopen(implements_lib9p_srv_f struct lib9p_stat stat = VCALL(filep, stat, ctx); if (lib9p_ctx_has_error(&ctx->basectx)) break; - lib9p_assert_stat(stat); + lib9p_stat_assert(stat); if (strcmp(stat.file_name.utf8, childname) == 0) return filep; } @@ -132,8 +132,8 @@ static size_t util9p_static_dir_dread(implements_lib9p_srv_file *_self, struct l struct lib9p_stat stat = VCALL(filep, stat, ctx); if (lib9p_ctx_has_error(&ctx->basectx)) break; - lib9p_assert_stat(stat); - uint32_t nbytes = lib9p_marshal_stat(&ctx->basectx, byte_count-byte_offset, &stat, + lib9p_stat_assert(stat); + uint32_t nbytes = lib9p_stat_marshal(&ctx->basectx, byte_count-byte_offset, &stat, &buf[byte_offset]); if (!nbytes) { if (obj_offset == _obj_offset) |