Skip to content

Keep a FUSE 2 code path for Windows - #578

Merged
smessmer merged 4 commits into
feature/fuse3from
fix/fuse3-windows-fuse2-path
Sep 6, 2026
Merged

smessmer merged 4 commits into
feature/fuse3from
fix/fuse3-windows-fuse2-path

Conversation

@smessmer

@smessmer smessmer commented Sep 5, 2026

Copy link
Copy Markdown
Member

This is the Windows half of the blocker from the review. The macOS half is a separate pull request; together they cover the platforms the migration broke.

Why Windows needs its own path

Dokany's FUSE wrapper implements FUSE 2.7 and there is no libFUSE 3 version of it. Its dokan_fuse/include/fuse_common.h hardcodes:

#define FUSE_MAJOR_VERSION 2
#define FUSE_MINOR_VERSION 7

getattr has no fuse_file_info, rename has no flags, init has no fuse_config, readdir has no flags and a four-argument filler, fgetattr and ftruncate are still separate operations, and there are no FUSE_CAP_* constants at all. dokany#182, asking for a newer FUSE API, has been open since February 2016 with no maintainer commitment, and the current release, v2.3.1.1000, still ships the 2.7 wrapper.

So unlike macOS, Windows cannot simply move to FUSE 3. Since the sources became FUSE 3 only, every Windows job in the branch's CI fails at build:

windows-2022 / MSVC (job 100906241132)
Fuse.cpp(1170): error C2039: 'want': is not a member of 'fuse_conn_info'
Fuse.cpp(1170): error C2065: 'FUSE_CAP_POSIX_LOCKS': undeclared identifier

This adds the compile-time switch issue #419 asks for, without duplicating any filesystem code.

How it is split

The fspp interface keeps its FUSE 3 shape on both APIs. Fuse::getattr always takes a fuse_file_info, Fuse::rename always takes flags, and so on. Only the wrappers libfuse calls differ, and only where the two APIs genuinely disagree:

Operation FUSE 3 FUSE 2 wrapper
getattr one op with fuse_file_info getattr passes nullptr, fgetattr passes the handle
truncate one op with fuse_file_info truncate passes nullptr, ftruncate passes the handle
rename takes flags passes 0; FUSE 2 never implemented FUSE_RENAME2
chmod, chown, utimens take fuse_file_info pass nullptr
readdir takes flags, five-arg filler passes FUSE_READDIR_DEFAULTS, four-arg filler
init takes fuse_config, negotiates capabilities passes nullptr, negotiates nothing

The getattr/truncate split is the interesting one. It is exactly the fi != NULL dispatch FUSE 3 asks for, written as two entry points instead of one, so both APIs end up calling the same Fuse method with the same information.

params.h picks the API and declares the two FUSE 3 types the fspp interface mentions, fuse_readdir_flags and fuse_config, when they are missing. Nothing outside the wrappers ever looks inside either: the config pointer is unused, and the readdir flags are always FUSE_READDIR_DEFAULTS on an API with no readdirplus.

stat_compatibility.h now goes through params.h instead of including <fuse.h> directly, so FUSE_USE_VERSION is set whichever of the two headers a translation unit includes first.

Verification

Windows cannot be built here, so the real src/fspp/fuse/Fuse.cpp was compiled against Dokany's own dokan_fuse headers, fetched from dokan-dev/dokany at master. That works on Linux because Dokany's fuse.h maps FUSE_STAT and FUSE_OFF_T to the platform types when _WIN32 is not defined:

#ifdef _WIN32
#include "fuse_win.h"
#else
#define FUSE_OFF_T off_t
#define FUSE_STAT stat
#endif
Translation unit GCC Clang
src/fspp/fuse/Fuse.cpp against Dokany headers clean clean
Fuse.h + stat_compatibility.h against Dokany headers clean clean

This checks the whole FUSE 2 path, including the operations table, the wrapper signatures and the guarded filler and init bodies. It does not check the MSVC-specific and Dokan-API-specific blocks, but those are separately guarded on _MSC_VER and are unchanged by this pull request.

Linux is unaffected. fspp-test still passes 1007 tests.

Note on overlap

The macOS pull request also rewrites params.h, so whichever of the two lands second will need a trivial merge there. I am watching both and will do it.

🤖 Generated with Claude Code

https://claude.ai/code/session_015ErTwCwE5TPLj5VL3PDKhP


Generated by Claude Code

Dokany's FUSE wrapper implements FUSE 2.7 and there is no libFUSE 3 version
of it, so the Windows build cannot use the FUSE 3 API. Its
dokan_fuse/include/fuse_common.h hardcodes FUSE_MAJOR_VERSION 2 and
FUSE_MINOR_VERSION 7, getattr has no fuse_file_info, rename has no flags,
init has no fuse_config, readdir has no flags and a four argument filler,
and there are no FUSE_CAP_* constants at all. dokan-dev/dokany#182, asking
for a newer FUSE API, has been open since 2016. Since the sources became
FUSE 3 only, every Windows job in CI fails at build:

    Fuse.cpp(1170): error C2039: 'want': is not a member of 'fuse_conn_info'
    Fuse.cpp(1170): error C2065: 'FUSE_CAP_POSIX_LOCKS': undeclared identifier

