1 /* Test (somewhat) stats and stat. */
10 #include <sys/syscall.h>
11 #if defined(MUSL_LIBC)
12 /* musl has __NR_statx but not the structs that it needs */
15 #if !defined(HAVE_STRUCT_STATX_IN_SYS_STAT_H)
16 #include <linux/stat.h>
17 #endif /* HAVE_STRUCT_STATX_IN_SYS_STAT_H */
18 #endif /* MUSL_LIBC */
23 #define field(fieldname,s) s->st_##fieldname
24 #if defined(__NR_statx)
25 #define checkfield(fieldname) \
26 assert(!check_stat2 || stat1.st_##fieldname == stat2.stx_##fieldname)
28 #define checkfield(fieldname) \
29 assert(!check_stat2 || stat1.st_##fieldname == stat2.st_##fieldname)
36 memset(&stat1
, 0x55, sizeof(stat1
));
38 assert (stat ("/tmp", &stat1
) == 0);
39 #if defined(__NR_statx)
41 memset(&stat2
, 0x22, sizeof(stat2
));
42 if (syscall (__NR_statx
, 0, "/tmp", 0, STATX_ALL
, &stat2
) == 0)
46 check_stat2
= 0; // Defined but not provided by kernel.
48 check_stat2
= 1; // Probably better fail ...
53 memset(&stat2
, 0x22, sizeof(stat2
));
54 assert (stat ("/tmp", &stat2
) == 0);