aboutsummaryrefslogtreecommitdiffstats
path: root/lib
AgeCommit message (Collapse)AuthorLines
2021-06-16Fix: a potential crash on failure to setlocalelixiaokeng-4/+2
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-04-12Remove unused fuse_worker bufsize (#590)Hookey-1/+0
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é-0/+5
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-17Fix FTBFS on kfreebsd (#581)Laurent Bigonville-1/+1
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-1/+1
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-11buffer.c: correct return value when buf is NULLZhiqiang Liu-1/+1
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-0/+3
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-20/+6
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-2/+1
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é-0/+4
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-8/+12
2020-08-28Suppress some bogus thread sanitizer warnings.Nikolaus Rath-1/+9
2020-08-09fuse_send_data_iov(): correctly calculate total buffer size.Nikolaus Rath-1/+1
Fixes: #538.
2020-08-09Define fuse_session_loop_mt as a macro on uclibc and MacOS (#532)asafkahlon-0/+1
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-4/+9
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-2/+1
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-1/+1
(#519)
2020-07-01libfuse: Assign NULL to "old" to avoid free it twice (#522)winndows-0/+1
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-0/+1
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-13Fix issue preventing using splice with reads (#505)Jean-Yves VET-8/+6
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-02Fixed memory leak in fuse_session_new()Bill Zissimopoulos-1/+2
2020-01-02Fixed an issue with the linker version script. (#483)Bill Zissimopoulos-1/+1
Fixes #467.
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-29Kill off some proto_major < 6 checks (#476)Dr. David Alan Gilbert-5/+5
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-0/+4
2019-11-20fix memleak in cuse_lowlevel_setup (#472)Tomasz Kulasek-0/+1
Local variable args is not freed on cuse_lowlevel_setup success. Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
2019-11-03Implement lseek operation (#457)Yuri Per-0/+98
2019-11-03Use the -o intr mount option on FreeBSD (#462)Alan Somers-0/+3
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-3/+6
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-174/+220
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-3/+3
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-07-23fuse-lowlevel: set pipe size to max (#438)Giuseppe Scrivano-0/+35
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-06-13fuse_lowlevel: Add max_pages support (#384)scosu-9/+27
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-8/+8
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-1/+1
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-1/+1
This is a GNU C extension.
2019-05-05Fixed type of ioctl command parameter.Nikolaus Rath-3/+3
2019-04-16Add documentation for opting out of opendir and releasedir (#391)Chad Austin-0/+2
2019-04-06Add support for in-kernel readdir caching.Nikolaus Rath-0/+2
Fixes: #394.
2019-04-06Delete FUSE_FSYNC_FDATASYNCNikolaus Rath-2/+2
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é-6/+7
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-6/+8
2019-03-04Link against libiconv when possible (#372)HazelFZ-1/+5
2019-02-13fuse_free_buf(): to check flags of each buffer, rather than only 0thAlbert Chen-1/+1
Fixes: #360
2019-01-14Add support for buildin under DragonFly BSDTomohiro Kusumi-3/+3
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-0/+1
2018-11-19examples: add copy_file_range() support to passthrough(_fh)Niels de Vos-1/+1
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-0/+91
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-4/+2
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().