Browse Source

find functions now return errors. closes #24

pull/37/merge 1.4.1
Antonio SJ Musumeci 10 years ago
parent
commit
cfe7609bcd
  1. 6
      src/access.cpp
  2. 6
      src/chmod.cpp
  3. 6
      src/chown.cpp
  4. 13
      src/create.cpp
  5. 58
      src/fs.cpp
  6. 50
      src/fs.hpp
  7. 6
      src/getattr.cpp
  8. 6
      src/getxattr.cpp
  9. 6
      src/link.cpp
  10. 6
      src/listxattr.cpp
  11. 8
      src/mkdir.cpp
  12. 6
      src/mknod.cpp
  13. 9
      src/open.cpp
  14. 6
      src/readlink.cpp
  15. 6
      src/removexattr.cpp
  16. 6
      src/rename.cpp
  17. 6
      src/rmdir.cpp
  18. 6
      src/setxattr.cpp
  19. 6
      src/truncate.cpp
  20. 6
      src/unlink.cpp
  21. 6
      src/utimens.cpp

6
src/access.cpp

@ -53,9 +53,9 @@ _access(const fs::SearchFunc searchFunc,
int rv;
fs::PathVector path;
searchFunc(srcmounts,fusepath,path);
if(path.empty())
return -ENOENT;
rv = searchFunc(srcmounts,fusepath,path);
if(rv == -1)
return -errno;
rv = ::eaccess(path[0].full.c_str(),mask);

6
src/chmod.cpp

@ -48,9 +48,9 @@ _chmod(const fs::SearchFunc searchFunc,
int error;
fs::PathVector paths;
searchFunc(srcmounts,fusepath,paths);
if(paths.empty())
return -ENOENT;
rv = searchFunc(srcmounts,fusepath,paths);
if(rv == -1)
return -errno;
rv = -1;
error = 0;

6
src/chown.cpp

@ -50,9 +50,9 @@ _chown(const fs::SearchFunc searchFunc,
int error;
fs::PathVector paths;
searchFunc(srcmounts,fusepath,paths);
if(paths.empty())
return -ENOENT;
rv = searchFunc(srcmounts,fusepath,paths);
if(rv == -1)
return -errno;
rv = -1;
error = 0;

13
src/create.cpp

@ -54,19 +54,20 @@ _create(const fs::SearchFunc searchFunc,
uint64_t &fh)
{
int fd;
int rv;
string path;
string dirname;
fs::PathVector createpath;
fs::PathVector existingpath;
dirname = fs::dirname(fusepath);
searchFunc(srcmounts,dirname,existingpath);
if(existingpath.empty())
return -ENOENT;
rv = searchFunc(srcmounts,dirname,existingpath);
if(rv == -1)
return -errno;
createPathFunc(srcmounts,dirname,createpath);
if(createpath.empty())
return -ENOSPC;
rv = createPathFunc(srcmounts,dirname,createpath);
if(rv == -1)
return -errno;
if(createpath[0].base != existingpath[0].base)
fs::clonepath(existingpath[0].base,createpath[0].base,dirname);

58
src/fs.cpp

@ -490,19 +490,20 @@ namespace fs
namespace find
{
void
int
invalid(const vector<string> &basepaths,
const string fusepath,
PathVector &paths)
{
return;
return (errno = EINVAL,-1);
}
void
int
ff(const vector<string> &basepaths,
const string fusepath,
PathVector &paths)
{
errno = ENOENT;
for(vector<string>::const_iterator
iter = basepaths.begin(), eiter = basepaths.end();
iter != eiter;
@ -515,22 +516,20 @@ namespace fs
path = fs::make_path(*iter,fusepath);
rv = ::lstat(path.c_str(),&st);
if(rv == 0)
{
paths.push_back(Path(*iter,path));
return;
}
return (paths.push_back(Path(*iter,path)),0);
}
return;
return -1;
}
void
int
ffwp(const vector<string> &basepaths,
const string fusepath,
PathVector &paths)
{
Path fallback;
errno = ENOENT;
for(vector<string>::const_iterator
iter = basepaths.begin(), eiter = basepaths.end();
iter != eiter;
@ -544,8 +543,7 @@ namespace fs
rv = ::lstat(path.c_str(),&st);
if(rv == 0)
{
paths.push_back(Path(*iter,path));
return;
return (paths.push_back(Path(*iter,path)),0);
}
else if(errno == EACCES)
{
@ -555,12 +553,12 @@ namespace fs
}
if(!fallback.base.empty())
paths.push_back(fallback);
return (paths.push_back(fallback),0);
return;
return -1;
}
void
int
newest(const vector<string> &basepaths,
const string fusepath,
PathVector &paths)
@ -570,6 +568,7 @@ namespace fs
vector<string>::const_iterator niter;
newest = 0;
errno = ENOENT;
for(vector<string>::const_iterator
iter = basepaths.begin(), eiter = basepaths.end();
iter != eiter;
@ -589,16 +588,17 @@ namespace fs
}
if(newest)
paths.push_back(Path(*niter,npath));
return (paths.push_back(Path(*niter,npath)),0);
return;
return -1;
}
void
int
all(const vector<string> &basepaths,
const string fusepath,
PathVector &paths)
{
errno = ENOENT;
for(vector<string>::const_iterator
iter = basepaths.begin(), eiter = basepaths.end();
iter != eiter;
@ -614,18 +614,20 @@ namespace fs
paths.push_back(Path(*iter,path));
}
return;
return paths.empty() ? -1 : 0;
}
void
int
mfs(const vector<string> &basepaths,
const string fusepath,
PathVector &paths)
{
fsblkcnt_t mfs = 0;
fsblkcnt_t mfs;
string mfspath;
string fullmfspath;
mfs = 0;
errno = ENOENT;
for(vector<string>::const_iterator
iter = basepaths.begin(), eiter = basepaths.end();
iter != eiter;
@ -649,14 +651,17 @@ namespace fs
}
}
if(mfs == 0)
return -1;
fullmfspath = fs::make_path(mfspath,fusepath);
paths.push_back(Path(mfspath,fullmfspath));
return;
return 0;
}
void
int
epmfs(const vector<string> &basepaths,
const string fusepath,
PathVector &paths)
@ -669,6 +674,9 @@ namespace fs
vector<string>::const_iterator iter = basepaths.begin();
vector<string>::const_iterator eiter = basepaths.end();
if(iter == eiter)
return (errno = ENOENT,-1);
do
{
int rv;
@ -709,10 +717,10 @@ namespace fs
paths.push_back(Path(existingmfspath,path));
return;
return 0;
}
void
int
rand(const vector<string> &basepaths,
const string fusepath,
PathVector &paths)
@ -727,6 +735,8 @@ namespace fs
fusepath);
paths.push_back(Path(randombasepath,randomfullpath));
return 0;
}
}
};

