mirror of
https://github.com/trapexit/mergerfs.git
synced 2025-02-02 05:57:15 +08:00
Merge pull request #94 from trapexit/config-cleanup
config get and struct naming cleanup
This commit is contained in:
commit
838c081b8c
|
@ -74,8 +74,8 @@ namespace mergerfs
|
||||||
access(const char *fusepath,
|
access(const char *fusepath,
|
||||||
int mask)
|
int mask)
|
||||||
{
|
{
|
||||||
const struct fuse_context *fc = fuse_get_context();
|
const fuse_context *fc = fuse_get_context();
|
||||||
const config::Config &config = config::get();
|
const Config &config = Config::get(fc);
|
||||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||||
|
|
||||||
|
|
|
@ -74,8 +74,8 @@ namespace mergerfs
|
||||||
chmod(const char *fusepath,
|
chmod(const char *fusepath,
|
||||||
mode_t mode)
|
mode_t mode)
|
||||||
{
|
{
|
||||||
const struct fuse_context *fc = fuse_get_context();
|
const fuse_context *fc = fuse_get_context();
|
||||||
const config::Config &config = config::get();
|
const Config &config = Config::get(fc);
|
||||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using mergerfs::Policy;
|
using mergerfs::Policy;
|
||||||
|
using mergerfs::Config;
|
||||||
|
|
||||||
static
|
static
|
||||||
int
|
int
|
||||||
|
@ -77,8 +78,8 @@ namespace mergerfs
|
||||||
uid_t uid,
|
uid_t uid,
|
||||||
gid_t gid)
|
gid_t gid)
|
||||||
{
|
{
|
||||||
const struct fuse_context *fc = fuse_get_context();
|
const fuse_context *fc = fuse_get_context();
|
||||||
const config::Config &config = config::get();
|
const Config &config = Config::get(fc);
|
||||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,6 @@ using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
namespace mergerfs
|
namespace mergerfs
|
||||||
{
|
|
||||||
namespace config
|
|
||||||
{
|
{
|
||||||
Config::Config()
|
Config::Config()
|
||||||
: destmount(),
|
: destmount(),
|
||||||
|
@ -119,23 +117,4 @@ namespace mergerfs
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Config&
|
|
||||||
get(const struct fuse_context *fc)
|
|
||||||
{
|
|
||||||
return *((Config*)fc->private_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
const Config&
|
|
||||||
get(void)
|
|
||||||
{
|
|
||||||
return get(fuse_get_context());
|
|
||||||
}
|
|
||||||
|
|
||||||
Config&
|
|
||||||
get_writable(void)
|
|
||||||
{
|
|
||||||
return (*((Config*)fuse_get_context()->private_data));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,8 +37,6 @@
|
||||||
#include "fusefunc.hpp"
|
#include "fusefunc.hpp"
|
||||||
|
|
||||||
namespace mergerfs
|
namespace mergerfs
|
||||||
{
|
|
||||||
namespace config
|
|
||||||
{
|
{
|
||||||
class Config
|
class Config
|
||||||
{
|
{
|
||||||
|
@ -82,12 +80,22 @@ namespace mergerfs
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const std::string controlfile;
|
const std::string controlfile;
|
||||||
};
|
|
||||||
|
|
||||||
const Config &get(const struct fuse_context *fc);
|
public:
|
||||||
const Config &get(void);
|
static
|
||||||
Config &get_writable(void);
|
const Config &
|
||||||
|
get(const fuse_context *fc)
|
||||||
|
{
|
||||||
|
return *((Config*)fc->private_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
Config &
|
||||||
|
get_writable(void)
|
||||||
|
{
|
||||||
|
return (*((Config*)fuse_get_context()->private_data));
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -91,10 +91,10 @@ namespace mergerfs
|
||||||
int
|
int
|
||||||
create(const char *fusepath,
|
create(const char *fusepath,
|
||||||
mode_t mode,
|
mode_t mode,
|
||||||
struct fuse_file_info *fileinfo)
|
fuse_file_info *fileinfo)
|
||||||
{
|
{
|
||||||
const struct fuse_context *fc = fuse_get_context();
|
const fuse_context *fc = fuse_get_context();
|
||||||
const config::Config &config = config::get();
|
const Config &config = Config::get(fc);
|
||||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,6 @@ namespace mergerfs
|
||||||
int
|
int
|
||||||
create(const char *fusepath,
|
create(const char *fusepath,
|
||||||
mode_t mode,
|
mode_t mode,
|
||||||
struct fuse_file_info *fileinfo);
|
fuse_file_info *fileinfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ namespace mergerfs
|
||||||
int mode,
|
int mode,
|
||||||
off_t offset,
|
off_t offset,
|
||||||
off_t len,
|
off_t len,
|
||||||
struct fuse_file_info *ffi)
|
fuse_file_info *ffi)
|
||||||
{
|
{
|
||||||
return _fallocate(ffi->fh,
|
return _fallocate(ffi->fh,
|
||||||
mode,
|
mode,
|
||||||
|
|
|
@ -31,6 +31,6 @@ namespace mergerfs
|
||||||
int mode,
|
int mode,
|
||||||
off_t offset,
|
off_t offset,
|
||||||
off_t len,
|
off_t len,
|
||||||
struct fuse_file_info *fi);
|
fuse_file_info *fi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ namespace mergerfs
|
||||||
int
|
int
|
||||||
fgetattr(const char *fusepath,
|
fgetattr(const char *fusepath,
|
||||||
struct stat *st,
|
struct stat *st,
|
||||||
struct fuse_file_info *ffi)
|
fuse_file_info *ffi)
|
||||||
{
|
{
|
||||||
return _fgetattr(ffi->fh,
|
return _fgetattr(ffi->fh,
|
||||||
*st);
|
*st);
|
||||||
|
|
|
@ -33,6 +33,6 @@ namespace mergerfs
|
||||||
int
|
int
|
||||||
fgetattr(const char *fusepath,
|
fgetattr(const char *fusepath,
|
||||||
struct stat *st,
|
struct stat *st,
|
||||||
struct fuse_file_info *fileinfo);
|
fuse_file_info *fileinfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ namespace mergerfs
|
||||||
{
|
{
|
||||||
int
|
int
|
||||||
flush(const char *fusepath,
|
flush(const char *fusepath,
|
||||||
struct fuse_file_info *ffi)
|
fuse_file_info *ffi)
|
||||||
{
|
{
|
||||||
return _flush(ffi->fh);
|
return _flush(ffi->fh);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,6 @@ namespace mergerfs
|
||||||
{
|
{
|
||||||
int
|
int
|
||||||
flush(const char *path,
|
flush(const char *path,
|
||||||
struct fuse_file_info *fi);
|
fuse_file_info *fi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace mergerfs
|
||||||
int
|
int
|
||||||
fsync(const char *fusepath,
|
fsync(const char *fusepath,
|
||||||
int isdatasync,
|
int isdatasync,
|
||||||
struct fuse_file_info *ffi)
|
fuse_file_info *ffi)
|
||||||
{
|
{
|
||||||
return _fsync(ffi->fh,
|
return _fsync(ffi->fh,
|
||||||
isdatasync);
|
isdatasync);
|
||||||
|
|
|
@ -31,6 +31,6 @@ namespace mergerfs
|
||||||
int
|
int
|
||||||
fsync(const char *fusepath,
|
fsync(const char *fusepath,
|
||||||
int isdatasync,
|
int isdatasync,
|
||||||
struct fuse_file_info *fi);
|
fuse_file_info *fi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace mergerfs
|
||||||
int
|
int
|
||||||
ftruncate(const char *fusepath,
|
ftruncate(const char *fusepath,
|
||||||
off_t size,
|
off_t size,
|
||||||
struct fuse_file_info *ffi)
|
fuse_file_info *ffi)
|
||||||
{
|
{
|
||||||
return _ftruncate(ffi->fh,
|
return _ftruncate(ffi->fh,
|
||||||
size);
|
size);
|
||||||
|
|
|
@ -34,6 +34,6 @@ namespace mergerfs
|
||||||
int
|
int
|
||||||
ftruncate(const char *fusepath,
|
ftruncate(const char *fusepath,
|
||||||
off_t size,
|
off_t size,
|
||||||
struct fuse_file_info *fi);
|
fuse_file_info *fi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,12 +94,12 @@ namespace mergerfs
|
||||||
getattr(const char *fusepath,
|
getattr(const char *fusepath,
|
||||||
struct stat *st)
|
struct stat *st)
|
||||||
{
|
{
|
||||||
const config::Config &config = config::get();
|
const fuse_context *fc = fuse_get_context();
|
||||||
|
const Config &config = Config::get(fc);
|
||||||
|
|
||||||
if(fusepath == config.controlfile)
|
if(fusepath == config.controlfile)
|
||||||
return _getattr_controlfile(*st);
|
return _getattr_controlfile(*st);
|
||||||
|
|
||||||
const struct fuse_context *fc = fuse_get_context();
|
|
||||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,6 @@ using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using std::set;
|
using std::set;
|
||||||
using namespace mergerfs;
|
using namespace mergerfs;
|
||||||
using namespace mergerfs::config;
|
|
||||||
|
|
||||||
static
|
static
|
||||||
void
|
void
|
||||||
|
@ -246,7 +245,8 @@ namespace mergerfs
|
||||||
char *buf,
|
char *buf,
|
||||||
size_t count)
|
size_t count)
|
||||||
{
|
{
|
||||||
const config::Config &config = config::get();
|
const fuse_context *fc = fuse_get_context();
|
||||||
|
const Config &config = Config::get(fc);
|
||||||
|
|
||||||
if(fusepath == config.controlfile)
|
if(fusepath == config.controlfile)
|
||||||
return _getxattr_controlfile(config,
|
return _getxattr_controlfile(config,
|
||||||
|
@ -254,7 +254,6 @@ namespace mergerfs
|
||||||
buf,
|
buf,
|
||||||
count);
|
count);
|
||||||
|
|
||||||
const struct fuse_context *fc = fuse_get_context();
|
|
||||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace mergerfs
|
||||||
namespace fuse
|
namespace fuse
|
||||||
{
|
{
|
||||||
void *
|
void *
|
||||||
init(struct fuse_conn_info *conn)
|
init(fuse_conn_info *conn)
|
||||||
{
|
{
|
||||||
#ifdef FUSE_CAP_ASYNC_READ
|
#ifdef FUSE_CAP_ASYNC_READ
|
||||||
conn->want |= FUSE_CAP_ASYNC_READ;
|
conn->want |= FUSE_CAP_ASYNC_READ;
|
||||||
|
@ -55,7 +55,7 @@ namespace mergerfs
|
||||||
conn->want |= FUSE_CAP_SPLICE_MOVE;
|
conn->want |= FUSE_CAP_SPLICE_MOVE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return &config::get_writable();
|
return &Config::get_writable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,6 @@ namespace mergerfs
|
||||||
namespace fuse
|
namespace fuse
|
||||||
{
|
{
|
||||||
void *
|
void *
|
||||||
init(struct fuse_conn_info *conn);
|
init(fuse_conn_info *conn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,8 +98,8 @@ _ioctl_dir(const string &fusepath,
|
||||||
const int cmd,
|
const int cmd,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
const struct fuse_context *fc = fuse_get_context();
|
const fuse_context *fc = fuse_get_context();
|
||||||
const config::Config &config = config::get(fc);
|
const Config &config = Config::get(fc);
|
||||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ namespace mergerfs
|
||||||
ioctl(const char *fusepath,
|
ioctl(const char *fusepath,
|
||||||
int cmd,
|
int cmd,
|
||||||
void *arg,
|
void *arg,
|
||||||
struct fuse_file_info *ffi,
|
fuse_file_info *ffi,
|
||||||
unsigned int flags,
|
unsigned int flags,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace mergerfs
|
||||||
ioctl(const char *fusepath,
|
ioctl(const char *fusepath,
|
||||||
int cmd,
|
int cmd,
|
||||||
void *arg,
|
void *arg,
|
||||||
struct fuse_file_info *fi,
|
fuse_file_info *fi,
|
||||||
unsigned int flags,
|
unsigned int flags,
|
||||||
void *data);
|
void *data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,8 +110,8 @@ namespace mergerfs
|
||||||
link(const char *from,
|
link(const char *from,
|
||||||
const char *to)
|
const char *to)
|
||||||
{
|
{
|
||||||
const struct fuse_context *fc = fuse_get_context();
|
const fuse_context *fc = fuse_get_context();
|
||||||
const config::Config &config = config::get();
|
const Config &config = Config::get(fc);
|
||||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||||
|
|
||||||
|
|
|
@ -109,12 +109,12 @@ namespace mergerfs
|
||||||
char *list,
|
char *list,
|
||||||
size_t size)
|
size_t size)
|
||||||
{
|
{
|
||||||
const config::Config &config = config::get();
|
const fuse_context *fc = fuse_get_context();
|
||||||
|
const Config &config = Config::get(fc);
|
||||||
|
|
||||||
if(fusepath == config.controlfile)
|
if(fusepath == config.controlfile)
|
||||||
return _listxattr_controlfile(list,size);
|
return _listxattr_controlfile(list,size);
|
||||||
|
|
||||||
const struct fuse_context *fc = fuse_get_context();
|
|
||||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||||
|
|
||||||
|
|
|
@ -168,9 +168,9 @@ namespace mergerfs
|
||||||
main(const int argc,
|
main(const int argc,
|
||||||
char **argv)
|
char **argv)
|
||||||
{
|
{
|
||||||
struct fuse_args args;
|
fuse_args args;
|
||||||
struct fuse_operations ops = {0};
|
fuse_operations ops = {0};
|
||||||
mergerfs::config::Config config;
|
Config config;
|
||||||
|
|
||||||
args.argc = argc;
|
args.argc = argc;
|
||||||
args.argv = argv;
|
args.argv = argv;
|
||||||
|
|
|
@ -94,8 +94,8 @@ namespace mergerfs
|
||||||
mkdir(const char *fusepath,
|
mkdir(const char *fusepath,
|
||||||
mode_t mode)
|
mode_t mode)
|
||||||
{
|
{
|
||||||
const struct fuse_context *fc = fuse_get_context();
|
const fuse_context *fc = fuse_get_context();
|
||||||
const config::Config &config = config::get();
|
const Config &config = Config::get(fc);
|
||||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||||
|
|
||||||
|
|
|
@ -97,8 +97,8 @@ namespace mergerfs
|
||||||
mode_t mode,
|
mode_t mode,
|
||||||
dev_t rdev)
|
dev_t rdev)
|
||||||
{
|
{
|
||||||
const struct fuse_context *fc = fuse_get_context();
|
const fuse_context *fc = fuse_get_context();
|
||||||
const config::Config &config = config::get();
|
const Config &config = Config::get(fc);
|
||||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||||
|
|
||||||
|
|
|
@ -74,10 +74,10 @@ namespace mergerfs
|
||||||
{
|
{
|
||||||
int
|
int
|
||||||
open(const char *fusepath,
|
open(const char *fusepath,
|
||||||
struct fuse_file_info *fileinfo)
|
fuse_file_info *fileinfo)
|
||||||
{
|
{
|
||||||
const struct fuse_context *fc = fuse_get_context();
|
const fuse_context *fc = fuse_get_context();
|
||||||
const config::Config &config = config::get();
|
const Config &config = Config::get(fc);
|
||||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,6 @@ namespace mergerfs
|
||||||
{
|
{
|
||||||
int
|
int
|
||||||
open(const char *fusepath,
|
open(const char *fusepath,
|
||||||
struct fuse_file_info *fileinfo);
|
fuse_file_info *fileinfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace mergerfs
|
||||||
{
|
{
|
||||||
int
|
int
|
||||||
opendir(const char *fusepath,
|
opendir(const char *fusepath,
|
||||||
struct fuse_file_info *ffi)
|
fuse_file_info *ffi)
|
||||||
{
|
{
|
||||||
ffi->fh = 0;
|
ffi->fh = 0;
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,6 @@ namespace mergerfs
|
||||||
{
|
{
|
||||||
int
|
int
|
||||||
opendir(const char *fusepath,
|
opendir(const char *fusepath,
|
||||||
struct fuse_file_info *ffi);
|
fuse_file_info *ffi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ using namespace mergerfs;
|
||||||
|
|
||||||
static
|
static
|
||||||
void
|
void
|
||||||
set_option(struct fuse_args &args,
|
set_option(fuse_args &args,
|
||||||
const std::string &option_)
|
const std::string &option_)
|
||||||
{
|
{
|
||||||
string option;
|
string option;
|
||||||
|
@ -57,7 +57,7 @@ set_option(struct fuse_args &args,
|
||||||
|
|
||||||
static
|
static
|
||||||
void
|
void
|
||||||
set_kv_option(struct fuse_args &args,
|
set_kv_option(fuse_args &args,
|
||||||
const std::string &key,
|
const std::string &key,
|
||||||
const std::string &value)
|
const std::string &value)
|
||||||
{
|
{
|
||||||
|
@ -70,7 +70,7 @@ set_kv_option(struct fuse_args &args,
|
||||||
|
|
||||||
static
|
static
|
||||||
void
|
void
|
||||||
set_fsname(struct fuse_args &args,
|
set_fsname(fuse_args &args,
|
||||||
const vector<string> &srcmounts)
|
const vector<string> &srcmounts)
|
||||||
{
|
{
|
||||||
if(srcmounts.size() > 0)
|
if(srcmounts.size() > 0)
|
||||||
|
@ -85,14 +85,14 @@ set_fsname(struct fuse_args &args,
|
||||||
|
|
||||||
static
|
static
|
||||||
void
|
void
|
||||||
set_subtype(struct fuse_args &args)
|
set_subtype(fuse_args &args)
|
||||||
{
|
{
|
||||||
set_kv_option(args,"subtype","mergerfs");
|
set_kv_option(args,"subtype","mergerfs");
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
void
|
void
|
||||||
set_default_options(struct fuse_args &args)
|
set_default_options(fuse_args &args)
|
||||||
{
|
{
|
||||||
// set_option(args,"big_writes");
|
// set_option(args,"big_writes");
|
||||||
// set_option(args,"splice_read");
|
// set_option(args,"splice_read");
|
||||||
|
@ -118,9 +118,9 @@ parse_and_process_minfreespace(const std::string &value,
|
||||||
|
|
||||||
static
|
static
|
||||||
int
|
int
|
||||||
parse_and_process_arg(config::Config &config,
|
parse_and_process_arg(Config &config,
|
||||||
const std::string &arg,
|
const std::string &arg,
|
||||||
struct fuse_args *outargs)
|
fuse_args *outargs)
|
||||||
{
|
{
|
||||||
if(arg == "defaults")
|
if(arg == "defaults")
|
||||||
{
|
{
|
||||||
|
@ -133,7 +133,7 @@ parse_and_process_arg(config::Config &config,
|
||||||
|
|
||||||
static
|
static
|
||||||
int
|
int
|
||||||
parse_and_process_kv_arg(config::Config &config,
|
parse_and_process_kv_arg(Config &config,
|
||||||
const std::string &key,
|
const std::string &key,
|
||||||
const std::string &value)
|
const std::string &value)
|
||||||
{
|
{
|
||||||
|
@ -162,9 +162,9 @@ parse_and_process_kv_arg(config::Config &config,
|
||||||
|
|
||||||
static
|
static
|
||||||
int
|
int
|
||||||
process_opt(config::Config &config,
|
process_opt(Config &config,
|
||||||
const std::string &arg,
|
const std::string &arg,
|
||||||
struct fuse_args *outargs)
|
fuse_args *outargs)
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
std::vector<std::string> argvalue;
|
std::vector<std::string> argvalue;
|
||||||
|
@ -192,7 +192,7 @@ process_opt(config::Config &config,
|
||||||
static
|
static
|
||||||
int
|
int
|
||||||
process_srcmounts(const char *arg,
|
process_srcmounts(const char *arg,
|
||||||
config::Config &config)
|
Config &config)
|
||||||
{
|
{
|
||||||
vector<string> paths;
|
vector<string> paths;
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ process_srcmounts(const char *arg,
|
||||||
static
|
static
|
||||||
int
|
int
|
||||||
process_destmounts(const char *arg,
|
process_destmounts(const char *arg,
|
||||||
config::Config &config)
|
Config &config)
|
||||||
{
|
{
|
||||||
config.destmount = arg;
|
config.destmount = arg;
|
||||||
|
|
||||||
|
@ -218,10 +218,10 @@ int
|
||||||
option_processor(void *data,
|
option_processor(void *data,
|
||||||
const char *arg,
|
const char *arg,
|
||||||
int key,
|
int key,
|
||||||
struct fuse_args *outargs)
|
fuse_args *outargs)
|
||||||
{
|
{
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
config::Config &config = *(config::Config*)data;
|
Config &config = *(Config*)data;
|
||||||
|
|
||||||
switch(key)
|
switch(key)
|
||||||
{
|
{
|
||||||
|
@ -247,8 +247,8 @@ namespace mergerfs
|
||||||
namespace options
|
namespace options
|
||||||
{
|
{
|
||||||
void
|
void
|
||||||
parse(struct fuse_args &args,
|
parse(fuse_args &args,
|
||||||
config::Config &config)
|
Config &config)
|
||||||
{
|
{
|
||||||
|
|
||||||
fuse_opt_parse(&args,
|
fuse_opt_parse(&args,
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace mergerfs
|
||||||
namespace options
|
namespace options
|
||||||
{
|
{
|
||||||
void
|
void
|
||||||
parse(struct fuse_args &args,
|
parse(fuse_args &args,
|
||||||
mergerfs::config::Config &config);
|
Config &config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,9 +48,8 @@ _all(const vector<string> &basepaths,
|
||||||
|
|
||||||
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
|
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
|
||||||
{
|
{
|
||||||
const char *basepath;
|
const string &basepath = basepaths[i];
|
||||||
|
|
||||||
basepath = basepaths[i].c_str();
|
|
||||||
fullpath = fs::path::make(basepath,fusepath);
|
fullpath = fs::path::make(basepath,fusepath);
|
||||||
|
|
||||||
rv = ::lstat(fullpath.c_str(),&st);
|
rv = ::lstat(fullpath.c_str(),&st);
|
||||||
|
@ -58,7 +57,23 @@ _all(const vector<string> &basepaths,
|
||||||
paths.push_back(basepath);
|
paths.push_back(basepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
return paths.empty() ? (errno=ENOENT,-1) : 0;
|
if(paths.empty())
|
||||||
|
return (errno=ENOENT,-1);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
int
|
||||||
|
_all_create(const vector<string> &basepaths,
|
||||||
|
vector<string> &paths)
|
||||||
|
{
|
||||||
|
if(basepaths.empty())
|
||||||
|
return (errno=ENOENT,-1);
|
||||||
|
|
||||||
|
paths = basepaths;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace mergerfs
|
namespace mergerfs
|
||||||
|
@ -70,6 +85,9 @@ namespace mergerfs
|
||||||
const size_t minfreespace,
|
const size_t minfreespace,
|
||||||
vector<string> &paths)
|
vector<string> &paths)
|
||||||
{
|
{
|
||||||
|
if(type == Category::Enum::create)
|
||||||
|
return _all_create(basepaths,paths);
|
||||||
|
|
||||||
return _all(basepaths,fusepath,paths);
|
return _all(basepaths,fusepath,paths);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,11 +41,11 @@ static
|
||||||
inline
|
inline
|
||||||
void
|
void
|
||||||
_calc_epmfs(const struct statvfs &fsstats,
|
_calc_epmfs(const struct statvfs &fsstats,
|
||||||
const char *basepath,
|
const string &basepath,
|
||||||
fsblkcnt_t &epmfs,
|
fsblkcnt_t &epmfs,
|
||||||
const char *&epmfsbasepath,
|
string &epmfsbasepath,
|
||||||
fsblkcnt_t &mfs,
|
fsblkcnt_t &mfs,
|
||||||
const char *&mfsbasepath)
|
string &mfsbasepath)
|
||||||
{
|
{
|
||||||
fsblkcnt_t spaceavail;
|
fsblkcnt_t spaceavail;
|
||||||
|
|
||||||
|
@ -67,9 +67,9 @@ static
|
||||||
inline
|
inline
|
||||||
void
|
void
|
||||||
_calc_mfs(const struct statvfs &fsstats,
|
_calc_mfs(const struct statvfs &fsstats,
|
||||||
const char *basepath,
|
const string &basepath,
|
||||||
fsblkcnt_t &mfs,
|
fsblkcnt_t &mfs,
|
||||||
const char *&mfsbasepath)
|
string &mfsbasepath)
|
||||||
{
|
{
|
||||||
fsblkcnt_t spaceavail;
|
fsblkcnt_t spaceavail;
|
||||||
|
|
||||||
|
@ -84,12 +84,12 @@ _calc_mfs(const struct statvfs &fsstats,
|
||||||
static
|
static
|
||||||
inline
|
inline
|
||||||
int
|
int
|
||||||
_try_statvfs(const char *basepath,
|
_try_statvfs(const string &basepath,
|
||||||
const string &fullpath,
|
const string &fullpath,
|
||||||
fsblkcnt_t &epmfs,
|
fsblkcnt_t &epmfs,
|
||||||
const char *&epmfsbasepath,
|
string &epmfsbasepath,
|
||||||
fsblkcnt_t &mfs,
|
fsblkcnt_t &mfs,
|
||||||
const char *&mfsbasepath)
|
string &mfsbasepath)
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
struct statvfs fsstats;
|
struct statvfs fsstats;
|
||||||
|
@ -104,14 +104,14 @@ _try_statvfs(const char *basepath,
|
||||||
static
|
static
|
||||||
inline
|
inline
|
||||||
int
|
int
|
||||||
_try_statvfs(const char *basepath,
|
_try_statvfs(const string &basepath,
|
||||||
fsblkcnt_t &mfs,
|
fsblkcnt_t &mfs,
|
||||||
const char *&mfsbasepath)
|
string &mfsbasepath)
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
struct statvfs fsstats;
|
struct statvfs fsstats;
|
||||||
|
|
||||||
rv = ::statvfs(basepath,&fsstats);
|
rv = ::statvfs(basepath.c_str(),&fsstats);
|
||||||
if(rv == 0)
|
if(rv == 0)
|
||||||
_calc_mfs(fsstats,basepath,mfs,mfsbasepath);
|
_calc_mfs(fsstats,basepath,mfs,mfsbasepath);
|
||||||
|
|
||||||
|
@ -127,20 +127,17 @@ _epmfs_create(const vector<string> &basepaths,
|
||||||
{
|
{
|
||||||
fsblkcnt_t epmfs;
|
fsblkcnt_t epmfs;
|
||||||
fsblkcnt_t mfs;
|
fsblkcnt_t mfs;
|
||||||
const char *basepath;
|
string mfsbasepath;
|
||||||
const char *mfsbasepath;
|
string epmfsbasepath;
|
||||||
const char *epmfsbasepath;
|
|
||||||
string fullpath;
|
string fullpath;
|
||||||
|
|
||||||
mfs = 0;
|
mfs = 0;
|
||||||
epmfs = 0;
|
epmfs = 0;
|
||||||
mfsbasepath = NULL;
|
|
||||||
epmfsbasepath = NULL;
|
|
||||||
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
|
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
|
const string &basepath = basepaths[i];
|
||||||
|
|
||||||
basepath = basepaths[i].c_str();
|
|
||||||
fullpath = fs::path::make(basepath,fusepath);
|
fullpath = fs::path::make(basepath,fusepath);
|
||||||
|
|
||||||
rv = _try_statvfs(basepath,fusepath,epmfs,epmfsbasepath,mfs,mfsbasepath);
|
rv = _try_statvfs(basepath,fusepath,epmfs,epmfsbasepath,mfs,mfsbasepath);
|
||||||
|
@ -148,7 +145,7 @@ _epmfs_create(const vector<string> &basepaths,
|
||||||
_try_statvfs(basepath,mfs,mfsbasepath);
|
_try_statvfs(basepath,mfs,mfsbasepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(epmfsbasepath == NULL)
|
if(epmfsbasepath.empty())
|
||||||
epmfsbasepath = mfsbasepath;
|
epmfsbasepath = mfsbasepath;
|
||||||
|
|
||||||
paths.push_back(epmfsbasepath);
|
paths.push_back(epmfsbasepath);
|
||||||
|
@ -164,18 +161,16 @@ _epmfs(const vector<string> &basepaths,
|
||||||
|
|
||||||
{
|
{
|
||||||
fsblkcnt_t epmfs;
|
fsblkcnt_t epmfs;
|
||||||
const char *basepath;
|
string epmfsbasepath;
|
||||||
const char *epmfsbasepath;
|
|
||||||
string fullpath;
|
string fullpath;
|
||||||
|
|
||||||
epmfs = 0;
|
epmfs = 0;
|
||||||
epmfsbasepath = NULL;
|
|
||||||
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
|
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
struct statvfs fsstats;
|
struct statvfs fsstats;
|
||||||
|
const string &basepath = basepaths[i];
|
||||||
|
|
||||||
basepath = basepaths[i].c_str();
|
|
||||||
fullpath = fs::path::make(basepath,fusepath);
|
fullpath = fs::path::make(basepath,fusepath);
|
||||||
|
|
||||||
rv = ::statvfs(fullpath.c_str(),&fsstats);
|
rv = ::statvfs(fullpath.c_str(),&fsstats);
|
||||||
|
@ -183,7 +178,7 @@ _epmfs(const vector<string> &basepaths,
|
||||||
_calc_mfs(fsstats,basepath,epmfs,epmfsbasepath);
|
_calc_mfs(fsstats,basepath,epmfs,epmfsbasepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(epmfsbasepath == NULL)
|
if(epmfsbasepath.empty())
|
||||||
return (errno=ENOENT,-1);
|
return (errno=ENOENT,-1);
|
||||||
|
|
||||||
paths.push_back(epmfsbasepath);
|
paths.push_back(epmfsbasepath);
|
||||||
|
|
|
@ -47,10 +47,9 @@ _ff(const vector<string> &basepaths,
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
const char *basepath;
|
|
||||||
string fullpath;
|
string fullpath;
|
||||||
|
const string &basepath = basepaths[i];
|
||||||
|
|
||||||
basepath = basepaths[i].c_str();
|
|
||||||
fullpath = fs::path::make(basepath,fusepath);
|
fullpath = fs::path::make(basepath,fusepath);
|
||||||
|
|
||||||
rv = ::lstat(fullpath.c_str(),&st);
|
rv = ::lstat(fullpath.c_str(),&st);
|
||||||
|
@ -65,6 +64,20 @@ _ff(const vector<string> &basepaths,
|
||||||
return (errno=ENOENT,-1);
|
return (errno=ENOENT,-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
int
|
||||||
|
_ff_create(const vector<string> &basepaths,
|
||||||
|
const string &fusepath,
|
||||||
|
vector<string> &paths)
|
||||||
|
{
|
||||||
|
if(basepaths.empty())
|
||||||
|
return (errno=ENOENT,-1);
|
||||||
|
|
||||||
|
paths.push_back(basepaths[0]);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
namespace mergerfs
|
namespace mergerfs
|
||||||
{
|
{
|
||||||
int
|
int
|
||||||
|
@ -74,6 +87,9 @@ namespace mergerfs
|
||||||
const size_t minfreespace,
|
const size_t minfreespace,
|
||||||
vector<string> &paths)
|
vector<string> &paths)
|
||||||
{
|
{
|
||||||
|
if(type == Category::Enum::create)
|
||||||
|
return _ff_create(basepaths,fusepath,paths);
|
||||||
|
|
||||||
return _ff(basepaths,fusepath,paths);
|
return _ff(basepaths,fusepath,paths);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,17 +42,15 @@ _ffwp(const vector<string> &basepaths,
|
||||||
const string &fusepath,
|
const string &fusepath,
|
||||||
vector<string> &paths)
|
vector<string> &paths)
|
||||||
{
|
{
|
||||||
const char *fallback;
|
string fallback;
|
||||||
|
|
||||||
fallback = NULL;
|
|
||||||
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
|
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
const char *basepath;
|
|
||||||
string fullpath;
|
string fullpath;
|
||||||
|
const string &basepath = basepaths[i];
|
||||||
|
|
||||||
basepath = basepaths[i].c_str();
|
|
||||||
fullpath = fs::path::make(basepath,fusepath);
|
fullpath = fs::path::make(basepath,fusepath);
|
||||||
|
|
||||||
rv = ::lstat(fullpath.c_str(),&st);
|
rv = ::lstat(fullpath.c_str(),&st);
|
||||||
|
@ -67,7 +65,7 @@ _ffwp(const vector<string> &basepaths,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fallback == NULL)
|
if(fallback.empty())
|
||||||
return (errno=ENOENT,-1);
|
return (errno=ENOENT,-1);
|
||||||
|
|
||||||
paths.push_back(fallback);
|
paths.push_back(fallback);
|
||||||
|
|
|
@ -47,11 +47,10 @@ _fwfs_create(const Category::Enum::Type type,
|
||||||
for(size_t i = 0, size = basepaths.size(); i != size; i++)
|
for(size_t i = 0, size = basepaths.size(); i != size; i++)
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
const char *basepath;
|
|
||||||
struct statvfs fsstats;
|
struct statvfs fsstats;
|
||||||
|
const string &basepath = basepaths[i];
|
||||||
|
|
||||||
basepath = basepaths[i].c_str();
|
rv = ::statvfs(basepath.c_str(),&fsstats);
|
||||||
rv = ::statvfs(basepath,&fsstats);
|
|
||||||
if(rv == 0)
|
if(rv == 0)
|
||||||
{
|
{
|
||||||
fsblkcnt_t spaceavail;
|
fsblkcnt_t spaceavail;
|
||||||
|
@ -81,11 +80,11 @@ _fwfs(const Category::Enum::Type type,
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
string fullpath;
|
string fullpath;
|
||||||
const char *basepath;
|
|
||||||
struct statvfs fsstats;
|
struct statvfs fsstats;
|
||||||
|
const string &basepath = basepaths[i];
|
||||||
|
|
||||||
basepath = basepaths[i].c_str();
|
|
||||||
fullpath = fs::path::make(basepath,fusepath);
|
fullpath = fs::path::make(basepath,fusepath);
|
||||||
|
|
||||||
rv = ::statvfs(fullpath.c_str(),&fsstats);
|
rv = ::statvfs(fullpath.c_str(),&fsstats);
|
||||||
if(rv == 0)
|
if(rv == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,18 +48,16 @@ _lfs_create(const Category::Enum::Type type,
|
||||||
vector<string> &paths)
|
vector<string> &paths)
|
||||||
{
|
{
|
||||||
fsblkcnt_t lfs;
|
fsblkcnt_t lfs;
|
||||||
const char *lfsstr;
|
string lfsstr;
|
||||||
|
|
||||||
lfs = -1;
|
lfs = -1;
|
||||||
lfsstr = NULL;
|
|
||||||
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
|
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
const char *basepath;
|
|
||||||
struct statvfs fsstats;
|
struct statvfs fsstats;
|
||||||
|
const string &basepath = basepaths[i];
|
||||||
|
|
||||||
basepath = basepaths[i].c_str();
|
rv = ::statvfs(basepath.c_str(),&fsstats);
|
||||||
rv = ::statvfs(basepath,&fsstats);
|
|
||||||
if(rv == 0)
|
if(rv == 0)
|
||||||
{
|
{
|
||||||
fsblkcnt_t spaceavail;
|
fsblkcnt_t spaceavail;
|
||||||
|
@ -74,7 +72,7 @@ _lfs_create(const Category::Enum::Type type,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(lfsstr == NULL)
|
if(lfsstr.empty())
|
||||||
return Policy::Func::mfs(type,basepaths,fusepath,minfreespace,paths);
|
return Policy::Func::mfs(type,basepaths,fusepath,minfreespace,paths);
|
||||||
|
|
||||||
paths.push_back(lfsstr);
|
paths.push_back(lfsstr);
|
||||||
|
@ -91,19 +89,18 @@ _lfs(const Category::Enum::Type type,
|
||||||
vector<string> &paths)
|
vector<string> &paths)
|
||||||
{
|
{
|
||||||
fsblkcnt_t lfs;
|
fsblkcnt_t lfs;
|
||||||
const char *lfsstr;
|
string lfsstr;
|
||||||
|
|
||||||
lfs = -1;
|
lfs = -1;
|
||||||
lfsstr = NULL;
|
|
||||||
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
|
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
string fullpath;
|
string fullpath;
|
||||||
const char *basepath;
|
|
||||||
struct statvfs fsstats;
|
struct statvfs fsstats;
|
||||||
|
const string &basepath = basepaths[i];
|
||||||
|
|
||||||
basepath = basepaths[i].c_str();
|
|
||||||
fullpath = fs::path::make(basepath,fusepath);
|
fullpath = fs::path::make(basepath,fusepath);
|
||||||
|
|
||||||
rv = ::statvfs(fullpath.c_str(),&fsstats);
|
rv = ::statvfs(fullpath.c_str(),&fsstats);
|
||||||
if(rv == 0)
|
if(rv == 0)
|
||||||
{
|
{
|
||||||
|
@ -119,7 +116,7 @@ _lfs(const Category::Enum::Type type,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(lfsstr == NULL)
|
if(lfsstr.empty())
|
||||||
return Policy::Func::mfs(type,basepaths,fusepath,minfreespace,paths);
|
return Policy::Func::mfs(type,basepaths,fusepath,minfreespace,paths);
|
||||||
|
|
||||||
paths.push_back(lfsstr);
|
paths.push_back(lfsstr);
|
||||||
|
|
|
@ -41,18 +41,16 @@ _mfs_create(const vector<string> &basepaths,
|
||||||
vector<string> &paths)
|
vector<string> &paths)
|
||||||
{
|
{
|
||||||
fsblkcnt_t mfs;
|
fsblkcnt_t mfs;
|
||||||
const char *mfsstr;
|
string mfsstr;
|
||||||
|
|
||||||
mfs = 0;
|
mfs = 0;
|
||||||
mfsstr = NULL;
|
|
||||||
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
|
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
const char *basepath;
|
|
||||||
struct statvfs fsstats;
|
struct statvfs fsstats;
|
||||||
|
const string &basepath = basepaths[i];
|
||||||
|
|
||||||
basepath = basepaths[i].c_str();
|
rv = ::statvfs(basepath.c_str(),&fsstats);
|
||||||
rv = ::statvfs(basepath,&fsstats);
|
|
||||||
if(rv == 0)
|
if(rv == 0)
|
||||||
{
|
{
|
||||||
fsblkcnt_t spaceavail;
|
fsblkcnt_t spaceavail;
|
||||||
|
@ -66,7 +64,7 @@ _mfs_create(const vector<string> &basepaths,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mfsstr == NULL)
|
if(mfsstr.empty())
|
||||||
return (errno=ENOENT,-1);
|
return (errno=ENOENT,-1);
|
||||||
|
|
||||||
paths.push_back(mfsstr);
|
paths.push_back(mfsstr);
|
||||||
|
@ -81,19 +79,18 @@ _mfs(const vector<string> &basepaths,
|
||||||
vector<string> &paths)
|
vector<string> &paths)
|
||||||
{
|
{
|
||||||
fsblkcnt_t mfs;
|
fsblkcnt_t mfs;
|
||||||
const char *mfsstr;
|
string mfsstr;
|
||||||
|
|
||||||
mfs = 0;
|
mfs = 0;
|
||||||
mfsstr = NULL;
|
|
||||||
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
|
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
string fullpath;
|
string fullpath;
|
||||||
const char *basepath;
|
|
||||||
struct statvfs fsstats;
|
struct statvfs fsstats;
|
||||||
|
const string &basepath = basepaths[i];
|
||||||
|
|
||||||
basepath = basepaths[i].c_str();
|
|
||||||
fullpath = fs::path::make(basepath,fusepath);
|
fullpath = fs::path::make(basepath,fusepath);
|
||||||
|
|
||||||
rv = ::statvfs(fullpath.c_str(),&fsstats);
|
rv = ::statvfs(fullpath.c_str(),&fsstats);
|
||||||
if(rv == 0)
|
if(rv == 0)
|
||||||
{
|
{
|
||||||
|
@ -108,7 +105,7 @@ _mfs(const vector<string> &basepaths,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mfsstr == NULL)
|
if(mfsstr.empty())
|
||||||
return (errno=ENOENT,-1);
|
return (errno=ENOENT,-1);
|
||||||
|
|
||||||
paths.push_back(mfsstr);
|
paths.push_back(mfsstr);
|
||||||
|
|
|
@ -44,16 +44,15 @@ _newest(const vector<string> &basepaths,
|
||||||
vector<string> &paths)
|
vector<string> &paths)
|
||||||
{
|
{
|
||||||
time_t newest = std::numeric_limits<time_t>::min();
|
time_t newest = std::numeric_limits<time_t>::min();
|
||||||
const char *neweststr = NULL;
|
string neweststr;
|
||||||
|
|
||||||
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
|
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
const char *basepath;
|
|
||||||
string fullpath;
|
string fullpath;
|
||||||
|
const string &basepath = basepaths[i];
|
||||||
|
|
||||||
basepath = basepaths[i].c_str();
|
|
||||||
fullpath = fs::path::make(basepath,fusepath);
|
fullpath = fs::path::make(basepath,fusepath);
|
||||||
|
|
||||||
rv = ::lstat(fullpath.c_str(),&st);
|
rv = ::lstat(fullpath.c_str(),&st);
|
||||||
|
@ -64,7 +63,7 @@ _newest(const vector<string> &basepaths,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(neweststr == NULL)
|
if(neweststr.empty())
|
||||||
return (errno=ENOENT,-1);
|
return (errno=ENOENT,-1);
|
||||||
|
|
||||||
paths.push_back(neweststr);
|
paths.push_back(neweststr);
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace mergerfs
|
||||||
char *buf,
|
char *buf,
|
||||||
size_t count,
|
size_t count,
|
||||||
off_t offset,
|
off_t offset,
|
||||||
struct fuse_file_info *ffi)
|
fuse_file_info *ffi)
|
||||||
{
|
{
|
||||||
return _read(ffi->fh,
|
return _read(ffi->fh,
|
||||||
buf,
|
buf,
|
||||||
|
|
|
@ -31,6 +31,6 @@ namespace mergerfs
|
||||||
char *buf,
|
char *buf,
|
||||||
size_t count,
|
size_t count,
|
||||||
off_t offset,
|
off_t offset,
|
||||||
struct fuse_file_info *fi);
|
fuse_file_info *fi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,13 +33,13 @@
|
||||||
static
|
static
|
||||||
int
|
int
|
||||||
_read_buf(const int fd,
|
_read_buf(const int fd,
|
||||||
struct fuse_bufvec **bufp,
|
fuse_bufvec **bufp,
|
||||||
const size_t size,
|
const size_t size,
|
||||||
const off_t offset)
|
const off_t offset)
|
||||||
{
|
{
|
||||||
struct fuse_bufvec *src;
|
fuse_bufvec *src;
|
||||||
|
|
||||||
src = (fuse_bufvec*)malloc(sizeof(struct fuse_bufvec));
|
src = (fuse_bufvec*)malloc(sizeof(fuse_bufvec));
|
||||||
if(src == NULL)
|
if(src == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
@ -60,10 +60,10 @@ namespace mergerfs
|
||||||
{
|
{
|
||||||
int
|
int
|
||||||
read_buf(const char *fusepath,
|
read_buf(const char *fusepath,
|
||||||
struct fuse_bufvec **bufp,
|
fuse_bufvec **bufp,
|
||||||
size_t size,
|
size_t size,
|
||||||
off_t offset,
|
off_t offset,
|
||||||
struct fuse_file_info *ffi)
|
fuse_file_info *ffi)
|
||||||
{
|
{
|
||||||
return _read_buf(ffi->fh,
|
return _read_buf(ffi->fh,
|
||||||
bufp,
|
bufp,
|
||||||
|
|
|
@ -28,9 +28,9 @@ namespace mergerfs
|
||||||
{
|
{
|
||||||
int
|
int
|
||||||
read_buf(const char *fusepath,
|
read_buf(const char *fusepath,
|
||||||
struct fuse_bufvec **buf,
|
fuse_bufvec **buf,
|
||||||
size_t size,
|
size_t size,
|
||||||
off_t offset,
|
off_t offset,
|
||||||
struct fuse_file_info *fi);
|
fuse_file_info *fi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,10 +94,10 @@ namespace mergerfs
|
||||||
void *buf,
|
void *buf,
|
||||||
fuse_fill_dir_t filler,
|
fuse_fill_dir_t filler,
|
||||||
off_t offset,
|
off_t offset,
|
||||||
struct fuse_file_info *fi)
|
fuse_file_info *fi)
|
||||||
{
|
{
|
||||||
const struct fuse_context *fc = fuse_get_context();
|
const fuse_context *fc = fuse_get_context();
|
||||||
const config::Config &config = config::get();
|
const Config &config = Config::get(fc);
|
||||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace mergerfs
|
||||||
void *buf,
|
void *buf,
|
||||||
fuse_fill_dir_t filler,
|
fuse_fill_dir_t filler,
|
||||||
off_t offset,
|
off_t offset,
|
||||||
struct fuse_file_info *fi);
|
fuse_file_info *fi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,8 +75,8 @@ namespace mergerfs
|
||||||
char *buf,
|
char *buf,
|
||||||
size_t size)
|
size_t size)
|
||||||
{
|
{
|
||||||
const struct fuse_context *fc = fuse_get_context();
|
const fuse_context *fc = fuse_get_context();
|
||||||
const config::Config &config = config::get();
|
const Config &config = Config::get(fc);
|
||||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ namespace mergerfs
|
||||||
{
|
{
|
||||||
int
|
int
|
||||||
release(const char *fusepath,
|
release(const char *fusepath,
|
||||||
struct fuse_file_info *ffi)
|
fuse_file_info *ffi)
|
||||||
{
|
{
|
||||||
return _release(ffi->fh);
|
return _release(ffi->fh);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,6 @@ namespace mergerfs
|
||||||
{
|
{
|
||||||
int
|
int
|
||||||
release(const char *fusepath,
|
release(const char *fusepath,
|
||||||
struct fuse_file_info *fi);
|
fuse_file_info *fi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace mergerfs
|
||||||
{
|
{
|
||||||
int
|
int
|
||||||
releasedir(const char *fusepath,
|
releasedir(const char *fusepath,
|
||||||
struct fuse_file_info *ffi)
|
fuse_file_info *ffi)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,6 @@ namespace mergerfs
|
||||||
{
|
{
|
||||||
int
|
int
|
||||||
releasedir(const char *fusepath,
|
releasedir(const char *fusepath,
|
||||||
struct fuse_file_info *ffi);
|
fuse_file_info *ffi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,12 +81,12 @@ namespace mergerfs
|
||||||
removexattr(const char *fusepath,
|
removexattr(const char *fusepath,
|
||||||
const char *attrname)
|
const char *attrname)
|
||||||
{
|
{
|
||||||
const config::Config &config = config::get();
|
const fuse_context *fc = fuse_get_context();
|
||||||
|
const Config &config = Config::get(fc);
|
||||||
|
|
||||||
if(fusepath == config.controlfile)
|
if(fusepath == config.controlfile)
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
|
|
||||||
const struct fuse_context *fc = fuse_get_context();
|
|
||||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||||
|
|
||||||
|
|
|
@ -113,8 +113,8 @@ namespace mergerfs
|
||||||
rename(const char *oldpath,
|
rename(const char *oldpath,
|
||||||
const char *newpath)
|
const char *newpath)
|
||||||
{
|
{
|
||||||
const struct fuse_context *fc = fuse_get_context();
|
const fuse_context *fc = fuse_get_context();
|
||||||
const config::Config &config = config::get();
|
const Config &config = Config::get(fc);
|
||||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||||
|
|
||||||
|
|
|
@ -73,8 +73,8 @@ namespace mergerfs
|
||||||
int
|
int
|
||||||
rmdir(const char *fusepath)
|
rmdir(const char *fusepath)
|
||||||
{
|
{
|
||||||
const struct fuse_context *fc = fuse_get_context();
|
const fuse_context *fc = fuse_get_context();
|
||||||
const config::Config &config = config::get();
|
const Config &config = Config::get(fc);
|
||||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||||
const rwlock::ReadGuard readguard(&config.srcmountslock);
|
const rwlock::ReadGuard readguard(&config.srcmountslock);
|
||||||
|
|
||||||
|
|
|
@ -168,7 +168,7 @@ _setxattr_srcmounts(vector<string> &srcmounts,
|
||||||
|
|
||||||
static
|
static
|
||||||
int
|
int
|
||||||
_setxattr_minfreespace(config::Config &config,
|
_setxattr_minfreespace(Config &config,
|
||||||
const string &attrval,
|
const string &attrval,
|
||||||
const int flags)
|
const int flags)
|
||||||
{
|
{
|
||||||
|
@ -186,7 +186,7 @@ _setxattr_minfreespace(config::Config &config,
|
||||||
|
|
||||||
static
|
static
|
||||||
int
|
int
|
||||||
_setxattr_controlfile_func_policy(config::Config &config,
|
_setxattr_controlfile_func_policy(Config &config,
|
||||||
const char *funcname,
|
const char *funcname,
|
||||||
const string &attrval,
|
const string &attrval,
|
||||||
const int flags)
|
const int flags)
|
||||||
|
@ -205,7 +205,7 @@ _setxattr_controlfile_func_policy(config::Config &config,
|
||||||
|
|
||||||
static
|
static
|
||||||
int
|
int
|
||||||
_setxattr_controlfile_category_policy(config::Config &config,
|
_setxattr_controlfile_category_policy(Config &config,
|
||||||
const char *categoryname,
|
const char *categoryname,
|
||||||
const string &attrval,
|
const string &attrval,
|
||||||
const int flags)
|
const int flags)
|
||||||
|
@ -224,7 +224,7 @@ _setxattr_controlfile_category_policy(config::Config &config,
|
||||||
|
|
||||||
static
|
static
|
||||||
int
|
int
|
||||||
_setxattr_controlfile(config::Config &config,
|
_setxattr_controlfile(Config &config,
|
||||||
const char *attrname,
|
const char *attrname,
|
||||||
const string &attrval,
|
const string &attrval,
|
||||||
const int flags)
|
const int flags)
|
||||||
|
@ -307,21 +307,20 @@ namespace mergerfs
|
||||||
size_t attrvalsize,
|
size_t attrvalsize,
|
||||||
int flags)
|
int flags)
|
||||||
{
|
{
|
||||||
const config::Config &config = config::get();
|
const fuse_context *fc = fuse_get_context();
|
||||||
const struct fuse_context *fc = fuse_get_context();
|
const Config &config = Config::get(fc);
|
||||||
|
|
||||||
if(fusepath == config.controlfile)
|
if(fusepath == config.controlfile)
|
||||||
{
|
{
|
||||||
if((fc->uid != ::getuid()) && (fc->gid != ::getgid()))
|
if((fc->uid != ::getuid()) && (fc->gid != ::getgid()))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
return _setxattr_controlfile(config::get_writable(),
|
return _setxattr_controlfile(Config::get_writable(),
|
||||||
attrname,
|
attrname,
|
||||||
string(attrval,attrvalsize),
|
string(attrval,attrvalsize),
|
||||||
flags);
|
flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||||
|
|
||||||
|
@ -336,4 +335,3 @@ namespace mergerfs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -124,8 +124,8 @@ namespace mergerfs
|
||||||
statfs(const char *fusepath,
|
statfs(const char *fusepath,
|
||||||
struct statvfs *stat)
|
struct statvfs *stat)
|
||||||
{
|
{
|
||||||
const struct fuse_context *fc = fuse_get_context();
|
const fuse_context *fc = fuse_get_context();
|
||||||
const config::Config &config = config::get();
|
const Config &config = Config::get(fc);
|
||||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||||
|
|
||||||
|
|
|
@ -77,8 +77,8 @@ namespace mergerfs
|
||||||
symlink(const char *oldpath,
|
symlink(const char *oldpath,
|
||||||
const char *newpath)
|
const char *newpath)
|
||||||
{
|
{
|
||||||
const struct fuse_context *fc = fuse_get_context();
|
const fuse_context *fc = fuse_get_context();
|
||||||
const config::Config &config = config::get();
|
const Config &config = Config::get(fc);
|
||||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||||
|
|
||||||
|
|
|
@ -77,8 +77,8 @@ namespace mergerfs
|
||||||
truncate(const char *fusepath,
|
truncate(const char *fusepath,
|
||||||
off_t size)
|
off_t size)
|
||||||
{
|
{
|
||||||
const struct fuse_context *fc = fuse_get_context();
|
const fuse_context *fc = fuse_get_context();
|
||||||
const config::Config &config = config::get();
|
const Config &config = Config::get(fc);
|
||||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||||
|
|
||||||
|
|
|
@ -74,8 +74,8 @@ namespace mergerfs
|
||||||
int
|
int
|
||||||
unlink(const char *fusepath)
|
unlink(const char *fusepath)
|
||||||
{
|
{
|
||||||
const struct fuse_context *fc = fuse_get_context();
|
const fuse_context *fc = fuse_get_context();
|
||||||
const config::Config &config = config::get();
|
const Config &config = Config::get(fc);
|
||||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ _utimens(Policy::Func::Action actionFunc,
|
||||||
const vector<string> &srcmounts,
|
const vector<string> &srcmounts,
|
||||||
const size_t minfreespace,
|
const size_t minfreespace,
|
||||||
const string &fusepath,
|
const string &fusepath,
|
||||||
const struct timespec ts[2])
|
const timespec ts[2])
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
int error;
|
int error;
|
||||||
|
@ -75,10 +75,10 @@ namespace mergerfs
|
||||||
{
|
{
|
||||||
int
|
int
|
||||||
utimens(const char *fusepath,
|
utimens(const char *fusepath,
|
||||||
const struct timespec ts[2])
|
const timespec ts[2])
|
||||||
{
|
{
|
||||||
const struct fuse_context *fc = fuse_get_context();
|
const fuse_context *fc = fuse_get_context();
|
||||||
const config::Config &config = config::get();
|
const Config &config = Config::get(fc);
|
||||||
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
|
||||||
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
const rwlock::ReadGuard readlock(&config.srcmountslock);
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,6 @@ namespace mergerfs
|
||||||
{
|
{
|
||||||
int
|
int
|
||||||
utimens(const char *fusepath,
|
utimens(const char *fusepath,
|
||||||
const struct timespec ts[2]);
|
const timespec ts[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ namespace mergerfs
|
||||||
const char *buf,
|
const char *buf,
|
||||||
size_t count,
|
size_t count,
|
||||||
off_t offset,
|
off_t offset,
|
||||||
struct fuse_file_info *ffi)
|
fuse_file_info *ffi)
|
||||||
{
|
{
|
||||||
return _write(ffi->fh,
|
return _write(ffi->fh,
|
||||||
buf,
|
buf,
|
||||||
|
|
|
@ -31,6 +31,6 @@ namespace mergerfs
|
||||||
const char *buf,
|
const char *buf,
|
||||||
size_t count,
|
size_t count,
|
||||||
off_t offset,
|
off_t offset,
|
||||||
struct fuse_file_info *fi);
|
fuse_file_info *fi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,11 +33,11 @@
|
||||||
static
|
static
|
||||||
int
|
int
|
||||||
_write_buf(const int fd,
|
_write_buf(const int fd,
|
||||||
struct fuse_bufvec &src,
|
fuse_bufvec &src,
|
||||||
const off_t offset)
|
const off_t offset)
|
||||||
{
|
{
|
||||||
size_t size = fuse_buf_size(&src);
|
size_t size = fuse_buf_size(&src);
|
||||||
struct fuse_bufvec dst = FUSE_BUFVEC_INIT(size);
|
fuse_bufvec dst = FUSE_BUFVEC_INIT(size);
|
||||||
const fuse_buf_copy_flags cpflags =
|
const fuse_buf_copy_flags cpflags =
|
||||||
(fuse_buf_copy_flags)(FUSE_BUF_SPLICE_MOVE|FUSE_BUF_SPLICE_NONBLOCK);
|
(fuse_buf_copy_flags)(FUSE_BUF_SPLICE_MOVE|FUSE_BUF_SPLICE_NONBLOCK);
|
||||||
|
|
||||||
|
@ -54,9 +54,9 @@ namespace mergerfs
|
||||||
{
|
{
|
||||||
int
|
int
|
||||||
write_buf(const char *fusepath,
|
write_buf(const char *fusepath,
|
||||||
struct fuse_bufvec *src,
|
fuse_bufvec *src,
|
||||||
off_t offset,
|
off_t offset,
|
||||||
struct fuse_file_info *ffi)
|
fuse_file_info *ffi)
|
||||||
{
|
{
|
||||||
return _write_buf(ffi->fh,
|
return _write_buf(ffi->fh,
|
||||||
*src,
|
*src,
|
||||||
|
|
|
@ -28,8 +28,8 @@ namespace mergerfs
|
||||||
{
|
{
|
||||||
int
|
int
|
||||||
write_buf(const char *fusepath,
|
write_buf(const char *fusepath,
|
||||||
struct fuse_bufvec *buf,
|
fuse_bufvec *buf,
|
||||||
off_t offset,
|
off_t offset,
|
||||||
struct fuse_file_info *fi);
|
fuse_file_info *fi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user