rework some function error handling

chmod, chown, removexattr, setxattr, truncate, utimens:
* if no errors: return 0
* if no successes: return first error
* if file acted on was the same as related search function: return its value
* return 0

rmdir, unlink:
* if no errors: return 0
* return first error
This commit is contained in:
Antonio SJ Musumeci 2020-09-13 00:25:24 -04:00
parent 24f03b04eb
commit 5a3184359d
14 changed files with 492 additions and 167 deletions

View file

@ -16,9 +16,8 @@
#include "config.hpp"
#include "errno.hpp"
#include "fs_unlink.hpp"
#include "fs_path.hpp"
#include "rv.hpp"
#include "fs_unlink.hpp"
#include "ugid.hpp"
#include <fuse.h>
@ -31,6 +30,24 @@
using std::string;
using std::vector;
namespace error
{
static
inline
int
calc(const int rv_,
const int prev_,
const int cur_)
{
if(prev_ != 0)
return prev_;
if(rv_ == -1)
return cur_;
return 0;
}
}
namespace l
{
static
@ -56,7 +73,7 @@ namespace l
{
int error;
error = -1;
error = 0;
for(size_t i = 0, ei = basepaths_.size(); i != ei; i++)
{
error = l::unlink_loop_core(basepaths_[i],fusepath_,error);