Skip to content

Commit 822ddc6

Browse files
committed
Disk (Linux): replace statx(2) call to syscall(2)
1 parent 8bd171a commit 822ddc6

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

CMakeLists.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,9 +1306,6 @@ check_function_exists(wcwidth HAVE_WCWIDTH)
13061306
if(NOT HAVE_WCWIDTH)
13071307
list(APPEND LIBFASTFETCH_SRC src/util/wcwidth.c)
13081308
endif()
1309-
if(LINUX)
1310-
check_function_exists(statx HAVE_STATX)
1311-
endif()
13121309
if(NOT WIN32)
13131310
check_function_exists(pipe2 HAVE_PIPE2)
13141311
endif()
@@ -1424,10 +1421,6 @@ if(FreeBSD OR OpenBSD OR NetBSD)
14241421
unset(CMAKE_REQUIRED_DEFINITIONS)
14251422
endif()
14261423

1427-
if(HAVE_STATX)
1428-
target_compile_definitions(libfastfetch PUBLIC FF_HAVE_STATX)
1429-
endif()
1430-
14311424
if(HAVE_WCWIDTH)
14321425
target_compile_definitions(libfastfetch PUBLIC FF_HAVE_WCWIDTH)
14331426
endif()

src/detection/disk/disk_linux.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
#include <sys/stat.h>
1111
#include <sys/statvfs.h>
1212

13+
#ifdef STATX_BTIME
14+
#include <sys/syscall.h>
15+
#endif
16+
1317
#ifdef __USE_LARGEFILE64
1418
#define stat stat64
1519
#define statvfs statvfs64
@@ -263,9 +267,9 @@ static void detectStats(FFDisk* disk)
263267
}
264268

265269
disk->createTime = 0;
266-
#ifdef FF_HAVE_STATX
270+
#ifdef SYS_statx
267271
struct statx stx;
268-
if (statx(0, disk->mountpoint.chars, 0, STATX_BTIME, &stx) == 0 && (stx.stx_mask & STATX_BTIME))
272+
if (syscall(SYS_statx, 0, disk->mountpoint.chars, 0, STATX_BTIME, &stx) == 0 && (stx.stx_mask & STATX_BTIME))
269273
disk->createTime = (uint64_t)((stx.stx_btime.tv_sec * 1000) + (stx.stx_btime.tv_nsec / 1000000));
270274
#endif
271275

0 commit comments

Comments
 (0)