Browse Source

Merge pull request #94 from trapexit/config-cleanup

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

4
src/access.cpp

@ -74,8 +74,8 @@ namespace mergerfs
access(const char *fusepath,
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 rwlock::ReadGuard readlock(&config.srcmountslock);

4
src/chmod.cpp

@ -74,8 +74,8 @@ namespace mergerfs
chmod(const char *fusepath,
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 rwlock::ReadGuard readlock(&config.srcmountslock);

5
src/chown.cpp

@ -37,6 +37,7 @@
using std::string;
using std::vector;
using mergerfs::Policy;
using mergerfs::Config;
static
int
@ -77,8 +78,8 @@ namespace mergerfs
uid_t uid,
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 rwlock::ReadGuard readlock(&config.srcmountslock);

171
src/config.cpp

@ -40,102 +40,81 @@ using std::vector;
namespace mergerfs
{
namespace config
Config::Config()
: destmount(),
srcmounts(),
srcmountslock(),
minfreespace(UINT32_MAX),
POLICYINIT(access),
POLICYINIT(chmod),
POLICYINIT(chown),
POLICYINIT(create),
POLICYINIT(getattr),
POLICYINIT(getxattr),
POLICYINIT(link),
POLICYINIT(listxattr),
POLICYINIT(mkdir),
POLICYINIT(mknod),
POLICYINIT(open),
POLICYINIT(readlink),
POLICYINIT(removexattr),
POLICYINIT(rename),
POLICYINIT(rmdir),
POLICYINIT(setxattr),
POLICYINIT(symlink),
POLICYINIT(truncate),
POLICYINIT(unlink),
POLICYINIT(utimens),
controlfile("/.mergerfs")
{
Config::Config()
: destmount(),
srcmounts(),
srcmountslock(),
minfreespace(UINT32_MAX),
POLICYINIT(access),
POLICYINIT(chmod),
POLICYINIT(chown),
POLICYINIT(create),
POLICYINIT(getattr),
POLICYINIT(getxattr),
POLICYINIT(link),
POLICYINIT(listxattr),
POLICYINIT(mkdir),
POLICYINIT(mknod),
POLICYINIT(open),
POLICYINIT(readlink),
POLICYINIT(removexattr),
POLICYINIT(rename),
POLICYINIT(rmdir),
POLICYINIT(setxattr),
POLICYINIT(symlink),
POLICYINIT(truncate),
POLICYINIT(unlink),
POLICYINIT(utimens),
controlfile("/.mergerfs")
{
pthread_rwlock_init(&srcmountslock,NULL);
set_category_policy("action","all");
set_category_policy("create","epmfs");
set_category_policy("search","ff");
}
int
Config::set_func_policy(const string &fusefunc_,
const string &policy_)
{
const Policy *policy;
const FuseFunc *fusefunc;
fusefunc = FuseFunc::find(fusefunc_);
if(fusefunc == FuseFunc::invalid)
return (errno=ENODATA,-1);
policy = Policy::find(policy_);
if(policy == Policy::invalid)
return (errno=EINVAL,-1);
policies[(FuseFunc::Enum::Type)*fusefunc] = policy;
return 0;
}
int
Config::set_category_policy(const string &category_,
const string &policy_)
{
const Policy *policy;
const Category *category;
category = Category::find(category_);
if(category == Category::invalid)
return (errno=ENODATA,-1);
policy = Policy::find(policy_);
if(policy == Policy::invalid)
return (errno=EINVAL,-1);
for(int i = 0; i < FuseFunc::Enum::END; i++)
{
if(FuseFunc::fusefuncs[i] == (Category::Enum::Type)*category)
policies[(FuseFunc::Enum::Type)FuseFunc::fusefuncs[i]] = policy;
}
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));
}
pthread_rwlock_init(&srcmountslock,NULL);
set_category_policy("action","all");
set_category_policy("create","epmfs");
set_category_policy("search","ff");
}
int
Config::set_func_policy(const string &fusefunc_,
const string &policy_)
{
const Policy *policy;
const FuseFunc *fusefunc;
fusefunc = FuseFunc::find(fusefunc_);
if(fusefunc == FuseFunc::invalid)
return (errno=ENODATA,-1);
policy = Policy::find(policy_);
if(policy == Policy::invalid)
return (errno=EINVAL,-1);
policies[(FuseFunc::Enum::Type)*fusefunc] = policy;
return 0;
}
int
Config::set_category_policy(const string &category_,
const string &policy_)
{
const Policy *policy;
const Category *category;
category = Category::find(category_);
if(category == Category::invalid)
return (errno=ENODATA,-1);
policy = Policy::find(policy_);
if(policy == Policy::invalid)
return (errno=EINVAL,-1);
for(int i = 0; i < FuseFunc::Enum::END; i++)
{
if(FuseFunc::fusefuncs[i] == (Category::Enum::Type)*category)
policies[(FuseFunc::Enum::Type)FuseFunc::fusefuncs[i]] = policy;
}
return 0;
}
}

