summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/sbc_harness/fs_harness_flash_bin.c23
-rw-r--r--cmd/sbc_harness/fs_harness_uptime_txt.c23
-rw-r--r--lib9p/core_include/lib9p/core.h10
-rw-r--r--lib9p/srv.c51
-rw-r--r--lib9p/srv_include/lib9p/srv.h40
-rw-r--r--lib9p/tests/test_server/fs_flush.c23
-rw-r--r--lib9p/tests/test_server/fs_shutdown.c23
-rw-r--r--lib9p/tests/test_server/fs_whoami.c23
-rw-r--r--lib9p_util/static.c54
9 files changed, 142 insertions, 128 deletions
diff --git a/cmd/sbc_harness/fs_harness_flash_bin.c b/cmd/sbc_harness/fs_harness_flash_bin.c
index fa4069f..5920b85 100644
--- a/cmd/sbc_harness/fs_harness_flash_bin.c
+++ b/cmd/sbc_harness/fs_harness_flash_bin.c
@@ -148,30 +148,25 @@ static struct lib9p_qid flash_file_qid(struct flash_file *self) {
};
}
-static struct lib9p_stat flash_file_stat(struct flash_file *self, struct lib9p_srv_ctx *ctx) {
+static struct lib9p_srv_stat flash_file_stat(struct flash_file *self, struct lib9p_srv_ctx *ctx) {
assert(self);
assert(ctx);
- return (struct lib9p_stat){
- .fstype = 0,
- .fsdev = 0,
+ return (struct lib9p_srv_stat){
.qid = flash_file_qid(self),
.mode = LIB9P_DM_EXCL|0666,
- .atime = UTIL9P_ATIME,
- .mtime = UTIL9P_MTIME,
- .length = DATA_SIZE,
+ .atime_sec = UTIL9P_ATIME,
+ .mtime_sec = UTIL9P_MTIME,
+ .size = DATA_SIZE,
.name = lib9p_str(self->name),
- .owner_uname = lib9p_str("root"),
- .owner_unum = 0,
- .owner_gname = lib9p_str("root"),
- .owner_gnum = 0,
- .last_modifier_uname = lib9p_str("root"),
- .last_modifier_unum = 0,
+ .owner_uid = { .name = lib9p_str("root"), .num = 0 },
+ .owner_gid = { .name = lib9p_str("root"), .num = 0 },
+ .last_modifier_uid = { .name = lib9p_str("root"), .num = 0 },
.extension = lib9p_str(NULL),
};
}
static void flash_file_wstat(struct flash_file *self, struct lib9p_srv_ctx *ctx,
- struct lib9p_stat) {
+ struct lib9p_srv_stat) {
assert(self);
assert(ctx);
diff --git a/cmd/sbc_harness/fs_harness_uptime_txt.c b/cmd/sbc_harness/fs_harness_uptime_txt.c
index bfe1d98..f7b755f 100644
--- a/cmd/sbc_harness/fs_harness_uptime_txt.c
+++ b/cmd/sbc_harness/fs_harness_uptime_txt.c
@@ -38,7 +38,7 @@ static struct lib9p_qid uptime_file_qid(struct uptime_file *self) {
};
}
-static struct lib9p_stat uptime_file_stat(struct uptime_file *self, struct lib9p_srv_ctx *ctx) {
+static struct lib9p_srv_stat uptime_file_stat(struct uptime_file *self, struct lib9p_srv_ctx *ctx) {
assert(self);
assert(ctx);
@@ -52,26 +52,21 @@ static struct lib9p_stat uptime_file_stat(struct uptime_file *self, struct lib9p
size++;
size += 3;
- return (struct lib9p_stat){
- .fstype = 0,
- .fsdev = 0,
+ return (struct lib9p_srv_stat){
.qid = uptime_file_qid(self),
.mode = 0444,
- .atime = UTIL9P_ATIME,
- .mtime = UTIL9P_MTIME,
- .length = size,
+ .atime_sec = UTIL9P_ATIME,
+ .mtime_sec = UTIL9P_MTIME,
+ .size = size,
.name = lib9p_str(self->name),
- .owner_uname = lib9p_str("root"),
- .owner_unum = 0,
- .owner_gname = lib9p_str("root"),
- .owner_gnum = 0,
- .last_modifier_uname = lib9p_str("root"),
- .last_modifier_unum = 0,
+ .owner_uid = { .name = lib9p_str("root"), .num = 0 },
+ .owner_gid = { .name = lib9p_str("root"), .num = 0 },
+ .last_modifier_uid = { .name = lib9p_str("root"), .num = 0 },
.extension = lib9p_str(NULL),
};
}
static void uptime_file_wstat(struct uptime_file *self, struct lib9p_srv_ctx *ctx,
- struct lib9p_stat) {
+ struct lib9p_srv_stat) {
assert(self);
assert(ctx);
diff --git a/lib9p/core_include/lib9p/core.h b/lib9p/core_include/lib9p/core.h
index a82252b..572c68b 100644
--- a/lib9p/core_include/lib9p/core.h
+++ b/lib9p/core_include/lib9p/core.h
@@ -165,16 +165,6 @@ 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_stat_assert(struct lib9p_stat stat) {
- assert( ((bool)(stat.mode & LIB9P_DM_DIR )) == ((bool)(stat.qid.type & LIB9P_QT_DIR )) );
- assert( ((bool)(stat.mode & LIB9P_DM_APPEND)) == ((bool)(stat.qid.type & LIB9P_QT_APPEND)) );
- assert( ((bool)(stat.mode & LIB9P_DM_EXCL )) == ((bool)(stat.qid.type & LIB9P_QT_EXCL )) );
- assert( ((bool)(stat.mode & LIB9P_DM_AUTH )) == ((bool)(stat.qid.type & LIB9P_QT_AUTH )) );
- assert( ((bool)(stat.mode & LIB9P_DM_TMP )) == ((bool)(stat.qid.type & LIB9P_QT_TMP )) );
- assert( (stat.length == 0) || !(stat.mode & LIB9P_DM_DIR) );
-}
-
/**
* Validate a message's `stat` structure.
*
diff --git a/lib9p/srv.c b/lib9p/srv.c
index 96954aa..fd8e662 100644
--- a/lib9p/srv.c
+++ b/lib9p/srv.c
@@ -165,7 +165,7 @@ static inline enum srv_filetype srv_qid_filetype(struct lib9p_qid qid) {
return SRV_FILETYPE_FILE;
}
-static inline bool srv_check_perm(struct srv_req *ctx, struct lib9p_stat *stat, uint8_t action) {
+static inline bool srv_check_perm(struct srv_req *ctx, struct lib9p_srv_stat *stat, uint8_t action) {
assert(ctx);
assert(stat);
assert(action);
@@ -964,10 +964,10 @@ static void handle_Twalk(struct srv_req *ctx,
}
if (new_pathinfo->type == SRV_FILETYPE_DIR) {
- struct lib9p_stat stat = LO_CALL(new_pathinfo->file, stat, ctx);
+ struct lib9p_srv_stat stat = LO_CALL(new_pathinfo->file, stat, ctx);
if (lib9p_ctx_has_error(&ctx->basectx))
break;
- lib9p_stat_assert(stat);
+ lib9p_srv_stat_assert(stat);
if (!srv_check_perm(ctx, &stat, 0b001)) {
lib9p_error(&ctx->basectx,
LIB9P_ERRNO_L_EACCES, "you do not have execute permission on that directory");
@@ -1033,10 +1033,10 @@ static void handle_Topen(struct srv_req *ctx,
if (reqmode & LIB9P_O_RCLOSE) {
struct srv_pathinfo *parent = map_load(&ctx->parent_sess->paths, pathinfo->parent_dir);
assert(parent);
- struct lib9p_stat parent_stat = LO_CALL(parent->file, stat, ctx);
+ struct lib9p_srv_stat parent_stat = LO_CALL(parent->file, stat, ctx);
if (lib9p_ctx_has_error(&ctx->basectx))
goto topen_return;
- lib9p_stat_assert(parent_stat);
+ lib9p_srv_stat_assert(parent_stat);
if (!srv_check_perm(ctx, &parent_stat, 0b010)) {
lib9p_error(&ctx->basectx,
LIB9P_ERRNO_L_EACCES, "permission denied to remove-on-close");
@@ -1044,10 +1044,10 @@ static void handle_Topen(struct srv_req *ctx,
}
fidflags |= FIDFLAG_RCLOSE;
}
- struct lib9p_stat stat = LO_CALL(pathinfo->file, stat, ctx);
+ struct lib9p_srv_stat stat = LO_CALL(pathinfo->file, stat, ctx);
if (lib9p_ctx_has_error(&ctx->basectx))
goto topen_return;
- lib9p_stat_assert(stat);
+ lib9p_srv_stat_assert(stat);
if ((stat.mode & LIB9P_DM_EXCL) && pathinfo->io_refcount) {
lib9p_error(&ctx->basectx,
LIB9P_ERRNO_L_EEXIST, "exclusive file is already opened");
@@ -1140,6 +1140,26 @@ static void handle_Tcreate(struct srv_req *ctx,
srv_respond(ctx, create, &resp);
}
+static inline struct lib9p_stat srv_stat_to_net_stat(struct lib9p_srv_stat in) {
+ return (struct lib9p_stat){
+ .qid = in.qid,
+ .mode = in.mode,
+ .atime = in.atime_sec,
+ .mtime = in.mtime_sec,
+ .length = in.size,
+ .name = in.name,
+ .owner_uname = in.owner_uid.name,
+ .owner_gname = in.owner_gid.name,
+ .last_modifier_uname = in.last_modifier_uid.name,
+#if CONFIG_9P_ENABLE_9P2000_u
+ .owner_unum = in.owner_uid.num,
+ .owner_gnum = in.owner_gid.num,
+ .last_modifier_unum = in.last_modifier_uid.num,
+ .extension = in.extension,
+#endif
+ };
+}
+
static void handle_Tread(struct srv_req *ctx,
struct lib9p_msg_Tread *req) {
srv_handler_common(ctx, read, req);
@@ -1195,7 +1215,7 @@ static void handle_Tread(struct srv_req *ctx,
}
if (!member_dirent.name.len)
break;
- struct lib9p_stat member_stat;
+ struct lib9p_srv_stat member_stat;
struct srv_pathinfo *member_pathinfo = map_load(&ctx->parent_sess->paths, member_dirent.qid.path);
if (member_pathinfo) {
member_stat = LO_CALL(member_pathinfo->file, stat, ctx);
@@ -1216,8 +1236,9 @@ static void handle_Tread(struct srv_req *ctx,
lib9p_ctx_clear_error(&ctx->basectx);
break;
}
- lib9p_stat_assert(member_stat);
- uint32_t nbytes = lib9p_stat_marshal(&ctx->basectx, req->count-resp.count, &member_stat,
+ lib9p_srv_stat_assert(member_stat);
+ struct lib9p_stat member_netstat = srv_stat_to_net_stat(member_stat);
+ uint32_t nbytes = lib9p_stat_marshal(&ctx->basectx, req->count-resp.count, &member_netstat,
(uint8_t *)&resp.data[resp.count]);
if (!LO_IS_NULL(member_file))
LO_CALL(member_file, free);
@@ -1327,7 +1348,7 @@ static void handle_Tremove(struct srv_req *ctx,
}
struct srv_pathinfo *parent = map_load(&ctx->parent_sess->paths, pathinfo->parent_dir);
assert(parent);
- struct lib9p_stat parent_stat = LO_CALL(parent->file, stat, ctx);
+ 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,
LIB9P_ERRNO_L_EACCES, "you do not have write permission on the parent directory");
@@ -1355,9 +1376,11 @@ static void handle_Tstat(struct srv_req *ctx,
assert(pathinfo);
ctx->user = srv_userid_incref(fidinfo->user);
- resp.stat = LO_CALL(pathinfo->file, stat, ctx);
- if (!lib9p_ctx_has_error(&ctx->basectx))
- lib9p_stat_assert(resp.stat);
+ struct lib9p_srv_stat stat = LO_CALL(pathinfo->file, stat, ctx);
+ if (lib9p_ctx_has_error(&ctx->basectx))
+ goto tstat_return;
+ lib9p_srv_stat_assert(stat);
+ resp.stat = srv_stat_to_net_stat(stat);
tstat_return:
if (ctx->user)
ctx->user = srv_userid_decref(ctx->user);
diff --git a/lib9p/srv_include/lib9p/srv.h b/lib9p/srv_include/lib9p/srv.h
index 1c534e9..c72aff5 100644
--- a/lib9p/srv_include/lib9p/srv.h
+++ b/lib9p/srv_include/lib9p/srv.h
@@ -69,6 +69,42 @@ bool lib9p_srv_flush_requested(struct lib9p_srv_ctx *ctx);
*/
void lib9p_srv_acknowledge_flush(struct lib9p_srv_ctx *ctx);
+/* version-independent stat ***************************************************/
+
+struct lib9p_srv_stat {
+ struct lib9p_qid qid;
+ lib9p_dm_t mode;
+ uint32_t atime_sec; /* BUG: u32 seconds means a 2106 problem */
+#if CONFIG_9P_ENABLE_9P2000_L
+ uint32_t atime_nsec;
+#endif
+ uint32_t mtime_sec; /* BUG: u32 seconds means a 2106 problem */
+#if CONFIG_9P_ENABLE_9P2000_L
+ uint32_t mtime_nsec;
+ uint32_t ctime_sec; /* BUG: u32 seconds means a 2106 problem */
+ uint32_t ctime_nsec;
+ uint32_t btime_sec; /* BUG: u32 seconds means a 2106 problem */
+ uint32_t btime_nsec;
+#endif
+ uint64_t size;
+ struct lib9p_s name;
+ struct lib9p_srv_userid owner_uid;
+ struct lib9p_srv_userid owner_gid;
+ struct lib9p_srv_userid last_modifier_uid;
+#if CONFIG_9P_ENABLE_9P2000_u
+ struct lib9p_s extension;
+#endif
+};
+
+static inline void lib9p_srv_stat_assert(struct lib9p_srv_stat stat) {
+ assert( ((bool)(stat.mode & LIB9P_DM_DIR )) == ((bool)(stat.qid.type & LIB9P_QT_DIR )) );
+ assert( ((bool)(stat.mode & LIB9P_DM_APPEND)) == ((bool)(stat.qid.type & LIB9P_QT_APPEND)) );
+ assert( ((bool)(stat.mode & LIB9P_DM_EXCL )) == ((bool)(stat.qid.type & LIB9P_QT_EXCL )) );
+ assert( ((bool)(stat.mode & LIB9P_DM_AUTH )) == ((bool)(stat.qid.type & LIB9P_QT_AUTH )) );
+ assert( ((bool)(stat.mode & LIB9P_DM_TMP )) == ((bool)(stat.qid.type & LIB9P_QT_TMP )) );
+ assert( (stat.size == 0) || !(stat.mode & LIB9P_DM_DIR) );
+}
+
/* interface definitions ******************************************************/
struct lib9p_srv_dirent {
@@ -110,9 +146,9 @@ lo_interface lib9p_srv_dio;
/* non-"opened" generic I/O *****************************************/ \
\
/** Strings returned from stat() must remain valid until free(). */ \
- LO_FUNC(struct lib9p_stat , stat , struct lib9p_srv_ctx *) \
+ LO_FUNC(struct lib9p_srv_stat , stat , struct lib9p_srv_ctx *) \
LO_FUNC(void , wstat , struct lib9p_srv_ctx *, \
- struct lib9p_stat new) \
+ struct lib9p_srv_stat) \
LO_FUNC(void , remove , struct lib9p_srv_ctx *) \
\
/* non-"opened" directory I/O ***************************************/ \
diff --git a/lib9p/tests/test_server/fs_flush.c b/lib9p/tests/test_server/fs_flush.c
index 821f32d..e6408d7 100644
--- a/lib9p/tests/test_server/fs_flush.c
+++ b/lib9p/tests/test_server/fs_flush.c
@@ -31,28 +31,23 @@ static struct lib9p_qid flush_file_qid(struct flush_file *self) {
};
}
-static struct lib9p_stat flush_file_stat(struct flush_file *self, struct lib9p_srv_ctx *ctx) {
+static struct lib9p_srv_stat flush_file_stat(struct flush_file *self, struct lib9p_srv_ctx *ctx) {
assert(self);
assert(ctx);
- return (struct lib9p_stat){
- .fstype = 0,
- .fsdev = 0,
+ return (struct lib9p_srv_stat){
.qid = flush_file_qid(self),
.mode = 0444,
- .atime = UTIL9P_ATIME,
- .mtime = UTIL9P_MTIME,
- .length = 6,
+ .atime_sec = UTIL9P_ATIME,
+ .mtime_sec = UTIL9P_MTIME,
+ .size = 6,
.name = lib9p_str(self->name),
- .owner_uname = lib9p_str("root"),
- .owner_unum = 0,
- .owner_gname = lib9p_str("root"),
- .owner_gnum = 0,
- .last_modifier_uname = lib9p_str("root"),
- .last_modifier_unum = 0,
+ .owner_uid = { .name = lib9p_str("root"), .num = 0 },
+ .owner_gid = { .name = lib9p_str("root"), .num = 0 },
+ .last_modifier_uid = { .name = lib9p_str("root"), .num = 0 },
.extension = lib9p_str(NULL),
};
}
-static void flush_file_wstat(struct flush_file *self, struct lib9p_srv_ctx *ctx, struct lib9p_stat) {
+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, LIB9P_ERRNO_L_EROFS, "cannot wstat API file");
diff --git a/lib9p/tests/test_server/fs_shutdown.c b/lib9p/tests/test_server/fs_shutdown.c
index 2c3137c..d4ae67e 100644
--- a/lib9p/tests/test_server/fs_shutdown.c
+++ b/lib9p/tests/test_server/fs_shutdown.c
@@ -30,28 +30,23 @@ static struct lib9p_qid shutdown_file_qid(struct shutdown_file *self) {
};
}
-static struct lib9p_stat shutdown_file_stat(struct shutdown_file *self, struct lib9p_srv_ctx *ctx) {
+static struct lib9p_srv_stat shutdown_file_stat(struct shutdown_file *self, struct lib9p_srv_ctx *ctx) {
assert(self);
assert(ctx);
- return (struct lib9p_stat){
- .fstype = 0,
- .fsdev = 0,
+ return (struct lib9p_srv_stat){
.qid = shutdown_file_qid(self),
.mode = 0222 | LIB9P_DM_APPEND,
- .atime = UTIL9P_ATIME,
- .mtime = UTIL9P_MTIME,
- .length = 0,
+ .atime_sec = UTIL9P_ATIME,
+ .mtime_sec = UTIL9P_MTIME,
+ .size = 0,
.name = lib9p_str(self->name),
- .owner_uname = lib9p_str("root"),
- .owner_unum = 0,
- .owner_gname = lib9p_str("root"),
- .owner_gnum = 0,
- .last_modifier_uname = lib9p_str("root"),
- .last_modifier_unum = 0,
+ .owner_uid = { .name=lib9p_str("root"), .num=0 },
+ .owner_gid = { .name=lib9p_str("root"), .num=0 },
+ .last_modifier_uid = { .name=lib9p_str("root"), .num=0 },
.extension = lib9p_str(NULL),
};
}
-static void shutdown_file_wstat(struct shutdown_file *self, struct lib9p_srv_ctx *ctx, struct lib9p_stat) {
+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, LIB9P_ERRNO_L_EROFS, "cannot wstat API file");
diff --git a/lib9p/tests/test_server/fs_whoami.c b/lib9p/tests/test_server/fs_whoami.c
index c493000..8d9752a 100644
--- a/lib9p/tests/test_server/fs_whoami.c
+++ b/lib9p/tests/test_server/fs_whoami.c
@@ -52,29 +52,24 @@ static struct lib9p_qid whoami_file_qid(struct whoami_file *self) {
};
}
-static struct lib9p_stat whoami_file_stat(struct whoami_file *self, struct lib9p_srv_ctx *ctx) {
+static struct lib9p_srv_stat whoami_file_stat(struct whoami_file *self, struct lib9p_srv_ctx *ctx) {
assert(self);
assert(ctx);
- return (struct lib9p_stat){
- .fstype = 0,
- .fsdev = 0,
+ return (struct lib9p_srv_stat){
.qid = whoami_file_qid(self),
.mode = 0444,
- .atime = UTIL9P_ATIME,
- .mtime = UTIL9P_MTIME,
- .length = whoami_len(ctx),
+ .atime_sec = UTIL9P_ATIME,
+ .mtime_sec = UTIL9P_MTIME,
+ .size = whoami_len(ctx),
.name = lib9p_str(self->name),
- .owner_uname = lib9p_str("root"),
- .owner_unum = 0,
- .owner_gname = lib9p_str("root"),
- .owner_gnum = 0,
- .last_modifier_uname = lib9p_str("root"),
- .last_modifier_unum = 0,
+ .owner_uid = { .name=lib9p_str("root"), .num=0 },
+ .owner_gid = { .name=lib9p_str("root"), .num=0 },
+ .last_modifier_uid = { .name=lib9p_str("root"), .num=0 },
.extension = lib9p_str(NULL),
};
}
-static void whoami_file_wstat(struct whoami_file *self, struct lib9p_srv_ctx *ctx, struct lib9p_stat) {
+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, LIB9P_ERRNO_L_EROFS, "cannot wstat API file");
diff --git a/lib9p_util/static.c b/lib9p_util/static.c
index d2413c6..1726319 100644
--- a/lib9p_util/static.c
+++ b/lib9p_util/static.c
@@ -33,30 +33,25 @@ static struct lib9p_qid util9p_static_dir_qid(struct util9p_static_dir *self) {
};
}
-static struct lib9p_stat util9p_static_dir_stat(struct util9p_static_dir *self, struct lib9p_srv_ctx *ctx) {
+static struct lib9p_srv_stat util9p_static_dir_stat(struct util9p_static_dir *self, struct lib9p_srv_ctx *ctx) {
assert(self);
assert(ctx);
- return (struct lib9p_stat){
- .fstype = 0,
- .fsdev = 0,
+ return (struct lib9p_srv_stat){
.qid = util9p_static_dir_qid(self),
.mode = LIB9P_DM_DIR | (self->perm & 0555),
- .atime = self->atime,
- .mtime = self->mtime,
- .length = 0,
+ .atime_sec = self->atime,
+ .mtime_sec = self->mtime,
+ .size = 0,
.name = lib9p_str(self->name),
- .owner_uname = lib9p_str(self->u_name),
- .owner_unum = self->u_num,
- .owner_gname = lib9p_str(self->g_name),
- .owner_gnum = self->g_num,
- .last_modifier_uname = lib9p_str(self->m_name),
- .last_modifier_unum = self->m_num,
+ .owner_uid = { .name = lib9p_str(self->u_name), .num = self->u_num },
+ .owner_gid = { .name = lib9p_str(self->g_name), .num = self->g_num },
+ .last_modifier_uid = { .name = lib9p_str(self->m_name), .num = self->m_num },
.extension = lib9p_str(NULL),
};
}
static void util9p_static_dir_wstat(struct util9p_static_dir *self, struct lib9p_srv_ctx *ctx,
- struct lib9p_stat) {
+ struct lib9p_srv_stat) {
assert(self);
assert(ctx);
@@ -76,10 +71,10 @@ 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_stat stat = LO_CALL(file, stat, ctx);
+ struct lib9p_srv_stat stat = LO_CALL(file, stat, ctx);
if (lib9p_ctx_has_error(&ctx->basectx))
break;
- lib9p_stat_assert(stat);
+ lib9p_srv_stat_assert(stat);
if (lib9p_str_eq(stat.name, childname))
return file;
}
@@ -118,10 +113,10 @@ static struct lib9p_srv_dirent util9p_static_dir_dread(struct util9p_static_dir
if (LO_IS_NULL(file))
return (struct lib9p_srv_dirent){};
- struct lib9p_stat stat = LO_CALL(file, stat, ctx);
+ struct lib9p_srv_stat stat = LO_CALL(file, stat, ctx);
if (lib9p_ctx_has_error(&ctx->basectx))
return (struct lib9p_srv_dirent){};
- lib9p_stat_assert(stat);
+ lib9p_srv_stat_assert(stat);
return (struct lib9p_srv_dirent){
.qid = stat.qid,
@@ -156,30 +151,25 @@ static inline size_t util9p_static_file_size(struct util9p_static_file *file) {
}
-static struct lib9p_stat util9p_static_file_stat(struct util9p_static_file *self, struct lib9p_srv_ctx *ctx) {
+static struct lib9p_srv_stat util9p_static_file_stat(struct util9p_static_file *self, struct lib9p_srv_ctx *ctx) {
assert(self);
assert(ctx);
- return (struct lib9p_stat){
- .fstype = 0,
- .fsdev = 0,
+ return (struct lib9p_srv_stat){
.qid = util9p_static_file_qid(self),
.mode = self->perm & 0444,
- .atime = self->atime,
- .mtime = self->mtime,
- .length = (uint64_t)util9p_static_file_size(self),
+ .atime_sec = self->atime,
+ .mtime_sec = self->mtime,
+ .size = (uint64_t)util9p_static_file_size(self),
.name = lib9p_str(self->name),
- .owner_uname = lib9p_str(self->u_name),
- .owner_unum = self->u_num,
- .owner_gname = lib9p_str(self->g_name),
- .owner_gnum = self->g_num,
- .last_modifier_uname = lib9p_str(self->m_name),
- .last_modifier_unum = self->m_num,
+ .owner_uid = { .name = lib9p_str(self->u_name), .num = self->u_num },
+ .owner_gid = { .name = lib9p_str(self->g_name), .num = self->g_num },
+ .last_modifier_uid = { .name = lib9p_str(self->m_name), .num = self->m_num },
.extension = lib9p_str(NULL),
};
}
static void util9p_static_file_wstat(struct util9p_static_file *self, struct lib9p_srv_ctx *ctx,
- struct lib9p_stat) {
+ struct lib9p_srv_stat) {
assert(self);
assert(ctx);