Browse Source

Merge pull request #126 from trapexit/realpathize

realpath'ize all source mount points. closes #117
pull/135/head 2.4.0
Antonio SJ Musumeci 9 years ago
parent
commit
8323e16ad2
  1. 18
      src/fs.cpp
  2. 2
      src/fs.hpp
  3. 2
      src/option_parser.cpp
  4. 2
      src/setxattr.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;
}
}
};

2
src/fs.hpp

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

2
src/option_parser.cpp

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

2
src/setxattr.cpp

@ -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…
Cancel
Save