Revision | 8a04c4d84c8a1a1297ec0c5cec5522112981e0c0 (tree) |
---|---|
Zeit | 2020-02-03 19:50:54 |
Autor | Waldemar Brodkorb <wbx@open...> |
Commiter | Waldemar Brodkorb |
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>
@@ -6,7 +6,6 @@ config FORCE_OPTIONS_FOR_ARCH | ||
6 | 6 | bool |
7 | 7 | default y |
8 | 8 | select ARCH_ANY_ENDIAN |
9 | - select ARCH_HAS_DEPRECATED_SYSCALLS | |
10 | 9 | select ARCH_USE_MMU |
11 | 10 | select ARCH_HAS_MMU |
12 | 11 |
@@ -67,6 +67,11 @@ __BEGIN_DECLS | ||
67 | 67 | # define AT_NO_AUTOMOUNT 0x800 /* Suppress terminal automount |
68 | 68 | traversal. */ |
69 | 69 | # 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. */ | |
70 | 75 | # endif |
71 | 76 | # define AT_EACCESS 0x200 /* Test access permitted for |
72 | 77 | effective IDs, not real IDs. */ |
@@ -393,6 +393,11 @@ extern int futimens (int __fd, const struct timespec __times[2]) __THROW; | ||
393 | 393 | #undef _MKNOD_VER |
394 | 394 | #define _MKNOD_VER 0 |
395 | 395 | |
396 | +#ifdef __USE_GNU | |
397 | +# include <bits/statx.h> | |
398 | +#endif | |
399 | + | |
400 | + | |
396 | 401 | __END_DECLS |
397 | 402 | |
398 | 403 |
@@ -36,9 +36,37 @@ extern int _dl_errno; | ||
36 | 36 | /* 1. common-generic ABI doesn't need kernel_stat translation |
37 | 37 | * 3. S_IS?ID already provided by stat.h |
38 | 38 | */ |
39 | +#include <fcntl.h> | |
39 | 40 | #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 | +} | |
40 | 66 | #endif |
41 | 67 | |
68 | +#define AT_NO_AUTOMOUNT 0x800 | |
69 | +#define AT_EMPTY_PATH 0x1000 | |
42 | 70 | |
43 | 71 | /* Here are the definitions for some syscalls that are used |
44 | 72 | 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, | ||
109 | 137 | # define __NR__dl_stat __NR_stat |
110 | 138 | static __always_inline _syscall2(int, _dl_stat, const char *, file_name, |
111 | 139 | 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 | +} | |
112 | 158 | #endif |
113 | 159 | |
114 | 160 | #if defined __NR_fstat64 && !defined __NR_fstat |
115 | 161 | # define __NR__dl_fstat __NR_fstat64 |
162 | +static __always_inline _syscall2(int, _dl_fstat, int, fd, struct stat *, buf) | |
116 | 163 | #elif defined __NR_fstat |
117 | 164 | # define __NR__dl_fstat __NR_fstat |
118 | -#endif | |
119 | 165 | 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 | |
120 | 182 | |
121 | 183 | #define __NR__dl_munmap __NR_munmap |
122 | 184 | static __always_inline _syscall2(int, _dl_munmap, void *, start, unsigned long, length) |
@@ -79,17 +79,11 @@ _dl_parse(struct elf_resolve *tpnt, struct r_scope_elem*scope, | ||
79 | 79 | strtab + symtab[symtab_index].st_name); |
80 | 80 | if (unlikely(res < 0)) { |
81 | 81 | 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", | |
88 | 83 | reloc_type, tpnt->libname); |
89 | -#endif | |
90 | 84 | return res; |
91 | 85 | } 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); | |
93 | 87 | return res; |
94 | 88 | } |
95 | 89 | } |
@@ -11,6 +11,9 @@ | ||
11 | 11 | /* can your target use syscall6() for mmap ? */ |
12 | 12 | #define __UCLIBC_MMAP_HAS_6_ARGS__ |
13 | 13 | |
14 | +/* does your target use statx */ | |
15 | +#undef __UCLIBC_HAVE_STATX__ | |
16 | + | |
14 | 17 | /* does your target have a broken create_module() ? */ |
15 | 18 | #define __UCLIBC_BROKEN_CREATE_MODULE__ |
16 | 19 |
@@ -11,6 +11,9 @@ | ||
11 | 11 | /* can your target use syscall6() for mmap ? */ |
12 | 12 | #define __UCLIBC_MMAP_HAS_6_ARGS__ |
13 | 13 | |
14 | +/* does your target use statx */ | |
15 | +#undef __UCLIBC_HAVE_STATX__ | |
16 | + | |
14 | 17 | /* does your target align 64bit values in register pairs ? (32bit arches only) */ |
15 | 18 | #undef __UCLIBC_SYSCALL_ALIGN_64BIT__ |
16 | 19 |
@@ -17,6 +17,9 @@ | ||
17 | 17 | /* can your target use syscall6() for mmap ? */ |
18 | 18 | #undef __UCLIBC_MMAP_HAS_6_ARGS__ |
19 | 19 | |
20 | +/* does your target use statx */ | |
21 | +#undef __UCLIBC_HAVE_STATX__ | |
22 | + | |
20 | 23 | /* does your target have a broken create_module() ? */ |
21 | 24 | #undef __UCLIBC_BROKEN_CREATE_MODULE__ |
22 | 25 |
@@ -11,6 +11,9 @@ | ||
11 | 11 | /* can your target use syscall6() for mmap ? */ |
12 | 12 | #undef __UCLIBC_MMAP_HAS_6_ARGS__ |
13 | 13 | |
14 | +/* does your target use statx */ | |
15 | +#undef __UCLIBC_HAVE_STATX__ | |
16 | + | |
14 | 17 | /* does your target align 64bit values in register pairs ? (32bit arches only) */ |
15 | 18 | #ifdef __ARM_EABI__ |
16 | 19 | #define __UCLIBC_SYSCALL_ALIGN_64BIT__ |
@@ -12,6 +12,9 @@ | ||
12 | 12 | /* can your target use syscall6() for mmap ? */ |
13 | 13 | #define __UCLIBC_MMAP_HAS_6_ARGS__ |
14 | 14 | |
15 | +/* does your target use statx */ | |
16 | +#undef __UCLIBC_HAVE_STATX__ | |
17 | + | |
15 | 18 | /* does your target align 64bit values in register pairs ? (32bit arches only) */ |
16 | 19 | #undef __UCLIBC_SYSCALL_ALIGN_64BIT__ |
17 | 20 |
@@ -11,6 +11,9 @@ | ||
11 | 11 | /* can your target use syscall6() for mmap ? */ |
12 | 12 | #define __UCLIBC_MMAP_HAS_6_ARGS__ |
13 | 13 | |
14 | +/* does your target use statx */ | |
15 | +#undef __UCLIBC_HAVE_STATX__ | |
16 | + | |
14 | 17 | /* does your target align 64bit values in register pairs ? (32bit arches only) */ |
15 | 18 | #undef __UCLIBC_SYSCALL_ALIGN_64BIT__ |
16 | 19 |
@@ -12,6 +12,9 @@ | ||
12 | 12 | /* can your target use syscall6() for mmap ? */ |
13 | 13 | #define __UCLIBC_MMAP_HAS_6_ARGS__ |
14 | 14 | |
15 | +/* does your target use statx */ | |
16 | +#undef __UCLIBC_HAVE_STATX__ | |
17 | + | |
15 | 18 | /* does your target align 64bit values in register pairs ? (32bit arches only) */ |
16 | 19 | #undef __UCLIBC_SYSCALL_ALIGN_64BIT__ |
17 | 20 |
@@ -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 | + |
@@ -14,6 +14,9 @@ | ||
14 | 14 | /* can your target use syscall6() for mmap ? */ |
15 | 15 | #undef __UCLIBC_MMAP_HAS_6_ARGS__ |
16 | 16 | |
17 | +/* does your target use statx */ | |
18 | +#undef __UCLIBC_HAVE_STATX__ | |
19 | + | |
17 | 20 | /* does your target align 64bit values in register pairs ? (32bit arches only) */ |
18 | 21 | #undef __UCLIBC_SYSCALL_ALIGN_64BIT__ |
19 | 22 |
@@ -29,6 +29,20 @@ int fstat(int fd, struct stat *buf) | ||
29 | 29 | } |
30 | 30 | libc_hidden_def(fstat) |
31 | 31 | |
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 | + | |
32 | 46 | #elif defined __NR_fstat |
33 | 47 | int fstat(int fd, struct stat *buf) |
34 | 48 | { |
@@ -57,7 +71,7 @@ int fstat(int fd, struct stat *buf) | ||
57 | 71 | libc_hidden_def(fstat) |
58 | 72 | #endif |
59 | 73 | |
60 | -# if ! defined __NR_fstat64 | |
74 | +# if ! defined __NR_fstat64 && ! defined __UCLIBC_HAVE_STATX__ | |
61 | 75 | strong_alias_untyped(fstat,fstat64) |
62 | 76 | libc_hidden_def(fstat64) |
63 | 77 | #endif |
@@ -28,9 +28,26 @@ int fstat64(int fd, struct stat64 *buf) | ||
28 | 28 | __xstat64_conv(&kbuf, buf); |
29 | 29 | } |
30 | 30 | return result; |
31 | + | |
31 | 32 | #else |
32 | 33 | return __syscall_fstat64(fd, buf); |
33 | 34 | #endif |
34 | 35 | } |
35 | 36 | 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) | |
36 | 53 | #endif |
@@ -28,6 +28,23 @@ int lstat(const char *file_name, struct stat *buf) | ||
28 | 28 | } |
29 | 29 | libc_hidden_def(lstat) |
30 | 30 | |
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 | + | |
31 | 48 | /* For systems which have both, prefer the old one */ |
32 | 49 | #else |
33 | 50 | # include "xstatconv.h" |
@@ -57,7 +74,7 @@ int lstat(const char *file_name, struct stat *buf) | ||
57 | 74 | } |
58 | 75 | libc_hidden_def(lstat) |
59 | 76 | |
60 | -# if ! defined __NR_fstatat64 && ! defined __NR_lstat64 | |
77 | +# if ! defined __NR_fstatat64 && ! defined __NR_lstat64 && ! defined __UCLIBC_HAS_STATX__ | |
61 | 78 | strong_alias_untyped(lstat,lstat64) |
62 | 79 | libc_hidden_def(lstat64) |
63 | 80 | # endif |
@@ -29,6 +29,23 @@ int lstat64(const char *file_name, struct stat64 *buf) | ||
29 | 29 | } |
30 | 30 | libc_hidden_def(lstat64) |
31 | 31 | |
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 | + | |
32 | 49 | /* For systems which have both, prefer the old one */ |
33 | 50 | #elif defined __NR_lstat64 |
34 | 51 | # include "xstatconv.h" |
@@ -27,7 +27,20 @@ int stat(const char *file_name, struct stat *buf) | ||
27 | 27 | { |
28 | 28 | return fstatat64(AT_FDCWD, file_name, buf, 0); |
29 | 29 | } |
30 | +#elif __NR_statx && defined __UCLIBC_HAVE_STATX__ | |
31 | +# include <fcntl.h> | |
32 | +# include <statx_cp.h> | |
30 | 33 | |
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 | +} | |
31 | 44 | #else |
32 | 45 | # include "xstatconv.h" |
33 | 46 |
@@ -58,7 +71,7 @@ int stat(const char *file_name, struct stat *buf) | ||
58 | 71 | #endif /* __NR_fstat64 */ |
59 | 72 | libc_hidden_def(stat) |
60 | 73 | |
61 | -#if ! defined __NR_stat64 && ! defined __NR_fstatat64 | |
74 | +#if ! defined __NR_stat64 && ! defined __NR_fstatat64 && ! defined __UCLIBC_HAVE_STATX__ | |
62 | 75 | strong_alias_untyped(stat,stat64) |
63 | 76 | libc_hidden_def(stat64) |
64 | 77 | #endif |
@@ -20,6 +20,22 @@ int stat64(const char *file_name, struct stat64 *buf) | ||
20 | 20 | } |
21 | 21 | libc_hidden_def(stat64) |
22 | 22 | |
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 | + | |
23 | 39 | /* For systems which have both, prefer the old one */ |
24 | 40 | # elif defined __NR_stat64 |
25 | 41 | # define __NR___syscall_stat64 __NR_stat64 |
@@ -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 |
@@ -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; |
@@ -12,6 +12,9 @@ | ||
12 | 12 | /* can your target use syscall6() for mmap ? */ |
13 | 13 | #undef __UCLIBC_MMAP_HAS_6_ARGS__ |
14 | 14 | |
15 | +/* does your target use statx */ | |
16 | +#undef __UCLIBC_HAVE_STATX__ | |
17 | + | |
15 | 18 | /* does your target align 64bit values in register pairs ? (32bit arches only) */ |
16 | 19 | #undef __UCLIBC_SYSCALL_ALIGN_64BIT__ |
17 | 20 |
@@ -1,6 +1,6 @@ | ||
1 | 1 | CSRC-y := clone.c __syscall_error.c cacheflush.c |
2 | 2 | |
3 | 3 | 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 | |
5 | 5 | |
6 | 6 |
@@ -33,13 +33,13 @@ | ||
33 | 33 | #define O_ASYNC 020000 |
34 | 34 | |
35 | 35 | #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 */ | |
38 | 38 | # define O_CLOEXEC 02000000 /* Set close_on_exec. */ |
39 | 39 | #endif |
40 | 40 | |
41 | 41 | #ifdef __USE_GNU |
42 | -# define O_DIRECT 0200000 /* Direct disk access. */ | |
42 | +# define O_DIRECT 00040000 /* direct disk access hint */ | |
43 | 43 | # define O_NOATIME 01000000 /* Do not set atime. */ |
44 | 44 | # define O_PATH 010000000 /* Resolve pathname but do not open file. */ |
45 | 45 | #endif |
@@ -17,6 +17,9 @@ | ||
17 | 17 | /* can your target use syscall6() for mmap ? */ |
18 | 18 | #undef __UCLIBC_MMAP_HAS_6_ARGS__ |
19 | 19 | |
20 | +/* does your target use statx */ | |
21 | +#define __UCLIBC_HAVE_STATX__ | |
22 | + | |
20 | 23 | #ifdef __CSKYABIV2__ |
21 | 24 | #undef __UCLIBC_SYSCALL_ALIGN_64BIT__ |
22 | 25 | #else |
@@ -12,6 +12,9 @@ | ||
12 | 12 | /* can your target use syscall6() for mmap ? */ |
13 | 13 | #undef __UCLIBC_MMAP_HAS_6_ARGS__ |
14 | 14 | |
15 | +/* does your target use statx */ | |
16 | +#undef __UCLIBC_HAVE_STATX__ | |
17 | + | |
15 | 18 | /* does your target align 64bit values in register pairs ? (32bit arches only) */ |
16 | 19 | #undef __UCLIBC_SYSCALL_ALIGN_64BIT__ |
17 | 20 |
@@ -12,6 +12,9 @@ | ||
12 | 12 | /* can your target use syscall6() for mmap ? */ |
13 | 13 | #define __UCLIBC_MMAP_HAS_6_ARGS__ |
14 | 14 | |
15 | +/* does your target use statx */ | |
16 | +#undef __UCLIBC_HAVE_STATX__ | |
17 | + | |
15 | 18 | /* does your target align 64bit values in register pairs ? (32bit arches only) */ |
16 | 19 | #undef __UCLIBC_SYSCALL_ALIGN_64BIT__ |
17 | 20 |
@@ -11,6 +11,9 @@ | ||
11 | 11 | /* can your target use syscall6() for mmap ? */ |
12 | 12 | #define __UCLIBC_MMAP_HAS_6_ARGS__ |
13 | 13 | |
14 | +/* does your target use statx */ | |
15 | +#undef __UCLIBC_HAVE_STATX__ | |
16 | + | |
14 | 17 | /* does your target align 64bit values in register pairs ? (32bit arches only) */ |
15 | 18 | #undef __UCLIBC_SYSCALL_ALIGN_64BIT__ |
16 | 19 |
@@ -11,6 +11,9 @@ | ||
11 | 11 | /* can your target use syscall6() for mmap ? */ |
12 | 12 | #undef __UCLIBC_MMAP_HAS_6_ARGS__ |
13 | 13 | |
14 | +/* does your target use statx */ | |
15 | +#undef __UCLIBC_HAVE_STATX__ | |
16 | + | |
14 | 17 | /* does your target align 64bit values in register pairs ? (32bit arches only) */ |
15 | 18 | #undef __UCLIBC_SYSCALL_ALIGN_64BIT__ |
16 | 19 |
@@ -11,6 +11,9 @@ | ||
11 | 11 | /* can your target use syscall6() for mmap ? */ |
12 | 12 | #define __UCLIBC_MMAP_HAS_6_ARGS__ |
13 | 13 | |
14 | +/* does your target use statx */ | |
15 | +#undef __UCLIBC_HAVE_STATX__ | |
16 | + | |
14 | 17 | /* does your target align 64bit values in register pairs ? (32bit arches only) */ |
15 | 18 | #undef __UCLIBC_SYSCALL_ALIGN_64BIT__ |
16 | 19 |
@@ -12,6 +12,9 @@ | ||
12 | 12 | /* can your target use syscall6() for mmap ? */ |
13 | 13 | #define __UCLIBC_MMAP_HAS_6_ARGS__ |
14 | 14 | |
15 | +/* does your target use statx */ | |
16 | +#undef __UCLIBC_HAVE_STATX__ | |
17 | + | |
15 | 18 | /* does your target have a broken create_module() ? */ |
16 | 19 | #undef __UCLIBC_BROKEN_CREATE_MODULE__ |
17 | 20 |
@@ -15,6 +15,9 @@ | ||
15 | 15 | /* can your target use syscall6() for mmap ? */ |
16 | 16 | #undef __UCLIBC_MMAP_HAS_6_ARGS__ |
17 | 17 | |
18 | +/* does your target use statx */ | |
19 | +#undef __UCLIBC_HAVE_STATX__ | |
20 | + | |
18 | 21 | /* does your target align 64bit values in register pairs ? (32bit arches only) */ |
19 | 22 | #undef __UCLIBC_SYSCALL_ALIGN_64BIT__ |
20 | 23 |
@@ -16,6 +16,9 @@ | ||
16 | 16 | /* can your target use syscall6() for mmap ? */ |
17 | 17 | #define __UCLIBC_MMAP_HAS_6_ARGS__ |
18 | 18 | |
19 | +/* does your target use statx */ | |
20 | +#undef __UCLIBC_HAVE_STATX__ | |
21 | + | |
19 | 22 | /* does your target align 64bit values in register pairs ? (32bit arches only) */ |
20 | 23 | #undef __UCLIBC_SYSCALL_ALIGN_64BIT__ |
21 | 24 |
@@ -11,6 +11,9 @@ | ||
11 | 11 | /* can your target use syscall6() for mmap ? */ |
12 | 12 | #define __UCLIBC_MMAP_HAS_6_ARGS__ |
13 | 13 | |
14 | +/* does your target use statx */ | |
15 | +#undef __UCLIBC_HAVE_STATX__ | |
16 | + | |
14 | 17 | /* does your target align 64bit values in register pairs ? (32bit arches only) */ |
15 | 18 | #undef __UCLIBC_SYSCALL_ALIGN_64BIT__ |
16 | 19 |
@@ -12,6 +12,9 @@ | ||
12 | 12 | /* can your target use syscall6() for mmap ? */ |
13 | 13 | #define __UCLIBC_MMAP_HAS_6_ARGS__ |
14 | 14 | |
15 | +/* does your target use statx */ | |
16 | +#undef __UCLIBC_HAVE_STATX__ | |
17 | + | |
15 | 18 | /* does your target align 64bit values in register pairs ? (32bit arches only) */ |
16 | 19 | #if _MIPS_SIM == _ABIO32 |
17 | 20 | #define __UCLIBC_SYSCALL_ALIGN_64BIT__ |
@@ -13,6 +13,9 @@ | ||
13 | 13 | /* instruction used when calling abort() to kill yourself */ |
14 | 14 | #define __UCLIBC_ABORT_INSTRUCTION__ "bal abort" |
15 | 15 | |
16 | +/* does your target use statx */ | |
17 | +#undef __UCLIBC_HAVE_STATX__ | |
18 | + | |
16 | 19 | /* does your target align 64bit values in register pairs ? (32bit arches only) */ |
17 | 20 | #define __UCLIBC_SYSCALL_ALIGN_64BIT__ |
18 | 21 |
@@ -12,6 +12,9 @@ | ||
12 | 12 | /* can your target use syscall6() for mmap ? */ |
13 | 13 | #undef __UCLIBC_MMAP_HAS_6_ARGS__ |
14 | 14 | |
15 | +/* does your target use statx */ | |
16 | +#undef __UCLIBC_HAVE_STATX__ | |
17 | + | |
15 | 18 | /* does your target align 64bit values in register pairs ? (32bit arches only) */ |
16 | 19 | #undef __UCLIBC_SYSCALL_ALIGN_64BIT__ |
17 | 20 |
@@ -14,6 +14,9 @@ | ||
14 | 14 | /* can your target use syscall6() for mmap ? */ |
15 | 15 | #define __UCLIBC_MMAP_HAS_6_ARGS__ |
16 | 16 | |
17 | +/* does your target use statx */ | |
18 | +#undef __UCLIBC_HAVE_STATX__ | |
19 | + | |
17 | 20 | /* does your target have a broken create_module() ? */ |
18 | 21 | #undef __UCLIBC_BROKEN_CREATE_MODULE__ |
19 | 22 |
@@ -11,6 +11,9 @@ | ||
11 | 11 | /* can your target use syscall6() for mmap ? */ |
12 | 12 | #define __UCLIBC_MMAP_HAS_6_ARGS__ |
13 | 13 | |
14 | +/* does your target use statx */ | |
15 | +#undef __UCLIBC_HAVE_STATX__ | |
16 | + | |
14 | 17 | /* does your target align 64bit values in register pairs ? (32bit arches only) */ |
15 | 18 | #define __UCLIBC_SYSCALL_ALIGN_64BIT__ |
16 | 19 |
@@ -10,6 +10,9 @@ | ||
10 | 10 | /* can your target use syscall6() for mmap ? */ |
11 | 11 | #define __UCLIBC_MMAP_HAS_6_ARGS__ |
12 | 12 | |
13 | +/* does your target use statx */ | |
14 | +#undef __UCLIBC_HAVE_STATX__ | |
15 | + | |
13 | 16 | #define __UCLIBC_SYSCALL_ALIGN_64BIT__ |
14 | 17 | |
15 | 18 | /* does your target have a broken create_module() ? */ |
@@ -15,6 +15,9 @@ | ||
15 | 15 | /* can your target use syscall6() for mmap ? */ |
16 | 16 | #define __UCLIBC_MMAP_HAS_6_ARGS__ |
17 | 17 | |
18 | +/* does your target use statx */ | |
19 | +#undef __UCLIBC_HAVE_STATX__ | |
20 | + | |
18 | 21 | /* does your target align 64bit values in register pairs ? (32bit arches only) */ |
19 | 22 | #undef __UCLIBC_SYSCALL_ALIGN_64BIT__ |
20 | 23 |
@@ -11,6 +11,9 @@ | ||
11 | 11 | /* can your target use syscall6() for mmap ? */ |
12 | 12 | #define __UCLIBC_MMAP_HAS_6_ARGS__ |
13 | 13 | |
14 | +/* does your target use statx */ | |
15 | +#undef __UCLIBC_HAVE_STATX__ | |
16 | + | |
14 | 17 | /* does your target align 64bit values in register pairs ? (32bit arches only) */ |
15 | 18 | #undef __UCLIBC_SYSCALL_ALIGN_64BIT__ |
16 | 19 |
@@ -11,6 +11,9 @@ | ||
11 | 11 | /* can your target use syscall6() for mmap ? */ |
12 | 12 | #define __UCLIBC_MMAP_HAS_6_ARGS__ |
13 | 13 | |
14 | +/* does your target use statx */ | |
15 | +#undef __UCLIBC_HAVE_STATX__ | |
16 | + | |
14 | 17 | /* does your target align 64bit values in register pairs ? (32bit arches only) */ |
15 | 18 | #undef __UCLIBC_SYSCALL_ALIGN_64BIT__ |
16 | 19 |
@@ -10,6 +10,9 @@ | ||
10 | 10 | /* can your target use syscall6() for mmap ? */ |
11 | 11 | #undef __UCLIBC_MMAP_HAS_6_ARGS__ |
12 | 12 | |
13 | +/* does your target use statx */ | |
14 | +#undef __UCLIBC_HAVE_STATX__ | |
15 | + | |
13 | 16 | #define __UCLIBC_SYSCALL_ALIGN_64BIT__ |
14 | 17 | |
15 | 18 | /* does your target have a broken create_module() ? */ |
@@ -11,6 +11,9 @@ | ||
11 | 11 | /* can your target use syscall6() for mmap ? */ |
12 | 12 | #define __UCLIBC_MMAP_HAS_6_ARGS__ |
13 | 13 | |
14 | +/* does your target use statx */ | |
15 | +#undef __UCLIBC_HAVE_STATX__ | |
16 | + | |
14 | 17 | /* does your target align 64bit values in register pairs ? (32bit arches only) */ |
15 | 18 | #undef __UCLIBC_SYSCALL_ALIGN_64BIT__ |
16 | 19 |
@@ -11,6 +11,9 @@ | ||
11 | 11 | /* can your target use syscall6() for mmap ? */ |
12 | 12 | #define __UCLIBC_MMAP_HAS_6_ARGS__ |
13 | 13 | |
14 | +/* does your target use statx */ | |
15 | +#undef __UCLIBC_HAVE_STATX__ | |
16 | + | |
14 | 17 | /* does your target align 64bit values in register pairs ? (32bit arches only) */ |
15 | 18 | #define __UCLIBC_SYSCALL_ALIGN_64BIT__ |
16 | 19 |