authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-12-15 22:15:31-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-06-05 22:43:53-07:00
logeead70f2d6758e928f5fe96d7d3bffa24308dbb2
treed7034bb72b03a7f8fb8ab3d29d11075a30bea19b
parent4c068c3be1e8501ba85d4b98f6b869474fc967df

glibc patch: make fstatat.c and fstatat64.c compile

instead of importing every header file under the sun, I copied a couple inline functions into these files to make them work.

2 files changed, 33 insertions(+), 2 deletions(-)

lib/libc/glibc/sysdeps/unix/sysv/linux/fstatat.c+20
...@@ -19,8 +19,28 @@...@@ -19,8 +19,28 @@
19#include <sys/stat.h>19#include <sys/stat.h>
20#include <kernel_stat.h>20#include <kernel_stat.h>
21#include <sysdep.h>21#include <sysdep.h>
22#include <string.h>
2223
23#if !XSTAT_IS_XSTAT6424#if !XSTAT_IS_XSTAT64
25
26static inline bool
27in_time_t_range (__time64_t t)
28{
29 time_t s = t;
30 return s == t;
31}
32
33static inline struct timespec
34valid_timespec64_to_timespec (const struct __timespec64 ts64)
35{
36 struct timespec ts;
37
38 ts.tv_sec = (time_t) ts64.tv_sec;
39 ts.tv_nsec = ts64.tv_nsec;
40
41 return ts;
42}
43
24int44int
25__fstatat (int fd, const char *file, struct stat *buf, int flag)45__fstatat (int fd, const char *file, struct stat *buf, int flag)
26{46{
lib/libc/glibc/sysdeps/unix/sysv/linux/fstatat64.c+13-2
...@@ -53,8 +53,8 @@ fstatat64_time64_statx (int fd, const char *file, struct __stat64_t64 *buf,...@@ -53,8 +53,8 @@ fstatat64_time64_statx (int fd, const char *file, struct __stat64_t64 *buf,
53 return r;53 return r;
5454
55 *buf = (struct __stat64_t64) {55 *buf = (struct __stat64_t64) {
56 .st_dev = __gnu_dev_makedev (tmp.stx_dev_major, tmp.stx_dev_minor),56 .st_dev = gnu_dev_makedev (tmp.stx_dev_major, tmp.stx_dev_minor),
57 .st_rdev = __gnu_dev_makedev (tmp.stx_rdev_major, tmp.stx_rdev_minor),57 .st_rdev = gnu_dev_makedev (tmp.stx_rdev_major, tmp.stx_rdev_minor),
58 .st_ino = tmp.stx_ino,58 .st_ino = tmp.stx_ino,
59 .st_mode = tmp.stx_mode,59 .st_mode = tmp.stx_mode,
60 .st_nlink = tmp.stx_nlink,60 .st_nlink = tmp.stx_nlink,
...@@ -78,6 +78,17 @@ fstatat64_time64_statx (int fd, const char *file, struct __stat64_t64 *buf,...@@ -78,6 +78,17 @@ fstatat64_time64_statx (int fd, const char *file, struct __stat64_t64 *buf,
78/* Only statx supports 64-bit timestamps for 32-bit architectures with78/* Only statx supports 64-bit timestamps for 32-bit architectures with
79 __ASSUME_STATX, so there is no point in building the fallback. */79 __ASSUME_STATX, so there is no point in building the fallback. */
80#if !FSTATAT_USE_STATX || (FSTATAT_USE_STATX && !defined __ASSUME_STATX)80#if !FSTATAT_USE_STATX || (FSTATAT_USE_STATX && !defined __ASSUME_STATX)
81static inline struct __timespec64
82valid_timespec_to_timespec64 (const struct timespec ts)
83{
84 struct __timespec64 ts64;
85
86 ts64.tv_sec = ts.tv_sec;
87 ts64.tv_nsec = ts.tv_nsec;
88
89 return ts64;
90}
91
81static inline int92static inline int
82fstatat64_time64_stat (int fd, const char *file, struct __stat64_t64 *buf,93fstatat64_time64_stat (int fd, const char *file, struct __stat64_t64 *buf,
83 int flag)94 int flag)