From 822ddc6dc6b8d8f34da4e3abe298533ced041679 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Wed, 17 Sep 2025 14:50:22 +0800 Subject: [PATCH] Disk (Linux): replace statx(2) call to syscall(2) --- CMakeLists.txt | 7 ------- src/detection/disk/disk_linux.c | 8 ++++++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c723a5762..045b8f7b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1306,9 +1306,6 @@ check_function_exists(wcwidth HAVE_WCWIDTH) if(NOT HAVE_WCWIDTH) list(APPEND LIBFASTFETCH_SRC src/util/wcwidth.c) endif() -if(LINUX) - check_function_exists(statx HAVE_STATX) -endif() if(NOT WIN32) check_function_exists(pipe2 HAVE_PIPE2) endif() @@ -1424,10 +1421,6 @@ if(FreeBSD OR OpenBSD OR NetBSD) unset(CMAKE_REQUIRED_DEFINITIONS) endif() -if(HAVE_STATX) - target_compile_definitions(libfastfetch PUBLIC FF_HAVE_STATX) -endif() - if(HAVE_WCWIDTH) target_compile_definitions(libfastfetch PUBLIC FF_HAVE_WCWIDTH) endif() diff --git a/src/detection/disk/disk_linux.c b/src/detection/disk/disk_linux.c index 377faf9fc..6a1341c25 100644 --- a/src/detection/disk/disk_linux.c +++ b/src/detection/disk/disk_linux.c @@ -10,6 +10,10 @@ #include #include +#ifdef STATX_BTIME + #include +#endif + #ifdef __USE_LARGEFILE64 #define stat stat64 #define statvfs statvfs64 @@ -263,9 +267,9 @@ static void detectStats(FFDisk* disk) } disk->createTime = 0; - #ifdef FF_HAVE_STATX + #ifdef SYS_statx struct statx stx; - if (statx(0, disk->mountpoint.chars, 0, STATX_BTIME, &stx) == 0 && (stx.stx_mask & STATX_BTIME)) + if (syscall(SYS_statx, 0, disk->mountpoint.chars, 0, STATX_BTIME, &stx) == 0 && (stx.stx_mask & STATX_BTIME)) disk->createTime = (uint64_t)((stx.stx_btime.tv_sec * 1000) + (stx.stx_btime.tv_nsec / 1000000)); #endif