Browse Source

timespec_utils.hpp

getattr
Antonio SJ Musumeci 4 weeks ago
parent
commit
52e6a43808
  1. 47
      src/func_getattr_newest.cpp
  2. 17
      src/func_getattr_newest.hpp
  3. 6
      src/timespec_utils.hpp

47
src/func_getattr_newest.cpp

@ -0,0 +1,47 @@
#include "func_getattr_newest.hpp"
#include "fs_lstat.hpp"
#include "fs_inode.hpp"
#include "timespec_utils.hpp"
int
Func2::GetattrNewest::process(const Branches &branches_,
const fs::Path &fusepath_,
struct stat *st_,
fuse_timeouts_t *timeout_)
{
int rv;
Branches::CPtr branches;
fs::Path fullpath;
branches = branches_;
for(const auto &branch : *branches)
{
struct stat st;
fullpath = branch.path;
fullpath += fusepath_;
rv = fs::lstat(fullpath.c_str(),&st);
if(rv == -1)
continue;
if(st_->st_ino == 0)
{
*st_ = st;
continue;
}
st_->st_atim = TimeSpec::newest(st_->st_atim,st.st_atim);
st_->st_ctim = TimeSpec::newest(st_->st_ctim,st.st_ctim);
st_->st_mtim = TimeSpec::newest(st_->st_mtim,st.st_mtim);
st_->st_nlink += st.st_nlink;
}
if(st_->st_ino == 0)
return -ENOENT;
fs::inode::calc(fusepath_,st_);
return 0;
}

17
src/func_getattr_newest.hpp

@ -0,0 +1,17 @@
#include "func_getattr_base.hpp"
namespace Func2
{
class GetattrNewest : public GetattrBase
{
public:
GetattrNewest() {}
~GetattrNewest() {}
public:
int process(const Branches &branches,
const fs::Path &fusepath,
struct stat *st,
fuse_timeouts_t *timeout);
};
}

6
src/timespec_utils.hpp

@ -9,14 +9,14 @@ namespace TimeSpec
const timespec &t1_)
{
if(t0_.tv_sec > t1_.tv_sec)
return t0_;
return true;
if(t0_.tv_sec == t1_.tv_sec)
{
if(t0_.tv_nsec > t1_.tv_nsec)
return t0_;
return true;
}
return t1_;
return false;
}
static

Loading…
Cancel
Save