Skip to content

Latest commit

History

20 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

FuseSharp

FuseSharp is a FUSE binding for macOS (macFUSE) written in modern C#. It provides a clean API designed specifically to enable the development of userspace filesystems in .NET applications.

Note: This fork is a complete rewrite of the original FuseSharp for .NET 10. It binds directly against macFUSE's FUSE 2.x compatibility library (/usr/local/lib/libfuse.2.dylib) using LibraryImport and [UnmanagedCallersOnly] function pointers. The original native Adaptor shim, the Mono.Posix dependency, and the delegate-based marshaling layer have been removed entirely - no native components need to be built or shipped alongside the managed assembly, and both osx-arm64 and osx-x64 are supported.

Requirements

  • macOS with macFUSE installed
  • .NET 10 or later

Usage

Derive from FuseFileSystemBase and override the operations your filesystem supports. Only overridden callbacks are registered with FUSE; everything else is reported to the kernel as not implemented.

usingFuseSharp;usingFuseSharp.Native;sealedclassMyFileSystem:FuseFileSystemBase{publicoverrideboolSupportsMultiThreading=>true;publicoverrideintGetAttr(ReadOnlySpan<byte>path,refStatstat,FuseFileInfoReffiRef){if(!path.SequenceEqual(RootPath))return-LibC.ENOENT;stat.st_mode=(ushort)(LibC.S_IFDIR|0x1ED);// drwxr-xr-xstat.st_nlink=2;return0;}publicoverrideintReadDir(ReadOnlySpan<byte>path,ulongoffset,DirectoryContentcontent,refFuseFileInfofi){content.AddEntry(".");content.AddEntry("..");return0;}}

Mount and unmount:

if(!Fuse.CheckDependencies())thrownewInvalidOperationException("macFUSE is not installed.");IFuseMountmount=Fuse.Mount("/path/to/mountpoint",newMyFileSystem(),newMountOptions(){Options="default_permissions,volname=MyVolume"});// ... the filesystem is served on a background thread ...boolunmounted=awaitmount.UnmountAsync(force:true);

Project overview

ComponentPurpose
FuseFileSystemBaseThe abstract base class filesystem implementations derive from. Callbacks receive UTF-8 paths as spans and return 0 or a negated Darwin errno.
FuseStatic entry point: CheckDependencies, Mount, LazyUnmount.
IFuseMountA handle to a mounted filesystem with UnmountAsync.
Native/LibFuseLibraryImport bindings for libfuse.2.dylib (fuse_mount, fuse_new, fuse_loop_mt, ...).
Native/LibCDarwin libSystem bindings and POSIX constants (errno values, open flags, xattr, ...).
Native/FuseOperationsA blittable mirror of macFUSE's struct fuse_operations (FUSE API 26), layout-verified against the installed headers.

Mount options

The MountOptions.Options string is passed to FUSE verbatim (comma-separated). Commonly useful options (see the macFUSE mount options wiki):

OptionDescription
volname=NAMEThe volume name shown in Finder.
fsname=NAMEThe file system name reported by mount.
default_permissionsLet the kernel enforce permissions based on GetAttr results.
allow_other / allow_rootAllow other users (requires the allow_other macFUSE tunable).
roMount read-only.
noappledoubleDo not create AppleDouble (._) companion files.
iosize=NI/O size in bytes (512 bytes - 32 MB, power of 2).
debugPrint FUSE debugging output.

License

See LICENSE. Based on FuseSharp by Códice Software / PlasticSCM.

About

Modern FUSE wrapper written in .NET for macOS

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages