aboutsummaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2022-01-24Merge tag 'fuse-3.10.5' into HEADandroid-t-preview-2android-t-preview-1android-t-beta-3android-s-v2-beta-3android-s-qpr3-beta-1android-t-preview-1android-s-v2-beta-3android-s-qpr3-beta-1Alessio Balsini
Tagged release. Test: MediaProviderTests Bug: 216129364 Signed-off-by: Alessio Balsini <balsini@google.com> Change-Id: I1fcb0684f88e6160943f0d0d3ab797be13695e61
2021-11-16Support fuse-bpfAlessio Balsini
Add struct fuse_args Introduce bpf_arg in fuse_reply_entry Currently, the opcode filters are zeroed to preserve the libfuse compatibility. Bug: 202785178 Test: Along with other changes, file /sys/fs/bpf/prog_fuse_media_fuse_media appears. Signed-off-by: Alessio Balsini <balsini@google.com> Signed-off-by: Paul Lawrence <paullawrence@google.com> Change-Id: I38cd80d702813f4e2b45d69af2ca451fca0984c6
2021-08-25remove executable file mode bit from source filesa1346054
2021-06-16Fix: a potential crash on failure to setlocalelixiaokeng
setlocale() can fail, returning NULL, which will lead to a crash in iconv_new(). Fix it like in iconv_help(). Signed-off-by: Lixiaokeng <lixiaokeng@huawei.com>
2021-05-13Introduce API V2 for FUSE_PASSTHROUGH_OPENAlessio Balsini
From the feedback received on LKML, it would be better to have multiple ioctls, than a single ioctl the behavior of which depends on the data that is passed (e.g., with an enum). Introduce the new FUSE_PASSTHROUGH_OPEN ioctl which only gets the fd of the lower file system. Bug: 175195837 Test: CtsScopedStorageDeviceOnlyTest with android-mainline kernel \ implementing the new FUSE_PASSTHROUGH_OPEN ioctl Signed-off-by: Alessio Balsini <balsini@google.com> Change-Id: Iecb677722ca9630ce89b8a8fb5f486216ecd89cc
2021-04-12Remove unused fuse_worker bufsize (#590)Hookey
Not used since https://github.com/libfuse/libfuse/commit/561d7054d856eea6c2d634093546d6af773dada9
2021-03-18Fix returning d_ino and d_type by readdir(3) in non-plus modeJean-Pierre André
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
- 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-29FUSE passthrough: handle unstable kernel interfaceAlessio Balsini
The interface for FUSE passthrough is still under discussion upstream, thus this change fixes the issue of being able to support multiple interfaces for passthrough, depending on what the kernel provides. This implementation tries to explore the different FUSE passthrough interface implementation and updates an index to the one that has been found working. Bug: 167695973 Test: Manual read/write of passthrough files with extra printks Signed-off-by: Alessio Balsini <balsini@google.com> Change-Id: I74e0e6c0691b37160a00af77fb18eda5342630f5
2021-01-17Fix FTBFS on kfreebsd (#581)Laurent Bigonville
kfreebsd is a FreeBSD kernel and a GNU libc The only macro defined in that case is __FreeBSD_kernel__ Fix #580
2020-11-17fix errno comparisonhuman
this affected `-o remember` in single-thread mode, it could prematurely exit if a signal was received # start an example filesystem from example/ ./passthrough -f -s -o remember=5 ./mnt # make the poll() call return with EINTR pkill -PIPE passthrough
2020-11-12Enable passthrough mode for read/write operationsAlessio Balsini
Add support for filesystem passthrough read/write of files. When the FUSE_PASSTHROUGH capability is enabled, the FUSE daemon may decide while handling the "open" or "create" operation, 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 lower filesystem rather than to the FUSE daemon. All requests that aren't read or write are still handled by the userspace code. 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. Bug: 168023149 Test: atest ScopedStorageTest Signed-off-by: Alessio Balsini <balsini@android.com> Change-Id: I38aff0cf7198b7cd92eccc97547d47f4e1132b00
2020-11-11buffer.c: correct return value when buf is NULLZhiqiang Liu
In commit d614415a ("buffer.c: check whether buf is NULL in fuse_bufvec_advance func"), if fuse_bufvec_current func returns NULL, it returns 1 directly. Actually, we should return 0 when buf is NULL. Fixes: d614415a ("buffer.c: check whether buf is NULL in fuse_bufvec_advance func") Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com> Signed-off-by: Haotian Li <lihaotian9@huawei.com>
2020-11-06buffer.c: check whether buf is NULL in fuse_bufvec_advance funcZhiqiang Liu
In fuse_bufvec_advance func, calling fuse_bufvec_current func may return NULL, so we should check whether buf is NULL before using it. Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com> Signed-off-by: Haotian Liu <lihaotian9@huawei.com>
2020-10-29remove fuse_mutex_initRosen Penev
This seems to have been added before 2006 to fix a uclibc bug. It doesn't seem to be the case anymore so just get rid of it. Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-10-29remove old uclibc hackRosen Penev
This actually prevents sshfs linking to it as fuse_new becomes unavailable. According to the git history, this seems to predate 2006. Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-09-20Allow caching symlinks in kernel page cache. (#551)Etienne Dublé
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-11Implement GCC 10 style symbol versioning (#545)Tom Callaway
2020-08-28Suppress some bogus thread sanitizer warnings.Nikolaus Rath
2020-08-09fuse_send_data_iov(): correctly calculate total buffer size.Nikolaus Rath
Fixes: #538.
2020-08-09Define fuse_session_loop_mt as a macro on uclibc and MacOS (#532)asafkahlon
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>
2020-07-10Fix: crash on failure to set locale (#529)Jérémie Galarneau
setlocale() can fail, returning NULL, if the user has an invalid (or missing) locale set in the LANG environment variable. In my case, this happens when using VS Code's integrated terminal to launch a fuse-based filesystem. A bug (fix upcoming) results in VS Code setting an invalid locale. iconv_help() currently passes the return value of setlocale(...) directly to strdup() without checking if it is NULL, resulting in a crash. To reproduce, simply set LANG="something_invalid" and call fuse_lib_help(). Stack trace when the process receives `SIGSEGV`: (gdb) bt #0 0x00007fabd0fcc4b5 in __strlen_avx2 () from /usr/lib/libc.so.6 #1 0x00007fabd0ef9233 in strdup () from /usr/lib/libc.so.6 #2 0x00007fabd13b8128 in iconv_help () at ../lib/modules/iconv.c:641 #3 0x00007fabd13b81a8 in iconv_opt_proc (data=0x55580a6ee850, arg=0x55580a6edfb0 "-h", key=0, outargs=0x7ffeeb1a8ec8) at ../lib/modules/iconv.c:658 #4 0x00007fabd13af7d5 in call_proc (ctx=0x7ffeeb1a8ea0, arg=0x55580a6edfb0 "-h", key=0, iso=0) at ../lib/fuse_opt.c:161 #5 0x00007fabd13afaf1 in process_opt (ctx=0x7ffeeb1a8ea0, opt=0x7fabd13c3d40 <iconv_opts>, sep=0, arg=0x55580a6edfb0 "-h", iso=0) at ../lib/fuse_opt.c:233 #6 0x00007fabd13afd5a in process_gopt (ctx=0x7ffeeb1a8ea0, arg=0x55580a6edfb0 "-h", iso=0) at ../lib/fuse_opt.c:285 #7 0x00007fabd13b0117 in process_one (ctx=0x7ffeeb1a8ea0, arg=0x55580a6edfb0 "-h") at ../lib/fuse_opt.c:368 #8 0x00007fabd13b0190 in opt_parse (ctx=0x7ffeeb1a8ea0) at ../lib/fuse_opt.c:379 #9 0x00007fabd13b03d3 in fuse_opt_parse (args=0x7ffeeb1a8f70, data=0x55580a6ee850, opts=0x7fabd13c3d40 <iconv_opts>, proc=0x7fabd13b8186 <iconv_opt_proc>) at ../lib/fuse_opt.c:414 #10 0x00007fabd13b8226 in iconv_new (args=0x7ffeeb1a8f70, next=0x0) at ../lib/modules/iconv.c:680 #11 0x00007fabd13a5627 in print_module_help (name=0x7fabd13b9e1c "iconv", fac=0x7fabd13d48e0 <fuse_module_iconv_factory>) at ../lib/fuse.c:4692 #12 0x00007fabd13a56aa in fuse_lib_help (args=0x7ffeeb1a9238) at ../lib/fuse.c:4721 iconv_help() is modified to print an error when setlocale() fails. It then carries on printing the iconv module's help. Reading setlocale(3), it seems that the strdup() of the result was not necessary. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@gmail.com>
2020-07-10fuse_lowlevel: Move assert for se before dereferencing it with se->debug (#530)winndows
Move assert for se before dereferencing it with se->debug. Signed-off-by: Liao Pingfang <liao.pingfang@zte.com.cn> Co-authored-by: Liao Pingfang <liao.pingfang@zte.com.cn>
2020-07-03Fixed minor print alignment issue in iconv_help(), replacing tab with space ↵Albert Chen
(#519)
2020-07-01libfuse: Assign NULL to "old" to avoid free it twice (#522)winndows
Assign NULL to "old" at the first free(), to avoid the possible 2nd free() for it. Signed-off-by: Liao Pingfang <liao.pingfang@zte.com.cn> Co-authored-by: Liao Pingfang <liao.pingfang@zte.com.cn>
2020-05-15Avoid closing se->fd twice in fuse_lowlevel.c (#516)Fabian Vogt
If fuse_session_unmount is called before fuse_session_destroy, both would try to close(se->fd). Avoid that by resetting it in fuse_session_unmount.
2020-03-25Fix FUSE_CANONICAL_PATH responseZim
The bluecross kernel introduced a change, 4fb542f2aa1414cea5686efcf72a411b7213c375 that breaks responses to canonical paths. The patch above tried to guarantee that the canonical path returned from the FUSE daemon is null terminated. It does this by replacing the last character in the path returned from the FUSE daemon with '\0'. Since the size of the response returned from the FUSE daemon is gotten from strlen which doesn't take into account the null terminating character. This means that the kernel fix above will break the file path returned from userspace. Effectively replacing /storage/emulated/0 with /storage/emulated/. It is unclear how this breaks inotify on the root path but not inotify on Download/ for instance since that too is replaced by /storage/emulated/Downloa. One thing I've noticed is that in the case of Download, being replaced with Downloa, there is an error generated, since Downloa doesn't exist, but in the case of /storage/emulated/0, there is no error since /storage/emulated/ exists. In any case, this cl returns a buffer size including the '\0' to the kernel and seems right given that the actual size of the buffer returned to the kernel is now correct. Test: Manual tests with inotify and Documents UI detecting changes on /sdcard on both taimen and crosshatch Bug: 152035889 Change-Id: Ia4b9adec09dd501ec0c5327b9ea9577412cea6a2
2020-03-13Fix issue preventing using splice with reads (#505)Jean-Yves VET
Context: SPLICE_WRITE is not used with regular buffers (i.e. when they are not file-descriptor backed buffers). There is a bug which assumes file descriptors are used. If the amount of data associated with those FD is lower than twice the page size, SPLICE_WRITE is not utilized. With regular buffers the aggregated size was always 0. Because vmsplice (splice user pages to/from a pipe) is called before splice in fuse_lowlevel.c, regular buffers would also work with splice. This patch prevents to fallback to non-splice enabled copies when itheir is no FD involved.
2020-01-10Support FUSE_CANONICAL_PATH in libfuseZim
FUSE_CANONICAL_PATH opcode, (2016) was added in some Android kernels to support inotify. Add canonical path handlers in libfuse and create a patch file to easily apply this patch on top of updates. Test: inotify - /sdcard on Taimen Test: atest FileObserver Bug: 147482155 Change-Id: I97a2c4247aa3e4a70af697569b56662a0755f72b
2020-01-02Fixed memory leak in fuse_session_new()Bill Zissimopoulos
2020-01-02Fixed an issue with the linker version script. (#483)Bill Zissimopoulos
Fixes #467.
2019-12-31Make ioctl prototype conditional on FUSE_USE_VERSION. (#482)Bill Zissimopoulos
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-29Kill off some proto_major < 6 checks (#476)Dr. David Alan Gilbert
fuse_init already refuses to start if we're on major < 7 , so we can kill off checks for old major versions. Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
2019-11-27Added support for FUSE_EXPLICIT_INVAL_DATA to enable (#474)Albert Chen
2019-11-20fix memleak in cuse_lowlevel_setup (#472)Tomasz Kulasek
Local variable args is not freed on cuse_lowlevel_setup success. Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
2019-11-09Update to libfuse 3.8.0Zim
The latest release allows a custom logger Bug: 135341433 Test: adb shell ls /sdcard with persist.sys.fuse Change-Id: Iaa8a2bb7b6da3f364fba41b443527a998a26549f
2019-11-03Implement lseek operation (#457)Yuri Per
2019-11-03Use the -o intr mount option on FreeBSD (#462)Alan Somers
FUSE file systems normally indicate their interruptibility by returning ENOSYS to the first FUSE_INTERRUPT operation. But that causes two problems for file systems that aren't interruptible: 1) A process may block on a signal, even if another thread could've handled the signal. The kernel must know whether the FUSE thread is interruptible before deciding which thread should receive a signal. 2) The protocol allows a FUSE daemon to simply ignore FUSE_INTERRUPT operations. From the kernel's point of view, that is indistinguishable from a FUSE_INTERRUPT operation arriving after the original operation had already completed. Thus, the kernel can't interpret an ignored FUSE_INTERRUPT as an indication that the daemon is non-interruptible. With the -o nointr mount option, no FUSE_INTERRUPT operations will ever be sent. Most FUSE file systems should require no modifications to take advantage of this mount option.
2019-09-10log: move fuse_log() to the public header fileStefan Hajnoczi
Applications may wish to call fuse_log() for unified logging. This way they don't need to define their own wrappers to invoke the log message handler function installed by fuse_set_log_func(). Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2019-09-04Introduce callback for loggingStefan Hajnoczi
Introduce an API for custom log handler functions. This allows libfuse applications to send messages to syslog(3) or other logging systems. See include/fuse_log.h for details. Convert libfuse from fprintf(stderr, ...) to log_fuse(level, ...). Most messages are error messages with FUSE_LOG_ERR log level. There are also some debug messages which now use the FUSE_LOG_DEBUG log level. Note that lib/mount_util.c is used by both libfuse and fusermount3. Since fusermount3 does not link against libfuse, we cannot call fuse_log() from lib/mount_util.c. This file will continue to use fprintf(stderr, ...) until someone figures out how to split it up. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2019-08-29Avoid gcc 9.1 strncpy(3) warnings (#447)Stefan Hajnoczi
Recent GCC releases have warnings related to common strncpy(3) bugs. These warnings can be avoided by explicitly NUL-terminating the buffer or using memcpy(3) when the intention is to copy just the characters without the NUL terminator. This commit fixes the following warnings: [1/27] Compiling C object 'test/9f86d08@@test_syscalls@exe/test_syscalls.c.o'. In function ‘test_socket’, inlined from ‘main’ at ../test/test_syscalls.c:1899:9: ../test/test_syscalls.c:1760:2: warning: ‘strncpy’ output may be truncated copying 108 bytes from a string of length 1023 [-Wstringop-truncation] 1760 | strncpy(su.sun_path, testsock, sizeof(su.sun_path)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [2/27] Compiling C object 'lib/76b5a35@@fuse3@sha/fuse.c.o'. ../lib/fuse.c: In function ‘add_name’: ../lib/fuse.c:968:2: warning: ‘strncpy’ output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation] 968 | strncpy(s, name, len); | ^~~~~~~~~~~~~~~~~~~~~ ../lib/fuse.c:944:15: note: length computed here 944 | size_t len = strlen(name); | ^~~~~~~~~~~~ [3/27] Compiling C object 'lib/76b5a35@@fuse3@sha/fuse_lowlevel.c.o'. ../lib/fuse_lowlevel.c: In function ‘fuse_add_direntry’: ../lib/fuse_lowlevel.c:288:2: warning: ‘strncpy’ output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation] 288 | strncpy(dirent->name, name, namelen); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../lib/fuse_lowlevel.c:276:12: note: length computed here 276 | namelen = strlen(name); | ^~~~~~~~~~~~ ../lib/fuse_lowlevel.c: In function ‘fuse_add_direntry_plus’: ../lib/fuse_lowlevel.c:381:2: warning: ‘strncpy’ output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation] 381 | strncpy(dirent->name, name, namelen); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../lib/fuse_lowlevel.c:366:12: note: length computed here 366 | namelen = strlen(name); | ^~~~~~~~~~~~ Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2019-08-02Merge remote-tracking branch 'origin/upstream-master' am: 9b55afda07 am: ↵Paul Lawrence
ae757e65a9 am: 7eff99c4b7 am: 26f560b643 am: 3d406b8575 Change-Id: I49119cf3733b0495ced4b8bdb5148a8f3c61e0dd
2019-07-23fuse-lowlevel: set pipe size to max (#438)Giuseppe Scrivano
on failure to set the pipe size, set it to the maximum allowed by the kernel. If the first request required more than the maximum allowed, the can_grow flag would be reset thus preventing any further resize. Grow the pipe to the maximum allowed to increase the likelihood of using splice for successive requests instead of falling back to read/write. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-07-23Remove GPL filesPaul Lawrence
Make compile on Android
2019-06-13fuse_lowlevel: Add max_pages support (#384)scosu
Starting with kernel version 4.20 fuse supports a new property 'max_pages' which is the maximum number of pages that can be used per request. This can be set via an argument during initialization. This new property allows writes to be larger than 128k. This patch sets the property if the matching capability is set (FUSE_MAX_PAGES). It will also set max_write to 1MiB. Filesystems have the possibility to decrease this size by setting max_write to a smaller size. The max_pages and bufsize fields are adjusted accordingly. Cc: Constantine Shulyupin <const@MakeLinux.com> Signed-off-by: Markus Pargmann <scosu@quobyte.com>
2019-06-06Avoid pointer arithmetic with `void *`Michael Forney
The pointer operand to the binary `+` operator must be to a complete object type. Since we are working with byte sizes, use `char *` instead.
2019-06-06Don't return expression in function returning voidMichael Forney
This is a constraint violation in ISO C[0]. [0] http://port70.net/~nsz/c/c11/n1570.html#6.8.6.4p1
2019-06-06Don't omit second operand to `?` operatorMichael Forney
This is a GNU C extension.
2019-05-05Fixed type of ioctl command parameter.Nikolaus Rath
2019-04-16Add documentation for opting out of opendir and releasedir (#391)Chad Austin