struct fuse_loop_config was passed as a plain struct, without any
version identifer. This had two implications
1) Any addition of new parameters required a FUSE_SYMVER for
fuse_session_loop_mt() and fuse_loop_mt() as otherwise a read
beyond end-of previous struct size might have happened.
2) Filesystems also might have been recompiled and the developer
might not have noticed the struct extensions and unexpected for
the developer (or people recomliling the code) uninitialized
parameters would have been passed.
Code is updated to have struct fuse_loop_config as an opaque/private
data type for file systems that want version 312
(FUSE_MAKE_VERSION(3, 12)). The deprecated fuse_loop_config_v1
is visible, but should not be used outside of internal
conversion functions
File systems that want version >= 32 < 312 get the previous
struct (through ifdefs) and the #define of fuse_loop_mt
and fuse_session_loop_mt ensures that these recompiled file
systems call into the previous API, which then converts
the struct. This is similar to existing compiled applications
when just libfuse updated, but binaries it is solved with
the FUSE_SYMVER ABI compact declarations.
Signed-off-by: Bernd Schubert <bschubert@ddn.com>
meson was complaining:
Build targets in project: 27
NOTICE: Future-deprecated features used:
* 0.56.0: {'Dependency.get_pkgconfig_variable'}
So change to .get_variable(pkgconfig : 'type' and also increase
the meson minimal version to be able to handle it.
Co-authored-by: Bernd Schubert <bschubert@ddn.com>
meson configure -D buildtype=debugoptimized
meson configure -D b_sanitize=address,undefined
Results in '-fsanitize=address,undefined ... -O2 -g' that made
compilation to give errors with recent gcc versions.
bernd@t1700bs build-ubuntu>ninja -v
[1/2] ccache gcc -Itest/test_syscalls.p -Itest -I../test -Iinclude -I../include -Ilib -I../lib -I. -I.. -fdiagnostics-color=always -fsanitize=address,undefined -fno-omit-frame-pointer -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -O2 -g -D_REENTRANT -DHAVE_CONFIG_H -Wno-sign-compare -Wstrict-prototypes -Wmissing-declarations -Wwrite-strings -fno-strict-aliasing -Wno-unused-result -DHAVE_SYMVER_ATTRIBUTE -MD -MQ test/test_syscalls.p/test_syscalls.c.o -MF test/test_syscalls.p/test_syscalls.c.o.d -o test/test_syscalls.p/test_syscalls.c.o -c ../test/test_syscalls.c
FAILED: test/test_syscalls.p/test_syscalls.c.o
ccache gcc -Itest/test_syscalls.p -Itest -I../test -Iinclude -I../include -Ilib -I../lib -I. -I.. -fdiagnostics-color=always -fsanitize=address,undefined -fno-omit-frame-pointer -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -O2 -g -D_REENTRANT -DHAVE_CONFIG_H -Wno-sign-compare -Wstrict-prototypes -Wmissing-declarations -Wwrite-strings -fno-strict-aliasing -Wno-unused-result -DHAVE_SYMVER_ATTRIBUTE -MD -MQ test/test_syscalls.p/test_syscalls.c.o -MF test/test_syscalls.p/test_syscalls.c.o.d -o test/test_syscalls.p/test_syscalls.c.o -c ../test/test_syscalls.c
In file included from /usr/include/string.h:519,
from ../test/test_syscalls.c:7:
In function ‘strncpy’,
inlined from ‘test_socket’ at ../test/test_syscalls.c:1885:2,
inlined from ‘main’ at ../test/test_syscalls.c:2030:9:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:95:10: error: ‘__builtin_strncpy’ output may be truncated copying 107 bytes from a string of length 1023 [-Werror=stringop-truncation]
95 | return __builtin___strncpy_chk (__dest, __src, __len,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
96 | __glibc_objsize (__dest));
| ~~~~~~~~~~~~~~~~~~~~~~~~~
I disagree a bit on the gcc sanity here, as the code was behaving
correctly and even already checked the string length. But sice
the string length is already verified, that length can be used
for the final strncpy.
In fuse kernel, 'commit 53db28933e95 ("fuse: extend init flags")'
made the changes to handle flags going beyond 32 bits but i think
changes were not done in libfuse to handle the same.
This patch prepares the ground in libfuse for incoming FUSE kernel
patches (Atomic open + lookup) where flags went beyond 32 bits.
It makes struct same as in fuse kernel resulting in name change of
few fields.
sfs_unlink may call do_lookup(), which increases the inode ref count,
but since that function does not return attributes that lookup ref
count won't get automatically decreased.
do_interrupt would destroy_req on the request without decrementing the
channel's refcount. With clone_fd this could leak file descriptors if
the worker thread holding the cloned fd was destroyed. (Only
max_idle_threads are kept).
When returning a negative error code by ->ioctl() to the high level
interface, no error is propagated to the low level, and the reply
message to the kernel is shown as successful.
A negative result is however returned to kernel, so the kernel can
detect the bad condition, but this appears to not be the case since
kernel 5.15.
The proposed fix is more in line with the usual processing of errors
in fuse, taking into account that ioctl(2) always returns a non-negative
value in the absence of errors.
Co-authored-by: Jean-Pierre André <jpandre@users.sourceforge.net>
Simulate write() delay and verify that close(rofd) does not
block waiting on pending writes.
The support for the flag was added in kernel v5.16-rc1.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Allow requesting from kernel to avoid flush on close at file open
time. If kernel does not support FOPEN_NOFLUSH flag, the request
will be ignored.
For passthrough_hp example, request to avoid flush on close when
writeback cache is disabled and file is opened O_RDONLY.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
When directories with open handles are removed, the releasedir and
fsyncdir operations might be called with a NULL path. That is because
there is no hiding behavior like for regular files and the nodes get
removed immediately.
As pointed here [1] __has_attribute() is broken for many attributes and
if it doesn't support the specific attribute it returns true, so we
can't really rely on that for this check. This lead to Buildroot
libfuse3 build failure [2] where that shows up with:
```
error: symver is only supported on ELF platforms
```
Indeed Microblaze doesn't support ELF since it doesn't include elfos.h,
but __has_attribute(symver) returns true.
So let's substitute the #ifdef __has_attribute() with a stronger test on
a function foo() with __attribute__((symver ("test@TEST"))).
[1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101766
[2]: http://autobuild.buildroot.net/results/d6c/d6cfaf2aafaeda3c12d127f6a2d2e175b25e654f/build-end.log
Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
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>
Before last unlink() release the reference on inode.fd to allow reuse
of underlying fs inode number, mark the server inode "deleted" and bump
it's generation counter.
When same inode number is found on lookup(), the server inode object will
be reused as well.
Skip this when inode has an open file and when writeback cache is enabled.
This will be used to verify inode reuse bug fix in the kernel.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
On some tests on regular files, open an O_PATH fd of the testfile and
record it along side the size and mode and inode.
At the end of all tests, use recorded testfiles info to re-check the size
mode and inode of the unlinked testfiles.
With O_PATH fd, the server does not have to keep the inode alive so FUSE
inode may be stale or bad. Therefore, ESTALE and EIO are valid results
for fstat() on the old testfile fd's, but returning the wrong size or
mode is an invalid result.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Generate unique filename per test (only for regular file for now).
Make sure to unlink the unique filename after each test.
realpath variable was renamed to basepath_r to fix build warning
on conflicting symbols with realpath() function.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
rename dir loop test fails when test tmp dir is xfs with an error
test_rename_dir_loop() - rename : File exists
That is because xfs returns EEXIST for the case of renaming over
a non-empty directory.
According to rename(2) man page, EEXIST and ENOTEMPTY are both valid
error code in this case.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
We currently do not pass anything in PREDEFINED and that means
FUSE_USE_VERSION is undefined.
Add that definition so that Doxygen built-in C pre-processor can use
FUSE_USE_VERSION value to find the correct comment to parse.
fuse (4) is an excellent introduction to the FUSE protocol,
and it lists fusermount (1) and mount.fuse (8) in its
SEE ALSO section.
I (the author of gocryptfs) was not aware of this man
page till March 2021, which suggest that it should be
made more discoverable.
So link back to fuse (4) in our SEE ALSO sections.