Go to file
Lykso e2f548895d Implement NodeStatfser interface to allow LUFS to show a "free space" value based on the top layer's filesystem. 2023-07-07 17:03:21 -07:00
fs Implement NodeStatfser interface to allow LUFS to show a "free space" value based on the top layer's filesystem. 2023-07-07 17:03:21 -07:00
.gitignore Initial commit. Seems to work, too, so this may also be the last commit unless there are bugs! 2022-12-13 18:27:25 -08:00
LICENSE Initial commit. Seems to work, too, so this may also be the last commit unless there are bugs! 2022-12-13 18:27:25 -08:00
README.md Add a blurb about using this as a library. 2022-12-22 15:20:26 -08:00
go.mod Add support for extended attribute operations. 2023-02-02 23:23:47 -08:00
go.sum Add support for extended attribute operations. 2023-02-02 23:23:47 -08:00
main.go Enable use as a library. 2023-02-05 13:36:08 -08:00

README.md

lufs

Lykso's Union File System, or lufs, is a fork of the "newunionfs" example from go-fuse. It is a simple implementation of a union filesystem in userspace via FUSE. Files in lower layers are guaranteed to remain in those layers when edited or moved around. New files get created in the topmost layer. Files can be moved between layers at will without causing problems. There is no balancing of files between layers, and there is no "copy-on-write" option. New files are created in the top layer.

Deleting files and directories

  • Deleting regular files only deletes them from the topmost layer containing each file, leaving any same-named files in the layers beneath alone.

  • Deleting directories deletes them from each layer they appear in, starting from the topmost layer, until either the directory has been removed from all layers or the directory removal from a layer fails.

Directories are treated differently because leaving behind a bunch of empty directories across each layer after an rm -rf seemed like it would get annoying quickly. In my use case, files will rarely shadow each other, but directories will almost always have shadows in other layers.

Some programs, such as vim, will, when saving, unlink the original file and create a new file containing the edited contents. To detect this and keep the newly created file in the same layer as the original file whose place it's taking, a record of recently deleted files is kept and any file created at the same path within one second of that path having been unlinked will be written to the layer the deleted file belonged to.

Use as a library

LUFS can also be used as a library to mount a union filesystem from within a program. When used this way, layers can be appended to the bottom of the stack after mounting. LUFS should also be concurrency-safe, though this has not been rigorously tested, much like the rest of this project's codebase at time of writing.