summaryrefslogtreecommitdiff
path: root/src/cmd/logfs
diff options
context:
space:
mode:
authordzwdz2023-08-14 18:51:07 +0200
committerdzwdz2023-08-14 18:51:07 +0200
commit642b5fb0007b64c77d186fcb018d571152ee1d47 (patch)
tree1c466461f3602d306be309a053edae558ef2568e /src/cmd/logfs
parent8050069c57b729c18c19b1a03ab6e4bf63b4735e (diff)
reorganization: first steps
Diffstat (limited to 'src/cmd/logfs')
-rw-r--r--src/cmd/logfs/logfs.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/cmd/logfs/logfs.c b/src/cmd/logfs/logfs.c
new file mode 100644
index 0000000..a50d530
--- /dev/null
+++ b/src/cmd/logfs/logfs.c
@@ -0,0 +1,34 @@
+#include <camellia.h>
+#include <camellia/syscalls.h>
+#include <err.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <camellia/fs/misc.h>
+
+_Noreturn void fs(void) {
+ const size_t buflen = 1024;
+ char *buf = malloc(buflen);
+ if (!buf) err(1, "malloc");
+ for (;;) {
+ struct ufs_request req;
+ hid_t reqh = ufs_wait(buf, buflen, &req);
+ if (reqh < 0) errx(1, "ufs_wait error");
+
+ switch (req.op) {
+ case VFSOP_OPEN:
+ printf("[logfs] open(\"%s\", 0x%x)\n", buf, req.flags);
+ forward_open(reqh, buf, req.len, req.flags);
+ break;
+ default:
+ /* Unsupported vfs operation.
+ * Currently if you never create your own file descriptors you won't receive
+ * anything but VFSOP_OPEN, but it's idiomatic to handle this anyways. */
+ _sys_fs_respond(reqh, NULL, -1, 0);
+ break;
+ }
+ }
+}
+
+int main(void) {
+ fs();
+}