config get and struct naming cleanup

This commit is contained in:
Antonio SJ Musumeci 2015-07-21 14:19:17 -04:00
parent 81dbafdc19
commit f130d07fd8
67 changed files with 471 additions and 467 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -38,8 +38,6 @@
namespace mergerfs
{
namespace config
{
class Config
{
public:
@ -82,12 +80,22 @@ namespace mergerfs
public:
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

View File

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

View File

@ -32,6 +32,6 @@ namespace mergerfs
int
create(const char *fusepath,
mode_t mode,
struct fuse_file_info *fileinfo);
fuse_file_info *fileinfo);
}
}

View File

@ -71,7 +71,7 @@ namespace mergerfs
int mode,
off_t offset,
off_t len,
struct fuse_file_info *ffi)
fuse_file_info *ffi)
{
return _fallocate(ffi->fh,
mode,

View File

@ -31,6 +31,6 @@ namespace mergerfs
int mode,
off_t offset,
off_t len,
struct fuse_file_info *fi);
fuse_file_info *fi);
}
}

View File

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

View File

@ -33,6 +33,6 @@ namespace mergerfs
int
fgetattr(const char *fusepath,
struct stat *st,
struct fuse_file_info *fileinfo);
fuse_file_info *fileinfo);
}
}

View File

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

View File

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

View File

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

View File

@ -31,6 +31,6 @@ namespace mergerfs
int
fsync(const char *fusepath,
int isdatasync,
struct fuse_file_info *fi);
fuse_file_info *fi);
}
}

View File

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

View File

@ -34,6 +34,6 @@ namespace mergerfs
int
ftruncate(const char *fusepath,
off_t size,
struct fuse_file_info *fi);
fuse_file_info *fi);
}
}

View File

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

View File

@ -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,7 +254,6 @@ 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);

View File

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

View File

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

View File

