| Crates.io | libfuse-fs |
| lib.rs | libfuse-fs |
| version | 0.1.9 |
| created_at | 2025-03-14 14:32:49.511095+00 |
| updated_at | 2025-12-12 04:02:16.635531+00 |
| description | FUSE Filesystem Library |
| homepage | https://github.com/r2cn-dev/rk8s/tree/main/project/libfuse-fs |
| repository | https://github.com/r2cn-dev/rk8s/tree/main/project/libfuse-fs |
| max_upload_size | |
| id | 1592280 |
| size | 1,533,260 |
A ready-to-use filesystem library based on FUSE (Filesystem in Userspace). This library provides implementations for various filesystem types and makes it easy to develop custom filesystems.
Features:
Asynchronous I/O support
Overlay filesystem implementation
Passthrough filesystem support
Easy-to-use API for custom filesystem development
# run OverlayFS demo
cargo run --example overlay -- -o lowerdir=/usr:/bin,upperdir=/tmp/ovl_upper,workdir=/tmp/ovl_work overlay_test /tmp/ovl_mnt
# run PassthroughFS demo
cargo run --example passthrough -- /tmp/source_dir /tmp/pt_mnt
We provide an integration script that mounts overlayfs and passthroughfs examples, then runs:
Requirements: fio, ior, fuse3 (providing fusermount3), Rust toolchain.
cd project/libfuse-fs
./tests/integration_test.sh
Set WORKDIR=/custom/tmp to control temporary directory. Logs are stored under $WORKDIR/logs.
Workflow file: .github/workflows/libfuse-fs-integration.yml (runs on PR touching this crate).
Example binaries used by the integration tests:
cargo run --example overlayfs -- \
--mountpoint /tmp/ovl_mnt --upperdir /tmp/ovl_upper \
--lowerdir /usr --lowerdir /bin
cargo run --example passthrough -- \
--mountpoint /tmp/pt_mnt --rootdir /var/tmp
For rootless execution of the passthrough filesystem, you need to grant the necessary capabilities to the binary:
# Build the example first
cargo build --example passthrough
# Grant capabilities for rootless operation
sudo setcap cap_dac_read_search+ep ../target/debug/examples/passthrough
This allows the passthrough filesystem to access files with elevated permissions without requiring the entire process to run as root.
This library provides both UnionFS and OverlayFS implementations with significant architectural differences:
UnionFS (src/unionfs/):
BoxedLayer = dyn Layer trait objects for flexible layer compositionObjectSafeFilesystem with #[async_trait] for true async operationsOperationContext for UID/GID overriding during copy-up operationscreate_with_context() - File creation with custom ownershipmkdir_with_context() - Directory creation with custom ownershipsymlink_with_context() - Symlink creation with custom ownershipdo_getattr_helper() - Raw metadata retrieval bypassing ID mappingOverlayFS (src/overlayfs/):
BoxedLayer = PassthroughFs type for better performanceFilesystem without async_trait overhead| Aspect | UnionFS | OverlayFS |
|---|---|---|
| Layer Type | dyn Layer (trait object) |
PassthroughFs (concrete) |
| Trait Bounds | ObjectSafeFilesystem + async_trait |
Filesystem |
| Inode Storage | Arc<BoxedLayer> |
Arc<PassthroughFs> |
| Async Support | Full async trait methods | Standard filesystem methods |
UnionFS Advanced Features:
// Context-aware file creation with custom UID/GID
async fn create_with_context(
&self,
ctx: OperationContext,
parent: Inode,
name: &OsStr,
mode: u32,
flags: u32,
) -> Result<ReplyCreated>
// Helper for metadata bypassing ID mapping
async fn do_getattr_helper(
&self,
inode: Inode,
handle: Option<u64>,
) -> std::io::Result<(libc::stat64, Duration)>
OverlayFS Simplified Approach:
// Basic layer trait with essential overlay operations
pub trait Layer: Filesystem {
fn root_inode(&self) -> Inode;
async fn create_whiteout(...) -> Result<ReplyEntry>;
async fn delete_whiteout(...) -> Result<()>;
async fn set_opaque(...) -> Result<()>;
async fn is_opaque(...) -> Result<bool>;
}
UnionFS:
OverlayFS:
Choose UnionFS when:
Choose OverlayFS when:
All commits must be signed (git commit -s) and GPG signed (-S) per project policy.
See the CHANGELOG for version history.