From c893a1cb9eed3ab2667439aa81696b15d9512603 Mon Sep 17 00:00:00 2001 From: rnou Date: Wed, 15 Oct 2025 13:56:44 +0200 Subject: [PATCH 1/2] update arm --- src/client/intercept.cpp | 5 +++-- src/client/path.cpp | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/client/intercept.cpp b/src/client/intercept.cpp index 35df1cf9a..39b2ec18f 100644 --- a/src/client/intercept.cpp +++ b/src/client/intercept.cpp @@ -106,8 +106,9 @@ get_open_fds() { const int buffer_size = 4096; char buffer[buffer_size]; - // Open /proc/self/fd directory using raw syscall - int dir_fd = syscall_no_intercept_wrapper(SYS_open, "/proc/self/fd", +// Open /proc/self/fd directory using raw syscall + + 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 1792a0e70..99174c582 100644 --- a/src/client/path.cpp +++ b/src/client/path.cpp @@ -115,7 +115,12 @@ static char* (*real_realpath)(const char* path, char* resolved_path) = nullptr; string follow_symlinks(const string& path) { struct stat st{}; +// If we are in ARM device just call lstat, not the syscall lstat +#ifdef __aarch64__ + auto res = lstat(path.c_str(), &st); +#else auto res = syscall_no_intercept(SYS_lstat, path.c_str(), &st); +#endif if(res < 0) { LOG(DEBUG, "path \"{}\" does not exist", path); return path; -- GitLab From afe8786d84d1c2182b873ec404f53094c0eb0159 Mon Sep 17 00:00:00 2001 From: Ramon Nou Date: Fri, 21 Nov 2025 07:39:28 +0100 Subject: [PATCH 2/2] update fstatat / lstat --- CHANGELOG.md | 2 ++ src/client/intercept.cpp | 6 +++--- src/client/path.cpp | 10 +++++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08875e4a7..047b05db7 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 39b2ec18f..b38642564 100644 --- a/src/client/intercept.cpp +++ b/src/client/intercept.cpp @@ -106,10 +106,10 @@ get_open_fds() { const int buffer_size = 4096; char buffer[buffer_size]; -// Open /proc/self/fd directory using raw syscall + // Open /proc/self/fd directory using raw syscall - int dir_fd = syscall_no_intercept_wrapper(SYS_openat, AT_FDCWD, "/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 99174c582..48f7c6c09 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,11 +116,14 @@ static char* (*real_realpath)(const char* path, char* resolved_path) = nullptr; string follow_symlinks(const string& path) { struct stat st{}; + long res; // If we are in ARM device just call lstat, not the syscall lstat -#ifdef __aarch64__ - auto res = lstat(path.c_str(), &st); +#ifdef SYS_lstat + res = syscall_no_intercept(SYS_lstat, path.c_str(), &st); #else - auto res = syscall_no_intercept(SYS_lstat, path.c_str(), &st); + // 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); -- GitLab