Browse Source

Merge pull request #1057 from trapexit/cfgerrs

Error when given invalid policy names
pull/1058/head
trapexit 2 years ago
committed by GitHub
parent
commit
d1762b2bac
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      man/mergerfs.1
  2. 2
      src/category.cpp
  3. 6
      src/func.cpp
  4. 3
      src/mergerfs.cpp
  5. 15
      src/policy.hpp

8
man/mergerfs.1

@ -704,8 +704,8 @@ Even though it\[cq]s a more niche situation this hack breaks normal
security and behavior and as such is \f[C]off\f[R] by default. security and behavior and as such is \f[C]off\f[R] by default.
If set to \f[C]git\f[R] it will only perform the hack when the path in If set to \f[C]git\f[R] it will only perform the hack when the path in
question includes \f[C]/.git/\f[R]. question includes \f[C]/.git/\f[R].
\f[C]all\f[R] will result it applying anytime a readonly file which
is empty is opened for writing.
\f[C]all\f[R] will result it applying anytime a readonly file which is
empty is opened for writing.
.SH FUNCTIONS, CATEGORIES and POLICIES .SH FUNCTIONS, CATEGORIES and POLICIES
.PP .PP
The POSIX filesystem API is made up of a number of functions. The POSIX filesystem API is made up of a number of functions.
@ -1643,7 +1643,7 @@ Fast network, slow drives, small\[cq]ish bursty writes: You have a
10+Gbps network and wish to transfer amounts of data less than your 10+Gbps network and wish to transfer amounts of data less than your
cache drive but wish to do so quickly. cache drive but wish to do so quickly.
.PP .PP
With #1 it's arguable if you should be using mergerfs at all.
With #1 it\[cq]s arguable if you should be using mergerfs at all.
RAID would probably be the better solution. RAID would probably be the better solution.
If you\[cq]re going to use mergerfs there are other tactics that may If you\[cq]re going to use mergerfs there are other tactics that may
help: spreading the data across drives (see the mergerfs.dup tool) and help: spreading the data across drives (see the mergerfs.dup tool) and
@ -1963,7 +1963,7 @@ efficiently determine whether to scan for new content rather than simply
performing a full scan. performing a full scan.
If using the default \f[B]getattr\f[R] policy of \f[B]ff\f[R] it\[cq]s If using the default \f[B]getattr\f[R] policy of \f[B]ff\f[R] it\[cq]s
possible those programs will miss an update on account of it returning possible those programs will miss an update on account of it returning
the first directory found\[cq]s \f[B]stat\f[R] info and its a later
the first directory found\[cq]s \f[B]stat\f[R] info and it\[cq]s a later
directory on another mount which had the \f[B]mtime\f[R] recently directory on another mount which had the \f[B]mtime\f[R] recently
updated. updated.
To fix this you will want to set \f[B]func.getattr=newest\f[R]. To fix this you will want to set \f[B]func.getattr=newest\f[R].

2
src/category.cpp

@ -42,7 +42,7 @@ Category::Base::to_string(void) const
{ {
std::set<std::string> rv; std::set<std::string> rv;
for(auto func : funcs)
for(const auto func : funcs)
rv.insert(func->to_string()); rv.insert(func->to_string());
return str::join(rv,','); return str::join(rv,',');

6
src/func.cpp

@ -23,6 +23,8 @@ int
Func::Base::Action::from_string(const std::string &policyname_) Func::Base::Action::from_string(const std::string &policyname_)
{ {
policy = Policies::Action::find(policyname_); policy = Policies::Action::find(policyname_);
if(!policy)
return -EINVAL;
return 0; return 0;
} }
@ -37,6 +39,8 @@ int
Func::Base::Create::from_string(const std::string &policyname_) Func::Base::Create::from_string(const std::string &policyname_)
{ {
policy = Policies::Create::find(policyname_); policy = Policies::Create::find(policyname_);
if(!policy)
return -EINVAL;
return 0; return 0;
} }
@ -51,6 +55,8 @@ int
Func::Base::Search::from_string(const std::string &policyname_) Func::Base::Search::from_string(const std::string &policyname_)
{ {
policy = Policies::Search::find(policyname_); policy = Policies::Search::find(policyname_);
if(!policy)
return -EINVAL;
return 0; return 0;
} }

3
src/mergerfs.cpp

@ -164,7 +164,10 @@ namespace l
options::parse(&args,&errs); options::parse(&args,&errs);
if(errs.size()) if(errs.size())
{
std::cerr << errs << std::endl; std::cerr << errs << std::endl;
return 1;
}
l::setup_resources(); l::setup_resources();
l::get_fuse_operations(ops,cfg->nullrw); l::get_fuse_operations(ops,cfg->nullrw);

15
src/policy.hpp

@ -73,6 +73,11 @@ namespace Policy
return (*impl)(branches_,fusepath_.c_str(),paths_); return (*impl)(branches_,fusepath_.c_str(),paths_);
} }
operator bool() const
{
return (bool)impl;
}
private: private:
ActionImpl *impl; ActionImpl *impl;
}; };
@ -134,6 +139,11 @@ namespace Policy
return (*impl)(branches_,fusepath_.c_str(),paths_); return (*impl)(branches_,fusepath_.c_str(),paths_);
} }
operator bool() const
{
return (bool)impl;
}
private: private:
CreateImpl *impl; CreateImpl *impl;
}; };
@ -188,6 +198,11 @@ namespace Policy
return (*impl)(branches_,fusepath_.c_str(),paths_); return (*impl)(branches_,fusepath_.c_str(),paths_);
} }
operator bool() const
{
return (bool)impl;
}
private: private:
SearchImpl *impl; SearchImpl *impl;
}; };

Loading…
Cancel
Save