Disk (Linux): replace statx(2) call to syscall(2)

This commit is contained in:
Carter Li
2025-09-17 14:50:22 +08:00
parent 8bd171a9ff
commit 822ddc6dc6
2 changed files with 6 additions and 9 deletions
-7
View File
@@ -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()
+6 -2
View File
@@ -10,6 +10,10 @@
#include <sys/stat.h>
#include <sys/statvfs.h>
#ifdef STATX_BTIME
#include <sys/syscall.h>
#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