aboutsummaryrefslogtreecommitdiffstats
path: root/example
AgeCommit message (Collapse)AuthorLines
2023-04-01Fix compiler warning in hello_ll.c (#760)Nikolaus Rath-2/+4
2023-04-01Add unit tests for setxattr() et alNikolaus Rath-5/+54
Hopefully, this will catch issues as in commit 024eccbf3
2023-03-29Fix typos and configure spellcheck for PRsYaroslav Halchenko-2/+2
2023-01-28Install a the configure_file (config.h) and use in headersBernd Schubert-19/+1
This addresses: https://github.com/libfuse/libfuse/issues/724 HAVE_LIBC_VERSIONED_SYMBOLS configures the library if to use versioned symbols and is set at meson configuration time. External filesystems (the main target, actually) include fuse headers and the preprocessor then acts on HAVE_LIBC_VERSIONED_SYMBOLS. Problem was now that 'config.h' was not distributed with libfuse and so HAVE_LIBC_VERSIONED_SYMBOLS was never defined with external tools and the preprocessor did the wrong decision. This commit also increases the the minimal meson version, as this depends on meson feature only available in 0.50 <quote 'meson' > WARNING: Project specifies a minimum meson_ version '>= 0.42' but uses features which were added in newer versions: * 0.50.0: {'install arg in configure_file'} </quote> Additionally the config file has been renamed to "fuse_config.h" to avoid clashes - 'config.h' is not very specific.
2023-01-15use off_t over __off64_tpsykose-2/+2
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-13passthrough_hp: Avoid a bit code dup in readdirBernd Schubert-14/+9
Just a slight code simplification.
2023-01-13passthrough_hp: Add options for clone_fd, max_threads, daemonizeBernd Schubert-2/+29
This is useful for benchmarking. Note: This changes behavior - passthrough_hp runs in background by default now.
2023-01-10Support application-defined I/O functions for FUSE fdTofik Sonono-3/+361
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-06Test for fuse_lowlevel_notify_expire_entry.HereThereBeDragons-5/+18
This test is too simple to check for all functionalities of notify_expire as it always successfully passes when libfuse supports the function (even if kernel does not support it - it just takes it as notify_inval)
2023-01-06adding comments and capability discovery, enum for flags moved to top of fileHereThereBeDragons-0/+2
2022-09-04fuse-loop/fuse_do_work: Avoid lots of thread creations/destructionsBernd Schubert-5/+9
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-04-08Passthrough_ll should display cmd line optionsDharmendra singh-0/+18
Make passthrough_ll to display all its cmdline options instead of keeping them hidden. (I am not sure if these are intentionally kept hidden)
2022-03-31passthrough_hp: Disable splice with the --nosplice optionBernd Schubert-7/+13
passthrough_hp was not updated when splice got enabled by default in libfuse3. I.e. the --nosplice option and condition on it was a noop.
2022-03-31passthrough_hp: Fix inode ref in sfs_unlinkBernd Schubert-0/+26
sfs_unlink may call do_lookup(), which increases the inode ref count, but since that function does not return attributes that lookup ref count won't get automatically decreased.
2022-03-14Merge branch 'master' into fopen_noflushNikolaus Rath-2/+0
2022-02-11Removed duplicates code. (#642)David Galeano-2/+0
The cap for FUSE_CAP_WRITEBACK_CACHE was printed twice.
2022-01-03Add support for FOPEN_NOFLUSH flagAmir Goldstein-0/+1
Allow requesting from kernel to avoid flush on close at file open time. If kernel does not support FOPEN_NOFLUSH flag, the request will be ignored. For passthrough_hp example, request to avoid flush on close when writeback cache is disabled and file is opened O_RDONLY. Signed-off-by: Amir Goldstein <amir73il@gmail.com>
2021-06-14passthrough_hp: excercise reusing inode numbersAmir Goldstein-7/+50
Before last unlink() release the reference on inode.fd to allow reuse of underlying fs inode number, mark the server inode "deleted" and bump it's generation counter. When same inode number is found on lookup(), the server inode object will be reused as well. Skip this when inode has an open file and when writeback cache is enabled. This will be used to verify inode reuse bug fix in the kernel. Signed-off-by: Amir Goldstein <amir73il@gmail.com>
2021-06-09Cuse example: Fix memory leak (#607)Christian Menges-5/+11
* cuse example: fix memory leak * Travis CI: re-enable leak checking
2021-05-09Fix memory leaks in examples (#604)Christian Menges-1/+17
2021-05-09Bump cxxopts from 2.2.0 to 2.2.1 (#602)Christian Menges-41/+78
2021-05-07Fix doxygen warnings. (#600)Junichi Uekawa-3/+3
Some parameters were undocumented, and @file does not mean to expand current file name.
2021-03-18Fix returning d_ino and d_type by readdir(3) in non-plus modeJean-Pierre André-2/+16
When not using the readdir_plus mode, the d_type was not returned, and the use_ino flag was not used for returning d_ino. This patch fixes the returned values for d_ino and d_type by readdir(3) The test for the returned value of d_ino has been adjusted to also take the d_type into consideration and to check the returned values in both basic readdir and readdir_plus modes. This is done by executing the passthrough test twice. Co-authored-by: Jean-Pierre André <jpandre@users.sourceforge.net>
2021-02-03Fix returning inode numbers from readdir() in offset==0 mode. (#584)Martin Pärtel-1/+1
- Test added for all passthrough examples. - passthrough.c uses offset==0 mode. The others don't. - passthrough.c changed to set FUSE_FILL_DIR_PLUS to make the test pass. - This fixes #583.
2021-01-01Fix FUSE_COPY_FILE_RANGE in the passthrough example (#575)Alan Somers-2/+4
Only close the file descriptors if they were just opened. Otherwise, the second FUSE_COPY_FILE_RANGE operation on any given file will fail with EBADF.
2020-11-24examples/cuse_client: add include file to eliminate compiler warning (#568)Rethan-0/+2
Compiler warning about close(fd), add include file to fix. Signed-off-by: haoyixing <haoyixing@kuaishou.com> Co-authored-by: haoyixing <haoyixing@kuaishou.com>
2020-11-06example/cuse_client.c: fix fd leakage problemZhiqiang Liu-4/+10
In cuse_client.c, fd should be closed before return. Otherwise, it will cause fd leakage problem. Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com> Signed-off-by: Haotian Li <lihaotian9@huawei.com>
2020-11-06ioctl_client.c: fix potential fd leakage problemZhiqiang Liu-3/+8
In ioctl_client.c, fd is not closed before return, thus it will cause fd leakage problem. Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com> Signed-off-by: Haotian Li <lihaotian9@huawei.com>
2020-09-20Allow caching symlinks in kernel page cache. (#551)Etienne Dublé-0/+2
This commit defines a new capability called `FUSE_CAP_CACHE_SYMLINKS`. It is off by default but you can now enable it by setting this flag in in the `want` field of the `fuse_conn_info` structure. When enabled, the kernel will save symlinks in its page cache, by making use of the feature introduced in kernel 4.20: https://github.com/torvalds/linux/commit/5571f1e65486be025f73fa6aa30fb03725d362a2
2020-09-09Updated example code to work with new API (#547)AKowshik-18/+42
2020-08-09Fixed typo in command to compile program (#536)AKowshik-1/+1
2020-05-14passthrough_ll: remove symlink fallbacks (#514)Miklos Szeredi-139/+14
* passthrough_ll/hp: remove symlink fallbacks Path lookup in the kernel has special rules for looking up magic symlinks under /proc. If a filesystem operation is instructed to follow symlinks (e.g. via AT_SYMLINK_FOLLOW or lack of AT_SYMLINK_NOFOLLOW), and the final component is such a proc symlink, then the target of the magic symlink is used for the operation, even if the target itself is a symlink. I.e. path lookup is always terminated after following a final magic symlink. I was erronously assuming that in the above case the target symlink would also be followed, and so workarounds were added for a couple of operations to handle the symlink case. Since the symlink can be handled simply by following the proc symlink, these workardouds are not needed. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com> Co-authored-by: Miklos Szeredi <mszeredi@redhat.com>
2020-04-20Do not require C++ compiler for buildingFabrice Fontaine-1/+1
Fixes: - http://autobuild.buildroot.org/results/a6e64213f2910b2b81e79cb1e96e558413d7f70a Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2020-03-13State GPL version in comment (#485)Dr. David Alan Gilbert-19/+19
IN a bunch of comments we say 'under the terms of the GNU GPL', make it clear this is GPLv2 (as LICENSE says). Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
2020-02-24passthrough_ll: Remove unneeded variable assignment (#501)philmd-2/+0
Fix warning reported by Clang static code analyzer: example/passthrough_ll.c:390:5: warning: Value stored to 'saverr' is never read saverr = ENOMEM; ^ ~~~~~~ Fixes: 4a92a82f2e2 Reported-by: Clang Static Analyzer Reviewed-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
2020-02-04Include limits.h because of PATH_MAX usage. (#498)maxice8-0/+1
Fixes build with musl libc on Alpine Linux.
2020-01-30examples: mark ops variables constant (#496)zsugabubus-13/+13
2020-01-24passthrough_ll: Use cache_readdir for directory open (#492)Misono Tomohiro-1/+1
Upstreamed from: https://www.redhat.com/archives/virtio-fs/2020-January/msg00106.html Since keep_cache(FOPEN_KEEP_CACHE) has no effect for directory as described in fuse_common.h, use cache_readdir(FOPEN_CACHE_DIR) for diretory open when cache=always mode. Signed-off-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
2020-01-06passthrough_ll: pass correct errno to fuse_reply_err()Dr. David Alan Gilbert-1/+1
fuse_reply_err() expects the error code, not its negative. Upstreamed from https://www.redhat.com/archives/virtio-fs/2020-January/msg00000.html. Original commit message: lo_copy_file_range() passes -errno to fuse_reply_err() and then fuse_reply_err() changes it to errno again, so that subsequent fuse_send_reply_iov_nofree() catches the wrong errno.(i.e. reports "fuse: bad error value: ..."). Make fuse_send_reply_iov_nofree() accept the correct -errno by passing errno directly in lo_copy_file_range(). Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com> Reviewed-by: Eryu Guan <eguan@linux.alibaba.com> Co-authored-by: Xiao Yang <ice_yangxiao@163.com>
2019-12-31Make ioctl prototype conditional on FUSE_USE_VERSION. (#482)Bill Zissimopoulos-1/+1
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-27Added support for FUSE_EXPLICIT_INVAL_DATA to enable (#474)Albert Chen-0/+2
2019-11-03Implement lseek operation (#457)Yuri Per-0/+50
2019-11-03passthrough_ll: drop lo_dirp->fd field (#464)Stefan Hajnoczi-7/+9
fdopendir(3) takes ownership of the file descriptor. The presence of the lo_dirp->fd field could lead to someone incorrectly adding a close(d->fd) cleanup call in the future. Do not store the file descriptor in struct lo_dirp since it is unused. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
2019-09-10passthrough_ll: use fuse_log() instead of err()/errx()Stefan Hajnoczi-8/+17
Send everything through fuse_log() instead of writing directly to stderr. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2019-09-10passthrough_ll: use fuse_log()Stefan Hajnoczi-16/+16
Make use of fuse_log() instead of printing directly to stderr. This demonstrates unified logging and also caught the fact that I forgot to add fuse_log APIs to lib/fuse_versionscript. So it's basically a test case :). Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2019-09-09passthrough_ll: fix fallocate variant ifdefs (#449)Dr. David Alan Gilbert-2/+2
If fallocate isn't available we incorrectly check for the value of HAVE_POSIX_FALLOCATE rather than it being defined. We also fail to initialise 'err' in the case where neither are defined. Fixes: 5fc562c90d7925963467 ("Add fallocate and use it instead of ...") Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
2019-05-15passthrough: fix unix-domain sockets on FreeBSD (#413)Alan Somers-19/+87
FreeBSD doesn't allow creating sockets using mknod(2). Instead, one has to use socket(2) and bind(2). Add appropriate logic to the examples and add a test case.
2019-05-12Fix includes of non-system headers.Nikolaus Rath-2/+2
Fixes: #415.
2019-05-09Added new example filesystemNikolaus Rath-0/+3363
passthrough_hp puts emphasis and performance and correctness, rather than simplicity.
2019-05-05Fixed permissions.Nikolaus Rath-0/+0