summaryrefslogtreecommitdiff
path: root/lib9p/tests
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-02-04 08:57:14 -0700
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-02-09 19:20:07 -0700
commita25ab8432dcf15d7d43adbc429a7cd9b493b3d91 (patch)
tree2a933b3e4451e3d82b8f9a779fe9bf3a9a3cf501 /lib9p/tests
parent4efc7582a255439a574f577272d8be11f6491fe4 (diff)
lib9p: srv: Use a separate pathmap
Diffstat (limited to 'lib9p/tests')
-rwxr-xr-xlib9p/tests/runtest2
-rw-r--r--lib9p/tests/test_server/config/config.h1
-rw-r--r--lib9p/tests/test_server/main.c31
3 files changed, 21 insertions, 13 deletions
diff --git a/lib9p/tests/runtest b/lib9p/tests/runtest
index d963c53..bb83a83 100755
--- a/lib9p/tests/runtest
+++ b/lib9p/tests/runtest
@@ -43,7 +43,7 @@ expect_lines \
out=$("${client[@]}" stat 'Documentation/x')
expect_lines \
- "'x' 'root' 'root' 'root' q (0000000000000009 1 ) m 0444 at 1728337905 mt 1728337904 l 4 t 0 d 0"
+ "'x' 'root' 'root' 'root' q (0000000000000008 1 ) m 0444 at 1728337905 mt 1728337904 l 4 t 0 d 0"
out=$("${client[@]}" write 'shutdown' <<<1)
expect_lines ''
diff --git a/lib9p/tests/test_server/config/config.h b/lib9p/tests/test_server/config/config.h
index ffd549b..d852470 100644
--- a/lib9p/tests/test_server/config/config.h
+++ b/lib9p/tests/test_server/config/config.h
@@ -39,6 +39,7 @@
#define CONFIG_9P_MAX_ERR_SIZE 128 /* 128 is what Plan 9 4e uses */
#define CONFIG_9P_SRV_MAX_FIDS 16
#define CONFIG_9P_SRV_MAX_REQS 2
+#define CONFIG_9P_SRV_MAX_DEPTH 3
#define CONFIG_9P_ENABLE_9P2000 1 /* bool */
#define CONFIG_9P_ENABLE_9P2000_u 1 /* bool */
#define CONFIG_9P_ENABLE_9P2000_e 0 /* bool */
diff --git a/lib9p/tests/test_server/main.c b/lib9p/tests/test_server/main.c
index 71c6cc2..07fc74b 100644
--- a/lib9p/tests/test_server/main.c
+++ b/lib9p/tests/test_server/main.c
@@ -47,23 +47,30 @@ struct api_file {
uint64_t pathnum;
};
-static implements_lib9p_srv_file *api_clone(implements_lib9p_srv_file *self, struct lib9p_srv_ctx *) { return self; }
-static void api_free(implements_lib9p_srv_file *, struct lib9p_srv_ctx *) {}
+static void api_free(implements_lib9p_srv_file *) {}
+static uint32_t api_chio(implements_lib9p_srv_file *, struct lib9p_srv_ctx *, bool, bool, bool) { return 0; }
-static uint32_t api_io(implements_lib9p_srv_file *, struct lib9p_srv_ctx *, lib9p_o_t) { return 0; }
static void api_wstat(implements_lib9p_srv_file *, struct lib9p_srv_ctx *ctx, struct lib9p_stat) { lib9p_error(&ctx->basectx, LINUX_EROFS, "cannot wstat API file"); }
static void api_remove(implements_lib9p_srv_file *, struct lib9p_srv_ctx *ctx) { lib9p_error(&ctx->basectx, LINUX_EROFS, "cannot remove API file"); }
+static struct lib9p_qid api_qid(implements_lib9p_srv_file *_self) {
+ struct api_file *self = VCALL_SELF(struct api_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 api_stat(implements_lib9p_srv_file *_self, struct lib9p_srv_ctx *) {
struct api_file *self = VCALL_SELF(struct api_file, implements_lib9p_srv_file, _self);
+ assert(self);
+
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 = api_qid(self),
.file_mode = 0222,
.file_atime = 1728337905,
.file_mtime = 1728337904,
@@ -87,10 +94,10 @@ static uint32_t api_pwrite(implements_lib9p_srv_file *, struct lib9p_srv_ctx *,
}
static struct lib9p_srv_file_vtable api_file_vtable = {
- .clone = api_clone,
.free = api_free,
+ .qid = api_qid,
+ .chio = api_chio,
- .io = api_io,
.stat = api_stat,
.wstat = api_wstat,
.remove = api_remove,