104
src/config.hpp

@ -38,56 +38,64 @@
namespace mergerfs
{
namespace config
class Config
{
class Config
public:
Config();
public:
int set_func_policy(const std::string &fusefunc_,
const std::string &policy_);
int set_category_policy(const std::string &category,
const std::string &policy);
public:
std::string destmount;
std::vector<std::string> srcmounts;
mutable pthread_rwlock_t srcmountslock;
size_t minfreespace;
public:
const Policy *policies[FuseFunc::Enum::END];
const Policy *&access;
const Policy *&chmod;
const Policy *&chown;
const Policy *&create;
const Policy *&getattr;
const Policy *&getxattr;
const Policy *&link;
const Policy *&listxattr;
const Policy *&mkdir;
const Policy *&mknod;
const Policy *&open;
const Policy *&readlink;
const Policy *&removexattr;
const Policy *&rename;
const Policy *&rmdir;
const Policy *&setxattr;
const Policy *&symlink;
const Policy *&truncate;
const Policy *&unlink;
const Policy *&utimens;
public:
const std::string controlfile;
public:
static
const Config &
get(const fuse_context *fc)
{
public:
Config();
public:
int set_func_policy(const std::string &fusefunc_,
const std::string &policy_);
int set_category_policy(const std::string &category,
const std::string &policy);
public:
std::string destmount;
std::vector<std::string> srcmounts;
mutable pthread_rwlock_t srcmountslock;
size_t minfreespace;
public:
const Policy *policies[FuseFunc::Enum::END];
const Policy *&access;
const Policy *&chmod;
const Policy *&chown;
const Policy *&create;
const Policy *&getattr;
const Policy *&getxattr;
const Policy *&link;
const Policy *&listxattr;
const Policy *&mkdir;
const Policy *&mknod;
const Policy *&open;
const Policy *&readlink;
const Policy *&removexattr;
const Policy *&rename;
const Policy *&rmdir;
const Policy *&setxattr;
const Policy *&symlink;
const Policy *&truncate;
const Policy *&unlink;
const Policy *&utimens;
public:
const std::string controlfile;
};
const Config &get(const struct fuse_context *fc);
const Config &get(void);
Config &get_writable(void);
}
return *((Config*)fc->private_data);
}
static
Config &
get_writable(void)
{
return (*((Config*)fuse_get_context()->private_data));
}
};
}
#endif

10
src/create.cpp

