ref: 3c203e383e93d0ae44263e9f824d66f8e1f7878d
parent: f207de7119046894c031b89fe934aff4a907c969
author: sirjofri <sirjofri@sirjofri.de>
date: Tue Dec 16 10:06:24 EST 2025
adds test example
--- /dev/null
+++ b/test/fns.h
@@ -1,0 +1,1 @@
+Srv *getfs_test(void);
\ No newline at end of file
--- /dev/null
+++ b/test/main.c
@@ -1,0 +1,19 @@
+#include <u.h>
+#include <libc.h>
+#include <thread.h>
+#include <fcall.h>
+#include <9p.h>
+#include "fns.h"
+
+void
+main(int argc, char **argv)
+{+ ARGBEGIN{+ case 'D':
+ chatty9p++;
+ break;
+ }ARGEND;
+ Srv *fs = getfs_test();
+ postmountsrv(fs, nil, "/mnt/fsgen", MREPL);
+ exits(nil);
+}
--- /dev/null
+++ b/test/mkfile
@@ -1,0 +1,11 @@
+</$objtype/mkfile
+
+TARG=t
+OFILES=test.$O main.$O
+HFILES=fns.h
+CLEANFILES=test.c
+
+</sys/src/cmd/mkone
+
+test.c: test.fs
+ ../$O.out test.fs > test.c
--- /dev/null
+++ b/test/test.fs
@@ -1,0 +1,37 @@
+# This is a demo description file for the fsgen filesystem generator.
+# - Lines starting with # are comments
+# - all functions need to be assigned to a file path
+# - file paths have to start with / (root of the mountpoint)
+# - lines enclosed with %{ and %} enclose code that is copied verbatim+# - path parts can be enclosed in {} to make a variable+# - variables can be accessed by name. Prevent collisions with other symbols.
+# - handler functions start with the short name of the handler (see below), followed by {}.+#
+# There are a few handler functions that are available:
+# - read: r{ and r}+# - write: w{ and w}+# - stat: s{ and s}+# - directory listings (not implemented yet)
+#
+# Read through this example to get a better idea.
+#
+
+
+
+%{+#include "fns.h"
+%}
+
+# lines starting with a # are comments.
+
+# you can access /mnt/fsgen/test/bla
+/test/{fname}+r{+ char buf[512];
+ snprint(buf, sizeof buf, "read: %s\n", fname);
+ readstr(r, buf);
+ respond(r, nil);
+r}
+w{+ respond(r, "write");
+w}
--
⑨