9p server high level API demo added by alaricsp on Mon Oct 1 18:29:31 2012
(use 9p-server-vfs 9p-lolevel tcp srfi-18 posix) ;; A static filesystem (for now) (define filesystem (new-filesystem (+ perm/irusr perm/ixusr perm/irgrp perm/ixgrp perm/iroth perm/ixoth) "root" "root" (current-seconds) (current-seconds) #t)) (insert-static-file! filesystem "hello" (+ perm/irusr perm/irgrp perm/iroth) "root" "root" "root" (current-seconds) (current-seconds) "Hello, World!\n" 0) (define subdir (insert-directory! filesystem "dynamic-content" (+ perm/irusr perm/irgrp perm/iroth perm/ixusr perm/ixgrp perm/ixoth) "root" "root" "root" (current-seconds) (current-seconds) 0)) (insert-simple-file! filesystem "test" (+ perm/irusr perm/irgrp perm/iroth) "root" "root" "root" (current-seconds) (current-seconds) (lambda () (string-append (seconds->string) "\n")) subdir) (parameterize ((tcp-read-timeout #f) (tcp-buffer-size 65536)) (let ((listener (tcp-listen 1564))) (let accept-loop () (receive (in out) (tcp-accept listener) (thread-start! (make-thread (lambda () (vfs-serve in out filesystem) (close-input-port in) (close-output-port out))))) (accept-loop)))) And in the shell: [alaric@ahu trunk]$ sudo mount -t 9p 127.0.0.1 -o port=1564 /mnt [alaric@ahu trunk]$ ls -l /mnt total 1 dr-xr-xr-x 1 4294967294 4294967294 0 Oct 1 17:28 dynamic-content -r--r--r-- 1 4294967294 4294967294 14 Oct 1 17:28 hello [alaric@ahu trunk]$ cat /mnt/hello Hello, World! [alaric@ahu trunk]$ ls -l /mnt/dynamic-content/ total 1 -r--r--r-- 1 4294967294 4294967294 25 Oct 1 17:28 test [alaric@ahu trunk]$ cat /mnt/dynamic-content/test Mon Oct 1 17:29:00 2012 [alaric@ahu trunk]$ sudo umount /mnt