aboutsummaryrefslogtreecommitdiffstats
path: root/include/fuse_lowlevel.h
AgeCommit message (Collapse)AuthorLines
2025-04-28Add fuse_req_is_uring() to check if a req comes through io-uringBernd Schubert-0/+5
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-03-19Fix a comment typo "passed to the filesystem.n"Bernd Schubert-1/+1
Closes: https://github.com/libfuse/libfuse/issues/1168 Signed-off-by: Bernd Schubert <bernd@bsbernd.com>
2025-02-18Avoid nested function declarations in helper functionsBernd Schubert-6/+6
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-17Add comment for fuse_passthrough_open()Maksim Harbachou-0/+2
See https://github.com/libfuse/libfuse/issues/1125 Signed-off-by: Maksim Harbachou <maksim.harbachou@resilio.com>
2025-02-09Rename to fuse_session_new_versionedBernd Schubert-18/+7
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-01-13Update doxygen/comments for fuse_reply_open/fuse_reply_createBernd Schubert-2/+4
Comments for fuse_reply_open and fuse_reply_create and with that doxygen had not been updated for parallel_direct_writes and others. Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-01-06Avoid global declarion of internal functions that are new in 3.17Bernd Schubert-19/+7
_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>
2024-11-27support FUSE_TMPFILE in the low level APIHorst Birthelmer-0/+23
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-09-12getattr: Make use of FUSE_GETATTR_FH in lowlevel examplesBernd Schubert-1/+1
High level examples were already using it, but not lowlevel. Also update the documentation.
2024-07-03Annotate ABI sensitivness for some data structuresBernd Schubert-2/+5
These are not all ABI sensitive data structures yet. Also some space vs tab indentation issues are corrected.
2024-06-01Fix compatibility issue around fuse_custom_io->clone_fd (#953)legezywzh-2/+22
Fixes: 73cd124d0408 ("Add clone_fd to custom IO (#927)") Signed-off-by: Xiaoguang Wang <lege.wang@jaguarmicro.com>
2024-05-13Enable passthrough mode for read/write operations (#919)Amir Goldstein-0/+13
Add support for filesystem passthrough read/write of files. When the FUSE_PASSTHROUGH capability is enabled, the FUSE server may decide, while handling the "open" or "create" requests, if the given file can be accessed by that process in "passthrough" mode, meaning that all the further read and write operations would be forwarded by the kernel directly to the backing file rather than to the FUSE server. All requests other than read or write are still handled by the server. This allows for an improved performance on reads and writes, especially in the case of reads at random offsets, for which no (readahead) caching mechanism would help, reducing the performance gap between FUSE and native filesystem access. Extend also the passthrough_hp example with the new passthrough feature. This example opens a kernel backing file per FUSE inode on the first FUSE file open of that inode and closes the backing file on the release of the last FUSE file on that inode. All opens of the same inode passthrough to the same backing file. A combination of fi->direct_io and fi->passthrough is allowed. It means that read/write operations go directly to the server, but mmap is done on the backing file. This allows to open some fds of the inode in passthrough mode and some fd of the same inode in direct_io/passthrough_mmap mode. Signed-off-by: Alessio Balsini <balsini@android.com> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
2024-05-13Add in the libfuse version a program was compiled with (#942)Bernd Schubert-4/+46
The API stays the same, the libfuse version comes from inlined functions, which are defined fuse_lowlevel.h and fuse.h. As these inlined functions are defined in the header files they get added into the application, similar as if these were preprocessor macros. Macro vs inlined function is then just a style issue - I personally prefer the latter. fuse_session_new() -> static inlinei, in the application _fuse_session_new -> inside of libfuse fuse_new() -> static inline, in the application _fuse_new() -> inside of libfuse Note: Entirely untested is the fuse 30 api - we need a test for it. And we do not have any ABI tests at all. Signed-off-by: Bernd Schubert <bernd.schubert@fastmail.fm>
2024-05-10Handle NO_OPEN/NO_OPENDIR support automatically (#949)Josef Bacik-0/+14
If the file system doesn't provide a ->open or an ->opendir, and the kernel supports FUSE_CAP_NO_OPEN_SUPPORT or FUSE_CAP_NO_OPENDIR_SUPPORT, allow the implementation to set FUSE_CAP_NO_OPEN*_SUPPORT on conn->want in order to automatically get this behavior. Expand the documentation to be more explicit about the behavior of libfuse in the different cases WRT this capability. Signed-off-by: Josef Bacik <josef@toxicpanda.com>
2024-04-18Add clone_fd to custom IO (#927)legezywzh-0/+1
Define a new clone_fd() helper for fuse_custom_io, users can implement their own clone fd logic. Signed-off-by: Xiaoguang Wang <lege.wang@jaguarmicro.com>
2023-11-19Clarify fuse_lowlevel poll() docstring (#862)George Hilliard-7/+10
The original docstring was confusing; it was not clear that the ph must be retained indefinitely, nor was it clear that the client *also* needs to reply to the poll call immediately. Clarify this by explaining that it is only necessary to retain a single handle, that the client must retain ph, and that it must immediately call reply.
2023-06-30Make expire only function fail if no kernel support (#789)HereThereBeDragons-14/+14
2023-06-29Clarify behavior of fuse_session_exit().Nikolaus Rath-3/+6
2023-05-12Do not pass unsupported mount options to the kernel.Nikolaus Rath-0/+6
The filesystem daemon is responsible for implementing eg. st_atime updates, so passing options like relatime to the kernel results in them being silently ignored. Instead, such options need to be interpreted (and filtered out) by the filesystem daemon.
2023-03-29Fix typos and configure spellcheck for PRsYaroslav Halchenko-2/+2
2023-02-09fuse_lowlevel.h: add more setattr flagsXiubo Li-0/+8
Such as for the xfstest-dev's generic/684 test case it will clear suid and sgid if the fallocate request is commited by an unprivileged user. The kernel fuse passed the ATTR_KILL_SUID/ATTR_KILL_SGID flags to userspace but it will be dropped. Signed-off-by: Xiubo Li <xiubli@redhat.com>
2023-02-09Split config.h into private and public configBernd Schubert-2/+2
This addresses https://github.com/libfuse/libfuse/issues/729 commit db35a37def14b72181f3630efeea0e0433103c41 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-01-15use off_t over __off64_tpsykose-4/+4
when -D_FILE_OFFSET_BITS=64 is defined, the off_t type is 64 bits wide already. the fuse_common.h header already checks for this, and errors when it is not, so be consistent with all the other uses of off_t. some libcs like musl do not have a 32-bit off_t type, and don't define __off64_t.
2023-01-10Support application-defined I/O functions for FUSE fdTofik Sonono-0/+41
The io for FUSE requests and responses can now be further customized by allowing to write custom functions for reading/writing the responses. This includes overriding the splice io. The reason for this addition is that having a custom file descriptor is not sufficient to allow custom io. Different types of file descriptor require different mechanisms of io interaction. For example, some file descriptor communication has boundaries (SOCK_DGRAM, EOF, etc...), while other types of fd:s might be unbounded (SOCK_STREAMS, ...). For unbounded communication, you have to read the header of the FUSE request first, and then read the remaining packet data. Furthermore, the one read call does not necessarily return all the data expected, requiring further calls in a loop.
2023-01-06adding comments and capability discovery, enum for flags moved to top of fileHereThereBeDragons-4/+36
2023-01-06Initial patch provided by Miklos Szeredi <mszeredi@redhat.com>HereThereBeDragons-0/+8
2023-01-04convert __APPLE__ and __ULIBC__ to HAVE_LIBC_VERSIONED_SYMBOLSBernd Schubert-2/+2
In fact only gnu-libc fully supports symbol versioning, so it is better to have a generic macro for it. This also allows to manually disable symbol version and allows to run tests with that configuration on gnu-libc. That testing will still not catch compat issues, but least ensures the code can compile. Testing for __APPLE__ and __ULIBC__ is now done by meson. More of such checks can be added by people using other libcs.
2023-01-02Revert "libfuse custom communication interface"Nikolaus Rath-19/+0
This reverts commit 777663953382925c7403f0560c28ec9bbd14d7be.
2022-11-15libfuse custom communication interfacey-0/+19
libfuse can now be used without having a mount interface.
2022-09-04fuse-loop/fuse_do_work: Avoid lots of thread creations/destructionsBernd Schubert-1/+22
On benchmarking metadata operations with a single threaded bonnie++ and "max_idle_threads" limited to 1, 'top' was showing suspicious 160% cpu usage. Profiling the system with flame graphs showed that an astonishing amount of CPU time was spent in thread creation and destruction. After verifying the code it turned out that fuse_do_work() was creating a new thread every time all existing idle threads were already busy. And then just a few lines later after processing the current request it noticed that it had created too many threads and destructed the current thread. I.e. there was a thread creation/destruction ping-pong. Code is changed to only create new threads if the max number of threads is not reached. Furthermore, thread destruction is disabled, as creation/destruction is expensive in general. With this change cpu usage of passthrough_hp went from ~160% to ~80% (with different values of max_idle_threads). And bonnie values got approximately faster by 90%. This is a with single threaded bonnie++ bonnie++ -x 4 -q -s0 -d <path> -n 30:1:1:10 -r 0 Without this patch, using the default max_idle_threads=10 and just a single bonnie++ the thread creation/destruction code path is not triggered. Just one libfuse and one application thread is just a corner case - the requirement for the issue was just n-application-threads >= max_idle_threads. Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2022-09-04API update for fuse_loop_config additionsBernd Schubert-19/+22
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>
2021-05-19Define FUSE_USE_VERSION in Doxygen. (#608)Junichi Uekawa-5/+5
We currently do not pass anything in PREDEFINED and that means FUSE_USE_VERSION is undefined. Add that definition so that Doxygen built-in C pre-processor can use FUSE_USE_VERSION value to find the correct comment to parse.
2021-05-07Fix doxygen warnings. (#600)Junichi Uekawa-5/+5
Some parameters were undocumented, and @file does not mean to expand current file name.
2021-04-23Add missing exceptions to fuse_reply_err() documentation. (#597)Manuel Jacob-1/+1
Co-authored-by: Manuel Jacob <test>
2021-03-30Fix typo in fuse_lowlevel.h (#593)Tobias Nießen-1/+1
2021-01-10Fix typo (#578)Feverfew-1/+1
2020-08-09Define fuse_session_loop_mt as a macro on uclibc and MacOS (#532)asafkahlon-0/+5
On uclibc and MacOS we don't use versioned symbols. Hence, there's no definition for fuse_session_loop_mt on those cases and the linker won't be able to resolve calls to fuse_session_loop_mt() Signed-off-by: Asaf Kahlon <asafka7@gmail.com>
2019-12-31Make ioctl prototype conditional on FUSE_USE_VERSION. (#482)Bill Zissimopoulos-1/+7
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-11-03Implement lseek operation (#457)Yuri Per-0/+33
2019-05-24Remove incorrect comment about fuse_entry_param.generation (#420)Alan Somers-3/+0
A comment said that fuse_entry_param.generation must be non-zero. However, I can't find anything in the kernel that requires that, and real-world file systems don't seem to follow that advice, either.
2019-04-16Add documentation for opting out of opendir and releasedir (#391)Chad Austin-0/+7
2019-03-11Defined the (*ioctl)() commands as unsigned int (#381)Jean-Pierre André-2/+5
Instead of the Posix ioctl(2) command, Linux uses its own variant of ioctl() in which the commands are requested as "unsigned long" and truncated to 32 bits by the fuse kernel module. Transmitting the commands to user space file systems as "unsigned int" is a workaround for processing ioctl() commands which do not fit into a signed int.
2019-03-10Improve documentation for the flush method (#378)Alan Somers-2/+6
Fixes: #373
2019-03-09Improve readdir() and file handle documentationChad Austin-11/+22
Fixes: #333
2019-01-21Clarify documentation of fuse_lowlevel_inval_inodeNikolaus Rath-8/+8
Fixes: #341.
2018-11-19libfuse: add copy_file_range() supportNiels de Vos-0/+36
Add support for the relatively new copy_file_range() syscall. Backend filesystems can now implement an efficient way of cloning/duplicating data ranges within files. See 'man 2 copy_file_range' for more details.
2018-11-06Document when `fuse_lowlevel_notify_*` functions may block.Nikolaus Rath-0/+13
2018-09-20Clarify what qualifies as a "related operation" for notify_inval_entry.Nikolaus Rath-6/+13
2018-07-04Document that access() is also called on chdir().Nikolaus Rath-3/+3
Source: Miklos Szeredi on fuse-devel, Wednesday, 4 July 2018 15:29.
2017-11-27Spelling (#223)Josh Soref-2/+2
Fix spelling errors