Skip to content

C4-6: Bring the cgofuse implementation to parity with go-fuse #168

Closed

Description

@scttfrdmn

Summary

Bring the cgofuse build to parity with the go-fuse build once the new operations have settled.
cgofuse currently implements fewer operations than the default build, so the Windows and
FUSE-T path is further behind than the documented gap suggests.

Background

internal/fuse/cgofuse_filesystem.go implements: Mount, Unmount, IsMounted, Getattr, Open,
Read, Write, Release, Readdir. It lacks Mkdir and Create, which the go-fuse build has had
all along, on top of everything added in this milestone.

The two implementations are selected by build tag via internal/fuse/platform.go and
platform_cgofuse.go. They share the backend, cache, and buffer, but each wires the FUSE
surface independently — which is how the drift happened and why this needs to be deliberate
work rather than a copy-paste at the end.

Deliberately sequenced last: implementing against the go-fuse semantics before they are settled
would mean porting the same decisions twice.

Implementation

Port Mkdir, Create, Unlink, Rmdir, Rename, Setattr/Truncate, Statfs, Fsync,
and the xattr operations to the cgofuse implementation.

cgofuse differs from go-fuse in ways that matter here:

  • Path-based, not node-based. cgofuse handlers receive full paths where go-fuse receives
    parent node plus name. Path parsing lives in the cgofuse layer.
  • Errno returns. cgofuse returns plain int errno values rather than syscall.Errno,
    and uses its own constants. The error mapping is not shared.
  • Windows semantics. Windows has no uid/gid or POSIX modes in the Unix sense, and xattr
    support is limited. Where the platform cannot honor an operation, return a clear errno rather
    than pretending it succeeded.

Extract the shared logic — key derivation, attribute encoding/decoding, the annotation
capability layer, cache and buffer invalidation — into backend-level helpers both
implementations call, rather than duplicating it. Duplication is what produced the current
drift.

Acceptance Criteria

  • cgofuse implements every operation the go-fuse build implements, including Mkdir and Create
  • Shared logic lives in common helpers, not duplicated per implementation
  • Operations Windows cannot support return a documented errno rather than silently succeeding
  • Attribute and xattr encoding is byte-identical between the two builds — a mount written by
    one reads correctly under the other
  • A parity test enumerates the expected operation set so future drift fails CI
  • go test -race -tags=cgofuse ./internal/fuse/... passes
  • go build -tags=cgofuse ./... passes
  • The supported-operations documentation from C0-9: Correct the POSIX compliance claim in the documentation #162 is updated to reflect parity

Dependencies

Blocked on #163, #164, #165, #166, and #167. Lands last in the milestone.

Activity

  1. added
    type: enhancement
    priority: medium
    area: fuse
    on Jul 30, 2026
  2. scttfrdmn commented on Aug 1, 2026

    @scttfrdmn
    OwnerAuthor

    Closing as moot. The cgofuse implementation was deleted in the v0.10.1 refactor, so there is nothing left to bring to parity.

    Three findings settled it, each verified by execution rather than by reading:

    The cgofuse build tag had never compiled. filesystem.go carried no //go:build constraint of its own while cgofuse_filesystem.go had //go:build cgofuse, so under the tag OpenFile was declared twice. That duplicate-symbol error was masked by a missing fuse.h:

    $ go build -tags=cgofuse ./internal/fuse/
    fatal error: 'fuse.h' file not found
    

    So the parity gap this issue describes was never a gap between two shipping builds. It was a gap between a shipping build and code that could not be built at all.

    Its stated rationale was false. FUSE_MIGRATION.md justified the tag by "macOS compatibility issues" with go-fuse. go-fuse's darwin mount execs /Library/Filesystems/macfuse.fs/Contents/Resources/mount_macfuse (fuse/mount_darwin.go:99) and cgofuse needs the same macFUSE headers — identical macOS requirements. The migration solved nothing it claimed to.

    The drift was worse than documented. Beyond the missing Mkdir and Create this issue names, the 382-line subset never received the Unlink/Rmdir EROFS fix (#163), so under that tag rm reported success while the object survived in S3.

    cgofuse's one genuine advantage is that it cross-compiles for Windows where go-fuse does not:

    $ CGO_ENABLED=0 GOOS=windows go build github.com/hanwen/go-fuse/v2/fs
    internal/fallocate/fallocate.go:8:9: undefined: fallocate
    $ CGO_ENABLED=0 GOOS=windows go build github.com/winfsp/cgofuse/fuse
    (builds)
    

    But nothing verified that a Windows binary could mount anything, and the build-windows Makefile target produced a binary with no working FUSE binding. Windows is now explicitly unsupported: every file in internal/fuse carries //go:build linux || darwin, and a new platform_unsupported.go fails the build for any other GOOS with a message naming the reason, rather than emitting a list of undefined: fuse.PlatformFileSystem errors from internal/adapter that read like a broken build.

    Deleted: cgofuse_filesystem.go, cgofuse_mount.go, cgofuse_test.go, platform_cgofuse.go, the github.com/winfsp/cgofuse dependency, the five *-cgofuse Makefile targets, and FUSE_MIGRATION.md.

    If a second binding is wanted later, this issue's own diagnosis is the right one and is now being acted on. It says the drift happened because "each wires the FUSE surface independently" and asks for shared logic in common helpers. That is internal/vfs — a backend-agnostic POSIX-semantics core owning the attribute model, handle table, dirty-range tracking, and read-modify-write policy, depending on nothing FUSE and returning typed errors rather than syscall.Errno. internal/fuse becomes a translation shim above it (#22-equivalent work, tracked against #165). A Windows or NFS binding would then be a second shim over the same tested core rather than a fork that silently diverges.

    Two alternatives worth their own issues if Windows or kernel-extension-free macOS is ever wanted: NFS loopback via willscott/go-nfs (rclone's macFUSE-free macOS path — no kernel extension, no admin install, weaker POSIX semantics) and macOS FSKit (the strategic answer to macFUSE on modern macOS, but Swift/ObjC-only with no Go bindings). Neither is cgofuse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: fusepriority: mediumtype: enhancement

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions