aboutsummaryrefslogtreecommitdiffstats
path: root/lib
AgeCommit message (Collapse)AuthorLines
2025-09-22fuse_loop_mt: Don't create new workers before init is receivedBernd Schubert-1/+2
This is to prevent startup races. For example it is hard for threads to know the buffer size the kernel usage. In the past kernel buffer size always was max 1MB, but in the mean time this might be more, depending on system tunings. I thought I had fixed all races, but the report in issue #1296 proves otherwise. Closes: https://github.com/libfuse/libfuse/issues/1296 Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-09-19io-uring: re-initialize fields in struct fuse_reqBernd Schubert-19/+26
In io-uring mode these requests are always re-used and not allocated - we need to re-initialize them. In order to set flags to zero a struct holding the flags had to be added. Signed-off-by: Bernd Schubert <bernd@bsbernd.com>
2025-09-19fuse_log: Add __attribute__((format(printf, ) and fix warningsBernd Schubert-15/+23
fuse_log() did not have that attribute and so compilers didn't give warnings for plain printf(). Add the attribute and fix related warnings. Signed-off-by: Bernd Schubert <bernd@bsbernd.com>
2025-09-19fuse_lowlevel.c: allow passing ops as NULLAlik Aslanyan-1/+25
During testing of LACT using various sanitizers issue with libfuse.so leaking memory and reading uninitialized memory was uncovered. While this was due to ABI misusage on the side of fuser (Rust wrapper for libfuse.so), we now allow creating a no-op session by passing ops as NULL. fuser and other libfuse users is using fuse_session_new() with NULL struct fuse_lowlevel_ops *op and op_size=0. This resulted in a warning, but otherwise succeeded. The resulting fuse_session is just passed to fuse_session_mount() so that libfuse could do the actual mount. Fuse kernel request handling is not done through libfuse but their own layer. Edit by Bernd: - Update the commit message - moved using null_ops to fuse_session_new_30() as that is actually called by the external fuse_session_new(). - forbidding NULL struct fuse_lowlevel_ops *op and 0 op_size in fuse_session_new_versioned() - various other NULL ptr checks in fuse_session_new() that now result in failure. Signed-off-by: Alik Aslanyan <inline0@pm.me> Signed-off-by: Bernd Schubert <bernd@bsbernd.com>
2025-09-13libfuse: fix COPY_FILE_RANGE interfaceMiklos Szeredi-5/+62
The FUSE protocol uses struct fuse_write_out to convey the return value of copy_file_range, which is restricted to uint32_t. But the COPY_FILE_RANGE interface supports a 64-bit size copies. Currently the number of bytes copied is silently truncated to 32-bit, which is unfortunate at best. Implement the COPY_FILE_RANGE_64 interface which is identical to the old one, except the number of bytes copied is returned in a 64-bit value. The library interface remains the same. If the kernel does not support the new interface or the server is running as a 32-bit process, limit the copy size to size to UINT_MAX - 4096. Edit by Bernd: Keep ioctl_64bit and add use new bit is_copy_file_range_64 to keep flags separated from each other - easier code readability IMO. Reported-by: Florian Weimer <fweimer@redhat.com> Closes: https://lore.kernel.org/all/lhuh5ynl8z5.fsf@oldenburg.str.redhat.com/ Signed-off-by: Miklos Szeredi <mszeredi@redhat.com> Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-08-22send_reply_uring: Avoid memcpy if src and dest are identicalBernd Schubert-1/+2
The application might have just written directly into the payload to no need to copy it and in fact, using memcpy would be undefined behavior. Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-08-22Allow applications to retrieve the req payload (io-uring only)Bernd Schubert-0/+37
With io-uring the req owns the payload buffer, the application can directly access it and copy data into it. fuse_buf_copy_one() already has a check for dstmem == srcmem and skips data copies. fuse_reply_data fuse_reply_data_uring fuse_buf_copy fuse_buf_copy_one Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-08-22fuse-io-uring: Release io-uring resources on io-uring startup failureBernd Schubert-0/+5
Operation might continue without io-uring, so just free these resources. Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-08-22fuse-io-uring: Fix double count of ring_pool->failed_threadsBernd Schubert-3/+0
This is already done a few lines below. And actually no reason to hold the lock at all given the variables are atomics now. Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-08-22io-uring startup: Fix spinning and variable readBernd Schubert-10/+15
Reported-by: lixianming <lixianming.19951001@bytedance.com> Closes: https://github.com/libfuse/libfuse/pull/1317 Signed-off-by: Bernd Schubert <bernd@bsbernd.com>
2025-08-12fuse_loop_mt.c: fix close-on-exec flag on clone fdCismonX-3/+9
Closes: https://github.com/libfuse/libfuse/issues/1310 Signed-off-by: CismonX <admin@cismon.net>
2025-08-04mount_bsd.c: Actually report mount failures back to callerGleb Popov-1/+3
Signed-off-by: Gleb Popov <6yearold@gmail.com>
2025-07-22high level: Remove the nullpath_ok log messageBernd Schubert-4/+0
This seems to be a left over - the file system has to set this variable in its ->init method, i.e. logging it in startup is not giving any helpful output. Closes: https://github.com/libfuse/libfuse/issues/1272 Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-07-22fuse_uring_i.h: Include errno.hBernd Schubert-0/+2
Needed for ENOTSUP Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-07-22Split fuse-io-uring startupBernd Schubert-9/+71
Start the ring threads before sending fuse_reply_ok() so that io-uring startup issues can be non-fatal. Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-07-22fuse-io-uring: Add sanity check for the number of queue entriesBernd Schubert-2/+7
fuse-io-uring would create a blocking mount with 0 queue entries, we need a sanity check for it. Signed-off-by: Bernd Schubert <bschubert@ddn.com>
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>