summaryrefslogtreecommitdiff
path: root/lib9p_util
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-06-27 08:58:41 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-06-27 08:58:41 -0600
commit5a16ac6589817d20749103f45c8d3b4f1eccf784 (patch)
tree59148ec2255d14c184c7920baaae9766dc2c5ade /lib9p_util
parent90f0c59f227b92a046f296865763dc77351782ed (diff)
parent112b4940c76e22606033acf437b00ad3edbd3c9c (diff)
Merge branch 'lukeshu/stack-sizes'HEADmain
Diffstat (limited to 'lib9p_util')
-rw-r--r--lib9p_util/static.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/lib9p_util/static.c b/lib9p_util/static.c
index 53d205f..338e9c9 100644
--- a/lib9p_util/static.c
+++ b/lib9p_util/static.c
@@ -30,11 +30,11 @@ struct lib9p_qid util9p_static_dir_qid(struct util9p_static_dir *self) {
};
}
-lib9p_srv_stat_or_error util9p_static_dir_stat(struct util9p_static_dir *self, struct lib9p_srv_ctx *ctx) {
+error util9p_static_dir_stat(struct util9p_static_dir *self, struct lib9p_srv_ctx *ctx, struct lib9p_srv_stat *out) {
assert(self);
assert(ctx);
- return ERROR_NEW_VAL(lib9p_srv_stat, ((struct lib9p_srv_stat){
+ *out = ((struct lib9p_srv_stat){
.qid = util9p_static_dir_qid(self),
.mode = LIB9P_DM_DIR | (self->c.perm & 0555),
.atime_sec = self->c.atime,
@@ -45,7 +45,8 @@ lib9p_srv_stat_or_error util9p_static_dir_stat(struct util9p_static_dir *self, s
.owner_gid = { .name = lib9p_str(self->c.g_name), .num = self->c.g_num },
.last_modifier_uid = { .name = lib9p_str(self->c.m_name), .num = self->c.m_num },
.extension = lib9p_str(NULL),
- }));
+ });
+ return ERROR_NULL;
}
error util9p_static_dir_wstat(struct util9p_static_dir *self, struct lib9p_srv_ctx *ctx,
struct lib9p_srv_stat) {
@@ -68,11 +69,12 @@ lib9p_srv_file_or_error util9p_static_dir_dwalk(struct util9p_static_dir *self,
for (size_t i = 0; !LO_IS_NULL(self->members[i]); i++) {
lo_interface lib9p_srv_file file = self->members[i];
- lib9p_srv_stat_or_error stat = LO_CALL(file, stat, ctx);
- if (stat.is_err)
- return ERROR_NEW_ERR(lib9p_srv_file, stat.err);
- lib9p_srv_stat_assert(&stat.lib9p_srv_stat);
- if (lib9p_str_eq(stat.lib9p_srv_stat.name, childname))
+ struct lib9p_srv_stat stat;
+ error err = LO_CALL(file, stat, ctx, &stat);
+ if (!ERROR_IS_NULL(err))
+ return ERROR_NEW_ERR(lib9p_srv_file, err);
+ lib9p_srv_stat_assert(&stat);
+ if (lib9p_str_eq(stat.name, childname))
return ERROR_NEW_VAL(lib9p_srv_file, file);
}
return ERROR_NEW_ERR(lib9p_srv_file, error_new(E_POSIX_ENOENT, "no such file or directory"));
@@ -111,14 +113,15 @@ static lib9p_srv_dirent_or_error util9p_static_dio_dread(struct util9p_static_di
if (LO_IS_NULL(file))
return ERROR_NEW_VAL(lib9p_srv_dirent, (struct lib9p_srv_dirent){});
- lib9p_srv_stat_or_error stat = LO_CALL(file, stat, ctx);
- if (stat.is_err)
- return ERROR_NEW_ERR(lib9p_srv_dirent, stat.err);
- lib9p_srv_stat_assert(&stat.lib9p_srv_stat);
+ struct lib9p_srv_stat stat;
+ error err = LO_CALL(file, stat, ctx, &stat);
+ if (!ERROR_IS_NULL(err))
+ return ERROR_NEW_ERR(lib9p_srv_dirent, err);
+ lib9p_srv_stat_assert(&stat);
return ERROR_NEW_VAL(lib9p_srv_dirent, ((struct lib9p_srv_dirent){
- .qid = stat.lib9p_srv_stat.qid,
- .name = stat.lib9p_srv_stat.name,
+ .qid = stat.qid,
+ .name = stat.name,
}));
}
@@ -149,11 +152,12 @@ static inline size_t util9p_static_file_size(struct util9p_static_file *file) {
}
-lib9p_srv_stat_or_error util9p_static_file_stat(struct util9p_static_file *self, struct lib9p_srv_ctx *ctx) {
+error util9p_static_file_stat(struct util9p_static_file *self, struct lib9p_srv_ctx *ctx, struct lib9p_srv_stat *out) {
assert(self);
assert(ctx);
+ assert(out);
- return ERROR_NEW_VAL(lib9p_srv_stat, ((struct lib9p_srv_stat){
+ *out = ((struct lib9p_srv_stat){
.qid = util9p_static_file_qid(self),
.mode = self->c.perm & 0444,
.atime_sec = self->c.atime,
@@ -164,7 +168,8 @@ lib9p_srv_stat_or_error util9p_static_file_stat(struct util9p_static_file *self,
.owner_gid = { .name = lib9p_str(self->c.g_name), .num = self->c.g_num },
.last_modifier_uid = { .name = lib9p_str(self->c.m_name), .num = self->c.m_num },
.extension = lib9p_str(NULL),
- }));
+ });
+ return ERROR_NULL;
}
error util9p_static_file_wstat(struct util9p_static_file *self, struct lib9p_srv_ctx *ctx,
struct lib9p_srv_stat) {