summaryrefslogtreecommitdiff
path: root/cmd/srv9p/static.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/srv9p/static.c')
-rw-r--r--cmd/srv9p/static.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/cmd/srv9p/static.c b/cmd/srv9p/static.c
new file mode 100644
index 0000000..f992764
--- /dev/null
+++ b/cmd/srv9p/static.c
@@ -0,0 +1,84 @@
+#include <assert.h>
+
+#include "static.h"
+
+#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};
+ lib9p_error(&ctx->basectx, LINUX_EFAULT, "TODO: io");
+ return iohandle;
+}
+
+#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);
+
+ struct lib9p_stat stat = {
+ .kern_type = 0,
+ .kern_dev = 0,
+ .file_qid = {
+ .type = LIB9P_QT_DIR,
+ .vers = 1,
+ .path = data->pathnum,
+ },
+ .file_mode = LIB9P_DM_DIR | (data->perm & 0555),
+ .file_atime = data->atime,
+ .file_mtime = data->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_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,
+ };
+ return stat;
+}
+
+static void static_dir_wstat(struct lib9p_srv_ctx *ctx, void *UNUSED(_data),
+ struct lib9p_stat UNUSED(new)) {
+ lib9p_error(&ctx->basectx, LINUX_EROFS, "read-only part of filesystem");
+}
+
+static void static_dir_remove(struct lib9p_srv_ctx *ctx, void *UNUSED(_data)) {
+ 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 struct lib9p_srv_file static_dir_dopen(struct lib9p_srv_ctx *ctx, void *UNUSED(_data),
+ char *UNUSED(childname)) {
+ struct lib9p_srv_file file= {0};
+ lib9p_error(&ctx->basectx, LINUX_EFAULT, "TODO: dopen");
+ return file;
+}
+
+static struct lib9p_srv_file static_dir_dcreate(struct lib9p_srv_ctx *ctx, void *UNUSED(_data),
+ char *UNUSED(childname),
+ lib9p_dm_t UNUSED(perm), lib9p_o_t UNUSED(flags)) {
+ struct lib9p_srv_file file = {0};
+ lib9p_error(&ctx->basectx, LINUX_EROFS, "read-only part of filesystem");
+ return file;
+}
+
+struct lib9p_srv_file_vtable static_dir_vtable = {
+ .io = static_dir_io,
+ .stat = static_dir_stat,
+ .wstat = static_dir_wstat,
+ .remove = static_dir_remove,
+ .free = static_dir_free,
+ .dopen = static_dir_dopen,
+ .dcreate = static_dir_dcreate,
+};
+
+/*
+ struct lib9p_srv_io_dir_vtable static_dir_io_vtable = {
+ .readdir = TODO,
+ };
+*/