Lion Cipher Lab
Write a userspace filesystem from scratch with FUSE
- Foundations
- Advanced
- ~90 min
- Free · no account required
Why it matters
A filesystem feels like something only the kernel can do -- deep, privileged, off-limits. FUSE removes that mystery in the most convincing way possible: it lets an ordinary, unprivileged userspace program BE a filesystem. You write a handful of callbacks, mount them at a directory, and from that moment every `ls`, `cat`, and `echo >` that touches that directory is a function call into YOUR code. That is the single clearest way to see the Virtual File System boundary that every Unix program lives on top of. When a process calls read() on a file under your mount, the C library traps into the…
What you'll learn
- the FUSE request path in concrete terms: a process's read()/readdir() -> glibc -> kernel VFS -> /dev/fuse -> your userspace daemon -> back through the same path
- implementing the core VFS callbacks by hand (getattr, readdir, open, read, write, create, unlink, mkdir) against the fusepy Operations interface
- mounting your own filesystem at a directory and watching each ls / cat / echo / mkdir drive a specific one of YOUR functions via a live debug log
- reading errno as a protocol: returning ENOENT from a missing getattr and watching the shell report "No such file or directory"
- why FUSE exists and where it ships (sshfs, s3fs, gocryptfs, rclone mount, fuse-overlayfs) and the performance cost it pays -- extra context switches per operation
- the FUSE security model: unprivileged mounts, running the daemon as a normal user, and why allow_other is a footgun you must opt into deliberately
- recovering a wedged mount: a crashed daemon leaves the mountpoint hung until you fusermount -u it
- the judgment of when FUSE beats a real kernel filesystem, and when to move to pyfuse3's low-level async API or C libfuse for performance
Steps in this lab
- What FUSE is, and the exact path a request takes
- Why this exists -- and where it already runs on your machines
- Set up: one scratch folder, FUSE, and fusepy
- Write the read side: getattr, readdir, open, read
- Add the write side: create, write, truncate, unlink, mkdir
- Mount it and watch your code service every request
- Unmount cleanly -- and see a wedged mount
- The judgment: security, performance, and when NOT to use FUSE