restructure error calculation

This commit is contained in:
Antonio SJ Musumeci 2016-12-21 00:00:00 -05:00
parent 078e4bab49
commit 726b88e039
14 changed files with 31 additions and 28 deletions

View file

@ -45,7 +45,7 @@ _chmod_loop_core(const string *basepath,
rv = fs::chmod(fullpath,mode);
return calc_error(rv,error,errno);
return error::calc(rv,error,errno);
}
static

View file

@ -47,7 +47,7 @@ _chown_loop_core(const string *basepath,
rv = fs::lchown(fullpath,uid,gid);
return calc_error(rv,error,errno);
return error::calc(rv,error,errno);
}
static

View file

@ -59,7 +59,7 @@ _link_create_path_core(const string &oldbasepath,
rv = fs::link(oldfullpath,newfullpath);
return calc_error(rv,error,errno);
return error::calc(rv,error,errno);
}
static
@ -176,7 +176,7 @@ _link_preserve_path_core(Policy::Func::Search searchFunc,
rv = fs::link(oldfullpath,newfullpath);
}
return calc_error(rv,error,errno);
return error::calc(rv,error,errno);
}
static

View file

@ -71,7 +71,7 @@ _mkdir_loop_core(const string &existingpath,
rv = _mkdir_core(fullpath,mode,umask);
return calc_error(rv,error,errno);
return error::calc(rv,error,errno);
}
static

View file

@ -73,7 +73,7 @@ _mknod_loop_core(const string &existingpath,
rv = _mknod_core(fullpath,mode,umask,dev);
return calc_error(rv,error,errno);
return error::calc(rv,error,errno);
}
static

View file

@ -45,7 +45,7 @@ _removexattr_loop_core(const string *basepath,
rv = fs::lremovexattr(fullpath,attrname);
return calc_error(rv,error,errno);
return error::calc(rv,error,errno);
}
static

View file

@ -103,7 +103,7 @@ _rename_create_path_core(const vector<const string*> &oldbasepaths,
rv = _rename(oldbasepath,oldfullpath,
newbasepath,newfusedirpath,newfullpath);
error = calc_error(rv,error,errno);
error = error::calc(rv,error,errno);
if(RENAME_FAILED(rv))
tounlink.push_back(oldfullpath);
}
@ -241,7 +241,7 @@ _rename_preserve_path_core(Policy::Func::Search searchFunc,
rv = fs::rename(oldfullpath,newfullpath);
}
error = calc_error(rv,error,errno);
error = error::calc(rv,error,errno);
if(RENAME_FAILED(rv))
toremove.push_back(oldfullpath);
}

View file

@ -45,7 +45,7 @@ _rmdir_loop_core(const string *basepath,
rv = fs::rmdir(fullpath);
return calc_error(rv,error,errno);
return error::calc(rv,error,errno);
}

View file

@ -17,21 +17,24 @@
#ifndef __RV_HPP__
#define __RV_HPP__
static
inline
int
calc_error(const int rv,
const int prev,
const int cur)
namespace error
{
if(rv == -1)
{
if(prev == 0)
return 0;
return cur;
}
static
inline
int
calc(const int rv,
const int prev,
const int cur)
{
if(rv == -1)
{
if(prev == 0)
return 0;
return cur;
}
return 0;
return 0;
}
}
#endif // __RV_HPP__

View file

@ -303,7 +303,7 @@ _setxattr_loop_core(const string *basepath,
rv = fs::lsetxattr(fullpath,attrname,attrval,attrvalsize,flags);
return calc_error(rv,error,errno);
return error::calc(rv,error,errno);
}
static

View file

@ -58,7 +58,7 @@ _symlink_loop_core(const string &existingpath,
rv = ::symlink(oldpath,fullnewpath.c_str());
return calc_error(rv,error,errno);
return error::calc(rv,error,errno);
}
static

View file

@ -48,7 +48,7 @@ _truncate_loop_core(const string *basepath,
rv = fs::truncate(fullpath,size);
return calc_error(rv,error,errno);
return error::calc(rv,error,errno);
}
static

View file

@ -46,7 +46,7 @@ _unlink_loop_core(const string *basepath,
rv = fs::unlink(fullpath);
return calc_error(rv,error,errno);
return error::calc(rv,error,errno);
}
static

View file

@ -47,7 +47,7 @@ _utimens_loop_core(const string *basepath,
rv = fs::lutime(fullpath,ts);
return calc_error(rv,error,errno);
return error::calc(rv,error,errno);
}
static