summaryrefslogtreecommitdiff
path: root/lib9p_util
diff options
context:
space:
mode:
Diffstat (limited to 'lib9p_util')
-rw-r--r--lib9p_util/static.c64
1 files changed, 35 insertions, 29 deletions
diff --git a/lib9p_util/static.c b/lib9p_util/static.c
index 7851714..0f0efad 100644
--- a/lib9p_util/static.c
+++ b/lib9p_util/static.c
@@ -12,23 +12,15 @@
/* common *********************************************************************/
-static implements_lib9p_srv_file *util9p_static_common_clone(implements_lib9p_srv_file *_self, struct lib9p_srv_ctx *ctx) {
+static void util9p_static_common_free(implements_lib9p_srv_file *_self) {
_util9p_static_common *self = VCALL_SELF(_util9p_static_common, implements_lib9p_srv_file, _self);
assert(self);
- assert(ctx);
-
- return self;
-}
-
-static void util9p_static_common_free(implements_lib9p_srv_file *_self, struct lib9p_srv_ctx *ctx) {
- _util9p_static_common *self = VCALL_SELF(_util9p_static_common, implements_lib9p_srv_file, _self);
- assert(self);
- assert(ctx);
/* do nothing */
}
-static uint32_t util9p_static_common_io(implements_lib9p_srv_file *_self, struct lib9p_srv_ctx *ctx, lib9p_o_t LM_UNUSED(flags)) {
+static uint32_t util9p_static_common_chio(implements_lib9p_srv_file *_self, struct lib9p_srv_ctx *ctx,
+ bool LM_UNUSED(rd), bool LM_UNUSED(wr), bool LM_UNUSED(trunc)) {
_util9p_static_common *self = VCALL_SELF(_util9p_static_common, implements_lib9p_srv_file, _self);
assert(self);
assert(ctx);
@@ -55,19 +47,26 @@ static void util9p_static_common_remove(implements_lib9p_srv_file *_self, struct
/* dir ************************************************************************/
+static struct lib9p_qid util9p_static_dir_qid(implements_lib9p_srv_file *_self) {
+ struct util9p_static_dir *self = VCALL_SELF(struct util9p_static_dir, implements_lib9p_srv_file, _self);
+ assert(self);
+
+ return (struct lib9p_qid){
+ .type = LIB9P_QT_DIR,
+ .vers = 1,
+ .path = self->pathnum,
+ };
+}
+
static struct lib9p_stat util9p_static_dir_stat(implements_lib9p_srv_file *_self, struct lib9p_srv_ctx *ctx) {
struct util9p_static_dir *self = VCALL_SELF(struct util9p_static_dir, implements_lib9p_srv_file, _self);
assert(self);
assert(ctx);
return (struct lib9p_stat){
- .kern_type = 0,
- .kern_dev = 0,
- .file_qid = {
- .type = LIB9P_QT_DIR,
- .vers = 1,
- .path = self->pathnum,
- },
+ .kern_type = 0,
+ .kern_dev = 0,
+ .file_qid = util9p_static_dir_qid(self),
.file_mode = LIB9P_DM_DIR | (self->perm & 0555),
.file_atime = self->atime,
.file_mtime = self->mtime,
@@ -145,10 +144,10 @@ static size_t util9p_static_dir_dread(implements_lib9p_srv_file *_self, struct l
}
struct lib9p_srv_file_vtable util9p_static_dir_vtable = {
- .clone = util9p_static_common_clone,
.free = util9p_static_common_free,
+ .qid = util9p_static_dir_qid,
+ .chio = util9p_static_common_chio,
- .io = util9p_static_common_io,
.stat = util9p_static_dir_stat,
.wstat = util9p_static_common_wstat,
.remove = util9p_static_common_remove,
@@ -172,19 +171,26 @@ static inline size_t util9p_static_file_size(struct util9p_static_file *file) {
return (size_t)((uintptr_t)file->data_end - (uintptr_t)file->data_start);
}
+static struct lib9p_qid util9p_static_file_qid(implements_lib9p_srv_file *_self) {
+ struct util9p_static_file *self = VCALL_SELF(struct util9p_static_file, implements_lib9p_srv_file, _self);
+ assert(self);
+
+ return (struct lib9p_qid){
+ .type = LIB9P_QT_FILE,
+ .vers = 1,
+ .path = self->pathnum,
+ };
+}
+
static struct lib9p_stat util9p_static_file_stat(implements_lib9p_srv_file *_self, struct lib9p_srv_ctx *ctx) {
struct util9p_static_file *self = VCALL_SELF(struct util9p_static_file, implements_lib9p_srv_file, _self);
assert(self);
assert(ctx);
return (struct lib9p_stat){
- .kern_type = 0,
- .kern_dev = 0,
- .file_qid = {
- .type = LIB9P_QT_FILE,
- .vers = 1,
- .path = self->pathnum,
- },
+ .kern_type = 0,
+ .kern_dev = 0,
+ .file_qid = util9p_static_file_qid(self),
.file_mode = self->perm & 0444,
.file_atime = self->atime,
.file_mtime = self->mtime,
@@ -225,10 +231,10 @@ static uint32_t util9p_static_file_pread(implements_lib9p_srv_file *_self, struc
}
struct lib9p_srv_file_vtable util9p_static_file_vtable = {
- .clone = util9p_static_common_clone,
.free = util9p_static_common_free,
+ .qid = util9p_static_file_qid,
+ .chio = util9p_static_common_chio,
- .io = util9p_static_common_io,
.stat = util9p_static_file_stat,
.wstat = util9p_static_common_wstat,
.remove = util9p_static_common_remove,