realpath'ize all source mount points. closes #117

This commit is contained in:
Antonio SJ Musumeci 2015-09-06 18:24:36 -04:00
parent 2d899479c3
commit ce9352987c
4 changed files with 24 additions and 0 deletions

View File

@ -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;
}
}
};

View File

@ -122,6 +122,8 @@ namespace fs
void glob(const vector<string> &patterns,
vector<string> &strs);
void realpathize(vector<string> &strs);
};
#endif // __FS_HPP__

View File

@ -200,6 +200,8 @@ process_srcmounts(const char *arg,
fs::glob(paths,config.srcmounts);
fs::realpathize(config.srcmounts);
return 0;
}

View File

@ -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);