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> 2023-10-13 18:06:12-07:00
log50e18343a99f8806be7fe46385970b3fbda0a15a
tree729b67e47a5ba0c7307d55fefeae034c374cd97a
parent89aa63bec7102189a7449afaabff55f032eb3258

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
...@@ -59,8 +59,8 @@ fstatat64_time64_statx (int fd, const char *file, struct __stat64_t64 *buf,...@@ -59,8 +59,8 @@ fstatat64_time64_statx (int fd, const char *file, struct __stat64_t64 *buf,
59 return r;59 return r;
6060
61 *buf = (struct __stat64_t64) {61 *buf = (struct __stat64_t64) {
62 .st_dev = __gnu_dev_makedev (tmp.stx_dev_major, tmp.stx_dev_minor),62 .st_dev = gnu_dev_makedev (tmp.stx_dev_major, tmp.stx_dev_minor),
63 .st_rdev = __gnu_dev_makedev (tmp.stx_rdev_major, tmp.stx_rdev_minor),63 .st_rdev = gnu_dev_makedev (tmp.stx_rdev_major, tmp.stx_rdev_minor),
64 .st_ino = tmp.stx_ino,64 .st_ino = tmp.stx_ino,
65 .st_mode = tmp.stx_mode,65 .st_mode = tmp.stx_mode,
66 .st_nlink = tmp.stx_nlink,66 .st_nlink = tmp.stx_nlink,
...@@ -86,6 +86,17 @@ fstatat64_time64_statx (int fd, const char *file, struct __stat64_t64 *buf,...@@ -86,6 +86,17 @@ fstatat64_time64_statx (int fd, const char *file, struct __stat64_t64 *buf,
86/* Only statx supports 64-bit timestamps for 32-bit architectures with86/* Only statx supports 64-bit timestamps for 32-bit architectures with
87 __ASSUME_STATX, so there is no point in building the fallback. */87 __ASSUME_STATX, so there is no point in building the fallback. */
88#if !FSTATAT_USE_STATX || (FSTATAT_USE_STATX && !defined __ASSUME_STATX)88#if !FSTATAT_USE_STATX || (FSTATAT_USE_STATX && !defined __ASSUME_STATX)
89static inline struct __timespec64
90valid_timespec_to_timespec64 (const struct timespec ts)
91{
92 struct __timespec64 ts64;
93
94 ts64.tv_sec = ts.tv_sec;
95 ts64.tv_nsec = ts.tv_nsec;
96
97 return ts64;
98}
99
89static inline int100static inline int
90fstatat64_time64_stat (int fd, const char *file, struct __stat64_t64 *buf,101fstatat64_time64_stat (int fd, const char *file, struct __stat64_t64 *buf,
91 int flag)102 int flag)