Commit Graph

2048 Commits

Author SHA1 Message Date
desertwitch
366f6a6a9a example/notify_inval_entry.c: improve comment readability
Follow the same format as other arguments passed to example commands.
2024-07-08 09:53:08 +02:00
desertwitch
a36f16a3a4 example/notify_inval_entry.c: fix example command in comments
Notifications should be enabled here, but present command example would disable them.
2024-07-08 09:53:08 +02:00
Bernd Schubert
21b6ad2124 Add list of libfuse (kernel) operations
This is to document operations and to also list
their in/out arguments.
This list was auto generated and only partly verified,
use with care. Not all operations are supported by
libfuse yet.
2024-07-03 13:14:19 +02:00
Bernd Schubert
9581e214b8 Annotate ABI sensitivness for some data structures
These are not all ABI sensitive data structures yet.

Also some space vs tab indentation issues are corrected.
2024-07-03 13:10:46 +02:00
gandalfs_cat
54b8cd6757 high-level: add fmask and dmask options
dmask: umask applied to directories
fmask: umask applied to non-directories

to get "typical" permission bits for regular files (0644) and directories (0755), a single
umask option is not sufficient (or well, it isn't the way fuse implements it)

there is precident for separate umask and dmask options in other
filesystems (see for example fat: https://github.com/torvalds/linux/tree/master/fs/fat)

this addition should not affect backward-compatibility; the original
umask option retains the same meaning, but non-zero fmask or
dmask will override it.
2024-07-03 12:50:06 +02:00
Bernd Schubert
f88e08f34d Add nullptr check in fuse_session_mount
The pointer did not have any sanity check.

Addresses https://github.com/libfuse/libfuse/issues/979
2024-06-25 11:34:16 +02:00
CismonX
09e6583b54 Use off_t instead of loff_t
Since we're already enforcing 64-bit off_t, using loff_t
makes no difference.

Also loff_t is Linux-only, which breaks compatibility for *BSD.
2024-06-25 07:16:49 +02:00
CismonX
285465fbdb Fix wrong use of the EBADFD errno
should use EBADF instead
2024-06-25 07:16:49 +02:00
CismonX
0a62f5d761 Do not build the hello_ll_uds example for *BSD
since there's no splice(2) support
2024-06-25 07:16:49 +02:00
trapexit
e0dda7019d Update AUTHORS
Co-authored-by: Ashley Pittman <ashley@pittman.co.uk>
2024-06-22 14:14:53 +02:00
Antonio SJ Musumeci
2769a9edeb Update AUTHORS 2024-06-22 14:14:53 +02:00
dependabot[bot]
6b4b4dc859 Bump actions/checkout from 4.1.6 to 4.1.7
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.6 to 4.1.7.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](a5ac7e51b4...692973e3d9)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-19 18:04:37 +02:00
Miklos Szeredi
29f621af8d libfuse: null-terminate buffer in fuse_req_getgroups()
After reading the file /proc/$PID/task/$PID/status the buffer wasn't
terminated with a null character.  This could theoretically lead to buffer
overrun by the subsequent strstr() call.

Since the contents of the proc file are guaranteed to contain the pattern
that strstr is looking for, this doesn't happen in normal situations.

Add null termination for robustness.

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2024-06-13 16:39:54 +02:00
yangyun
8bd873cbcc fix useless fuse_init_intr_signal in high-level api
The code `fuse_init_intr_signal` in `_fuse_new_317` is useless
since commit 8ee553dac ("fuse_new(): don't accept options that
don't make sense for end-users") has remove the conf.intr option
for end-users. The conf.intr is always zero (i.e., disabled) here.

Move `fuse_init_intr_signal` after the user-defined `init()` function,
so that conf.intr and conf.intr_signal has been configured by the user.
2024-06-11 09:47:31 +02:00
Josef Bacik
c9204dbd0d libfuse: have passthrough_hp return an error with invalid mount options
generic/003 fails currently because if you specify -o relatime we will
fail to mount, but not return an error, so the test thinks that we
support relatime and then hilarity ensues.  Set ret so that if we get
any failures while trying to mount we will properly error out.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
2024-06-07 21:33:04 +02:00
Bernd Schubert
2105cd7724
xfstests: Add the possibility for extra daemon options (#964)
We need to test w/o page cache, w/o passthrough and other options.
I.e. we need to have the possibility to add these options via
local.config
2024-06-07 21:31:28 +02:00
Bernd Schubert
dd5349a2cf
Merge pull request #957 from bsbernd/fuse-req-atomic-ref-cnt
Atomic struct fuse_req::ref_cnt
2024-06-04 14:44:51 +02:00
Bernd Schubert
153d65ff6b Rename struct fuse_req::ctr to ::ref_cnt
ref_cnt should make the intention of this variable more clear.
2024-06-04 14:00:55 +02:00
Bernd Schubert
d44162534c Make struct fuse_req::ctr a C11 _Atomic
The variable is not modified exclusively with locks since commit
cef8c8b249 ("Add support for no_interrupt") anymore.
That commit is safe, but might be error prone to future updates.
Changing it to a C11 _Atomic should avoid issues.
2024-06-04 13:59:42 +02:00
yangyun50
cef8c8b249
Add support for no_interrupt (#956)
The function fuse_session_process_buf_int() would do much things
for FUSE_INTERRUPT requests, even there are no FUSE_INTERRUPT requests:

1. check every non-FUSE_INTERRUPT request and add these requests to the
linked list(se->list) under a big lock(se->lock).
2. the function fuse_free_req() frees every request and remove them from
the linked list(se->list) under a bing lock(se->lock).

These operations are not meaningful when there are no FUSE_INTERRUPT requests,
and have a great impact on the performance of fuse filesystem because the big
lock for each request.

In some cases, FUSE_INTERRUPT requests are infrequent, even none at all.
Besides, the user-defined filesystem may do nothing for FUSE_INTERRUPT requests.

And the kernel side has the option "no_interrupt" in struct fuse_conn. This kernel option
can be enabled by return ENOSYS in libfuse for the reply of FUSE_INTERRUPT request.
But I don't find the code to enable the "no_interrupt" kernel option in libfuse.

So add the no_interrupt support, and when this operaion is enabled:
1. remove the useless locking operaions and list operations.
2. return ENOSYS for the reply of FUSE_INTERRUPT request to inform the kernel to disable
FUSE_INTERRUPT request.
2024-06-04 13:50:48 +02:00
legezywzh
949944ff3b
Fix compatibility issue around fuse_custom_io->clone_fd (#953)
Fixes: 73cd124d04 ("Add clone_fd to custom IO (#927)")

Signed-off-by: Xiaoguang Wang <lege.wang@jaguarmicro.com>
2024-06-01 23:18:35 +02:00
Bernd Schubert
251d2fb0e1
Remove most includes in compat.c (#954)
compat.c is supposed to be standalone to provide compat ABI symbols.
Including fuse header files can cause conflicts - just the opposite
of what compat.c was made for.
2024-05-27 15:24:10 +02:00
Bernd Schubert
05becec65d
Add a .clang-format file (#952)
This is direct copy of <linux>/.clang-format as
this project was initiated with linux style. Some
lines that were auto-generated are removed
("# Taken from:...).

Some files like example/passthrough_hp.cc use
a different style - these files probably should
be cleaned up when major changes are done to them.
2024-05-27 10:18:19 +02:00
dependabot[bot]
6476b1c3cc
--- (#951)
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-22 20:53:49 +02:00
Amir Goldstein
eca63dab45
Enable passthrough mode for read/write operations (#919)
Add support for filesystem passthrough read/write of files.

When the FUSE_PASSTHROUGH capability is enabled, the FUSE server may
decide, while handling the "open" or "create" requests, if the given
file can be accessed by that process in "passthrough" mode, meaning that
all the further read and write operations would be forwarded by the
kernel directly to the backing file rather than to the FUSE server.
All requests other than read or write are still handled by the server.

This allows for an improved performance on reads and writes, especially
in the case of reads at random offsets, for which no (readahead)
caching mechanism would help, reducing the performance gap between FUSE
and native filesystem access.

Extend also the passthrough_hp example with the new passthrough feature.
This example opens a kernel backing file per FUSE inode on the first
FUSE file open of that inode and closes the backing file on the release
of the last FUSE file on that inode.

All opens of the same inode passthrough to the same backing file.
A combination of fi->direct_io and fi->passthrough is allowed.
It means that read/write operations go directly to the server, but mmap
is done on the backing file.

This allows to open some fds of the inode in passthrough mode and some
fd of the same inode in direct_io/passthrough_mmap mode.

Signed-off-by: Alessio Balsini <balsini@android.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
2024-05-13 15:30:25 +02:00
Bernd Schubert
58f85bfa9b
Add in the libfuse version a program was compiled with (#942)
The API stays the same, the libfuse version comes from
inlined functions, which are defined fuse_lowlevel.h
and fuse.h. As these inlined functions are defined in the header
files they get added into the application, similar as if these
were preprocessor macros.
Macro vs inlined function is then just a style issue - I personally
prefer the latter.

fuse_session_new() -> static inlinei, in the application
_fuse_session_new -> inside of libfuse

fuse_new() -> static inline, in the application
_fuse_new() -> inside of libfuse

Note: Entirely untested is the fuse 30 api - we need a test
for it. And we do not have any ABI tests at all.

Signed-off-by: Bernd Schubert <bernd.schubert@fastmail.fm>
2024-05-13 12:32:06 +02:00
Josef Bacik
2bdec0bc22
Handle NO_OPEN/NO_OPENDIR support automatically (#949)
If the file system doesn't provide a ->open or an ->opendir, and the
kernel supports FUSE_CAP_NO_OPEN_SUPPORT or FUSE_CAP_NO_OPENDIR_SUPPORT,
allow the implementation to set FUSE_CAP_NO_OPEN*_SUPPORT on conn->want
in order to automatically get this behavior.  Expand the documentation
to be more explicit about the behavior of libfuse in the different cases
WRT this capability.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
2024-05-10 17:52:20 +02:00
dependabot[bot]
0128f5efe8
Bump actions/checkout from 4.1.4 to 4.1.5 (#946)
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.4 to 4.1.5.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](0ad4b8fada...44c2b7a8a4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-07 20:16:48 +02:00
CismonX
e4e6873973
fuse_common.h: fix warning on _Static_assert() (#939)
_Static_assert() is an ISO C11 feature.  Make the check more
standard-conformant so that the compiler won't give pedantic warnings.
2024-05-07 13:22:59 +02:00
Bernd Schubert
b701673e74
Fix missing fuse_loop_cfg_destroy() in fuse_session_loop_mt_31 (#944)
All credits to Miklos Szeredi <miklos@szeredi.hu> for spotting
this.

Signed-off-by: Bernd Schubert <bernd.schubert@fastmail.fm>
2024-05-05 13:09:56 +02:00
dependabot[bot]
26fa6c1f03
Bump actions/checkout from 4.1.3 to 4.1.4 (#943)
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.3 to 4.1.4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](1d96c772d1...0ad4b8fada)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-30 10:05:33 +02:00
Bernd Schubert
8a9e2dc20c
Use std=gnu11 (#940)
We already have some C11 pieces like Static_assert and we are likely
going to add more - tell meson to use C11.
Plain C11 does not work as there are several language extension,
like typeof - part of C23 only. We might be able to fix/workaround
such extensions with compiler ifdef, but then I prefer gnu11 over
checking which compiler is used (example gcc has __typeof vs
clangs __typeof++). And compiler extension would also defeat pedantic.
2024-04-27 14:25:48 +02:00
dependabot[bot]
cdcaabd2c3
Bump actions/checkout from 4.1.2 to 4.1.3 (#934)
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.2 to 4.1.3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](9bb56186c3...1d96c772d1)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-26 14:19:16 +02:00
Bernd Schubert
45effd5db8
[libFuse 3.16.2]Compilation failure on freeBSD #936 (#938)
Despite the creation of the header file fuse_config.h during LibFUSE
version 3.16.2's Meson build process, the BSD mount_bsd.c file continues to reference config.h. Consequently, this discrepancy results in compilation failures.

FIX : Point the mount_bsd.c to correct header.
2024-04-25 17:09:05 +02:00
Bernd Schubert
80663a7936
Use single place to define the version and increase version to 3.17.0 (#932)
* Use single place to define the version

Defining the version in fuse_common.h, is removed, it is defined
through meson and provided by "libfuse_config.h". I.e. it avoids
to define the version twice - once in meson and once in
fuse_common.h.

Ideal would be to set integers in the meson file and create the version
string from these integers. However, meson requires that "project"
is the first meson.build keyword - with that it requires to
set the version from a string and then major/minor/hotfix integers
are created from string split.

Signed-off-by: Bernd Schubert <bernd.schubert@fastmail.fm>

* Increase the version to 3.17.0

This is to prepare the branch for the next release.

Signed-off-by: Bernd Schubert <bernd.schubert@fastmail.fm>

---------

Signed-off-by: Bernd Schubert <bernd.schubert@fastmail.fm>
2024-04-22 12:05:39 +02:00
Bernd Schubert
a8f1ae35af
example/: Convert all fuse_session_loop_mt users to 3.12 API (#931)
Convert all the remaining users of fuse_session_loop_mt() to
the new 3.12 config api.
2024-04-20 22:56:13 +02:00
legezywzh
285da329ea
passthrough_ll: fix fd leaks in lo_destroy() (#929)
By virtio-fs and libfuse fuse_custom_io, passthrough_ll could be
a virtio filesystem device backend, this bug was found when doing
mount, fsstress and umount repeatedly.

Signed-off-by: Xiaoguang Wang <lege.wang@jaguarmicro.com>
Co-authored-by: Xiaoguang Wang <lege.wang@jaguarmicro.com>
2024-04-20 13:40:16 +02:00
legezywzh
73cd124d04
Add clone_fd to custom IO (#927)
Define a new clone_fd() helper for fuse_custom_io, users
can implement their own clone fd logic.

Signed-off-by: Xiaoguang Wang <lege.wang@jaguarmicro.com>
2024-04-18 11:29:35 +02:00
legezywzh
080077369e
fix max_write update in do_init() (#926)
If user updates conn->max_write in fuse_lowlevel_ops' init() method, do_init()
will miss the "conn.max_write > bufsize - FUSE_BUFFER_HEADER_SIZE" judgment,
and ->init method will be called after it, which obviously is a bug.

Signed-off-by: Xiaoguang Wang <lege.wang@jaguarmicro.com>
Co-authored-by: Xiaoguang Wang <lege.wang@jaguarmicro.com>
2024-04-16 17:23:57 +02:00
Bernd Schubert
20de66dc89
fusermount: Fix use of uninitialized x_mnt_opts (#924)
x_mnt_opts was not initialized to 0, but strncat was done

Spotted by cppcheck running on our ddn branch.
2024-04-06 15:19:33 +02:00
Bernd Schubert
e2df577a7c
Add more documentation for FUSE_CAP_EXPORT_SUPPORT (#917)
Add more documentation for FUSE_CAP_EXPORT_SUPPORT

Also remove the flag from passthrough_ll.c and passthrough_hp.cc
as these implementations do _not_ handle that flag. They just
cast fuse_ino_t to an inode and cause a heap buffer overflow
for unknown objects (simplest reproducer are the examples
in "man 2 open_by_handle_at", but to unmount/mount the file
system after name_to_handle_at and before open_by_handle_at).

Fixes https://github.com/libfuse/libfuse/issues/838

---------

Co-authored-by: Nikolaus Rath <Nikolaus@rath.org>
2024-04-02 23:52:18 +02:00
Bernd Schubert
3e283a1bcb Add support for FUSE_CAP_HANDLE_KILLPRIV_V2
This just adds in the basic handler, but does not
use it yet in examples.
2024-03-29 13:04:45 +01:00
Bernd Schubert
67d4db4050 Fix FUSE_CAP_DIRECT_IO_ALLOW_MMAP - use new numerical value
Commit 22741f5  accidentally re-used (1 << 27), which is
already taken for FUSE_CAP_SETXATTR_EXT.

Fortunately not part of any release yet.
2024-03-27 21:35:50 +01:00
Ashley Pittman
e3bd7de517 Install all test/build python packages from requirements.txt
Have GitHub actions setup python on runners and install
all python dependencies via pip.

Signed-off-by: Ashley Pittman <ashley@pittman.co.uk>
2024-03-27 17:26:14 +01:00
farlongsignal
dd95d13aac
fix readdirplus when filler is called with zero offset (#896)
fixes #235

In fill_dir_plus(), there's a lookup for caching dirent attributes.
However, when offset = 0 the cache metadata from the lookup is lost
as only the entry attributes are passed when added to the list. Kernel
doesn't cache the attributes since .ino = 0.

This change moves the entry lookup to happen just before the relevant
fuse_add_direntry_plus() calls
2024-03-24 21:54:19 +01:00
legezywzh
f01d9277cb
reset got_init after handling FUSE_DESTROY message (#910)
User may still need to mount same fuse filesystem after umounting
it(In this case, the userspace filesystem server needs to keep live),
and after handling FUSE_DESTROY message, new FUSE_INIT message may come,
so need to reset got_init to be zero.

Signed-off-by: Xiaoguang Wang <lege.wang@jaguarmicro.com>
2024-03-21 10:02:05 +01:00
Bernd Schubert
e547a66566
ci-build.sh: Fix checking for function arguments (#909)
Checking for an emtpy string actually doesn't work for $@,
so just check for number of arguments.

Co-authored-by: Bernd Schubert <bschubert@ddn.com>
2024-03-20 16:43:54 +01:00
FredyVia
c021e910a5
Add FUSE_FILL_DIR_DEFAULTS enum (#903)
In order to use the fuse_fill_dir_t function in a C++ program, add the enum item:
FUSE_FILL_DIR_DEFAULTS

Without this change g++ compilation failed with
example/hello.c:94:35: error: invalid conversion from ‘int’ to ‘fuse_fill_dir_flags’ [-fpermissive]
   94 |         filler(buf, ".", NULL, 0, 0);
      |                                   ^
      |                                   |
      |                                   int
2024-03-20 16:08:04 +01:00
Bernd Schubert
9a823df6d9
Fix example/fix-notify_inval_inode.c (#908)
Similar issue as fixed in commit
3c7ba570 "examples/notify_store_retrieve: Add a clean shutdown".
Basically a clean shutdown was missing, but even with clean
shutdown it does not work, as kernel side releases inodes before
sending FUSE_DESTROY - the intervaled thread then gets
-ENOENT.

Co-authored-by: Bernd Schubert <bschubert@ddn.com>
2024-03-20 15:25:41 +01:00
dependabot[bot]
b4804ce3f8
Bump actions/checkout from 4.1.1 to 4.1.2 (#905)
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.1 to 4.1.2.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](b4ffde65f4...9bb56186c3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-20 14:53:43 +01:00