@ -89,12 +89,12 @@ namespace mergerfs
namespace fuse
{
int
create(const char *fusepath,
mode_t mode,
struct fuse_file_info *fileinfo)
create(const char *fusepath,
mode_t mode,
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 rwlock::ReadGuard readlock(&config.srcmountslock);

6
src/create.hpp

@ -30,8 +30,8 @@ namespace mergerfs
namespace fuse
{
int
create(const char *fusepath,
mode_t mode,
struct fuse_file_info *fileinfo);
create(const char *fusepath,
mode_t mode,
fuse_file_info *fileinfo);
}
}

10
src/fallocate.cpp

@ -67,11 +67,11 @@ namespace mergerfs
namespace fuse
{
int
fallocate(const char *fusepath,
int mode,
off_t offset,
off_t len,
struct fuse_file_info *ffi)
fallocate(const char *fusepath,
int mode,
off_t offset,
off_t len,
fuse_file_info *ffi)
{
return _fallocate(ffi->fh,
mode,

10
src/fallocate.hpp

@ -27,10 +27,10 @@ namespace mergerfs
namespace fuse
{
int
fallocate(const char *fusepath,
int mode,
off_t offset,
off_t len,
struct fuse_file_info *fi);
fallocate(const char *fusepath,
int mode,
off_t offset,
off_t len,
fuse_file_info *fi);
}
}

6
src/fgetattr.cpp

@ -46,9 +46,9 @@ namespace mergerfs
namespace fuse
{
int
fgetattr(const char *fusepath,
struct stat *st,
struct fuse_file_info *ffi)
fgetattr(const char *fusepath,
struct stat *st,
fuse_file_info *ffi)
{
return _fgetattr(ffi->fh,
*st);

6
src/fgetattr.hpp

@ -31,8 +31,8 @@ namespace mergerfs
namespace fuse
{
int
fgetattr(const char *fusepath,
struct stat *st,
struct fuse_file_info *fileinfo);
fgetattr(const char *fusepath,
struct stat *st,
fuse_file_info *fileinfo);
}
}

4
src/flush.cpp

@ -47,8 +47,8 @@ namespace mergerfs
namespace fuse
{
int
flush(const char *fusepath,
struct fuse_file_info *ffi)
flush(const char *fusepath,
fuse_file_info *ffi)
{
return _flush(ffi->fh);
}

4
src/flush.hpp

@ -27,7 +27,7 @@ namespace mergerfs
namespace fuse
{
int
flush(const char *path,
struct fuse_file_info *fi);
flush(const char *path,
fuse_file_info *fi);
}
}

6
src/fsync.cpp

@ -53,9 +53,9 @@ namespace mergerfs
namespace fuse
{
int
fsync(const char *fusepath,
int isdatasync,
struct fuse_file_info *ffi)
fsync(const char *fusepath,
int isdatasync,
fuse_file_info *ffi)
{
return _fsync(ffi->fh,
isdatasync);

6
src/fsync.hpp

@ -29,8 +29,8 @@ namespace mergerfs
namespace fuse
{
int
fsync(const char *fusepath,
int isdatasync,
struct fuse_file_info *fi);
fsync(const char *fusepath,
int isdatasync,
fuse_file_info *fi);
}
}

6
src/ftruncate.cpp

@ -45,9 +45,9 @@ namespace mergerfs
namespace fuse
{
int
ftruncate(const char *fusepath,
off_t size,
struct fuse_file_info *ffi)
ftruncate(const char *fusepath,
off_t size,
fuse_file_info *ffi)
{
return _ftruncate(ffi->fh,
size);

6
src/ftruncate.hpp

@ -32,8 +32,8 @@ namespace mergerfs
namespace fuse
{
int
ftruncate(const char *fusepath,
off_t size,
struct fuse_file_info *fi);
ftruncate(const char *fusepath,
off_t size,
fuse_file_info *fi);
}
}

4
src/getattr.cpp

@ -94,12 +94,12 @@ namespace mergerfs
getattr(const char *fusepath,
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)
return _getattr_controlfile(*st);
const struct fuse_context *fc = fuse_get_context();
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
const rwlock::ReadGuard readlock(&config.srcmountslock);

9
src/getxattr.cpp

@ -45,7 +45,6 @@ using std::string;
using std::vector;
using std::set;
using namespace mergerfs;
using namespace mergerfs::config;
static
void
@ -246,7 +245,8 @@ namespace mergerfs
char *buf,
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)
return _getxattr_controlfile(config,
@ -254,9 +254,8 @@ namespace mergerfs
buf,
count);
const struct fuse_context *fc = fuse_get_context();
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
const rwlock::ReadGuard readlock(&config.srcmountslock);
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
const rwlock::ReadGuard readlock(&config.srcmountslock);
return _getxattr(config.getxattr,
config.srcmounts,

4
src/init.cpp

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

2
src/init.hpp

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

16
src/ioctl.cpp

@ -98,8 +98,8 @@ _ioctl_dir(const string &fusepath,
const int cmd,
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 rwlock::ReadGuard readlock(&config.srcmountslock);
@ -117,12 +117,12 @@ namespace mergerfs
namespace fuse
{
int
ioctl(const char *fusepath,
int cmd,
void *arg,
struct fuse_file_info *ffi,
unsigned int flags,
void *data)
ioctl(const char *fusepath,
int cmd,
void *arg,
fuse_file_info *ffi,
unsigned int flags,
void *data)
{
#ifdef FUSE_IOCTL_DIR
if(flags & FUSE_IOCTL_DIR)

12
src/ioctl.hpp

@ -27,11 +27,11 @@ namespace mergerfs
namespace fuse
{
int
ioctl(const char *fusepath,
int cmd,
void *arg,
struct fuse_file_info *fi,
unsigned int flags,
void *data);
ioctl(const char *fusepath,
int cmd,
void *arg,
fuse_file_info *fi,
unsigned int flags,
void *data);
}
}

4
src/link.cpp

@ -110,8 +110,8 @@ namespace mergerfs
link(const char *from,
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 rwlock::ReadGuard readlock(&config.srcmountslock);

4
src/listxattr.cpp

@ -109,12 +109,12 @@ namespace mergerfs
char *list,
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)
return _listxattr_controlfile(list,size);
const struct fuse_context *fc = fuse_get_context();
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
const rwlock::ReadGuard readlock(&config.srcmountslock);

6
src/mergerfs.cpp

@ -168,9 +168,9 @@ namespace mergerfs
main(const int argc,
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.argv = argv;

4
src/mkdir.cpp

@ -94,8 +94,8 @@ namespace mergerfs
mkdir(const char *fusepath,
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 rwlock::ReadGuard readlock(&config.srcmountslock);

4
src/mknod.cpp

@ -97,8 +97,8 @@ namespace mergerfs
mode_t mode,
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 rwlock::ReadGuard readlock(&config.srcmountslock);

8
src/open.cpp

@ -73,11 +73,11 @@ namespace mergerfs
namespace fuse
{
int
open(const char *fusepath,
struct fuse_file_info *fileinfo)
open(const char *fusepath,
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 rwlock::ReadGuard readlock(&config.srcmountslock);

4
src/open.hpp

@ -29,7 +29,7 @@ namespace mergerfs
namespace fuse
{
int
open(const char *fusepath,
struct fuse_file_info *fileinfo);
open(const char *fusepath,
fuse_file_info *fileinfo);
}
}

4
src/opendir.cpp

@ -29,8 +29,8 @@ namespace mergerfs
namespace fuse
{
int
opendir(const char *fusepath,
struct fuse_file_info *ffi)
opendir(const char *fusepath,
fuse_file_info *ffi)
{
ffi->fh = 0;

4
src/opendir.hpp

@ -29,7 +29,7 @@ namespace mergerfs
namespace fuse
{
int
opendir(const char *fusepath,
struct fuse_file_info *ffi);
opendir(const char *fusepath,
fuse_file_info *ffi);
}
}

44
src/option_parser.cpp

@ -45,7 +45,7 @@ using namespace mergerfs;
static
void
set_option(struct fuse_args &args,
set_option(fuse_args &args,
const std::string &option_)
{
string option;
@ -57,7 +57,7 @@ set_option(struct fuse_args &args,
static
void
set_kv_option(struct fuse_args &args,
set_kv_option(fuse_args &args,
const std::string &key,
const std::string &value)
{
@ -70,7 +70,7 @@ set_kv_option(struct fuse_args &args,
static
void
set_fsname(struct fuse_args &args,
set_fsname(fuse_args &args,
const vector<string> &srcmounts)
{
if(srcmounts.size() > 0)
@ -85,14 +85,14 @@ set_fsname(struct fuse_args &args,
static
void
set_subtype(struct fuse_args &args)
set_subtype(fuse_args &args)
{
set_kv_option(args,"subtype","mergerfs");
}
static
void
set_default_options(struct fuse_args &args)
set_default_options(fuse_args &args)
{
// set_option(args,"big_writes");
// set_option(args,"splice_read");
@ -118,9 +118,9 @@ parse_and_process_minfreespace(const std::string &value,
static
int
parse_and_process_arg(config::Config &config,
parse_and_process_arg(Config &config,
const std::string &arg,
struct fuse_args *outargs)
fuse_args *outargs)
{
if(arg == "defaults")
{
@ -133,7 +133,7 @@ parse_and_process_arg(config::Config &config,
static
int
parse_and_process_kv_arg(config::Config &config,
parse_and_process_kv_arg(Config &config,
const std::string &key,
const std::string &value)
{
@ -162,9 +162,9 @@ parse_and_process_kv_arg(config::Config &config,
static
int
process_opt(config::Config &config,
process_opt(Config &config,
const std::string &arg,
struct fuse_args *outargs)
fuse_args *outargs)
{
int rv;
std::vector<std::string> argvalue;
@ -191,8 +191,8 @@ process_opt(config::Config &config,
static
int
process_srcmounts(const char *arg,
config::Config &config)
process_srcmounts(const char *arg,
Config &config)
{
vector<string> paths;
@ -205,8 +205,8 @@ process_srcmounts(const char *arg,
static
int
process_destmounts(const char *arg,
config::Config &config)
process_destmounts(const char *arg,
Config &config)
{
config.destmount = arg;
@ -215,13 +215,13 @@ process_destmounts(const char *arg,
static
int
option_processor(void *data,
const char *arg,
int key,
struct fuse_args *outargs)
option_processor(void *data,
const char *arg,
int key,
fuse_args *outargs)
{
int rv = 0;
config::Config &config = *(config::Config*)data;
int rv = 0;
Config &config = *(Config*)data;
switch(key)
{
@ -247,8 +247,8 @@ namespace mergerfs
namespace options
{
void
parse(struct fuse_args &args,
config::Config &config)
parse(fuse_args &args,
Config &config)
{
fuse_opt_parse(&args,

4
src/option_parser.hpp

@ -31,7 +31,7 @@ namespace mergerfs
namespace options
{
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++)
{
const char *basepath;
const string &basepath = basepaths[i];
basepath = basepaths[i].c_str();
fullpath = fs::path::make(basepath,fusepath);
rv = ::lstat(fullpath.c_str(),&st);
@ -58,7 +57,23 @@ _all(const vector<string> &basepaths,
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
@ -70,6 +85,9 @@ namespace mergerfs
const size_t minfreespace,
vector<string> &paths)
{
if(type == Category::Enum::create)
return _all_create(basepaths,paths);
return _all(basepaths,fusepath,paths);
}
}

69
src/policy_epmfs.cpp

@ -40,12 +40,12 @@ using std::size_t;
static
inline
void
_calc_epmfs(const struct statvfs &fsstats,
const char *basepath,
fsblkcnt_t &epmfs,
const char *&epmfsbasepath,
fsblkcnt_t &mfs,
const char *&mfsbasepath)
_calc_epmfs(const struct statvfs &fsstats,
const string &basepath,
fsblkcnt_t &epmfs,
string &epmfsbasepath,
fsblkcnt_t &mfs,
string &mfsbasepath)
{
fsblkcnt_t spaceavail;
@ -66,10 +66,10 @@ _calc_epmfs(const struct statvfs &fsstats,
static
inline
void
_calc_mfs(const struct statvfs &fsstats,
const char *basepath,
fsblkcnt_t &mfs,
const char *&mfsbasepath)
_calc_mfs(const struct statvfs &fsstats,
const string &basepath,
fsblkcnt_t &mfs,
string &mfsbasepath)
{
fsblkcnt_t spaceavail;
@ -84,12 +84,12 @@ _calc_mfs(const struct statvfs &fsstats,
static
inline
int
_try_statvfs(const char *basepath,
const string &fullpath,
fsblkcnt_t &epmfs,
const char *&epmfsbasepath,
fsblkcnt_t &mfs,
const char *&mfsbasepath)
_try_statvfs(const string &basepath,
const string &fullpath,
fsblkcnt_t &epmfs,
string &epmfsbasepath,
fsblkcnt_t &mfs,
string &mfsbasepath)
{
int rv;
struct statvfs fsstats;
@ -104,14 +104,14 @@ _try_statvfs(const char *basepath,
static
inline
int
_try_statvfs(const char *basepath,
fsblkcnt_t &mfs,
const char *&mfsbasepath)
_try_statvfs(const string &basepath,
fsblkcnt_t &mfs,
string &mfsbasepath)
{
int rv;
struct statvfs fsstats;
rv = ::statvfs(basepath,&fsstats);
rv = ::statvfs(basepath.c_str(),&fsstats);
if(rv == 0)
_calc_mfs(fsstats,basepath,mfs,mfsbasepath);
@ -125,22 +125,19 @@ _epmfs_create(const vector<string> &basepaths,
vector<string> &paths)
{
fsblkcnt_t epmfs;
fsblkcnt_t mfs;
const char *basepath;
const char *mfsbasepath;
const char *epmfsbasepath;
string fullpath;
fsblkcnt_t epmfs;
fsblkcnt_t mfs;
string mfsbasepath;
string epmfsbasepath;
string fullpath;
mfs = 0;
epmfs = 0;
mfsbasepath = NULL;
epmfsbasepath = NULL;
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
{
int rv;
const string &basepath = basepaths[i];
basepath = basepaths[i].c_str();
fullpath = fs::path::make(basepath,fusepath);
rv = _try_statvfs(basepath,fusepath,epmfs,epmfsbasepath,mfs,mfsbasepath);
@ -148,7 +145,7 @@ _epmfs_create(const vector<string> &basepaths,
_try_statvfs(basepath,mfs,mfsbasepath);
}
if(epmfsbasepath == NULL)
if(epmfsbasepath.empty())
epmfsbasepath = mfsbasepath;
paths.push_back(epmfsbasepath);
@ -163,19 +160,17 @@ _epmfs(const vector<string> &basepaths,
vector<string> &paths)
{
fsblkcnt_t epmfs;
const char *basepath;
const char *epmfsbasepath;
string fullpath;
fsblkcnt_t epmfs;
string epmfsbasepath;
string fullpath;
epmfs = 0;
epmfsbasepath = NULL;
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
{
int rv;
struct statvfs fsstats;
const string &basepath = basepaths[i];
basepath = basepaths[i].c_str();
fullpath = fs::path::make(basepath,fusepath);
rv = ::statvfs(fullpath.c_str(),&fsstats);
@ -183,7 +178,7 @@ _epmfs(const vector<string> &basepaths,
_calc_mfs(fsstats,basepath,epmfs,epmfsbasepath);
}
if(epmfsbasepath == NULL)
if(epmfsbasepath.empty())
return (errno=ENOENT,-1);
paths.push_back(epmfsbasepath);

26
src/policy_ff.cpp

@ -45,12 +45,11 @@ _ff(const vector<string> &basepaths,
{
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
{
int rv;
struct stat st;
const char *basepath;
string fullpath;
int rv;
struct stat st;
string fullpath;
const string &basepath = basepaths[i];
basepath = basepaths[i].c_str();
fullpath = fs::path::make(basepath,fusepath);
rv = ::lstat(fullpath.c_str(),&st);
@ -65,6 +64,20 @@ _ff(const vector<string> &basepaths,
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
{
int
@ -74,6 +87,9 @@ namespace mergerfs
const size_t minfreespace,
vector<string> &paths)
{
if(type == Category::Enum::create)
return _ff_create(basepaths,fusepath,paths);
return _ff(basepaths,fusepath,paths);
}
}

14
src/policy_ffwp.cpp

@ -42,17 +42,15 @@ _ffwp(const vector<string> &basepaths,
const string &fusepath,
vector<string> &paths)
{
const char *fallback;
string fallback;
fallback = NULL;
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
{
int rv;
struct stat st;
const char *basepath;
string fullpath;
int rv;
struct stat st;
string fullpath;
const string &basepath = basepaths[i];
basepath = basepaths[i].c_str();
fullpath = fs::path::make(basepath,fusepath);
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);
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++)
{
int rv;
const char *basepath;
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)
{
fsblkcnt_t spaceavail;
@ -81,11 +80,11 @@ _fwfs(const Category::Enum::Type type,
{
int rv;
string fullpath;
const char *basepath;
struct statvfs fsstats;
const string &basepath = basepaths[i];
basepath = basepaths[i].c_str();
fullpath = fs::path::make(basepath,fusepath);
rv = ::statvfs(fullpath.c_str(),&fsstats);
if(rv == 0)
{

23
src/policy_lfs.cpp

@ -47,19 +47,17 @@ _lfs_create(const Category::Enum::Type type,
const size_t minfreespace,
vector<string> &paths)
{
fsblkcnt_t lfs;
const char *lfsstr;
fsblkcnt_t lfs;
string lfsstr;
lfs = -1;
lfsstr = NULL;
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
{
int rv;
const char *basepath;
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)
{
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);
paths.push_back(lfsstr);
@ -90,20 +88,19 @@ _lfs(const Category::Enum::Type type,
const size_t minfreespace,
vector<string> &paths)
{
fsblkcnt_t lfs;
const char *lfsstr;
fsblkcnt_t lfs;
string lfsstr;
lfs = -1;
lfsstr = NULL;
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
{
int rv;
string fullpath;
const char *basepath;
struct statvfs fsstats;
const string &basepath = basepaths[i];
basepath = basepaths[i].c_str();
fullpath = fs::path::make(basepath,fusepath);
rv = ::statvfs(fullpath.c_str(),&fsstats);
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);
paths.push_back(lfsstr);

23
src/policy_mfs.cpp

@ -40,19 +40,17 @@ _mfs_create(const vector<string> &basepaths,
const string &fusepath,
vector<string> &paths)
{
fsblkcnt_t mfs;
const char *mfsstr;
fsblkcnt_t mfs;
string mfsstr;
mfs = 0;
mfsstr = NULL;
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
{
int rv;
const char *basepath;
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)
{
fsblkcnt_t spaceavail;
@ -66,7 +64,7 @@ _mfs_create(const vector<string> &basepaths,
}
}
if(mfsstr == NULL)
if(mfsstr.empty())
return (errno=ENOENT,-1);
paths.push_back(mfsstr);
@ -80,20 +78,19 @@ _mfs(const vector<string> &basepaths,
const string &fusepath,
vector<string> &paths)
{
fsblkcnt_t mfs;
const char *mfsstr;
fsblkcnt_t mfs;
string mfsstr;
mfs = 0;
mfsstr = NULL;
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
{
int rv;
string fullpath;
const char *basepath;
struct statvfs fsstats;
const string &basepath = basepaths[i];
basepath = basepaths[i].c_str();
fullpath = fs::path::make(basepath,fusepath);
rv = ::statvfs(fullpath.c_str(),&fsstats);
if(rv == 0)
{
@ -108,7 +105,7 @@ _mfs(const vector<string> &basepaths,
}
}
if(mfsstr == NULL)
if(mfsstr.empty())
return (errno=ENOENT,-1);
paths.push_back(mfsstr);

15
src/policy_newest.cpp

@ -43,17 +43,16 @@ _newest(const vector<string> &basepaths,
const string &fusepath,
vector<string> &paths)
{
time_t newest = std::numeric_limits<time_t>::min();
const char *neweststr = NULL;
time_t newest = std::numeric_limits<time_t>::min();
string neweststr;
for(size_t i = 0, ei = basepaths.size(); i != ei; i++)
{
int rv;
struct stat st;
const char *basepath;
string fullpath;
int rv;
struct stat st;
string fullpath;
const string &basepath = basepaths[i];
basepath = basepaths[i].c_str();
fullpath = fs::path::make(basepath,fusepath);
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);
paths.push_back(neweststr);

10
src/read.cpp

@ -49,11 +49,11 @@ namespace mergerfs
namespace fuse
{
int
read(const char *fusepath,
char *buf,
size_t count,
off_t offset,
struct fuse_file_info *ffi)
read(const char *fusepath,
char *buf,
size_t count,
off_t offset,
fuse_file_info *ffi)
{
return _read(ffi->fh,
buf,

10
src/read.hpp

@ -27,10 +27,10 @@ namespace mergerfs
namespace fuse
{
int
read(const char *fusepath,
char *buf,
size_t count,
off_t offset,
struct fuse_file_info *fi);
read(const char *fusepath,
char *buf,
size_t count,
off_t offset,
fuse_file_info *fi);
}
}

22
src/read_buf.cpp

@ -32,14 +32,14 @@
static
int
_read_buf(const int fd,
struct fuse_bufvec **bufp,
const size_t size,
const off_t offset)
_read_buf(const int fd,
fuse_bufvec **bufp,
const size_t size,
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)
return -ENOMEM;
@ -59,11 +59,11 @@ namespace mergerfs
namespace fuse
{
int
read_buf(const char *fusepath,
struct fuse_bufvec **bufp,
size_t size,
off_t offset,
struct fuse_file_info *ffi)
read_buf(const char *fusepath,
fuse_bufvec **bufp,
size_t size,
off_t offset,
fuse_file_info *ffi)
{
return _read_buf(ffi->fh,
bufp,

10
src/read_buf.hpp

@ -27,10 +27,10 @@ namespace mergerfs
namespace fuse
{
int
read_buf(const char *fusepath,
struct fuse_bufvec **buf,
size_t size,
off_t offset,
struct fuse_file_info *fi);
read_buf(const char *fusepath,
fuse_bufvec **buf,
size_t size,
off_t offset,
fuse_file_info *fi);
}
}

14
src/readdir.cpp

@ -90,14 +90,14 @@ namespace mergerfs
namespace fuse
{
int
readdir(const char *fusepath,
void *buf,
fuse_fill_dir_t filler,
off_t offset,
struct fuse_file_info *fi)
readdir(const char *fusepath,
void *buf,
fuse_fill_dir_t filler,
off_t offset,
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 rwlock::ReadGuard readlock(&config.srcmountslock);

10
src/readdir.hpp

@ -39,11 +39,11 @@ namespace mergerfs
namespace fuse
{
int
readdir(const char *fusepath,
void *buf,
fuse_fill_dir_t filler,
off_t offset,
struct fuse_file_info *fi);
readdir(const char *fusepath,
void *buf,
fuse_fill_dir_t filler,
off_t offset,
fuse_file_info *fi);
}
}

4
src/readlink.cpp

@ -75,8 +75,8 @@ namespace mergerfs
char *buf,
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 rwlock::ReadGuard readlock(&config.srcmountslock);

4
src/release.cpp

@ -45,8 +45,8 @@ namespace mergerfs
namespace fuse
{
int
release(const char *fusepath,
struct fuse_file_info *ffi)
release(const char *fusepath,
fuse_file_info *ffi)
{
return _release(ffi->fh);
}

4
src/release.hpp

@ -27,7 +27,7 @@ namespace mergerfs
namespace fuse
{
int
release(const char *fusepath,
struct fuse_file_info *fi);
release(const char *fusepath,
fuse_file_info *fi);
}
}

4
src/releasedir.cpp

@ -29,8 +29,8 @@ namespace mergerfs
namespace fuse
{
int
releasedir(const char *fusepath,
struct fuse_file_info *ffi)
releasedir(const char *fusepath,
fuse_file_info *ffi)
{
return 0;
}

4
src/releasedir.hpp

@ -29,7 +29,7 @@ namespace mergerfs
namespace fuse
{
int
releasedir(const char *fusepath,
struct fuse_file_info *ffi);
releasedir(const char *fusepath,
fuse_file_info *ffi);
}
}

8
src/removexattr.cpp

@ -81,14 +81,14 @@ namespace mergerfs
removexattr(const char *fusepath,
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)
return -ENOTSUP;
const struct fuse_context *fc = fuse_get_context();
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
const rwlock::ReadGuard readlock(&config.srcmountslock);
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
const rwlock::ReadGuard readlock(&config.srcmountslock);
return _removexattr(config.removexattr,
config.srcmounts,

4
src/rename.cpp

@ -113,8 +113,8 @@ namespace mergerfs
rename(const char *oldpath,
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 rwlock::ReadGuard readlock(&config.srcmountslock);

4
src/rmdir.cpp

@ -73,8 +73,8 @@ namespace mergerfs
int
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 rwlock::ReadGuard readguard(&config.srcmountslock);

60
src/setxattr.cpp

@ -168,9 +168,9 @@ _setxattr_srcmounts(vector<string> &srcmounts,
static
int
_setxattr_minfreespace(config::Config &config,
const string &attrval,
const int flags)
_setxattr_minfreespace(Config &config,
const string &attrval,
const int flags)
{
int rv;
@ -186,10 +186,10 @@ _setxattr_minfreespace(config::Config &config,
static
int
_setxattr_controlfile_func_policy(config::Config &config,
const char *funcname,
const string &attrval,
const int flags)
_setxattr_controlfile_func_policy(Config &config,
const char *funcname,
const string &attrval,
const int flags)
{
int rv;
@ -205,10 +205,10 @@ _setxattr_controlfile_func_policy(config::Config &config,
static
int
_setxattr_controlfile_category_policy(config::Config &config,
const char *categoryname,
const string &attrval,
const int flags)
_setxattr_controlfile_category_policy(Config &config,
const char *categoryname,
const string &attrval,
const int flags)
{
int rv;
@ -224,10 +224,10 @@ _setxattr_controlfile_category_policy(config::Config &config,
static
int
_setxattr_controlfile(config::Config &config,
const char *attrname,
const string &attrval,
const int flags)
_setxattr_controlfile(Config &config,
const char *attrname,
const string &attrval,
const int flags)
{
const char *attrbasename = &attrname[sizeof("user.mergerfs.")-1];
@ -307,33 +307,31 @@ namespace mergerfs
size_t attrvalsize,
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((fc->uid != ::getuid()) && (fc->gid != ::getgid()))
return -EPERM;
return _setxattr_controlfile(config::get_writable(),
return _setxattr_controlfile(Config::get_writable(),
attrname,
string(attrval,attrvalsize),
flags);
}
{
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
const rwlock::ReadGuard readlock(&config.srcmountslock);
return _setxattr(config.setxattr,
config.srcmounts,
config.minfreespace,
fusepath,
attrname,
attrval,
attrvalsize,
flags);
}
const ugid::SetResetGuard ugid(fc->uid,fc->gid);
const rwlock::ReadGuard readlock(&config.srcmountslock);
return _setxattr(config.setxattr,
config.srcmounts,
config.minfreespace,
fusepath,
attrname,
attrval,
attrvalsize,
flags);
}
}
}

4
src/statfs.cpp

@ -124,8 +124,8 @@ namespace mergerfs
statfs(const char *fusepath,
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 rwlock::ReadGuard readlock(&config.srcmountslock);

4
src/symlink.cpp

@ -77,8 +77,8 @@ namespace mergerfs
symlink(const char *oldpath,
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 rwlock::ReadGuard readlock(&config.srcmountslock);

4
src/truncate.cpp

@ -77,8 +77,8 @@ namespace mergerfs
truncate(const char *fusepath,
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 rwlock::ReadGuard readlock(&config.srcmountslock);

4
src/unlink.cpp

@ -74,8 +74,8 @@ namespace mergerfs
int
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 rwlock::ReadGuard readlock(&config.srcmountslock);

18
src/utimens.cpp

@ -42,11 +42,11 @@ using mergerfs::Policy;
static
int
_utimens(Policy::Func::Action actionFunc,
const vector<string> &srcmounts,
const size_t minfreespace,
const string &fusepath,
const struct timespec ts[2])
_utimens(Policy::Func::Action actionFunc,
const vector<string> &srcmounts,
const size_t minfreespace,
const string &fusepath,
const timespec ts[2])
{
int rv;
int error;
@ -74,11 +74,11 @@ namespace mergerfs
namespace fuse
{
int
utimens(const char *fusepath,
const struct timespec ts[2])
utimens(const char *fusepath,
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 rwlock::ReadGuard readlock(&config.srcmountslock);

4
src/utimens.hpp

@ -27,7 +27,7 @@ namespace mergerfs
namespace fuse
{
int
utimens(const char *fusepath,
const struct timespec ts[2]);
utimens(const char *fusepath,
const timespec ts[2]);
}
}

10
src/write.cpp

@ -46,11 +46,11 @@ namespace mergerfs
namespace fuse
{
int
write(const char *fusepath,
const char *buf,
size_t count,
off_t offset,
struct fuse_file_info *ffi)
write(const char *fusepath,
const char *buf,
size_t count,
off_t offset,
fuse_file_info *ffi)
{
return _write(ffi->fh,
buf,

10
src/write.hpp

@ -27,10 +27,10 @@ namespace mergerfs
namespace fuse
{
int
write(const char *fusepath,
const char *buf,
size_t count,
off_t offset,
struct fuse_file_info *fi);
write(const char *fusepath,
const char *buf,
size_t count,
off_t offset,
fuse_file_info *fi);
}
}

18
src/write_buf.cpp

@ -32,12 +32,12 @@
static
int
_write_buf(const int fd,
struct fuse_bufvec &src,
const off_t offset)
_write_buf(const int fd,
fuse_bufvec &src,
const off_t offset)
{
size_t size = fuse_buf_size(&src);
struct fuse_bufvec dst = FUSE_BUFVEC_INIT(size);
size_t size = fuse_buf_size(&src);
fuse_bufvec dst = FUSE_BUFVEC_INIT(size);
const fuse_buf_copy_flags cpflags =
(fuse_buf_copy_flags)(FUSE_BUF_SPLICE_MOVE|FUSE_BUF_SPLICE_NONBLOCK);
@ -53,10 +53,10 @@ namespace mergerfs
namespace fuse
{
int
write_buf(const char *fusepath,
struct fuse_bufvec *src,
off_t offset,
struct fuse_file_info *ffi)
write_buf(const char *fusepath,
fuse_bufvec *src,
off_t offset,
fuse_file_info *ffi)
{
return _write_buf(ffi->fh,
*src,

8
src/write_buf.hpp

@ -27,9 +27,9 @@ namespace mergerfs
namespace fuse
{
int
write_buf(const char *fusepath,
struct fuse_bufvec *buf,
off_t offset,
struct fuse_file_info *fi);
write_buf(const char *fusepath,
fuse_bufvec *buf,
off_t offset,
fuse_file_info *fi);
}
}
Loading…
Cancel
Save