From 8dd6e30a693c1af2d97cdf99ef85e4b946c7661d Mon Sep 17 00:00:00 2001 From: Ramon Nou Date: Wed, 17 Nov 2021 08:03:46 +0100 Subject: [PATCH] Solve fstatat with an empty path in newer kernels --- src/client/hooks.cpp | 5 ----- src/client/preload_context.cpp | 5 +++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/client/hooks.cpp b/src/client/hooks.cpp index 004a60f4f..7fdabf78f 100644 --- a/src/client/hooks.cpp +++ b/src/client/hooks.cpp @@ -203,11 +203,6 @@ hook_fstatat(int dirfd, const char* cpath, struct stat* buf, int flags) { LOG(DEBUG, "{}() called with path: \"{}\", fd: {}, buf: {}, flags: {}", __func__, cpath, dirfd, fmt::ptr(buf), flags); - if(flags & AT_EMPTY_PATH) { - LOG(ERROR, "{}() AT_EMPTY_PATH flag not supported", __func__); - return -ENOTSUP; - } - std::string resolved; auto rstatus = CTX->relativize_fd_path(dirfd, cpath, resolved); switch(rstatus) { diff --git a/src/client/preload_context.cpp b/src/client/preload_context.cpp index f076360b3..f31d6f7cd 100644 --- a/src/client/preload_context.cpp +++ b/src/client/preload_context.cpp @@ -199,7 +199,7 @@ PreloadContext::relativize_fd_path(int dirfd, const char* raw_path, std::string path; - if(raw_path[0] != gkfs::path::separator) { + if(raw_path != nullptr && raw_path[0] != gkfs::path::separator) { // path is relative if(dirfd == AT_FDCWD) { // path is relative to cwd @@ -243,7 +243,7 @@ PreloadContext::relativize_path(const char* raw_path, std::string path; - if(raw_path[0] != gkfs::path::separator) { + if(raw_path != nullptr && raw_path[0] != gkfs::path::separator) { /* Path is not absolute, we need to prepend CWD; * First reserve enough space to minimize memory copy */ @@ -251,6 +251,7 @@ PreloadContext::relativize_path(const char* raw_path, } else { path = raw_path; } + return gkfs::path::resolve(path, relative_path, resolve_last_link); } -- GitLab