diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c93c2d1793b1be563d31caa64c0d016ec3176f8..30582c1c9baad28127bf4823f224e0f0472d6ebc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### Fixed - Using `unlink` now fails if it is a directory unless the `AT_REMOVEDIR` flag is used (POSIX compliance) ([!139](https://storage.bsc.es/gitlab/hpc/gekkofs/-/merge_requests/139)). - fchdir generate a SIGSEV in debug mode (due to log) ([!141](https://storage.bsc.es/gitlab/hpc/gekkofs/-/merge_requests/141)) +- Fix fstatat to be able to understand `AT_EMPTY_PATH` flag used in coreutils (`cat` ...) ([!149](https://storage.bsc.es/gitlab/hpc/gekkofs/-/merge_requests/149)). + ## [0.9.1] - 2022-04-29 ### New diff --git a/include/client/preload_context.hpp b/include/client/preload_context.hpp index bfdaacadf7d74814ade69e2873271950b85c00d5..26875435b3f1546b9dd455160d845811ade38166 100644 --- a/include/client/preload_context.hpp +++ b/include/client/preload_context.hpp @@ -170,7 +170,7 @@ public: RelativizeStatus relativize_fd_path(int dirfd, const char* raw_path, - std::string& relative_path, + std::string& relative_path, int flags = 0, bool resolve_last_link = true) const; bool diff --git a/src/client/hooks.cpp b/src/client/hooks.cpp index 5917b80a7b6813bdba5b8602881f15b6c9068856..a476c2dce299d0897b3afcd6fd5a24be2455590a 100644 --- a/src/client/hooks.cpp +++ b/src/client/hooks.cpp @@ -203,7 +203,7 @@ hook_fstatat(int dirfd, const char* cpath, struct stat* buf, int flags) { __func__, cpath, dirfd, fmt::ptr(buf), flags); std::string resolved; - auto rstatus = CTX->relativize_fd_path(dirfd, cpath, resolved); + auto rstatus = CTX->relativize_fd_path(dirfd, cpath, resolved, flags); switch(rstatus) { case gkfs::preload::RelativizeStatus::fd_unknown: return syscall_no_intercept_wrapper(SYS_newfstatat, dirfd, cpath, diff --git a/src/client/preload_context.cpp b/src/client/preload_context.cpp index 9a1f9f27dde268ad907421df3ef38e2804969957..03284be042455ae063a0ad513a5f4b3e16e03e5f 100644 --- a/src/client/preload_context.cpp +++ b/src/client/preload_context.cpp @@ -185,7 +185,7 @@ PreloadContext::auto_sm(bool auto_sm) { RelativizeStatus PreloadContext::relativize_fd_path(int dirfd, const char* raw_path, - std::string& relative_path, + std::string& relative_path, int flags, bool resolve_last_link) const { // Relativize path should be called only after the library constructor has @@ -207,6 +207,13 @@ PreloadContext::relativize_fd_path(int dirfd, const char* raw_path, } else { if(!ofm_->exist(dirfd)) { return RelativizeStatus::fd_unknown; + } else { + // check if we have the AT_EMPTY_PATH flag + // for fstatat. + if(flags & AT_EMPTY_PATH) { + relative_path = ofm_->get(dirfd)->path(); + return RelativizeStatus::internal; + } } // path is relative to fd auto dir = ofm_->get_dir(dirfd);