@ -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);
@ -120,7 +120,7 @@ namespace mergerfs
ioctl(const char *fusepath,
int cmd,
void *arg,
struct fuse_file_info *ffi,
fuse_file_info *ffi,
unsigned int flags,
void *data)
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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;
@ -192,7 +192,7 @@ process_opt(config::Config &config,
static
int
process_srcmounts(const char *arg,
config::Config &config)
Config &config)
{
vector<string> paths;
@ -206,7 +206,7 @@ process_srcmounts(const char *arg,
static
int
process_destmounts(const char *arg,
config::Config &config)
Config &config)
{
config.destmount = arg;
@ -218,10 +218,10 @@ int
option_processor(void *data,
const char *arg,
int key,
struct fuse_args *outargs)
fuse_args *outargs)
{
int rv = 0;
config::Config &config = *(config::Config*)data;
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,

View File

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

View File

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

View File

@ -41,11 +41,11 @@ static
inline
void
_calc_epmfs(const struct statvfs &fsstats,
const char *basepath,
const string &basepath,
fsblkcnt_t &epmfs,
const char *&epmfsbasepath,
string &epmfsbasepath,
fsblkcnt_t &mfs,
const char *&mfsbasepath)
string &mfsbasepath)
{
fsblkcnt_t spaceavail;
@ -67,9 +67,9 @@ static
inline
void
_calc_mfs(const struct statvfs &fsstats,
const char *basepath,
const string &basepath,
fsblkcnt_t &mfs,
const char *&mfsbasepath)
string &mfsbasepath)
{
fsblkcnt_t spaceavail;
@ -84,12 +84,12 @@ _calc_mfs(const struct statvfs &fsstats,
static
inline
int
_try_statvfs(const char *basepath,
_try_statvfs(const string &basepath,
const string &fullpath,
fsblkcnt_t &epmfs,
const char *&epmfsbasepath,
string &epmfsbasepath,
fsblkcnt_t &mfs,
const char *&mfsbasepath)
string &mfsbasepath)
{
int rv;
struct statvfs fsstats;
@ -104,14 +104,14 @@ _try_statvfs(const char *basepath,
static
inline
int
_try_statvfs(const char *basepath,
_try_statvfs(const string &basepath,
fsblkcnt_t &mfs,
const char *&mfsbasepath)
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);
@ -127,20 +127,17 @@ _epmfs_create(const vector<string> &basepaths,
{
fsblkcnt_t epmfs;
fsblkcnt_t mfs;
const char *basepath;
const char *mfsbasepath;
const char *epmfsbasepath;
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);
@ -164,18 +161,16 @@ _epmfs(const vector<string> &basepaths,
{
fsblkcnt_t epmfs;
const char *basepath;
const char *epmfsbasepath;
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);

View File

@ -47,10 +47,9 @@ _ff(const vector<string> &basepaths,
{
int rv;
struct stat st;
const char *basepath;
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);
}
}

View File

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

View File

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

View File

@ -48,18 +48,16 @@ _lfs_create(const Category::Enum::Type type,
vector<string> &paths)
{
fsblkcnt_t lfs;
const char *lfsstr;
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);
@ -91,19 +89,18 @@ _lfs(const Category::Enum::Type type,
vector<string> &paths)
{
fsblkcnt_t lfs;
const char *lfsstr;
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);

View File

@ -41,18 +41,16 @@ _mfs_create(const vector<string> &basepaths,
vector<string> &paths)
{
fsblkcnt_t mfs;
const char *mfsstr;
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);
@ -81,19 +79,18 @@ _mfs(const vector<string> &basepaths,
vector<string> &paths)
{
fsblkcnt_t mfs;
const char *mfsstr;
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);

View File

@ -44,16 +44,15 @@ _newest(const vector<string> &basepaths,
vector<string> &paths)
{
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++)
{
int rv;
struct stat st;
const char *basepath;
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);

View File

@ -53,7 +53,7 @@ namespace mergerfs
char *buf,
size_t count,
off_t offset,
struct fuse_file_info *ffi)
fuse_file_info *ffi)
{
return _read(ffi->fh,
buf,

View File

@ -31,6 +31,6 @@ namespace mergerfs
char *buf,
size_t count,
off_t offset,
struct fuse_file_info *fi);
fuse_file_info *fi);
}
}

View File

@ -33,13 +33,13 @@
static
int
_read_buf(const int fd,
struct fuse_bufvec **bufp,
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;
@ -60,10 +60,10 @@ namespace mergerfs
{
int
read_buf(const char *fusepath,
struct fuse_bufvec **bufp,
fuse_bufvec **bufp,
size_t size,
off_t offset,
struct fuse_file_info *ffi)
fuse_file_info *ffi)
{
return _read_buf(ffi->fh,
bufp,

View File

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

View File

@ -94,10 +94,10 @@ namespace mergerfs
void *buf,
fuse_fill_dir_t filler,
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 rwlock::ReadGuard readlock(&config.srcmountslock);

View File

@ -43,7 +43,7 @@ namespace mergerfs
void *buf,
fuse_fill_dir_t filler,
off_t offset,
struct fuse_file_info *fi);
fuse_file_info *fi);
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -81,12 +81,12 @@ 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);

View File

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

View File

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

View File

@ -168,7 +168,7 @@ _setxattr_srcmounts(vector<string> &srcmounts,
static
int
_setxattr_minfreespace(config::Config &config,
_setxattr_minfreespace(Config &config,
const string &attrval,
const int flags)
{
@ -186,7 +186,7 @@ _setxattr_minfreespace(config::Config &config,
static
int
_setxattr_controlfile_func_policy(config::Config &config,
_setxattr_controlfile_func_policy(Config &config,
const char *funcname,
const string &attrval,
const int flags)
@ -205,7 +205,7 @@ _setxattr_controlfile_func_policy(config::Config &config,
static
int
_setxattr_controlfile_category_policy(config::Config &config,
_setxattr_controlfile_category_policy(Config &config,
const char *categoryname,
const string &attrval,
const int flags)
@ -224,7 +224,7 @@ _setxattr_controlfile_category_policy(config::Config &config,
static
int
_setxattr_controlfile(config::Config &config,
_setxattr_controlfile(Config &config,
const char *attrname,
const string &attrval,
const int flags)
@ -307,21 +307,20 @@ 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);
@ -335,5 +334,4 @@ namespace mergerfs
flags);
}
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -46,7 +46,7 @@ _utimens(Policy::Func::Action actionFunc,
const vector<string> &srcmounts,
const size_t minfreespace,
const string &fusepath,
const struct timespec ts[2])
const timespec ts[2])
{
int rv;
int error;
@ -75,10 +75,10 @@ namespace mergerfs
{
int
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 rwlock::ReadGuard readlock(&config.srcmountslock);

View File

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

View File

@ -50,7 +50,7 @@ namespace mergerfs
const char *buf,
size_t count,
off_t offset,
struct fuse_file_info *ffi)
fuse_file_info *ffi)
{
return _write(ffi->fh,
buf,

View File

@ -31,6 +31,6 @@ namespace mergerfs
const char *buf,
size_t count,
off_t offset,
struct fuse_file_info *fi);
fuse_file_info *fi);
}
}

View File

@ -33,11 +33,11 @@
static
int
_write_buf(const int fd,
struct fuse_bufvec &src,
fuse_bufvec &src,
const off_t offset)
{
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 =
(fuse_buf_copy_flags)(FUSE_BUF_SPLICE_MOVE|FUSE_BUF_SPLICE_NONBLOCK);
@ -54,9 +54,9 @@ namespace mergerfs
{
int
write_buf(const char *fusepath,
struct fuse_bufvec *src,
fuse_bufvec *src,
off_t offset,
struct fuse_file_info *ffi)
fuse_file_info *ffi)
{
return _write_buf(ffi->fh,
*src,

View File

@ -28,8 +28,8 @@ namespace mergerfs
{
int
write_buf(const char *fusepath,
struct fuse_bufvec *buf,
fuse_bufvec *buf,
off_t offset,
struct fuse_file_info *fi);
fuse_file_info *fi);
}
}