Skip to contentSkip to conversation

fix up issues from djwong/fuse4fs-fork

PATCH In review Theodore Ts'o 2 participants 24 messages May 4 – May 6

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover fix up issues from djwong/fuse4fs-fork

These are the patches that I've applied to the next branch to clean up found when trying to compile e2fsprogs on MacOS and via the github's continuous integration testing.

Note: See .github/workflows/ci.yaml; it's a good reason to get a github account if you are doing a lot of e2fsprogs development. If you fork my e2fsprogs repository and push your changes to your github repo, you can get reports like the ones found here:
https://github.com/tytso/e2fsprogs/actions

Anyway, with these patches, e2fsprogs builds on MacOS (both using the github CI and on locally on my Macbook). Unfortunately fuse2fs has regressed in that non-root accesses are getting denied with a permission denied on MacOS, and this worked with e2fsprogs v1.47.4. Here's a lightly edited transcript from my Macbook Air:

% uname -a
Darwin macsyma.local 25.4.0 Darwin Kernel Version 25.4.0: Thu Mar 19 19:33:09 PDT 2026; root:xnu-12377.101.15~1/RELEASE_ARM64_T8112 arm64 arm Darwin % ./mke2fs -Fq -t ext4 -d . /tmp/foo.img 1G
% ./fuse2fs -o allow_other /tmp/foo.img /Users/tytso/mnt
FUSE2FS (foo.img): Warning: fuse2fs does not support using the journal.
There may be file system corruption or data loss if
the file system is not gracefully unmounted.
% stat /Users/tytso/mnt/revoke.o
stat: cannot stat '/Users/tytso/mnt/revoke.o': Permission denied
% sudo stat /Users/tytso/mnt/revoke.o
File: /Users/tytso/mnt/revoke.o
Size: 29728 Blocks: 64 IO Block: 16384 regular file
Device: 55,270 Inode: 91 Links: 1
Access: (0644/-rw-r--r--) Uid: (15806/ tytso) Gid: ( 20/ staff)
Access: 2026-05-05 00:21:50.000000000 +0200
Modify: 2026-05-05 00:21:50.000000000 +0200
Change: 2026-05-05 00:21:50.000000000 +0200
Birth: -
% stat revoke.o
File: revoke.o
Size: 29728 Blocks: 64 IO Block: 4096 regular file
Device: 1,18 Inode: 851374 Links: 1
Access: (0644/-rw-r--r--) Uid: (15806/ tytso) Gid: ( 20/ staff)
Access: 2026-05-05 00:21:50.903084819 +0200
Modify: 2026-05-05 00:21:50.346338295 +0200
Change: 2026-05-05 00:21:50.346580544 +0200
Birth: 2026-05-05 00:21:50.293229053 +0200
% sum revoke.o
45116 30 revoke.o
% sum /Users/tytso/mnt/revoke.o
sum: /Users/tytso/mnt/revoke.o: Permission denied

So fuse2fs is broken on MacOS, but it's not *totally* broken, since you can still use it as root. I'll want to fix this before updating the master branch, but this is good enough for the next branch.

Theodore Ts'o (7):
libsupport: drop xbitops.h and define fls() if necessary configure.ac: fix disable fuse2fs/fuse4fs by default path
libsupport: don't use bzero in cache.c
fuse[24]fs: suppress clang warnings which were breaking the github CI
libsupport: remove the LIST_HEAD macro from list.h
libsupport: fix gcc -Wall warnings
fuse2fs: fix uninitialized variable warnings

 configure               |   8 +++
 configure.ac            |   3 +
 fuse4fs/Makefile.in     |  18 +++---
 fuse4fs/fuse4fs.c       |  29 +++++++--
 lib/config.h.in         |   3 +
 lib/support/Makefile.in |   2 +-
 lib/support/cache.c     |  49 ++++++++++++---
 lib/support/cache.h     |   2 +-
 lib/support/list.h      |  17 ++++--
 lib/support/xbitops.h   | 128 ----------------------------------------
 misc/fuse2fs.c          |  21 +++++++
 11 files changed, 125 insertions(+), 155 deletions(-)
 delete mode 100644 lib/support/xbitops.h
Signature · 1 line
2.53.0
#1 lore raw

PATCH 1/7 libsupport: drop xbitops.h and define fls() if necessary

The new cache.c file doesn't actually need most of the functions in xbitops.h. It only needs fls(), and on some systems, like MacOS and *BSD systems, fls() is defined already. The other functions in xbitops.h are massively non-portable and break on non-Linux systems, especially MacOS.

So define fls() if it's needed (on Linux), and drop xbitops.h.

Fixes 30b3c80ed6bc ("libsupport: add a cache")
---
 configure               |   6 ++
 configure.ac            |   1 +
 fuse4fs/Makefile.in     |  18 +++---
 lib/config.h.in         |   3 +
 lib/support/Makefile.in |   2 +-
 lib/support/cache.c     |  33 ++++++++++-
 lib/support/xbitops.h   | 128 ----------------------------------------
 7 files changed, 51 insertions(+), 140 deletions(-)
 delete mode 100644 lib/support/xbitops.h
configure +6 -0
index a97794121..a1a270e63 100755
@@ -13677,6 +13677,12 @@ if test "x$ac_cv_func_fdatasync" = xyes
 then :
   printf "%s\n" "#define HAVE_FDATASYNC 1" >>confdefs.h
 
+fi
+ac_fn_c_check_func "$LINENO" "fls" "ac_cv_func_fls"
+if test "x$ac_cv_func_fls" = xyes
+then :
+  printf "%s\n" "#define HAVE_FLS 1" >>confdefs.h
+
 fi
 ac_fn_c_check_func "$LINENO" "fstat64" "ac_cv_func_fstat64"
 if test "x$ac_cv_func_fstat64" = xyes
