aboutsummaryrefslogtreecommitdiffstats
path: root/lib
AgeCommit message (Collapse)AuthorLines
2025-07-22fuse-over-io-uring: Remove handling of -EOPNOTSUPPBernd Schubert-11/+3
-EOPNOTSUPP was in early RFC kernel patches, but merged version does not have this handler anymore. Closes: https://github.com/libfuse/libfuse/issues/1283 Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-07-16Avoid double unmount on FUSE_DESTROYBernd Schubert-12/+24
This is a long standing issue, a system could have unmounted /path/to/mnt and then fuse-client/kernel would send FUSE_DESTROY, which would then again try a umount. Given that FUSE_DESTROY is async, that umount might arrive any time later and might possibly unmount a wrong mount point. A warning as in issue #1286 is just minor to that. Code wise this uses atomics to free the char *, as FUSE_DESTROY might race with a signal and a double free might be possible without proctection. A lock might run into the same issue, if the signal would arrive at the wrong time a double lock would be possible. Additionally, fuse_session_mount() is updated, to first duplicatate the pointer and to then do the kernel mount - reverting the kernel mount in case of strdup() failure is much harder. Closes: https://github.com/libfuse/libfuse/issues/1286 Signed-off-by: Bernd Schubert <bernd@bsbernd.com>
2025-07-16Add statx supportJoanne Koong-1/+214
This commit adds libfuse support for FUSE_STATX requests on linux distributions. Currently, statx is only supported on linux. To make the interface a ergonomic as possible (eg using native 'struct statx' vs 'struct fuse_statx'), this implementation gates the 'struct statx' changes by #ifdef linux. Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
2025-06-27license: s/COPYING/GPL2.txt, s/COPYING.LIB/LGPL2.txtizxl007-21/+21
Signed-off-by: izxl007 <zeng.zheng@zte.com.cn>
2025-06-25Catch up with fuse_send_data_iov() signature changes in the fallback caseGleb Popov-2/+3
Signed-off-by: Gleb Popov <6yearold@gmail.com>
2025-06-22Clarify offset field is signed despite uint64_t typeizxl007-0/+4
Add comment noting that the uint64_t offset in fuse_lseek_in is derived from kernel loff_t and should be treated as signed for negative offsets. Signed-off-by: izxl007 <zeng.zheng@zte.com.cn>
2025-06-18fuse: add support to FUSE_NOTIFY_INC_EPOCHLuis Henriques-0/+14
This patch adds support for the FUSE INC_EPOCH notify. This new operation simply increments the FUSE connection epoch value, allowing to invalidate all the dentries next time they are revalidated. Signed-off-by: Luis Henriques <luis@igalia.com>
2025-06-17mount_util.c: check if utab exists before updateGeorgi Valkov-0/+4
Do not attempt to update /run/mount/utab if it doesn't exist. Note: if this path ever changes, utab updates will break. Fixes the following error when mounting iPhone using ifuse: ifuse /mnt --container com.httpstorm.httpstorm mount: mounting ifuse on /mnt failed: Invalid argument On OpenWRT by default mount-utils is not installed and utab does not exist. /bin/mount is a symlink to /bin/busybox and does not support updating of utab. If mount-utils is installed: /run/mount/ exists, but does not contain utab. The mount-utils instance is under /usr/bin/mount, so a hard-coded call to /bin/mount will still fail. Using /usr/bin/mount succeeds but does not create utab. [1] https://github.com/libfuse/libfuse/pull/1247 Signed-off-by: Georgi Valkov <gvalkov@gmail.com>
2025-06-17Fix io-uring teardownBernd Schubert-4/+10
We need to write an uint64_t to eventfd. Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-06-12help: Remove duplicate io_uring options from fuse_cmdline_helpizxl007-5/+1
The io_uring options are currently shown in both fuse_cmdline_help() and fuse_lowlevel_help(), which creates unnecessary duplication. Since io_uring is a low-level I/O feature, it makes more sense to only show these options in fuse_lowlevel_help(). This change: - Removes io_uring options from fuse_cmdline_help() - Keeps them in fuse_lowlevel_help() where they belong - Removes the FIXME comment that is no longer needed This is purely a documentation improvement and does not affect any functionality. Users will still see all available options when using --help, just organized in a more logical way. Signed-off-by: izxl007 <zeng.zheng@zte.com.cn>
2025-06-12fuse_signals.c: fix build warning when HAVE_BACKTRACE is undefinedGeorgi Valkov-0/+2
BT_STACK_SZ and backtrace_buffer are not used when HAVE_BACKTRACE is undefined. Wrap them in #ifdef to avoid a build warning: ../lib/fuse_signals.c:31:14: warning: 'backtrace_buffer' defined but not used [-Wunused-variable] 31 | static void *backtrace_buffer[BT_STACK_SZ]; | ^~~~~~~~~~~~~~~~ Signed-off-by: Georgi Valkov <gvalkov@gmail.com>
2025-06-10mount_bsd.c: Fix race between actual mounting and returning to the callerGleb Popov-1/+2
Signed-off-by: Gleb Popov <6yearold@gmail.com>
2025-05-28fuse_lowlevel.c: Remove duplicate descriptions of auto_unmountizxl007-1/+0
Signed-off-by: izxl007 <zeng.zheng@zte.com.cn>
2025-05-22Fix build in musl libcLuis Henriques-7/+6
Function fuse_set_thread_name() assumes that pthread_t is an unsigned long and fails to compile in musl libc with the following: ../lib/util.c: In function 'fuse_set_thread_name': ../lib/util.c:48:28: error: passing argument 1 of 'pthread_setname_np' makes \ pointer from integer without a cast [-Wint-conversion] Fix fuse_set_thread_name() by dropping the 'tid' parameter, as it is always set to pthread_self(). Signed-off-by: Luis Henriques <luis@igalia.com>
2025-05-20conn->want conversion: Fix fuse_apply_conn_info_opts()Bernd Schubert-47/+99
fuse_apply_conn_info_opts() was applying to 'want_ext', which would cause conflicts with 'want' if the application applied its own flags to 'conn->want'. Solution is: - to move fuse_{set,unset,get}_feature_flag and convert_to_conn_want_ext() to fuse_lowlevel.c and to define them as part of the public API, although convert_to_conn_want_ext() should not be used - it is currently needed to be a public function due as it needs to be defined for the tests. Related to https://github.com/libfuse/libfuse/issues/1171 and https://github.com/libfuse/libfuse/pull/1172. Closes: https://github.com/libfuse/libfuse/issues/1171 Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-05-20Make conn->want/want_ext conversion non fatalBernd Schubert-27/+3
there are too many issues with conn->want and conn->want_ext conversion, for now just log a warning, but setting both flags is now not fatal anymore. Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-04-30Support request timeoutsJoanne Koong-0/+5
This adds the libfuse changes needed to support request timeouts. A timeout may be set by the server in its init call. If a request is not completed by the timeout, the connection will be aborted by the kernel. Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
2025-04-29fuse_lowlevel.c: Fix a small spelling mistakeizxl007-1/+1
Signed-off-by: izxl007 <zeng.zheng@zte.com.cn>
2025-04-28lib/fuse.c: refactor handler logic for readabilityJoanne Koong-450/+399
Refactor handler logic to make it more readable. No functional changes. Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
2025-04-28Add a README for fuse-over-io-uringBernd Schubert-2/+1
Also update the comment description of fuse_uring.c Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-04-28Set FUSE_CAP_OVER_IO_URING flag - allow io-uring modeBernd Schubert-0/+3
So far it was disabled as the series was not complete yet. Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-04-28env variables to override default io-uring enable and q-depthBernd Schubert-2/+11
We want to especially test with and without io-uring being enabled. Ideally without modifying all tests - that is what the env variable can be used for. Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-04-28Add fuse_req_is_uring() to check if a req comes through io-uringBernd Schubert-0/+10
This might be useful to optimize code paths. For example, with io-uring the request buffer is valid until the request is replied to, while without io-uring the request buffer is only valid in current thread context. Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-04-28fuse: Add io-uring optionsBernd Schubert-2/+18
Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-04-28Add fuse-io-uring reply supportBernd Schubert-27/+222
Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-04-28Add fuse_session_process_uring_cqeBernd Schubert-37/+111
Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-04-28Add a basic io-uring cqe handlerBernd Schubert-3/+92
Not function yet, just preparation. Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-04-28fuse_ll_ops: Make fuse_ino_t constBernd Schubert-1/+1
It will never be modified, should be const. Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-04-28fuse_lowlevel: Split fuse_send_msgBernd Schubert-19/+32
The actual function to write to /dev/fuse is offloaded into _fuse_send_msg() Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-04-28Add support for ring creation in fuse_lowlevel.cBernd Schubert-3/+63
Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-04-28fuse: Add ring creationBernd Schubert-3/+595
Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-04-28Add a fuse_set_thread_name() helperBernd Schubert-7/+23
Avoid splattering the code with ifdef Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-04-28Add container_of and ROUND_UP macrosBernd Schubert-8/+6
Needed by follow up commits. container_of is actually just moved/consolidated to util.h. Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-04-28fuse_lowlevel: Add support for header/payload separationBernd Schubert-171/+608
Header/payload separation is part of the fuse-io-uring protocol and might be later on for /dev/fuse legacy communication as well. This is a preparation commit, for now fuse_ll_ops2 is unused. Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-04-24Fix multi-threaded fuse session exitBernd Schubert-39/+61
Issue with previous code was that fuse_session_exit() didn't wake up the semaphore in fuse_loop_mt.c. Lock, semaphore and all uses of checking for "exited" are now moved to struct fuse_session to have it available for the signal handler. This also removes internal fuse_session_reset() calls, as that makes testing hard. From git history I also don't see why it was added. Closes: https://github.com/libfuse/libfuse/issues/997 Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-04-23signal handlers: Store fuse_session unconditionallyBernd Schubert-4/+9
Commit dae1184 ("Add syslog and fatal signal handler feature") added fuse_set_fail_signal_handlers() which can store "se". But as fuse_set_signal_handlers() also stores the object storing it was made conditionally if not set already. As per https://github.com/libfuse/libfuse/issues/1182 this breaks some applications like osspd, that have multiple sessions and rely on the right order and that the last call of fuse_set_signal_handlers() wins. Special thanks to Sébastien Noel to debug this issue. Closes: https://github.com/libfuse/libfuse/issues/1182 Signed-off-by: Bernd Schubert <bernd@bsbernd.com>
2025-04-23Check if pthread_setname_np() exists before use itGiulio Benetti-0/+4
Since pthread_setname_np() is the only pthread function that requires NPTL and it basically only set thread name, let's check if pthread_setname_np() does exist, otherwise let's not call pthread_setname_np() to shrink dependencies. Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
2025-04-16conn: prevent duplicate flag conversion in high-level interfaceBernd Schubert-0/+3
The high-level interface triggers flag conversion twice: once in the high-level init and once in the low-level init. This caused false "both 'want' and 'want_ext' are set" errors when using fuse_set_feature_flag() or fuse_unset_feature_flag(). The existing check for duplicate conversion only worked when 32-bit flags were set directly. When using the preferred flag manipulation functions, conn->want and the lower 32 bits of conn->want_ext would differ, triggering the error. Fix this by synchronizing conn->want with the lower 32 bits of conn->want_ext after conversion, ensuring consistent state for subsequent calls. Closes: https://github.com/libfuse/libfuse/issues/1171 Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-04-15mount: Add FUSE_KERN_DEVICE env variable to specify fuse kernel deviceMeng Lu Wang-2/+5
For kernel development it might be necessary to load a module with renamed symbols and renamed /dev/<devicenode>. Reason is that for example ubuntu kernels have fuse compiled in and it is not possible to replace it at run time. And fuse might also be used for other file systems - a different device node is then needed. Also consolidate device path handling and remove unnecessary string duplication in mount_fuse() in fusermount.c. Signed-off-by: Meng Lu Wang <mwang@ddn.com>
2025-04-07fuse_lowlevel: Set bufsize if HAVE_SPLICE is not define and avoid raceBernd Schubert-6/+10
These are several buf size fixes 1) Set bufsize when HAVE_SPLICE is not defined. Addresses https://github.com/libfuse/libfuse/issues/1184 2) Check in the read retry condition for bufsize, i.e. the value passed to read and not for the buf->mem_size. Using buf->mem_size can be startup racy. Additionally we now also set bufsize on allocation to avoid these races. 3) Allocation and value assigned needs to follow the pattern bufsize = se->bufsize; buf_alloc(bufsize, internal) buf->mem_size = bufsize; I.e. bufsize has to be retrieved first, as se->bufsize might change at anytime - the value used for allocation and must not differ from the value actually used. This also tries to set large sizes in passthrough_hp, to catch issues in xfstests - though requires to set /proc/sys/fs/fuse/max_pages_limit Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-04-04meson: add option for enabling usdtJoanne Koong-1/+26
Default is having usdt disabled. Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
2025-04-02fuse_lowlevel: add tracepoints for request receiving, processing, and replyingJoanne Koong-0/+23
Add user statically-defined tracepoints for request lifecycle. Verified by: [machine]$ readelf -n /home/libfuse/build/lib/libfuse3.so | grep -A 1000 '.note.stapsdt' Displaying notes found in: .note.stapsdt Owner Data size Description stapsdt 0x00000035 NT_STAPSDT (SystemTap probe descriptors) Provider: libfuse Name: request_receive Location: 0x0000000000016360, Base: 0x00000000000002fc, Semaphore: 0x0000000000000000 Arguments: -4@%edi stapsdt 0x00000055 NT_STAPSDT (SystemTap probe descriptors) Provider: libfuse Name: request_reply Location: 0x0000000000017c0f, Base: 0x00000000000002fc, Semaphore: 0x0000000000000000 Arguments: 8@8(%r12) 4@(%r12) -4@4(%r12) -4@%r13d stapsdt 0x0000003e NT_STAPSDT (SystemTap probe descriptors) Provider: libfuse Name: request_process Location: 0x000000000001acf7, Base: 0x00000000000002fc, Semaphore: 0x0000000000000000 Arguments: 4@%r8d 4@%edx Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
2025-04-02lib: Add usdt.hJoanne Koong-0/+540
Copy over usdt.h from [1] as part of the prepatory work for adding tracepoints for requests. [1] https://github.com/libbpf/usdt Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
2025-03-24fuse: Fix want flag conversionBernd Schubert-29/+99
32-bit conn->want flags been left to be ABI compatible to 3.10, even though the so version was changed. The more recent way is to use fuse_set_feature_flag(), which will use conn->want_ext. Given that we now have two flags (want and want_ext), we need to convert and that brought several issues - If the application sets conn->want, that needs to be set into the lower 32 bit of conn->want_ext. As the application might actually unset values, it really has to be a copy and not just 'or' - fixed now. - convert_to_conn_want_ext() actually needs to check for _modified_ conn->want and conn->want_ext - convert_to_conn_want_ext() must consider being called from high and lowlevel interfact, with different want_ext_default and want_default values. It is only a failure, if the application changed both, conn->want and conn->want_ext. This function was failing in issue #1171, because high level fuse_fs_init() was changing values and then lowlevel do_init() was incorrectly failing on that. This also adds a new test (test_want_conversion) and sets values into example/{hello.c,hello_ll.c} Also some more internal users of conn->want are converted to fuse_{set,unset}_feature_flag(). Closes: https://github.com/libfuse/libfuse/issues/1171 Signed-off-by: Bernd Schubert <bernd@bsbernd.com>
2025-03-24convert LL_ENABLE/LL_DISABLE to do-while-loopBernd Schubert-4/+11
This is to avoid checkpatch reports and might potentially avoid future issues if these macros would be part of conditions. Signed-off-by: Bernd Schubert <bernd@bsbernd.com>
2025-03-14fuse_lowlevel: Simplify se->buf_reallocableBernd Schubert-12/+18
se->buf_reallocable is true when reading /dev/fuse is handled from internal functions - we can set the variable in fuse_session_receive_buf_internal(). With that we also don't need to have it an _Atomic variable anymore. In _fuse_session_receive_buf() we can use "bool internal" to check if the buffer can be re-allocated. Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-03-14fuse_session_receive_buf: Fix the pipe buf sizeBernd Schubert-3/+13
This fixes dynamic buffer allocation in commit 0e0f43b79b9b ("Reallocate fuse_session buffer...") I noticed that when I increased the default fuse buf size as possible in recent kernels. Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-02-20fuse_log: simplify default log functionVassili Tchersky-42/+5
fuse_log_level is guaranteed to be the same as libc as syslog is a network protocol and levels are numerical constants enforced in RFCs. Syslog is originally BSD-only and was imported by glibc and standardised in SUS and POSIX. Use vsyslog rather than formatting a new intermediate string. Signed-off-by: Vassili Tchersky <vt+git@vbc.su>
2025-02-19mount: fix closing stdout/err and error logsVassili Tchersky-10/+11
Don't spawn a setuid children with FD 1&2 closed. Check status and not errno after posix_spawn(p). Add comments to fix later error checking, as posix_spawn(p) returns non-zero status only if clone/vfork/rfork fails. If only setup (open, dup2) or execve fails, the forked process exit with 127 but posix_spawn returns zero. Signed-off-by: Vassili Tchersky <vt+git@vbc.su>
2025-02-18Avoid nested function declarations in helper functionsBernd Schubert-19/+2
libfuse-3.17 introduced several functions that should only be called via inlined helper functions, never directly. To enforce this, these functions were declared within the inlined functions. However, this triggers the compiler warning "-Werror=nested-externs". While this warning is valid, the nested declarations were intentional to prevent direct usage of these functions. Rather than suppressing the warning with pragmas, move these function declarations outside the helper functions while maintaining the intended access restrictions through other means. Closes: https://github.com/libfuse/libfuse/issues/1134 Signed-off-by: Bernd Schubert <bschubert@ddn.com>