Browse Source

Add more debugging options to makefiles and cleanup

pull/1556/head
Antonio SJ Musumeci 3 weeks ago
parent
commit
d2b225c590
  1. 20
      Makefile
  2. 18
      libfuse/Makefile
  3. 64
      libfuse/include/fuse_common.h
  4. 24
      libfuse/include/fuse_lowlevel.h
  5. 316
      libfuse/lib/buffer.c
  6. 2
      libfuse/lib/crc32b.c
  7. 62
      libfuse/lib/fuse.cpp
  8. 140
      libfuse/lib/fuse_lowlevel.cpp
  9. 9
      libfuse/util/fusermount.c
  10. 1
      src/branches.cpp
  11. 7
      src/branches.hpp
  12. 4
      src/config.cpp
  13. 2
      src/config.hpp
  14. 2
      src/config_pagesize.hpp
  15. 2
      src/fs_copyfile.cpp
  16. 2
      src/fs_glob.cpp
  17. 2
      src/fs_wait_for_mount.cpp
  18. 1
      src/fuse_create.cpp
  19. 1
      src/fuse_open.cpp
  20. 2
      src/fuse_readdir.cpp

20
Makefile

@ -34,6 +34,7 @@ TOUCH ?= touch
BUILDDIR := build
GITHUB_REPO ?= "https://github.com/trapexit/mergerfs"
RELEASE_SAMPLE ?= "debian:13.amd64"
ifndef GIT_REPO
ifneq ($(shell $(GIT) --version 2> /dev/null),)
@ -49,7 +50,22 @@ UGID_USE_RWLOCK ?= 0
ifdef NDEBUG
OPT_FLAGS := -O2 -DNDEBUG
else
OPT_FLAGS := -O0 -g -fno-omit-frame-pointer -DDEBUG
ifdef SANITIZE
ifeq ($(SANITIZE),1)
override SANITIZE := -fsanitize=address,undefined,leak
else
override SANITIZE := -fsanitize=$(SANITIZE)
endif
endif
OPT_FLAGS := -O0 \
-g \
-fno-omit-frame-pointer \
$(SANITIZE) \
-fstack-protector-strong \
-Wextra \
-Werror \
-Wno-unused-parameter \
-DDEBUG
endif
ifdef STATIC
@ -332,7 +348,7 @@ endef
release:
$(call build_release,"all")
release-sample:
$(call build_release,"debian:13.amd64")
$(call build_release,$(RELEASE_SAMPLE))
release-amd64:
$(call build_release,"amd64")
release-arm64:

18
libfuse/Makefile

@ -33,7 +33,22 @@ endif
ifeq ($(NDEBUG),1)
OPT_FLAGS := -O2 -DNDEBUG
else
OPT_FLAGS := -O0 -g -DDEBUG -fno-omit-frame-pointer
ifdef SANITIZE
ifeq ($(SANITIZE),1)
override SANITIZE := -fsanitize=address,undefined,leak
else
override SANITIZE := -fsanitize=$(SANITIZE)
endif
endif
OPT_FLAGS := -O0 \
-g \
-fno-omit-frame-pointer \
$(SANITIZE) \
-fstack-protector-strong \
-Wextra \
-Werror \
-Wno-unused-parameter \
-DDEBUG
endif
ifeq ($(LTO),1)
@ -60,7 +75,6 @@ INSTALLMAN1DIR ?= $(DESTDIR)$(MAN1DIR)
BUILDDIR := build
SRC_C = \
lib/buffer.c \
lib/crc32b.c \
lib/fuse_opt.c \
lib/fuse_session.c \

64
libfuse/include/fuse_common.h

@ -330,70 +330,6 @@ struct fuse_buf {
off_t pos;
};
/**
* Data buffer vector
*
* An array of data buffers, each containing a memory pointer or a
* file descriptor.
*
* Allocate dynamically to add more than one buffer.
*/
struct fuse_bufvec {
/**
* Number of buffers in the array
*/
size_t count;
/**
* Index of current buffer within the array
*/
size_t idx;
/**
* Current offset within the current buffer
*/
size_t off;
/**
* Array of buffers
*/
struct fuse_buf buf[1];
};
/* Initialize bufvec with a single buffer of given size */
#define FUSE_BUFVEC_INIT(size__) \
((struct fuse_bufvec) { \
/* .count= */ 1, \
/* .idx = */ 0, \
/* .off = */ 0, \
/* .buf = */ { /* [0] = */ { \
/* .size = */ (size__), \
/* .flags = */ (enum fuse_buf_flags) 0, \
/* .mem = */ NULL, \
/* .fd = */ -1, \
/* .pos = */ 0, \
} } \
} )
/**
* Get total size of data in a fuse buffer vector
*
* @param bufv buffer vector
* @return size of data
*/
size_t fuse_buf_size(const struct fuse_bufvec *bufv);
/**
* Copy data from one buffer vector to another
*
* @param dst destination buffer vector
* @param src source buffer vector
* @param flags flags controlling the copy
* @return actual number of bytes copied or -errno on error
*/
ssize_t fuse_buf_copy(struct fuse_bufvec *dst, struct fuse_bufvec *src,
enum fuse_buf_copy_flags flags);
/* ----------------------------------------------------------- *
* Signal handling *
* ----------------------------------------------------------- */