configure.ac +1 -0
index b62553e3d..abce79594 100644
@@ -1233,6 +1233,7 @@ AC_CHECK_FUNCS(m4_flatten([
 	fchown
 	fcntl
 	fdatasync
+	fls
 	fstat64
 	fsync
 	ftruncate64
fuse4fs/Makefile.in +8 -10
index 9f3547c27..cecee2b25 100644
@@ -134,7 +134,7 @@ distclean: clean
 	$(RM) -f .depend Makefile $(srcdir)/TAGS $(srcdir)/Makefile.in.old
 
 # +++ Dependency line eater +++
-#
+# 
 # Makefile dependencies follow.  This must be the last section in
 # the Makefile.in file
 #
@@ -145,9 +145,10 @@ fuse4fs.o: $(srcdir)/fuse4fs.c $(top_builddir)/lib/config.h \
  $(top_srcdir)/lib/ext2fs/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
  $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/hashmap.h \
  $(top_srcdir)/lib/ext2fs/bitops.h $(top_srcdir)/lib/ext2fs/ext2fsP.h \
- $(top_srcdir)/lib/ext2fs/ext2fs.h $(top_srcdir)/version.h \
- $(top_srcdir)/lib/e2p/e2p.h $(top_srcdir)/lib/support/cache.h \
- $(top_srcdir)/lib/support/list.h $(top_srcdir)/lib/support/xbitops.h
+ $(top_srcdir)/lib/ext2fs/ext2fs.h $(top_srcdir)/lib/support/bthread.h \
+ $(top_srcdir)/lib/support/thread.h $(top_srcdir)/lib/support/list.h \
+ $(top_srcdir)/lib/support/cache.h $(top_srcdir)/version.h \
+ $(top_srcdir)/lib/e2p/e2p.h
 journal.o: $(srcdir)/../debugfs/journal.c $(top_builddir)/lib/config.h \
  $(top_builddir)/lib/dirpaths.h $(srcdir)/../debugfs/journal.h \
  $(top_srcdir)/e2fsck/jfs_user.h $(top_srcdir)/e2fsck/e2fsck.h \
@@ -161,8 +162,7 @@ journal.o: $(srcdir)/../debugfs/journal.c $(top_builddir)/lib/config.h \
  $(top_srcdir)/lib/support/dqblk_v2.h \
  $(top_srcdir)/lib/support/quotaio_tree.h \
  $(top_srcdir)/lib/ext2fs/fast_commit.h $(top_srcdir)/lib/ext2fs/jfs_compat.h \
- $(top_srcdir)/lib/support/list.h $(top_srcdir)/lib/ext2fs/compiler.h \
- $(top_srcdir)/lib/ext2fs/kernel-jbd.h
+ $(top_srcdir)/lib/support/list.h $(top_srcdir)/lib/ext2fs/kernel-jbd.h
 revoke.o: $(srcdir)/../e2fsck/revoke.c $(srcdir)/../e2fsck/jfs_user.h \
  $(top_builddir)/lib/config.h $(top_builddir)/lib/dirpaths.h \
  $(srcdir)/../e2fsck/e2fsck.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \
@@ -175,8 +175,7 @@ revoke.o: $(srcdir)/../e2fsck/revoke.c $(srcdir)/../e2fsck/jfs_user.h \
  $(top_srcdir)/lib/support/dqblk_v2.h \
  $(top_srcdir)/lib/support/quotaio_tree.h \
  $(top_srcdir)/lib/ext2fs/fast_commit.h $(top_srcdir)/lib/ext2fs/jfs_compat.h \
- $(top_srcdir)/lib/support/list.h $(top_srcdir)/lib/ext2fs/compiler.h \
- $(top_srcdir)/lib/ext2fs/kernel-jbd.h
+ $(top_srcdir)/lib/support/list.h $(top_srcdir)/lib/ext2fs/kernel-jbd.h
 recovery.o: $(srcdir)/../e2fsck/recovery.c $(srcdir)/../e2fsck/jfs_user.h \
  $(top_builddir)/lib/config.h $(top_builddir)/lib/dirpaths.h \
  $(srcdir)/../e2fsck/e2fsck.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \
@@ -189,5 +188,4 @@ recovery.o: $(srcdir)/../e2fsck/recovery.c $(srcdir)/../e2fsck/jfs_user.h \
  $(top_srcdir)/lib/support/dqblk_v2.h \
  $(top_srcdir)/lib/support/quotaio_tree.h \
  $(top_srcdir)/lib/ext2fs/fast_commit.h $(top_srcdir)/lib/ext2fs/jfs_compat.h \
- $(top_srcdir)/lib/support/list.h $(top_srcdir)/lib/ext2fs/compiler.h \
- $(top_srcdir)/lib/ext2fs/kernel-jbd.h
+ $(top_srcdir)/lib/support/list.h $(top_srcdir)/lib/ext2fs/kernel-jbd.h
lib/config.h.in +3 -0
index fd2520396..abba5e2c6 100644
@@ -124,6 +124,9 @@
 /* Define to 1 if you have the 'fdatasync' function. */
 #undef HAVE_FDATASYNC
 
+/* Define to 1 if you have the 'fls' function. */
+#undef HAVE_FLS
+
 /* Define to 1 if fsmap_sizeof() is declared in linux/fsmap.h */
 #undef HAVE_FSMAP_SIZEOF
 
lib/support/Makefile.in +1 -1
index 6ff1c81d0..d20d6a984 100644
@@ -199,4 +199,4 @@ dict.o: $(srcdir)/dict.c $(top_builddir)/lib/config.h \
 devname.o: $(srcdir)/devname.c $(top_builddir)/lib/config.h \
  $(top_builddir)/lib/dirpaths.h $(srcdir)/devname.h $(srcdir)/nls-enable.h
 cache.o: $(srcdir)/cache.c $(top_builddir)/lib/config.h \
- $(srcdir)/cache.h $(srcdir)/list.h $(srcdir)/xbitops.h
+ $(top_builddir)/lib/dirpaths.h $(srcdir)/list.h $(srcdir)/cache.h
lib/support/cache.c +32 -1
index 3a9e276f1..f9669e3fc 100644
@@ -7,6 +7,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 #include <unistd.h>
 #include <pthread.h>
 #include <stdbool.h>
@@ -14,9 +15,9 @@
 #include <stdint.h>
 #include <errno.h>
 
+#include "config.h"
 #include "list.h"
 #include "cache.h"
-#include "xbitops.h"
 
 #undef CACHE_DEBUG
 /* #define CACHE_DEBUG 1 */
@@ -32,6 +33,36 @@
 # define ASSERT(x)		do { } while (0)
 #endif
 
+#ifndef HAVE_FLS
+static inline int fls(int x)
+{
+	int r = 32;
+
+	if (!x)
+		return 0;
+	if (!(x & 0xffff0000u)) {
+		x = (x & 0xffffu) << 16;
+		r -= 16;
+	}
+	if (!(x & 0xff000000u)) {
+		x = (x & 0xffffffu) << 8;
+		r -= 8;
+	}
+	if (!(x & 0xf0000000u)) {
+		x = (x & 0xfffffffu) << 4;
+		r -= 4;
+	}
+	if (!(x & 0xc0000000u)) {
+		x = (x & 0x3fffffffu) << 2;
+		r -= 2;
+	}
+	if (!(x & 0x80000000u)) {
+		r -= 1;
+	}
+	return r;
+}
+#endif
+
 static unsigned int cache_generic_bulkrelse(struct cache *, struct list_head *);
 
 int
lib/support/xbitops.h deleted +0 -128

128 lines not on this page · raw message

Signature · 1 line
2.53.0
Reviewed-by on v1 1/7
#2 lore raw

Re: [PATCH 1/7] libsupport: drop xbitops.h and define fls() if necessary

Quoted 10 lines · Theodore Ts'o

The new cache.c file doesn't actually need most of the functions in xbitops.h. It only needs fls(), and on some systems, like MacOS and *BSD systems, fls() is defined already. The other functions in xbitops.h are massively non-portable and break on non-Linux systems, especially MacOS.

So define fls() if it's needed (on Linux), and drop xbitops.h.

Fixes 30b3c80ed6bc ("libsupport: add a cache")

Works for me; in the end I didn't use it as many places as I thought I was going to.

--D

Quoted 316 lines
---
 configure               |   6 ++
 configure.ac            |   1 +
 fuse4fs/Makefile.in     |  18 +++---
 lib/config.h.in         |   3 +
 lib/support/Makefile.in |   2 +-
 lib/support/cache.c     |  33 ++++++++++-
 lib/support/xbitops.h   | 128 ----------------------------------------
 7 files changed, 51 insertions(+), 140 deletions(-)
 delete mode 100644 lib/support/xbitops.h
configure +6 -0
index a97794121..a1a270e63 100755
@@ -13677,6 +13677,12 @@ if test "x$ac_cv_func_fdatasync" = xyes
 then :
   printf "%s\n" "#define HAVE_FDATASYNC 1" >>confdefs.h
 
+fi
+ac_fn_c_check_func "$LINENO" "fls" "ac_cv_func_fls"
+if test "x$ac_cv_func_fls" = xyes
+then :
+  printf "%s\n" "#define HAVE_FLS 1" >>confdefs.h
+
 fi
 ac_fn_c_check_func "$LINENO" "fstat64" "ac_cv_func_fstat64"
 if test "x$ac_cv_func_fstat64" = xyes
configure.ac +1 -0
index b62553e3d..abce79594 100644
@@ -1233,6 +1233,7 @@ AC_CHECK_FUNCS(m4_flatten([
 	fchown
 	fcntl
 	fdatasync
+	fls
 	fstat64
 	fsync
 	ftruncate64
fuse4fs/Makefile.in +8 -10
index 9f3547c27..cecee2b25 100644
@@ -134,7 +134,7 @@ distclean: clean
 	$(RM) -f .depend Makefile $(srcdir)/TAGS $(srcdir)/Makefile.in.old
 
 # +++ Dependency line eater +++
-#
+# 
 # Makefile dependencies follow.  This must be the last section in
 # the Makefile.in file
 #
@@ -145,9 +145,10 @@ fuse4fs.o: $(srcdir)/fuse4fs.c $(top_builddir)/lib/config.h \
  $(top_srcdir)/lib/ext2fs/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
  $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/hashmap.h \
  $(top_srcdir)/lib/ext2fs/bitops.h $(top_srcdir)/lib/ext2fs/ext2fsP.h \
- $(top_srcdir)/lib/ext2fs/ext2fs.h $(top_srcdir)/version.h \
- $(top_srcdir)/lib/e2p/e2p.h $(top_srcdir)/lib/support/cache.h \
- $(top_srcdir)/lib/support/list.h $(top_srcdir)/lib/support/xbitops.h
+ $(top_srcdir)/lib/ext2fs/ext2fs.h $(top_srcdir)/lib/support/bthread.h \
+ $(top_srcdir)/lib/support/thread.h $(top_srcdir)/lib/support/list.h \
+ $(top_srcdir)/lib/support/cache.h $(top_srcdir)/version.h \
+ $(top_srcdir)/lib/e2p/e2p.h
 journal.o: $(srcdir)/../debugfs/journal.c $(top_builddir)/lib/config.h \
  $(top_builddir)/lib/dirpaths.h $(srcdir)/../debugfs/journal.h \
  $(top_srcdir)/e2fsck/jfs_user.h $(top_srcdir)/e2fsck/e2fsck.h \
@@ -161,8 +162,7 @@ journal.o: $(srcdir)/../debugfs/journal.c $(top_builddir)/lib/config.h \
  $(top_srcdir)/lib/support/dqblk_v2.h \
  $(top_srcdir)/lib/support/quotaio_tree.h \
  $(top_srcdir)/lib/ext2fs/fast_commit.h $(top_srcdir)/lib/ext2fs/jfs_compat.h \
- $(top_srcdir)/lib/support/list.h $(top_srcdir)/lib/ext2fs/compiler.h \
- $(top_srcdir)/lib/ext2fs/kernel-jbd.h
+ $(top_srcdir)/lib/support/list.h $(top_srcdir)/lib/ext2fs/kernel-jbd.h
 revoke.o: $(srcdir)/../e2fsck/revoke.c $(srcdir)/../e2fsck/jfs_user.h \
  $(top_builddir)/lib/config.h $(top_builddir)/lib/dirpaths.h \
  $(srcdir)/../e2fsck/e2fsck.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \
@@ -175,8 +175,7 @@ revoke.o: $(srcdir)/../e2fsck/revoke.c $(srcdir)/../e2fsck/jfs_user.h \
  $(top_srcdir)/lib/support/dqblk_v2.h \
  $(top_srcdir)/lib/support/quotaio_tree.h \
  $(top_srcdir)/lib/ext2fs/fast_commit.h $(top_srcdir)/lib/ext2fs/jfs_compat.h \
- $(top_srcdir)/lib/support/list.h $(top_srcdir)/lib/ext2fs/compiler.h \
- $(top_srcdir)/lib/ext2fs/kernel-jbd.h
+ $(top_srcdir)/lib/support/list.h $(top_srcdir)/lib/ext2fs/kernel-jbd.h
 recovery.o: $(srcdir)/../e2fsck/recovery.c $(srcdir)/../e2fsck/jfs_user.h \
  $(top_builddir)/lib/config.h $(top_builddir)/lib/dirpaths.h \
  $(srcdir)/../e2fsck/e2fsck.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \
@@ -189,5 +188,4 @@ recovery.o: $(srcdir)/../e2fsck/recovery.c $(srcdir)/../e2fsck/jfs_user.h \
  $(top_srcdir)/lib/support/dqblk_v2.h \
  $(top_srcdir)/lib/support/quotaio_tree.h \
  $(top_srcdir)/lib/ext2fs/fast_commit.h $(top_srcdir)/lib/ext2fs/jfs_compat.h \
- $(top_srcdir)/lib/support/list.h $(top_srcdir)/lib/ext2fs/compiler.h \
- $(top_srcdir)/lib/ext2fs/kernel-jbd.h
+ $(top_srcdir)/lib/support/list.h $(top_srcdir)/lib/ext2fs/kernel-jbd.h
lib/config.h.in +3 -0
index fd2520396..abba5e2c6 100644
@@ -124,6 +124,9 @@
 /* Define to 1 if you have the 'fdatasync' function. */
 #undef HAVE_FDATASYNC
 
+/* Define to 1 if you have the 'fls' function. */
+#undef HAVE_FLS
+
 /* Define to 1 if fsmap_sizeof() is declared in linux/fsmap.h */
 #undef HAVE_FSMAP_SIZEOF
 
lib/support/Makefile.in +1 -1
index 6ff1c81d0..d20d6a984 100644
@@ -199,4 +199,4 @@ dict.o: $(srcdir)/dict.c $(top_builddir)/lib/config.h \
 devname.o: $(srcdir)/devname.c $(top_builddir)/lib/config.h \
  $(top_builddir)/lib/dirpaths.h $(srcdir)/devname.h $(srcdir)/nls-enable.h
 cache.o: $(srcdir)/cache.c $(top_builddir)/lib/config.h \
- $(srcdir)/cache.h $(srcdir)/list.h $(srcdir)/xbitops.h
+ $(top_builddir)/lib/dirpaths.h $(srcdir)/list.h $(srcdir)/cache.h
lib/support/cache.c +32 -1
index 3a9e276f1..f9669e3fc 100644
@@ -7,6 +7,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 #include <unistd.h>
 #include <pthread.h>
 #include <stdbool.h>
@@ -14,9 +15,9 @@
 #include <stdint.h>
 #include <errno.h>
 
+#include "config.h"
 #include "list.h"
 #include "cache.h"
-#include "xbitops.h"
 
 #undef CACHE_DEBUG
 /* #define CACHE_DEBUG 1 */
@@ -32,6 +33,36 @@
 # define ASSERT(x)		do { } while (0)
 #endif
 
+#ifndef HAVE_FLS
+static inline int fls(int x)
+{
+	int r = 32;
+
+	if (!x)
+		return 0;
+	if (!(x & 0xffff0000u)) {
+		x = (x & 0xffffu) << 16;
+		r -= 16;
+	}
+	if (!(x & 0xff000000u)) {
+		x = (x & 0xffffffu) << 8;
+		r -= 8;
+	}
+	if (!(x & 0xf0000000u)) {
+		x = (x & 0xfffffffu) << 4;
+		r -= 4;
+	}
+	if (!(x & 0xc0000000u)) {
+		x = (x & 0x3fffffffu) << 2;
+		r -= 2;
+	}
+	if (!(x & 0x80000000u)) {
+		r -= 1;
+	}
+	return r;
+}
+#endif
+
 static unsigned int cache_generic_bulkrelse(struct cache *, struct list_head *);
 
 int
lib/support/xbitops.h deleted +0 -128
deleted file mode 100644
index 78a8f2a85..000000000
@@ -1,128 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-#ifndef __BITOPS_H__
-#define __BITOPS_H__
-
-/*
- * fls: find last bit set.
- */
-
-static inline int fls(int x)
-{
-	int r = 32;
-
-	if (!x)
-		return 0;
-	if (!(x & 0xffff0000u)) {
-		x = (x & 0xffffu) << 16;
-		r -= 16;
-	}
-	if (!(x & 0xff000000u)) {
-		x = (x & 0xffffffu) << 8;
-		r -= 8;
-	}
-	if (!(x & 0xf0000000u)) {
-		x = (x & 0xfffffffu) << 4;
-		r -= 4;
-	}
-	if (!(x & 0xc0000000u)) {
-		x = (x & 0x3fffffffu) << 2;
-		r -= 2;
-	}
-	if (!(x & 0x80000000u)) {
-		r -= 1;
-	}
-	return r;
-}
-
-static inline int fls64(uint64_t x)
-{
-	uint32_t h = x >> 32;
-	if (h)
-		return fls(h) + 32;
-	return fls(x);
-}
-
-static inline unsigned fls_long(unsigned long l)
-{
-        if (sizeof(l) == 4)
-                return fls(l);
-        return fls64(l);
-}
-
-/*
- * ffz: find first zero bit.
- * Result is undefined if no zero bit exists.
- */
-#define ffz(x)	ffs(~(x))
-
-/*
- * XFS bit manipulation routines.  Repeated here so that some programs
- * don't have to link in all of libxfs just to have bit manipulation.
- */
-
-/*
- * masks with n high/low bits set, 64-bit values
- */
-static inline uint64_t mask64hi(int n)
-{
-	return (uint64_t)-1 << (64 - (n));
-}
-static inline uint32_t mask32lo(int n)
-{
-	return ((uint32_t)1 << (n)) - 1;
-}
-static inline uint64_t mask64lo(int n)
-{
-	return ((uint64_t)1 << (n)) - 1;
-}
-
-/* Get high bit set out of 32-bit argument, -1 if none set */
-static inline int highbit32(uint32_t v)
-{
-	return fls(v) - 1;
-}
-
-/* Get high bit set out of 64-bit argument, -1 if none set */
-static inline int highbit64(uint64_t v)
-{
-	return fls64(v) - 1;
-}
-
-/* Get low bit set out of 32-bit argument, -1 if none set */
-static inline int lowbit32(uint32_t v)
-{
-	return ffs(v) - 1;
-}
-
-/* Get low bit set out of 64-bit argument, -1 if none set */
-static inline int lowbit64(uint64_t v)
-{
-	uint32_t	w = (uint32_t)v;
-	int		n = 0;
-
-	if (w) {	/* lower bits */
-		n = ffs(w);
-	} else {	/* upper bits */
-		w = (uint32_t)(v >> 32);
-		if (w) {
-			n = ffs(w);
-			if (n)
-				n += 32;
-		}
-	}
-	return n - 1;
-}
-
-/**
- * __rounddown_pow_of_two() - round down to nearest power of two
- * @n: value to round down
- */
-static inline __attribute__((const))
-unsigned long __rounddown_pow_of_two(unsigned long n)
-{
-	return 1UL << (fls_long(n) - 1);
-}
-
-#define rounddown_pow_of_two(n) __rounddown_pow_of_two(n)
-
-#endif
Signature · 1 line
2.53.0
#3 lore raw

PATCH 2/7 configure.ac: fix disable fuse2fs/fuse4fs by default path

In reply to Theodore Ts'o

If the fuse.h header file is not present, fix the "Disabling fuse[24]fs by default" codepath to actually disable trying to build fuse2fs or fuse4fs.

Fixes 239f4b7ac05b ("fuse2fs: separate libfuse3 and fuse2fs detection in configure")
---
 configure    | 2 ++
 configure.ac | 2 ++
 2 files changed, 4 insertions(+)
configure +2 -0
index a1a270e63..d941ff1f1 100755
@@ -14737,6 +14737,7 @@ else case e in #(
 		{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Enabling fuse2fs by default" >&5
 printf "%s\n" "Enabling fuse2fs by default" >&6; }
 	else
+		FUSE2FS_CMT="#"
 		{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Disabling fuse2fs by default" >&5
 printf "%s\n" "Disabling fuse2fs by default" >&6; }
 	fi
@@ -14804,6 +14805,7 @@ else case e in #(
 		{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Enabling fuse4fs by default" >&5
 printf "%s\n" "Enabling fuse4fs by default" >&6; }
 	else
+		FUSE4FS_CMT="#"
 		{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Disabling fuse4fs by default" >&5
 printf "%s\n" "Disabling fuse4fs by default" >&6; }
 	fi
configure.ac +2 -0
index abce79594..d8f40f5df 100644
@@ -1459,6 +1459,7 @@ AS_HELP_STRING([--disable-fuse2fs],[do not build fuse2fs]),
 	then
 		AC_MSG_RESULT([Enabling fuse2fs by default])
 	else
+		FUSE2FS_CMT="#"
 		AC_MSG_RESULT([Disabling fuse2fs by default])
 	fi
 ]
@@ -1496,6 +1497,7 @@ AS_HELP_STRING([--disable-fuse4fs],[do not build fuse4fs]),
 	then
 		AC_MSG_RESULT([Enabling fuse4fs by default])
 	else
+		FUSE4FS_CMT="#"
 		AC_MSG_RESULT([Disabling fuse4fs by default])
 	fi
 ]
Signature · 1 line
2.53.0
Reviewed-by on v1 2/7
#4 lore raw

Re: [PATCH 2/7] configure.ac: fix disable fuse2fs/fuse4fs by default path

Quoted 7 lines · Theodore Ts'o

If the fuse.h header file is not present, fix the "Disabling fuse[24]fs by default" codepath to actually disable trying to build fuse2fs or fuse4fs.

Fixes 239f4b7ac05b ("fuse2fs: separate libfuse3 and fuse2fs detection in configure")

Oops. I hadn't tried building without a fuse.h in a while. :/

--D

Quoted 49 lines
---
 configure    | 2 ++
 configure.ac | 2 ++
 2 files changed, 4 insertions(+)
configure +2 -0
index a1a270e63..d941ff1f1 100755
@@ -14737,6 +14737,7 @@ else case e in #(
 		{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Enabling fuse2fs by default" >&5
 printf "%s\n" "Enabling fuse2fs by default" >&6; }
 	else
+		FUSE2FS_CMT="#"
 		{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Disabling fuse2fs by default" >&5
 printf "%s\n" "Disabling fuse2fs by default" >&6; }
 	fi
@@ -14804,6 +14805,7 @@ else case e in #(
 		{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Enabling fuse4fs by default" >&5
 printf "%s\n" "Enabling fuse4fs by default" >&6; }
 	else
+		FUSE4FS_CMT="#"
 		{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Disabling fuse4fs by default" >&5
 printf "%s\n" "Disabling fuse4fs by default" >&6; }
 	fi
configure.ac +2 -0
index abce79594..d8f40f5df 100644
@@ -1459,6 +1459,7 @@ AS_HELP_STRING([--disable-fuse2fs],[do not build fuse2fs]),
 	then
 		AC_MSG_RESULT([Enabling fuse2fs by default])
 	else
+		FUSE2FS_CMT="#"
 		AC_MSG_RESULT([Disabling fuse2fs by default])
 	fi
 ]
@@ -1496,6 +1497,7 @@ AS_HELP_STRING([--disable-fuse4fs],[do not build fuse4fs]),
 	then
 		AC_MSG_RESULT([Enabling fuse4fs by default])
 	else
+		FUSE4FS_CMT="#"
 		AC_MSG_RESULT([Disabling fuse4fs by default])
 	fi
 ]
Signature · 1 line
2.53.0
#5 lore raw

PATCH 3/7 libsupport: don't use bzero in cache.c

In reply to Theodore Ts'o

The bzero() function is deprecated and not available in some platforms. It's not needed in any case because we can just use an automatic initializer.

Fixes 30b3c80ed6bc ("libsupport: add a cache")
---
 lib/support/cache.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
lib/support/cache.c +1 -3
index f9669e3fc..aec785347 100644
@@ -850,7 +850,7 @@ cache_report(
 {
 	int		i;
 	unsigned long	count, index, total;
-	unsigned long	hash_bucket_lengths[HASH_REPORT + 2];
+	unsigned long	hash_bucket_lengths[HASH_REPORT + 2] = { 0 };
 
 	if ((cache->c_hits + cache->c_misses) == 0)
 		return;
@@ -886,8 +886,6 @@ cache_report(
 		cache->c_mrus[i].cm_count * 100 / cache->c_count);
 
 	/* report hash bucket lengths */
-	bzero(hash_bucket_lengths, sizeof(hash_bucket_lengths));
-
 	for (i = 0; i < cache->c_hashsize; i++) {
 		count = cache->c_hash[i].ch_count;
 		if (count > HASH_REPORT)
Signature · 1 line
2.53.0
Reviewed-by on v1 3/7
#6 lore raw

Re: [PATCH 3/7] libsupport: don't use bzero in cache.c

Quoted 6 lines · Theodore Ts'o

The bzero() function is deprecated and not available in some platforms. It's not needed in any case because we can just use an automatic initializer.

Fixes 30b3c80ed6bc ("libsupport: add a cache")

Yeesh. What a sordid legacy this function has (see manpage). :(

--D

Quoted 30 lines
---
 lib/support/cache.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
lib/support/cache.c +1 -3
index f9669e3fc..aec785347 100644
@@ -850,7 +850,7 @@ cache_report(
 {
 	int		i;
 	unsigned long	count, index, total;
-	unsigned long	hash_bucket_lengths[HASH_REPORT + 2];
+	unsigned long	hash_bucket_lengths[HASH_REPORT + 2] = { 0 };
 
 	if ((cache->c_hits + cache->c_misses) == 0)
 		return;
@@ -886,8 +886,6 @@ cache_report(
 		cache->c_mrus[i].cm_count * 100 / cache->c_count);
 
 	/* report hash bucket lengths */
-	bzero(hash_bucket_lengths, sizeof(hash_bucket_lengths));
-
 	for (i = 0; i < cache->c_hashsize; i++) {
 		count = cache->c_hash[i].ch_count;
 		if (count > HASH_REPORT)
Signature · 1 line
2.53.0
#7 lore raw

PATCH 4/7 fuse[24]fs: suppress clang warnings which were breaking the github CI

In reply to Theodore Ts'o

fuse[24]fs.c defines some functions which might or might not be used depending on the version of the fuse library installed on the system. Unfortunately while gcc won't complain if there are static inline functions which are not used, clang will only suppress such complaints if the static inline functions are in a header file.

Since the github CI runs a test build with -Wall -Werror this was breaking the CI build.

---
 fuse4fs/fuse4fs.c | 21 +++++++++++++++++++++
 misc/fuse2fs.c    | 21 +++++++++++++++++++++
 2 files changed, 42 insertions(+)
fuse4fs/fuse4fs.c +21 -0
index 13e1aae4b..b883083f8 100644
@@ -502,6 +502,27 @@ static inline off_t FUSE4FS_FSB_TO_B(const struct fuse4fs *ff, blk64_t bno)
 	return bno << ff->blocklog;
 }
 
+#ifdef __clang__
+#define SUPPRESS_UNUSED_FUNCTION(func)    (void)func
+/*
+ * These functions might or might not be used depending on the version
+ * of the fuse library installed on the system.  Unfortunately while
+ * gcc won't complain if there are static inline functions which are
+ * not used, clang will only suppress such complaints if the static
+ * inline functions are in a header file.
+ */
+void fuse2fs_shut_up_stupid_clang_warnings(void)
+{
+	SUPPRESS_UNUSED_FUNCTION(fuse2fs_shut_up_stupid_clang_warnings);
+	SUPPRESS_UNUSED_FUNCTION(round_up);
+	SUPPRESS_UNUSED_FUNCTION(round_down);
+	SUPPRESS_UNUSED_FUNCTION(FUSE4FS_B_TO_FSBT);
+	SUPPRESS_UNUSED_FUNCTION(FUSE4FS_OFF_IN_FSB);
+	SUPPRESS_UNUSED_FUNCTION(FUSE4FS_B_TO_FSB);
+	SUPPRESS_UNUSED_FUNCTION(FUSE4FS_FSB_TO_B);
+}
+#endif
+
 static double gettime_monotonic(void)
 {
 #ifdef CLOCK_MONOTONIC
misc/fuse2fs.c +21 -0
index 0f4781bc4..c46cfc236 100644
@@ -339,6 +339,27 @@ static inline off_t FUSE2FS_FSB_TO_B(const struct fuse2fs *ff, blk64_t bno)
 	return bno << ff->blocklog;
 }
 
+#ifdef __clang__
+#define SUPPRESS_UNUSED_FUNCTION(func)    (void)func
+/*
+ * These functions might or might not be used depending on the version
+ * of the fuse library installed on the system.  Unfortunately while
+ * gcc won't complain if there are static inline functions which are
+ * not used, clang will only suppress such complaints if the static
+ * inline functions are in a header file.
+ */
+void fuse2fs_shut_up_stupid_clang_warnings(void)
+{
+	SUPPRESS_UNUSED_FUNCTION(fuse2fs_shut_up_stupid_clang_warnings);
+	SUPPRESS_UNUSED_FUNCTION(round_up);
+	SUPPRESS_UNUSED_FUNCTION(round_down);
+	SUPPRESS_UNUSED_FUNCTION(FUSE2FS_B_TO_FSBT);
+	SUPPRESS_UNUSED_FUNCTION(FUSE2FS_OFF_IN_FSB);
+	SUPPRESS_UNUSED_FUNCTION(FUSE2FS_B_TO_FSB);
+	SUPPRESS_UNUSED_FUNCTION(FUSE2FS_FSB_TO_B);
+}
+#endif
+
 static double gettime_monotonic(void)
 {
 #ifdef CLOCK_MONOTONIC
Signature · 1 line
2.53.0
#8 lore raw

Re: [PATCH 4/7] fuse[24]fs: suppress clang warnings which were breaking the github CI

Quoted 5 lines · Theodore Ts'o

fuse[24]fs.c defines some functions which might or might not be used depending on the version of the fuse library installed on the system. Unfortunately while gcc won't complain if there are static inline functions which are not used, clang will only suppress such complaints if the static inline functions are in a header file.

<groan>

Quoted 19 lines

Since the github CI runs a test build with -Wall -Werror this was breaking the CI build.

---
 fuse4fs/fuse4fs.c | 21 +++++++++++++++++++++
 misc/fuse2fs.c    | 21 +++++++++++++++++++++
 2 files changed, 42 insertions(+)
fuse4fs/fuse4fs.c +2 -0
index 13e1aae4b..b883083f8 100644
@@ -502,6 +502,27 @@ static inline off_t FUSE4FS_FSB_TO_B(const struct fuse4fs *ff, blk64_t bno)
 	return bno << ff->blocklog;
 }
 
+#ifdef __clang__
+#define SUPPRESS_UNUSED_FUNCTION(func)    (void)func

fuse4fs/fuse4fs.c static inline off_t FUSE4FS_FSB_TO_B(const struct fuse4fs *ff, blk64_t bno) · line 516

Quoted 10 lines
fuse4fs/fuse4fs.c +10 -0
+/*
+ * These functions might or might not be used depending on the version
+ * of the fuse library installed on the system.  Unfortunately while
+ * gcc won't complain if there are static inline functions which are
+ * not used, clang will only suppress such complaints if the static
+ * inline functions are in a header file.
+ */
+void fuse2fs_shut_up_stupid_clang_warnings(void)
+{
+	SUPPRESS_UNUSED_FUNCTION(fuse2fs_shut_up_stupid_clang_warnings);

Why is this stupid recursive shi ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ even necessary?

fuse4fs/fuse4fs.c static inline off_t FUSE4FS_FSB_TO_B(const struct fuse4fs *ff, blk64_t bno) · line 522

Quoted 6 lines
fuse4fs/fuse4fs.c +6 -0
+	SUPPRESS_UNUSED_FUNCTION(round_up);
+	SUPPRESS_UNUSED_FUNCTION(round_down);
+	SUPPRESS_UNUSED_FUNCTION(FUSE4FS_B_TO_FSBT);
+	SUPPRESS_UNUSED_FUNCTION(FUSE4FS_OFF_IN_FSB);
+	SUPPRESS_UNUSED_FUNCTION(FUSE4FS_B_TO_FSB);
+	SUPPRESS_UNUSED_FUNCTION(FUSE4FS_FSB_TO_B);

Hrmm some of these aren't strictly necessary, but ... oh. The first three are actively used in the punch hole helpers, but that only applies on a platform that *supports* hole punching. So my guess is that these clang warnings appear on macos, where there isn't holepunching?

--D

Quoted 42 lines
fuse4fs/fuse4fs.c +3 -0
+}
+#endif
+
 static double gettime_monotonic(void)
 {
 #ifdef CLOCK_MONOTONIC
misc/fuse2fs.c +21 -0
index 0f4781bc4..c46cfc236 100644
@@ -339,6 +339,27 @@ static inline off_t FUSE2FS_FSB_TO_B(const struct fuse2fs *ff, blk64_t bno)
 	return bno << ff->blocklog;
 }
 
+#ifdef __clang__
+#define SUPPRESS_UNUSED_FUNCTION(func)    (void)func
+/*
+ * These functions might or might not be used depending on the version
+ * of the fuse library installed on the system.  Unfortunately while
+ * gcc won't complain if there are static inline functions which are
+ * not used, clang will only suppress such complaints if the static
+ * inline functions are in a header file.
+ */
+void fuse2fs_shut_up_stupid_clang_warnings(void)
+{
+	SUPPRESS_UNUSED_FUNCTION(fuse2fs_shut_up_stupid_clang_warnings);
+	SUPPRESS_UNUSED_FUNCTION(round_up);
+	SUPPRESS_UNUSED_FUNCTION(round_down);
+	SUPPRESS_UNUSED_FUNCTION(FUSE2FS_B_TO_FSBT);
+	SUPPRESS_UNUSED_FUNCTION(FUSE2FS_OFF_IN_FSB);
+	SUPPRESS_UNUSED_FUNCTION(FUSE2FS_B_TO_FSB);
+	SUPPRESS_UNUSED_FUNCTION(FUSE2FS_FSB_TO_B);
+}
+#endif
+
 static double gettime_monotonic(void)
 {
 #ifdef CLOCK_MONOTONIC
Signature · 1 line
2.53.0
#9 lore raw

PATCH 5/7 libsupport: remove the LIST_HEAD macro from list.h

In reply to Theodore Ts'o

The LIST_HEAD macro is defined by both the Linux kernel's list.h and <sys/queue.h> (originally from BSD). The problem is that on MacOS, some system header file pulls in <sys/queue.h> leading to a macro redefiniction conflict. Since we don't use LIST_HEAD in e2fsprogs, the simplest mitigation is to just comment out the definition of LIST_HEAD.

Fixes 37dafcc0894b ("libsupport: port the kernel list.h to libsupport")
---
 lib/support/list.h | 9 +++++++++
 1 file changed, 9 insertions(+)
lib/support/list.h +9 -0
index 0e00e446d..0ec8de525 100644
@@ -36,8 +36,17 @@ static inline void list_head_destroy(struct list_head *list)
 
 #define LIST_HEAD_INIT(name) { &(name), &(name) }
 
+#if 0
+/*
+ * This conflicts with the LIST_HEAD defined in <sys/queue.h>.  We
+ * don't include it in e2fsprogs, but some systems' header files might
+ * pull it in, leading to the macro redefinition conflict.
+ * Fortunately, we also don't need LIST_HEAD in e2fsprogs, so just
+ * drop this convenience macro.
+ */
 #define LIST_HEAD(name) \
 	struct list_head name = LIST_HEAD_INIT(name)
+#endif
 
 /**
  * INIT_LIST_HEAD - Initialize a list_head structure
Signature · 1 line
2.53.0
Reviewed-by on v1 5/7
#10 lore raw

Re: [PATCH 5/7] libsupport: remove the LIST_HEAD macro from list.h

Quoted 8 lines · Theodore Ts'o

The LIST_HEAD macro is defined by both the Linux kernel's list.h and <sys/queue.h> (originally from BSD). The problem is that on MacOS, some system header file pulls in <sys/queue.h> leading to a macro redefiniction conflict. Since we don't use LIST_HEAD in e2fsprogs, the simplest mitigation is to just comment out the definition of LIST_HEAD.

Fixes 37dafcc0894b ("libsupport: port the kernel list.h to libsupport")

Sounds fine to me.

--D

Quoted 30 lines
---
 lib/support/list.h | 9 +++++++++
 1 file changed, 9 insertions(+)
lib/support/list.h +9 -0
index 0e00e446d..0ec8de525 100644
@@ -36,8 +36,17 @@ static inline void list_head_destroy(struct list_head *list)
 
 #define LIST_HEAD_INIT(name) { &(name), &(name) }
 
+#if 0
+/*
+ * This conflicts with the LIST_HEAD defined in <sys/queue.h>.  We
+ * don't include it in e2fsprogs, but some systems' header files might
+ * pull it in, leading to the macro redefinition conflict.
+ * Fortunately, we also don't need LIST_HEAD in e2fsprogs, so just
+ * drop this convenience macro.
+ */
 #define LIST_HEAD(name) \
 	struct list_head name = LIST_HEAD_INIT(name)
+#endif
 
 /**
  * INIT_LIST_HEAD - Initialize a list_head structure
Signature · 1 line
2.53.0
#11 lore raw

PATCH 6/7 libsupport: fix gcc -Wall warnings

In reply to Theodore Ts'o
---
 lib/support/cache.c | 12 +++++++++---
 lib/support/cache.h |  2 +-
 lib/support/list.h  |  8 ++++----
 3 files changed, 14 insertions(+), 8 deletions(-)
lib/support/cache.c +9 -3
index aec785347..ece0adece 100644
@@ -15,6 +15,12 @@
 #include <stdint.h>
 #include <errno.h>
 
+#ifdef __GNUC__
+#define EXT2FS_ATTR(x) __attribute__(x)
+#else
+#define EXT2FS_ATTR(x)
+#endif
+
 #include "config.h"
 #include "list.h"
 #include "cache.h"
@@ -711,7 +717,7 @@ cache_node_put(
 
 void
 cache_node_set_priority(
-	struct cache *		cache,
+	struct cache *		cache EXT2FS_ATTR((unused)),
 	struct cache_node *	node,
 	int			priority)
 {
@@ -820,7 +826,7 @@ cache_flush(
 {
 	struct cache_hash	*hash;
 	struct cache_node	*node;
-	int			i;
+	unsigned int		i;
 	bool			still_dirty = false;
 
 	if (!cache->flush)
@@ -848,7 +854,7 @@ cache_report(
 	const char	*name,
 	struct cache	*cache)
 {
-	int		i;
+	unsigned int	i;
 	unsigned long	count, index, total;
 	unsigned long	hash_bucket_lengths[HASH_REPORT + 2] = { 0 };
 
lib/support/cache.h +1 -1
index 71fb9762f..cd0e8c20e 100644
@@ -83,7 +83,7 @@ typedef unsigned int (*cache_node_resize_t)(const struct cache *c,
 					    unsigned int curr_size,
 					    int dir);
 
-static inline unsigned int cache_gradual_resize(const struct cache *cache,
+static inline unsigned int cache_gradual_resize(const struct cache *cache EXT2FS_ATTR((unused)),
 						unsigned int curr_size,
 						int dir)
 {
lib/support/list.h +4 -4
index 0ec8de525..54e8e2360 100644
@@ -148,13 +148,13 @@ static __always_inline bool __list_del_entry_valid(struct list_head *entry)
 	return ret;
 }
 #else
-static inline bool __list_add_valid(struct list_head *new,
-				struct list_head *prev,
-				struct list_head *next)
+static inline bool __list_add_valid(struct list_head *new EXT2FS_ATTR((unused)),
+				struct list_head *prev EXT2FS_ATTR((unused)),
+				struct list_head *next EXT2FS_ATTR((unused)))
 {
 	return true;
 }
-static inline bool __list_del_entry_valid(struct list_head *entry)
+static inline bool __list_del_entry_valid(struct list_head *entry EXT2FS_ATTR((unused)))
 {
 	return true;
 }
Signature · 1 line
2.53.0
Reviewed-by on v1 6/7
#12 lore raw

Re: [PATCH 6/7] libsupport: fix gcc -Wall warnings

Quoted 1 line · Theodore Ts'o

Looks good to me,

--D

Quoted 89 lines
---
 lib/support/cache.c | 12 +++++++++---
 lib/support/cache.h |  2 +-
 lib/support/list.h  |  8 ++++----
 3 files changed, 14 insertions(+), 8 deletions(-)
lib/support/cache.c +9 -3
index aec785347..ece0adece 100644
@@ -15,6 +15,12 @@
 #include <stdint.h>
 #include <errno.h>
 
+#ifdef __GNUC__
+#define EXT2FS_ATTR(x) __attribute__(x)
+#else
+#define EXT2FS_ATTR(x)
+#endif
+
 #include "config.h"
 #include "list.h"
 #include "cache.h"
@@ -711,7 +717,7 @@ cache_node_put(
 
 void
 cache_node_set_priority(
-	struct cache *		cache,
+	struct cache *		cache EXT2FS_ATTR((unused)),
 	struct cache_node *	node,
 	int			priority)
 {
@@ -820,7 +826,7 @@ cache_flush(
 {
 	struct cache_hash	*hash;
 	struct cache_node	*node;
-	int			i;
+	unsigned int		i;
 	bool			still_dirty = false;
 
 	if (!cache->flush)
@@ -848,7 +854,7 @@ cache_report(
 	const char	*name,
 	struct cache	*cache)
 {
-	int		i;
+	unsigned int	i;
 	unsigned long	count, index, total;
 	unsigned long	hash_bucket_lengths[HASH_REPORT + 2] = { 0 };
 
lib/support/cache.h +1 -1
index 71fb9762f..cd0e8c20e 100644
@@ -83,7 +83,7 @@ typedef unsigned int (*cache_node_resize_t)(const struct cache *c,
 					    unsigned int curr_size,
 					    int dir);
 
-static inline unsigned int cache_gradual_resize(const struct cache *cache,
+static inline unsigned int cache_gradual_resize(const struct cache *cache EXT2FS_ATTR((unused)),
 						unsigned int curr_size,
 						int dir)
 {
lib/support/list.h +4 -4
index 0ec8de525..54e8e2360 100644
@@ -148,13 +148,13 @@ static __always_inline bool __list_del_entry_valid(struct list_head *entry)
 	return ret;
 }
 #else
-static inline bool __list_add_valid(struct list_head *new,
-				struct list_head *prev,
-				struct list_head *next)
+static inline bool __list_add_valid(struct list_head *new EXT2FS_ATTR((unused)),
+				struct list_head *prev EXT2FS_ATTR((unused)),
+				struct list_head *next EXT2FS_ATTR((unused)))
 {
 	return true;
 }
-static inline bool __list_del_entry_valid(struct list_head *entry)
+static inline bool __list_del_entry_valid(struct list_head *entry EXT2FS_ATTR((unused)))
 {
 	return true;
 }
Signature · 1 line
2.53.0
#13 lore raw

PATCH 7/7 fuse2fs: fix uninitialized variable warnings

In reply to Theodore Ts'o

Clang treats use of unitialized variables found by static analysis to be serious enough that it will emit them by default (even without -Wall). So let's fix them up.

---
 fuse4fs/fuse4fs.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
fuse4fs/fuse4fs.c +4 -4
index b883083f8..928473268 100644
@@ -2216,7 +2216,7 @@ static void op_mknod(fuse_req_t req, fuse_ino_t fino, const char *name,
 	const struct fuse_ctx *ctxt = fuse_req_ctx(req);
 	struct fuse4fs *ff = fuse4fs_get(req);
 	ext2_filsys fs;
-	ext2_ino_t parent, child;
+	ext2_ino_t parent, child = 0;
 	errcode_t err;
 	int filetype;
 	gid_t gid;
@@ -2311,7 +2311,7 @@ static void op_mkdir(fuse_req_t req, fuse_ino_t fino, const char *name,
 	const struct fuse_ctx *ctxt = fuse_req_ctx(req);
 	struct fuse4fs *ff = fuse4fs_get(req);
 	ext2_filsys fs;
-	ext2_ino_t parent, child;
+	ext2_ino_t parent, child = 0;
 	errcode_t err;
 	char *block;
 	blk64_t blk;
@@ -2990,7 +2990,7 @@ static void op_symlink(fuse_req_t req, const char *target, fuse_ino_t fino,
 	const struct fuse_ctx *ctxt = fuse_req_ctx(req);
 	struct fuse4fs *ff = fuse4fs_get(req);
 	ext2_filsys fs;
-	ext2_ino_t parent, child;
+	ext2_ino_t parent, child = 0;
 	errcode_t err;
 	gid_t gid;
 	int ret = 0;
@@ -6042,7 +6042,7 @@ static int fuse4fs_main(struct fuse_args *args, struct fuse4fs *ff)
 	struct fuse_cmdline_opts opts;
 	struct fuse_session *se;
 	struct fuse_loop_config *loop_config = NULL;
-	int ret;
+	int ret = 0;
 
 	if (fuse_parse_cmdline(args, &opts) != 0) {
 		ret = 1;
Signature · 1 line
2.53.0
Reviewed-by on v1 7/7
#14 lore raw

Re: [PATCH 7/7] fuse2fs: fix uninitialized variable warnings

Quoted 5 lines · Theodore Ts'o

Clang treats use of unitialized variables found by static analysis to be serious enough that it will emit them by default (even without -Wall). So let's fix them up.

I wonder why gcc doesn't complain about this??

--D

Quoted 48 lines
---
 fuse4fs/fuse4fs.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
fuse4fs/fuse4fs.c +4 -4
index b883083f8..928473268 100644
@@ -2216,7 +2216,7 @@ static void op_mknod(fuse_req_t req, fuse_ino_t fino, const char *name,
 	const struct fuse_ctx *ctxt = fuse_req_ctx(req);
 	struct fuse4fs *ff = fuse4fs_get(req);
 	ext2_filsys fs;
-	ext2_ino_t parent, child;
+	ext2_ino_t parent, child = 0;
 	errcode_t err;
 	int filetype;
 	gid_t gid;
@@ -2311,7 +2311,7 @@ static void op_mkdir(fuse_req_t req, fuse_ino_t fino, const char *name,
 	const struct fuse_ctx *ctxt = fuse_req_ctx(req);
 	struct fuse4fs *ff = fuse4fs_get(req);
 	ext2_filsys fs;
-	ext2_ino_t parent, child;
+	ext2_ino_t parent, child = 0;
 	errcode_t err;
 	char *block;
 	blk64_t blk;
@@ -2990,7 +2990,7 @@ static void op_symlink(fuse_req_t req, const char *target, fuse_ino_t fino,
 	const struct fuse_ctx *ctxt = fuse_req_ctx(req);
 	struct fuse4fs *ff = fuse4fs_get(req);
 	ext2_filsys fs;
-	ext2_ino_t parent, child;
+	ext2_ino_t parent, child = 0;
 	errcode_t err;
 	gid_t gid;
 	int ret = 0;
@@ -6042,7 +6042,7 @@ static int fuse4fs_main(struct fuse_args *args, struct fuse4fs *ff)
 	struct fuse_cmdline_opts opts;
 	struct fuse_session *se;
 	struct fuse_loop_config *loop_config = NULL;
-	int ret;
+	int ret = 0;
 
 	if (fuse_parse_cmdline(args, &opts) != 0) {
 		ret = 1;
Signature · 1 line
2.53.0
#15 lore raw
In reply to Theodore Ts'o
Quoted 11 lines · Theodore Ts'o

These are the patches that I've applied to the next branch to clean up found when trying to compile e2fsprogs on MacOS and via the github's continuous integration testing.

Note: See .github/workflows/ci.yaml; it's a good reason to get a github account if you are doing a lot of e2fsprogs development. If you fork my e2fsprogs repository and push your changes to your github repo, you can get reports like the ones found here:
https://github.com/tytso/e2fsprogs/actions

Quoted 5 lines

Anyway, with these patches, e2fsprogs builds on MacOS (both using the github CI and on locally on my Macbook). Unfortunately fuse2fs has regressed in that non-root accesses are getting denied with a permission denied on MacOS, and this worked with e2fsprogs v1.47.4. Here's a lightly edited transcript from my Macbook Air:

Hm, curious. It's regrettable that I no longer have a Mac, and therefore can't really do much investigating. If you give -o default_permissions,allow_other , does that fix the problem? If that fixes it, then fuse2fs has a bug somewhere in its own permissions checking.

Quoted 23 lines

% uname -a
Darwin macsyma.local 25.4.0 Darwin Kernel Version 25.4.0: Thu Mar 19 19:33:09 PDT 2026; root:xnu-12377.101.15~1/RELEASE_ARM64_T8112 arm64 arm Darwin % ./mke2fs -Fq -t ext4 -d . /tmp/foo.img 1G
% ./fuse2fs -o allow_other /tmp/foo.img /Users/tytso/mnt
FUSE2FS (foo.img): Warning: fuse2fs does not support using the journal.
There may be file system corruption or data loss if
the file system is not gracefully unmounted.
% stat /Users/tytso/mnt/revoke.o
stat: cannot stat '/Users/tytso/mnt/revoke.o': Permission denied
% sudo stat /Users/tytso/mnt/revoke.o
File: /Users/tytso/mnt/revoke.o
Size: 29728 Blocks: 64 IO Block: 16384 regular file
Device: 55,270 Inode: 91 Links: 1
Access: (0644/-rw-r--r--) Uid: (15806/ tytso) Gid: ( 20/ staff)
Access: 2026-05-05 00:21:50.000000000 +0200
Modify: 2026-05-05 00:21:50.000000000 +0200
Change: 2026-05-05 00:21:50.000000000 +0200
Birth: -
% stat revoke.o
File: revoke.o
Size: 29728 Blocks: 64 IO Block: 4096 regular file
Device: 1,18 Inode: 851374 Links: 1
Access: (0644/-rw-r--r--) Uid: (15806/ tytso) Gid: ( 20/ staff)

Quoted 8 lines

Access: 2026-05-05 00:21:50.903084819 +0200
Modify: 2026-05-05 00:21:50.346338295 +0200
Change: 2026-05-05 00:21:50.346580544 +0200
Birth: 2026-05-05 00:21:50.293229053 +0200
% sum revoke.o
45116 30 revoke.o
% sum /Users/tytso/mnt/revoke.o
sum: /Users/tytso/mnt/revoke.o: Permission denied

That's really strange. Does MacOS do any strange idmapping stuff?

I'm also curious if there's a particular commit that makes it all work again? There are a few defaults that changed between fuse2 and fuse3, and since MacFuse claims to have vendored both, it could very well be the megacommit dropping the fuse2 api support.

--D

Quoted 33 lines

So fuse2fs is broken on MacOS, but it's not *totally* broken, since you can still use it as root. I'll want to fix this before updating the master branch, but this is good enough for the next branch.

Theodore Ts'o (7):
libsupport: drop xbitops.h and define fls() if necessary configure.ac: fix disable fuse2fs/fuse4fs by default path
libsupport: don't use bzero in cache.c
fuse[24]fs: suppress clang warnings which were breaking the github CI
libsupport: remove the LIST_HEAD macro from list.h
libsupport: fix gcc -Wall warnings
fuse2fs: fix uninitialized variable warnings

 configure               |   8 +++
 configure.ac            |   3 +
 fuse4fs/Makefile.in     |  18 +++---
 fuse4fs/fuse4fs.c       |  29 +++++++--
 lib/config.h.in         |   3 +
 lib/support/Makefile.in |   2 +-
 lib/support/cache.c     |  49 ++++++++++++---
 lib/support/cache.h     |   2 +-
 lib/support/list.h      |  17 ++++--
 lib/support/xbitops.h   | 128 ----------------------------------------
 misc/fuse2fs.c          |  21 +++++++
 11 files changed, 125 insertions(+), 155 deletions(-)
 delete mode 100644 lib/support/xbitops.h
Signature · 1 line
2.53.0
#16 lore raw
Quoted 5 lines · Darrick J. Wong

Hm, curious. It's regrettable that I no longer have a Mac, and therefore can't really do much investigating. If you give -o default_permissions,allow_other , does that fix the problem? If that fixes it, then fuse2fs has a bug somewhere in its own permissions checking.

Nice catch! Yes, using default_permissions does fix things. So now I need to figure out what changed between v1.47.4 and next, and what default_permissions does. I notice that in kernel mode we enable default_permissions?

Can you give me a suggestion at what I might try to look at next?

- Ted

#17 lore raw
Quoted 11 lines · Theodore Tso
Quoted 5 lines · Darrick J. Wong

Hm, curious. It's regrettable that I no longer have a Mac, and therefore can't really do much investigating. If you give -o default_permissions,allow_other , does that fix the problem? If that fixes it, then fuse2fs has a bug somewhere in its own permissions checking.

Nice catch! Yes, using default_permissions does fix things. So now I need to figure out what changed between v1.47.4 and next, and what default_permissions does. I notice that in kernel mode we enable default_permissions?

Yes. Though the addition of allow_other and default_permissions was exactly the same in 1.47.4.

Quoted 1 line

Can you give me a suggestion at what I might try to look at next?

Hrm. A bisect would be the best (but least conference-friendly) option to narrow things down.

On Linux, adding "default_permissions" means that the kernel uses the same permission checking code that it uses for in-kernel filesystems. Without it, the fuse server is responsible for doing all permission checking.

And now that I've tried it, there are bugs in fuse2fs' permission checking (aka !default_permissions):

# fuse2fs /dev/sda /mnt -d -f -o iomap=0,allow_other
# mkdir /mnt/lost+found/frogs
# su - djwong
$ ls -d /mnt/ /mnt/lost+found/ /mnt/lost+found/frogs/
drwxr-xr-x 3 root root  4096 May  5 08:32 /mnt//
drwx------ 3 root root 16384 May  5 08:49 /mnt/lost+found//
drwxr-xr-x 2 root root  4096 May  5 08:49 /mnt/lost+found/frogs//

So I guess I'm still confused. I've wondered if fuse2fs should always inject default_permissions?

--D

#18 lore raw
Quoted 2 lines · Darrick J. Wong

Hrm. A bisect would be the best (but least conference-friendly) option to narrow things down.

Well, a bisect was a bit painful because I had to cherry-pick patches so I could get a successfull build. But I did finally come up with the guilty commit, and it's.... surprising at least to me:

commit b0bd58062bbf645942ab4f0aced3bb229f462dde

Author: Darrick J. Wong <[email protected]>
Date:   Thu Aug 28 10:30:40 2025 -0700

fuse2fs: cache symlink targets in the kernel

Speed up symlinks by allowing the kernel to cache them.

I don't know why it made a difference, but this attached patch appears fix the MacOS regression. Could this be a bug in MacFuse[1]? FWIW, I'm running MacFuse 5.2.0_1 from MacPorts.

[1] https://macfuse.github.io

I could condition the patch so that we only avoid setting FUSE_CAP_CACHE_SYMLINKS on MacOS? WDYT?

- Ted

From fb3d2fc975d17d97ed76b2ed76022462a3b329f1 Mon Sep 17 00:00:00 2001
From: Theodore Ts'o <[email protected]>
Date: Tue, 5 May 2026 23:34:53 +0200
Subject: [PATCH] Revert "fuse2fs: cache symlink targets in the kernel"

This reverts commit b0bd58062bbf645942ab4f0aced3bb229f462dde.

This commit is apparently causing fuse2fs on MacOS to fail without "-o default_permissions". It's not clear why, but it was determined using a git bisect, and reverting the commit addresses the regression.

---
 misc/fuse2fs.c | 3 ---
 1 file changed, 3 deletions(-)
misc/fuse2fs.c +0 -3
index c46cfc23..0f9cefa6 100644
@@ -1593,9 +1593,6 @@ static void *op_init(struct fuse_conn_info *conn,
 	if (ff->acl)
 		fuse_set_feature_flag(conn, FUSE_CAP_POSIX_ACL);
 #endif
-#ifdef FUSE_CAP_CACHE_SYMLINKS
-	fuse_set_feature_flag(conn, FUSE_CAP_CACHE_SYMLINKS);
-#endif
 #ifdef FUSE_CAP_NO_EXPORT_SUPPORT
 	fuse_set_feature_flag(conn, FUSE_CAP_NO_EXPORT_SUPPORT);
 #endif
Signature · 1 line
2.50.1 (Apple Git-155)
#19 lore raw
Quoted 18 lines · Theodore Tso
Quoted 2 lines · Darrick J. Wong

Hrm. A bisect would be the best (but least conference-friendly) option to narrow things down.

Well, a bisect was a bit painful because I had to cherry-pick patches so I could get a successfull build. But I did finally come up with the guilty commit, and it's.... surprising at least to me:

commit b0bd58062bbf645942ab4f0aced3bb229f462dde

Author: Darrick J. Wong <[email protected]>
Date:   Thu Aug 28 10:30:40 2025 -0700

fuse2fs: cache symlink targets in the kernel

Speed up symlinks by allowing the kernel to cache them.

Quoted 8 lines

I don't know why it made a difference, but this attached patch appears fix the MacOS regression. Could this be a bug in MacFuse[1]? FWIW, I'm running MacFuse 5.2.0_1 from MacPorts.

[1] https://macfuse.github.io

I could condition the patch so that we only avoid setting FUSE_CAP_CACHE_SYMLINKS on MacOS? WDYT?

I vomit a little in my mouth, because...

$ cd macfuse/Library-3
$ git grep FUSE_CAP_CACHE_SYMLINKS
<snip>
include/fuse_common.h:472:#define FUSE_CAP_CACHE_SYMLINKS (1UL << 23)

Ok, so fuse2fs passes want-flag 1<<23 into the kernel to turn on what it *thinks* are cached symlinks.

[Editor's note: this email previously contained the following text]

Unfortunately, we both now hit a brick wall, because the macfuse page says:

"This repository contains the source code of libfuse.dylib and macFUSE.framework. The other components, e.g. the macFUSE kernel extension, are closed-source."

Hence we have no way to find out what the kext thinks 1<<23 means. There's talk of some sort of "fskit" replacement for the signed kext, but I don't know where that is.

Actually, it's *MUCH* worse than that. Look at what Library-3/include/fuse_kernel.h contains:

#ifdef __APPLE__
/*
* TODO(bf)
*
* Resolve conflict with vanilla API. As long as we don't support anything
* beyond 7.19 on the kernel-side this should not be an issue. We need to clean
* this up when moving to 7.20 or later.
*/
#define FUSE_DARWIN_ACCESS_EXT (1 << 23)
#define FUSE_DARWIN_THREAD_SAFE (1 << 24)
#define FUSE_DARWIN_RENAME_EXT ((1 << 25) | (1 << 26))
#define FUSE_DARWIN_FALLOCATE (1 << 27)
#define FUSE_DARWIN_CASE_INSENSITIVE (1 << 29)
#define FUSE_DARWIN_SETVOLNAME (1 << 30)
#endif

Then look up about 30 lines:

#define FUSE_CACHE_SYMLINKS (1 << 23)
#define FUSE_NO_OPENDIR_SUPPORT (1 << 24)
#define FUSE_EXPLICIT_INVAL_DATA (1 << 25)
#define FUSE_MAP_ALIGNMENT (1 << 26)
#define FUSE_SUBMOUNTS (1 << 27)
#define FUSE_HANDLE_KILLPRIV_V2 (1 << 28)
#define FUSE_SETXATTR_EXT (1 << 29)
#define FUSE_INIT_EXT (1 << 30)

FUSE kABI 7.20 added FUSE_AUTO_INVAL_DATA, which is bit 12. It looks to me as though they decided to add their own MacOS-specific feature flags at the end of the u32 want field. Then Linux FUSE added 11 more feature flags, at which point they unthinkingly ported over FUSE_CACHE_SYMLINKS, which collides with FUSE_DARWIN_ACCESS_EXT. Apparently nobody on the macfuse end noticed, so on your machine you're getting whatever "ACCESS_EXT" does.

$searchengine has zero hits for FUSE_DARWIN_ACCESS_EXT so who knows what that actually does. But this sure is a messed up situation.

Does this work?

/* MacFUSE overlays feature bits with LinuxFUSE, this is fcked up */

#if defined(FUSE_CAP_CACHE_SYMLINKS) && !defined(FUSE_CACHE_SYMLINKS)
	fuse_set_feature_flag(conn, FUSE_CAP_CACHE_SYMLINKS);

#endif

--D

Quoted 35 lines

- Ted

From fb3d2fc975d17d97ed76b2ed76022462a3b329f1 Mon Sep 17 00:00:00 2001
From: Theodore Ts'o <[email protected]>
Date: Tue, 5 May 2026 23:34:53 +0200
Subject: [PATCH] Revert "fuse2fs: cache symlink targets in the kernel"

This reverts commit b0bd58062bbf645942ab4f0aced3bb229f462dde.

This commit is apparently causing fuse2fs on MacOS to fail without "-o default_permissions". It's not clear why, but it was determined using a git bisect, and reverting the commit addresses the regression.

---
 misc/fuse2fs.c | 3 ---
 1 file changed, 3 deletions(-)
misc/fuse2fs.c +0 -3
index c46cfc23..0f9cefa6 100644
@@ -1593,9 +1593,6 @@ static void *op_init(struct fuse_conn_info *conn,
 	if (ff->acl)
 		fuse_set_feature_flag(conn, FUSE_CAP_POSIX_ACL);
 #endif
-#ifdef FUSE_CAP_CACHE_SYMLINKS
-	fuse_set_feature_flag(conn, FUSE_CAP_CACHE_SYMLINKS);
-#endif
 #ifdef FUSE_CAP_NO_EXPORT_SUPPORT
 	fuse_set_feature_flag(conn, FUSE_CAP_NO_EXPORT_SUPPORT);
 #endif
Signature · 1 line
2.50.1 (Apple Git-155)
#20 lore raw
Quoted 7 lines · Darrick J. Wong

FUSE kABI 7.20 added FUSE_AUTO_INVAL_DATA, which is bit 12. It looks to me as though they decided to add their own MacOS-specific feature flags at the end of the u32 want field. Then Linux FUSE added 11 more feature flags, at which point they unthinkingly ported over FUSE_CACHE_SYMLINKS, which collides with FUSE_DARWIN_ACCESS_EXT. Apparently nobody on the macfuse end noticed, so on your machine you're getting whatever "ACCESS_EXT" does.

Yeah....

What MacFuse needs to do is to steal some extra fields from struct fuse_init_in and fuse_init_out for the darwin-specific capabilities. It turns out it already has conn->{want,capable}_darwin, but there's no way to pass it in and out of op_init....

#ifdef __APPLE__
	/*
	 * TODO(bf)
	 *
	 * Resolve conflict with vanilla API. We need a separate field flags for
	 * Darwin-only flags. As long as we don't support anything beyond ABI
	 * version 7.19 on the kernel-side this should not be an issue, though.
	 * We need to clean this up when moving to 7.20 or later.
	 */
	if (se->conn.want_darwin & FUSE_DARWIN_CAP_ACCESS_EXT)
		outargflags |= FUSE_DARWIN_ACCESS_EXT;

So I *guess* what MacFuse needs to do is to do something like:

struct fuse_init_in {
	uint32_t	major;
	uint32_t	minor;
	uint32_t	max_readahead;
	uint32_t	flags;
	uint32_t	flags2;
	uint32_t	unused[9];
	uint32_t	darwin_flags;
	uint32_t	darwin_flags2;
};

am I right in understanding that fuse_*_{in,out} is private between the OS's libfuse and OS's fuse driver or kernel extension, so it's not disastrous for fuse_kernel.h for Mac and Linux to drift?

Quoted 6 lines

Does this work?

/* MacFUSE overlays feature bits with LinuxFUSE, this is fcked up */

#if defined(FUSE_CAP_CACHE_SYMLINKS) && !defined(FUSE_CACHE_SYMLINKS)
	fuse_set_feature_flag(conn, FUSE_CAP_CACHE_SYMLINKS);

#endif

What I'm thinking about doing is adding at the beginning of fuse[24]fs.c:

#ifdef __APPLE__
/*
* Sigh.... MacFuse is overloading the top bits of the flags field of
* struct fuse_init_{out} so we have to avoid using these capability
* flags until this gets fixed in MacFUSE
*/
#undef FUSE_CACHE_SYMLINKS
#undef FUSE_NO_OPENDIR_SUPPORT
#undef FUSE_EXPLICIT_INVAL_DATA
#undef FUSE_MAP_ALIGNMENT
#undef FUSE_SUBMOUNTS
#undef FUSE_HANDLE_KILLPRIV_V2
#undef FUSE_SETXATTR_EXT
#undef FUSE_INIT_EXT
#endif

- Ted

#21 lore raw

[cc fuse-devel]

TLDR for the fuse developers: Ted and I discovered a collision between the upstream libfuse feature bits and the MacFUSE feature bits, which causes macfuse to do the wrong thing if you try to enable symlink pagecache.

https://lore.kernel.org/linux-ext4/20260505225635.GT7765@frogsfrogsfrogs/

Quoted 41 lines · Theodore Tso
Quoted 7 lines · Darrick J. Wong

FUSE kABI 7.20 added FUSE_AUTO_INVAL_DATA, which is bit 12. It looks to me as though they decided to add their own MacOS-specific feature flags at the end of the u32 want field. Then Linux FUSE added 11 more feature flags, at which point they unthinkingly ported over FUSE_CACHE_SYMLINKS, which collides with FUSE_DARWIN_ACCESS_EXT. Apparently nobody on the macfuse end noticed, so on your machine you're getting whatever "ACCESS_EXT" does.

Yeah....

What MacFuse needs to do is to steal some extra fields from struct fuse_init_in and fuse_init_out for the darwin-specific capabilities. It turns out it already has conn->{want,capable}_darwin, but there's no way to pass it in and out of op_init....

#ifdef __APPLE__
	/*
	 * TODO(bf)
	 *
	 * Resolve conflict with vanilla API. We need a separate field flags for
	 * Darwin-only flags. As long as we don't support anything beyond ABI
	 * version 7.19 on the kernel-side this should not be an issue, though.
	 * We need to clean this up when moving to 7.20 or later.
	 */
	if (se->conn.want_darwin & FUSE_DARWIN_CAP_ACCESS_EXT)
		outargflags |= FUSE_DARWIN_ACCESS_EXT;

So I *guess* what MacFuse needs to do is to do something like:

struct fuse_init_in {
	uint32_t	major;
	uint32_t	minor;
	uint32_t	max_readahead;
	uint32_t	flags;
	uint32_t	flags2;
	uint32_t	unused[9];
	uint32_t	darwin_flags;
	uint32_t	darwin_flags2;
};
Quoted 3 lines

am I right in understanding that fuse_*_{in,out} is private between the OS's libfuse and OS's fuse driver or kernel extension, so it's not disastrous for fuse_kernel.h for Mac and Linux to drift?

Yeah, the easiest method would be to carve out the darwin_flags field.

If they still want to use flags/flags2, then they could probably still fix it by redefining whichever feature was added later (probably FUSE_CACHE_SYMLINKS) because right now they're broken, so it's not an ABI break to redefine the symbol.

Either way someone will have to talk to the MacFUSE people about this.

Quoted 10 lines
Quoted 6 lines

Does this work?

/* MacFUSE overlays feature bits with LinuxFUSE, this is fcked up */

#if defined(FUSE_CAP_CACHE_SYMLINKS) && !defined(FUSE_CACHE_SYMLINKS)
	fuse_set_feature_flag(conn, FUSE_CAP_CACHE_SYMLINKS);

#endif

What I'm thinking about doing is adding at the beginning of fuse[24]fs.c:

Quoted 15 lines

#ifdef __APPLE__
/*
* Sigh.... MacFuse is overloading the top bits of the flags field of
* struct fuse_init_{out} so we have to avoid using these capability
* flags until this gets fixed in MacFUSE
*/
#undef FUSE_CACHE_SYMLINKS
#undef FUSE_NO_OPENDIR_SUPPORT
#undef FUSE_EXPLICIT_INVAL_DATA
#undef FUSE_MAP_ALIGNMENT
#undef FUSE_SUBMOUNTS
#undef FUSE_HANDLE_KILLPRIV_V2
#undef FUSE_SETXATTR_EXT
#undef FUSE_INIT_EXT
#endif

That works for now. If macfuse fixes themselves, then I guess we could turn that into a configure check.

--D

Quoted 2 lines

- Ted

#22 lore raw
Quoted 6 lines · Darrick J. Wong

[cc fuse-devel]

TLDR for the fuse developers: Ted and I discovered a collision between the upstream libfuse feature bits and the MacFUSE feature bits, which causes macfuse to do the wrong thing if you try to enable symlink pagecache.

This is the patch for fuse2fs and fuse4fs in e2fsprogs which works around the problem (tested on MacOS using macfuse 5.2.0_1 from MacPorts). More details about why it was needed is in the commit description.

- Ted

From 67f1ec55a1309abead16cad883e38b798a567191 Mon Sep 17 00:00:00 2001
From: Theodore Ts'o <[email protected]>
Date: Wed, 6 May 2026 10:51:56 -0400
Subject: [PATCH] fuse2fs, fuse4fs: Fix MacFuse compatibility issue

Unfortunately, MacFuse is overloading the top bits of the flags field in struct fuse_init_{out} for MacFuse-specific capability extensions. This results in an attempt to use FUSE_CAP_CACHE_SYMLINKS when linking with the libfuse in MacPorts will end up enabling FUSE_DARWIN_CAP_ACCESS_EXT with MacFuse. Hilarity then ensues with all non-privileged access failing with permission denied.

The change which is needed in MacFuse is described in a TODO(bf) statement:

https://github.com/macfuse/library/blob/ddb630db8327a50b6670ef5e4f5e6da82a549e99/lib/fuse_lowlevel.c#L3415

I plan to submit a bug report to MacFuse, but in the mean time, work around the problem by disabling the overloaded capability flags on MacOS.

---
 fuse4fs/fuse4fs.c | 18 ++++++++++++++++++
 misc/fuse2fs.c    | 18 ++++++++++++++++++
 2 files changed, 36 insertions(+)
fuse4fs/fuse4fs.c +18 -0
index 92847326..2739da92 100644
@@ -120,6 +120,24 @@
 #endif
 #endif /* !defined(ENODATA) */
 
+#ifdef __APPLE__
+/*
+ * Sigh.... MacFuse is overloading the top bits of the flags field in
+ * struct fuse_init_{out} for MacFuse-specific capability extensions.
+ * Avoid using these fuse3 capability flags until this gets fixed in
+ * MacFUSE
+ */
+#undef FUSE_CAP_CACHE_SYMLINKS
+#undef FUSE_CAP_NO_OPENDIR_SUPPORT
+#undef FUSE_CAP_EXPLICIT_INVAL_DATA
+#undef FUSE_CAP_EXPIRE_ONLY
+#undef FUSE_CAP_SETXATTR_EXT
+#undef FUSE_CAP_DIRECT_IO_ALLOW_MMAP
+#undef FUSE_CAP_PASSTHROUGH
+#undef FUSE_CAP_NO_EXPORT_SUPPORT
+#undef FUSE_CAP_OVER_IO_URING
+#endif
+
 #define FUSE4FS_ATTR_TIMEOUT	(0.0)
 
 static inline uint64_t round_up(uint64_t b, unsigned int align)
misc/fuse2fs.c +18 -0
index c46cfc23..0f2a3c35 100644
@@ -116,6 +116,24 @@
 #endif
 #endif /* !defined(ENODATA) */
 
+#ifdef __APPLE__
+/*
+ * Sigh.... MacFuse is overloading the top bits of the flags field in
+ * struct fuse_init_{out} for MacFuse-specific capability extensions.
+ * Avoid using these fuse3 capability flags until this gets fixed in
+ * MacFUSE
+ */
+#undef FUSE_CAP_CACHE_SYMLINKS
+#undef FUSE_CAP_NO_OPENDIR_SUPPORT
+#undef FUSE_CAP_EXPLICIT_INVAL_DATA
+#undef FUSE_CAP_EXPIRE_ONLY
+#undef FUSE_CAP_SETXATTR_EXT
+#undef FUSE_CAP_DIRECT_IO_ALLOW_MMAP
+#undef FUSE_CAP_PASSTHROUGH
+#undef FUSE_CAP_NO_EXPORT_SUPPORT
+#undef FUSE_CAP_OVER_IO_URING
+#endif
+
 static inline uint64_t round_up(uint64_t b, unsigned int align)
 {
 	unsigned int m;
Signature · 1 line
2.50.1 (Apple Git-155)
Reviewed-by
#23 lore raw
Quoted 30 lines · Theodore Tso
Quoted 6 lines · Darrick J. Wong

[cc fuse-devel]

TLDR for the fuse developers: Ted and I discovered a collision between the upstream libfuse feature bits and the MacFUSE feature bits, which causes macfuse to do the wrong thing if you try to enable symlink pagecache.

This is the patch for fuse2fs and fuse4fs in e2fsprogs which works around the problem (tested on MacOS using macfuse 5.2.0_1 from MacPorts). More details about why it was needed is in the commit description.

- Ted

From 67f1ec55a1309abead16cad883e38b798a567191 Mon Sep 17 00:00:00 2001
From: Theodore Ts'o <[email protected]>
Date: Wed, 6 May 2026 10:51:56 -0400
Subject: [PATCH] fuse2fs, fuse4fs: Fix MacFuse compatibility issue

Unfortunately, MacFuse is overloading the top bits of the flags field in struct fuse_init_{out} for MacFuse-specific capability extensions. This results in an attempt to use FUSE_CAP_CACHE_SYMLINKS when linking with the libfuse in MacPorts will end up enabling FUSE_DARWIN_CAP_ACCESS_EXT with MacFuse. Hilarity then ensues with all non-privileged access failing with permission denied.

The change which is needed in MacFuse is described in a TODO(bf) statement:

Quoted 8 lines

https://github.com/macfuse/library/blob/ddb630db8327a50b6670ef5e4f5e6da82a549e99/lib/fuse_lowlevel.c#L3415

I plan to submit a bug report to MacFuse, but in the mean time, work around the problem by disabling the overloaded capability flags on MacOS.

Looks fine for now...

--D

Quoted 66 lines
---
 fuse4fs/fuse4fs.c | 18 ++++++++++++++++++
 misc/fuse2fs.c    | 18 ++++++++++++++++++
 2 files changed, 36 insertions(+)
fuse4fs/fuse4fs.c +18 -0
index 92847326..2739da92 100644
@@ -120,6 +120,24 @@
 #endif
 #endif /* !defined(ENODATA) */
 
+#ifdef __APPLE__
+/*
+ * Sigh.... MacFuse is overloading the top bits of the flags field in
+ * struct fuse_init_{out} for MacFuse-specific capability extensions.
+ * Avoid using these fuse3 capability flags until this gets fixed in
+ * MacFUSE
+ */
+#undef FUSE_CAP_CACHE_SYMLINKS
+#undef FUSE_CAP_NO_OPENDIR_SUPPORT
+#undef FUSE_CAP_EXPLICIT_INVAL_DATA
+#undef FUSE_CAP_EXPIRE_ONLY
+#undef FUSE_CAP_SETXATTR_EXT
+#undef FUSE_CAP_DIRECT_IO_ALLOW_MMAP
+#undef FUSE_CAP_PASSTHROUGH
+#undef FUSE_CAP_NO_EXPORT_SUPPORT
+#undef FUSE_CAP_OVER_IO_URING
+#endif
+
 #define FUSE4FS_ATTR_TIMEOUT	(0.0)
 
 static inline uint64_t round_up(uint64_t b, unsigned int align)
misc/fuse2fs.c +18 -0
index c46cfc23..0f2a3c35 100644
@@ -116,6 +116,24 @@
 #endif
 #endif /* !defined(ENODATA) */
 
+#ifdef __APPLE__
+/*
+ * Sigh.... MacFuse is overloading the top bits of the flags field in
+ * struct fuse_init_{out} for MacFuse-specific capability extensions.
+ * Avoid using these fuse3 capability flags until this gets fixed in
+ * MacFUSE
+ */
+#undef FUSE_CAP_CACHE_SYMLINKS
+#undef FUSE_CAP_NO_OPENDIR_SUPPORT
+#undef FUSE_CAP_EXPLICIT_INVAL_DATA
+#undef FUSE_CAP_EXPIRE_ONLY
+#undef FUSE_CAP_SETXATTR_EXT
+#undef FUSE_CAP_DIRECT_IO_ALLOW_MMAP
+#undef FUSE_CAP_PASSTHROUGH
+#undef FUSE_CAP_NO_EXPORT_SUPPORT
+#undef FUSE_CAP_OVER_IO_URING
+#endif
+
 static inline uint64_t round_up(uint64_t b, unsigned int align)
 {
 	unsigned int m;
Signature · 1 line
2.50.1 (Apple Git-155)