From 4520a97286e53977d15825111365d46b99d5a836 Mon Sep 17 00:00:00 2001 From: Tomasz Kulasek <34129113+tkulasek@users.noreply.github.com> Date: Wed, 20 Nov 2019 12:43:52 +0100 Subject: fix memleak in cuse_lowlevel_setup (#472) Local variable args is not freed on cuse_lowlevel_setup success. Signed-off-by: Tomasz Kulasek --- lib/cuse_lowlevel.c | 1 + 1 file changed, 1 insertion(+) (limited to 'lib') diff --git a/lib/cuse_lowlevel.c b/lib/cuse_lowlevel.c index 9917b64..b70947e 100644 --- a/lib/cuse_lowlevel.c +++ b/lib/cuse_lowlevel.c @@ -319,6 +319,7 @@ struct fuse_session *cuse_lowlevel_setup(int argc, char *argv[], if (res == -1) goto err_sig; + fuse_opt_free_args(&args); return se; err_sig: -- cgit v1.2.3 From ada08d50a647adb37c77f2106e7adc0db6ab93d5 Mon Sep 17 00:00:00 2001 From: Albert Chen Date: Wed, 27 Nov 2019 01:36:30 -0800 Subject: Added support for FUSE_EXPLICIT_INVAL_DATA to enable (#474) --- lib/fuse_lowlevel.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib') diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c index f2d7038..6eb949f 100644 --- a/lib/fuse_lowlevel.c +++ b/lib/fuse_lowlevel.c @@ -1965,6 +1965,8 @@ static void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) se->conn.capable |= FUSE_CAP_HANDLE_KILLPRIV; if (arg->flags & FUSE_NO_OPENDIR_SUPPORT) se->conn.capable |= FUSE_CAP_NO_OPENDIR_SUPPORT; + if (arg->flags & FUSE_EXPLICIT_INVAL_DATA) + se->conn.capable |= FUSE_CAP_EXPLICIT_INVAL_DATA; if (!(arg->flags & FUSE_MAX_PAGES)) { size_t max_bufsize = FUSE_DEFAULT_MAX_PAGES_PER_REQ * getpagesize() @@ -2085,6 +2087,8 @@ static void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) outarg.flags |= FUSE_WRITEBACK_CACHE; if (se->conn.want & FUSE_CAP_POSIX_ACL) outarg.flags |= FUSE_POSIX_ACL; + if (se->conn.want & FUSE_CAP_EXPLICIT_INVAL_DATA) + outarg.flags |= FUSE_EXPLICIT_INVAL_DATA; outarg.max_readahead = se->conn.max_readahead; outarg.max_write = se->conn.max_write; if (se->conn.proto_minor >= 13) { -- cgit v1.2.3 From 014960bc77fbd3376354c2bef744b546075c0ccc Mon Sep 17 00:00:00 2001 From: "Dr. David Alan Gilbert" Date: Fri, 29 Nov 2019 09:14:28 +0000 Subject: Kill off some proto_major < 6 checks (#476) fuse_init already refuses to start if we're on major < 7 , so we can kill off checks for old major versions. Signed-off-by: Dr. David Alan Gilbert --- lib/fuse_lowlevel.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c index 6eb949f..3671385 100644 --- a/lib/fuse_lowlevel.c +++ b/lib/fuse_lowlevel.c @@ -2229,7 +2229,7 @@ int fuse_lowlevel_notify_inval_inode(struct fuse_session *se, fuse_ino_t ino, if (!se) return -EINVAL; - if (se->conn.proto_major < 6 || se->conn.proto_minor < 12) + if (se->conn.proto_minor < 12) return -ENOSYS; outarg.ino = ino; @@ -2251,7 +2251,7 @@ int fuse_lowlevel_notify_inval_entry(struct fuse_session *se, fuse_ino_t parent, if (!se) return -EINVAL; - if (se->conn.proto_major < 6 || se->conn.proto_minor < 12) + if (se->conn.proto_minor < 12) return -ENOSYS; outarg.parent = parent; @@ -2276,7 +2276,7 @@ int fuse_lowlevel_notify_delete(struct fuse_session *se, if (!se) return -EINVAL; - if (se->conn.proto_major < 6 || se->conn.proto_minor < 18) + if (se->conn.proto_minor < 18) return -ENOSYS; outarg.parent = parent; @@ -2305,7 +2305,7 @@ int fuse_lowlevel_notify_store(struct fuse_session *se, fuse_ino_t ino, if (!se) return -EINVAL; - if (se->conn.proto_major < 6 || se->conn.proto_minor < 15) + if (se->conn.proto_minor < 15) return -ENOSYS; out.unique = 0; @@ -2383,7 +2383,7 @@ int fuse_lowlevel_notify_retrieve(struct fuse_session *se, fuse_ino_t ino, if (!se) return -EINVAL; - if (se->conn.proto_major < 6 || se->conn.proto_minor < 15) + if (se->conn.proto_minor < 15) return -ENOSYS; rreq = malloc(sizeof(*rreq)); -- cgit v1.2.3 From abdd45f83cea86410536d9a45aa317cc0511d9d2 Mon Sep 17 00:00:00 2001 From: Bill Zissimopoulos Date: Tue, 31 Dec 2019 01:58:57 -0800 Subject: Make ioctl prototype conditional on FUSE_USE_VERSION. (#482) Define FUSE_USE_VERSION < 35 to get old ioctl prototype with int commands; define FUSE_USE_VERSION >= 35 to get new ioctl prototype with unsigned int commands. Fixes #463. --- lib/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/meson.build b/lib/meson.build index 28f0aee..98461d8 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -37,7 +37,7 @@ libfuse = library('fuse3', libfuse_sources, version: meson.project_version(), soversion: '3', include_directories: include_dirs, dependencies: deps, install: true, link_depends: 'fuse_versionscript', - c_args: [ '-DFUSE_USE_VERSION=34', + c_args: [ '-DFUSE_USE_VERSION=35', '-DFUSERMOUNT_DIR="@0@"'.format(fusermount_path) ], link_args: ['-Wl,--version-script,' + meson.current_source_dir() + '/fuse_versionscript' ]) -- cgit v1.2.3 From e3dcc2d550afebf9b4386f71294ab01fc1d6299d Mon Sep 17 00:00:00 2001 From: Bill Zissimopoulos Date: Thu, 2 Jan 2020 03:06:18 -0800 Subject: Fixed an issue with the linker version script. (#483) Fixes #467. --- lib/fuse_versionscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/fuse_versionscript b/lib/fuse_versionscript index 160f11d..235abf4 100644 --- a/lib/fuse_versionscript +++ b/lib/fuse_versionscript @@ -165,7 +165,7 @@ FUSE_3.7 { global: fuse_set_log_func; fuse_log; -} FUSE_3.3; +} FUSE_3.4; # Local Variables: # indent-tabs-mode: t -- cgit v1.2.3 From 50fe9f7c818628dc5dd69218c851a48fa1f07987 Mon Sep 17 00:00:00 2001 From: Bill Zissimopoulos Date: Thu, 2 Jan 2020 03:08:03 -0800 Subject: Fixed memory leak in fuse_session_new() --- lib/fuse_lowlevel.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c index 3671385..d8112f5 100644 --- a/lib/fuse_lowlevel.c +++ b/lib/fuse_lowlevel.c @@ -2975,7 +2975,8 @@ out5: out4: fuse_opt_free_args(args); out3: - free(mo); + if (mo != NULL) + destroy_mount_opts(mo); out2: free(se); out1: -- cgit v1.2.3 From 3b17db6f7417d5396230bfd56a64cae4e1e2a47c Mon Sep 17 00:00:00 2001 From: Jean-Yves VET Date: Fri, 13 Mar 2020 20:02:41 +0100 Subject: Fix issue preventing using splice with reads (#505) Context: SPLICE_WRITE is not used with regular buffers (i.e. when they are not file-descriptor backed buffers). There is a bug which assumes file descriptors are used. If the amount of data associated with those FD is lower than twice the page size, SPLICE_WRITE is not utilized. With regular buffers the aggregated size was always 0. Because vmsplice (splice user pages to/from a pipe) is called before splice in fuse_lowlevel.c, regular buffers would also work with splice. This patch prevents to fallback to non-splice enabled copies when itheir is no FD involved. --- lib/fuse_lowlevel.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c index d8112f5..fd1f484 100644 --- a/lib/fuse_lowlevel.c +++ b/lib/fuse_lowlevel.c @@ -650,7 +650,7 @@ static int fuse_send_data_iov(struct fuse_session *se, struct fuse_chan *ch, struct fuse_ll_pipe *llp; int splice_flags; size_t pipesize; - size_t total_fd_size; + size_t total_buf_size; size_t idx; size_t headerlen; struct fuse_bufvec pipe_buf = FUSE_BUFVEC_INIT(len); @@ -661,15 +661,13 @@ static int fuse_send_data_iov(struct fuse_session *se, struct fuse_chan *ch, if (flags & FUSE_BUF_NO_SPLICE) goto fallback; - total_fd_size = 0; + total_buf_size = 0; for (idx = buf->idx; idx < buf->count; idx++) { - if (buf->buf[idx].flags & FUSE_BUF_IS_FD) { - total_fd_size = buf->buf[idx].size; - if (idx == buf->idx) - total_fd_size -= buf->off; - } + total_buf_size = buf->buf[idx].size; + if (idx == buf->idx) + total_buf_size -= buf->off; } - if (total_fd_size < 2 * pagesize) + if (total_buf_size < 2 * pagesize) goto fallback; if (se->conn.proto_minor < 14 || -- cgit v1.2.3 From 9126a7b48e2c27fb0ce19785181286b15a438f76 Mon Sep 17 00:00:00 2001 From: Fabian Vogt Date: Fri, 15 May 2020 20:32:10 +0200 Subject: Avoid closing se->fd twice in fuse_lowlevel.c (#516) If fuse_session_unmount is called before fuse_session_destroy, both would try to close(se->fd). Avoid that by resetting it in fuse_session_unmount. --- lib/fuse_lowlevel.c | 1 + 1 file changed, 1 insertion(+) (limited to 'lib') diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c index fd1f484..3dabbd5 100644 --- a/lib/fuse_lowlevel.c +++ b/lib/fuse_lowlevel.c @@ -3040,6 +3040,7 @@ void fuse_session_unmount(struct fuse_session *se) { if (se->mountpoint != NULL) { fuse_kern_unmount(se->mountpoint, se->fd); + se->fd = -1; free(se->mountpoint); se->mountpoint = NULL; } -- cgit v1.2.3 From 06342ca60ed822b856990915f127d8beddc0d1f6 Mon Sep 17 00:00:00 2001 From: winndows Date: Wed, 1 Jul 2020 13:20:01 +0800 Subject: libfuse: Assign NULL to "old" to avoid free it twice (#522) Assign NULL to "old" at the first free(), to avoid the possible 2nd free() for it. Signed-off-by: Liao Pingfang Co-authored-by: Liao Pingfang --- lib/modules/iconv.c | 1 + 1 file changed, 1 insertion(+) (limited to 'lib') diff --git a/lib/modules/iconv.c b/lib/modules/iconv.c index eb5edd8..3a4db7c 100644 --- a/lib/modules/iconv.c +++ b/lib/modules/iconv.c @@ -705,6 +705,7 @@ static struct fuse_fs *iconv_new(struct fuse_args *args, if (old) { setlocale(LC_CTYPE, old); free(old); + old = NULL; } ic->next = next[0]; -- cgit v1.2.3 From 7471156354002c6547aa6c3a4f39a3262f435ba4 Mon Sep 17 00:00:00 2001 From: Albert Chen <58009229+hselin-kalista-io@users.noreply.github.com> Date: Fri, 3 Jul 2020 04:39:09 -0700 Subject: Fixed minor print alignment issue in iconv_help(), replacing tab with space (#519) --- lib/modules/iconv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 lib/modules/iconv.c (limited to 'lib') diff --git a/lib/modules/iconv.c b/lib/modules/iconv.c old mode 100644 new mode 100755 index 3a4db7c..e04e7a9 --- a/lib/modules/iconv.c +++ b/lib/modules/iconv.c @@ -644,7 +644,7 @@ static void iconv_help(void) free(old); printf( " -o from_code=CHARSET original encoding of file names (default: UTF-8)\n" -" -o to_code=CHARSET new encoding of the file names (default: %s)\n", +" -o to_code=CHARSET new encoding of the file names (default: %s)\n", charmap); free(charmap); } -- cgit v1.2.3 From 9e1c2a4959c16c0b50090dd822389ad9acb08111 Mon Sep 17 00:00:00 2001 From: winndows Date: Sat, 11 Jul 2020 02:58:07 +0800 Subject: fuse_lowlevel: Move assert for se before dereferencing it with se->debug (#530) Move assert for se before dereferencing it with se->debug. Signed-off-by: Liao Pingfang Co-authored-by: Liao Pingfang --- lib/fuse_lowlevel.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c index 3dabbd5..7b72ee0 100644 --- a/lib/fuse_lowlevel.c +++ b/lib/fuse_lowlevel.c @@ -167,6 +167,7 @@ static int fuse_send_msg(struct fuse_session *se, struct fuse_chan *ch, { struct fuse_out_header *out = iov[0].iov_base; + assert(se != NULL); out->len = iov_length(iov, count); if (se->debug) { if (out->unique == 0) { @@ -189,8 +190,6 @@ static int fuse_send_msg(struct fuse_session *se, struct fuse_chan *ch, int err = errno; if (res == -1) { - assert(se != NULL); - /* ENOENT means the operation was interrupted */ if (!fuse_session_exited(se) && err != ENOENT) perror("fuse: writing device"); -- cgit v1.2.3 From 48450411647ca0818821af7b05b819ceff92ae7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Fri, 10 Jul 2020 14:59:57 -0400 Subject: Fix: crash on failure to set locale (#529) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit setlocale() can fail, returning NULL, if the user has an invalid (or missing) locale set in the LANG environment variable. In my case, this happens when using VS Code's integrated terminal to launch a fuse-based filesystem. A bug (fix upcoming) results in VS Code setting an invalid locale. iconv_help() currently passes the return value of setlocale(...) directly to strdup() without checking if it is NULL, resulting in a crash. To reproduce, simply set LANG="something_invalid" and call fuse_lib_help(). Stack trace when the process receives `SIGSEGV`: (gdb) bt #0 0x00007fabd0fcc4b5 in __strlen_avx2 () from /usr/lib/libc.so.6 #1 0x00007fabd0ef9233 in strdup () from /usr/lib/libc.so.6 #2 0x00007fabd13b8128 in iconv_help () at ../lib/modules/iconv.c:641 #3 0x00007fabd13b81a8 in iconv_opt_proc (data=0x55580a6ee850, arg=0x55580a6edfb0 "-h", key=0, outargs=0x7ffeeb1a8ec8) at ../lib/modules/iconv.c:658 #4 0x00007fabd13af7d5 in call_proc (ctx=0x7ffeeb1a8ea0, arg=0x55580a6edfb0 "-h", key=0, iso=0) at ../lib/fuse_opt.c:161 #5 0x00007fabd13afaf1 in process_opt (ctx=0x7ffeeb1a8ea0, opt=0x7fabd13c3d40 , sep=0, arg=0x55580a6edfb0 "-h", iso=0) at ../lib/fuse_opt.c:233 #6 0x00007fabd13afd5a in process_gopt (ctx=0x7ffeeb1a8ea0, arg=0x55580a6edfb0 "-h", iso=0) at ../lib/fuse_opt.c:285 #7 0x00007fabd13b0117 in process_one (ctx=0x7ffeeb1a8ea0, arg=0x55580a6edfb0 "-h") at ../lib/fuse_opt.c:368 #8 0x00007fabd13b0190 in opt_parse (ctx=0x7ffeeb1a8ea0) at ../lib/fuse_opt.c:379 #9 0x00007fabd13b03d3 in fuse_opt_parse (args=0x7ffeeb1a8f70, data=0x55580a6ee850, opts=0x7fabd13c3d40 , proc=0x7fabd13b8186 ) at ../lib/fuse_opt.c:414 #10 0x00007fabd13b8226 in iconv_new (args=0x7ffeeb1a8f70, next=0x0) at ../lib/modules/iconv.c:680 #11 0x00007fabd13a5627 in print_module_help (name=0x7fabd13b9e1c "iconv", fac=0x7fabd13d48e0 ) at ../lib/fuse.c:4692 #12 0x00007fabd13a56aa in fuse_lib_help (args=0x7ffeeb1a9238) at ../lib/fuse.c:4721 iconv_help() is modified to print an error when setlocale() fails. It then carries on printing the iconv module's help. Reading setlocale(3), it seems that the strdup() of the result was not necessary. Signed-off-by: Jérémie Galarneau --- lib/modules/iconv.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/modules/iconv.c b/lib/modules/iconv.c index e04e7a9..76e2f7d 100755 --- a/lib/modules/iconv.c +++ b/lib/modules/iconv.c @@ -638,10 +638,15 @@ static const struct fuse_opt iconv_opts[] = { static void iconv_help(void) { - char *old = strdup(setlocale(LC_CTYPE, "")); - char *charmap = strdup(nl_langinfo(CODESET)); - setlocale(LC_CTYPE, old); - free(old); + char *charmap; + const char *old = setlocale(LC_CTYPE, ""); + + charmap = strdup(nl_langinfo(CODESET)); + if (old) + setlocale(LC_CTYPE, old); + else + perror("setlocale"); + printf( " -o from_code=CHARSET original encoding of file names (default: UTF-8)\n" " -o to_code=CHARSET new encoding of the file names (default: %s)\n", -- cgit v1.2.3 From 7b3e3899157566875280a8b860eb5ad5c73eadc1 Mon Sep 17 00:00:00 2001 From: asafkahlon <35964924+asafkahlon@users.noreply.github.com> Date: Sun, 9 Aug 2020 14:37:26 +0300 Subject: Define fuse_session_loop_mt as a macro on uclibc and MacOS (#532) On uclibc and MacOS we don't use versioned symbols. Hence, there's no definition for fuse_session_loop_mt on those cases and the linker won't be able to resolve calls to fuse_session_loop_mt() Signed-off-by: Asaf Kahlon --- lib/fuse_versionscript | 1 + 1 file changed, 1 insertion(+) (limited to 'lib') diff --git a/lib/fuse_versionscript b/lib/fuse_versionscript index 235abf4..a06f768 100644 --- a/lib/fuse_versionscript +++ b/lib/fuse_versionscript @@ -146,6 +146,7 @@ FUSE_3.2 { global: fuse_session_loop_mt; fuse_session_loop_mt_31; + fuse_session_loop_mt_32; fuse_loop_mt; fuse_loop_mt_31; } FUSE_3.1; -- cgit v1.2.3 From 50cbca799c1f9b010fabaa0dd4a387f29d140873 Mon Sep 17 00:00:00 2001 From: Nikolaus Rath Date: Sun, 9 Aug 2020 12:39:07 +0100 Subject: fuse_send_data_iov(): correctly calculate total buffer size. Fixes: #538. --- lib/fuse_lowlevel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c index 7b72ee0..f4e6138 100644 --- a/lib/fuse_lowlevel.c +++ b/lib/fuse_lowlevel.c @@ -662,7 +662,7 @@ static int fuse_send_data_iov(struct fuse_session *se, struct fuse_chan *ch, total_buf_size = 0; for (idx = buf->idx; idx < buf->count; idx++) { - total_buf_size = buf->buf[idx].size; + total_buf_size += buf->buf[idx].size; if (idx == buf->idx) total_buf_size -= buf->off; } -- cgit v1.2.3 From f0d55439057b3b75aed5ffa29b5f08ad2099d536 Mon Sep 17 00:00:00 2001 From: Nikolaus Rath Date: Fri, 28 Aug 2020 20:07:11 +0100 Subject: Suppress some bogus thread sanitizer warnings. --- lib/fuse_lowlevel.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c index f4e6138..21379c1 100644 --- a/lib/fuse_lowlevel.c +++ b/lib/fuse_lowlevel.c @@ -1888,7 +1888,10 @@ static void do_lseek(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) fuse_reply_err(req, ENOSYS); } -static void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) +/* Prevent bogus data races (bogus since "init" is called before + * multi-threading becomes relevant */ +static __attribute__((no_sanitize("thread"))) +void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { struct fuse_init_in *arg = (struct fuse_init_in *) inarg; struct fuse_init_out outarg; @@ -3115,17 +3118,22 @@ int fuse_req_getgroups(fuse_req_t req, int size, gid_t list[]) } #endif +/* Prevent spurious data race warning - we don't care + * about races for this flag */ +__attribute__((no_sanitize_thread)) void fuse_session_exit(struct fuse_session *se) { se->exited = 1; } +__attribute__((no_sanitize_thread)) void fuse_session_reset(struct fuse_session *se) { se->exited = 0; se->error = 0; } +__attribute__((no_sanitize_thread)) int fuse_session_exited(struct fuse_session *se) { return se->exited; -- cgit v1.2.3 From 83f682385543d949e4ee5e1271a96beddaa9a23b Mon Sep 17 00:00:00 2001 From: Tom Callaway Date: Fri, 11 Sep 2020 05:15:43 -0400 Subject: Implement GCC 10 style symbol versioning (#545) --- lib/fuse.c | 8 ++++---- lib/fuse_loop_mt.c | 4 ++-- lib/fuse_misc.h | 8 ++++++-- 3 files changed, 12 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/fuse.c b/lib/fuse.c index b0f5b30..70299ef 100755 --- a/lib/fuse.c +++ b/lib/fuse.c @@ -4569,7 +4569,7 @@ int fuse_loop(struct fuse *f) return fuse_session_loop(f->se); } -FUSE_SYMVER(".symver fuse_loop_mt_32,fuse_loop_mt@@FUSE_3.2"); +FUSE_SYMVER("fuse_loop_mt_32", "fuse_loop_mt@@FUSE_3.2") int fuse_loop_mt_32(struct fuse *f, struct fuse_loop_config *config) { if (f == NULL) @@ -4585,7 +4585,7 @@ int fuse_loop_mt_32(struct fuse *f, struct fuse_loop_config *config) } int fuse_loop_mt_31(struct fuse *f, int clone_fd); -FUSE_SYMVER(".symver fuse_loop_mt_31,fuse_loop_mt@FUSE_3.0"); +FUSE_SYMVER("fuse_loop_mt_31", "fuse_loop_mt@FUSE_3.0") int fuse_loop_mt_31(struct fuse *f, int clone_fd) { struct fuse_loop_config config; @@ -4870,7 +4870,7 @@ void fuse_stop_cleanup_thread(struct fuse *f) } -FUSE_SYMVER(".symver fuse_new_31,fuse_new@@FUSE_3.1"); +FUSE_SYMVER("fuse_new_31", "fuse_new@@FUSE_3.1") struct fuse *fuse_new_31(struct fuse_args *args, const struct fuse_operations *op, size_t op_size, void *user_data) @@ -5024,7 +5024,7 @@ out: /* Emulates 3.0-style fuse_new(), which processes --help */ struct fuse *fuse_new_30(struct fuse_args *args, const struct fuse_operations *op, size_t op_size, void *private_data); -FUSE_SYMVER(".symver fuse_new_30,fuse_new@FUSE_3.0"); +FUSE_SYMVER("fuse_new_30", "fuse_new@FUSE_3.0") struct fuse *fuse_new_30(struct fuse_args *args, const struct fuse_operations *op, size_t op_size, void *user_data) diff --git a/lib/fuse_loop_mt.c b/lib/fuse_loop_mt.c index 445e9a0..0c6a5b7 100644 --- a/lib/fuse_loop_mt.c +++ b/lib/fuse_loop_mt.c @@ -304,7 +304,7 @@ static void fuse_join_worker(struct fuse_mt *mt, struct fuse_worker *w) free(w); } -FUSE_SYMVER(".symver fuse_session_loop_mt_32,fuse_session_loop_mt@@FUSE_3.2"); +FUSE_SYMVER("fuse_session_loop_mt_32", "fuse_session_loop_mt@@FUSE_3.2") int fuse_session_loop_mt_32(struct fuse_session *se, struct fuse_loop_config *config) { int err; @@ -352,7 +352,7 @@ int fuse_session_loop_mt_32(struct fuse_session *se, struct fuse_loop_config *co } int fuse_session_loop_mt_31(struct fuse_session *se, int clone_fd); -FUSE_SYMVER(".symver fuse_session_loop_mt_31,fuse_session_loop_mt@FUSE_3.0"); +FUSE_SYMVER("fuse_session_loop_mt_31", "fuse_session_loop_mt@FUSE_3.0") int fuse_session_loop_mt_31(struct fuse_session *se, int clone_fd) { struct fuse_loop_config config; diff --git a/lib/fuse_misc.h b/lib/fuse_misc.h index 2f6663e..a8b5961 100644 --- a/lib/fuse_misc.h +++ b/lib/fuse_misc.h @@ -14,9 +14,13 @@ - not supported on MacOSX (in MachO binary format) */ #if (!defined(__UCLIBC__) && !defined(__APPLE__)) -#define FUSE_SYMVER(x) __asm__(x) +# if HAVE_SYMVER_ATTRIBUTE +# define FUSE_SYMVER(sym1, sym2) __attribute__ ((symver (sym2))) +# else +# define FUSE_SYMVER(sym1, sym2) __asm__("\t.symver " sym1 "," sym2); +# endif #else -#define FUSE_SYMVER(x) +#define FUSE_SYMVER(sym1, sym2) #endif #ifndef USE_UCLIBC -- cgit v1.2.3 From ba3b225a126ebb3c6d4fe27c9f7c73aa4167001e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Etienne=20Dubl=C3=A9?= Date: Sun, 20 Sep 2020 20:08:15 +0200 Subject: Allow caching symlinks in kernel page cache. (#551) This commit defines a new capability called `FUSE_CAP_CACHE_SYMLINKS`. It is off by default but you can now enable it by setting this flag in in the `want` field of the `fuse_conn_info` structure. When enabled, the kernel will save symlinks in its page cache, by making use of the feature introduced in kernel 4.20: https://github.com/torvalds/linux/commit/5571f1e65486be025f73fa6aa30fb03725d362a2 --- lib/fuse_lowlevel.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib') diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c index 21379c1..83510b3 100644 --- a/lib/fuse_lowlevel.c +++ b/lib/fuse_lowlevel.c @@ -1963,6 +1963,8 @@ void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) se->conn.capable |= FUSE_CAP_POSIX_ACL; if (arg->flags & FUSE_HANDLE_KILLPRIV) se->conn.capable |= FUSE_CAP_HANDLE_KILLPRIV; + if (arg->flags & FUSE_CACHE_SYMLINKS) + se->conn.capable |= FUSE_CAP_CACHE_SYMLINKS; if (arg->flags & FUSE_NO_OPENDIR_SUPPORT) se->conn.capable |= FUSE_CAP_NO_OPENDIR_SUPPORT; if (arg->flags & FUSE_EXPLICIT_INVAL_DATA) @@ -2087,6 +2089,8 @@ void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) outarg.flags |= FUSE_WRITEBACK_CACHE; if (se->conn.want & FUSE_CAP_POSIX_ACL) outarg.flags |= FUSE_POSIX_ACL; + if (se->conn.want & FUSE_CAP_CACHE_SYMLINKS) + outarg.flags |= FUSE_CACHE_SYMLINKS; if (se->conn.want & FUSE_CAP_EXPLICIT_INVAL_DATA) outarg.flags |= FUSE_EXPLICIT_INVAL_DATA; outarg.max_readahead = se->conn.max_readahead; -- cgit v1.2.3 From 4ebb018e78b53a8afe0368e7cd7a17a67c52e3df Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Wed, 28 Oct 2020 19:20:35 -0700 Subject: remove old uclibc hack This actually prevents sshfs linking to it as fuse_new becomes unavailable. According to the git history, this seems to predate 2006. Signed-off-by: Rosen Penev --- lib/fuse_misc.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/fuse_misc.h b/lib/fuse_misc.h index a8b5961..f384aea 100644 --- a/lib/fuse_misc.h +++ b/lib/fuse_misc.h @@ -10,10 +10,9 @@ /* Versioned symbols cannot be used in some cases because it - - confuse the dynamic linker in uClibc - not supported on MacOSX (in MachO binary format) */ -#if (!defined(__UCLIBC__) && !defined(__APPLE__)) +#ifndef __APPLE__ # if HAVE_SYMVER_ATTRIBUTE # define FUSE_SYMVER(sym1, sym2) __attribute__ ((symver (sym2))) # else -- cgit v1.2.3 From e032ca7a88afe1a7cd028ca63e2993af9c0b91af Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Wed, 28 Oct 2020 19:25:38 -0700 Subject: remove fuse_mutex_init This seems to have been added before 2006 to fix a uclibc bug. It doesn't seem to be the case anymore so just get rid of it. Signed-off-by: Rosen Penev --- lib/fuse.c | 4 ++-- lib/fuse_loop_mt.c | 4 ++-- lib/fuse_lowlevel.c | 4 ++-- lib/fuse_misc.h | 14 -------------- 4 files changed, 6 insertions(+), 20 deletions(-) (limited to 'lib') diff --git a/lib/fuse.c b/lib/fuse.c index 70299ef..2125cda 100755 --- a/lib/fuse.c +++ b/lib/fuse.c @@ -3390,7 +3390,7 @@ static void fuse_lib_opendir(fuse_req_t req, fuse_ino_t ino, dh->len = 0; dh->filled = 0; dh->nodeid = ino; - fuse_mutex_init(&dh->lock); + pthread_mutex_init(&dh->lock, NULL); llfi->fh = (uintptr_t) dh; @@ -4973,7 +4973,7 @@ struct fuse *fuse_new_31(struct fuse_args *args, if (node_table_init(&f->id_table) == -1) goto out_free_name_table; - fuse_mutex_init(&f->lock); + pthread_mutex_init(&f->lock, NULL); root = alloc_node(f); if (root == NULL) { diff --git a/lib/fuse_loop_mt.c b/lib/fuse_loop_mt.c index 0c6a5b7..71be15d 100644 --- a/lib/fuse_loop_mt.c +++ b/lib/fuse_loop_mt.c @@ -65,7 +65,7 @@ static struct fuse_chan *fuse_chan_new(int fd) memset(ch, 0, sizeof(*ch)); ch->fd = fd; ch->ctr = 1; - fuse_mutex_init(&ch->lock); + pthread_mutex_init(&ch->lock, NULL); return ch; } @@ -321,7 +321,7 @@ int fuse_session_loop_mt_32(struct fuse_session *se, struct fuse_loop_config *co mt.main.thread_id = pthread_self(); mt.main.prev = mt.main.next = &mt.main; sem_init(&mt.finish, 0, 0); - fuse_mutex_init(&mt.lock); + pthread_mutex_init(&mt.lock, NULL); pthread_mutex_lock(&mt.lock); err = fuse_loop_start_thread(&mt); diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c index 83510b3..d227688 100644 --- a/lib/fuse_lowlevel.c +++ b/lib/fuse_lowlevel.c @@ -155,7 +155,7 @@ static struct fuse_req *fuse_ll_alloc_req(struct fuse_session *se) req->se = se; req->ctr = 1; list_init_req(req); - fuse_mutex_init(&req->lock); + pthread_mutex_init(&req->lock, NULL); } return req; @@ -2958,7 +2958,7 @@ struct fuse_session *fuse_session_new(struct fuse_args *args, list_init_req(&se->interrupts); list_init_nreq(&se->notify_list); se->notify_ctr = 1; - fuse_mutex_init(&se->lock); + pthread_mutex_init(&se->lock, NULL); err = pthread_key_create(&se->pipe_key, fuse_ll_pipe_destructor); if (err) { diff --git a/lib/fuse_misc.h b/lib/fuse_misc.h index f384aea..f956ab7 100644 --- a/lib/fuse_misc.h +++ b/lib/fuse_misc.h @@ -22,20 +22,6 @@ #define FUSE_SYMVER(sym1, sym2) #endif -#ifndef USE_UCLIBC -#define fuse_mutex_init(mut) pthread_mutex_init(mut, NULL) -#else -/* Is this hack still needed? */ -static inline void fuse_mutex_init(pthread_mutex_t *mut) -{ - pthread_mutexattr_t attr; - pthread_mutexattr_init(&attr); - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ADAPTIVE_NP); - pthread_mutex_init(mut, &attr); - pthread_mutexattr_destroy(&attr); -} -#endif - #ifdef HAVE_STRUCT_STAT_ST_ATIM /* Linux */ #define ST_ATIM_NSEC(stbuf) ((stbuf)->st_atim.tv_nsec) -- cgit v1.2.3 From d614415a0c4ebf587e690ea209da1436e73fae19 Mon Sep 17 00:00:00 2001 From: Zhiqiang Liu Date: Thu, 5 Nov 2020 16:33:22 +0800 Subject: buffer.c: check whether buf is NULL in fuse_bufvec_advance func In fuse_bufvec_advance func, calling fuse_bufvec_current func may return NULL, so we should check whether buf is NULL before using it. Signed-off-by: Zhiqiang Liu Signed-off-by: Haotian Liu --- lib/buffer.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib') diff --git a/lib/buffer.c b/lib/buffer.c index 5ab9b87..ba07b26 100644 --- a/lib/buffer.c +++ b/lib/buffer.c @@ -266,6 +266,9 @@ static int fuse_bufvec_advance(struct fuse_bufvec *bufv, size_t len) { const struct fuse_buf *buf = fuse_bufvec_current(bufv); + if (!buf) + return 1; + bufv->off += len; assert(bufv->off <= buf->size); if (bufv->off == buf->size) { -- cgit v1.2.3 From f604536b08584bd7c979eed438f0c46ddd1871f0 Mon Sep 17 00:00:00 2001 From: Zhiqiang Liu Date: Wed, 11 Nov 2020 10:00:23 +0800 Subject: buffer.c: correct return value when buf is NULL In commit d614415a ("buffer.c: check whether buf is NULL in fuse_bufvec_advance func"), if fuse_bufvec_current func returns NULL, it returns 1 directly. Actually, we should return 0 when buf is NULL. Fixes: d614415a ("buffer.c: check whether buf is NULL in fuse_bufvec_advance func") Signed-off-by: Zhiqiang Liu Signed-off-by: Haotian Li --- lib/buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/buffer.c b/lib/buffer.c index ba07b26..757807a 100644 --- a/lib/buffer.c +++ b/lib/buffer.c @@ -267,7 +267,7 @@ static int fuse_bufvec_advance(struct fuse_bufvec *bufv, size_t len) const struct fuse_buf *buf = fuse_bufvec_current(bufv); if (!buf) - return 1; + return 0; bufv->off += len; assert(bufv->off <= buf->size); -- cgit v1.2.3 From 42f661ede18fdf0fe74f81b304d1f1d91616570d Mon Sep 17 00:00:00 2001 From: human Date: Mon, 16 Nov 2020 19:11:09 +0200 Subject: fix errno comparison this affected `-o remember` in single-thread mode, it could prematurely exit if a signal was received # start an example filesystem from example/ ./passthrough -f -s -o remember=5 ./mnt # make the poll() call return with EINTR pkill -PIPE passthrough --- lib/fuse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/fuse.c b/lib/fuse.c index 2125cda..a8c5915 100755 --- a/lib/fuse.c +++ b/lib/fuse.c @@ -4533,7 +4533,7 @@ static int fuse_session_loop_remember(struct fuse *f) res = poll(&fds, 1, timeout * 1000); if (res == -1) { - if (errno == -EINTR) + if (errno == EINTR) continue; else break; -- cgit v1.2.3 From d35470382b50aa10e4e81697b23183b50ee45941 Mon Sep 17 00:00:00 2001 From: Laurent Bigonville Date: Sun, 17 Jan 2021 11:49:07 +0100 Subject: Fix FTBFS on kfreebsd (#581) kfreebsd is a FreeBSD kernel and a GNU libc The only macro defined in that case is __FreeBSD_kernel__ Fix #580 --- lib/mount_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/mount_util.c b/lib/mount_util.c index f1d2325..35e9948 100644 --- a/lib/mount_util.c +++ b/lib/mount_util.c @@ -30,7 +30,7 @@ #include #include -#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) +#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__) #define umount2(mnt, flags) unmount(mnt, ((flags) == 2) ? MNT_FORCE : 0) #endif -- cgit v1.2.3 From 5012a05ac875c1988263faaa77177c27c62c52bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A4rtel?= Date: Wed, 3 Feb 2021 11:53:21 +0200 Subject: Fix returning inode numbers from readdir() in offset==0 mode. (#584) - Test added for all passthrough examples. - passthrough.c uses offset==0 mode. The others don't. - passthrough.c changed to set FUSE_FILL_DIR_PLUS to make the test pass. - This fixes #583. --- lib/fuse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/fuse.c b/lib/fuse.c index a8c5915..737456e 100755 --- a/lib/fuse.c +++ b/lib/fuse.c @@ -3566,7 +3566,7 @@ static int fill_dir_plus(void *dh_, const char *name, const struct stat *statp, return 1; } - if (off && statp && (flags & FUSE_FILL_DIR_PLUS)) { + if (statp && (flags & FUSE_FILL_DIR_PLUS)) { e.attr = *statp; if (!is_dot_or_dotdot(name)) { -- cgit v1.2.3 From bdd2d4110fbc6d2059eb699efad2cca4a7eacccb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Thu, 18 Mar 2021 10:52:30 +0100 Subject: Fix returning d_ino and d_type by readdir(3) in non-plus mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When not using the readdir_plus mode, the d_type was not returned, and the use_ino flag was not used for returning d_ino. This patch fixes the returned values for d_ino and d_type by readdir(3) The test for the returned value of d_ino has been adjusted to also take the d_type into consideration and to check the returned values in both basic readdir and readdir_plus modes. This is done by executing the passthrough test twice. Co-authored-by: Jean-Pierre André --- lib/fuse.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib') diff --git a/lib/fuse.c b/lib/fuse.c index 737456e..a95d7c1 100755 --- a/lib/fuse.c +++ b/lib/fuse.c @@ -3578,6 +3578,11 @@ static int fill_dir_plus(void *dh_, const char *name, const struct stat *statp, } } else { e.attr.st_ino = FUSE_UNKNOWN_INO; + if (statp) { + e.attr.st_mode = statp->st_mode; + if (f->conf.use_ino) + e.attr.st_ino = statp->st_ino; + } if (!f->conf.use_ino && f->conf.readdir_ino) { e.attr.st_ino = (ino_t) lookup_nodeid(f, dh->nodeid, name); -- cgit v1.2.3 From 02eb082aea9cfdbf556fe0c89a87f3a8b877f312 Mon Sep 17 00:00:00 2001 From: Hookey Date: Mon, 12 Apr 2021 18:08:50 +0800 Subject: Remove unused fuse_worker bufsize (#590) Not used since https://github.com/libfuse/libfuse/commit/561d7054d856eea6c2d634093546d6af773dada9 --- lib/fuse_loop_mt.c | 1 - 1 file changed, 1 deletion(-) (limited to 'lib') diff --git a/lib/fuse_loop_mt.c b/lib/fuse_loop_mt.c index 71be15d..8fcc46c 100644 --- a/lib/fuse_loop_mt.c +++ b/lib/fuse_loop_mt.c @@ -32,7 +32,6 @@ struct fuse_worker { struct fuse_worker *prev; struct fuse_worker *next; pthread_t thread_id; - size_t bufsize; // We need to include fuse_buf so that we can properly free // it when a thread is terminated by pthread_cancel(). -- cgit v1.2.3 From a1e41676e34096abe21d202f4c4e440fd1257672 Mon Sep 17 00:00:00 2001 From: lixiaokeng Date: Wed, 16 Jun 2021 16:57:16 +0800 Subject: Fix: a potential crash on failure to setlocale setlocale() can fail, returning NULL, which will lead to a crash in iconv_new(). Fix it like in iconv_help(). Signed-off-by: Lixiaokeng --- lib/modules/iconv.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/modules/iconv.c b/lib/modules/iconv.c index 76e2f7d..0ec3c2b 100755 --- a/lib/modules/iconv.c +++ b/lib/modules/iconv.c @@ -672,7 +672,7 @@ static struct fuse_fs *iconv_new(struct fuse_args *args, { struct fuse_fs *fs; struct iconv *ic; - char *old = NULL; + const char *old = NULL; const char *from; const char *to; @@ -694,7 +694,7 @@ static struct fuse_fs *iconv_new(struct fuse_args *args, to = ic->to_code ? ic->to_code : ""; /* FIXME: detect charset equivalence? */ if (!to[0]) - old = strdup(setlocale(LC_CTYPE, "")); + old = setlocale(LC_CTYPE, ""); ic->tofs = iconv_open(from, to); if (ic->tofs == (iconv_t) -1) { fuse_log(FUSE_LOG_ERR, "fuse-iconv: cannot convert from %s to %s\n", @@ -709,7 +709,6 @@ static struct fuse_fs *iconv_new(struct fuse_args *args, } if (old) { setlocale(LC_CTYPE, old); - free(old); old = NULL; } @@ -730,7 +729,6 @@ out_free: free(ic); if (old) { setlocale(LC_CTYPE, old); - free(old); } return NULL; } -- cgit v1.2.3 From 6100b6405469605210613061b4a8b06f87e36de3 Mon Sep 17 00:00:00 2001 From: a1346054 <36859588+a1346054@users.noreply.github.com> Date: Fri, 20 Aug 2021 17:47:43 +0000 Subject: remove executable file mode bit from source files --- lib/fuse.c | 0 lib/modules/iconv.c | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 lib/fuse.c mode change 100755 => 100644 lib/modules/iconv.c (limited to 'lib') diff --git a/lib/fuse.c b/lib/fuse.c old mode 100755 new mode 100644 diff --git a/lib/modules/iconv.c b/lib/modules/iconv.c old mode 100755 new mode 100644 -- cgit v1.2.3