24
libfuse/include/fuse_lowlevel.h

@ -472,30 +472,6 @@ int fuse_lowlevel_notify_delete(struct fuse_chan *ch,
uint64_t parent, uint64_t child,
const char *name, size_t namelen);
/**
* Store data to the kernel buffers
*
* Synchronously store data in the kernel buffers belonging to the
* given inode. The stored data is marked up-to-date (no read will be
* performed against it, unless it's invalidated or evicted from the
* cache).
*
* If the stored data overflows the current file size, then the size
* is extended, similarly to a write(2) on the filesystem.
*
* If this function returns an error, then the store wasn't fully
* completed, but it may have been partially completed.
*
* @param ch the channel through which to send the invalidation
* @param ino the inode number
* @param offset the starting offset into the file to store to
* @param bufv buffer vector
* @param flags flags controlling the copy
* @return zero for success, -errno for failure
*/
int fuse_lowlevel_notify_store(struct fuse_chan *ch, uint64_t ino,
off_t offset, struct fuse_bufvec *bufv,
enum fuse_buf_copy_flags flags);
/**
* Retrieve data from the kernel buffers
*

316
libfuse/lib/buffer.c

@ -1,316 +0,0 @@
/*
FUSE: Filesystem in Userspace
Copyright (C) 2010 Miklos Szeredi <miklos@szeredi.hu>
This program can be distributed under the terms of the GNU LGPLv2.
See the file COPYING.LIB
*/
#define _GNU_SOURCE
#include "fuse_i.h"
#include "fuse_lowlevel.h"
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <assert.h>
size_t fuse_buf_size(const struct fuse_bufvec *bufv)
{
size_t i;
size_t size = 0;
for (i = 0; i < bufv->count; i++) {
if (bufv->buf[i].size == SIZE_MAX)
size = SIZE_MAX;
else
size += bufv->buf[i].size;
}
return size;
}
static size_t min_size(size_t s1, size_t s2)
{
return s1 < s2 ? s1 : s2;
}
static ssize_t fuse_buf_write(const struct fuse_buf *dst, size_t dst_off,
const struct fuse_buf *src, size_t src_off,
size_t len)
{
ssize_t res = 0;
size_t copied = 0;
while (len) {
if (dst->flags & FUSE_BUF_FD_SEEK) {
res = pwrite(dst->fd, src->mem + src_off, len,
dst->pos + dst_off);
} else {
res = write(dst->fd, src->mem + src_off, len);
}
if (res == -1) {
if (!copied)
return -errno;
break;
}
if (res == 0)
break;
copied += res;
if (!(dst->flags & FUSE_BUF_FD_RETRY))
break;
src_off += res;
dst_off += res;
len -= res;
}
return copied;
}
static ssize_t fuse_buf_read(const struct fuse_buf *dst, size_t dst_off,
const struct fuse_buf *src, size_t src_off,
size_t len)
{
ssize_t res = 0;
size_t copied = 0;
while (len) {
if (src->flags & FUSE_BUF_FD_SEEK) {
res = pread(src->fd, dst->mem + dst_off, len,
src->pos + src_off);
} else {
res = read(src->fd, dst->mem + dst_off, len);
}
if (res == -1) {
if (!copied)
return -errno;
break;
}
if (res == 0)
break;
copied += res;
if (!(src->flags & FUSE_BUF_FD_RETRY))
break;
dst_off += res;
src_off += res;
len -= res;
}
return copied;
}
static ssize_t fuse_buf_fd_to_fd(const struct fuse_buf *dst, size_t dst_off,
const struct fuse_buf *src, size_t src_off,
size_t len)
{
char buf[4096];
struct fuse_buf tmp = {
.size = sizeof(buf),
.flags = 0,
};
ssize_t res;
size_t copied = 0;
tmp.mem = buf;
while (len) {
size_t this_len = min_size(tmp.size, len);
size_t read_len;
res = fuse_buf_read(&tmp, 0, src, src_off, this_len);
if (res < 0) {
if (!copied)
return res;
break;
}
if (res == 0)
break;
read_len = res;
res = fuse_buf_write(dst, dst_off, &tmp, 0, read_len);
if (res < 0) {
if (!copied)
return res;
break;
}
if (res == 0)
break;
copied += res;
if (res < this_len)
break;
dst_off += res;
src_off += res;
len -= res;
}
return copied;
}
#ifdef HAVE_SPLICE
static ssize_t fuse_buf_splice(const struct fuse_buf *dst, size_t dst_off,
const struct fuse_buf *src, size_t src_off,
size_t len, enum fuse_buf_copy_flags flags)
{
int splice_flags = 0;
off_t *srcpos = NULL;
off_t *dstpos = NULL;
off_t srcpos_val;
off_t dstpos_val;
ssize_t res;
size_t copied = 0;
if (flags & FUSE_BUF_SPLICE_MOVE)
splice_flags |= SPLICE_F_MOVE;
if (flags & FUSE_BUF_SPLICE_NONBLOCK)
splice_flags |= SPLICE_F_NONBLOCK;
if (src->flags & FUSE_BUF_FD_SEEK) {
srcpos_val = src->pos + src_off;
srcpos = &srcpos_val;
}
if (dst->flags & FUSE_BUF_FD_SEEK) {
dstpos_val = dst->pos + dst_off;
dstpos = &dstpos_val;
}
while (len) {
res = splice(src->fd, srcpos, dst->fd, dstpos, len, splice_flags);
if (res == -1) {
if (copied)
break;
if (errno != EINVAL || (flags & FUSE_BUF_FORCE_SPLICE))
return -errno;
/* Maybe splice is not supported for this combination */
return fuse_buf_fd_to_fd(dst, dst_off, src, src_off,
len);
}
if (res == 0)
break;
copied += res;
if (!(src->flags & FUSE_BUF_FD_RETRY) &&
!(dst->flags & FUSE_BUF_FD_RETRY)) {
break;
}
len -= res;
}
return copied;
}
#else
static ssize_t fuse_buf_splice(const struct fuse_buf *dst, size_t dst_off,
const struct fuse_buf *src, size_t src_off,
size_t len, enum fuse_buf_copy_flags flags)
{
(void) flags;
return fuse_buf_fd_to_fd(dst, dst_off, src, src_off, len);
}
#endif
static ssize_t fuse_buf_copy_one(const struct fuse_buf *dst, size_t dst_off,
const struct fuse_buf *src, size_t src_off,
size_t len, enum fuse_buf_copy_flags flags)
{
int src_is_fd = src->flags & FUSE_BUF_IS_FD;
int dst_is_fd = dst->flags & FUSE_BUF_IS_FD;
if (!src_is_fd && !dst_is_fd) {
char *dstmem = dst->mem + dst_off;
char *srcmem = src->mem + src_off;
if (dstmem != srcmem) {
if (dstmem + len <= srcmem || srcmem + len <= dstmem)
memcpy(dstmem, srcmem, len);
else
memmove(dstmem, srcmem, len);
}
return len;
} else if (!src_is_fd) {
return fuse_buf_write(dst, dst_off, src, src_off, len);
} else if (!dst_is_fd) {
return fuse_buf_read(dst, dst_off, src, src_off, len);
} else if (flags & FUSE_BUF_NO_SPLICE) {
return fuse_buf_fd_to_fd(dst, dst_off, src, src_off, len);
} else {
return fuse_buf_splice(dst, dst_off, src, src_off, len, flags);
}
}
static const struct fuse_buf *fuse_bufvec_current(struct fuse_bufvec *bufv)
{
if (bufv->idx < bufv->count)
return &bufv->buf[bufv->idx];
else
return NULL;
}
static int fuse_bufvec_advance(struct fuse_bufvec *bufv, size_t len)
{
const struct fuse_buf *buf = fuse_bufvec_current(bufv);
bufv->off += len;
assert(bufv->off <= buf->size);
if (bufv->off == buf->size) {
assert(bufv->idx < bufv->count);
bufv->idx++;
if (bufv->idx == bufv->count)
return 0;
bufv->off = 0;
}
return 1;
}
ssize_t fuse_buf_copy(struct fuse_bufvec *dstv, struct fuse_bufvec *srcv,
enum fuse_buf_copy_flags flags)
{
size_t copied = 0;
if (dstv == srcv)
return fuse_buf_size(dstv);
for (;;) {
const struct fuse_buf *src = fuse_bufvec_current(srcv);
const struct fuse_buf *dst = fuse_bufvec_current(dstv);
size_t src_len;
size_t dst_len;
size_t len;
ssize_t res;
if (src == NULL || dst == NULL)
break;
src_len = src->size - srcv->off;
dst_len = dst->size - dstv->off;
len = min_size(src_len, dst_len);
res = fuse_buf_copy_one(dst, dstv->off, src, srcv->off, len, flags);
if (res < 0) {
if (!copied)
return res;
break;
}
copied += res;
if (!fuse_bufvec_advance(srcv, res) ||
!fuse_bufvec_advance(dstv, res))
break;
if (res < len)
break;
}
return copied;
}

