Browse Source

realpath'ize all source mount points. closes #117

pull/126/head
Antonio SJ Musumeci 9 years ago
parent
commit
ce9352987c
  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 <cstdlib>
#include <iterator> #include <iterator>
#include <stdlib.h>
#include <limits.h>
#include <dirent.h> #include <dirent.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
@ -510,4 +512,20 @@ namespace fs
globfree(&gbuf); 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, void glob(const vector<string> &patterns,
vector<string> &strs); vector<string> &strs);
void realpathize(vector<string> &strs);
}; };
#endif // __FS_HPP__ #endif // __FS_HPP__

2
src/option_parser.cpp

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

2
src/setxattr.cpp

@ -59,6 +59,7 @@ _add_srcmounts(vector<string> &srcmounts,
str::split(patterns,values,':'); str::split(patterns,values,':');
fs::glob(patterns,additions); fs::glob(patterns,additions);
fs::realpathize(additions);
if(!additions.empty()) if(!additions.empty())
{ {
@ -106,6 +107,7 @@ _replace_srcmounts(vector<string> &srcmounts,
str::split(patterns,values,':'); str::split(patterns,values,':');
fs::glob(patterns,newmounts); fs::glob(patterns,newmounts);
fs::realpathize(newmounts);
{ {
const rwlock::WriteGuard wrg(&srcmountslock); const rwlock::WriteGuard wrg(&srcmountslock);

Loading…
Cancel
Save