Browse Source

checkpoint

getattr
Antonio SJ Musumeci 4 weeks ago
parent
commit
fa9199131b
  1. 47
      src/func_getattr_combine.cpp
  2. 17
      src/func_getattr_combine.hpp
  3. 21
      src/timespec_utils.hpp

47
src/func_getattr_combine.cpp

@ -0,0 +1,47 @@
#include "func_getattr_combine.hpp"
#include "fs_lstat.hpp"
#include "fs_inode.hpp"
#include "timespec_utils.hpp"
int
Func2::GetattrCombine::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_combine.hpp

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

21
src/timespec_utils.hpp

@ -0,0 +1,21 @@
#pragma once
namespace TimeSpec
{
static
inline
timespec
newest(const timespec &t0_,
const timespec &t1_)
{
if(t0_.tv_sec > t1_.tv_sec)
return t0_;
if(t0_.tv_sec == t1_.tv_sec)
{
if(t0_.tv_nsec > t1_.tv_nsec)
return t0_;
}
return t1_;
}
}
Loading…
Cancel
Save