mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-10-26 19:01:56 -04:00
Misc cleanup for FreeBSD and clang (#1560)
This commit is contained in:
parent
2412ae7316
commit
41b65ae9e8
9 changed files with 25 additions and 64 deletions
|
|
@ -177,48 +177,6 @@ fuse_hdr_arg(const struct fuse_in_header *hdr_)
|
||||||
return (void*)&hdr_[1];
|
return (void*)&hdr_[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
list_add(struct list_head *new_,
|
|
||||||
struct list_head *prev_,
|
|
||||||
struct list_head *next_)
|
|
||||||
{
|
|
||||||
next_->prev = new_;
|
|
||||||
new_->next = next_;
|
|
||||||
new_->prev = prev_;
|
|
||||||
prev_->next = new_;
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
|
||||||
inline
|
|
||||||
void
|
|
||||||
list_add_head(struct list_head *new_,
|
|
||||||
struct list_head *head_)
|
|
||||||
{
|
|
||||||
list_add(new_,head_,head_->next);
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
|
||||||
inline
|
|
||||||
void
|
|
||||||
list_add_tail(struct list_head *new_,
|
|
||||||
struct list_head *head_)
|
|
||||||
{
|
|
||||||
list_add(new_,head_->prev,head_);
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
|
||||||
inline
|
|
||||||
void
|
|
||||||
list_del(struct list_head *entry)
|
|
||||||
{
|
|
||||||
struct list_head *prev = entry->prev;
|
|
||||||
struct list_head *next = entry->next;
|
|
||||||
|
|
||||||
next->prev = prev;
|
|
||||||
prev->next = next;
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
static
|
||||||
size_t
|
size_t
|
||||||
id_hash(uint64_t ino)
|
id_hash(uint64_t ino)
|
||||||
|
|
|
||||||
|
|
@ -282,7 +282,7 @@ fuse_setup_common(int argc,
|
||||||
if (res == -1)
|
if (res == -1)
|
||||||
goto err_unmount;
|
goto err_unmount;
|
||||||
|
|
||||||
res = fuse_set_signal_handlers(fuse_get_session(fuse));
|
res = fuse_set_signal_handlers(fuse_get_session());
|
||||||
if (res == -1)
|
if (res == -1)
|
||||||
goto err_unmount;
|
goto err_unmount;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -184,13 +184,16 @@ void fuse_kern_unmount(const char *mountpoint, int fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if kernel is doing init in background */
|
/* Check if kernel is doing init in background */
|
||||||
static int init_backgrounded(void)
|
static
|
||||||
|
int
|
||||||
|
init_backgrounded(void)
|
||||||
{
|
{
|
||||||
unsigned ibg, len;
|
unsigned ibg;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
len = sizeof(ibg);
|
len = sizeof(ibg);
|
||||||
|
|
||||||
if (sysctlbyname("vfs.fuse.init_backgrounded", &ibg, &len, NULL, 0))
|
if(sysctlbyname("vfs.fuse.init_backgrounded", &ibg, &len, NULL, 0))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return ibg;
|
return ibg;
|
||||||
|
|
@ -298,10 +301,12 @@ static int fuse_mount_core(const char *mountpoint, const char *opts)
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fuse_kern_mount(const char *mountpoint, struct fuse_args *args)
|
int
|
||||||
|
fuse_kern_mount(const char *mountpoint,
|
||||||
|
struct fuse_args *args)
|
||||||
{
|
{
|
||||||
struct mount_opts mo;
|
|
||||||
int res = -1;
|
int res = -1;
|
||||||
|
struct mount_opts mo;
|
||||||
|
|
||||||
memset(&mo, 0, sizeof(mo));
|
memset(&mo, 0, sizeof(mo));
|
||||||
/* mount util should not try to spawn the daemon */
|
/* mount util should not try to spawn the daemon */
|
||||||
|
|
@ -317,7 +322,6 @@ int fuse_kern_mount(const char *mountpoint, struct fuse_args *args)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
res = fuse_mount_core(mountpoint, mo.kernel_opts);
|
res = fuse_mount_core(mountpoint, mo.kernel_opts);
|
||||||
out:
|
|
||||||
free(mo.kernel_opts);
|
free(mo.kernel_opts);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/poll.h>
|
#include <poll.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,9 @@ public:
|
||||||
Branch(const Branch&);
|
Branch(const Branch&);
|
||||||
Branch(const u64 &default_minfreespace);
|
Branch(const u64 &default_minfreespace);
|
||||||
|
|
||||||
|
public:
|
||||||
|
Branch& operator=(const Branch&) = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool ro(void) const;
|
bool ro(void) const;
|
||||||
bool nc(void) const;
|
bool nc(void) const;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
# include <sys/syscall.h>
|
# include <sys/syscall.h>
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#else
|
#else
|
||||||
#warning "ioprio not supported on this platform"
|
#pragma message "ioprio not supported on this platform"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
|
|
||||||
|
|
@ -20,17 +20,6 @@
|
||||||
static int g_PROCFS_DIR_FD = -1;
|
static int g_PROCFS_DIR_FD = -1;
|
||||||
namespace procfs { int PROC_SELF_FD_FD = -1; }
|
namespace procfs { int PROC_SELF_FD_FD = -1; }
|
||||||
static constexpr const char PROCFS_PATH[] = "/proc";
|
static constexpr const char PROCFS_PATH[] = "/proc";
|
||||||
static constexpr const char PROC_SELF_FD[] = "/proc/self/fd";
|
|
||||||
|
|
||||||
// This is critical to the function of the app. abort if failed to
|
|
||||||
// open.
|
|
||||||
static
|
|
||||||
void
|
|
||||||
_open_proc_self_fd()
|
|
||||||
{
|
|
||||||
procfs::PROC_SELF_FD_FD = fs::open(PROC_SELF_FD,O_PATH|O_DIRECTORY);
|
|
||||||
assert(procfs::PROC_SELF_FD_FD >= 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
procfs::init()
|
procfs::init()
|
||||||
|
|
@ -47,7 +36,12 @@ procfs::init()
|
||||||
g_PROCFS_DIR_FD = rv;
|
g_PROCFS_DIR_FD = rv;
|
||||||
|
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
::_open_proc_self_fd();
|
// This is critical to the function of the app. abort if failed to
|
||||||
|
// open.
|
||||||
|
static constexpr const char PROC_SELF_FD[] = "/proc/self/fd";
|
||||||
|
|
||||||
|
procfs::PROC_SELF_FD_FD = fs::open(PROC_SELF_FD,O_PATH|O_DIRECTORY);
|
||||||
|
assert(procfs::PROC_SELF_FD_FD >= 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "fuse_req_ctx.h"
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
# include <sys/xattr.h>
|
# include <sys/xattr.h>
|
||||||
# else
|
# else
|
||||||
# undef USE_XATTR
|
# undef USE_XATTR
|
||||||
# warning "USE_XATTR unset: xattrs disabled"
|
# pragma message "USE_XATTR unset: xattrs disabled"
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue