Browse Source

use stat/2 rather than statvfs/2 to find file drive

pull/230/head
Antonio SJ Musumeci 9 years ago
parent
commit
792c9b9808
  1. 25
      src/fs.cpp
  2. 5
      src/success_fail.hpp

25
src/fs.cpp

@ -112,28 +112,29 @@ namespace fs
string &basepath)
{
int rv;
dev_t dev;
string fullpath;
unsigned long fsid;
struct statvfs buf;
struct stat st;
rv = ::fstatvfs(fd,&buf);
if(rv == -1)
rv = ::fstat(fd,&st);
if(FSTAT_FAILED(rv))
return -1;
fsid = buf.f_fsid;
dev = st.st_dev;
for(int i = 0, ei = srcmounts.size(); i != ei; i++)
{
fs::path::make(&srcmounts[i],fusepath,fullpath);
rv = ::statvfs(fullpath.c_str(),&buf);
if(rv == -1)
rv = ::lstat(fullpath.c_str(),&st);
if(FSTAT_FAILED(rv))
continue;
if(buf.f_fsid == fsid)
{
basepath = srcmounts[i];
return 0;
}
if(st.st_dev != dev)
continue;
basepath = srcmounts[i];
return 0;
}
return (errno=ENOENT,-1);

5
src/success_fail.hpp

@ -31,4 +31,9 @@
#define LSTAT_FAIL -1
#define LSTAT_FAILED(RV) ((RV) == LSTAT_FAIL)
#define FSTAT_SUCCESS 0
#define FSTAT_SUCCEEDED(RV) ((RV) == FSTAT_SUCCESS)
#define FSTAT_FAIL -1
#define FSTAT_FAILED(RV) ((RV) == FSTAT_FAIL)
#endif /*__MERGERFS_SUCCESS_FAIL_HPP__ */
Loading…
Cancel
Save