2
libfuse/lib/crc32b.c

@ -78,8 +78,8 @@ crc32b_continue(const void *buf_,
const crc32b_t len_,
const crc32b_t crc_)
{
int i;
char *buf;
crc32b_t i;
crc32b_t crc;
crc = crc_;

62
libfuse/lib/fuse.cpp

@ -152,7 +152,7 @@ struct fuse_dh
fuse_dirents_t d;
};
static struct fuse f = {0};
static struct fuse f = {};
/*
Why was the nodeid:generation logic simplified?
@ -1020,7 +1020,7 @@ get_path_common(uint64_t nodeid,
err = try_get_path(nodeid,name,path,wnode,true);
if(err == -EAGAIN)
{
struct lock_queue_element qe = {0};
struct lock_queue_element qe = {};
qe.nodeid1 = nodeid;
qe.name1 = name;
@ -1079,7 +1079,7 @@ get_path2(uint64_t nodeid1,
path1,path2,wnode1,wnode2);
if(err == -EAGAIN)
{
struct lock_queue_element qe = {0};
struct lock_queue_element qe = {};
qe.nodeid1 = nodeid1;
qe.name1 = name1;
@ -1157,7 +1157,7 @@ forget_node(const uint64_t nodeid,
*/
while(node->nlookup == nlookup && node->treelock)
{
struct lock_queue_element qe = {0};
struct lock_queue_element qe = {};
qe.nodeid1 = nodeid;
@ -1389,7 +1389,7 @@ fuse_lib_lookup(fuse_req_t *req_,
char *fusepath;
const char *name;
node_t *dot = NULL;
struct fuse_entry_param e = {0};
struct fuse_entry_param e = {};
name = (const char*)fuse_hdr_arg(hdr_);
nodeid = hdr_->nodeid;
@ -1622,7 +1622,7 @@ fuse_lib_setattr(fuse_req_t *req_,
struct fuse_in_header *hdr_)
{
uint64_t fh;
struct stat stbuf = {0};
struct stat stbuf = {};
char *fusepath;
int err;
fuse_timeouts_t timeout;
@ -1927,7 +1927,7 @@ fuse_lib_symlink(fuse_req_t *req_,
char *fusepath;
const char *name;
const char *linkname;
struct fuse_entry_param e = {0};
struct fuse_entry_param e = {};
name = (const char*)fuse_hdr_arg(hdr_);
linkname = (name + strlen(name) + 1);
@ -2017,7 +2017,7 @@ fuse_lib_link(fuse_req_t *req_,
char *newpath;
const char *newname;
struct fuse_link_in *arg;
struct fuse_entry_param e = {0};
struct fuse_entry_param e = {};
arg = (fuse_link_in*)fuse_hdr_arg(hdr_);
newname = (const char*)PARAM(arg);
@ -2074,7 +2074,7 @@ fuse_lib_create(fuse_req_t *req_,
char *fusepath;
const char *name;
uint64_t new_nodeid;
fuse_file_info_t ffi = {0};
fuse_file_info_t ffi = {};
struct fuse_entry_param e;
struct fuse_create_in *arg;
@ -2188,7 +2188,7 @@ fuse_lib_open(fuse_req_t *req_,
{
int err;
char *fusepath;
fuse_file_info_t ffi = {0};
fuse_file_info_t ffi = {};
struct fuse_open_in *arg;
arg = (fuse_open_in*)fuse_hdr_arg(hdr_);
@ -2231,7 +2231,7 @@ fuse_lib_read(fuse_req_t *req_,
struct fuse_in_header *hdr_)
{
int res;
fuse_file_info_t ffi = {0};
fuse_file_info_t ffi = {};
struct fuse_read_in *arg;
fuse_msgbuf_t *msgbuf;
@ -2266,7 +2266,7 @@ fuse_lib_write(fuse_req_t *req_,
{
int res;
char *data;
fuse_file_info_t ffi = {0};
fuse_file_info_t ffi = {};
struct fuse_write_in *arg;
arg = (fuse_write_in*)fuse_hdr_arg(hdr_);
@ -2335,8 +2335,8 @@ fuse_lib_opendir(fuse_req_t *req_,
int err;
char *fusepath;
struct fuse_dh *dh;
fuse_file_info_t llffi = {0};
fuse_file_info_t ffi = {0};
fuse_file_info_t llffi = {};
fuse_file_info_t ffi = {};
struct fuse_open_in *arg;
arg = (fuse_open_in*)fuse_hdr_arg(hdr_);
@ -2422,8 +2422,8 @@ fuse_lib_readdir(fuse_req_t *req_,
size_t size;
fuse_dirents_t *d;
struct fuse_dh *dh;
fuse_file_info_t ffi = {0};
fuse_file_info_t llffi = {0};
fuse_file_info_t ffi = {};
fuse_file_info_t llffi = {};
struct fuse_read_in *arg;
arg = (fuse_read_in*)fuse_hdr_arg(hdr_);
@ -2466,8 +2466,8 @@ fuse_lib_readdir_plus(fuse_req_t *req_,
size_t size;
fuse_dirents_t *d;
struct fuse_dh *dh;
fuse_file_info_t ffi = {0};
fuse_file_info_t llffi = {0};
fuse_file_info_t ffi = {};
fuse_file_info_t llffi = {};
struct fuse_read_in *arg;
arg = (fuse_read_in*)fuse_hdr_arg(hdr_);
@ -2508,7 +2508,7 @@ fuse_lib_releasedir(fuse_req_t *req_,
{
struct fuse_dh *dh;
fuse_file_info_t ffi;
fuse_file_info_t llffi = {0};
fuse_file_info_t llffi = {};
struct fuse_release_in *arg;
arg = (fuse_release_in*)fuse_hdr_arg(hdr_);
@ -2537,7 +2537,7 @@ fuse_lib_fsyncdir(fuse_req_t *req_,
int err;
int is_datasync;
fuse_file_info_t ffi;
fuse_file_info_t llffi = {0};
fuse_file_info_t llffi = {};
struct fuse_fsync_in *arg;
arg = (fuse_fsync_in*)fuse_hdr_arg(hdr_);
@ -2560,7 +2560,7 @@ fuse_lib_statfs(fuse_req_t *req_,
{
int err = 0;
char *fusepath;
struct statvfs buf = {0};
struct statvfs buf = {};
fusepath = NULL;
if(hdr_->nodeid)
@ -2767,8 +2767,8 @@ fuse_lib_copy_file_range(fuse_req_t *req_,
const struct fuse_in_header *hdr_)
{
ssize_t rv;
fuse_file_info_t ffi_in = {0};
fuse_file_info_t ffi_out = {0};
fuse_file_info_t ffi_in = {};
fuse_file_info_t ffi_out = {};
const struct fuse_copy_file_range_in *arg;
arg = (fuse_copy_file_range_in*)fuse_hdr_arg(hdr_);
@ -2825,7 +2825,7 @@ fuse_lib_tmpfile(fuse_req_t *req_,
int err;
char *fusepath;
const char *name;
fuse_file_info_t ffi = {0};
fuse_file_info_t ffi = {};
struct fuse_entry_param e;
struct fuse_create_in *arg;
@ -3072,7 +3072,7 @@ fuse_lib_release(fuse_req_t *req_,
struct fuse_in_header *hdr_)
{
int err = 0;
fuse_file_info_t ffi = {0};
fuse_file_info_t ffi = {};
struct fuse_release_in *arg;
arg = (fuse_release_in*)fuse_hdr_arg(hdr_);
@ -3109,7 +3109,7 @@ fuse_lib_flush(fuse_req_t *req_,
struct fuse_in_header *hdr_)
{
int err;
fuse_file_info_t ffi = {0};
fuse_file_info_t ffi = {};
struct fuse_flush_in *arg;
arg = (fuse_flush_in*)fuse_hdr_arg(hdr_);
@ -3167,7 +3167,7 @@ fuse_lib_getlk(fuse_req_t *req_,
lock_t lk;
struct flock flk;
lock_t *conflict;
fuse_file_info_t ffi = {0};
fuse_file_info_t ffi = {};
const struct fuse_lk_in *arg;
arg = (fuse_lk_in*)fuse_hdr_arg(hdr_);
@ -3270,7 +3270,7 @@ fuse_lib_ioctl(fuse_req_t *req_,
int err;
char *out_buf = NULL;
fuse_file_info_t ffi;
fuse_file_info_t llffi = {0};
fuse_file_info_t llffi = {};
const void *in_buf;
uint32_t out_size;
const struct fuse_ioctl_in *arg;
@ -3339,7 +3339,7 @@ fuse_lib_poll(fuse_req_t *req_,
{
int err;
unsigned revents = 0;
fuse_file_info_t ffi = {0};
fuse_file_info_t ffi = {};
fuse_pollhandle_t *ph = NULL;
const struct fuse_poll_in *arg;
@ -3428,7 +3428,7 @@ fuse_prune_some_remembered_nodes(int *offset_)
pruned = 0;
checked = 0;
now = current_time();
while(*offset_ < kv_size(f.remembered_nodes))
while(*offset_ < (int)kv_size(f.remembered_nodes))
{
time_t age;
remembered_node_t *fn = &kv_A(f.remembered_nodes,*offset_);
@ -3913,7 +3913,7 @@ fuse_passthrough_open(const int fd_)
{
int rv;
int dev_fuse_fd;
struct fuse_backing_map bm = {0};
struct fuse_backing_map bm = {};
dev_fuse_fd = fuse_chan_fd(f.se->ch);
bm.fd = fd_;

140
libfuse/lib/fuse_lowlevel.cpp

@ -292,7 +292,7 @@ int
fuse_reply_entry(fuse_req_t *req,
const struct fuse_entry_param *e)
{
struct fuse_entry_out arg = {0};
struct fuse_entry_out arg = {};
size_t size = req->f->conn.proto_minor < 9 ?
FUSE_COMPAT_ENTRY_OUT_SIZE : sizeof(arg);
@ -322,7 +322,7 @@ fuse_reply_create(fuse_req_t *req,
const struct fuse_entry_param *e,
const fuse_file_info_t *f)
{
struct fuse_create_out buf = {0};
struct fuse_create_out buf = {};
size_t entrysize = req->f->conn.proto_minor < 9 ?
FUSE_COMPAT_ENTRY_OUT_SIZE : sizeof(struct fuse_entry_out);
struct fuse_entry_out *earg = (struct fuse_entry_out*)&buf.e;
@ -339,7 +339,7 @@ fuse_reply_attr(fuse_req_t *req,
const struct stat *attr,
const uint64_t timeout)
{
struct fuse_attr_out arg = {0};
struct fuse_attr_out arg = {};
size_t size = req->f->conn.proto_minor < 9 ?
FUSE_COMPAT_ATTR_OUT_SIZE : sizeof(arg);
@ -377,7 +377,7 @@ int
fuse_reply_open(fuse_req_t *req,
const fuse_file_info_t *f)
{
struct fuse_open_out arg = {0};
struct fuse_open_out arg = {};
fill_open(&arg, f);
@ -388,7 +388,7 @@ int
fuse_reply_write(fuse_req_t *req,
size_t count)
{
struct fuse_write_out arg = {0};
struct fuse_write_out arg = {};
arg.size = count;
@ -403,55 +403,6 @@ fuse_reply_buf(fuse_req_t *req,
return send_reply_ok(req, buf, size);
}
static
int
fuse_send_data_iov_fallback(struct fuse_ll *f,
struct fuse_chan *ch,
struct iovec *iov,
int iov_count,
struct fuse_bufvec *buf,
size_t len)
{
int res;
struct fuse_bufvec mem_buf = FUSE_BUFVEC_INIT(len);
/* Optimize common case */
if(buf->count == 1 && buf->idx == 0 && buf->off == 0 &&
!(buf->buf[0].flags & FUSE_BUF_IS_FD))
{
/* FIXME: also avoid memory copy if there are multiple buffers
but none of them contain an fd */
iov[iov_count].iov_base = buf->buf[0].mem;
iov[iov_count].iov_len = len;
iov_count++;
return fuse_send_msg(f, ch, iov, iov_count);
}
fuse_msgbuf_t *msgbuf;
msgbuf = msgbuf_alloc();
if(msgbuf == NULL)
return -ENOMEM;
mem_buf.buf[0].mem = msgbuf->mem;
res = fuse_buf_copy(&mem_buf, buf, (fuse_buf_copy_flags)0);
if(res < 0)
{
msgbuf_free(msgbuf);
return -res;
}
len = res;
iov[iov_count].iov_base = msgbuf->mem;
iov[iov_count].iov_len = len;
iov_count++;
res = fuse_send_msg(f, ch, iov, iov_count);
msgbuf_free(msgbuf);
return res;
}
struct fuse_ll_pipe
{
size_t size;
@ -468,21 +419,6 @@ fuse_ll_pipe_free(struct fuse_ll_pipe *llp)
free(llp);
}
static
int
fuse_send_data_iov(struct fuse_ll *f,
struct fuse_chan *ch,
struct iovec *iov,
int iov_count,
struct fuse_bufvec *buf,
unsigned int flags)
{
size_t len = fuse_buf_size(buf);
(void) flags;
return fuse_send_data_iov_fallback(f, ch, iov, iov_count, buf, len);
}
int
fuse_reply_data(fuse_req_t *req,
char *buf_,
@ -516,7 +452,7 @@ int
fuse_reply_statfs(fuse_req_t *req,
const struct statvfs *stbuf)
{
struct fuse_statfs_out arg = {0};
struct fuse_statfs_out arg = {};
size_t size = req->f->conn.proto_minor < 4 ?
FUSE_COMPAT_STATFS_SIZE : sizeof(arg);
@ -529,7 +465,7 @@ int
fuse_reply_xattr(fuse_req_t *req,
size_t count)
{
struct fuse_getxattr_out arg = {0};
struct fuse_getxattr_out arg = {};
arg.size = count;
@ -540,7 +476,7 @@ int
fuse_reply_lock(fuse_req_t *req,
const struct flock *lock)
{
struct fuse_lk_out arg = {0};
struct fuse_lk_out arg = {};
arg.lk.type = lock->l_type;
if(lock->l_type != F_UNLCK)
@ -560,7 +496,7 @@ int
fuse_reply_bmap(fuse_req_t *req,
uint64_t idx)
{
struct fuse_bmap_out arg = {0};
struct fuse_bmap_out arg = {};
arg.block = idx;
@ -595,7 +531,7 @@ fuse_reply_ioctl_retry(fuse_req_t *req,
const struct iovec *out_iov,
size_t out_count)
{
struct fuse_ioctl_out arg = {0};
struct fuse_ioctl_out arg = {};
struct fuse_ioctl_iovec *in_fiov = NULL;
struct fuse_ioctl_iovec *out_fiov = NULL;
struct iovec iov[4];
@ -705,7 +641,7 @@ fuse_reply_ioctl_iov(fuse_req_t *req,
int count)
{
struct iovec *padded_iov;
struct fuse_ioctl_out arg = {0};
struct fuse_ioctl_out arg = {};
int res;
padded_iov = (iovec*)malloc((count + 2) * sizeof(struct iovec));
@ -728,7 +664,7 @@ int
fuse_reply_poll(fuse_req_t *req,
unsigned revents)
{
struct fuse_poll_out arg = {0};
struct fuse_poll_out arg = {};
arg.revents = revents;
@ -1015,7 +951,7 @@ do_setlk_common(fuse_req_t *req,
int sleep)
{
struct flock flock;
fuse_file_info_t fi = {0};
fuse_file_info_t fi = {};
struct fuse_lk_in *arg = (struct fuse_lk_in*)inarg;
fi.fh = arg->fh;
@ -1118,7 +1054,7 @@ void
do_init(fuse_req_t *req,
struct fuse_in_header *hdr_)
{
struct fuse_init_out outarg = {0};
struct fuse_init_out outarg = {};
struct fuse_init_in *arg = (struct fuse_init_in *)&hdr_[1];
struct fuse_ll *f = req->f;
size_t bufsize;
@ -1604,50 +1540,6 @@ fuse_lowlevel_notify_delete(struct fuse_chan *ch,
return send_notify_iov(f, ch, FUSE_NOTIFY_DELETE, iov, 3);
}
int
fuse_lowlevel_notify_store(struct fuse_chan *ch,
uint64_t ino,
off_t offset,
struct fuse_bufvec *bufv,
enum fuse_buf_copy_flags flags)
{
struct fuse_out_header out;
struct fuse_notify_store_out outarg;
struct fuse_ll *f;
struct iovec iov[3];
size_t size = fuse_buf_size(bufv);
int res;
if(!ch)
return -EINVAL;
f = (struct fuse_ll*)fuse_session_data(fuse_chan_session(ch));
if(!f)
return -ENODEV;
if(f->conn.proto_minor < 15)
return -ENOSYS;
out.unique = 0;
out.error = FUSE_NOTIFY_STORE;
outarg.nodeid = ino;
outarg.offset = offset;
outarg.size = size;
outarg.padding = 0;
iov[0].iov_base = &out;
iov[0].iov_len = sizeof(out);
iov[1].iov_base = &outarg;
iov[1].iov_len = sizeof(outarg);
res = fuse_send_data_iov(f, ch, iov, 2, bufv, flags);
if(res > 0)
res = -res;
return res;
}
struct fuse_retrieve_req
{
struct fuse_notify_req nreq;
@ -1825,8 +1717,8 @@ fuse_send_errno(struct fuse_ll *f_,
const int errno_,
const uint64_t unique_id_)
{
struct fuse_out_header out = {0};
struct iovec iov = {0};
struct fuse_out_header out = {};
struct iovec iov = {};
out.unique = unique_id_;
out.error = -errno_;

9
libfuse/util/fusermount.c

@ -701,10 +701,13 @@ static int opt_eq(const char *s, unsigned len, const char *opt)
return 0;
}
static int get_string_opt(const char *s, unsigned len, const char *opt,
static
int
get_string_opt(const char *s,
unsigned len,
const char *opt,
char **val)
{
int i;
unsigned opt_len = strlen(opt);
char *d;
@ -719,7 +722,7 @@ static int get_string_opt(const char *s, unsigned len, const char *opt,
d = *val;
s += opt_len;
len -= opt_len;
for (i = 0; i < len; i++) {
for (unsigned i = 0; i < len; i++) {
if (s[i] == '\\' && i + 1 < len)
i++;
*d++ = s[i];

1
src/branches.cpp

@ -154,6 +154,7 @@ namespace l
rv = l::parse_minfreespace(v[1],minfreespace_);
if(rv < 0)
return rv;
[[fallthrough]];
case 1:
rv = l::parse_mode(v[0],mode_);
if(rv < 0)

7
src/branches.hpp

@ -63,13 +63,16 @@ public:
public:
using Ptr = Branches::Impl::Ptr;
public:
u64 minfreespace;
private:
mutable std::mutex _mutex;
Ptr _impl;
public:
Branches(const u64 &default_minfreespace_)
: _impl(std::make_shared<Impl>(default_minfreespace_))
Branches()
: _impl(std::make_shared<Impl>(minfreespace))
{}
public:

4
src/config.cpp

@ -81,7 +81,7 @@ Config::Config()
:
allow_idmap(false),
async_read(true),
branches(minfreespace),
branches(),
branches_mount_timeout(0),
branches_mount_timeout_fail(false),
cache_attr(1),
@ -118,7 +118,7 @@ Config::Config()
link_exdev(LinkEXDEV::ENUM::PASSTHROUGH),
log_metrics(false),
max_background(fuse_cfg.max_background,0),
minfreespace(MINFREESPACE_DEFAULT),
minfreespace(branches.minfreespace,MINFREESPACE_DEFAULT),
mountpoint(),
_mount(mountpoint),
_mountpoint(mountpoint),

2
src/config.hpp

@ -148,7 +148,7 @@ public:
LinkEXDEV link_exdev;
LogMetrics log_metrics;
TFSRef<int> max_background;
ConfigUINT64 minfreespace;
TFSRef<u64> minfreespace;
fs::path mountpoint;
TFSRef<fs::path> _mount;
TFSRef<fs::path> _mountpoint;

2
src/config_pagesize.hpp

@ -44,7 +44,7 @@ public:
return *this;
}
operator const uint64_t() const
operator uint64_t() const
{
return _v;
}

2
src/fs_copyfile.cpp

@ -103,7 +103,7 @@ fs::copyfile(const int src_fd_,
{
s64 rv;
int dst_fd;
struct stat src_st = {0};
struct stat src_st = {};
std::string dst_tmppath;
struct sigaction old_act;
struct sigaction new_act;

2
src/fs_glob.cpp

@ -38,7 +38,7 @@ fs::glob(const string &pattern_,
vector<string> *strs_)
{
int flags;
glob_t gbuf = {0};
glob_t gbuf = {};
flags = (GLOB_BRACE|GLOB_ONLYDIR);
::glob(pattern_.c_str(),flags,NULL,&gbuf);

2
src/fs_wait_for_mount.cpp

@ -146,7 +146,7 @@ fs::wait_for_mount(const fs::path &src_path_,
const std::chrono::milliseconds &timeout_)
{
int rv;
struct stat src_st = {0};
struct stat src_st = {};
rv = fs::stat(src_path_,&src_st);
if(rv < 0)

1
src/fuse_create.cpp

@ -208,7 +208,6 @@ _create(const Policy::Search &searchFunc_,
}
constexpr
const
uint64_t
_(const PassthroughIOEnum e_,
const uint64_t m_)

1
src/fuse_open.cpp

@ -265,7 +265,6 @@ _open(const Policy::Search &searchFunc_,
}
constexpr
const
uint64_t
_(const PassthroughIOEnum e_,
const uint64_t m_)

2
src/fuse_readdir.cpp

@ -86,7 +86,7 @@ _handle_ENOENT(const fuse_file_info_t *ffi_,
if(!di->fusepath.empty())
return -ENOENT;
de = {0};
de = {};
de.d_ino = 0;
de.d_off = 0;

Loading…
Cancel
Save