aboutsummaryrefslogtreecommitdiffstats
path: root/example
AgeCommit message (Collapse)AuthorLines
2025-07-16Add statx supportJoanne Koong-0/+70
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-07-15Switch to c++20Bernd Schubert-1/+1
This only effects example/{passthrough_hp.cc,memfs_ll.cc} and is mainly to avoid these warnings ../example/memfs_ll.cc:1100:1: warning: missing field 'statx' initializer [-Wmissing-designated-field-initializers] Signed-off-by: Bernd Schubert <bernd@bsbernd.com>
2025-07-13example/passthrough: support fspacectl()CismonX-0/+13
FreeBSD 14 introduced a new system call, fspacectl(). Currently, it supports one operation mode, SPACECTL_DEALLOC, which is functionally equivalent to Linux fallocate() with FALLOC_FL_KEEP_SIZE|FALLOC_FL_PUNCH_HOLE flags. fspacectl() calls with SPACECTL_DEALLOC is supported on FUSE filesystems via FUSE_FALLOCATE with the aforementioned flags. Signed-off-by: CismonX <admin@cismon.net>
2025-07-13example/passthrough: tidy up passthrough_helpers.hCismonX-5/+17
Add header guards, include system headers as needed, and declare helper functions as inline. This ensures that the helper header could be properly included. Signed-off-by: CismonX <admin@cismon.net>
2025-07-13example/passthrough: refactor fallocateCismonX-39/+27
Move fallocate implementation to passthrough_helpers.h, so that it could be reused by multiple passthrough examples. Signed-off-by: CismonX <admin@cismon.net>
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-27passthrough_hp: Fix unused function warningGleb Popov-1/+1
Signed-off-by: Gleb Popov <6yearold@gmail.com>
2025-06-27memfs_ll: Fix unused variable warningGleb Popov-0/+2
Signed-off-by: Gleb Popov <6yearold@gmail.com>
2025-06-25meson: Enable building C++ examples on FreeBSDGleb Popov-1/+1
Signed-off-by: Gleb Popov <6yearold@gmail.com>
2025-06-25passthrough_hp: Fix compilation on systems without O_TMPFILE supportGleb Popov-1/+4
Signed-off-by: Gleb Popov <6yearold@gmail.com>
2025-06-25passthrough_hp: Abstract out the fd -> path transitionGleb Popov-12/+31
Signed-off-by: Gleb Popov <6yearold@gmail.com>
2025-06-25memfs_ll: Fix compiling on non-Linux OSesGleb Popov-0/+2
Signed-off-by: Gleb Popov <6yearold@gmail.com>
2025-06-25examples: Guard inclusions of Linux headers with appropriate ifdefsGleb Popov-1/+5
Signed-off-by: Gleb Popov <6yearold@gmail.com>
2025-06-18example/ioctl_client: Delete the redundant commentizxl007-2/+0
Signed-off-by: izxl007 <zeng.zheng@zte.com.cn>
2025-06-18tests: example: add new test for increment epochLuis Henriques-10/+37
This patch modifies the notify_inval_entry.c example so that it includes an extra option to use fuse_lowlevel_notify_increment_epoch(). The test test_notify_inval_entry() was also modified to test this extra option. Signed-off-by: Luis Henriques <luis@igalia.com>
2025-06-17example/passthrough_hp: Show fuse lowlevel help optionsBernd Schubert-0/+2
Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-06-17Reformat passthrough_hp with clang-formatBernd Schubert-1260/+1300
Not ideal for git history, but the different formatting within the project is really disturbing. Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-06-05Update how to use the io_uring and io_uring_q_depth mount optionsizxl007-21/+2
This patch updates how to use the io_uring and io_uring_q_depth mount options. There are two reasons for this: 1. It is recommended for end-users to use a format like “-o io_uring" (with a space) in README.fuse-io-uring. This is because, in the passthrough_hp example, cxxopts does not support the "-oio_uring" format (without a space), and using it would result in a syntax error. 2. Remove redundant "--uring" and "--uring-q-depth=" from passthrough_hp example. Signed-off-by: izxl007 <zeng.zheng@zte.com.cn>
2025-04-28passthrough_hp: Add io-uring optionsBernd Schubert-4/+25
Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-04-23example: fix memfs_rename deadlock errorswj-4/+5
Signed-off-by: swj <1186093704@qq.com>
2025-04-16conn: prevent duplicate flag conversion in high-level interfaceBernd Schubert-2/+2
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-07fuse_lowlevel: Set bufsize if HAVE_SPLICE is not define and avoid raceBernd Schubert-0/+3
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-02example: add usdt.btJoanne Koong-0/+19
Add example bpftrace file for monitoring tracepoints. Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
2025-03-27example: Add a compilation instruction in README.compileizxl007-0/+4
When building FUSE3 with Meson on CentOS 8, the fuse3.pc file gets installed in /usr/local/lib64/pkgconfig. Since pkg-config doesn't search this path by default, GCC compilation fails due to missing FUSE3 flags. This patch adds an instruction for setting PKG_CONFIG_PATH variable in README.compile to fix GCC compilation issues. Signed-off-by: izxl007 <zeng.zheng@zte.com.cn>
2025-03-26example/hello_ll.c: Improve the compilation commentsizxl007-0/+4
When building and installing FUSE3 using Meson on CentOS8, the fuse3.pc file is installed in the /usr/local/lib64/pkgconfig directory. However, pkg-config does not search for fuse3.pc in this directory, leading to GCC compilation failures. This patch improves the compilation comments, helping users successfully execute the GCC command. Signed-off-by: izxl007 <zeng.zheng@zte.com.cn>
2025-03-24fuse: Fix want flag conversionBernd Schubert-0/+9
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-02-17example/hello_ll_uds: Switch to %zu and avoid 32bit build warningBernd Schubert-2/+2
Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-02-17Fix build of example/memfs_ll.cc on 32 bit architecturesLaszlo Boszormenyi (GCS)-2/+2
The code uses std::min() which expects its arguments to be size_t. Two times it uses an offset declared as off_t. While both size_t and off_t are 32-bit integers, the latter is signed. On 64 bit architectures the conversation of off_t -> size_t performed automatically. On 32 bit architectures it needs a type cast. Signed-off-by: Laszlo Boszormenyi (GCS) <gcs@debian.org>
2025-02-12passthrough_hp: enable splice move by defaultJoanne Koong-3/+5
This commit enables splice moves by default, unless the caller opts into nosplice. Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
2025-02-10Build fixes for -OgBernd Schubert-1/+1
Cleaning... 18 files. [35/69] Compiling C object example/passthrough_ll.p/passthrough_ll.c.o ../example/passthrough_ll.c: In function ‘lo_opendir’: ../example/passthrough_ll.c:666:20: warning: ‘fd’ may be used uninitialized [-Wmaybe-uninitialized] 666 | if (fd != -1) | ^ ../example/passthrough_ll.c:637:13: note: ‘fd’ was declared here 637 | int fd; | ^~ [38/69] Compiling C object test/test_syscalls.p/test_syscalls.c.o ../test/test_syscalls.c: In function ‘test_seekdir’: ../test/test_syscalls.c:804:16: warning: ‘de’ may be used uninitialized [-Wmaybe-uninitialized] 804 | while (de) | ^~ ../test/test_syscalls.c:776:24: note: ‘de’ was declared here 776 | struct dirent *de; | ^~ These are actually valid. Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2025-01-03example/passthrough: Enable testing of readdirplus without fill offsetsAmir Goldstein-6/+13
passthrough example supports the --plus command line argument to reply to readdirplus with fill_dir_plus and unspecified (0) fill offsets. As explained in this comment: https://github.com/libfuse/libfuse/pull/896#issuecomment-1978917041 passthrough example needs a few more changes to be able to test commit dd95d13a ("fix readdirplus when filler is called with zero offset (#896)) With the changes in this commit, readdirplus without fill offsets can be tested to verify the readdirplus fix above with command line: passthrough --plus -o auto_cache,modules=subdir,subdir=/src /mnt Signed-off-by: Amir Goldstein <amir73il@gmail.com>
2025-01-03Fix build of memfs_ll without manual meson reconfigureAmir Goldstein-0/+1
After pulling latest code, memfs_ll build would fail because it builds with C++11. Changing the default of cpp_std in meson.build is not enough to fix this problem even if user runs 'meson setup --reconfigure'. I had to run 'meson setup -Dcpp_std= --reconfigure' to fix the build as mentioned in this meson issue: https://github.com/mesonbuild/meson/issues/8062#issuecomment-1568249672 Signed-off-by: Amir Goldstein <amir73il@gmail.com>
2025-01-01passthrough_ll: set correct keep_cache flag in opendir (#1083)Amir Goldstein-1/+3
In cache=always mode, set keep_cache flag in opendir(), same as done in open() and same as passthrough_hp does in opendir(). In the default cache=auto mode, use readdir cache, but do not set keep_cache, same as regular files use page cache for an open file, but do not keep_cache for a new open. Note that passthrough_hp by default behaves the same as passthrough_ll cache=always mode and supports the cache=never mode with --nocache, but it does not support the equivalent of cache=auto mode. Signed-off-by: Amir Goldstein <amir73il@gmail.com>
2024-12-30Add 64-bit conn::{capable,want}_ext fieldsBernd Schubert-69/+66
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-13examples: Add memfs_ll.ccBernd Schubert-0/+1159
This is an initial implementation and quickly hacked together within a few hours - issues expected. This also increase to C++17 as memfs_ll makes use of more recent features. Background to create this was actually to be able to test large file names (3 * 1024B), which couldn't be achieved with passthrough file system as non of the underlying file systems seems to support that. Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2024-11-27support FUSE_TMPFILE in the low level APIHorst Birthelmer-19/+168
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-13Add FUSE_CAP_NO_EXPORT and use it in passthrough_hpBernd Schubert-1/+13
This should stop some more xfstest test failures.
2024-11-13Add fuse_set_feature_flag() / fuse_unset_feature_flagBernd Schubert-16/+9
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-09-19passthrough_hp: Use fuse_loop_cfg_set_max_threads()Bernd Schubert-1/+1
fuse_loop_cfg_set_idle_threads() was by accident and setting it might cause a performance issue.
2024-09-13example/passthrough_hp: Set keep_cache and noflush in sfs_createBernd Schubert-2/+3
These flags should be also set for O_CREAT
2024-09-13example/passthrough_hp: No auto FOPEN_DIRECT_IO in passthrough modeBernd Schubert-22/+27
sfs_open and sfs_create set fi->direct_io (FOPEN_DIRECT_IO) when O_DIRECT is given, in order to benefit from a shared inode lock in kernel, i.e. to get parallel DIO writes. However, kernel side disabled passthrough when FOPEN_DIRECT_IO is set. Reads/writes had been totally failing in this case for O_DIRECT as sfs_write_buf() and sfs_read() have a sanity check. That sanity check could be modified, but for performance passthrough is better than parallel DIO, hence, we only want automatic FOPEN_DIRECT_IO for O_DIRECT when passthrough is not enabled. Fixes: https://github.com/libfuse/libfuse/issues/1027 This also fixes automatically switching to FOPEN_DIRECT_IO for O_DIRECT in sfs_create().
2024-09-12getattr: Make use of FUSE_GETATTR_FH in lowlevel examplesBernd Schubert-6/+7
High level examples were already using it, but not lowlevel. Also update the documentation.
2024-08-26remove unused headers in example/poll_clientyangyun-1/+0
fuse_config.h is used in libfuse internally. This may confuse developers that fuse_config.h is used in the examples.
2024-08-19Fix FUSE_USE_VERSION in example/notify_store_retrieve.cyangyun-1/+1
This is an addition to commit e75d2c54a347. This example sets FUSE_USE_VERSION = 34 but uses fuse_loop_cfg_* APIs, which is not allowed since these APIs are not introduced in version 34.
2024-08-01example/passthrough_hp: Remove unused includesBernd Schubert-4/+0
Fix some clang-tidy warnings. Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2024-08-01Fix FUSE_USE_VERSION in example/Bernd Schubert-3/+3
This is an addition to commit a8f1ae35af66, which introduced the 312 API, but didn't set the right API version in all examples. Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2024-07-30example/passthrough_hp: Fix . and .. readdir lookup countBernd Schubert-5/+7
Commit 170edc6a8ef0 added dot and dotdot (. and ..) to readdir results, but introduced an issue when max number of entries was reached - lookup count must not be decreased without doing the lookup. With ext4 as underlying file system readir seems to return . and .. at random offsets and randomly failed xfstests for me. This also fixes indentation, as passthrough_hp.cc does not follow the linux indentation style (if we decide to fix this, it needs to be done for the entire file). Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2024-07-14Add syslog and fatal signal handler featureBernd Schubert-1/+10
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-08passthrough_hp: include . and .. in readdirJoanne Koong-5/+10
generic/401 fails currently because it checks that "." and ".." are listed as directory entries. Include "." and ".." as listed directory entries in passthrough_hp's readdir implementation. Signed-off by: Joanne Koong <joannelkoong@gmail.com>
2024-07-08example/notify_inval_entry.c: improve comment readabilitydesertwitch-2/+2
Follow the same format as other arguments passed to example commands.