| .clang-format | Add .clang-format | |
| main.c | Add .clang-format | |
| README.md | Add README.md | |
ovlmount
This is an extremely small C utility to mount OverlayFS filesystems. It does not handle anything other than OverlayFS, nor any mount options other than upperdir, workdir and lowerdir. In fact this README is bigger than the source code.
Why?
Good old mount(8) from util-linux should handle this right? Sure, mostly. mount(2) (the syscall) takes in the options (which is where lowerdir is set) as a string limited to PAGE_SIZE, set to 4096 bytes on most systems. Ought to be enough for anybody, I didn't really find anybody complaining online anyway. Except for nihil's purposes the string will overflow after about 50-ish installed packages, since it uses the lowerdir as a way to manage them.
To make things both better and worse util-linux >= 2.39 uses a semi-new fs mounting API where you set mount options using fsconfig(2). (unless you opt out) The string passed to this syscall is limited to 256 chars, or about 2-3 packages for nihil. Something people did complain about (see util-linux issue #2287)
So, a new API for appending lowerdirs one-by-one to the options was added, then temporarily disabled, then added differently, which this utility uses to append lowerdirs passed into argv up to the OVL_MAX_STACK, (arbitrarily?) set to 500.
mount(8) could of course do this too, but the 4096 byte limit of mount(2) seems to, understandably, be enough for most people.
Usage
ovlmount <merged dir> <upper dir> <work dir> <lower dir>...
Compile
$CC main.c -o ovlmount