This adds the compile-time switch issue #419 asks for, without duplicating
the file system code.

The fspp interface keeps its FUSE 3 shape on both APIs: Fuse::getattr always
takes a fuse_file_info, Fuse::rename always takes flags, and so on. Only the
wrappers that libfuse calls differ, and only where the two APIs actually
disagree:

- getattr and truncate split back into getattr/fgetattr and
  truncate/ftruncate, both pairs calling the same Fuse method with and
  without the handle. That is exactly the dispatch FUSE 3 asks for, written
  as two entry points.
- rename, chmod, chown and utimens lose the parameter FUSE 3 added, and pass
  0 or nullptr for it. FUSE 2 never implemented FUSE_RENAME2, so a flagged
  rename never reaches the file system there.
- readdir loses the flags parameter and calls the four argument filler.
- init has no fuse_config, and no capability negotiation, because Dokany has
  neither conn->want nor any FUSE_CAP_* constant.

params.h picks the API and declares the two FUSE 3 types the fspp interface
mentions, fuse_readdir_flags and fuse_config, when they are missing. Nothing
outside the wrappers looks inside either: the config pointer is unused and
the readdir flags are always FUSE_READDIR_DEFAULTS on FUSE 2.

stat_compatibility.h now goes through params.h instead of including <fuse.h>
directly, so FUSE_USE_VERSION is set no matter which header is included
first.

Windows cannot be built here, so this was verified by compiling the real
src/fspp/fuse/Fuse.cpp against Dokany's own dokan_fuse headers with both GCC
and Clang, which works because Dokany's fuse.h maps FUSE_STAT and FUSE_OFF_T
to the platform types when _WIN32 isn't defined. Both compile it clean, as
do Fuse.h and stat_compatibility.h on their own. The MSVC and Dokan API
specific blocks are separately guarded on _MSC_VER and are unchanged.

Linux is unaffected: fspp-test still passes 1007 tests.

macOS is a separate change, see the macFUSE pull request. Both touch
params.h, so whichever lands second needs a trivial merge there.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015ErTwCwE5TPLj5VL3PDKhP

smessmer commented Sep 5, 2026

Copy link
Copy Markdown
Member Author

The merge with #577 is trivial, and I have verified it rather than just asserting it.

The two changes nest: _MSC_VER picks the API on the outside, __APPLE__ picks the Darwin extensions inside the non-Windows branch, and the #error guard and the FUSE 2 type declarations sit side by side after the include. Resolved locally and then checked all three paths:

Check Result
Linux build and fspp-test passes
Operations table vs macFUSE 3.18.2 headers, extensions off, GCC and Clang clean
src/fspp/fuse/Fuse.cpp vs Dokany headers, FUSE 2 path, GCC and Clang clean

Note for whoever merges second: #577 adds an #error that fires when a FUSE 2 header is used, exempt on _MSC_VER. That exemption is what keeps this PR's Windows path working, and it also means the Dokany check above cannot be run on Linux without neutralising the guard, since _MSC_VER cannot be set here. I did that for the check and confirmed nothing else in the merged file breaks.

#577 also now carries the libFUSE version floor and the FUSE_USE_VERSION correction, which touch the same two files. Nothing in there conflicts with this PR either.


Generated by Claude Code

…ndows-fuse2-path

The base branch gained Capabilities.cpp, which uses FUSE_CAP_* constants that
Dokany's FUSE 2.7 headers don't have. Guard it the same way as the rest of the
FUSE 3 only code, and keep the capability negotiation in Fuse::init() inside the
FUSE_MAJOR_VERSION check.

Co-Authored-By: Claude <[email protected]>
Claude-Session: https://claude.ai/code/session_015ErTwCwE5TPLj5VL3PDKhP
…s-fuse2-path

#576 added the is_null_path() helper at the top of the anonymous namespace in
Fuse.cpp, which is exactly where this branch opens its
#if FUSE_MAJOR_VERSION >= 3 for the getattr/fgetattr split, so the two collided.

Resolved by nesting rather than choosing: is_null_path() stays before the guard.
It has to, because seven of its fifteen call sites (open, read, write, flush,
release, fsync, readdir and friends) are in operations that are compiled on both
the FUSE 2 and the FUSE 3 path, so defining it inside the guard would not compile
on Windows.

The FUSE 2 branches deliberately do not get the null-path guard. libfuse only
passes a null path when the file system sets nullpath_ok, and Dokany's wrapper -
FUSE_MAJOR_VERSION 2, FUSE_MINOR_VERSION 7 - has no such member: grepping its
headers for nullpath_ok and flag_nullpath_ok finds nothing, while upstream
libfuse 2.9.9 has flag_nullpath_ok and 3.9.0 has nullpath_ok. There is no way for
a null path to arrive on the Dokany path, so guarding there would add dead code.

Co-Authored-By: Claude <[email protected]>
Claude-Session: https://claude.ai/code/session_015ErTwCwE5TPLj5VL3PDKhP
@smessmer
smessmer merged commit 8606df4 into feature/fuse3 Sep 6, 2026
6 of 260 checks passed
@smessmer
smessmer deleted the fix/fuse3-windows-fuse2-path branch September 6, 2026 19:41
smessmer pushed a commit that referenced this pull request Sep 6, 2026
…support

#578 landed first, so this is the params.h merge I said in the pull request I
would do. Both changes rewrite the same few lines for opposite reasons: #578
selects the FUSE 2 API because Dokany's wrapper has no libFUSE 3 counterpart,
this branch selects FUSE 3 and turns macFUSE's Darwin extensions off.

They nest rather than compete. _MSC_VER picks the API on the outside; __APPLE__
picks the extensions inside the non-Windows branch, so the Darwin define can
only be reached on a build that already chose FUSE 3.

The second hunk keeps both guards as independent blocks instead of one chain,
because they answer different questions: a FUSE 2 header off Windows is a
misconfiguration and still gets the #error, while a FUSE 2 header on Windows is
expected and gets the fuse_readdir_flags and fuse_config declarations.

Verified by preprocessing the resolved header against real headers:
  Linux, libfuse 3.14        -> 39, no Darwin define, no error
  macOS, macFUSE 3.18        -> 39, FUSE_DARWIN_ENABLE_EXTENSIONS 0
  non-MSVC + a FUSE 2 header -> #error fires
  MSVC + Dokany's headers    -> 27, no error, both types declared

Co-Authored-By: Claude <[email protected]>
Claude-Session: https://claude.ai/code/session_015ErTwCwE5TPLj5VL3PDKhP
smessmer added a commit that referenced this pull request Sep 7, 2026
Dokany's FUSE wrapper implements FUSE 2.7 and there is no libFUSE 3 version
of it, so the Windows build cannot use the FUSE 3 API. Its
dokan_fuse/include/fuse_common.h hardcodes FUSE_MAJOR_VERSION 2 and
FUSE_MINOR_VERSION 7, getattr has no fuse_file_info, rename has no flags,
init has no fuse_config, readdir has no flags and a four argument filler,
and there are no FUSE_CAP_* constants at all. dokan-dev/dokany#182, asking
for a newer FUSE API, has been open since 2016. Since the sources became
FUSE 3 only, every Windows job in CI fails at build:

    Fuse.cpp(1170): error C2039: 'want': is not a member of 'fuse_conn_info'
    Fuse.cpp(1170): error C2065: 'FUSE_CAP_POSIX_LOCKS': undeclared identifier

This adds the compile-time switch issue #419 asks for, without duplicating
the file system code.

The fspp interface keeps its FUSE 3 shape on both APIs: Fuse::getattr always
takes a fuse_file_info, Fuse::rename always takes flags, and so on. Only the
wrappers that libfuse calls differ, and only where the two APIs actually
disagree:

- getattr and truncate split back into getattr/fgetattr and
  truncate/ftruncate, both pairs calling the same Fuse method with and
  without the handle. That is exactly the dispatch FUSE 3 asks for, written
  as two entry points.
- rename, chmod, chown and utimens lose the parameter FUSE 3 added, and pass
  0 or nullptr for it. FUSE 2 never implemented FUSE_RENAME2, so a flagged
  rename never reaches the file system there.
- readdir loses the flags parameter and calls the four argument filler.
- init has no fuse_config, and no capability negotiation, because Dokany has
  neither conn->want nor any FUSE_CAP_* constant.

params.h picks the API and declares the two FUSE 3 types the fspp interface
mentions, fuse_readdir_flags and fuse_config, when they are missing. Nothing
outside the wrappers looks inside either: the config pointer is unused and
the readdir flags are always FUSE_READDIR_DEFAULTS on FUSE 2.

stat_compatibility.h now goes through params.h instead of including <fuse.h>
directly, so FUSE_USE_VERSION is set no matter which header is included
first.

Windows cannot be built here, so this was verified by compiling the real
src/fspp/fuse/Fuse.cpp against Dokany's own dokan_fuse headers with both GCC
and Clang, which works because Dokany's fuse.h maps FUSE_STAT and FUSE_OFF_T
to the platform types when _WIN32 isn't defined. Both compile it clean, as
do Fuse.h and stat_compatibility.h on their own. The MSVC and Dokan API
specific blocks are separately guarded on _MSC_VER and are unchanged.

Linux is unaffected: fspp-test still passes 1007 tests.

macOS is a separate change, see the macFUSE pull request. Both touch
params.h, so whichever lands second needs a trivial merge there.


Claude-Session: https://claude.ai/code/session_015ErTwCwE5TPLj5VL3PDKhP

Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants