aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_syscalls.c
AgeCommit message (Collapse)AuthorLines
2025-07-16Add statx supportJoanne Koong-0/+49
This commit adds libfuse support for FUSE_STATX requests on linux distributions. Currently, statx is only supported on linux. To make the interface a ergonomic as possible (eg using native 'struct statx' vs 'struct fuse_statx'), this implementation gates the 'struct statx' changes by #ifdef linux. Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
2025-02-18tests: Re-enable mknod and mkfifo tests on FreeBSDVassili Tchersky-6/+0
Signed-off-by: Vassili Tchersky <vt+git@vbcy.org>
2025-02-18tests: Disable tests with TMP_FILE on FreeBSDVassili Tchersky-0/+4
Not supported yet on this platform. See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=283179 Signed-off-by: Vassili Tchersky <vt+git@vbcy.org>
2025-02-10Build fixes for -OgBernd Schubert-1/+1
Cleaning... 18 files. [35/69] Compiling C object example/passthrough_ll.p/passthrough_ll.c.o ../example/passthrough_ll.c: In function ‘lo_opendir’: ../example/passthrough_ll.c:666:20: warning: ‘fd’ may be used uninitialized [-Wmaybe-uninitialized] 666 | if (fd != -1) | ^ ../example/passthrough_ll.c:637:13: note: ‘fd’ was declared here 637 | int fd; | ^~ [38/69] Compiling C object test/test_syscalls.p/test_syscalls.c.o ../test/test_syscalls.c: In function ‘test_seekdir’: ../test/test_syscalls.c:804:16: warning: ‘de’ may be used uninitialized [-Wmaybe-uninitialized] 804 | while (de) | ^~ ../test/test_syscalls.c:776:24: note: ‘de’ was declared here 776 | struct dirent *de; | ^~ These are actually valid. Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2024-11-27support FUSE_TMPFILE in the low level APIHorst Birthelmer-0/+100
Note that name hashes and using paths as parameters makes it very hard to support anonymous files in the high level API. Known Issues: - tests have to bail out when O_TMPFILE is not supported. This will always be the case with high level passthrough implementations. - test_create_and_link_tmpfile has to be skipped due to unidentified problems with github runner
2023-01-28Install a the configure_file (config.h) and use in headersBernd Schubert-1/+1
This addresses: https://github.com/libfuse/libfuse/issues/724 HAVE_LIBC_VERSIONED_SYMBOLS configures the library if to use versioned symbols and is set at meson configuration time. External filesystems (the main target, actually) include fuse headers and the preprocessor then acts on HAVE_LIBC_VERSIONED_SYMBOLS. Problem was now that 'config.h' was not distributed with libfuse and so HAVE_LIBC_VERSIONED_SYMBOLS was never defined with external tools and the preprocessor did the wrong decision. This commit also increases the the minimal meson version, as this depends on meson feature only available in 0.50 <quote 'meson' > WARNING: Project specifies a minimum meson_ version '>= 0.42' but uses features which were added in newer versions: * 0.50.0: {'install arg in configure_file'} </quote> Additionally the config file has been renamed to "fuse_config.h" to avoid clashes - 'config.h' is not very specific.
2022-05-06Fix a test strncpy compilation warning with recent gccBernd Schubert-2/+4
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.
2021-11-20test/test_syscalls.c: allow EBADF in fcheck_stat() (#631)Luis Henriques-1/+2
Test test/test_examples.py::test_passthrough_hp[False] fails because, on kernels >= 5.14, fstat() will return -EBADF: 3 [check_unlinked_testfile] fcheck_stat() - fstat: Bad file descriptor 4 [check_unlinked_testfile] fcheck_stat() - fstat: Bad file descriptor 5 [check_unlinked_testfile] fcheck_stat() - fstat: Bad file descriptor 9 [check_unlinked_testfile] fcheck_stat() - fstat: Bad file descriptor ... This patch simply whitelists the EBADF errno code. Signed-off-by: Luís Henriques <lhenriques@suse.de> Co-authored-by: Luís Henriques <lhenriques@suse.de>
2021-06-23Do not run unlinked files test on passthrough_hp with old kernelsAmir Goldstein-3/+12
test_syscalls unlinked testfiles check fails on passthourhg_hp without the kernel commit "fuse: fix illegal access to inode with reused nodeid" queued for kernel 5.14 [1]. Make this check opt-in and do not run it with kernel version before 5.14. [1] https://lore.kernel.org/linux-fsdevel/CAJfpegtGKjeK8E5QsHKF0=re1J9wVHuGRVgg9NDJ_OOwQdCUNg@mail.gmail.com/ Signed-off-by: Amir Goldstein <amir73il@gmail.com>
2021-06-14test/test_syscalls.c: check unlinked testfiles at the end of the testAmir Goldstein-16/+129
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>
2021-06-14test/test_syscalls.c: refactor fcheck_* helpersAmir Goldstein-68/+45
Avoid multiple fstat() calls and consolidate all fcheck_* helpers into fcheck_stat(). Signed-off-by: Amir Goldstein <amir73il@gmail.com>
2021-06-14test/test_syscalls.c: use unique filename per testAmir Goldstein-13/+37
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>
2021-06-02test/test_syscalls.c: fix test failure on xfs src dir (#611)Amir Goldstein-1/+1
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>
2020-11-06test/test_syscalls.c: fix potential fd leakage problemsZhiqiang Liu-2/+7
In test_syscalls.c, several funcs have potential fd leakage problems. This patch will fix them. Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com> Signed-off-by: Haotian Li <lihaotian9@huawei.com>
2020-05-15fix format in test (#515)Rosen Penev-1/+1
Fixes warning under 32-bit.
2019-08-29Avoid gcc 9.1 strncpy(3) warnings (#447)Stefan Hajnoczi-1/+2
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-05-15passthrough: fix unix-domain sockets on FreeBSD (#413)Alan Somers-0/+53
FreeBSD doesn't allow creating sockets using mknod(2). Instead, one has to use socket(2) and bind(2). Add appropriate logic to the examples and add a test case.
2019-05-09Added new example filesystemNikolaus Rath-4/+7
passthrough_hp puts emphasis and performance and correctness, rather than simplicity.
2019-03-11Define ALLPERMS for musl libc systems. (#379)maxice8-0/+4
2019-03-09Work around -Wformat-truncation=/-Wformat-overflow= warnings (#356)Tomohiro Kusumi-5/+5
sprintf(3)/snprintf(3) destination buffers need to be large enough so that gcc doesn't warn -Wformat-truncation= or -Wformat-overflow= when source buffer size is 1024 bytes. -- ../test/test_syscalls.c:1445:47: warning: '%s' directive output may be truncated writing 1 byte into a region of size between 0 and 1023 [-Wformat-truncation=] #define PATH(p) (snprintf(path, sizeof path, "%s/%s", testdir, p), path) ^~~~~~~ ../test/test_syscalls.c:1458:19: res = mkdir(PATH("a"), 0755); ~~~ Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
2019-03-08Document fuse_fsync_in.fsync_flags and remove magic numbers (#375)Alan Somers-6/+8
2018-11-19tests: add copy_file_range() to the syscall testsNiels de Vos-0/+99
2018-07-21Fix readdir() bug when a non-zero offset is specified in filler (#269)Rostislav-0/+61
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-0/+216
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.
2017-08-11Skip tests that aren't supported under FreeBSD.Nikolaus Rath-1/+7
2017-08-03Don't check st_nlink value for mkdirNikolaus Rath-1/+3
Some filesystems don't track this for directories. Fixes: #180.
2017-01-12Added experimental support for building with Meson+NinjaNikolaus Rath-0/+1522