• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision8a04c4d84c8a1a1297ec0c5cec5522112981e0c0 (tree)
Zeit2020-02-03 19:50:54
AutorWaldemar Brodkorb <wbx@open...>
CommiterWaldemar Brodkorb

Log Message

csky: add statx conditionals

Similar to glibc commit
https://sourceware.org/git/?p=glibc.git;a=commit;h=6bbfc5c09fc5b5e3d4a0cddbbd4e2e457767dae7
we need to handle Linux kernel change, which removed stat64 family from default syscall set.

Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
Signed-off-by: Waldemar Brodkorb <wbrodkorb@conet.de>

Ändern Zusammenfassung

Diff

--- a/extra/Configs/Config.csky
+++ b/extra/Configs/Config.csky
@@ -6,7 +6,6 @@ config FORCE_OPTIONS_FOR_ARCH
66 bool
77 default y
88 select ARCH_ANY_ENDIAN
9- select ARCH_HAS_DEPRECATED_SYSCALLS
109 select ARCH_USE_MMU
1110 select ARCH_HAS_MMU
1211
--- a/include/fcntl.h
+++ b/include/fcntl.h
@@ -67,6 +67,11 @@ __BEGIN_DECLS
6767 # define AT_NO_AUTOMOUNT 0x800 /* Suppress terminal automount
6868 traversal. */
6969 # define AT_EMPTY_PATH 0x1000 /* Allow empty relative pathname. */
70+# define AT_STATX_SYNC_TYPE 0x6000
71+# define AT_STATX_SYNC_AS_STAT 0x0000
72+# define AT_STATX_FORCE_SYNC 0x2000
73+# define AT_STATX_DONT_SYNC 0x4000
74+# define AT_RECURSIVE 0x8000 /* Apply to the entire subtree. */
7075 # endif
7176 # define AT_EACCESS 0x200 /* Test access permitted for
7277 effective IDs, not real IDs. */
--- a/include/sys/stat.h
+++ b/include/sys/stat.h
@@ -393,6 +393,11 @@ extern int futimens (int __fd, const struct timespec __times[2]) __THROW;
393393 #undef _MKNOD_VER
394394 #define _MKNOD_VER 0
395395
396+#ifdef __USE_GNU
397+# include <bits/statx.h>
398+#endif
399+
400+
396401 __END_DECLS
397402
398403
--- a/ldso/include/dl-syscall.h
+++ b/ldso/include/dl-syscall.h
@@ -36,9 +36,37 @@ extern int _dl_errno;
3636 /* 1. common-generic ABI doesn't need kernel_stat translation
3737 * 3. S_IS?ID already provided by stat.h
3838 */
39+#include <fcntl.h>
3940 #include <sys/stat.h>
41+#include <dl-string.h>
42+
43+static __always_inline void
44+__cp_stat_statx (struct stat *to, struct statx *from)
45+{
46+ _dl_memset (to, 0, sizeof (struct stat));
47+ to->st_dev = ((from->stx_dev_minor & 0xff) | (from->stx_dev_major << 8)
48+ | ((from->stx_dev_minor & ~0xff) << 12));
49+ to->st_rdev = ((from->stx_rdev_minor & 0xff) | (from->stx_rdev_major << 8)
50+ | ((from->stx_rdev_minor & ~0xff) << 12));
51+ to->st_ino = from->stx_ino;
52+ to->st_mode = from->stx_mode;
53+ to->st_nlink = from->stx_nlink;
54+ to->st_uid = from->stx_uid;
55+ to->st_gid = from->stx_gid;
56+ to->st_atime = from->stx_atime.tv_sec;
57+ to->st_atim.tv_nsec = from->stx_atime.tv_nsec;
58+ to->st_mtime = from->stx_mtime.tv_sec;
59+ to->st_mtim.tv_nsec = from->stx_mtime.tv_nsec;
60+ to->st_ctime = from->stx_ctime.tv_sec;
61+ to->st_ctim.tv_nsec = from->stx_ctime.tv_nsec;
62+ to->st_size = from->stx_size;
63+ to->st_blocks = from->stx_blocks;
64+ to->st_blksize = from->stx_blksize;
65+}
4066 #endif
4167
68+#define AT_NO_AUTOMOUNT 0x800
69+#define AT_EMPTY_PATH 0x1000
4270
4371 /* Here are the definitions for some syscalls that are used
4472 by the dynamic linker. The idea is that we want to be able
@@ -109,14 +137,48 @@ static __always_inline int _dl_stat(const char *file_name,
109137 # define __NR__dl_stat __NR_stat
110138 static __always_inline _syscall2(int, _dl_stat, const char *, file_name,
111139 struct stat *, buf)
140+
141+#elif defined __NR_statx && defined __UCLIBC_HAVE_STATX__
142+# define __NR__dl_statx __NR_statx
143+# include <fcntl.h>
144+# include <statx_cp.h>
145+
146+static __always_inline _syscall5(int, _dl_statx, int, fd, const char *, file_name, int, flags,
147+ unsigned int, mask, struct statx *, buf);
148+
149+static __always_inline int _dl_stat(const char *file_name,
150+ struct stat *buf)
151+{
152+ struct statx tmp;
153+ int rc = _dl_statx(AT_FDCWD, file_name, AT_NO_AUTOMOUNT, STATX_BASIC_STATS, &tmp);
154+ if (rc == 0)
155+ __cp_stat_statx ((struct stat *)buf, &tmp);
156+ return rc;
157+}
112158 #endif
113159
114160 #if defined __NR_fstat64 && !defined __NR_fstat
115161 # define __NR__dl_fstat __NR_fstat64
162+static __always_inline _syscall2(int, _dl_fstat, int, fd, struct stat *, buf)
116163 #elif defined __NR_fstat
117164 # define __NR__dl_fstat __NR_fstat
118-#endif
119165 static __always_inline _syscall2(int, _dl_fstat, int, fd, struct stat *, buf)
166+#elif defined __NR_statx && defined __UCLIBC_HAVE_STATX__
167+# define __NR__dl_fstatx __NR_statx
168+static __always_inline _syscall5(int, _dl_fstatx, int, fd, const char *, file_name, int, flags, unsigned int, mask, struct stat *, buf);
169+
170+static __always_inline int _dl_fstat(int fd,
171+ struct stat *buf)
172+{
173+ struct statx tmp;
174+ int rc = _dl_fstatx(fd, "", AT_EMPTY_PATH, STATX_BASIC_STATS, &tmp);
175+ if (rc == 0)
176+ __cp_stat_statx ((struct stat *)buf, &tmp);
177+ return rc;
178+}
179+#else
180+static __always_inline _syscall2(int, _dl_fstat, int, fd, struct stat *, buf)
181+#endif
120182
121183 #define __NR__dl_munmap __NR_munmap
122184 static __always_inline _syscall2(int, _dl_munmap, void *, start, unsigned long, length)
--- a/ldso/ldso/csky/elfinterp.c
+++ b/ldso/ldso/csky/elfinterp.c
@@ -79,17 +79,11 @@ _dl_parse(struct elf_resolve *tpnt, struct r_scope_elem*scope,
7979 strtab + symtab[symtab_index].st_name);
8080 if (unlikely(res < 0)) {
8181 int reloc_type = ELF32_R_TYPE(rpnt->r_info);
82-
83-#if defined (__SUPPORT_LD_DEBUG__)
84- _dl_dprintf(2, "2can't handle reloc type '%s' in lib '%s'\n",
85- _dl_reltypes(reloc_type), tpnt->libname);
86-#else
87- _dl_dprintf(2, "3can't handle reloc type %x in lib '%s'\n",
82+ _dl_dprintf(2, "2can't handle reloc type %x in lib '%s'\n",
8883 reloc_type, tpnt->libname);
89-#endif
9084 return res;
9185 } else if (unlikely(res > 0)) {
92- _dl_dprintf(2, "4can't resolve symbol in lib '%s'.\n", tpnt->libname);
86+ _dl_dprintf(2, "3can't resolve symbol in lib '%s'.\n", tpnt->libname);
9387 return res;
9488 }
9589 }
--- a/libc/sysdeps/linux/aarch64/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/aarch64/bits/uClibc_arch_features.h
@@ -11,6 +11,9 @@
1111 /* can your target use syscall6() for mmap ? */
1212 #define __UCLIBC_MMAP_HAS_6_ARGS__
1313
14+/* does your target use statx */
15+#undef __UCLIBC_HAVE_STATX__
16+
1417 /* does your target have a broken create_module() ? */
1518 #define __UCLIBC_BROKEN_CREATE_MODULE__
1619
--- a/libc/sysdeps/linux/alpha/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/alpha/bits/uClibc_arch_features.h
@@ -11,6 +11,9 @@
1111 /* can your target use syscall6() for mmap ? */
1212 #define __UCLIBC_MMAP_HAS_6_ARGS__
1313
14+/* does your target use statx */
15+#undef __UCLIBC_HAVE_STATX__
16+
1417 /* does your target align 64bit values in register pairs ? (32bit arches only) */
1518 #undef __UCLIBC_SYSCALL_ALIGN_64BIT__
1619
--- a/libc/sysdeps/linux/arc/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/arc/bits/uClibc_arch_features.h
@@ -17,6 +17,9 @@
1717 /* can your target use syscall6() for mmap ? */
1818 #undef __UCLIBC_MMAP_HAS_6_ARGS__
1919
20+/* does your target use statx */
21+#undef __UCLIBC_HAVE_STATX__
22+
2023 /* does your target have a broken create_module() ? */
2124 #undef __UCLIBC_BROKEN_CREATE_MODULE__
2225
--- a/libc/sysdeps/linux/arm/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/arm/bits/uClibc_arch_features.h
@@ -11,6 +11,9 @@
1111 /* can your target use syscall6() for mmap ? */
1212 #undef __UCLIBC_MMAP_HAS_6_ARGS__
1313
14+/* does your target use statx */
15+#undef __UCLIBC_HAVE_STATX__
16+
1417 /* does your target align 64bit values in register pairs ? (32bit arches only) */
1518 #ifdef __ARM_EABI__
1619 #define __UCLIBC_SYSCALL_ALIGN_64BIT__
--- a/libc/sysdeps/linux/avr32/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/avr32/bits/uClibc_arch_features.h
@@ -12,6 +12,9 @@
1212 /* can your target use syscall6() for mmap ? */
1313 #define __UCLIBC_MMAP_HAS_6_ARGS__
1414
15+/* does your target use statx */
16+#undef __UCLIBC_HAVE_STATX__
17+
1518 /* does your target align 64bit values in register pairs ? (32bit arches only) */
1619 #undef __UCLIBC_SYSCALL_ALIGN_64BIT__
1720
--- a/libc/sysdeps/linux/bfin/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/bfin/bits/uClibc_arch_features.h
@@ -11,6 +11,9 @@
1111 /* can your target use syscall6() for mmap ? */
1212 #define __UCLIBC_MMAP_HAS_6_ARGS__
1313
14+/* does your target use statx */
15+#undef __UCLIBC_HAVE_STATX__
16+
1417 /* does your target align 64bit values in register pairs ? (32bit arches only) */
1518 #undef __UCLIBC_SYSCALL_ALIGN_64BIT__
1619
--- a/libc/sysdeps/linux/c6x/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/c6x/bits/uClibc_arch_features.h
@@ -12,6 +12,9 @@
1212 /* can your target use syscall6() for mmap ? */
1313 #define __UCLIBC_MMAP_HAS_6_ARGS__
1414
15+/* does your target use statx */
16+#undef __UCLIBC_HAVE_STATX__
17+
1518 /* does your target align 64bit values in register pairs ? (32bit arches only) */
1619 #undef __UCLIBC_SYSCALL_ALIGN_64BIT__
1720
--- /dev/null
+++ b/libc/sysdeps/linux/common/bits/statx.h
@@ -0,0 +1,93 @@
1+/* Generic statx-related definitions and declarations.
2+ Copyright (C) 2018-2019 Free Software Foundation, Inc.
3+
4+ The GNU C Library is free software; you can redistribute it and/or
5+ modify it under the terms of the GNU Lesser General Public
6+ License as published by the Free Software Foundation; either
7+ version 2.1 of the License, or (at your option) any later version.
8+
9+ The GNU C Library is distributed in the hope that it will be useful,
10+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+ Lesser General Public License for more details.
13+
14+ You should have received a copy of the GNU Lesser General Public
15+ License along with the GNU C Library; if not, see
16+ <https://www.gnu.org/licenses/>. */
17+
18+/* This interface is based on <linux/stat.h> in Linux. */
19+
20+#ifndef _SYS_STAT_H
21+# error Never include <bits/statx.h> directly, include <sys/stat.h> instead.
22+#endif
23+
24+struct statx_timestamp
25+{
26+ __int64_t tv_sec;
27+ __uint32_t tv_nsec;
28+ __int32_t __statx_timestamp_pad1[1];
29+};
30+
31+/* Warning: The kernel may add additional fields to this struct in the
32+ future. Only use this struct for calling the statx function, not
33+ for storing data. (Expansion will be controlled by the mask
34+ argument of the statx function.) */
35+struct statx
36+{
37+ __uint32_t stx_mask;
38+ __uint32_t stx_blksize;
39+ __uint64_t stx_attributes;
40+ __uint32_t stx_nlink;
41+ __uint32_t stx_uid;
42+ __uint32_t stx_gid;
43+ __uint16_t stx_mode;
44+ __uint16_t __statx_pad1[1];
45+ __uint64_t stx_ino;
46+ __uint64_t stx_size;
47+ __uint64_t stx_blocks;
48+ __uint64_t stx_attributes_mask;
49+ struct statx_timestamp stx_atime;
50+ struct statx_timestamp stx_btime;
51+ struct statx_timestamp stx_ctime;
52+ struct statx_timestamp stx_mtime;
53+ __uint32_t stx_rdev_major;
54+ __uint32_t stx_rdev_minor;
55+ __uint32_t stx_dev_major;
56+ __uint32_t stx_dev_minor;
57+ __uint64_t __statx_pad2[14];
58+};
59+
60+#ifndef STATX_TYPE
61+# define STATX_TYPE 0x0001U
62+# define STATX_MODE 0x0002U
63+# define STATX_NLINK 0x0004U
64+# define STATX_UID 0x0008U
65+# define STATX_GID 0x0010U
66+# define STATX_ATIME 0x0020U
67+# define STATX_MTIME 0x0040U
68+# define STATX_CTIME 0x0080U
69+# define STATX_INO 0x0100U
70+# define STATX_SIZE 0x0200U
71+# define STATX_BLOCKS 0x0400U
72+# define STATX_BASIC_STATS 0x07ffU
73+# define STATX_ALL 0x0fffU
74+# define STATX_BTIME 0x0800U
75+# define STATX__RESERVED 0x80000000U
76+
77+# define STATX_ATTR_COMPRESSED 0x0004
78+# define STATX_ATTR_IMMUTABLE 0x0010
79+# define STATX_ATTR_APPEND 0x0020
80+# define STATX_ATTR_NODUMP 0x0040
81+# define STATX_ATTR_ENCRYPTED 0x0800
82+# define STATX_ATTR_AUTOMOUNT 0x1000
83+#endif /* !STATX_TYPE */
84+
85+__BEGIN_DECLS
86+
87+/* Fill *BUF with information about PATH in DIRFD. */
88+int statx (int __dirfd, const char *__restrict __path, int __flags,
89+ unsigned int __mask, struct statx *__restrict __buf)
90+ __THROW __nonnull ((2, 5));
91+
92+__END_DECLS
93+
--- a/libc/sysdeps/linux/common/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/common/bits/uClibc_arch_features.h
@@ -14,6 +14,9 @@
1414 /* can your target use syscall6() for mmap ? */
1515 #undef __UCLIBC_MMAP_HAS_6_ARGS__
1616
17+/* does your target use statx */
18+#undef __UCLIBC_HAVE_STATX__
19+
1720 /* does your target align 64bit values in register pairs ? (32bit arches only) */
1821 #undef __UCLIBC_SYSCALL_ALIGN_64BIT__
1922
--- a/libc/sysdeps/linux/common/fstat.c
+++ b/libc/sysdeps/linux/common/fstat.c
@@ -29,6 +29,20 @@ int fstat(int fd, struct stat *buf)
2929 }
3030 libc_hidden_def(fstat)
3131
32+#elif __NR_statx && defined __UCLIBC_HAVE_STATX__
33+# include <fcntl.h>
34+# include <statx_cp.h>
35+
36+int fstat(int fd, struct stat *buf)
37+{
38+ struct statx tmp;
39+ int rc = INLINE_SYSCALL (statx, 5, fd, "", AT_EMPTY_PATH,
40+ STATX_BASIC_STATS, &tmp);
41+ if (rc == 0)
42+ __cp_stat_statx ((struct stat *)buf, &tmp);
43+}
44+libc_hidden_def(fstat)
45+
3246 #elif defined __NR_fstat
3347 int fstat(int fd, struct stat *buf)
3448 {
@@ -57,7 +71,7 @@ int fstat(int fd, struct stat *buf)
5771 libc_hidden_def(fstat)
5872 #endif
5973
60-# if ! defined __NR_fstat64
74+# if ! defined __NR_fstat64 && ! defined __UCLIBC_HAVE_STATX__
6175 strong_alias_untyped(fstat,fstat64)
6276 libc_hidden_def(fstat64)
6377 #endif
--- a/libc/sysdeps/linux/common/fstat64.c
+++ b/libc/sysdeps/linux/common/fstat64.c
@@ -28,9 +28,26 @@ int fstat64(int fd, struct stat64 *buf)
2828 __xstat64_conv(&kbuf, buf);
2929 }
3030 return result;
31+
3132 #else
3233 return __syscall_fstat64(fd, buf);
3334 #endif
3435 }
3536 libc_hidden_def(fstat64)
37+
38+#elif __NR_statx && defined __UCLIBC_HAVE_STATX__
39+# include <fcntl.h>
40+# include <statx_cp.h>
41+
42+int fstat64(int fd, struct stat64 *buf)
43+{
44+ struct statx tmp;
45+ int rc = INLINE_SYSCALL (statx, 5, fd, "", AT_EMPTY_PATH,
46+ STATX_BASIC_STATS, &tmp);
47+ if (rc == 0)
48+ __cp_stat_statx ((struct stat64 *)buf, &tmp);
49+
50+ return rc;
51+}
52+libc_hidden_def(fstat64)
3653 #endif
--- a/libc/sysdeps/linux/common/lstat.c
+++ b/libc/sysdeps/linux/common/lstat.c
@@ -28,6 +28,23 @@ int lstat(const char *file_name, struct stat *buf)
2828 }
2929 libc_hidden_def(lstat)
3030
31+#elif defined __NR_statx && defined __UCLIBC_HAVE_STATX__
32+# include <fcntl.h>
33+# include <statx_cp.h>
34+
35+int lstat(const char *file_name, struct stat *buf)
36+{
37+ struct statx tmp;
38+ int rc = INLINE_SYSCALL (statx, 5, AT_FDCWD, file_name,
39+ AT_NO_AUTOMOUNT | AT_SYMLINK_NOFOLLOW,
40+ STATX_BASIC_STATS, &tmp);
41+ if (rc == 0)
42+ __cp_stat_statx ((struct stat *)buf, &tmp);
43+
44+ return rc;
45+}
46+libc_hidden_def(lstat)
47+
3148 /* For systems which have both, prefer the old one */
3249 #else
3350 # include "xstatconv.h"
@@ -57,7 +74,7 @@ int lstat(const char *file_name, struct stat *buf)
5774 }
5875 libc_hidden_def(lstat)
5976
60-# if ! defined __NR_fstatat64 && ! defined __NR_lstat64
77+# if ! defined __NR_fstatat64 && ! defined __NR_lstat64 && ! defined __UCLIBC_HAS_STATX__
6178 strong_alias_untyped(lstat,lstat64)
6279 libc_hidden_def(lstat64)
6380 # endif
--- a/libc/sysdeps/linux/common/lstat64.c
+++ b/libc/sysdeps/linux/common/lstat64.c
@@ -29,6 +29,23 @@ int lstat64(const char *file_name, struct stat64 *buf)
2929 }
3030 libc_hidden_def(lstat64)
3131
32+#elif defined __NR_statx && defined __UCLIBC_HAVE_STATX__
33+# include <fcntl.h>
34+# include <statx_cp.h>
35+
36+int lstat64(const char *file_name, struct stat64 *buf)
37+{
38+ struct statx tmp;
39+ int rc = INLINE_SYSCALL (statx, 5, AT_FDCWD, file_name,
40+ AT_NO_AUTOMOUNT | AT_SYMLINK_NOFOLLOW,
41+ STATX_BASIC_STATS, &tmp);
42+ if (rc == 0)
43+ __cp_stat64_statx ((struct stat64 *)buf, &tmp);
44+
45+ return rc;
46+}
47+libc_hidden_def(lstat64)
48+
3249 /* For systems which have both, prefer the old one */
3350 #elif defined __NR_lstat64
3451 # include "xstatconv.h"
--- a/libc/sysdeps/linux/common/stat.c
+++ b/libc/sysdeps/linux/common/stat.c
@@ -27,7 +27,20 @@ int stat(const char *file_name, struct stat *buf)
2727 {
2828 return fstatat64(AT_FDCWD, file_name, buf, 0);
2929 }
30+#elif __NR_statx && defined __UCLIBC_HAVE_STATX__
31+# include <fcntl.h>
32+# include <statx_cp.h>
3033
34+int stat(const char *file_name, struct stat *buf)
35+{
36+ struct statx tmp;
37+ int rc = INLINE_SYSCALL (statx, 5, AT_FDCWD, file_name, AT_NO_AUTOMOUNT,
38+ STATX_BASIC_STATS, &tmp);
39+ if (rc == 0)
40+ __cp_stat_statx ((struct stat *)buf, &tmp);
41+
42+ return rc;
43+}
3144 #else
3245 # include "xstatconv.h"
3346
@@ -58,7 +71,7 @@ int stat(const char *file_name, struct stat *buf)
5871 #endif /* __NR_fstat64 */
5972 libc_hidden_def(stat)
6073
61-#if ! defined __NR_stat64 && ! defined __NR_fstatat64
74+#if ! defined __NR_stat64 && ! defined __NR_fstatat64 && ! defined __UCLIBC_HAVE_STATX__
6275 strong_alias_untyped(stat,stat64)
6376 libc_hidden_def(stat64)
6477 #endif
--- a/libc/sysdeps/linux/common/stat64.c
+++ b/libc/sysdeps/linux/common/stat64.c
@@ -20,6 +20,22 @@ int stat64(const char *file_name, struct stat64 *buf)
2020 }
2121 libc_hidden_def(stat64)
2222
23+#elif __NR_statx && defined __UCLIBC_HAVE_STATX__
24+# include <fcntl.h>
25+# include <statx_cp.h>
26+
27+int stat64(const char *file_name, struct stat64 *buf)
28+{
29+ struct statx tmp;
30+ int rc = INLINE_SYSCALL (statx, 5, AT_FDCWD, file_name, AT_NO_AUTOMOUNT,
31+ STATX_BASIC_STATS, &tmp);
32+ if (rc == 0)
33+ __cp_stat_statx ((struct stat64 *)buf, &tmp);
34+
35+ return rc;
36+}
37+libc_hidden_def(stat64)
38+
2339 /* For systems which have both, prefer the old one */
2440 # elif defined __NR_stat64
2541 # define __NR___syscall_stat64 __NR_stat64
--- /dev/null
+++ b/libc/sysdeps/linux/common/statx_cp.c
@@ -0,0 +1,72 @@
1+/* Struct statx to stat/stat64 conversion for Linux.
2+ Copyright (C) 2018 Free Software Foundation, Inc.
3+
4+ The GNU C Library is free software; you can redistribute it and/or
5+ modify it under the terms of the GNU Lesser General Public
6+ License as published by the Free Software Foundation; either
7+ version 2.1 of the License, or (at your option) any later version.
8+
9+ The GNU C Library is distributed in the hope that it will be useful,
10+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+ Lesser General Public License for more details.
13+
14+ You should have received a copy of the GNU Lesser General Public
15+ License along with the GNU C Library. If not, see
16+ <http://www.gnu.org/licenses/>. */
17+
18+#include <stddef.h>
19+#include <string.h>
20+#include <sys/stat.h>
21+
22+#include <statx_cp.h>
23+
24+#if !defined(__NR_fstat64) || !defined(__NR_fstatat64)
25+void
26+__cp_stat64_statx (struct stat64 *to, struct statx *from)
27+{
28+ memset (to, 0, sizeof (struct stat64));
29+ to->st_dev = ((from->stx_dev_minor & 0xff) | (from->stx_dev_major << 8)
30+ | ((from->stx_dev_minor & ~0xff) << 12));
31+ to->st_rdev = ((from->stx_rdev_minor & 0xff) | (from->stx_rdev_major << 8)
32+ | ((from->stx_rdev_minor & ~0xff) << 12));
33+ to->st_ino = from->stx_ino;
34+ to->st_mode = from->stx_mode;
35+ to->st_nlink = from->stx_nlink;
36+ to->st_uid = from->stx_uid;
37+ to->st_gid = from->stx_gid;
38+ to->st_atime = from->stx_atime.tv_sec;
39+ to->st_atim.tv_nsec = from->stx_atime.tv_nsec;
40+ to->st_mtime = from->stx_mtime.tv_sec;
41+ to->st_mtim.tv_nsec = from->stx_mtime.tv_nsec;
42+ to->st_ctime = from->stx_ctime.tv_sec;
43+ to->st_ctim.tv_nsec = from->stx_ctime.tv_nsec;
44+ to->st_size = from->stx_size;
45+ to->st_blocks = from->stx_blocks;
46+ to->st_blksize = from->stx_blksize;
47+}
48+
49+void
50+__cp_stat_statx (struct stat *to, struct statx *from)
51+{
52+ memset (to, 0, sizeof (struct stat));
53+ to->st_dev = ((from->stx_dev_minor & 0xff) | (from->stx_dev_major << 8)
54+ | ((from->stx_dev_minor & ~0xff) << 12));
55+ to->st_rdev = ((from->stx_rdev_minor & 0xff) | (from->stx_rdev_major << 8)
56+ | ((from->stx_rdev_minor & ~0xff) << 12));
57+ to->st_ino = from->stx_ino;
58+ to->st_mode = from->stx_mode;
59+ to->st_nlink = from->stx_nlink;
60+ to->st_uid = from->stx_uid;
61+ to->st_gid = from->stx_gid;
62+ to->st_atime = from->stx_atime.tv_sec;
63+ to->st_atim.tv_nsec = from->stx_atime.tv_nsec;
64+ to->st_mtime = from->stx_mtime.tv_sec;
65+ to->st_mtim.tv_nsec = from->stx_mtime.tv_nsec;
66+ to->st_ctime = from->stx_ctime.tv_sec;
67+ to->st_ctim.tv_nsec = from->stx_ctime.tv_nsec;
68+ to->st_size = from->stx_size;
69+ to->st_blocks = from->stx_blocks;
70+ to->st_blksize = from->stx_blksize;
71+}
72+#endif
--- /dev/null
+++ b/libc/sysdeps/linux/common/statx_cp.h
@@ -0,0 +1,22 @@
1+/* Struct statx to stat/stat64 conversion for Linux.
2+ Copyright (C) 2018 Free Software Foundation, Inc.
3+
4+ The GNU C Library is free software; you can redistribute it and/or
5+ modify it under the terms of the GNU Lesser General Public
6+ License as published by the Free Software Foundation; either
7+ version 2.1 of the License, or (at your option) any later version.
8+
9+ The GNU C Library is distributed in the hope that it will be useful,
10+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+ Lesser General Public License for more details.
13+
14+ You should have received a copy of the GNU Lesser General Public
15+ License along with the GNU C Library. If not, see
16+ <http://www.gnu.org/licenses/>. */
17+
18+extern void __cp_stat64_statx (struct stat64 *to, struct statx *from)
19+ attribute_hidden;
20+
21+extern void __cp_stat_statx (struct stat *to, struct statx *from)
22+ attribute_hidden;
--- a/libc/sysdeps/linux/cris/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/cris/bits/uClibc_arch_features.h
@@ -12,6 +12,9 @@
1212 /* can your target use syscall6() for mmap ? */
1313 #undef __UCLIBC_MMAP_HAS_6_ARGS__
1414
15+/* does your target use statx */
16+#undef __UCLIBC_HAVE_STATX__
17+
1518 /* does your target align 64bit values in register pairs ? (32bit arches only) */
1619 #undef __UCLIBC_SYSCALL_ALIGN_64BIT__
1720
--- a/libc/sysdeps/linux/csky/Makefile.arch
+++ b/libc/sysdeps/linux/csky/Makefile.arch
@@ -1,6 +1,6 @@
11 CSRC-y := clone.c __syscall_error.c cacheflush.c
22
33 SSRC-y := __longjmp.S setjmp.S
4-SSRC-y += libc-read_tp.S vfork.S csky_clone.S
4+SSRC-y += libc-read_tp.S csky_clone.S
55
66
--- a/libc/sysdeps/linux/csky/bits/fcntl.h
+++ b/libc/sysdeps/linux/csky/bits/fcntl.h
@@ -33,13 +33,13 @@
3333 #define O_ASYNC 020000
3434
3535 #ifdef __USE_XOPEN2K8
36-# define O_DIRECTORY 040000 /* Must be a directory. */
37-# define O_NOFOLLOW 0100000 /* Do not follow links. */
36+# define O_DIRECTORY 00200000 /* must be a directory */
37+# define O_NOFOLLOW 00400000 /* don't follow links */
3838 # define O_CLOEXEC 02000000 /* Set close_on_exec. */
3939 #endif
4040
4141 #ifdef __USE_GNU
42-# define O_DIRECT 0200000 /* Direct disk access. */
42+# define O_DIRECT 00040000 /* direct disk access hint */
4343 # define O_NOATIME 01000000 /* Do not set atime. */
4444 # define O_PATH 010000000 /* Resolve pathname but do not open file. */
4545 #endif
--- a/libc/sysdeps/linux/csky/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/csky/bits/uClibc_arch_features.h
@@ -17,6 +17,9 @@
1717 /* can your target use syscall6() for mmap ? */
1818 #undef __UCLIBC_MMAP_HAS_6_ARGS__
1919
20+/* does your target use statx */
21+#define __UCLIBC_HAVE_STATX__
22+
2023 #ifdef __CSKYABIV2__
2124 #undef __UCLIBC_SYSCALL_ALIGN_64BIT__
2225 #else
--- a/libc/sysdeps/linux/frv/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/frv/bits/uClibc_arch_features.h
@@ -12,6 +12,9 @@
1212 /* can your target use syscall6() for mmap ? */
1313 #undef __UCLIBC_MMAP_HAS_6_ARGS__
1414
15+/* does your target use statx */
16+#undef __UCLIBC_HAVE_STATX__
17+
1518 /* does your target align 64bit values in register pairs ? (32bit arches only) */
1619 #undef __UCLIBC_SYSCALL_ALIGN_64BIT__
1720
--- a/libc/sysdeps/linux/h8300/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/h8300/bits/uClibc_arch_features.h
@@ -12,6 +12,9 @@
1212 /* can your target use syscall6() for mmap ? */
1313 #define __UCLIBC_MMAP_HAS_6_ARGS__
1414
15+/* does your target use statx */
16+#undef __UCLIBC_HAVE_STATX__
17+
1518 /* does your target align 64bit values in register pairs ? (32bit arches only) */
1619 #undef __UCLIBC_SYSCALL_ALIGN_64BIT__
1720
--- a/libc/sysdeps/linux/hppa/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/hppa/bits/uClibc_arch_features.h
@@ -11,6 +11,9 @@
1111 /* can your target use syscall6() for mmap ? */
1212 #define __UCLIBC_MMAP_HAS_6_ARGS__
1313
14+/* does your target use statx */
15+#undef __UCLIBC_HAVE_STATX__
16+
1417 /* does your target align 64bit values in register pairs ? (32bit arches only) */
1518 #undef __UCLIBC_SYSCALL_ALIGN_64BIT__
1619
--- a/libc/sysdeps/linux/i386/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/i386/bits/uClibc_arch_features.h
@@ -11,6 +11,9 @@
1111 /* can your target use syscall6() for mmap ? */
1212 #undef __UCLIBC_MMAP_HAS_6_ARGS__
1313
14+/* does your target use statx */
15+#undef __UCLIBC_HAVE_STATX__
16+
1417 /* does your target align 64bit values in register pairs ? (32bit arches only) */
1518 #undef __UCLIBC_SYSCALL_ALIGN_64BIT__
1619
--- a/libc/sysdeps/linux/ia64/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/ia64/bits/uClibc_arch_features.h
@@ -11,6 +11,9 @@
1111 /* can your target use syscall6() for mmap ? */
1212 #define __UCLIBC_MMAP_HAS_6_ARGS__
1313
14+/* does your target use statx */
15+#undef __UCLIBC_HAVE_STATX__
16+
1417 /* does your target align 64bit values in register pairs ? (32bit arches only) */
1518 #undef __UCLIBC_SYSCALL_ALIGN_64BIT__
1619
--- a/libc/sysdeps/linux/lm32/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/lm32/bits/uClibc_arch_features.h
@@ -12,6 +12,9 @@
1212 /* can your target use syscall6() for mmap ? */
1313 #define __UCLIBC_MMAP_HAS_6_ARGS__
1414
15+/* does your target use statx */
16+#undef __UCLIBC_HAVE_STATX__
17+
1518 /* does your target have a broken create_module() ? */
1619 #undef __UCLIBC_BROKEN_CREATE_MODULE__
1720
--- a/libc/sysdeps/linux/m68k/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/m68k/bits/uClibc_arch_features.h
@@ -15,6 +15,9 @@
1515 /* can your target use syscall6() for mmap ? */
1616 #undef __UCLIBC_MMAP_HAS_6_ARGS__
1717
18+/* does your target use statx */
19+#undef __UCLIBC_HAVE_STATX__
20+
1821 /* does your target align 64bit values in register pairs ? (32bit arches only) */
1922 #undef __UCLIBC_SYSCALL_ALIGN_64BIT__
2023
--- a/libc/sysdeps/linux/metag/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/metag/bits/uClibc_arch_features.h
@@ -16,6 +16,9 @@
1616 /* can your target use syscall6() for mmap ? */
1717 #define __UCLIBC_MMAP_HAS_6_ARGS__
1818
19+/* does your target use statx */
20+#undef __UCLIBC_HAVE_STATX__
21+
1922 /* does your target align 64bit values in register pairs ? (32bit arches only) */
2023 #undef __UCLIBC_SYSCALL_ALIGN_64BIT__
2124
--- a/libc/sysdeps/linux/microblaze/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/microblaze/bits/uClibc_arch_features.h
@@ -11,6 +11,9 @@
1111 /* can your target use syscall6() for mmap ? */
1212 #define __UCLIBC_MMAP_HAS_6_ARGS__
1313
14+/* does your target use statx */
15+#undef __UCLIBC_HAVE_STATX__
16+
1417 /* does your target align 64bit values in register pairs ? (32bit arches only) */
1518 #undef __UCLIBC_SYSCALL_ALIGN_64BIT__
1619
--- a/libc/sysdeps/linux/mips/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/mips/bits/uClibc_arch_features.h
@@ -12,6 +12,9 @@
1212 /* can your target use syscall6() for mmap ? */
1313 #define __UCLIBC_MMAP_HAS_6_ARGS__
1414
15+/* does your target use statx */
16+#undef __UCLIBC_HAVE_STATX__
17+
1518 /* does your target align 64bit values in register pairs ? (32bit arches only) */
1619 #if _MIPS_SIM == _ABIO32
1720 #define __UCLIBC_SYSCALL_ALIGN_64BIT__
--- a/libc/sysdeps/linux/nds32/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/nds32/bits/uClibc_arch_features.h
@@ -13,6 +13,9 @@
1313 /* instruction used when calling abort() to kill yourself */
1414 #define __UCLIBC_ABORT_INSTRUCTION__ "bal abort"
1515
16+/* does your target use statx */
17+#undef __UCLIBC_HAVE_STATX__
18+
1619 /* does your target align 64bit values in register pairs ? (32bit arches only) */
1720 #define __UCLIBC_SYSCALL_ALIGN_64BIT__
1821
--- a/libc/sysdeps/linux/nios2/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/nios2/bits/uClibc_arch_features.h
@@ -12,6 +12,9 @@
1212 /* can your target use syscall6() for mmap ? */
1313 #undef __UCLIBC_MMAP_HAS_6_ARGS__
1414
15+/* does your target use statx */
16+#undef __UCLIBC_HAVE_STATX__
17+
1518 /* does your target align 64bit values in register pairs ? (32bit arches only) */
1619 #undef __UCLIBC_SYSCALL_ALIGN_64BIT__
1720
--- a/libc/sysdeps/linux/or1k/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/or1k/bits/uClibc_arch_features.h
@@ -14,6 +14,9 @@
1414 /* can your target use syscall6() for mmap ? */
1515 #define __UCLIBC_MMAP_HAS_6_ARGS__
1616
17+/* does your target use statx */
18+#undef __UCLIBC_HAVE_STATX__
19+
1720 /* does your target have a broken create_module() ? */
1821 #undef __UCLIBC_BROKEN_CREATE_MODULE__
1922
--- a/libc/sysdeps/linux/powerpc/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/powerpc/bits/uClibc_arch_features.h
@@ -11,6 +11,9 @@
1111 /* can your target use syscall6() for mmap ? */
1212 #define __UCLIBC_MMAP_HAS_6_ARGS__
1313
14+/* does your target use statx */
15+#undef __UCLIBC_HAVE_STATX__
16+
1417 /* does your target align 64bit values in register pairs ? (32bit arches only) */
1518 #define __UCLIBC_SYSCALL_ALIGN_64BIT__
1619
--- a/libc/sysdeps/linux/riscv64/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/riscv64/bits/uClibc_arch_features.h
@@ -10,6 +10,9 @@
1010 /* can your target use syscall6() for mmap ? */
1111 #define __UCLIBC_MMAP_HAS_6_ARGS__
1212
13+/* does your target use statx */
14+#undef __UCLIBC_HAVE_STATX__
15+
1316 #define __UCLIBC_SYSCALL_ALIGN_64BIT__
1417
1518 /* does your target have a broken create_module() ? */
--- a/libc/sysdeps/linux/sh/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/sh/bits/uClibc_arch_features.h
@@ -15,6 +15,9 @@
1515 /* can your target use syscall6() for mmap ? */
1616 #define __UCLIBC_MMAP_HAS_6_ARGS__
1717
18+/* does your target use statx */
19+#undef __UCLIBC_HAVE_STATX__
20+
1821 /* does your target align 64bit values in register pairs ? (32bit arches only) */
1922 #undef __UCLIBC_SYSCALL_ALIGN_64BIT__
2023
--- a/libc/sysdeps/linux/sparc/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/sparc/bits/uClibc_arch_features.h
@@ -11,6 +11,9 @@
1111 /* can your target use syscall6() for mmap ? */
1212 #define __UCLIBC_MMAP_HAS_6_ARGS__
1313
14+/* does your target use statx */
15+#undef __UCLIBC_HAVE_STATX__
16+
1417 /* does your target align 64bit values in register pairs ? (32bit arches only) */
1518 #undef __UCLIBC_SYSCALL_ALIGN_64BIT__
1619
--- a/libc/sysdeps/linux/sparc64/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/sparc64/bits/uClibc_arch_features.h
@@ -11,6 +11,9 @@
1111 /* can your target use syscall6() for mmap ? */
1212 #define __UCLIBC_MMAP_HAS_6_ARGS__
1313
14+/* does your target use statx */
15+#undef __UCLIBC_HAVE_STATX__
16+
1417 /* does your target align 64bit values in register pairs ? (32bit arches only) */
1518 #undef __UCLIBC_SYSCALL_ALIGN_64BIT__
1619
--- a/libc/sysdeps/linux/tile/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/tile/bits/uClibc_arch_features.h
@@ -10,6 +10,9 @@
1010 /* can your target use syscall6() for mmap ? */
1111 #undef __UCLIBC_MMAP_HAS_6_ARGS__
1212
13+/* does your target use statx */
14+#undef __UCLIBC_HAVE_STATX__
15+
1316 #define __UCLIBC_SYSCALL_ALIGN_64BIT__
1417
1518 /* does your target have a broken create_module() ? */
--- a/libc/sysdeps/linux/x86_64/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/x86_64/bits/uClibc_arch_features.h
@@ -11,6 +11,9 @@
1111 /* can your target use syscall6() for mmap ? */
1212 #define __UCLIBC_MMAP_HAS_6_ARGS__
1313
14+/* does your target use statx */
15+#undef __UCLIBC_HAVE_STATX__
16+
1417 /* does your target align 64bit values in register pairs ? (32bit arches only) */
1518 #undef __UCLIBC_SYSCALL_ALIGN_64BIT__
1619
--- a/libc/sysdeps/linux/xtensa/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/xtensa/bits/uClibc_arch_features.h
@@ -11,6 +11,9 @@
1111 /* can your target use syscall6() for mmap ? */
1212 #define __UCLIBC_MMAP_HAS_6_ARGS__
1313
14+/* does your target use statx */
15+#undef __UCLIBC_HAVE_STATX__
16+
1417 /* does your target align 64bit values in register pairs ? (32bit arches only) */
1518 #define __UCLIBC_SYSCALL_ALIGN_64BIT__
1619