Browse Source

config get and struct naming cleanup

pull/94/head
Antonio SJ Musumeci 9 years ago
parent
commit
f130d07fd8
  1. 4
      src/access.cpp
  2. 4
      src/chmod.cpp
  3. 5
      src/chown.cpp
  4. 21
      src/config.cpp
  5. 20
      src/config.hpp
  6. 6
      src/create.cpp
  7. 2
      src/create.hpp
  8. 2
      src/fallocate.cpp
  9. 2
      src/fallocate.hpp
  10. 2
      src/fgetattr.cpp
  11. 2
      src/fgetattr.hpp
  12. 2
      src/flush.cpp
  13. 2
      src/flush.hpp
  14. 2
      src/fsync.cpp
  15. 2
      src/fsync.hpp
  16. 2
      src/ftruncate.cpp
  17. 2
      src/ftruncate.hpp
  18. 4
      src/getattr.cpp
  19. 5
      src/getxattr.cpp
  20. 4
      src/init.cpp
  21. 2
      src/init.hpp
  22. 6
      src/ioctl.cpp
  23. 2
      src/ioctl.hpp
  24. 4
      src/link.cpp
  25. 4
      src/listxattr.cpp
  26. 6
      src/mergerfs.cpp
  27. 4
      src/mkdir.cpp
  28. 4
      src/mknod.cpp
  29. 6
      src/open.cpp
  30. 2
      src/open.hpp
  31. 2
      src/opendir.cpp
  32. 2
      src/opendir.hpp
  33. 32
      src/option_parser.cpp
  34. 4
      src/option_parser.hpp
  35. 24
      src/policy_all.cpp
  36. 41
      src/policy_epmfs.cpp
  37. 20
      src/policy_ff.cpp
  38. 8
      src/policy_ffwp.cpp
  39. 9
      src/policy_fwfs.cpp
  40. 19
      src/policy_lfs.cpp
  41. 19
      src/policy_mfs.cpp
  42. 7
      src/policy_newest.cpp
  43. 2
      src/read.cpp
  44. 2
      src/read.hpp
  45. 10
      src/read_buf.cpp
  46. 4
      src/read_buf.hpp
  47. 6
      src/readdir.cpp
  48. 2
      src/readdir.hpp
  49. 4
      src/readlink.cpp
  50. 2
      src/release.cpp
  51. 2
      src/release.hpp
  52. 2
      src/releasedir.cpp
  53. 2
      src/releasedir.hpp
  54. 4
      src/removexattr.cpp
  55. 4
      src/rename.cpp
  56. 4
      src/rmdir.cpp
  57. 16
      src/setxattr.cpp
  58. 4
      src/statfs.cpp
  59. 4
      src/symlink.cpp
  60. 4
      src/truncate.cpp
  61. 4
      src/unlink.cpp
  62. 8
      src/utimens.cpp
  63. 2
      src/utimens.hpp
  64. 2
      src/write.cpp
  65. 2
      src/write.hpp
  66. 8
      src/write_buf.cpp
  67. 4
      src/write_buf.hpp

4
src/access.cpp

@ -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 config::Config &config = config::get();
const fuse_context *fc = fuse_get_context();
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);

4
src/chmod.cpp

@ -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 config::Config &config = config::get();
const fuse_context *fc = fuse_get_context();
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);

5
src/chown.cpp

@ -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 config::Config &config = config::get();
const fuse_context *fc = fuse_get_context();
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);

21
src/config.cpp

@ -40,8 +40,6 @@ using std::vector;
namespace mergerfs namespace mergerfs
{ {
namespace config
{
Config::Config() Config::Config()
: destmount(), : destmount(),
srcmounts(), srcmounts(),
@ -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));
}
}
} }

20
src/config.hpp

@ -38,8 +38,6 @@
namespace mergerfs namespace mergerfs
{ {
namespace config
{
class Config class Config
{ {
public: public:
@ -82,12 +80,22 @@ namespace mergerfs
public: public:
const std::string controlfile; const std::string controlfile;
};
const Config &get(const struct fuse_context *fc);
const Config &get(void);
Config &get_writable(void);
public:
static
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

6
src/create.cpp

@ -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 config::Config &config = config::get();
const fuse_context *fc = fuse_get_context();
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);

2
src/create.hpp

@ -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);
} }
} }

2
src/fallocate.cpp

@ -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,

2
src/fallocate.hpp

@ -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);
} }
} }

2
src/fgetattr.cpp

@ -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);

2
src/fgetattr.hpp

@ -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);
} }
} }

2
src/flush.cpp

@ -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);
} }

2
src/flush.hpp

@ -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);
} }
} }

2
src/fsync.cpp

@ -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);

2
src/fsync.hpp

@ -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);
} }
} }

2
src/ftruncate.cpp

@ -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);

2
src/ftruncate.hpp

@ -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);
} }
} }

4
src/getattr.cpp

@ -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);

5
src/getxattr.cpp

@ -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);

4
src/init.cpp

@ -31,13 +31,13 @@ namespace mergerfs
namespace fuse namespace fuse
{ {
void * void *
init(struct fuse_conn_info *conn)
init(fuse_conn_info *conn)
{ {
#ifdef FUSE_CAP_IOCTL_DIR #ifdef FUSE_CAP_IOCTL_DIR
conn->want |= FUSE_CAP_IOCTL_DIR; conn->want |= FUSE_CAP_IOCTL_DIR;
#endif #endif
return &config::get_writable();
return &Config::get_writable();
} }
} }
} }

