diff --git a/CHANGELOG.md b/CHANGELOG.md index 08875e4a7fa5df2a6a1e9b1c0d0a1502760d6b76..047b05db7b157a4e05a01c4ac413aa09c4139d61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### Changed ### Fixed + - SYS_lstat does not exists on some architectures, change to newfstatat ([!269](https://storage.bsc.es/gitlab/hpc/gekkofs/-/merge_requests/269)) + - We cannot use lstat directly as may cause a recursion call on libc interception. ## [0.9.5] - 2025-08 ### New diff --git a/src/client/intercept.cpp b/src/client/intercept.cpp index 35df1cf9a8bc6594cf1592d1b9191a880935afad..b38642564722fff65ef826f0028b29c2b790c663 100644 --- a/src/client/intercept.cpp +++ b/src/client/intercept.cpp @@ -107,8 +107,9 @@ get_open_fds() { char buffer[buffer_size]; // Open /proc/self/fd directory using raw syscall - int dir_fd = syscall_no_intercept_wrapper(SYS_open, "/proc/self/fd", - O_RDONLY | O_DIRECTORY, 0); + + int dir_fd = syscall_no_intercept_wrapper( + SYS_openat, AT_FDCWD, "/proc/self/fd", O_RDONLY | O_DIRECTORY, 0); if(dir_fd < 0) { return fds; } diff --git a/src/client/path.cpp b/src/client/path.cpp index 1792a0e70f437c4ef68e44ef969e678c911de319..48f7c6c09822841664dca9ae4455a595093addd7 100644 --- a/src/client/path.cpp +++ b/src/client/path.cpp @@ -56,6 +56,7 @@ extern "C" { #include #include +#include // Required for AT_FDCWD and AT_SYMLINK_NOFOLLOW } using namespace std; @@ -115,7 +116,15 @@ static char* (*real_realpath)(const char* path, char* resolved_path) = nullptr; string follow_symlinks(const string& path) { struct stat st{}; - auto res = syscall_no_intercept(SYS_lstat, path.c_str(), &st); + long res; +// If we are in ARM device just call lstat, not the syscall lstat +#ifdef SYS_lstat + res = syscall_no_intercept(SYS_lstat, path.c_str(), &st); +#else + // Modern architectures (ARM64, RISC-V) use fstatat (newfstatat) + res = syscall_no_intercept(SYS_newfstatat, AT_FDCWD, path.c_str(), &st, + AT_SYMLINK_NOFOLLOW); +#endif if(res < 0) { LOG(DEBUG, "path \"{}\" does not exist", path); return path;