50
src/fs.hpp

@ -49,7 +49,7 @@ namespace fs
};
typedef vector<Path> PathVector;
typedef void (*SearchFunc)(const vector<string>&,const string,PathVector&);
typedef int (*SearchFunc)(const vector<string>&,const string,PathVector&);
string dirname(const string path);
string basename(const string path);
@ -112,30 +112,30 @@ namespace fs
namespace find
{
void invalid(const vector<string> &basepaths,
const string fusepath,
PathVector &paths);
void ff(const vector<string> &basepaths,
const string fusepath,
PathVector &paths);
void ffwp(const vector<string> &paths,
const string fusepath,
PathVector &rv);
void newest(const vector<string> &paths,
const string fusepath,
PathVector &rv);
void all(const vector<string> &paths,
const string fusepath,
PathVector &rv);
void mfs(const vector<string> &paths,
const string fusepath,
PathVector &rv);
void epmfs(const vector<string> &paths,
const string fusepath,
PathVector &rv);
void rand(const vector<string> &paths,
const string fusepath,
PathVector &rv);
int invalid(const vector<string> &basepaths,
const string fusepath,
PathVector &paths);
int ff(const vector<string> &basepaths,
const string fusepath,
PathVector &paths);
int ffwp(const vector<string> &paths,
const string fusepath,
PathVector &rv);
int newest(const vector<string> &paths,
const string fusepath,
PathVector &rv);
int all(const vector<string> &paths,
const string fusepath,
PathVector &rv);
int mfs(const vector<string> &paths,
const string fusepath,
PathVector &rv);
int epmfs(const vector<string> &paths,
const string fusepath,
PathVector &rv);
int rand(const vector<string> &paths,
const string fusepath,
PathVector &rv);
}
};

6
src/getattr.cpp

