Skip to content

Fix macOS build: adapt getxattr to the Darwin 5-arg signature - #154

Open
moonsoup wants to merge 1 commit into
alperakcan:masterfrom
moonsoup:macos-getxattr-fix
Open

Fix macOS build: adapt getxattr to the Darwin 5-arg signature#154
moonsoup wants to merge 1 commit into
alperakcan:masterfrom
moonsoup:macos-getxattr-fix

Conversation

@moonsoup

@moonsoup moonsoup commented Jul 5, 2026

Copy link
Copy Markdown

On macOS the build currently fails with:

error: incompatible function pointer types initializing
'int (*)(const char *, const char *, char *, size_t, uint32_t)'
with an expression of type 'int (const char *, const char *, char *, size_t)'

macOS FUSE implementations (macFUSE and FUSE-T) declare the getxattr
operation with an extra trailing uint32_t position argument — the Darwin
resource-fork xattr convention — so assigning the shared 4-arg op_getxattr
to .getxattr no longer type-checks. This is the same breakage described in
#143 and blocks compilation on current macOS.

This adds an #ifdef __APPLE__ shim (op_getxattr_darwin) that accepts and
ignores position, then defers to the existing op_getxattr. ext2 has no
resource-fork concept, so dropping position is correct. The non-Darwin build
keeps using the 4-arg op_getxattr unchanged via the #else branch, so Linux
and BSD are unaffected.

Testing

Builds and mounts read-only on macOS 26.5.1 (Apple Silicon, Darwin 25.5.0)
with macFUSE 5.2 and Apple clang. Read-only verification (mount, checksum,
symlink read, write-rejection, byte-identical-after-unmount) passes on ext2,
ext3, and ext4 throwaway images.

Tested in a single environment; I haven't verified other macOS versions, Intel
Macs, or Linux/BSD (the #ifdef is specifically to leave those paths
untouched). Happy to adjust.

macOS FUSE implementations (macFUSE, FUSE-T) declare the getxattr
operation with an extra trailing `uint32_t position` argument — the
Darwin resource-fork xattr convention. Assigning the shared 4-arg
op_getxattr to .getxattr then fails to compile with an
incompatible-function-pointer-type error (ref upstream issue alperakcan#143).

Add an __APPLE__-only shim that accepts and ignores `position` and
defers to the existing op_getxattr. No behavior change on Linux/BSD;
ext2 has no resource-fork concept, so dropping `position` is correct.
The #ifdef keeps the non-Darwin build using the 4-arg op_getxattr
unchanged.

Tested: builds and mounts read-only on macOS 26.5.1 (Apple Silicon,
Darwin 25.5.0), macFUSE 5.2, Apple clang; read-only verification passes
on ext2/ext3/ext4 throwaway images. Single-environment test only;
broader platform testing not yet done.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
moonsoup added a commit to moonsoup/fuse-ext2 that referenced this pull request Jul 5, 2026
Replaces the outdated README (osxfuse references, a 100-line copy-paste
/opt/gnu build script, obscure caveats) with a focused install + usage guide:

- Install via `brew install moonsoup/fuse-ext2/fuse-ext2` (new tap) or from
  source with the macFUSE/e2fsprogs flags that actually work on current macOS.
- Read-only mount usage, incl. the no_default_permissions option for reading
  drives recovered from another machine.
- Points to the upstream PRs (alperakcan#154, alperakcan#155) for the fixes.

Also gitignore autoconf backup junk (config.*~) and CLAUDE.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant