aboutsummaryrefslogtreecommitdiffstats
path: root/lib
AgeCommit message (Collapse)AuthorLines
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>
2025-02-18mount_bsd: Remove unused headersVassili Tchersky-4/+0
Removed: - <sys/user.h>: used to be for kinfo_proc, long gone from the code - <paths.h>: used to be for _PATH_DEV and _PATH_DEVNULL, long gone - <limits.h>: used to be for _POSIX2_LINE_MAX, long gone - <sys/stat.h>: used to be for fstat/stat, long gone Signed-off-by: Vassili Tchersky <vt+git@vbcy.org>
2025-02-18mount_bsd: Show errors when syscalls failedVassili Tchersky-3/+7
Log on unmount() and close() failure Signed-off-by: Vassili Tchersky <vt+git@vbcy.org>
2025-02-18mount_bsd: Proper exit callsVassili Tchersky-4/+4
Use _exit() instead of exit() inside children Signed-off-by: Vassili Tchersky <vt+git@vbcy.org>
2025-02-18FreeBSD: Remove useless optionsVassili Tchersky-31/+6
These options never had any effect. See https://svnweb.freebsd.org/base?view=revision&revision=347544 Signed-off-by: Vassili Tchersky <vt+git@vbcy.org>
2025-02-18mount_bsd: Fix usage of libfuse_strtolVassili Tchersky-3/+4
The check on fd < 0 was recently removed. However, this check is important as the content of FUSE_DEV_FD is passed as-is to mount_fusefs, and a string beginning by '-' is treated as an option. Additionally, add a proper include and type. Signed-off-by: Vassili Tchersky <vt+git@vbcy.org>
2025-02-10Change version to 3.17.1-rc0Bernd Schubert-3/+7
Somehow really hard to set -rcX with meson. Signed-off-by: Bernd Schubert <bernd@bsbernd.com>
2025-02-10fuse_new version fixes: Change to fuse_new_versionedBernd Schubert-10/+8
Another additon for https://github.com/libfuse/libfuse/issues/1092 Use _fuse_new_versioned() instead of _fuse_new_317 and actually also remove symbol versioning for it - we don't need it. Signed-off-by: Bernd Schubert <bernd@bsbernd.com>
2025-02-09Rename to fuse_session_new_versionedBernd Schubert-32/+28
Similar previous renames to fuse_main_real_versioned, but here for the low level fuse_session_new. Also remove symbol versioned as part of "fuse_session_new" as that function is not part of the official API/ABI and to allow easier access with dlopen/dlsym. Also switch back to a macro fuse_session_new, just in case some code has some expectations on that. Signed-off-by: Bernd Schubert <bernd@bsbernd.com>
2025-02-09Make fuse_main a macro again and wrap that to fuse_main_fnBernd Schubert-1/+1
As suggested by Bill in Issue #1092 make fuse_main a macro again, just in case some applications expect it to be a macro. Signed-off-by: Bernd Schubert <bernd@bsbernd.com>
2025-02-09Rename fuse_main_real_317 to fuse_main_real_versionedBernd Schubert-6/+8
As suggested by Bill in Issue #1092, rename to _versioned so that applications using dlopen/dlvsym better understand the meaning of this function. Signed-off-by: Bernd Schubert <bernd@bsbernd.com>
2025-01-31fuse_lowlevel.c: drop incorrect comment from convert_to_conn_want_ext()Luis Henriques-2/+0
The comment is probably a leftover from older versions, as the application of the 32 bits of conn.capable_ext to conn.capable is done before function convert_to_conn_want_ext() is invoked. Signed-off-by: Luis Henriques <luis@igalia.com>
2025-01-31fuse_lowlevel.c: fix possible 64 bits value truncationLuis Henriques-1/+1
Because conn.want_ext is a uint64_t, copying it into a uint32_t may result in truncating it's value. This patch fixes a bug in do_init() where the 32 bits copy is again converted into a 64 bits value, because it will be used in convert_to_conn_want_ext(). Signed-off-by: Luis Henriques <luis@igalia.com>
2025-01-28lib: Set thread namesBernd Schubert-0/+8
Main worker threads: fuse_worker high level clean up threads: "fuse_prune_nodes" Signed-off-by: Bernd Schubert <bernd@bsbernd.com>
2025-01-13Identify the FD hold by parent processZegang-0/+17
Issue: There is no directly way to get the FD hold by parent process which asked do fuse mount. Use Case: For auto_unmount case, identify the FD can easy to close the FD and make automatically unmount manually and explicitly. The FD[1] can be got via getenv(FUSE_COMMFD2_ENV). One potential use case is to satisfy FD-Leak checks. Solution: Add an extra env _FUSE_COMMFD2 to store the FD. This will provide a easy way to get the FD via FUSE_COMMFD2_ENV. Signed-off-by: Zegang Luo <zegang.luo@qq.com>
2025-01-06Make fuse_main_real() not symboledBernd Schubert-17/+16
Addresses https://github.com/libfuse/libfuse/issues/1092 We actually don't need to make fuse_main_real() symboled, as it is not part of the official API. The inlined function now always calls into fuse_main_real_317 and the compat ABI function (which should also be available for dlopen/dlsym) is now always compiled, independent if the compiler/linker support versioned symbols. Additionally, fuse_main_real() is also declared as inlined function and a warning message is created when that function is called. Signed-off-by: Bernd Schubert <bernd@bsbernd.com>
2025-01-06Avoid global declarion of internal functions that are new in 3.17Bernd Schubert-6/+21
_fuse_new() is not supposed to be called by external users outside of internal functions or static inlined functions. This also removes several functions from lib/fuse_versionscript which where added and exported by commit 58f85bfa9b7d ("Add in the libfuse version a program...) as these are libfuse internal only. Signed-off-by: Bernd Schubert <bernd@bsbernd.com>
2025-01-06Fix fuse_main_real symbolsBernd Schubert-2/+29
Commit 58f85bfa9b7d ("Add in the libfuse version a program...") forgot to add a fuse_main_real function for libfuse compilations that are not symboled. That is now added in compat.c. Signed-off-by: Bernd Schubert <bernd@bsbernd.com>
2025-01-03Fix junk readdirplus results when filesystem not filling stat infoAmir Goldstein-4/+7
Commit dd95d13a ("fix readdirplus when filler is called with zero offset (#896)) broke readdirplus with passthrough example command: passthrough -o auto_cache,modules=subdir,subdir=/src /mnt The /src directory looks like this: ~# ls -l /src total 0 drwx------ 3 root root 60 Jan 2 17:51 testdir And the fuse directory looks like this: ~# ls -l /mnt total 0 d--------- 0 root root 0 Jan 1 1970 testdir Because readdir_fill_from_list() ignores the fact that filesystem did not pass the FUSE_FILL_DIR_PLUS flag with valid stat info. Signed-off-by: Amir Goldstein <amir73il@gmail.com>
2024-12-30Increase .so version to 4Bernd Schubert-1/+1
We have multiple ABI breakages - increase the .so version. Signed-off-by: Bernd Schubert <bernd@bsbernd.com>
2024-12-30Add 64-bit conn::{capable,want}_ext fieldsBernd Schubert-68/+113
The previous fields are left for ABI compatibility, although it is not beautiful to add that complexity when we have to increase the so-version as we had ABI breakage anyway. example/printcap is simplified to use an array, as every line would have needed to be modified anyway. Missing 'FUSE_CAP_PASSTHROUGH' was added. Signed-off-by: Bernd Schubert <bernd@bsbernd.com>
2024-12-30fuse_lowlevel.c: define FUSE_MAXOP as CUSE_INITBernd Schubert-1/+6
We don't want FUSE_MAXOP calculated at compilation time, as the ABI limit is CUSE_INIT - better use that value directly. Signed-off-by: Bernd Schubert <bernd@bsbernd.com>
2024-12-18Rename _int to _internalBernd Schubert-16/+20
_int can be confused with 'integer'
2024-12-18Allow to have page aligned writesBernd Schubert-41/+102
Read/writes IOs should be page aligned as fuse server might need to copy data to another buffer otherwise in order to fulfill network or device storage requirements. Simple reproducer is example/passthrough* and opening a file with O_DIRECT - without this change writing to that file failed with -EINVAL if the underlying file system was using ext4 (for passthrough_hp the 'passthrough' feature has to be disabled). The mis-alignment from fuse kernel is not ideal, but we can handle it by allocation one page more than needed and then using a buffer that is set up to compensate for kernel misalignment. This also only set se->buf_reallocable to true when called by a libfuse internal caller - we do not know what external callers are doing with the buffer - update to commit 0e0f43b79b9b
2024-11-27support FUSE_TMPFILE in the low level APIHorst Birthelmer-0/+19
Note that name hashes and using paths as parameters makes it very hard to support anonymous files in the high level API. Known Issues: - tests have to bail out when O_TMPFILE is not supported. This will always be the case with high level passthrough implementations. - test_create_and_link_tmpfile has to be skipped due to unidentified problems with github runner
2024-11-21Fix alignment of allocation in fuse_reply_createVladimir Serbinenko-1/+2
When allocating as an array of char only alignment of 1 is guaranteed but the structure needs an alignment of 8. Specify alignment explicitly
2024-11-21Reallocate fuse_session buffer transparently for extended max writesJoanne Koong-31/+32
A previous PR supported extended max writes (eg write requests larger than 1 MB) by initializing the fuse session buffer size to use the max_pages_limit set in /proc/sys/fs/fuse. However, this is a huge problem for machines where multiple fuse servers may be running but only one server needs large writes. In this case, a lot of memory will be wasted and will lead to OOM issues. This PR does a reallocation of the session buffer transparently if the server set "se->conn.max_write" to a value larger than 1 MiB. This is only for buffers that are "owned" by libfuse - if the server wishes to provide its own allocated buffer for receiving/processing requests, then it should ensure that buffer is allocated to the proper size from the start. Local testing showed: echo 65535 | sudo tee /proc/sys/fs/fuse/max_pages_limit dd if=/dev/urandom of=hello_file bs=6M count=2 write requests: write request size is 5242880 write request size is 1048576 write request size is 5242880 write request size is 1048576
2024-11-18Use fuse_session_{receive/process}_buf() instead of _int versionJoanne Koong-4/+4
No functional changes.
2024-11-13Add FUSE_CAP_NO_EXPORT and use it in passthrough_hpBernd Schubert-0/+4
This should stop some more xfstest test failures.
2024-11-13Add fuse_set_feature_flag() / fuse_unset_feature_flagBernd Schubert-4/+14
Simplify setting feature flags a bit by adding a helper function. Also move the check for valid flags into a funtion we can re-use in a later patch.
2024-10-14fuse_buf_size fix for SIZE_MAXleipeng-4/+4
2024-10-11Add libfuse util strtol wrapperJoanne Koong-17/+54
Add a wrapper around strtol for more rigorous error checking and convert uses of atoi and strtol to use this instead.
2024-10-11ignore mtab on androidDaniel Rosenberg-1/+1
Updating the mtab on Android fails due to differences in toybox's mount command. Setting IGNORE_MTAB avoids that issue. Signed-off-by: Daniel Rosenberg <drosen@google.com>
2024-09-28fuse_lowlevel FUSE_INIT: Simplify the max_write/bufsize logicBernd Schubert-5/+9
max_write can be limited by se->op.init() and by the buffer size, we use the minimum of these two. Required se->bufsize is then set according to the determined max_write. The current thread will have the old buffer size, though, as it already had to the allocation to handle the FUSE_INIT call (unless splice is used and ths variable and related buffer is not used at all). The given bufsize is just a hint for minimum size, allocation could be actually larger (for example to get huge pages).
2024-09-28fuse_lowlevel FUSE_INIT: group bufsize and max_write adjustmentsBernd Schubert-12/+12
The further these lines are separated from each other the harder it is to read the code. There shouldn't be any code change behavior here.
2024-09-28Change FUSE_MAX_MAX_PAGES to FUSE_DEFAULT_MAX_PAGES_LIMITJoanne Koong-4/+10
A recent upstream patch [1] changed FUSE_MAX_MAX_PAGES to FUSE_DEFAULT_MAX_PAGES_LIMIT. Update libfuse to use FUSE_DEFAULT_MAX_PAGES_LIMIT as well instead of FUSE_MAX_MAX_PAGES. [1] https://lore.kernel.org/linux-fsdevel/20240923171311.1561917-1-joannelkoong@gmail.com/T/#t
2024-09-28Initialize session buffer size to value set by sysctlJoanne Koong-1/+24
Currently in libfuse, the buffer size for a fuse session is capped at 1 MiB on a 4k page system. A recent patch upstream [1] was merged that allows the max number of pages per fuse request to be dynamically configurable through the /proc/sys interface (/proc/sys/fs/fuse/max_pages_limit). This commit adds support for this on the libfuse side to set the fuse session buffer to take into account the max pages limit set in /proc/sys/fs/fuse/max_pages_limit. If this sysctl does not exist (eg older kernels), it will default to old behavior (using FUSE_MAX_MAX_PAGES (256) as the max pages limit). This allows for things like bigger write buffers per request. [1] https://lore.kernel.org/linux-fsdevel/20240923171311.1561917-1-joannelkoong@gmail.com/T/#t
2024-08-02Fix program-path in util/parse-backtrace and dump_stack functionBernd Schubert-3/+0
The option to the path of the binary had been accidentally removed in the scripts that can parse backtraces. The dump_stack() function had left over debug messages.
2024-07-29Pass through nosymfollow mount optionTyler Hall-0/+5
This option is handled in VFS. Added in Linux 5.10 dab741e0e02bd3c4f5e2e97be74b39df2523fc6e Signed-off-by: Tyler Hall <tylerwhall@gmail.com>
2024-07-29Gate #include <execinfo.h> behind #ifdef HAVE_BACKTRACENils-1/+4
execinfo.h is unnecessary if HAVE_BACKTRACE is not defined. This increases portability for systems without execinfo.h
2024-07-17fuse_log: initialize sys_log_level variable to avoid compiler warningJoanne Koong-2/+2
2024-07-14Add syslog and fatal signal handler featureBernd Schubert-31/+182
I see random ENOTCONN failures in xfstest generic/013 and generic/014 in my branch, but earliest on the 2nd run - takes ~12hours to get the issue, but then there are no further information logged. ENOTCONN points to a daemon crash - I need backtraces and a core dump. This adds optional handling of fatal signals to print a core dump and optional syslog logging with these new public functions: fuse_set_fail_signal_handlers() In addition to the existing fuse_set_signal_handlers(). This is not enabled together with fuse_set_signal_handlers(), as it is change in behavior and file systems might already have their own fatal handlers. fuse_log_enable_syslog Print logs to syslog instead of stderr fuse_log_close_syslog Close syslog (for now just does closelog()) Code in fuse_signals.c is also updated, to be an array of signals, and setting signal handlers is now down with a for-loop instead of one hand coded set_one_signal_handler() per signal.
2024-07-03high-level: add fmask and dmask optionsgandalfs_cat-3/+17
dmask: umask applied to directories fmask: umask applied to non-directories to get "typical" permission bits for regular files (0644) and directories (0755), a single umask option is not sufficient (or well, it isn't the way fuse implements it) there is precident for separate umask and dmask options in other filesystems (see for example fat: https://github.com/torvalds/linux/tree/master/fs/fat) this addition should not affect backward-compatibility; the original umask option retains the same meaning, but non-zero fmask or dmask will override it.
2024-06-25Add nullptr check in fuse_session_mountBernd Schubert-0/+10
The pointer did not have any sanity check. Addresses https://github.com/libfuse/libfuse/issues/979
2024-06-13libfuse: null-terminate buffer in fuse_req_getgroups()Miklos Szeredi-0/+1
After reading the file /proc/$PID/task/$PID/status the buffer wasn't terminated with a null character. This could theoretically lead to buffer overrun by the subsequent strstr() call. Since the contents of the proc file are guaranteed to contain the pattern that strstr is looking for, this doesn't happen in normal situations. Add null termination for robustness. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2024-06-11fix useless fuse_init_intr_signal in high-level apiyangyun-10/+9
The code `fuse_init_intr_signal` in `_fuse_new_317` is useless since commit 8ee553dac ("fuse_new(): don't accept options that don't make sense for end-users") has remove the conf.intr option for end-users. The conf.intr is always zero (i.e., disabled) here. Move `fuse_init_intr_signal` after the user-defined `init()` function, so that conf.intr and conf.intr_signal has been configured by the user.
2024-06-04Rename struct fuse_req::ctr to ::ref_cntBernd Schubert-12/+12
ref_cnt should make the intention of this variable more clear.
2024-06-04Make struct fuse_req::ctr a C11 _AtomicBernd Schubert-1/+1
The variable is not modified exclusively with locks since commit cef8c8b24902 ("Add support for no_interrupt") anymore. That commit is safe, but might be error prone to future updates. Changing it to a C11 _Atomic should avoid issues.
2024-06-04Add support for no_interrupt (#956)yangyun50-9/+25
The function fuse_session_process_buf_int() would do much things for FUSE_INTERRUPT requests, even there are no FUSE_INTERRUPT requests: 1. check every non-FUSE_INTERRUPT request and add these requests to the linked list(se->list) under a big lock(se->lock). 2. the function fuse_free_req() frees every request and remove them from the linked list(se->list) under a bing lock(se->lock). These operations are not meaningful when there are no FUSE_INTERRUPT requests, and have a great impact on the performance of fuse filesystem because the big lock for each request. In some cases, FUSE_INTERRUPT requests are infrequent, even none at all. Besides, the user-defined filesystem may do nothing for FUSE_INTERRUPT requests. And the kernel side has the option "no_interrupt" in struct fuse_conn. This kernel option can be enabled by return ENOSYS in libfuse for the reply of FUSE_INTERRUPT request. But I don't find the code to enable the "no_interrupt" kernel option in libfuse. So add the no_interrupt support, and when this operaion is enabled: 1. remove the useless locking operaions and list operations. 2. return ENOSYS for the reply of FUSE_INTERRUPT request to inform the kernel to disable FUSE_INTERRUPT request.
2024-06-01Fix compatibility issue around fuse_custom_io->clone_fd (#953)legezywzh-5/+36
Fixes: 73cd124d0408 ("Add clone_fd to custom IO (#927)") Signed-off-by: Xiaoguang Wang <lege.wang@jaguarmicro.com>