A small FUSE filesystem in Rust with metadata in JSON and file contents in local blob files. Code for the post Building a Tiny FUSE Filesystem.
magicfs mounts a directory where normal tools like ls, cat, echo, mv, and rm work, while the backing store is just metadata plus local blob files named by allocated IDs:
/tmp/magicfs-store/
metadata.json
blobs/
7f/7f83...
docker run -it --rm --device /dev/fuse --cap-add SYS_ADMIN shayonj/magicfsThis drops you into a shell with the filesystem mounted at /magic and the backing store at /tmp/magicfs-store.
sudo apt install fuse3
cargo build --release
mkdir -p /tmp/magic
./target/release/magicfs /tmp/magic /tmp/magicfs-storeThen run commands against /tmp/magic from another terminal. Unmount with fusermount3 -u /tmp/magic.
The program logs the FUSE requests it receives. Writes are staged in memory first:
echo "remember the milk" > /magic/notes.txtOn FLUSH or FSYNC, magicfs writes a new blob and atomically replaces metadata.json. Inspect the store after writing:
cat /tmp/magicfs-store/metadata.json
find /tmp/magicfs-store/blobs -type fmagicfs only has a single root directory, stores each file as one local blob, and uses a one second metadata TTL. It does not implement a journal, multi-client cache invalidation, locking, mmap, xattrs, a full permission model, chunking, background garbage collection, remote backing stores, or recovery for orphaned blobs.