summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2021-10-12Introduce API V2 for FUSE_PASSTHROUGH_OPENHEADlineage-18.1Alessio 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-10-12FUSE 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-04-17Enable 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-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-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
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-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
2019-04-06Add support for in-kernel readdir caching.Nikolaus Rath
Fixes: #394.
2019-04-06Delete FUSE_FSYNC_FDATASYNCNikolaus Rath
This constant is not defined in the kernel, so it will be lost when fuse_kernel.h is not synchronized. Instead, the kernel just passes a flag value of "1", so for now we also use a literal in userspace.
2019-03-11Defined the (*ioctl)() commands as unsigned int (#381)Jean-Pierre André
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-08Document fuse_fsync_in.fsync_flags and remove magic numbers (#375)Alan Somers
2019-03-04Link against libiconv when possible (#372)HazelFZ
2019-02-13fuse_free_buf(): to check flags of each buffer, rather than only 0thAlbert Chen
Fixes: #360
2019-01-14Add support for buildin under DragonFly BSDTomohiro Kusumi
70e25ea74e("Fix build on non-Linux") broke build on DragonFly BSD, or likely anything other than FreeBSD and NetBSD that is not Linux. Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
2018-12-22fix memory leak in print_module_help methodalex
2018-11-19examples: add copy_file_range() support to passthrough(_fh)Niels de Vos
The passthrough example filesystem can be used for validating the API and the implementation in the FUSE kernel module.
2018-11-19libfuse: add copy_file_range() supportNiels de Vos
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-11Fix mounting on FreeBSDRoman Bogorodskiy
Currently, mounting on FreeBSD fails like this: mount_fusefs: ZZZZ<snip> on /mountpoint: No such file or directory This happens because right after doing argv[a++] = fdnam it's getting freed before calling execvp(). So move this free() call after execvp(). Also, when asprintf() fails for fdnam, close device fd before calling exit().
2018-11-11Fix build on non-LinuxRoman Bogorodskiy
* Update meson.build to add mount_util.c to libfuse_sources unconditionally, it's non Linux-only * FreeBSD, like NetBSD, doesn't have mntent.h, so don't include that and define IGNORE_MTAB for both * FreeBSD, like NetBSD, has no umount2() sysctl, so similarly define it to unmount()
2018-11-06Revert "Do not include struct fuse_buf in struct fuse_worker"Nikolaus Rath
This reverts commit 161983e2416bc6e26bbbe89664fff62c48c70858, because this causes resource leaks when threads are terminated by pthread_cancel(). Fixes: #313.
2018-10-09Add unprivileged option in `mount.fuse3`Mattias Nissler
The unprivileged option allows to run the FUSE file system process without privileges by dropping capabilities and preventing them from being re-acquired via setuid / fscaps etc. To accomplish this, mount.fuse sets up the `/dev/fuse` file descriptor and mount itself and passes the file descriptor via the `/dev/fd/%u` mountpoint syntax to the FUSE file system.
2018-10-09Allow passing `/dev/fuse` file descriptor from parent processMattias Nissler
This adds support for a mode of operation in which a privileged parent process opens `/dev/fuse` and takes care of mounting. The FUSE file system daemon can then run as an unprivileged child that merely processes requests on the FUSE file descriptor, which get passed using the special `/dev/fd/%u` syntax for the mountpoint parameter. The main benefit is that no privileged operations need to be performed by the FUSE file system daemon itself directly or indirectly, so the FUSE process can run with fully unprivileged and mechanisms like securebits and no_new_privs can be used to prevent subprocesses from re-acquiring privilege via setuid, fscaps, etc. This reduces risk in case the FUSE file system gets exploited by malicious file system data. Below is an example that illustrates this. Note that I'm using shell for presentation purposes, the expectation is that the parent process will implement the equivalent of the `mount -i` and `capsh` commands. ``` \# example/hello can mount successfully with privilege $ sudo sh -c "LD_LIBRARY_PATH=build/lib ./example/hello /mnt/tmp" $ sudo cat /mnt/tmp/hello Hello World! $ sudo umount /mnt/tmp \# example/hello fails to mount without privilege $ sudo capsh --drop=all --secbits=0x2f -- -c 'LD_LIBRARY_PATH=build/lib ./example/hello -f /mnt/tmp' fusermount3: mount failed: Operation not permitted \# Passing FUSE file descriptor via /dev/fd/%u allows example/hello to work without privilege $ sudo sh -c ' exec 17<>/dev/fuse mount -i -o nodev,nosuid,noexec,fd=17,rootmode=40000,user_id=0,group_id=0 -t fuse hello /mnt/tmp capsh --drop=all --secbits=0x2f -- -c "LD_LIBRARY_PATH=build/lib example/hello /dev/fd/17" ' $ sudo cat /mnt/tmp/hello Hello World! $ sudo umount /mnt/tmp ```
2018-09-20Don't enable adaptive readdirplus unless fs has readdir() handler.Nikolaus Rath
2018-09-17Do not include struct fuse_buf in struct fuse_workerNikolaus Rath
This is only used in fuse_do_work(), so we can put it on the stack.
2018-08-29return different non-zero error codes (#290)Oded Arbel
Return different error codes from fuse_main()
2018-08-26Fix memory leak of FUSE modulesRostislav
2018-08-26Fix invalid free of memory pointer in 'struct fuse_buf'Rostislav
2018-08-25Make meson build scripts subprojects friendlyMartin Blanchard
Multiple meson build scripts improvements including: * Bump meson requirement to 0.40.1 (0.40 already required) * Declare a dependency object for main library * Stop using add_global_arguments() * Various minor style fixes
2018-07-25Remove unused member of 'struct fuse_dh'Rostislav Skudnov
2018-07-21Fix readdir() bug when a non-zero offset is specified in filler (#269)Rostislav
The bug occurs when a filesystem client reads a directory until the end, seeks using seekdir() to some valid non-zero position and calls readdir(). A valid 'struct dirent *' is expected, but NULL is returned instead. Pseudocode demonstrating the bug: DIR *dp = opendir("some_dir"); struct dirent *de = readdir(dp); /* Get offset of the second entry */ long offset = telldir(dp); /* Read directory until the end */ while (de) de = readdir(de); seekdir(dp, offset); de = readdir(dp); /* de must contain the second entry, but NULL is returned instead */ The reason of the bug is that when the end of directory is reached, the kernel calls FUSE_READDIR op with an offset at the end of directory, so the filesystem's .readdir callback never calls the filler function, and we end up with dh->filled set to 1. After seekdir(), FUSE_READDIR is called again with a new offset, but this time the filesystem's .readdir callback is never called, and an empty reply is returned. Fix by setting dh->filled to 1 only when zero offsets are given to filler function.
2018-05-18rename: perform user mode dir loop check when not done in kernelBill Zissimooulos
Fix conditionals as per maintainer's request.
2018-05-18rename: perform user mode dir loop check when not done in kernelBill Zissimooulos
Linux performs the dir loop check (rename(a, a/b/c) or rename(a/b/c, a), etc.) in kernel. Unfortunately other systems do not perform this check (e.g. FreeBSD). This results in a deadlock in get_path2, because libfuse did not expect to handle such cases. We add a check_dir_loop function that performs the dir loop check in user mode and enable it on systems that need it.
2018-04-13Drop unneeded void cast for actually used local variableTomohiro Kusumi
`int sig` is acutually used, so `(void) sig;` is unneeded.
2018-02-09Fix uninitialised read in fuse_new_30() (#231) (#234)Ashley Pittman
Ensure that conf is always zero before it's read from to prevent sporadic failure at startup if higher layers were build against version 3.0 Signed-off-by: Ashley Pittman <ashley.m.pittman@intel.com>
2017-11-27Spelling (#223)Josh Soref
Fix spelling errors
2017-11-03Backed out d92bf83Nikolaus Rath
This change is bogus. fuse_module_factory_t is already a pointer type. Additionally, if dlsym returns NULL, then you will be dereferencing it causing a segfault. In my testing, a segfault will happen even if dlsym returns successfully. Thanks to Michael Theall for spotting!
2017-09-27Adding pointer dereferencing after calling dlsym()Sangwoo Moon
dlsym() resolves the location of the loaded symbol, therefore dlsym() returns the type (fuse_module_factory_t *), not (fuse_module_factory_t). Added pinter dereferencing to correctly refer the factory function.
2017-09-25fuse_lib_ioctl(): don't call memcpy with NULL argumentNikolaus Rath
This was detected by using clang's undefined behavior sanitizer, but didn't seem to cause problems in practice.
2017-09-25Link with -lrt to support ancient libcNikolaus Rath
Fixes: #207.
2017-09-19Correctly define fusermount3 path.Nikolaus Rath
2017-09-19Make *_loop_mt() available in version 3.0 againNikolaus Rath
The old versions of these symbols were defined with version tag FUSE_3.0, so this is what we have to use in the .symver directive.
2017-09-19Fix versioned symbols in version scriptNikolaus Rath
According to "How to Write Shared Libraries" by Ulrich Drepper (https://www.akkadia.org/drepper/dsohowto.pdf), the version script should contain the exported name of the versioned symbol once in each tag for which it has been defined by .symver.