|
@ -520,8 +520,8 @@ namespace fs |
|
|
int |
|
|
int |
|
|
invalid(const vector<string> &basepaths, |
|
|
invalid(const vector<string> &basepaths, |
|
|
const string &fusepath, |
|
|
const string &fusepath, |
|
|
Paths &rv, |
|
|
|
|
|
size_t count) |
|
|
|
|
|
|
|
|
const size_t minfreespace, |
|
|
|
|
|
Paths &rv) |
|
|
{ |
|
|
{ |
|
|
return (errno = EINVAL,-1); |
|
|
return (errno = EINVAL,-1); |
|
|
} |
|
|
} |
|
@ -529,8 +529,8 @@ namespace fs |
|
|
int |
|
|
int |
|
|
ff(const vector<string> &basepaths, |
|
|
ff(const vector<string> &basepaths, |
|
|
const string &fusepath, |
|
|
const string &fusepath, |
|
|
Paths &paths, |
|
|
|
|
|
size_t count) |
|
|
|
|
|
|
|
|
const size_t minfreespace, |
|
|
|
|
|
Paths &paths) |
|
|
{ |
|
|
{ |
|
|
errno = ENOENT; |
|
|
errno = ENOENT; |
|
|
for(vector<string>::const_iterator |
|
|
for(vector<string>::const_iterator |
|
@ -558,8 +558,8 @@ namespace fs |
|
|
int |
|
|
int |
|
|
ffwp(const vector<string> &basepaths, |
|
|
ffwp(const vector<string> &basepaths, |
|
|
const string &fusepath, |
|
|
const string &fusepath, |
|
|
Paths &paths, |
|
|
|
|
|
size_t count) |
|
|
|
|
|
|
|
|
const size_t minfreespace, |
|
|
|
|
|
Paths &paths) |
|
|
{ |
|
|
{ |
|
|
Path fallback; |
|
|
Path fallback; |
|
|
|
|
|
|
|
@ -597,8 +597,8 @@ namespace fs |
|
|
int |
|
|
int |
|
|
newest(const vector<string> &basepaths, |
|
|
newest(const vector<string> &basepaths, |
|
|
const string &fusepath, |
|
|
const string &fusepath, |
|
|
Paths &paths, |
|
|
|
|
|
size_t count) |
|
|
|
|
|
|
|
|
const size_t minfreespace, |
|
|
|
|
|
Paths &paths) |
|
|
{ |
|
|
{ |
|
|
time_t newest; |
|
|
time_t newest; |
|
|
string npath; |
|
|
string npath; |
|
@ -635,8 +635,8 @@ namespace fs |
|
|
int |
|
|
int |
|
|
mfs(const vector<string> &basepaths, |
|
|
mfs(const vector<string> &basepaths, |
|
|
const string &fusepath, |
|
|
const string &fusepath, |
|
|
Paths &paths, |
|
|
|
|
|
size_t count) |
|
|
|
|
|
|
|
|
const size_t minfreespace, |
|
|
|
|
|
Paths &paths) |
|
|
{ |
|
|
{ |
|
|
fsblkcnt_t mfs; |
|
|
fsblkcnt_t mfs; |
|
|
size_t mfsidx; |
|
|
size_t mfsidx; |
|
@ -675,11 +675,11 @@ namespace fs |
|
|
int |
|
|
int |
|
|
epmfs(const vector<string> &basepaths, |
|
|
epmfs(const vector<string> &basepaths, |
|
|
const string &fusepath, |
|
|
const string &fusepath, |
|
|
Paths &paths, |
|
|
|
|
|
size_t count) |
|
|
|
|
|
|
|
|
const size_t minfreespace, |
|
|
|
|
|
Paths &paths) |
|
|
{ |
|
|
{ |
|
|
fsblkcnt_t existingmfs = 0; |
|
|
|
|
|
fsblkcnt_t generalmfs = 0; |
|
|
|
|
|
|
|
|
fsblkcnt_t existingmfs; |
|
|
|
|
|
fsblkcnt_t generalmfs; |
|
|
string fullpath; |
|
|
string fullpath; |
|
|
string generalmfspath; |
|
|
string generalmfspath; |
|
|
string existingmfspath; |
|
|
string existingmfspath; |
|
@ -689,6 +689,8 @@ namespace fs |
|
|
if(iter == eiter) |
|
|
if(iter == eiter) |
|
|
return (errno = ENOENT,-1); |
|
|
return (errno = ENOENT,-1); |
|
|
|
|
|
|
|
|
|
|
|
existingmfs = 0; |
|
|
|
|
|
generalmfs = 0; |
|
|
do |
|
|
do |
|
|
{ |
|
|
{ |
|
|
int rv; |
|
|
int rv; |
|
@ -736,8 +738,8 @@ namespace fs |
|
|
int |
|
|
int |
|
|
all(const vector<string> &basepaths, |
|
|
all(const vector<string> &basepaths, |
|
|
const string &fusepath, |
|
|
const string &fusepath, |
|
|
Paths &paths, |
|
|
|
|
|
size_t count) |
|
|
|
|
|
|
|
|
const size_t minfreespace, |
|
|
|
|
|
Paths &paths) |
|
|
{ |
|
|
{ |
|
|
int rv; |
|
|
int rv; |
|
|
struct stat st; |
|
|
struct stat st; |
|
@ -745,17 +747,14 @@ namespace fs |
|
|
|
|
|
|
|
|
for(vector<string>::const_iterator |
|
|
for(vector<string>::const_iterator |
|
|
iter = basepaths.begin(), eiter = basepaths.end(); |
|
|
iter = basepaths.begin(), eiter = basepaths.end(); |
|
|
iter != eiter && count; |
|
|
|
|
|
|
|
|
iter != eiter; |
|
|
++iter) |
|
|
++iter) |
|
|
{ |
|
|
{ |
|
|
fullpath = fs::make_path(*iter,fusepath); |
|
|
fullpath = fs::make_path(*iter,fusepath); |
|
|
|
|
|
|
|
|
rv = ::lstat(fullpath.c_str(),&st); |
|
|
rv = ::lstat(fullpath.c_str(),&st); |
|
|
if(rv == 0) |
|
|
if(rv == 0) |
|
|
{ |
|
|
|
|
|
paths.push_back(Path(*iter,fullpath)); |
|
|
paths.push_back(Path(*iter,fullpath)); |
|
|
count--; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return paths.empty() ? (errno=ENOENT,-1) : 0; |
|
|
return paths.empty() ? (errno=ENOENT,-1) : 0; |
|
@ -764,20 +763,17 @@ namespace fs |
|
|
int |
|
|
int |
|
|
rand(const vector<string> &basepaths, |
|
|
rand(const vector<string> &basepaths, |
|
|
const string &fusepath, |
|
|
const string &fusepath, |
|
|
Paths &paths, |
|
|
|
|
|
size_t count) |
|
|
|
|
|
|
|
|
const size_t minfreespace, |
|
|
|
|
|
Paths &paths) |
|
|
{ |
|
|
{ |
|
|
int rv; |
|
|
int rv; |
|
|
|
|
|
|
|
|
rv = all(basepaths,fusepath,paths,-1); |
|
|
|
|
|
|
|
|
rv = all(basepaths,fusepath,minfreespace,paths); |
|
|
if(rv == -1) |
|
|
if(rv == -1) |
|
|
return -1; |
|
|
return -1; |
|
|
|
|
|
|
|
|
std::random_shuffle(paths.begin(),paths.end()); |
|
|
std::random_shuffle(paths.begin(),paths.end()); |
|
|
|
|
|
|
|
|
if(paths.size() > count) |
|
|
|
|
|
paths.resize(count); |
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|