summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/srv9p/main.c11
-rw-r--r--cmd/srv9p/static.c77
-rw-r--r--cmd/srv9p/static.h8
3 files changed, 59 insertions, 37 deletions
diff --git a/cmd/srv9p/main.c b/cmd/srv9p/main.c
index 6ed4b79..236bf60 100644
--- a/cmd/srv9p/main.c
+++ b/cmd/srv9p/main.c
@@ -19,7 +19,9 @@
#define UNUSED(name) /* name __attribute__((unused)) */
-static struct static_dir_data root = {
+static struct static_dir root = {
+ .header = { .vtable = &static_dir_vtable },
+
.u_name = "root", .u_num = 0, /* owner user */
.g_name = "root", .g_num = 0, /* owner group */
.m_name = "root", .m_num = 0, /* last-modified-by user */
@@ -35,11 +37,8 @@ static struct static_dir_data root = {
},
};
-struct lib9p_srv_file fs_root(struct lib9p_srv_ctx *UNUSED(ctx), char *UNUSED(treename)) {
- return (struct lib9p_srv_file){
- .vtable = static_dir_vtable,
- .impldata = &root,
- };
+struct lib9p_srv_file *fs_root(struct lib9p_srv_ctx *UNUSED(ctx), char *UNUSED(treename)) {
+ return &root.header;
}
int main() {
diff --git a/cmd/srv9p/static.c b/cmd/srv9p/static.c
index f992764..920daf2 100644
--- a/cmd/srv9p/static.c
+++ b/cmd/srv9p/static.c
@@ -4,67 +4,88 @@
#define UNUSED(name) /* name __attribute__((unused)) */
-static struct lib9p_srv_io static_dir_io(struct lib9p_srv_ctx *ctx, void *UNUSED(impl), lib9p_o_t UNUSED(flags)) {
- struct lib9p_srv_io iohandle = {0};
+static struct lib9p_srv_io *static_dir_io(struct lib9p_srv_ctx *ctx, struct lib9p_srv_file *_file, lib9p_o_t UNUSED(flags)) {
+ assert(ctx);
+ struct static_dir *file = (struct static_dir *)_file;
+ assert(file);
+
lib9p_error(&ctx->basectx, LINUX_EFAULT, "TODO: io");
- return iohandle;
+ return NULL;
}
#define p9_str(cstr) ((struct lib9p_s){ .len = strlen(cstr), .utf8 = cstr })
#define p9_nulstr ((struct lib9p_s){ .len = 0, .utf8 = NULL })
-static struct lib9p_stat static_dir_stat(struct lib9p_srv_ctx *UNUSED(ctx), void *_data) {
- struct static_dir_data *data = _data;
- assert(data);
+static struct lib9p_stat static_dir_stat(struct lib9p_srv_ctx *ctx, struct lib9p_srv_file *_file) {
+ assert(ctx);
+ struct static_dir *file = (struct static_dir *)_file;
+ assert(file);
- struct lib9p_stat stat = {
+ return (struct lib9p_stat){
.kern_type = 0,
.kern_dev = 0,
.file_qid = {
.type = LIB9P_QT_DIR,
.vers = 1,
- .path = data->pathnum,
+ .path = file->pathnum,
},
- .file_mode = LIB9P_DM_DIR | (data->perm & 0555),
- .file_atime = data->atime,
- .file_mtime = data->mtime,
+ .file_mode = LIB9P_DM_DIR | (file->perm & 0555),
+ .file_atime = file->atime,
+ .file_mtime = file->mtime,
.file_size = 0,
- .file_name = p9_str(data->name),
- .file_owner_uid = p9_str(data->u_name),
- .file_owner_gid = p9_str(data->g_name),
- .file_last_modified_uid = p9_str(data->m_name),
+ .file_name = p9_str(file->name),
+ .file_owner_uid = p9_str(file->u_name),
+ .file_owner_gid = p9_str(file->g_name),
+ .file_last_modified_uid = p9_str(file->m_name),
.file_extension = p9_nulstr,
- .file_owner_n_uid = data->u_num,
- .file_owner_n_gid = data->g_num,
- .file_last_modified_n_uid = data->m_num,
+ .file_owner_n_uid = file->u_num,
+ .file_owner_n_gid = file->g_num,
+ .file_last_modified_n_uid = file->m_num,
};
- return stat;
}
-static void static_dir_wstat(struct lib9p_srv_ctx *ctx, void *UNUSED(_data),
+static void static_dir_wstat(struct lib9p_srv_ctx *ctx, struct lib9p_srv_file *_file,
struct lib9p_stat UNUSED(new)) {
+ assert(ctx);
+ struct static_dir *file = (struct static_dir *)_file;
+ assert(file);
+
lib9p_error(&ctx->basectx, LINUX_EROFS, "read-only part of filesystem");
}
-static void static_dir_remove(struct lib9p_srv_ctx *ctx, void *UNUSED(_data)) {
+static void static_dir_remove(struct lib9p_srv_ctx *ctx, struct lib9p_srv_file *_file) {
+ assert(ctx);
+ struct static_dir *file = (struct static_dir *)_file;
+ assert(file);
+
lib9p_error(&ctx->basectx, LINUX_EROFS, "read-only part of filesystem");
}
-static void static_dir_free(struct lib9p_srv_ctx *UNUSED(ctx), void *UNUSED(_data)) {}
+static void static_dir_free(struct lib9p_srv_ctx *ctx, struct lib9p_srv_file *_file) {
+ assert(ctx);
+ struct static_dir *file = (struct static_dir *)_file;
+ assert(file);
+}
-static struct lib9p_srv_file static_dir_dopen(struct lib9p_srv_ctx *ctx, void *UNUSED(_data),
+static struct lib9p_srv_file *static_dir_dopen(struct lib9p_srv_ctx *ctx, struct lib9p_srv_file *_dir,
char *UNUSED(childname)) {
- struct lib9p_srv_file file= {0};
+ assert(ctx);
+ struct static_dir *dir = (struct static_dir *)_dir;
+ assert(dir);
+
lib9p_error(&ctx->basectx, LINUX_EFAULT, "TODO: dopen");
- return file;
+ return NULL;
}
-static struct lib9p_srv_file static_dir_dcreate(struct lib9p_srv_ctx *ctx, void *UNUSED(_data),
+static struct lib9p_srv_file *static_dir_dcreate(struct lib9p_srv_ctx *ctx, struct lib9p_srv_file *_dir,
char *UNUSED(childname),
lib9p_dm_t UNUSED(perm), lib9p_o_t UNUSED(flags)) {
- struct lib9p_srv_file file = {0};
+ assert(ctx);
+ struct static_dir *dir = (struct static_dir *)_dir;
+ assert(dir);
+
lib9p_error(&ctx->basectx, LINUX_EROFS, "read-only part of filesystem");
- return file;
+ return NULL;
}
struct lib9p_srv_file_vtable static_dir_vtable = {
diff --git a/cmd/srv9p/static.h b/cmd/srv9p/static.h
index 90bad4b..afb5a3f 100644
--- a/cmd/srv9p/static.h
+++ b/cmd/srv9p/static.h
@@ -3,7 +3,11 @@
#include <lib9p/srv.h>
-struct static_dir_data {
+extern struct lib9p_srv_file_vtable static_dir_vtable;
+
+struct static_dir {
+ struct lib9p_srv_file header;
+
char *u_name;
uint32_t u_num;
char *g_name;
@@ -20,8 +24,6 @@ struct static_dir_data {
struct lib9p_srv_file *members[];
};
-extern struct lib9p_srv_file_vtable static_dir_vtable;
-
//extern struct lib9p_srv_io_dir_vtable static_dir_io_vtable;
#endif /* _STATIC_H_ */