27 Commits

Author SHA1 Message Date
Benjamin Peterson 57954f4a5f libfuse: remove libnuma dependency
As discussed on https://github.com/libfuse/libfuse/issues/1515, libfuse has
a very light dependency on libnuma, only using very light wrappers over
mmap, mbind, and munmap. Remove the libnuma dependency by calling those
syscalls directly.

Populate memory after mmap to avoid SIGBUS later.

Signed-off-by: Benjamin Peterson <benjamin@python.org>
2026-06-15 23:05:11 +02:00
Darrick J. Wong 5d8b9a39a1 mount_service: add systemd socket service mounting helper
Create a mount helper program that can start a fuse server that runs as
a socket-based systemd service, and a new libfuse module to wrap all the
details of communicating between the mount helper and the containerized
fuse server.

This enables untrusted ext4 mounts via systemd service containers, which
avoids the problem of malicious filesystems compromising the integrity
of the running kernel through memory corruption.

In theory this could also be supported via inetd and clones, though the
author hasn't found one that supports AF_UNIX sockets.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: Bernd Schubert <bernd@bsbernd.com>
2026-05-02 17:52:38 +02:00
Bernd Schubert 14cb7b93bb Add support for the new linux mount API
So far only supported for fuse_session_mount(), which is called
from high and low level API, but not yet supported for
fuse_open_channel(), which used for privilege drop through
mount.fuse. Main goal for the new API is support for synchronous
FUSE_INIT and I don't think that is going to work with
fuse_open_channel(). At least not with io-uring support as long
as it is started from FUSE_INIT.

Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2026-05-02 15:45:40 +02:00
Bernd Schubert 33ea9ec898 Add a new daemonize API
Existing example/ file systems do the fuse_daemonize() after
fuse_session_mount() - i.e. after the mount point is already
established. Though, these example/ daemons do not start
extra threads and do not need network initialization either.

fuse_daemonize() also does not allow to return notification
from the forked child to the parent.

Complex fuse file system daemons often want the order of
1) fork - parent watches, child does the work

Child:
    2) start extra threads and system initialization (like network
       connection and RDMA memory registration) from the fork child.
    3) Start the fuse session after everything else succeeded

Parent:
    Report child initialization success or failure

A new API is introduced to overcome the limitations of
fuse_daemonize()

fuse_daemonize_start() - fork, but foreground process does not
terminate yet and watches the background.

fuse_daemonize_success() / fuse_daemonize_fail() - background
daemon signals to the foreground process success or failure.

fuse_daemonize_active() - helper function for the high level
interface, which needs to handle both APIs. fuse_daemonize()
is called within fuse_main(), which now needs to know if the caller
actually already used the new API itself.

The object 'struct fuse_daemonize *' is allocated dynamically
and stored a global variable in fuse_daemonize.c, because
- high level fuse_main_real_versioned() needs to know
if already daemonized
- high level daemons do not have access to struct fuse_session
- FUSE_SYNC_INIT in later commits can only be done if the new
API (or a file system internal) daemonization is used.

Signed-off-by: Bernd Schubert <bernd@bsbernd.com>
2026-05-02 15:45:40 +02:00
Bernd Schubert dde540e413 fuse: Add ring creation
Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-04-28 19:57:39 +02:00
Bernd Schubert 805969f528 Change version to 3.17.1-rc0
Somehow really hard to set -rcX with meson.

Signed-off-by: Bernd Schubert <bernd@bsbernd.com>
2025-02-10 15:28:17 +01:00
Bernd Schubert 3f9d369d08 Increase .so version to 4
We have multiple ABI breakages - increase the .so version.

Signed-off-by: Bernd Schubert <bernd@bsbernd.com>
2024-12-30 23:04:11 +01:00
Joanne Koong 535808c4d9 Add libfuse util strtol wrapper
Add a wrapper around strtol for more rigorous error checking
and convert uses of atoi and strtol to use this instead.
2024-10-11 13:15:38 +02:00
legezywzh 949944ff3b Fix compatibility issue around fuse_custom_io->clone_fd (#953)
Fixes: 73cd124d04 ("Add clone_fd to custom IO (#927)")

Signed-off-by: Xiaoguang Wang <lege.wang@jaguarmicro.com>
2024-06-01 23:18:35 +02:00
Bernd Schubert d7560cc991 Split config.h into private and public config
This addresses https://github.com/libfuse/libfuse/issues/729

commit db35a37def introduced a public
config.h (rename to fuse_config.h to avoid conflicts) that
was installed with the package and included by libfuse users
through fuse_common.h. Probablem is that this file does not have
unique defines so that they are unique to libfuse - on including
the file conflicts with libfuse users came up.

In principle all defines could be prefixed, but then most of them
are internal for libfuse compilation only. So this splits out
publically required defines to a new file 'libfuse_config.h'
and changes back to include of "fuse_config.h" only when
HAVE_LIBFUSE_PRIVATE_CONFIG_H is defined.

This also renames HAVE_LIBC_VERSIONED_SYMBOLS to
LIBFUSE_BUILT_WITH_VERSIONED_SYMBOLS, as it actually
better explains for libfuse users what that variable
is for.
2023-02-09 10:21:29 +00:00
Bernd Schubert f212ec0870 Fix ublic/apple build for the fuse_parse_cmdline ABI symbol
For __APPLE__ and __ULIBC__, which are assumed to not support
versioned symbols, helper.c has a compat ABI symbol for
fuse_parse_cmdline(). However that ABI symbol was conflicting
with the API macro (which redirects to the right API function
for recompilations against current libfuse).
Additionally the parameter 'opts' had a typo and was called
'out_opts'.
2023-01-04 15:27:21 +00:00
Bernd Schubert 30a126c5f9 API update for fuse_loop_config additions
struct fuse_loop_config was passed as a plain struct, without any
version identifer. This had two implications

1) Any addition of new parameters required a FUSE_SYMVER for
fuse_session_loop_mt() and fuse_loop_mt() as otherwise a read
beyond end-of previous struct size might have happened.

2) Filesystems also might have been recompiled and the developer
might not have noticed the struct extensions and unexpected for
the developer (or people recomliling the code) uninitialized
parameters would have been passed.


Code is updated to have struct fuse_loop_config as an opaque/private
data type for file systems that want version 312
(FUSE_MAKE_VERSION(3, 12)). The deprecated fuse_loop_config_v1
is visible, but should not be used outside of internal
conversion functions

File systems that want version >= 32 < 312 get the previous
struct (through ifdefs) and the #define of fuse_loop_mt
and fuse_session_loop_mt ensures that these recompiled file
systems call into the previous API, which then converts
the struct. This is similar to existing compiled applications
when just libfuse updated, but binaries it is solved with
the FUSE_SYMVER ABI compact declarations.

Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2022-09-04 13:07:15 +01:00
Bill Zissimopoulos abdd45f83c Make ioctl prototype conditional on FUSE_USE_VERSION. (#482)
Define FUSE_USE_VERSION < 35 to get old ioctl prototype
with int commands; define FUSE_USE_VERSION >= 35 to get
new ioctl prototype with unsigned int commands.

Fixes #463.
2019-12-31 09:58:57 +00:00
Stefan Hajnoczi 317181e8ea Introduce callback for logging
Introduce an API for custom log handler functions.  This allows libfuse
applications to send messages to syslog(3) or other logging systems.
See include/fuse_log.h for details.

Convert libfuse from fprintf(stderr, ...) to log_fuse(level, ...).  Most
messages are error messages with FUSE_LOG_ERR log level.  There are also
some debug messages which now use the FUSE_LOG_DEBUG log level.

Note that lib/mount_util.c is used by both libfuse and fusermount3.
Since fusermount3 does not link against libfuse, we cannot call
fuse_log() from lib/mount_util.c.  This file will continue to use
fprintf(stderr, ...) until someone figures out how to split it up.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2019-09-04 15:59:18 +01:00
HazelFZ 06a31dece0 Link against libiconv when possible (#372) 2019-03-04 09:43:22 +00:00
Niels de Vos 2548c4b83a examples: add copy_file_range() support to passthrough(_fh)
The passthrough example filesystem can be used for validating the API
and the implementation in the FUSE kernel module.
2018-11-19 12:33:56 +00:00
Roman Bogorodskiy 70e25ea74e Fix build on non-Linux
* Update meson.build to add mount_util.c to libfuse_sources
   unconditionally, it's non Linux-only
 * FreeBSD, like NetBSD, doesn't have mntent.h, so don't include
   that and define IGNORE_MTAB for both
 * FreeBSD, like NetBSD, has no umount2() sysctl, so similarly define
   it to unmount()
2018-11-11 19:40:25 +00:00
Mattias Nissler da7c9b228a Add unprivileged option in mount.fuse3
The unprivileged option allows to run the FUSE file system process
without privileges by dropping capabilities and preventing them from
being re-acquired via setuid / fscaps etc. To accomplish this,
mount.fuse sets up the `/dev/fuse` file descriptor and mount itself
and passes the file descriptor via the `/dev/fd/%u` mountpoint syntax
to the FUSE file system.
2018-10-09 20:36:22 +01:00
Martin Blanchard 52469901fc Make meson build scripts subprojects friendly
Multiple meson build scripts improvements including:
 * Bump meson requirement to 0.40.1 (0.40 already required)
 * Declare a dependency object for main library
 * Stop using add_global_arguments()
 * Various minor style fixes
2018-08-25 20:17:39 +01:00
Nikolaus Rath b1a743c8eb Link with -lrt to support ancient libc
Fixes: #207.
2017-09-25 10:23:38 +01:00
Nikolaus Rath 3b6a2a5eef Correctly define fusermount3 path. 2017-09-19 20:37:46 +01:00
Joseph Dodge f12d9686d4 Add idle_threads mount option. 2017-08-24 15:17:01 +02:00
Nikolaus Rath 19eaea2e77 Allow building without iconv.
cfg.has('HAVE_ICONV') was always true.
2017-08-22 12:10:50 +02:00
Nikolaus Rath e870a0427a Added public fuse_lib_help(), bumped minor version 2017-07-08 12:48:08 +02:00
Nikolaus Rath 31ebb7b975 Don't use emacs' python-mode for meson files
There is a proper meson-mode now.
2017-07-07 15:48:50 +02:00
Nikolaus Rath 2bc480a37a lib/meson.build: don't crash if there's no libdl
For example, FreeBSD doesn't have it.

Fixes: #173.
2017-05-24 16:12:41 -07:00
Nikolaus Rath 9f96db7125 Added experimental support for building with Meson+Ninja 2017-01-12 15:19:04 -08:00