Skip to content

Commit 46c2449

Browse files
committed
Add libfuse 3 support, default on Linux
configure prefers fuse3 (>= 3.4.0) on Linux and falls back to fuse2 when the fuse3 development files are absent, so existing build environments keep working; --with-fuse2 forces the legacy API and remains the default on macOS, FreeBSD, and NetBSD. FUSE_USE_VERSION becomes 31 for fuse3 builds. README documents the new prerequisites and mount options. API changes for FUSE 3: - getattr/truncate absorb fgetattr/ftruncate via the fuse_file_info argument; chmod, chown, and utimens gain the argument and use the file handle when the path is NULL (possible under nullpath_ok). - rename handles flags: RENAME_NOREPLACE returns EEXIST when the target exists, RENAME_EXCHANGE is rejected with EINVAL. - readdir and the directory filler gain flag arguments. - init receives struct fuse_config; use_ino, hard_remove, and nullpath_ok move there from mount options. - FUSE_CAP_ASYNC_READ is cleared in init to keep tape reads ordered; FUSE 3 removed the -o sync_read option and enables asynchronous reads by default. - big_writes is gone (always enabled); fuse_parse_cmdline uses struct fuse_cmdline_opts. The fuse2 code paths are unchanged and selected with --with-fuse2.
1 parent e411539 commit 46c2449

5 files changed

Lines changed: 238 additions & 16 deletions

File tree

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ These instructions will get you a copy of the project up and running on your loc
3838
* automake 1.13.4 or later
3939
* autoconf 2.69 or later
4040
* libtool 2.4.2 or later
41-
* fuse 2.6.0 or later
41+
* fuse3 3.4.0 or later (default), or fuse 2.6.0 or later with `--with-fuse2`
4242
* uuid 1.36 or later (Linux)
4343
* libxml-2.0 2.6.16 or later
4444
* net-snmp 5.3 or later
@@ -198,8 +198,26 @@ make install
198198

199199
`./configure --help` shows various options for build and install.
200200

201+
On Linux the build uses libfuse 3 (package `libfuse3-dev` on Debian/Ubuntu,
202+
`fuse3-devel` on Fedora/RHEL). Pass `--with-fuse2` to build against the
203+
legacy libfuse 2 API instead; macOS, FreeBSD, and NetBSD currently use the
204+
libfuse 2 API by default.
205+
206+
FUSE 3 builds negotiate request sizes up to 1 MiB (tunable with
207+
`-o max_write=<bytes>`), serve directory listings through readdirplus, and
208+
support `-o direct_io` to bypass the kernel page cache entirely so large
209+
archive jobs do not fill it (mmap does not work on files opened this way).
210+
201211
In some systems, you might need `sudo ldconfig -v` after `make install` to load the shared libraries correctly.
202212

213+
## Running the test suite
214+
215+
`make check` runs integration tests against a tape emulated in a local
216+
directory by the file backend; no tape hardware is required. The tests need
217+
a Linux host with `/dev/fuse` and are skipped elsewhere. On macOS,
218+
`tests/run-in-docker.sh [configure-options...]` builds and runs the suite
219+
inside an Ubuntu container.
220+
203221
#### Parameter settings of the sg driver
204222

205223
LTFS uses the sg driver by default. You can improve reliability to change parameters of the sg driver below.

configure.ac

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,39 @@ fi
289289
dnl
290290
dnl Check for FUSE, libuuid, and libxml2
291291
dnl
292-
PKG_CHECK_MODULES([FUSE_MODULE], [fuse >= 2.6.0])
292+
dnl libfuse 3 is preferred on Linux, falling back to libfuse 2 when the
293+
dnl fuse3 development files are not installed. --with-fuse2 forces the
294+
dnl legacy libfuse 2 API; it is also the default on the other platforms
295+
dnl until their fuse3 stacks are verified.
296+
dnl
297+
AC_ARG_WITH([fuse2],
298+
[AS_HELP_STRING([--with-fuse2],
299+
[build against libfuse 2 instead of libfuse 3])],
300+
[with_fuse2=$withval],
301+
[with_fuse2=default])
302+
if test "x${with_fuse2}" = "xdefault" && test "x${host_linux}" != "xyes"
303+
then
304+
with_fuse2=yes
305+
fi
306+
307+
if test "x${with_fuse2}" = "xyes"
308+
then
309+
PKG_CHECK_MODULES([FUSE_MODULE], [fuse >= 2.6.0])
310+
elif test "x${with_fuse2}" = "xno"
311+
then
312+
PKG_CHECK_MODULES([FUSE_MODULE], [fuse3 >= 3.4.0])
313+
else
314+
PKG_CHECK_MODULES([FUSE_MODULE], [fuse3 >= 3.4.0],
315+
[with_fuse2=no],
316+
[PKG_CHECK_MODULES([FUSE_MODULE], [fuse >= 2.6.0], [with_fuse2=yes])])
317+
fi
318+
AC_MSG_CHECKING([for the FUSE API version to use])
319+
if test "x${with_fuse2}" = "xyes"
320+
then
321+
AC_MSG_RESULT([2])
322+
else
323+
AC_MSG_RESULT([3])
324+
fi
293325
PKG_CHECK_MODULES([LIBXML2_MODULE], [libxml-2.0 >= 2.6.16])
294326

295327
if test "x${host_mac}" = "xyes"
@@ -461,6 +493,10 @@ dnl Update flags
461493
dnl Sets CFLAGS to force optimization and debugging options, which isn't quite kosher
462494
dnl
463495
AM_CPPFLAGS="-D_GNU_SOURCE -I\$(top_srcdir)/src -DLTFS_CONFIG_FILE='\"${sysconfdir}/ltfs.conf\"' -DLTFS_BASE_DIR='\"${prefix}\"'"
496+
if test "x${with_fuse2}" != "xyes"
497+
then
498+
AM_CPPFLAGS="${AM_CPPFLAGS} -DHAVE_FUSE3"
499+
fi
464500
AM_CFLAGS="-Wall -Wsign-compare -fsigned-char ${FUSE_MODULE_CFLAGS} ${UUID_MODULE_CFLAGS} ${LIBXML2_MODULE_CFLAGS} ${ICU_MODULE_CFLAGS} ${SNMP_ENABLE} ${SNMP_MODULE_CFLAGS}"
465501

466502
if test "x$use_fast" = "xyes"

src/libltfs/ltfs_fuse_version.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@
5050
#ifndef __ltfs_fuse_version_h__
5151
#define __ltfs_fuse_version_h__
5252

53+
/* HAVE_FUSE3 is set on the compiler command line by configure
54+
* (default on Linux; --with-fuse2 selects the libfuse 2 API). */
55+
#ifdef HAVE_FUSE3
56+
#define FUSE_USE_VERSION 31
57+
#else
5358
#define FUSE_USE_VERSION 26
59+
#endif
5460

5561
#endif /* __ltfs_fuse_version_h__ */

0 commit comments

Comments
 (0)