qemu-gpiodev/libfuse.git
19 months agoReleased fuse-3.16.1 fuse-3.16.1
Nikolaus Rath [Tue, 8 Aug 2023 10:15:03 +0000 (11:15 +0100)]
Released fuse-3.16.1

19 months agoDon't attempt to put signify signature into gz header
Nikolaus Rath [Wed, 5 Jul 2023 17:58:05 +0000 (18:58 +0100)]
Don't attempt to put signify signature into gz header

This is currently buggy, cf. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1042837

19 months agoMake errnum-verification more flexible (#824)
ikbenlike [Sat, 5 Aug 2023 20:39:09 +0000 (22:39 +0200)]
Make errnum-verification more flexible (#824)

Instead of hardcoding the value to check against, use a more dynamic method to verify the error number before passing it to the kernel.

20 months agoPass cache_readdir and keep_cache from high level API (#822)
Aleksandr Mikhailov [Thu, 3 Aug 2023 17:01:46 +0000 (19:01 +0200)]
Pass cache_readdir and keep_cache from high level API (#822)

* Pass cache_readdir and keep_cache from high level API

* Update ChangeLog.rst

20 months agoAdd dependabot for GHA
Pedro Kaj Kjellerup Nacht [Wed, 26 Jul 2023 13:48:26 +0000 (13:48 +0000)]
Add dependabot for GHA

Signed-off-by: Pedro Kaj Kjellerup Nacht <pnacht@google.com>
20 months agoHash-pin workflow Actions
Pedro Kaj Kjellerup Nacht [Wed, 26 Jul 2023 13:48:07 +0000 (13:48 +0000)]
Hash-pin workflow Actions

Signed-off-by: Pedro Kaj Kjellerup Nacht <pnacht@google.com>
20 months agoAllow linking with mold / fix the version script (#814)
Bernd Schubert [Fri, 7 Jul 2023 15:18:38 +0000 (17:18 +0200)]
Allow linking with mold / fix the version script (#814)

This fixes issue https://github.com/libfuse/libfuse/issues/810
and should avoid mold linking errors.
Commit d4e294b removed made fuse_register_module() a static
function, but forgot to remove it from the version script.

Commit fe4f942 introduced copy_file_range to libfuse and
added the non-exiting (neither declared nor defined) function
fuse_reply_copy_file_range() to the version script. Kernel
side just exects an integer reply how much was copied, using
fuse_reply_write() as in fuse_lib_copy_file_range() is sufficient
and no extra function is needed.

Co-authored-by: Bernd Schubert <bschubert@ddn.com>
20 months agoUse signify to sign releases.
Nikolaus Rath [Wed, 5 Jul 2023 10:03:07 +0000 (11:03 +0100)]
Use signify to sign releases.

20 months agoMerge tag 'fuse-3.15.1'
Nikolaus Rath [Wed, 5 Jul 2023 10:25:13 +0000 (11:25 +0100)]
Merge tag 'fuse-3.15.1'

20 months agoReleased fuse-3.15.1 fuse-3.15.1
Nikolaus Rath [Wed, 5 Jul 2023 10:14:33 +0000 (11:14 +0100)]
Released fuse-3.15.1

21 months agoReduce default write size by half
Nikolaus Rath [Sat, 1 Jul 2023 13:12:44 +0000 (14:12 +0100)]
Reduce default write size by half

Hopefully this will reduce test flakiness on CI.

21 months agoAdd missing include.
Nikolaus Rath [Sat, 1 Jul 2023 13:10:28 +0000 (14:10 +0100)]
Add missing include.

21 months agoMake expire only function fail if no kernel support (#789)
HereThereBeDragons [Fri, 30 Jun 2023 12:57:06 +0000 (14:57 +0200)]
Make expire only function fail if no kernel support (#789)

21 months agoClarify behavior of fuse_session_exit().
Nikolaus Rath [Thu, 29 Jun 2023 12:11:11 +0000 (13:11 +0100)]
Clarify behavior of fuse_session_exit().

21 months agoImprove wording of user_allow_other usage instructions (#806)
Waldir Pimenta [Mon, 19 Jun 2023 20:00:12 +0000 (21:00 +0100)]
Improve wording of user_allow_other usage instructions (#806)

* Improve wording of user_allow_other usage instructions

* Remove dated comment from mount_max usage instructions

21 months agoWrapper around test applications for cross compiler environment in meson.build (...
Rudi Heitbaum [Tue, 13 Jun 2023 10:02:01 +0000 (20:02 +1000)]
Wrapper around test applications for cross compiler environment in meson.build (#804)

This enhances commit 7be56c57f93e3436b1fbd9ecc320de5c03a3e4b8 to allow build
fuse to be built using a cross compiler

Fixes:
../meson.build:180:12: ERROR: Can not run test applications in this cross environment.

21 months agoReleased 3.15.0 fuse-3.15.0
Nikolaus Rath [Fri, 9 Jun 2023 09:36:28 +0000 (10:36 +0100)]
Released 3.15.0

21 months agoError handling for fusermount's commfd (#786)
Matthias Görgens [Thu, 8 Jun 2023 10:47:45 +0000 (18:47 +0800)]
Error handling for fusermount's commfd (#786)

21 months agoutil/meson.build: don't install udev.rules if udevdir cannot be determined (#801)
wdlkmpx [Thu, 8 Jun 2023 10:24:43 +0000 (05:24 -0500)]
util/meson.build: don't install udev.rules if udevdir cannot be determined (#801)

make the udev dependency optional

just show a big warning if `udevrulesdir` is empty

21 months agomeson.build: pass -D_FILE_OFFSET_BITS=64 to C/C++ compiler (#799)
wdlkmpx [Thu, 8 Jun 2023 10:24:28 +0000 (05:24 -0500)]
meson.build: pass -D_FILE_OFFSET_BITS=64 to C/C++ compiler (#799)

libfuse requires a 64bit off_t, it's not optional
../include/fuse_common.h:938:1: error: Kstatic assertion failed: "fuse: off_t must be 64bit"

so this only takes effect if compiling for a 32bit glibc system, it's ignored everywhere else

meson by default adds -D_FILE_OFFSET_BITS=64 to C/C++ compilers, and removes duplicate declarations
There are several opened issues in meson's git repo requesting to remove that behavior, so this makes sense even more now

this fixes compilation with muon (a C99 (mostly) meson compatible build app) in a 32bit glibc system ...

21 months agoutil/mount.fuse.c: compile with linux headers < 3.5 (#798)
wdlkmpx [Thu, 8 Jun 2023 10:23:55 +0000 (05:23 -0500)]
util/mount.fuse.c: compile with linux headers < 3.5 (#798)

PR_SET_NO_NEW_PRIVS was added in linux 3.5 according to prtcl(2) man page

https://elixir.bootlin.com/linux/v4.3/source/include/uapi/linux/prctl.h#L174

21 months agoFix memory leak (#785)
Matthias Görgens [Thu, 8 Jun 2023 10:20:56 +0000 (18:20 +0800)]
Fix memory leak (#785)

This is just to [keep address sanitizer happy](https://github.com/libfuse/libfuse/actions/runs/4730520764/jobs/8394347666?pr=784).  The OS would normally clean this up anyway.

Co-authored-by: Nikolaus Rath <Nikolaus@rath.org>
21 months agoRemove unnecessary `_GNU_SOURCE` in `fuse.c` (#787)
Matthias Görgens [Thu, 8 Jun 2023 07:26:54 +0000 (15:26 +0800)]
Remove unnecessary `_GNU_SOURCE` in `fuse.c` (#787)

We stopped using pthread_rwlock_t in 3fecccca989328ed2c0ac68860ee1ceec0673972, so we don't need `_GNU_SOURCE` anymore in `fuse.c`

21 months agoAdd security policy (#797)
Pedro Nacht [Tue, 6 Jun 2023 09:00:35 +0000 (06:00 -0300)]
Add security policy (#797)

Signed-off-by: Pedro Kaj Kjellerup Nacht <pnacht@google.com>
22 months agoAdd minimal token permissions
Pedro Kaj Kjellerup Nacht [Thu, 18 May 2023 20:47:33 +0000 (20:47 +0000)]
Add minimal token permissions

Signed-off-by: Pedro Kaj Kjellerup Nacht <pnacht@google.com>
22 months agoAdd support for running xfstests.
Nikolaus Rath [Fri, 17 Mar 2023 09:56:55 +0000 (09:56 +0000)]
Add support for running xfstests.

22 months agoDo not daemonize to early
Nikolaus Rath [Fri, 17 Mar 2023 09:04:28 +0000 (09:04 +0000)]
Do not daemonize to early

fuse_session_mount() may print errors to stderr, if we daemonize before
that than these are lost.

22 months agoDo not pass unsupported mount options to the kernel.
Nikolaus Rath [Mon, 8 May 2023 23:12:08 +0000 (16:12 -0700)]
Do not pass unsupported mount options to the kernel.

The filesystem daemon is responsible for implementing eg. st_atime updates, so passing
options like relatime to the kernel results in them being silently ignored. Instead, such
options need to be interpreted (and filtered out) by the filesystem daemon.

22 months agoFix issue #746. (#782)
Peri [Thu, 11 May 2023 01:38:46 +0000 (02:38 +0100)]
Fix issue #746. (#782)

Added a secondary check in fuse_lib_unlink() after hide_node()
to check again under a lock if the (now hidden) file is still open.
If not then delete it.

This should synchronise fuse_lib_unlink() with fuse_lib_release(),
when nullpath_ok is set.

23 months agoFix memory leak in high level API (#781)
Matthias Görgens [Fri, 14 Apr 2023 11:19:03 +0000 (19:19 +0800)]
Fix memory leak in high level API (#781)

Previously, in the high level API if we received a signal between
setting up signal handlers and processing INIT, we would leak

```
$ ./example/hello -s -d -f mountpoint/
[9/9] Linking target example/hello_ll
FUSE library version: 3.14.1
nullpath_ok: 0

=================================================================
==178330==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 352 byte(s) in 1 object(s) allocated from:
    #0 0x7fbb19abf411 in __interceptor_calloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:77
    #1 0x7fbb1a0efd3b in fuse_fs_new ../lib/fuse.c:4814
    #2 0x7fbb1a0f02b5 in fuse_new_31 ../lib/fuse.c:4913
    #3 0x7fbb1a10ec5e in fuse_main_real ../lib/helper.c:345
    #4 0x5625db8ab418 in main ../example/hello.c:176
    #5 0x7fbb1983c78f  (/usr/lib/libc.so.6+0x2378f)

SUMMARY: AddressSanitizer: 352 byte(s) leaked in 1 allocation(s).
```

That's because `fuse_lowlevel.c`s `fuse_session_destroy` would only call
the user supplied `op.destroy`, if INIT had been processed, but the high
level API relied on `op.destroy` to free `f->fs`.

This patch moves the freeing into `fuse_destroy` that will always be
called by our high-level API.

23 months agoFix doxygen deprecation warning (#774)
Matthias Görgens [Wed, 12 Apr 2023 08:10:12 +0000 (16:10 +0800)]
Fix doxygen deprecation warning (#774)

Before:

```
$ doxygen doc/Doxyfile
warning: Tag 'COLS_IN_ALPHA_INDEX' at line 707 of file 'doc/Doxyfile' has become obsolete.
         To avoid this warning please remove this line from your configuration file or upgrade it using "doxygen -u"
warning: Tag 'PERL_PATH' at line 1048 of file 'doc/Doxyfile' has become obsolete.
         To avoid this warning please remove this line from your configuration file or upgrade it using "doxygen -u"
warning: Tag 'CLASS_DIAGRAMS' at line 1061 of file 'doc/Doxyfile' has become obsolete.
         To avoid this warning please remove this line from your configuration file or upgrade it using "doxygen -u"
warning: Tag 'MSCGEN_PATH' at line 1070 of file 'doc/Doxyfile' has become obsolete.
         To avoid this warning please remove this line from your configuration file or upgrade it using "doxygen -u"
warning: Tag 'DOT_TRANSPARENT' at line 1207 of file 'doc/Doxyfile' has become obsolete.
         To avoid this warning please remove this line from your configuration file or upgrade it using "doxygen -u"
warning: Changing CLASS_GRAPH option to TEXT because obsolete option CLASS_DIAGRAM was found and set to NO.
/Users/matthias/prog/fuser/libfuse/include/fuse.h:934: warning: argument 'private_data' of command @param is not found in the argument list of fuse_new_31(struct fuse_args *args, const struct fuse_operations *op, size_t op_size, void *user_data)
/Users/matthias/prog/fuser/libfuse/include/fuse.h:934: warning: The following parameter of fuse_new_31(struct fuse_args *args, const struct fuse_operations *op, size_t op_size, void *user_data) is not documented:
  parameter 'user_data'
```

So let's try `doxygen -u doc/Doxyfile`.  After:

```
$ doxygen doc/Doxyfile
/Users/matthias/prog/fuser/libfuse/include/fuse.h:934: warning: argument 'private_data' of command @param is not found in the argument list of fuse_new_31(struct fuse_args *args, const struct fuse_operations *op, size_t op_size, void *user_data)
/Users/matthias/prog/fuser/libfuse/include/fuse.h:934: warning: The following parameter of fuse_new_31(struct fuse_args *args, const struct fuse_operations *op, size_t op_size, void *user_data) is not documented:
  parameter 'user_data'
```

The generated documentation `doc/html` does not differ.

For ease of review, here's a diff with all blank lines and comments removed via `grep -vE '^#|^$' doc/Doxyfile`

```
diff --git a/doc/Doxyfile.old b/doc/Doxyfile.new
index dbf469b..3f56d32 100644
--- a/doc/Doxyfile.old
+++ b/doc/Doxyfile.new
@@ -3,0 +4,2 @@ PROJECT_NUMBER         =
+PROJECT_BRIEF          =
+PROJECT_LOGO           =
@@ -5,0 +8,2 @@ CREATE_SUBDIRS         = NO
+CREATE_SUBDIRS_LEVEL   = 8
+ALLOW_UNICODE_NAMES    = NO
@@ -26,0 +31 @@ JAVADOC_AUTOBRIEF      = NO
+JAVADOC_BANNER         = NO
@@ -28,0 +34 @@ MULTILINE_CPP_IS_BRIEF = NO
+PYTHON_DOCSTRING       = YES
@@ -36,0 +43,5 @@ OPTIMIZE_OUTPUT_VHDL   = NO
+OPTIMIZE_OUTPUT_SLICE  = NO
+EXTENSION_MAPPING      =
+MARKDOWN_SUPPORT       = YES
+TOC_INCLUDE_HEADINGS   = 5
+AUTOLINK_SUPPORT       = YES
@@ -41,0 +53 @@ DISTRIBUTE_GROUP_DOC   = NO
+GROUP_NESTED_COMPOUNDS = NO
@@ -42,0 +55,2 @@ SUBGROUPING            = YES
+INLINE_GROUPED_CLASSES = NO
+INLINE_SIMPLE_STRUCTS  = NO
@@ -43,0 +58,2 @@ TYPEDEF_HIDES_STRUCT   = NO
+LOOKUP_CACHE_SIZE      = 0
+NUM_PROC_THREADS       = 1
@@ -45,0 +62,2 @@ EXTRACT_PRIVATE        = NO
+EXTRACT_PRIV_VIRTUAL   = NO
+EXTRACT_PACKAGE        = NO
@@ -49,0 +68 @@ EXTRACT_ANON_NSPACES   = NO
+RESOLVE_UNNAMED_PARAMS = YES
@@ -56,0 +76,2 @@ HIDE_SCOPE_NAMES       = NO
+HIDE_COMPOUND_REFERENCE= NO
+SHOW_HEADERFILE        = YES
@@ -57,0 +79,2 @@ SHOW_INCLUDE_FILES     = YES
+SHOW_GROUPED_MEMB_INC  = NO
+FORCE_LOCAL_INCLUDES   = NO
@@ -60,0 +84 @@ SORT_BRIEF_DOCS        = NO
+SORT_MEMBERS_CTORS_1ST = NO
@@ -62,0 +87 @@ SORT_BY_SCOPE_NAME     = NO
+STRICT_PROTO_MATCHING  = NO
@@ -72,0 +98,2 @@ FILE_VERSION_FILTER    =
+LAYOUT_FILE            =
+CITE_BIB_FILES         =
@@ -76,0 +104 @@ WARN_IF_DOC_ERROR      = YES
+WARN_IF_INCOMPLETE_DOC = YES
@@ -77,0 +106,2 @@ WARN_NO_PARAMDOC       = NO
+WARN_IF_UNDOC_ENUM_VAL = NO
+WARN_AS_ERROR          = NO
@@ -78,0 +109 @@ WARN_FORMAT            = "$file:$line: $text"
+WARN_LINE_FORMAT       = "at line $line of file $file"
@@ -82 +113,5 @@ INPUT_ENCODING         = UTF-8
-FILE_PATTERNS          = *.h *.c *.h *.dox
+INPUT_FILE_ENCODING    =
+FILE_PATTERNS          = *.h \
+                         *.c \
+                         *.h \
+                         *.dox
@@ -89 +124,2 @@ EXAMPLE_PATH           = example
-EXAMPLE_PATTERNS       = *.c *.h
+EXAMPLE_PATTERNS       = *.c \
+                         *.h
@@ -94,0 +131,3 @@ FILTER_SOURCE_FILES    = NO
+FILTER_SOURCE_PATTERNS =
+USE_MDFILE_AS_MAINPAGE =
+FORTRAN_COMMENT_AFTER  = 72
@@ -100,0 +140 @@ REFERENCES_LINK_SOURCE = YES
+SOURCE_TOOLTIPS        = YES
@@ -104 +143,0 @@ ALPHABETICAL_INDEX     = NO
-COLS_IN_ALPHA_INDEX    = 5
@@ -112 +151,10 @@ HTML_STYLESHEET        =
-GENERATE_HTMLHELP      = NO
+HTML_EXTRA_STYLESHEET  =
+HTML_EXTRA_FILES       = doc/fast17-vangoor.pdf
+HTML_COLORSTYLE        = AUTO_LIGHT
+HTML_COLORSTYLE_HUE    = 220
+HTML_COLORSTYLE_SAT    = 100
+HTML_COLORSTYLE_GAMMA  = 80
+HTML_TIMESTAMP         = NO
+HTML_DYNAMIC_MENUS     = YES
+HTML_DYNAMIC_SECTIONS  = YES
+HTML_INDEX_NUM_ENTRIES = 100
@@ -114,0 +163 @@ DOCSET_FEEDNAME        = "Doxygen generated docs"
+DOCSET_FEEDURL         =
@@ -116,2 +165,3 @@ DOCSET_BUNDLE_ID       = org.doxygen.Project
-HTML_DYNAMIC_SECTIONS  = YES
-HTML_EXTRA_FILES = doc/fast17-vangoor.pdf
+DOCSET_PUBLISHER_ID    = org.doxygen.Publisher
+DOCSET_PUBLISHER_NAME  = Publisher
+GENERATE_HTMLHELP      = NO
@@ -123,0 +174,10 @@ TOC_EXPAND             = NO
+GENERATE_QHP           = NO
+QCH_FILE               =
+QHP_NAMESPACE          = org.doxygen.Project
+QHP_VIRTUAL_FOLDER     = doc
+QHP_CUST_FILTER_NAME   =
+QHP_CUST_FILTER_ATTRS  =
+QHP_SECT_FILTER_ATTRS  =
+QHG_LOCATION           =
+GENERATE_ECLIPSEHELP   = NO
+ECLIPSE_DOC_ID         = org.doxygen.Project
@@ -125 +184,0 @@ DISABLE_INDEX          = NO
-ENUM_VALUES_PER_LINE   = 4
@@ -126,0 +186,2 @@ GENERATE_TREEVIEW      = NO
+FULL_SIDEBAR           = NO
+ENUM_VALUES_PER_LINE   = 4
@@ -127,0 +189,3 @@ TREEVIEW_WIDTH         = 250
+EXT_LINKS_IN_WINDOW    = NO
+OBFUSCATE_EMAILS       = YES
+HTML_FORMULA_FORMAT    = png
@@ -128,0 +193,14 @@ FORMULA_FONTSIZE       = 10
+FORMULA_MACROFILE      =
+USE_MATHJAX            = NO
+MATHJAX_VERSION        = MathJax_2
+MATHJAX_FORMAT         = HTML-CSS
+MATHJAX_RELPATH        =
+MATHJAX_EXTENSIONS     =
+MATHJAX_CODEFILE       =
+SEARCHENGINE           = NO
+SERVER_BASED_SEARCH    = NO
+EXTERNAL_SEARCH        = NO
+SEARCHENGINE_URL       =
+SEARCHDATA_FILE        = searchdata.xml
+EXTERNAL_SEARCH_ID     =
+EXTRA_SEARCH_MAPPINGS  =
@@ -129,0 +208,18 @@ GENERATE_LATEX         = NO
+LATEX_OUTPUT           = latex
+LATEX_CMD_NAME         =
+MAKEINDEX_CMD_NAME     = makeindex
+LATEX_MAKEINDEX_CMD    = makeindex
+COMPACT_LATEX          = NO
+PAPER_TYPE             = a4
+EXTRA_PACKAGES         =
+LATEX_HEADER           =
+LATEX_FOOTER           =
+LATEX_EXTRA_STYLESHEET =
+LATEX_EXTRA_FILES      =
+PDF_HYPERLINKS         = YES
+USE_PDFLATEX           = YES
+LATEX_BATCHMODE        = NO
+LATEX_HIDE_INDICES     = NO
+LATEX_BIB_STYLE        = plain
+LATEX_TIMESTAMP        = NO
+LATEX_EMOJI_DIRECTORY  =
@@ -130,0 +227,5 @@ GENERATE_RTF           = NO
+RTF_OUTPUT             = rtf
+COMPACT_RTF            = NO
+RTF_HYPERLINKS         = NO
+RTF_STYLESHEET_FILE    =
+RTF_EXTENSIONS_FILE    =
@@ -131,0 +233,4 @@ GENERATE_MAN           = NO
+MAN_OUTPUT             = man
+MAN_EXTENSION          = .3
+MAN_SUBDIR             =
+MAN_LINKS              = NO
@@ -132,0 +238,5 @@ GENERATE_XML           = NO
+XML_OUTPUT             = xml
+XML_PROGRAMLISTING     = YES
+XML_NS_MEMB_FILE_SCOPE = NO
+GENERATE_DOCBOOK       = NO
+DOCBOOK_OUTPUT         = docbook
@@ -134,0 +245,3 @@ GENERATE_PERLMOD       = NO
+PERLMOD_LATEX          = NO
+PERLMOD_PRETTY         = YES
+PERLMOD_MAKEVAR_PREFIX =
@@ -148,3 +261,2 @@ EXTERNAL_GROUPS        = YES
-PERL_PATH              = /usr/bin/perl
-CLASS_DIAGRAMS         = NO
-MSCGEN_PATH            =
+EXTERNAL_PAGES         = YES
+DIA_PATH               =
@@ -152,0 +265,4 @@ HAVE_DOT               = NO
+DOT_NUM_THREADS        = 0
+DOT_COMMON_ATTR        = "fontname=Helvetica,fontsize=10"
+DOT_EDGE_ATTR          = "labelfontname=Helvetica,labelfontsize=10"
+DOT_NODE_ATTR          = "shape=box,height=0.2,width=0.4"
@@ -154 +270 @@ DOT_FONTPATH           =
-CLASS_GRAPH            = YES
+CLASS_GRAPH            = TEXT
@@ -157,0 +274,3 @@ UML_LOOK               = NO
+UML_LIMIT_NUM_FIELDS   = 10
+DOT_UML_DETAILS        = NO
+DOT_WRAP_THRESHOLD     = 17
@@ -164,0 +284 @@ DIRECTORY_GRAPH        = YES
+DIR_GRAPH_MAX_DEPTH    = 1
@@ -165,0 +286 @@ DOT_IMAGE_FORMAT       = png
+INTERACTIVE_SVG        = NO
@@ -167,0 +289,5 @@ DOTFILE_DIRS           =
+MSCFILE_DIRS           =
+DIAFILE_DIRS           =
+PLANTUML_JAR_PATH      =
+PLANTUML_CFG_FILE      =
+PLANTUML_INCLUDE_PATH  =
@@ -170 +295,0 @@ MAX_DOT_GRAPH_DEPTH    = 1000
-DOT_TRANSPARENT        = NO
@@ -174 +298,0 @@ DOT_CLEANUP            = YES
-SEARCHENGINE           = NO
```

23 months agoDisable leak suppression (#773)
Matthias Görgens [Wed, 12 Apr 2023 07:40:18 +0000 (15:40 +0800)]
Disable leak suppression (#773)

23 months agoFuse mount: make auto_unmount compatible with suid/dev mount options (#762)
Matthias Görgens [Wed, 12 Apr 2023 07:39:32 +0000 (15:39 +0800)]
Fuse mount: make auto_unmount compatible with suid/dev mount options (#762)

* Fuse mount: make auto_unmount compatible with suid/dev mount options

> When you run as root, fuse normally does not call fusermount but uses
> the mount system call directly. When you specify auto_unmount, it goes
> through fusermount instead. However, fusermount is a setuid binary that
> is normally called by regular users, so it cannot in general accept suid
> or dev options.

In this patch, we split up how fuse mounts as root when `auto_unmount`
is specified.

First, we mount using system calls directly, then we reach out to
fusermount to set up auto_unmount only (with no actual mounting done in
fusermount).

Fixes: #148
23 months agoUpdate fuse_kernel.h to state of linux-6.3
Bernd Schubert [Tue, 11 Apr 2023 15:54:09 +0000 (17:54 +0200)]
Update fuse_kernel.h to state of linux-6.3

This syncs fuse_kernel.h to <linux-6.3>/include/uapi/linux/fuse.h

Special handling is done for setxattr as in linux commit
52a4c95f4d24b struct fuse_setxattr_in was extended. Extended
struct is only used when FUSE_SETXATTR_EXT is passed in FUSE_INIT
reply.

23 months agoMigrate away from deprecated distutils
Matthias Goergens [Tue, 11 Apr 2023 11:08:40 +0000 (19:08 +0800)]
Migrate away from deprecated distutils

Before:

```
=============================== warnings summary ===============================
test/test_ctests.py:12
  /tmp/libfuse-build-mB50ZC/build-gcc-9/test/test_ctests.py:12: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
    from distutils.version import LooseVersion

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
```

23 months agoFix doxygen warning about parameter name
Matthias Goergens [Tue, 11 Apr 2023 03:43:06 +0000 (11:43 +0800)]
Fix doxygen warning about parameter name

Before:

```
$ doxygen doc/Doxyfile
/Users/matthias/prog/fuser/libfuse/include/fuse.h:934: warning: argument 'private_data' of command @param is not found in the argument list of fuse_new_31(struct fuse_args *args, const struct fuse_operations *op, size_t op_size, void *user_data)
/Users/matthias/prog/fuser/libfuse/include/fuse.h:934: warning: The following parameter of fuse_new_31(struct fuse_args *args, const struct fuse_operations *op, size_t op_size, void *user_data) is not documented:
  parameter 'user_data'
```

23 months agoFix typo
Matthias Goergens [Mon, 10 Apr 2023 14:42:11 +0000 (22:42 +0800)]
Fix typo

23 months agoFix PytestReturnNotNoneWarning
Matthias Goergens [Fri, 7 Apr 2023 07:39:21 +0000 (15:39 +0800)]
Fix PytestReturnNotNoneWarning

```
test_examples.py::test_printcap
  /usr/local/lib/python3.9/dist-packages/_pytest/python.py:199: PytestReturnNotNoneWarning: Expected None, but test_examples.py::test_printcap returned ((7, 38), {'FUSE_CAP_READDIRPLUS_AUTO', 'FUSE_CAP_ASYNC_DIO', 'FUSE_CAP_SPLICE_READ', 'FUSE_CAP_CACHE_SYMLINKS', 'FUSE_CAP_IOCTL_DIR', 'FUSE_CAP_NO_OPENDIR_SUPPORT', 'FUSE_CAP_NO_OPEN_SUPPORT', 'FUSE_CAP_POSIX_LOCKS', 'FUSE_CAP_READDIRPLUS', 'FUSE_CAP_POSIX_ACL', 'FUSE_CAP_ATOMIC_O_TRUNC', 'FUSE_CAP_SPLICE_MOVE', 'FUSE_CAP_EXPORT_SUPPORT', 'FUSE_CAP_FLOCK_LOCKS', 'FUSE_CAP_EXPLICIT_INVAL_DATA', 'FUSE_CAP_EXPIRE_ONLY', 'FUSE_CAP_DONT_MASK', 'FUSE_CAP_WRITEBACK_CACHE', 'FUSE_CAP_AUTO_INVAL_DATA', 'FUSE_CAP_PARALLEL_DIROPS', 'FUSE_CAP_SPLICE_WRITE', 'FUSE_CAP_ASYNC_READ'}), which will be an error in a future version of pytest.  Did you mean to use `assert` instead of `return`?
    warnings.warn(
```

23 months agoFix deprecated @pytest.mark.hookwrapper
Matthias Goergens [Fri, 7 Apr 2023 07:34:43 +0000 (15:34 +0800)]
Fix deprecated @pytest.mark.hookwrapper

```
PytestDeprecationWarning: The hookimpl pytest_pyfunc_call uses old-style configuration options (marks or attributes).
  Please use the pytest.hookimpl(hookwrapper=True) decorator instead
   to configure the hooks.
   See https://docs.pytest.org/en/latest/deprecations.html#configuring-hook-specs-impls-using-markers
    @pytest.mark.hookwrapper
```

23 months agoFix meson deprecation warning
Matthias Goergens [Fri, 7 Apr 2023 06:48:00 +0000 (14:48 +0800)]
Fix meson deprecation warning

Also for rest of CI

23 months agoFix meson deprecation warning also in FreeBSD
Matthias Goergens [Fri, 7 Apr 2023 06:44:56 +0000 (14:44 +0800)]
Fix meson deprecation warning also in FreeBSD

See ed9be128370c93b93895bb1bb61cc1e606277613

23 months agoFix deprecated udev.get_pkgconfig_variable in meson
Matthias Goergens [Fri, 7 Apr 2023 09:13:26 +0000 (17:13 +0800)]
Fix deprecated udev.get_pkgconfig_variable in meson

And slightly bump minimum meson version.

23 months agoUpgrade meson version in CI
Matthias Goergens [Fri, 7 Apr 2023 09:03:27 +0000 (17:03 +0800)]
Upgrade meson version in CI

23 months agoAdd long `--options` to fusermount (#764)
Matthias Görgens [Thu, 6 Apr 2023 12:26:22 +0000 (20:26 +0800)]
Add long `--options` to fusermount (#764)

Mostly for consistency with mount(8).

Co-authored-by: Nikolaus Rath <Nikolaus@rath.org>
23 months agoFix MS_LAZYTIME not defined on uclibc and move all MS_* and UMOUNT_* (#753)
Giulio Benetti [Thu, 6 Apr 2023 11:37:57 +0000 (13:37 +0200)]
Fix MS_LAZYTIME not defined on uclibc and move all MS_* and UMOUNT_* (#753)

as well as <sys/mount.h> inclusion to new fuse_mount_compat.h file.

Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
23 months agoDocument risks of auto_unmount (#763)
Nikolaus Rath [Tue, 4 Apr 2023 21:20:19 +0000 (22:20 +0100)]
Document risks of auto_unmount (#763)

2 years agoWorkaround musl bug when mountdir has whitespace (#761)
Matthias Görgens [Sun, 2 Apr 2023 09:45:27 +0000 (17:45 +0800)]
Workaround musl bug when mountdir has whitespace (#761)

Fixes https://github.com/libfuse/libfuse/issues/634 and https://github.com/mpartel/bindfs/issues/106

2 years agoFix compiler warning in hello_ll.c (#760)
Nikolaus Rath [Sat, 1 Apr 2023 21:42:18 +0000 (22:42 +0100)]
Fix compiler warning in hello_ll.c (#760)

2 years agoAdd unit tests for setxattr() et al
Nikolaus Rath [Sat, 1 Apr 2023 15:45:46 +0000 (16:45 +0100)]
Add unit tests for setxattr() et al

Hopefully, this will catch issues as in commit 024eccbf3

2 years agoFix typos and configure spellcheck for PRs
Yaroslav Halchenko [Wed, 29 Mar 2023 18:47:13 +0000 (14:47 -0400)]
Fix typos and configure spellcheck for PRs

2 years agoFix meson deprecation warning
Matthias Goergens [Wed, 29 Mar 2023 03:07:04 +0000 (11:07 +0800)]
Fix meson deprecation warning

When running `meson ..` I get:

```
WARNING: Running the setup command as `meson [options]` instead of `meson setup [options]` is ambiguous and deprecated.WARNING: Running the setup command as `meson [options]` instead of `meson setup [options]` is ambiguous and deprecated.
```

So let's fix this in the docs.

2 years agoFix use-after-free warning
Matthias Goergens [Tue, 28 Mar 2023 05:35:56 +0000 (13:35 +0800)]
Fix use-after-free warning

When building, I get the following warning:

```bash
$ ninja
[18/71] Compiling C object lib/libfuse3.so.3.14.1.p/modules_iconv.c.o
../lib/modules/iconv.c: In function ‘iconv_convpath’:
../lib/modules/iconv.c:85:38: warning: pointer ‘newpath’ may be used after ‘realloc’ [-Wuse-after-free]
   85 |                         p = tmp + (p - newpath);
      |                                   ~~~^~~~~~~~~~
../lib/modules/iconv.c:80:31: note: call to ‘realloc’ here
   80 |                         tmp = realloc(newpath, newpathlen + 1);
      |                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[71/71] Linking target example/passthrough_hp
```

It's a false positive,  I thinks.  But it's also easy to silence this
warning with a small refactor.

2 years agoReview feedback: rename and comments
Matthias Goergens [Tue, 28 Mar 2023 09:45:55 +0000 (17:45 +0800)]
Review feedback: rename and comments

2 years agoFix `auto_unmount` to work without `allow_other`
Matthias Goergens [Mon, 27 Mar 2023 10:43:26 +0000 (18:43 +0800)]
Fix `auto_unmount` to work without `allow_other`

In
https://github.com/libfuse/libfuse/blob/77d662459a0fcdf358d515477d33795837e859d5/util/fusermount.c#L1219
`open` is executed as root which does not have access to the mount
point if `allow_other` was not used and the real user id is not 0. Since
`allow_other` usually cannot be specified by unprivileged users,
`auto_unmount` has no effect for unprivileged users.

In this commit, we work around this limitation:

We first try to open the mountpoint as root, and if we get `EACCES`, we
retry as the user who started fusermount, and see if we get `ENOTCONN`.

In my testing, I found that `setfsuid` and `setfsgid` don't work to get
around the lack of `allow_other`.  (Sorry, I don't know enough about the
Linux kernel to tell whether that's significant.)  As a workaround, I
decided to use `setresuid` and `setresgid` in a forked child process,
and communicate via its exit status.

Please give feedback on correctness, style and suggest tests.

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

2 years agoUpdate script to drop references to Travis CI.
Nikolaus Rath [Sun, 26 Mar 2023 10:49:40 +0000 (11:49 +0100)]
Update script to drop references to Travis CI.

2 years agoReleased 3.14.1 fuse-3.14.1
Nikolaus Rath [Sun, 26 Mar 2023 10:44:40 +0000 (11:44 +0100)]
Released 3.14.1

2 years agoRevert "upgrade of fuse_kernel.h based on Miklos expire_only kernel patch https:...
Nikolaus Rath [Sun, 26 Mar 2023 10:35:22 +0000 (11:35 +0100)]
Revert "upgrade of fuse_kernel.h based on Miklos expire_only kernel patch https://git./linux/kernel/git/mszeredi/fuse.git/commit/?h=for-next&id=53e949edb7692dce02220eba926c9d75ecbb47f7"

This reverts commit 7f430a39db5a30979d75a906af891a38ebce1a3c because it
breaks setxattr().

Fixes: #730
2 years agoAdd more time mount options to fusermount / fix lazytime
Bernd Schubert [Sun, 19 Mar 2023 21:12:36 +0000 (22:12 +0100)]
Add more time mount options to fusermount / fix lazytime

Previous patch had forgotten fusermount. And also had "lazyatime"
instead of "lazytime".

2 years agoAdd more time mount options
Bernd Schubert [Sat, 18 Mar 2023 18:51:42 +0000 (19:51 +0100)]
Add more time mount options

These are especially needed for xfstests, but also
useful in general.

2 years agoRespect includedir when installing libfuse_config.h
Heiko Becker [Sat, 11 Mar 2023 23:24:33 +0000 (00:24 +0100)]
Respect includedir when installing libfuse_config.h

2 years agoFix max_threads command line parameter propagation
Sarath Lakshman [Sat, 11 Mar 2023 11:28:31 +0000 (16:58 +0530)]
Fix max_threads command line parameter propagation

The fuse_main_real() method doesn't apply the max_threads parameter
parsed through the commandline arguments. This commit fixes the wiring
of max_threads argument.

2 years agoEnable parallel direct writes on the same file.
Dharmendra singh [Fri, 8 Apr 2022 10:18:27 +0000 (10:18 +0000)]
Enable parallel direct writes on the same file.

Right now fuse kernel serializes direct writes on the
same file. This serialization is good for such FUSE
implementations which rely on the inode lock to
avoid any data inconsistency issues but it hurts badly
such FUSE implementations which have their own mechanism
of dealing with cache/data integrity and can handle
parallel direct writes on the same file.

This patch allows parallel direct writes on the same file to be
enabled with the help of a flag FOPEN_PARALLEL_DIRECT_WRITES.
FUSE implementations which want to use this feature can
set this flag during fuse init. Default behaviour remains
same i.e no parallel direct writes on the same file.

Corresponding fuse kernel patch(Merged).
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v6.2&id=153524053bbb0d27bb2e0be36d1b46862e9ce74c

2 years agoUpdate description of keep_cache.
Nikolaus Rath [Wed, 1 Mar 2023 09:46:10 +0000 (09:46 +0000)]
Update description of keep_cache.

2 years agoMigrate from Travis to Github actions
Nikolaus Rath [Mon, 20 Feb 2023 19:46:16 +0000 (19:46 +0000)]
Migrate from Travis to Github actions

With current Ubuntu, Valgrind apparently does not like clang debug info, so do not run
valgrind with clang-compiled binaries.

2 years agoAvoid max-idle threads warning
Bernd Schubert [Sun, 19 Feb 2023 11:52:52 +0000 (12:52 +0100)]
Avoid max-idle threads warning

If a program with API before 312 did not set
max_idle_threads the new default from
fuse_parse_cmdline_312() is applied, which sets
UINT_MAX (-1).

Later in compat fuse_session_loop_mt_32 the old
config v1 struct is converted and that conversion
prints a warning if the default unset value was used.

This could have also happened to programs using the current
API, which just apply values struct fuse_cmdline_opts,
without checking if the defaults are set.

2 years agoChange define for C++ too
Pierre Labastie [Sun, 19 Feb 2023 08:52:13 +0000 (09:52 +0100)]
Change define for C++ too

Commit d7560cc has split defines into private and public, and passed -DHAVE_LIBFUSE-PRIVATE_CONFIG_H to all C programs. But the arguments of C++ programs have not been changed. This leads to a test failure as reported in issue #734. Pass -DHAVE_LIBFUSE-PRIVATE_CONFIG_H to C++ programs too.

Fixes: #734
2 years agoAdd a github actions file
Bernd Schubert [Sun, 19 Feb 2023 00:29:23 +0000 (01:29 +0100)]
Add a github actions file

converted from travis with _sligh_ editing by
https://akx.github.io/travis-to-github-actions/

2 years agoReleased 3.14.0 fuse-3.14.0
Nikolaus Rath [Fri, 17 Feb 2023 09:31:14 +0000 (09:31 +0000)]
Released 3.14.0

2 years agofuse_lowlevel.h: add more setattr flags
Xiubo Li [Thu, 9 Feb 2023 04:49:43 +0000 (12:49 +0800)]
fuse_lowlevel.h: add more setattr flags

Such as for the xfstest-dev's generic/684 test case it will clear
suid and sgid if the fallocate request is commited by an unprivileged
user.

The kernel fuse passed the ATTR_KILL_SUID/ATTR_KILL_SGID flags to
userspace but it will be dropped.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
2 years agoSplit config.h into private and public config
Bernd Schubert [Tue, 7 Feb 2023 22:06:42 +0000 (23:06 +0100)]
Split config.h into private and public config

This addresses https://github.com/libfuse/libfuse/issues/729

commit db35a37def14b72181f3630efeea0e0433103c41 introduced a public
config.h (rename to fuse_config.h to avoid conflicts) that
was installed with the package and included by libfuse users
through fuse_common.h. Probablem is that this file does not have
unique defines so that they are unique to libfuse - on including
the file conflicts with libfuse users came up.

In principle all defines could be prefixed, but then most of them
are internal for libfuse compilation only. So this splits out
publically required defines to a new file 'libfuse_config.h'
and changes back to include of "fuse_config.h" only when
HAVE_LIBFUSE_PRIVATE_CONFIG_H is defined.

This also renames HAVE_LIBC_VERSIONED_SYMBOLS to
LIBFUSE_BUILT_WITH_VERSIONED_SYMBOLS, as it actually
better explains for libfuse users what that variable
is for.

2 years agoReleased 3.13.1 fuse-3.13.1
Nikolaus Rath [Fri, 3 Feb 2023 10:05:30 +0000 (10:05 +0000)]
Released 3.13.1

2 years agoInstall a the configure_file (config.h) and use in headers
Bernd Schubert [Fri, 27 Jan 2023 20:54:48 +0000 (21:54 +0100)]
Install a the configure_file (config.h) and use in headers

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.

2 years agoUpdate travis to ubuntu jammy (22.04)
Bernd Schubert [Fri, 27 Jan 2023 22:14:55 +0000 (23:14 +0100)]
Update travis to ubuntu jammy (22.04)

A newer ubuntu version is required to get a more recent meson
(at least 0.50 now)

2 years agouse off_t over __off64_t
psykose [Sat, 14 Jan 2023 21:31:56 +0000 (21:31 +0000)]
use off_t over __off64_t

when -D_FILE_OFFSET_BITS=64 is defined, the off_t type is 64 bits wide
already. the fuse_common.h header already checks for this, and errors
when it is not, so be consistent with all the other uses of off_t.

some libcs like musl do not have a 32-bit off_t type, and don't define
__off64_t.

2 years agoReleased 3.13.0 fuse-3.13.0
Nikolaus Rath [Fri, 13 Jan 2023 10:33:35 +0000 (10:33 +0000)]
Released 3.13.0

2 years agopassthrough_hp: Avoid a bit code dup in readdir
Bernd Schubert [Wed, 23 Mar 2022 18:49:17 +0000 (19:49 +0100)]
passthrough_hp: Avoid a bit code dup in readdir

Just a slight code simplification.

2 years agopassthrough_hp: Add options for clone_fd, max_threads, daemonize
Bernd Schubert [Tue, 22 Mar 2022 18:55:36 +0000 (19:55 +0100)]
passthrough_hp: Add options for clone_fd, max_threads, daemonize

This is useful for benchmarking.

Note: This changes behavior - passthrough_hp runs in background by default
      now.

2 years agoFix loading of FUSE modules
Goswin von Brederlow [Fri, 13 Jan 2023 09:36:52 +0000 (10:36 +0100)]
Fix loading of FUSE modules

dlsym returns the address of the module factory symbol, not the actual function (#722)
pointer. Change the type of `factory` to `fuse_module_factory_t*` to reflect
this and then dereference it when registering the module.

This is a followup to d92bf83, which introduced a NULL pointer dereference
when dlsym returns NULL, and 8ec7fd9, which reverted it back to not
dereferencing the symbol at all.

Fixes: #721
Co-authored-by: Goswin von Brederlow <brederlo@q-leap.de>
2 years agoSupport application-defined I/O functions for FUSE fd
Tofik Sonono [Tue, 10 Jan 2023 10:04:35 +0000 (10:04 +0000)]
Support application-defined I/O functions for FUSE fd

The io for FUSE requests and responses can now be further customized by allowing to write custom functions for reading/writing the responses. This includes overriding the splice io.

The reason for this addition is that having a custom file descriptor is not sufficient to allow custom io. Different types of file descriptor require different mechanisms of io interaction. For example, some file descriptor communication has boundaries (SOCK_DGRAM, EOF, etc...), while other types of fd:s might be unbounded (SOCK_STREAMS, ...). For unbounded communication, you have to read the header of the FUSE request first, and then read the remaining packet data. Furthermore, the one read call does not necessarily return all the data expected, requiring further
calls in a loop.

2 years agoTest for fuse_lowlevel_notify_expire_entry.
HereThereBeDragons [Fri, 6 Jan 2023 13:05:00 +0000 (14:05 +0100)]
Test for fuse_lowlevel_notify_expire_entry.
This test is too simple to check for all functionalities of notify_expire as it always successfully passes when libfuse supports the function (even if kernel does not support it -  it just takes it as notify_inval)

2 years agoadding comments and capability discovery, enum for flags moved to top of file
HereThereBeDragons [Thu, 27 Oct 2022 15:52:10 +0000 (17:52 +0200)]
adding comments and capability discovery, enum for flags moved to top of file

2 years agoupgrade of fuse_kernel.h based on Miklos expire_only kernel patch https://git.kernel...
HereThereBeDragons [Thu, 27 Oct 2022 15:52:10 +0000 (17:52 +0200)]
upgrade of fuse_kernel.h based on Miklos expire_only kernel patch https://git./linux/kernel/git/mszeredi/fuse.git/commit/?h=for-next&id=53e949edb7692dce02220eba926c9d75ecbb47f7

2 years agoInitial patch provided by Miklos Szeredi <mszeredi@redhat.com>
HereThereBeDragons [Thu, 27 Oct 2022 15:52:10 +0000 (17:52 +0200)]
Initial patch provided by Miklos Szeredi <mszeredi@redhat.com>

2 years agoFixes when HAVE_LIBC_VERSIONED_SYMBOLS is not defined
Bernd Schubert [Tue, 3 Jan 2023 10:46:11 +0000 (11:46 +0100)]
Fixes when HAVE_LIBC_VERSIONED_SYMBOLS is not defined

fuse_loop_mt and fuse_new had not been defined when
HAVE_LIBC_VERSIONED_SYMBOLS had not been set and additionally,
fuse_new_31 was missing in the version script and was therefore
an unusable symbol.

This also adds a test for unset HAVE_LIBC_VERSIONED_SYMBOLS.

2 years agoconvert __APPLE__ and __ULIBC__ to HAVE_LIBC_VERSIONED_SYMBOLS
Bernd Schubert [Mon, 2 Jan 2023 21:53:54 +0000 (22:53 +0100)]
convert __APPLE__ and __ULIBC__ to HAVE_LIBC_VERSIONED_SYMBOLS

In fact only gnu-libc fully supports symbol versioning, so it is
better to have a generic macro for it. This also allows to manually
disable symbol version and allows to run tests with that
configuration on gnu-libc. That testing will still not catch compat
issues, but least ensures the code can compile.

Testing for __APPLE__ and __ULIBC__ is now done by meson. More of such
checks can be added by people using other libcs.

2 years agoFix ublic/apple build for the fuse_parse_cmdline ABI symbol
Bernd Schubert [Sun, 2 Oct 2022 20:39:52 +0000 (22:39 +0200)]
Fix ublic/apple build for the fuse_parse_cmdline ABI symbol

For __APPLE__ and __ULIBC__, which are assumed to not support
versioned symbols, helper.c has a compat ABI symbol for
fuse_parse_cmdline(). However that ABI symbol was conflicting
with the API macro (which redirects to the right API function
for recompilations against current libfuse).
Additionally the parameter 'opts' had a typo and was called
'out_opts'.

2 years agoRemove partial locking of paths when using high-level API
Kyle Lippincott [Mon, 12 Sep 2022 19:26:53 +0000 (12:26 -0700)]
Remove partial locking of paths when using high-level API

As described in https://github.com/libfuse/libfuse/issues/695 and below, partial
locking of paths can cause a deadlock. Partial locking was added to prevent
starvation, but it's unclear what specific cases of starvation were of concern.
As far as I was able to determine, since we support reader locks that give
priority to writers (to prevent starvation), this means that to starve the queue
element, we'd need a constant stream of queued requests that lock the path for
write. Write locks are used when the element is being (potentially) removed, so
this stream of requests that starve the `rename` or `lock` operations seems
unlikely.

### Summarizing issue #695

The high-level API handles locking of the node structures it maintains to
prevent concurrent requests from deleting nodes that are in use by other
requests. This means that requests that might remove these structs (`rmdir`,
`rename`, `unlink`, `link`) need to acquire an (internally managed - not
pthread) exclusive lock before doing so. In the case where the lock is already
held (for read or for write), the operation is placed onto a queue of waiters.
On every unlock, the queue is reinspected for any element that might now be able
to make progress.

Since `rename` and `link` involve two paths, when added to the queue, a single
queue entry requires that we lock two different paths. There was, prior to this
change, support for partially locking the first queue element if it had two
paths to lock. This partial locking can cause a deadlock:

- set up a situation where the first element in the queue is partially locked
  (such as by holding a reader lock on one of the paths being renamed, but not
  the other). For example: `/rmthis/foo/foo.txt` [not-yet-locked] and
  `/rmthis/bar/bar.txt` [locked]
- add an `rmdir` for an ancestor directory of the not-yet-locked path to the
  queue. In this example: `/rmthis`

After getting into this situation, we have the following `treelock` values:

- `/rmthis`: 1 current reader (due to the locked `/rmthis/bar/bar.txt`), one
  waiting writer (`rmdir`): no new readers will acquire a read lock here.
- `/rmthis/bar`: 1 reader (the locked `/rmthis/bar/bar.txt`)
- `/rmthis/bar/bar.txt`: 1 writer (the locked `/rmthis/bar/bar.txt`)

This is deadlocked, because the partial lock will never be able to be completely
locked, as doing so would require adding a reader lock on `/rmthis`, and that
will be rejected due to write lock requests having priority -- until the writer
succeeds in locking it, no new readers can be added. However, the writer (the
`rmdir`) will never be able to acquire its write lock, as the reader lock will
never be dropped -- there's no support for downgrading a partially locked
element to be unlocked, the only state change that's allowed involves it
becoming completely locked.

2 years agoMove try_get_path2 earlier in the file
Kyle Lippincott [Mon, 12 Sep 2022 19:26:53 +0000 (12:26 -0700)]
Move try_get_path2 earlier in the file

2 years agoRevert "libfuse custom communication interface"
Nikolaus Rath [Mon, 2 Jan 2023 11:08:16 +0000 (11:08 +0000)]
Revert "libfuse custom communication interface"

This reverts commit 777663953382925c7403f0560c28ec9bbd14d7be.

2 years agoupdate mount.c, in order to pass through -n.
Ciaran [Wed, 21 Dec 2022 00:44:50 +0000 (16:44 -0800)]
update mount.c, in order to pass through -n.

autofs uses automount, which calls fuse, during an sshfs call. fuse complains about -n being an unknown option (ref. https://github.com/libfuse/libfuse/issues/715)
this one line edit provides the command to be accepted, and pass through, allowing autofs-automount to operate on the mount, even though it is already in the mtab, given the nature of autofs/automount.

2 years agoMake it work even if max_idle_threads is set to 0
Zhansong Gao [Wed, 30 Nov 2022 08:01:50 +0000 (16:01 +0800)]
Make it work even if max_idle_threads is set to 0

It may happen that none of the worker threads are running
if max_idle_threads is set to 0 although few people will do this.
Adding a limit of keeping at least one worker thread will make
our code more rigorous.

Signed-off-by: Zhansong Gao <zhsgao@hotmail.com>
2 years agolibfuse custom communication interface
y [Mon, 14 Nov 2022 10:55:39 +0000 (11:55 +0100)]
libfuse custom communication interface

libfuse can now be used without having a mount interface.

2 years agoFix the fuse_parse_cmdline@FUSE_3.0 ABI compat symbol
Bernd Schubert [Sun, 11 Sep 2022 16:28:38 +0000 (18:28 +0200)]
Fix the fuse_parse_cmdline@FUSE_3.0 ABI compat symbol

There was a simple typo and sym1 didn't match the function name
with the older __asm__(".symver " sym1 "," sym2) way to define
ABI compatibility.
Witht the newer "__attribute__ ((symver (sym2)))" sym1 is not used
at all and in manual testing the issue didn't come up therefore.

2 years agoReleased 3.12.0 fuse-3.12.0
Nikolaus Rath [Thu, 8 Sep 2022 10:02:45 +0000 (11:02 +0100)]
Released 3.12.0

2 years agoAdd option to specify init script location
Fina Wilke [Sat, 16 Jul 2022 22:15:42 +0000 (00:15 +0200)]
Add option to specify init script location

Also allows to disable the installation if desired

2 years agoUse destroy_req instead of free to destroy fuse_req
Frank Dinoff [Tue, 26 Jul 2022 19:49:01 +0000 (15:49 -0400)]
Use destroy_req instead of free to destroy fuse_req

If we get the interrupt before the fuse op, the fuse_req is deleted without
decrementing the refcount on the cloned file descriptor. This leads to a
leak of the cloned /dev/fuse file descriptor.

2 years agoAdd summary of changes regarding 'max_threads' to ChangeLog.rst
Bernd Schubert [Fri, 5 Aug 2022 18:51:51 +0000 (20:51 +0200)]
Add summary of changes regarding 'max_threads' to ChangeLog.rst

Update the change log file with the summary of API changes related
to the 'max_threads' changes.

2 years agofuse_session_loop_mt: Accept a NULL config - use defaults
Bernd Schubert [Mon, 11 Apr 2022 10:02:54 +0000 (12:02 +0200)]
fuse_session_loop_mt: Accept a NULL config - use defaults

If an application does not want to bother with the session
and wants to keep defaults, it can now just pass a NULL
as config parameter.

2 years agofuse-loop/fuse_do_work: Avoid lots of thread creations/destructions
Bernd Schubert [Thu, 24 Mar 2022 11:19:57 +0000 (12:19 +0100)]
fuse-loop/fuse_do_work: Avoid lots of thread creations/destructions

On benchmarking metadata operations with a single threaded bonnie++
and "max_idle_threads" limited to 1, 'top' was showing suspicious
160% cpu usage.
Profiling the system with flame graphs showed that an astonishing
amount of CPU time was spent in thread creation and destruction.

After verifying the code it turned out that fuse_do_work() was
creating a new thread every time all existing idle threads
were already busy. And then just a few lines later after processing
the current request it noticed that it had created too many threads
and destructed the current thread. I.e. there was a thread
creation/destruction ping-pong.

Code is changed to only create new threads if the max number of
threads is not reached.

Furthermore, thread destruction is disabled, as creation/destruction
is expensive in general.

With this change cpu usage of passthrough_hp went from ~160% to
~80% (with different values of max_idle_threads). And bonnie
values got approximately faster by 90%. This is a with single
threaded bonnie++
bonnie++ -x 4 -q -s0  -d <path> -n 30:1:1:10 -r 0

Without this patch, using the default max_idle_threads=10 and just
a single bonnie++ the thread creation/destruction code path is not
triggered.  Just one libfuse and one application thread is just
a corner case - the requirement for the issue was just
n-application-threads >= max_idle_threads.

Signed-off-by: Bernd Schubert <bschubert@ddn.com>
2 years agoAPI update for fuse_loop_config additions
Bernd Schubert [Fri, 8 Apr 2022 20:30:27 +0000 (22:30 +0200)]
API update for fuse_loop_config additions

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>