mirror of
https://github.com/trapexit/mergerfs.git
synced 2024-11-26 10:13:50 +08:00
Merge pull request #126 from trapexit/realpathize
realpath'ize all source mount points. closes #117
This commit is contained in:
commit
8323e16ad2
18
src/fs.cpp
18
src/fs.cpp
|
@ -29,6 +29,8 @@
|
|||
#include <cstdlib>
|
||||
#include <iterator>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -510,4 +512,20 @@ namespace fs
|
|||
|
||||
globfree(&gbuf);
|
||||
}
|
||||
|
||||
void
|
||||
realpathize(vector<string> &strs)
|
||||
{
|
||||
char *rv;
|
||||
char buf[PATH_MAX];
|
||||
|
||||
for(size_t i = 0; i < strs.size(); i++)
|
||||
{
|
||||
rv = ::realpath(strs[i].c_str(),buf);
|
||||
if(rv == NULL)
|
||||
continue;
|
||||
|
||||
strs[i] = buf;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -122,6 +122,8 @@ namespace fs
|
|||
|
||||
void glob(const vector<string> &patterns,
|
||||
vector<string> &strs);
|
||||
|
||||
void realpathize(vector<string> &strs);
|
||||
};
|
||||
|
||||
#endif // __FS_HPP__
|
||||
|
|
|
@ -200,6 +200,8 @@ process_srcmounts(const char *arg,
|
|||
|
||||
fs::glob(paths,config.srcmounts);
|
||||
|
||||
fs::realpathize(config.srcmounts);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@ _add_srcmounts(vector<string> &srcmounts,
|
|||
|
||||
str::split(patterns,values,':');
|
||||
fs::glob(patterns,additions);
|
||||
fs::realpathize(additions);
|
||||
|
||||
if(!additions.empty())
|
||||
{
|
||||
|
@ -106,6 +107,7 @@ _replace_srcmounts(vector<string> &srcmounts,
|
|||
|
||||
str::split(patterns,values,':');
|
||||
fs::glob(patterns,newmounts);
|
||||
fs::realpathize(newmounts);
|
||||
|
||||
{
|
||||
const rwlock::WriteGuard wrg(&srcmountslock);
|
||||
|
|
Loading…
Reference in New Issue
Block a user