Error when given invalid policy names

This commit is contained in:
Antonio SJ Musumeci 2022-07-09 16:06:18 -04:00
parent faadeb75e0
commit 46ce28b149
5 changed files with 30 additions and 6 deletions

View file

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

View file

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

View file

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

View file

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