2
src/init.hpp

@ -27,6 +27,6 @@ namespace mergerfs
namespace fuse namespace fuse
{ {
void * void *
init(struct fuse_conn_info *conn);
init(fuse_conn_info *conn);
} }
} }

6
src/ioctl.cpp

@ -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 config::Config &config = config::get(fc);
const fuse_context *fc = fuse_get_context();
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)
{ {

2
src/ioctl.hpp

@ -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);
} }

4
src/link.cpp

@ -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 config::Config &config = config::get();
const fuse_context *fc = fuse_get_context();
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);

4
src/listxattr.cpp

@ -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);

6
src/mergerfs.cpp

@ -168,9 +168,9 @@ namespace mergerfs
main(const int argc, main(const int argc,
char **argv) char **argv)
{ {
struct fuse_args args;
struct fuse_operations ops = {0};
mergerfs::config::Config config;
fuse_args args;
fuse_operations ops = {0};
Config config;
args.argc = argc; args.argc = argc;
args.argv = argv; args.argv = argv;

4
src/mkdir.cpp

@ -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 config::Config &config = config::get();
const fuse_context *fc = fuse_get_context();
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);

4
src/mknod.cpp

@ -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 config::Config &config = config::get();
const fuse_context *fc = fuse_get_context();
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);

6
src/open.cpp

@ -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 config::Config &config = config::get();
const fuse_context *fc = fuse_get_context();
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);

2
src/open.hpp

@ -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);
} }
} }

2
src/opendir.cpp

@ -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;

2
src/opendir.hpp

@ -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);
} }
} }

32
src/option_parser.cpp

@ -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,
config::Config &config)
parse(fuse_args &args,
Config &config)
{ {
fuse_opt_parse(&args, fuse_opt_parse(&args,

4
src/option_parser.hpp

@ -31,7 +31,7 @@ namespace mergerfs
namespace options namespace options
{ {
void void
parse(struct fuse_args &args,
mergerfs::config::Config &config);
parse(fuse_args &args,
Config &config);
} }
} }

24
src/policy_all.cpp

@ -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
src/policy_epmfs.cpp

@ -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;
const char *mfsbasepath;
const char *epmfsbasepath;
string mfsbasepath;
string 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;
const char *epmfsbasepath;
string 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);

20
src/policy_ff.cpp

@ -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);
} }
} }

8
src/policy_ffwp.cpp

@ -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);

9
src/policy_fwfs.cpp

@ -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,&fsstats);
rv = ::statvfs(basepath.c_str(),&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)
{ {

19
src/policy_lfs.cpp

@ -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,&fsstats);
rv = ::statvfs(basepath.c_str(),&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);

19
src/policy_mfs.cpp

@ -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,&fsstats);
rv = ::statvfs(basepath.c_str(),&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);

7
src/policy_newest.cpp

@ -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);

2
src/read.cpp

@ -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,

2
src/read.hpp

@ -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);
} }
} }

10
src/read_buf.cpp

@ -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,

4
src/read_buf.hpp

@ -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);
} }
} }

6
src/readdir.cpp

@ -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 config::Config &config = config::get();
const fuse_context *fc = fuse_get_context();
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);

2
src/readdir.hpp

@ -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);
} }
} }

4
src/readlink.cpp

@ -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 config::Config &config = config::get();
const fuse_context *fc = fuse_get_context();
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);

2
src/release.cpp

@ -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);
} }

2
src/release.hpp

@ -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);
} }
} }

2
src/releasedir.cpp

@ -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;
} }

2
src/releasedir.hpp

@ -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);
} }
} }

4
src/removexattr.cpp

@ -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);

4
src/rename.cpp

@ -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 config::Config &config = config::get();
const fuse_context *fc = fuse_get_context();
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);

4
src/rmdir.cpp

@ -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 config::Config &config = config::get();
const fuse_context *fc = fuse_get_context();
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);

16
src/setxattr.cpp

@ -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 struct fuse_context *fc = fuse_get_context();
const 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);
@ -335,5 +334,4 @@ namespace mergerfs
flags); flags);
} }
} }
}
} }

4
src/statfs.cpp

@ -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 config::Config &config = config::get();
const fuse_context *fc = fuse_get_context();
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);

4
src/symlink.cpp

@ -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 config::Config &config = config::get();
const fuse_context *fc = fuse_get_context();
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);

4
src/truncate.cpp

@ -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 config::Config &config = config::get();
const fuse_context *fc = fuse_get_context();
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);

4
src/unlink.cpp

@ -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 config::Config &config = config::get();
const fuse_context *fc = fuse_get_context();
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);

8
src/utimens.cpp

@ -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 config::Config &config = config::get();
const fuse_context *fc = fuse_get_context();
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);

2
src/utimens.hpp

@ -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]);
} }
} }

2
src/write.cpp

@ -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,

2
src/write.hpp

@ -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);
} }
} }

8
src/write_buf.cpp

@ -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,

4
src/write_buf.hpp

@ -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…
Cancel
Save