@ -73,9 +73,9 @@ _getattr(const fs::SearchFunc searchFunc,
int rv;
fs::PathVector paths;
searchFunc(srcmounts,fusepath,paths);
if(paths.empty())
return -ENOENT;
rv = searchFunc(srcmounts,fusepath,paths);
if(rv == -1)
return -errno;
rv = ::lstat(paths[0].full.c_str(),&buf);

6
src/getxattr.cpp

@ -109,9 +109,9 @@ _getxattr(const fs::SearchFunc searchFunc,
int rv;
fs::PathVector paths;
searchFunc(srcmounts,fusepath,paths);
if(paths.empty())
return -ENOENT;
rv = searchFunc(srcmounts,fusepath,paths);
if(rv == -1)
return -errno;
if(!strcmp(attrname,"user.mergerfs.basepath"))
rv = ::_getxattr_from_string(buf,count,paths[0].base);

6
src/link.cpp

@ -50,9 +50,9 @@ _link(const fs::SearchFunc searchFunc,
int error;
fs::PathVector paths;
searchFunc(srcmounts,from,paths);
if(paths.empty())
return -ENOENT;
rv = searchFunc(srcmounts,from,paths);
if(rv == -1)
return -errno;
rv = -1;
error = 0;

6
src/listxattr.cpp

@ -77,9 +77,9 @@ _listxattr(const fs::SearchFunc searchFunc,
int rv;
fs::PathVector paths;
searchFunc(srcmounts,fusepath,paths);
if(paths.empty())
return -ENOENT;
rv = searchFunc(srcmounts,fusepath,paths);
if(rv == -1)
return -errno;
rv = ::llistxattr(paths[0].full.c_str(),list,size);

8
src/mkdir.cpp

@ -58,11 +58,11 @@ _mkdir(const fs::SearchFunc searchFunc,
return -EEXIST;
dirname = fs::dirname(fusepath);
searchFunc(srcmounts,dirname,existingpath);
if(existingpath.empty())
return -ENOENT;
rv = searchFunc(srcmounts,dirname,existingpath);
if(rv == -1)
return -errno;
createPathFunc(srcmounts,dirname,createpath);
rv = createPathFunc(srcmounts,dirname,createpath);
if(createpath[0].base != existingpath[0].base)
fs::clonepath(existingpath[0].base,createpath[0].base,dirname);

6
src/mknod.cpp

@ -60,9 +60,9 @@ _mknod(const fs::SearchFunc searchFunc,
return -EEXIST;
dirname = fs::dirname(fusepath);
searchFunc(srcmounts,dirname,existingpath);
if(existingpath.empty())
return -ENOENT;
rv = searchFunc(srcmounts,dirname,existingpath);
if(rv == -1)
return -errno;
createPathFunc(srcmounts,dirname,createpath);
if(existingpath[0].base != createpath[0].base)

9
src/open.cpp

@ -49,12 +49,13 @@ _open(const fs::SearchFunc searchFunc,
const int flags,
uint64_t &fh)
{
int fd;
int fd;
int rv;
fs::PathVector paths;
searchFunc(srcmounts,fusepath,paths);
if(paths.empty())
return -ENOENT;
rv = searchFunc(srcmounts,fusepath,paths);
if(rv == -1)
return -errno;
fd = ::open(paths[0].full.c_str(),flags);
if(fd == -1)

6
src/readlink.cpp

@ -50,9 +50,9 @@ _readlink(const fs::SearchFunc searchFunc,
int rv;
fs::PathVector paths;
searchFunc(srcmounts,fusepath,paths);
if(paths.empty())
return -ENOENT;
rv = searchFunc(srcmounts,fusepath,paths);
if(rv == -1)
return -errno;
rv = ::readlink(paths[0].full.c_str(),buf,size);
if(rv == -1)

6
src/removexattr.cpp

@ -51,9 +51,9 @@ _removexattr(const fs::SearchFunc searchFunc,
int error;
fs::PathVector paths;
searchFunc(srcmounts,fusepath,paths);
if(paths.empty())
return -ENOENT;
rv = searchFunc(srcmounts,fusepath,paths);
if(rv == -1)
return -errno;
rv = -1;
error = 0;

6
src/rename.cpp

@ -50,9 +50,9 @@ _rename(const fs::SearchFunc searchFunc,
string pathto;
fs::PathVector pathfrom;
searchFunc(srcmounts,from,pathfrom);
if(pathfrom.empty())
return -ENOENT;
rv = searchFunc(srcmounts,from,pathfrom);
if(rv == -1)
return -errno;
pathto = fs::make_path(pathfrom[0].base,to);

6
src/rmdir.cpp

@ -48,9 +48,9 @@ _rmdir(const fs::SearchFunc searchFunc,
int error;
fs::PathVector paths;
searchFunc(srcmounts,fusepath,paths);
if(paths.empty())
return -ENOENT;
rv = searchFunc(srcmounts,fusepath,paths);
if(rv == -1)
return -errno;
rv = -1;
error = 0;

6
src/setxattr.cpp

@ -235,9 +235,9 @@ _setxattr(const fs::SearchFunc searchFunc,
int error;
fs::PathVector paths;
searchFunc(srcmounts,fusepath,paths);
if(paths.empty())
return -ENOENT;
rv = searchFunc(srcmounts,fusepath,paths);
if(rv == -1)
return -errno;
rv = -1;
error = 0;

6
src/truncate.cpp

@ -50,9 +50,9 @@ _truncate(const fs::SearchFunc searchFunc,
int error;
fs::PathVector paths;
searchFunc(srcmounts,fusepath,paths);
if(paths.empty())
return -ENOENT;
rv = searchFunc(srcmounts,fusepath,paths);
if(rv == -1)
return -errno;
rv = -1;
error = 0;

6
src/unlink.cpp

@ -48,9 +48,9 @@ _unlink(const fs::SearchFunc searchFunc,
int error;
fs::PathVector paths;
searchFunc(srcmounts,fusepath,paths);
if(paths.empty())
return -ENOENT;
rv = searchFunc(srcmounts,fusepath,paths);
if(rv == -1)
return -errno;
rv = -1;
error = 0;

6
src/utimens.cpp

@ -50,9 +50,9 @@ _utimens(const fs::SearchFunc searchFunc,
int error;
fs::PathVector paths;
searchFunc(srcmounts,fusepath,paths);
if(paths.empty())
return -ENOENT;
rv = searchFunc(srcmounts,fusepath,paths);
if(rv == -1)
return -errno;
rv = -1;
error = 0;

Loading…
Cancel
Save