753 Commits

Author SHA1 Message Date
fangzhiyi18 a332960771 add is a symlink
Signed-off-by: fangzhiyi18 <fangzhiyi1@h-partners.com>
2025-11-22 15:06:31 +08:00
fangzhiyi18 bd5ee7c317 升级1.17.3
Signed-off-by: fangzhiyi18 <fangzhiyi1@h-partners.com>
2025-11-08 13:04:30 +08:00
psycho c99f6182b4 libfuse升级
Signed-off-by: psycho <wangmingxuan6@h-partners.com>
2024-01-09 09:19:42 +08:00
a1346054 8166eeffa5 remove executable file mode bit from source files 2021-08-25 14:46:25 +02:00
lixiaokeng 4d2860a9f5 Fix: a potential crash on failure to setlocale
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-06-16 18:25:14 +01:00
Hookey d8f5fe0b31 Remove unused fuse_worker bufsize (#590)
Not used since https://github.com/libfuse/libfuse/commit/561d7054d856eea6c2d634093546d6af773dada9
2021-04-12 11:08:50 +01:00
Jean-Pierre André 3dec359766 Fix returning d_ino and d_type by readdir(3) in non-plus mode
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-03-18 09:52:30 +00:00
Martin Pärtel 884b57886b Fix returning inode numbers from readdir() in offset==0 mode. (#584)
- 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-02-03 09:53:21 +00:00
Laurent Bigonville 1ffa33f76a Fix FTBFS on kfreebsd (#581)
kfreebsd is a FreeBSD kernel and a GNU libc

The only macro defined in that case is __FreeBSD_kernel__

Fix #580
2021-01-17 10:49:07 +00:00
human d77aa6f9e1 fix errno comparison
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-17 11:06:32 +00:00
Zhiqiang Liu 3c5b51c359 buffer.c: correct return value when buf is NULL
In commit b95aba82 ("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: b95aba82 ("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-11 09:32:56 +00:00
Zhiqiang Liu b95aba823b buffer.c: check whether buf is NULL in fuse_bufvec_advance func
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-11-06 19:26:03 +00:00
Rosen Penev 0fda68d9b8 remove fuse_mutex_init
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-29 10:59:23 +00:00
Rosen Penev 51ed467675 remove old uclibc hack
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-10-29 10:59:23 +00:00
Etienne Dublé e0ffce59eb Allow caching symlinks in kernel page cache. (#551)
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-20 19:08:15 +01:00
Tom Callaway 6fc9630acd Implement GCC 10 style symbol versioning (#545) 2020-09-11 10:15:43 +01:00
Nikolaus Rath c3d2df9bdf Suppress some bogus thread sanitizer warnings. 2020-08-28 20:07:11 +01:00
Nikolaus Rath 1965ae9b3e fuse_send_data_iov(): correctly calculate total buffer size.
Fixes: #538.
2020-08-09 12:42:09 +01:00
asafkahlon 968b7fd64f Define fuse_session_loop_mt as a macro on uclibc and MacOS (#532)
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-08-09 12:37:26 +01:00
Jérémie Galarneau 87fbb7c379 Fix: crash on failure to set locale (#529)
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-10 19:59:57 +01:00
winndows 49a2e86fad fuse_lowlevel: Move assert for se before dereferencing it with se->debug (#530)
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-10 19:58:07 +01:00
Albert Chen 28ebae29ba Fixed minor print alignment issue in iconv_help(), replacing tab with space (#519) 2020-07-03 12:39:09 +01:00
winndows 4579bd35fa libfuse: Assign NULL to "old" to avoid free it twice (#522)
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-07-01 06:20:01 +01:00
Fabian Vogt 16abac8b26 Avoid closing se->fd twice in fuse_lowlevel.c (#516)
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-05-15 19:32:10 +01:00
Jean-Yves VET ef6f36c354 Fix issue preventing using splice with reads (#505)
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-03-13 19:02:41 +00:00
Bill Zissimopoulos bb5de1d400 Fixed memory leak in fuse_session_new() 2020-01-02 11:08:03 +00:00
Bill Zissimopoulos 6017634e29 Fixed an issue with the linker version script. (#483)
Fixes #467.
2020-01-02 11:06:18 +00:00
Bill Zissimopoulos f340eb3d5d Make ioctl prototype conditional on FUSE_USE_VERSION. (#482)
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-12-31 09:58:57 +00:00
Dr. David Alan Gilbert ec79e026a6 Kill off some proto_major < 6 checks (#476)
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-29 09:14:28 +00:00
Albert Chen f17110b721 Added support for FUSE_EXPLICIT_INVAL_DATA to enable (#474) 2019-11-27 09:36:30 +00:00
Tomasz Kulasek ce1a921098 fix memleak in cuse_lowlevel_setup (#472)
Local variable args is not freed on cuse_lowlevel_setup success.

Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
2019-11-20 11:43:52 +00:00
Yuri Per 93b44b4db3 Implement lseek operation (#457) 2019-11-03 09:44:31 +00:00
Alan Somers 5bc6153dcc Use the -o intr mount option on FreeBSD (#462)
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-11-03 09:44:12 +00:00
Stefan Hajnoczi 846ec9bdf3 log: move fuse_log() to the public header file
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-10 14:25:15 +01:00
Stefan Hajnoczi 56345a98c5 Introduce callback for logging
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-09-04 15:59:18 +01:00
Stefan Hajnoczi 3bc5778e19 Avoid gcc 9.1 strncpy(3) warnings (#447)
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-29 20:28:29 +01:00
Giuseppe Scrivano 880cc3c46b fuse-lowlevel: set pipe size to max (#438)
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-23 12:52:16 -07:00
scosu 027d0d17c8 fuse_lowlevel: Add max_pages support (#384)
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-13 12:59:10 +01:00
Michael Forney 63c11456d4 Avoid pointer arithmetic with void *
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-06 13:31:41 +01:00
Michael Forney a6024d4bf8 Don't return expression in function returning void
This is a constraint violation in ISO C[0].

[0] http://port70.net/~nsz/c/c11/n1570.html#6.8.6.4p1
2019-06-06 13:31:41 +01:00
Michael Forney a9752e5f74 Don't omit second operand to ? operator
This is a GNU C extension.
2019-06-06 13:31:41 +01:00
Nikolaus Rath 0c59e2b509 Fixed type of ioctl command parameter. 2019-05-05 14:15:13 -04:00
Chad Austin 6439231f9b Add documentation for opting out of opendir and releasedir (#391) 2019-04-16 19:44:59 +01:00
Nikolaus Rath 1552b467fc Add support for in-kernel readdir caching.
Fixes: #394.
2019-04-06 18:34:57 +01:00
Nikolaus Rath 87b907808d Delete FUSE_FSYNC_FDATASYNC
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-04-06 17:56:14 +01:00
Jean-Pierre André a1bff7dbe3 Defined the (*ioctl)() commands as unsigned int (#381)
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-11 17:35:23 +00:00
Alan Somers 1b7d2b8862 Document fuse_fsync_in.fsync_flags and remove magic numbers (#375) 2019-03-08 21:24:50 +00:00
HazelFZ 06a31dece0 Link against libiconv when possible (#372) 2019-03-04 09:43:22 +00:00
Albert Chen 276728f70f fuse_free_buf(): to check flags of each buffer, rather than only 0th
Fixes: #360
2019-02-13 09:42:15 +00:00
Tomohiro Kusumi b197481738 Add support for buildin under DragonFly BSD
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>
2019-01-14 20:28:41 +00:00