ref: 26a9021e80a28365768e4649b2c5c2c8331239f7
dir: /test/test.fs/
# 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 prohibited");
w}
# implement a directory listing
/test
ls{
// fprint(2, "test_ls: %d\n", index);
switch (index) {
case 0:
dir->name = estrdup9p("File0");
break;
case 1:
dir->name = estrdup9p("File1");
break;
case 2:
dir->name = estrdup9p("File2");
break;
case 3:
dir->name = estrdup9p("File3");
break;
default:
return -1;
}
dir->uid = estrdup9p("none");
dir->gid = estrdup9p("none");
dir->muid = estrdup9p("none");
return 0;
ls}