You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.0 KiB

2 months ago
  1. #include "func_getattr_combine.hpp"
  2. #include "fs_lstat.hpp"
  3. #include "fs_inode.hpp"
  4. #include "timespec_utils.hpp"
  5. int
  6. Func2::GetattrCombine::process(const Branches &branches_,
  7. const fs::Path &fusepath_,
  8. struct stat *st_,
  9. fuse_timeouts_t *timeout_)
  10. {
  11. int rv;
  12. Branches::CPtr branches;
  13. fs::Path fullpath;
  14. branches = branches_;
  15. for(const auto &branch : *branches)
  16. {
  17. struct stat st;
  18. fullpath = branch.path;
  19. fullpath += fusepath_;
  20. rv = fs::lstat(fullpath.c_str(),&st);
  21. if(rv == -1)
  22. continue;
  23. if(st_->st_ino == 0)
  24. {
  25. *st_ = st;
  26. continue;
  27. }
  28. st_->st_atim = TimeSpec::newest(st_->st_atim,st.st_atim);
  29. st_->st_ctim = TimeSpec::newest(st_->st_ctim,st.st_ctim);
  30. st_->st_mtim = TimeSpec::newest(st_->st_mtim,st.st_mtim);
  31. st_->st_nlink += st.st_nlink;
  32. }
  33. if(st_->st_ino == 0)
  34. return -ENOENT;
  35. fs::inode::calc(fusepath_,st_);
  36. return 0;
  37. }