355 Commits

Author SHA1 Message Date
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
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
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
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
Tom Callaway 6fc9630acd Implement GCC 10 style symbol versioning (#545) 2020-09-11 10:15:43 +01:00
Yuri Per 93b44b4db3 Implement lseek operation (#457) 2019-11-03 09:44:31 +00: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
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
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
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
alex b8093eb57b fix memory leak in print_module_help method 2018-12-22 12:14:56 +00:00
Niels de Vos fe4f9428fc libfuse: add copy_file_range() support
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-19 12:33:56 +00:00
Rostislav 82ee6d6f77 Fix memory leak of FUSE modules 2018-08-26 09:55:06 +01:00
Rostislav f814b4fa0b Fix invalid free of memory pointer in 'struct fuse_buf' 2018-08-26 09:43:32 +01:00
Rostislav Skudnov af47e3e5e6 Remove unused member of 'struct fuse_dh' 2018-07-25 11:11:49 +01:00
Rostislav 5f125c5e6b Fix readdir() bug when a non-zero offset is specified in filler (#269)
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-07-21 10:57:09 +01:00
Bill Zissimooulos ac06ce29f2 rename: perform user mode dir loop check when not done in kernel
Fix conditionals as per maintainer's request.
2018-05-18 12:52:10 +01:00
Bill Zissimooulos d105fafabb rename: perform user mode dir loop check when not done in kernel
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-05-18 12:52:10 +01:00
Ashley Pittman 03515bbb30 Fix uninitialised read in fuse_new_30() (#231) (#234)
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>
2018-02-09 13:42:12 +00:00
Nikolaus Rath 8ec7fd92eb Backed out d92bf83
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-11-03 10:51:06 +00:00
Sangwoo Moon d92bf83c15 Adding pointer dereferencing after calling dlsym()
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-27 15:01:55 +01:00
Nikolaus Rath 77092d9581 fuse_lib_ioctl(): don't call memcpy with NULL argument
This was detected by using clang's undefined behavior sanitizer, but
didn't seem to cause problems in practice.
2017-09-25 10:34:07 +01:00
Nikolaus Rath 8929982478 Make *_loop_mt() available in version 3.0 again
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-19 20:33:26 +01:00
Nikolaus Rath f24673cc17 Don't use external symbol names in internal files
The fuse_session_loop_mt() and fuse_loop_mt() symbols are only visible
when linking against the shared object. The code in lib/, however, is
compiled *into* the shared object and should thus use the internal
names of these functions.

Surprisingly enough, the code still worked before - but only when link
time optimization was disabled.

Unfortunately, we still can't compile with LTO because it seems that
enabling LTO somehow makes the tagged symbols vanish.

Without lto, we have:

$ nm lib/libfuse3.so | grep fuse_new
0000000000011070 T fuse_new_30
0000000000010a00 t fuse_new_31
0000000000011070 T fuse_new@FUSE_3.0
0000000000010a00 T fuse_new@@FUSE_3.1

and with LTO:

$ nm lib/libfuse3.so | grep fuse_new
0000000000019a70 T fuse_new_30
0000000000019270 t fuse_new_31

See also issue #198.
2017-09-19 16:47:40 +01:00
Joseph Dodge f12d9686d4 Add idle_threads mount option. 2017-08-24 15:17:01 +02:00
Sławek Rudnicki 89f2bae00c Allow inode cache invalidation in high-level API
We re-introduce the functionality of invalidating the caches for an
inode specified by path by adding a new routine
fuse_invalidate_path. This is useful for network-based file systems
which use the high-level API, enabling them to notify the kernel about
external changes.

This is a revival of Miklos Szeredi's original code for the
fuse_invalidate routine.
2017-08-24 14:20:37 +02:00
Nikolaus Rath 19eaea2e77 Allow building without iconv.
cfg.has('HAVE_ICONV') was always true.
2017-08-22 12:10:50 +02:00
userwithuid 811c808b1d directly call fuse_new_31() instead of fuse_new() internally
this fixes building with lto, which failed since commit 503e32d01e
2017-08-14 20:02:28 +02:00
Nikolaus Rath c869f31322 fuse_lib_init(): don't set FUSE_CAP_EXPORT_SUPPORT unconditionally
FreeBSD kernel does not support this.
2017-08-11 20:14:55 +02:00
Nikolaus Rath 100944bd72 Only declare fuse_new_30() when FUSE_USE_VERSION == 30
This function shouldn't be called when using a newer fuse
version, so we should not define it in that case.
2017-07-13 13:27:43 +02:00
Nikolaus Rath 5a5edc3353 fuse_new_30(): call fuse_new_31(), not fuse_new()
I believe this function call is resolved by the compiler, not
the linker, so this seems safer.

Thanks to Chris Clayton for spotting this.
2017-07-13 13:22:12 +02:00
Nikolaus Rath 503e32d01e Fixup symbol versioning for GCC 4.x
GCC 4.8 doesn't like to rename fuse_new_30 to fuse_new, if we
also define an implementation for fuse_new.
2017-07-08 13:11:47 +02:00
Nikolaus Rath e870a0427a Added public fuse_lib_help(), bumped minor version 2017-07-08 12:48:08 +02:00
Angelo G. Del Regno b2aaaaf40c Fix comparison of integers of different signs
Some variables of different size and sign were getting compared
without any safe casting.
The build system also throws warnings at this and, being this
library used for filesystems, it's really important to ensure
stability.
2017-06-05 11:25:14 -04:00
Tej Chajed bf76304abd Set default options before parsing 2017-04-14 13:29:18 -07:00
amosonn e572050d3f Optimize fuse_fs_read. (#145)
Redundant copy when only op.read is available removed.
2017-03-03 12:44:59 -08:00
Nikolaus Rath ae49d8860d Added debug logging to chmod 2016-10-24 21:20:09 -07:00
Nikolaus Rath f84f2db692 Fix segfault in debug logging code
fi may be NULL, so we need to protect against this.
2016-10-24 21:09:00 -07:00
Nikolaus Rath 1d9f26f373 Turn fuse_operations.nopath_flag into fuse_config.nullpath_ok
Modifying struct fuse_config in the init() handler is the canonical way
to adjust file-system implementation specific settings. There is no need
to have flags in struct fuse_operations.
2016-10-20 15:45:32 -07:00
Nikolaus Rath 8ee553dac0 fuse_new(): don't accept options that don't make sense for end-users
Several options (use_ino, etc) depend on the file system
implementation. Allowing them to be set from the command line makes no
sense.
2016-10-20 15:32:20 -07:00
Nikolaus Rath 6c66dac9f2 Pass struct fuse_config to high-level init() handler. 2016-10-20 14:05:15 -07:00
Nikolaus Rath b16650830d Make --help output more suitable for end-user
We now only list options that are potentially useful for an
end-user (and unlikely to accidentally break a file system). The full
list of FUSE options has been moved to the documentation of the
fuse_new() and fuse_session_new() functions.
2016-10-15 19:46:57 -07:00
Nikolaus Rath b46250c40e Removed -o nopath - it never did anything
We are overriding this setting with the flag in struct fuse_operations:

$ example/hello -f -d  ~/tmp/mnt
FUSE library version: 3.0.0pre0
nopath: 0
unique: 1, opcode: INIT (26), nodeid: 0, insize: 56, pid: 0
INIT: 7.25
flags=0x0007fffb
max_readahead=0x00020000
   INIT: 7.23
   flags=0x00006031
   max_readahead=0x00020000
   max_write=0x00020000
   max_background=0
   congestion_threshold=0
   time_gran=0
   unique: 1, success, outsize: 80

$ example/hello -f -d  ~/tmp/mnt -o nopath
FUSE library version: 3.0.0pre0
nopath: 0
unique: 1, opcode: INIT (26), nodeid: 0, insize: 56, pid: 0
INIT: 7.25
flags=0x0007fffb
max_readahead=0x00020000
   INIT: 7.23
   flags=0x00006031
   max_readahead=0x00020000
   max_write=0x00020000
   max_background=0
   congestion_threshold=0
   time_gran=0
   unique: 1, success, outsize: 80
2016-10-15 19:09:45 -07:00
Nikolaus Rath 73b6ff4b75 Pass fuse_file_info to getattr, chown, chmod, truncate, utimens handlers
This obsoletes the ftruncate & fgetattr handlers.

Fixes #58.
2016-10-15 18:46:27 -07:00
Nikolaus Rath d49f2e77b4 Unify handling of fuse_conn_info options
Instead of using command line options to modify struct fuse_conn_info
before and after calling the init() handler, we now give the file system
explicit control over this.
2016-10-15 16:49:23 -07:00