asm-generic ABI: Allow statx syscall despite fstatat64, fstat64
PATCH 1/1 asm-generic ABI: Allow statx syscall despite fstatat64, fstat64
An old version of asm-generic syscall ABI (e.g. ARC 2013) provided fstat[at]64 syscalls for implementing the stat family.
These sycalls are passthru (no interworking/itemized-copy needed between kernel and user structs since they are binary comaptible). However with switch to 64-bit time_t the compatibily goes away so we need explicit interworking. Luckily such code already exists albeit it uses the statx syscall.
So this patch reworks the asm-generic based stat functions to use the statx code-path if the arch so desires. It essentially reworks the commit 6bbfc5c09fc5b5e3 ("Add statx conditionals for wordsize-32 *xstat.c")
This will be used by ARC port for 64-bit time_t. But it has no real bearing on 64-bit and can just be independently opted-in by an arch port provided the ABI supports it.
--- sysdeps/unix/sysv/linux/fxstat64.c | 8 ++++---- sysdeps/unix/sysv/linux/fxstatat64.c | 6 +++--- sysdeps/unix/sysv/linux/generic/kernel_stat.h | 7 +++++++ sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat.c | 6 +++--- sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat.c | 6 +++--- sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat.c | 10 +++++----- sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat64.c | 8 ++++---- sysdeps/unix/sysv/linux/generic/wordsize-32/xstat.c | 6 +++--- sysdeps/unix/sysv/linux/generic/wordsize-32/xstat64.c | 6 +++--- sysdeps/unix/sysv/linux/statx_cp.c | 2 +- 10 files changed, 36 insertions(+), 29 deletions(-)
sysdeps/unix/sysv/linux/fxstat64.c +4 -4
@@ -33,15 +33,15 @@ int ___fxstat64 (int vers, int fd, struct stat64 *buf) { int result; -#ifdef __NR_fstat64 - result =INLINE_SYSCALL (fstat64,2 , fd, buf); -#else +# if defined(STAT64_IS_NOT_KERNEL_STAT64 ) || !defined(__NR_fstat64)struct statx tmp; result =INLINE_SYSCALL (statx,5 , fd,"" ,AT_EMPTY_PATH ,STATX_BASIC_STATS , &tmp);if (result ==0 )__cp_stat64_statx (buf, &tmp); -#endif +# else + result =INLINE_SYSCALL (fstat64,2 , fd, buf); +# endif return result; }
sysdeps/unix/sysv/linux/fxstatat64.c +3 -3
@@ -38,15 +38,15 @@ __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag)int result; -#ifdef __NR_fstatat64 - result =INTERNAL_SYSCALL_CALL (fstatat64, fd, file, st, flag); -#else +# if defined(STAT64_IS_NOT_KERNEL_STAT64 ) || !defined(__NR_fstatat64)struct statx tmp; result =INTERNAL_SYSCALL_CALL (statx, fd, file,AT_NO_AUTOMOUNT | flag,STATX_BASIC_STATS , &tmp);if (result ==0 )__cp_stat64_statx (st, &tmp); +#else + result =INTERNAL_SYSCALL_CALL (fstatat64, fd, file, st, flag);#endif if (!__glibc_likely (INTERNAL_SYSCALL_ERROR_P (result)))return 0 ;
sysdeps/unix/sysv/linux/generic/kernel_stat.h +7 -0
@@ -28,3 +28,10 @@#endif #define STATFS_IS_STATFS64 0 + +/* Ports define to 1 when glibc struct stat64 is not compatible with +kernel stat64. This forces use of statx syscall (and explicit interworking) +even when fstat64 syscall is available. For asm-generic ABI this happened +with switch to 64-bit time_t. */ + +# undef STAT64_IS_NOT_KERNEL_STAT64
sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat.c +3 -3
@@ -36,14 +36,14 @@ __fxstat (int vers, int fd, struct stat *buf) {if (vers == _STAT_VER_KERNEL) { -# ifdef __NR_fstat64 -int rc =INLINE_SYSCALL (fstat64,2 , fd, buf); -# else +# if defined(STAT64_IS_NOT_KERNEL_STAT64 ) || !defined(__NR_fstat64)struct statx tmp;int rc =INLINE_SYSCALL (statx,5 , fd,"" ,AT_EMPTY_PATH ,STATX_BASIC_STATS , &tmp);if (rc ==0 )__cp_stat64_statx ((struct stat64 *)buf, &tmp); +# else +int rc =INLINE_SYSCALL (fstat64,2 , fd, buf);# endif return rc ?:stat_overflow (buf); }
sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat.c +3 -3
@@ -36,15 +36,15 @@ __fxstatat (int vers, int fd, const char *file, struct stat *buf, int flag) {if (vers == _STAT_VER_KERNEL) { -# ifdef __NR_fstatat64 -int rc =INLINE_SYSCALL (fstatat64,4 , fd, file, buf, flag); -# else +# if defined(STAT64_IS_NOT_KERNEL_STAT64 ) || !defined(__NR_fstat64)struct statx tmp;int rc =INLINE_SYSCALL (statx,5 , fd, file,AT_NO_AUTOMOUNT | flag,STATX_BASIC_STATS , &tmp);if (rc ==0 )__cp_stat64_statx ((struct stat64 *)buf, &tmp); +# else +int rc =INLINE_SYSCALL (fstatat64,4 , fd, file, buf, flag);# endif return rc ?:stat_overflow (buf); }
sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat.c +5 -5
@@ -35,17 +35,17 @@ __lxstat (int vers, const char *name, struct stat *buf) {if (vers == _STAT_VER_KERNEL) { -#ifdef __NR_fstatat64 -int rc =INLINE_SYSCALL (fstatat64,4 ,AT_FDCWD , name, buf, -AT_SYMLINK_NOFOLLOW ); -#else +# if defined(STAT64_IS_NOT_KERNEL_STAT64 ) || !defined(__NR_fstat64)struct statx tmp;int rc =INLINE_SYSCALL (statx,5 ,AT_FDCWD , name,AT_NO_AUTOMOUNT |AT_SYMLINK_NOFOLLOW ,STATX_BASIC_STATS , &tmp);if (rc ==0 )__cp_stat64_statx ((struct stat64 *)buf, &tmp); -#endif +# else +int rc =INLINE_SYSCALL (fstatat64,4 ,AT_FDCWD , name, buf, +AT_SYMLINK_NOFOLLOW ); +# endif return rc ?:stat_overflow (buf); } errno =EINVAL ;
sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat64.c +4 -4
@@ -40,10 +40,7 @@ __lxstat64 (int vers, const char *name, struct stat64 *buf) {if (vers == _STAT_VER_KERNEL) { -#ifdef __NR_fstatat64 -return INLINE_SYSCALL (fstatat64,4 ,AT_FDCWD , name, buf, -AT_SYMLINK_NOFOLLOW ); -#else +# if defined(STAT64_IS_NOT_KERNEL_STAT64 ) || !defined(__NR_fstat64)struct statx tmp; int rc = INLINE_SYSCALL (statx, 5, AT_FDCWD, name, AT_NO_AUTOMOUNT | AT_SYMLINK_NOFOLLOW,
@@ -51,6 +48,9 @@ __lxstat64 (int vers, const char *name, struct stat64 *buf)if (rc ==0 )__cp_stat64_statx (buf, &tmp);return rc; +#else +return INLINE_SYSCALL (fstatat64,4 ,AT_FDCWD , name, buf, +AT_SYMLINK_NOFOLLOW );#endif }
sysdeps/unix/sysv/linux/generic/wordsize-32/xstat.c +3 -3
@@ -35,14 +35,14 @@ __xstat (int vers, const char *name, struct stat *buf) {if (vers == _STAT_VER_KERNEL) { -# ifdef __NR_fstatat64 -int rc =INLINE_SYSCALL (fstatat64,4 ,AT_FDCWD , name, buf,0 ); -# else +# if defined(STAT64_IS_NOT_KERNEL_STAT64 ) || !defined(__NR_fstat64)struct statx tmp;int rc =INLINE_SYSCALL (statx,5 ,AT_FDCWD , name,AT_NO_AUTOMOUNT ,STATX_BASIC_STATS , &tmp);if (rc ==0 )__cp_stat64_statx ((struct stat64 *)buf, &tmp); +# else +int rc =INLINE_SYSCALL (fstatat64,4 ,AT_FDCWD , name, buf,0 );# endif return rc ?:stat_overflow (buf); }
sysdeps/unix/sysv/linux/generic/wordsize-32/xstat64.c +3 -3
@@ -40,15 +40,15 @@ __xstat64 (int vers, const char *name, struct stat64 *buf) {if (vers == _STAT_VER_KERNEL) { -#ifdef __NR_fstatat64 -return INLINE_SYSCALL (fstatat64,4 ,AT_FDCWD , name, buf,0 ); -#else +# if defined(STAT64_IS_NOT_KERNEL_STAT64 ) || !defined(__NR_fstat64)struct statx tmp;int rc =INLINE_SYSCALL (statx,5 ,AT_FDCWD , name,AT_NO_AUTOMOUNT ,STATX_BASIC_STATS , &tmp);if (rc ==0 )__cp_stat64_statx (buf, &tmp);return rc; +#else +return INLINE_SYSCALL (fstatat64,4 ,AT_FDCWD , name, buf,0 );#endif } errno =EINVAL ;
sysdeps/unix/sysv/linux/statx_cp.c +1 -1
@@ -22,7 +22,7 @@#include <statx_cp.h> -#if !defined(__NR_fstat64) || !defined(__NR_fstatat64) +#if !defined(__NR_fstat64) || !defined(__NR_fstatat64) || defined(STAT64_IS_NOT_KERNEL_STAT64 )void __cp_stat64_statx (struct stat64 *to,struct statx *from) {
Signature · 7 lines
2.20.1 _______________________________________________ linux-snps-arc mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-snps-arc
* Vineet Gupta:
sysdeps/unix/sysv/linux/generic/kernel_stat.h line 37
Quoted 6 lines
sysdeps/unix/sysv/linux/generic/kernel_stat.h +6
-0+/* Ports define to 1 when glibc struct stat64 is not compatible with +kernel stat64. This forces use of statx syscall (and explicit interworking) +even when fstat64 syscall is available. For asm-generic ABI this happened +with switch to 64-bit time_t. */ + +# undef STAT64_IS_NOT_KERNEL_STAT64
Sorry, I think that going forward, we prefer that such macros are always defined, with values 0 or 1 as appropriate.
Thanks,
Florian
_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH] asm-generic ABI: Allow statx syscall despite fstatat64,fstat64
Quoted 4 lines · Florian Weimer
Quoted 1 line
+# undef
STAT64_IS_NOT_KERNEL_STAT64Sorry, I think that going forward, we prefer that such macros are always defined, with values 0 or 1 as appropriate.
And that means we also need to additionally define this to 0 in all ports which don't end up including the generic header ?
Thx,
-Vineet
_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
* Vineet Gupta:
Quoted 8 lines · Florian Weimer
Quoted 4 lines
Quoted 1 line
+# undef
STAT64_IS_NOT_KERNEL_STAT64Sorry, I think that going forward, we prefer that such macros are always defined, with values 0 or 1 as appropriate.
And that means we also need to additionally define this to 0 in all ports which don't end up including the generic header ?
Yes, or move the definition into its own header, with the default for *future* architectures (not the majority of the current architectures) in the header in the sysdeps/unix/sysv/linux directory.
Thanks,
Florian
_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH] asm-generic ABI: Allow statx syscall despite fstatat64,fstat64
Quoted 7 lines · Florian Weimer
* Vineet Gupta:
Quoted 5 lines · Florian Weimer
Quoted 3 lines
Quoted 1 line
+# undef
STAT64_IS_NOT_KERNEL_STAT64Sorry, I think that going forward, we prefer that such macros are always defined, with values 0 or 1 as appropriate.
Quoted 6 lines
Quoted 2 lines
And that means we also need to additionally define this to 0 in all ports which don't end up including the generic header ?
Yes, or move the definition into its own header, with the default for *future* architectures (not the majority of the current architectures) in the header in the sysdeps/unix/sysv/linux directory.
Adding a new file would seem too kludgy. Adding it to existing arch headers is still OK but then one needs to know what exact syscall ABI each arch has as even asm-generic ones differ depending on when the linux port was merged. And the only way to know that is to do a build for each arch or is there some documentation one could refer to.
Thx,
-Vineet
_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
* Vineet Gupta:
Quoted 8 lines · Florian Weimer
Quoted 7 lines
* Vineet Gupta:
Quoted 5 lines · Florian Weimer
Quoted 3 lines
Quoted 1 line
+# undef
STAT64_IS_NOT_KERNEL_STAT64Sorry, I think that going forward, we prefer that such macros are always defined, with values 0 or 1 as appropriate.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
And that means we also need to additionally define this to 0 in all ports which don't end up including the generic header ?
Yes, or move the definition into its own header, with the default for *future* architectures (not the majority of the current architectures) in the header in the sysdeps/unix/sysv/linux directory.
Adding a new file would seem too kludgy.
I think it's the preferred approach. Here's a recent discussion that looks at a few options in this space:
<https://sourceware.org/ml/libc-alpha/2019-10/msg00030.html>
Quoted 5 lines
Adding it to existing arch headers is still OK but then one needs to know what exact syscall ABI each arch has as even asm-generic ones differ depending on when the linux port was merged. And the only way to know that is to do a build for each arch or is there some documentation one could refer to.
In your case, the build should fail somewhere if there is a mismatch and the #define is incorrect for a particular architecture. In this case, you can keep running build-many-glibcs.py and making tweaks to the failing architectures until all failures are gone.
Thanks,
Florian
_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
PATCH v2 1/1 asm-generic ABI: Allow statx syscall despite fstatat64, fstat64
An old version of asm-generic syscall ABI (e.g. ARC 2013) provided fstat[at]64 syscalls for implementing the stat family.
These sycalls are passthru (no interworking/itemized-copy needed between kernel and user structs since they are binary comaptible). However with switch to 64-bit time_t the compatibily goes away so we need explicit interworking. Luckily such code already exists albeit it uses the statx syscall.
So this patch reworks the asm-generic based stat functions to use the statx code-path if the arch so desires. It essentially reworks the commit 6bbfc5c09fc5b5e3 ("Add statx conditionals for wordsize-32 *xstat.c")
This will be used by ARC port for 64-bit time_t. But it has no real bearing on 64-bit and can just be independently opted-in by an arch port provided the ABI supports it.
---
Changes since v1
* make the toggle #if style rather than #ifdef style
* define to 0 in all arches which don't use it
--- sysdeps/unix/sysv/linux/alpha/kernel_stat.h | 1 + sysdeps/unix/sysv/linux/fxstat64.c | 8 ++++---- sysdeps/unix/sysv/linux/fxstatat64.c | 6 +++--- sysdeps/unix/sysv/linux/generic/kernel_stat.h | 7 +++++++ sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat.c | 6 +++--- sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat.c | 6 +++--- sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat.c | 10 +++++----- sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat64.c | 8 ++++---- sysdeps/unix/sysv/linux/generic/wordsize-32/xstat.c | 6 +++--- sysdeps/unix/sysv/linux/generic/wordsize-32/xstat64.c | 6 +++--- sysdeps/unix/sysv/linux/hppa/kernel_stat.h | 1 + sysdeps/unix/sysv/linux/ia64/kernel_stat.h | 1 + sysdeps/unix/sysv/linux/kernel_stat.h | 1 + sysdeps/unix/sysv/linux/microblaze/kernel_stat.h | 1 + sysdeps/unix/sysv/linux/mips/kernel_stat.h | 1 + .../unix/sysv/linux/powerpc/powerpc32/kernel_stat.h | 1 + .../unix/sysv/linux/powerpc/powerpc64/kernel_stat.h | 1 + sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h | 1 + sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h | 1 + sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h | 1 + sysdeps/unix/sysv/linux/statx_cp.c | 2 +- sysdeps/unix/sysv/linux/x86_64/kernel_stat.h | 1 + 22 files changed, 48 insertions(+), 29 deletions(-)
sysdeps/unix/sysv/linux/alpha/kernel_stat.h +1 -0
@@ -87,3 +87,4 @@ struct glibc21_stat#define XSTAT_IS_XSTAT64 1#define STATFS_IS_STATFS64 0 +#define STAT64_IS_NOT_KERNEL_STAT64 0
sysdeps/unix/sysv/linux/fxstat64.c +4 -4
@@ -33,15 +33,15 @@ int ___fxstat64 (int vers, int fd, struct stat64 *buf) { int result; -#ifdef __NR_fstat64 - result =INLINE_SYSCALL (fstat64,2 , fd, buf); -#else +# if STAT64_IS_NOT_KERNEL_STAT64 || !defined(__NR_fstat64)struct statx tmp; result =INLINE_SYSCALL (statx,5 , fd,"" ,AT_EMPTY_PATH ,STATX_BASIC_STATS , &tmp);if (result ==0 )__cp_stat64_statx (buf, &tmp); -#endif +# else + result =INLINE_SYSCALL (fstat64,2 , fd, buf); +# endif return result; }
sysdeps/unix/sysv/linux/fxstatat64.c +3 -3
@@ -38,15 +38,15 @@ __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag)int result; -#ifdef __NR_fstatat64 - result =INTERNAL_SYSCALL_CALL (fstatat64, fd, file, st, flag); -#else +# if STAT64_IS_NOT_KERNEL_STAT64 || !defined(__NR_fstatat64)struct statx tmp; result =INTERNAL_SYSCALL_CALL (statx, fd, file,AT_NO_AUTOMOUNT | flag,STATX_BASIC_STATS , &tmp);if (result ==0 )__cp_stat64_statx (st, &tmp); +#else + result =INTERNAL_SYSCALL_CALL (fstatat64, fd, file, st, flag);#endif if (!__glibc_likely (INTERNAL_SYSCALL_ERROR_P (result)))return 0 ;
sysdeps/unix/sysv/linux/generic/kernel_stat.h +7 -0
@@ -28,3 +28,10 @@#endif #define STATFS_IS_STATFS64 0 + +/* Allows asm-generic ABI ports with fstat64 syscall to use statx syscall for +implement stat* wrappers. This is needed when glibc stat64 is not compatible +with kernel stat64 (due to 64-bit time_t). By default it is off unless +arch opts-in. */ + +#define STAT64_IS_NOT_KERNEL_STAT64 0
sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat.c +3 -3
@@ -36,14 +36,14 @@ __fxstat (int vers, int fd, struct stat *buf) {if (vers == _STAT_VER_KERNEL) { -# ifdef __NR_fstat64 -int rc =INLINE_SYSCALL (fstat64,2 , fd, buf); -# else +# if STAT64_IS_NOT_KERNEL_STAT64 || !defined(__NR_fstat64)struct statx tmp;int rc =INLINE_SYSCALL (statx,5 , fd,"" ,AT_EMPTY_PATH ,STATX_BASIC_STATS , &tmp);if (rc ==0 )__cp_stat64_statx ((struct stat64 *)buf, &tmp); +# else +int rc =INLINE_SYSCALL (fstat64,2 , fd, buf);# endif return rc ?:stat_overflow (buf); }
sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat.c +3 -3
@@ -36,15 +36,15 @@ __fxstatat (int vers, int fd, const char *file, struct stat *buf, int flag) {if (vers == _STAT_VER_KERNEL) { -# ifdef __NR_fstatat64 -int rc =INLINE_SYSCALL (fstatat64,4 , fd, file, buf, flag); -# else +# if STAT64_IS_NOT_KERNEL_STAT64 || !defined(__NR_fstat64)struct statx tmp;int rc =INLINE_SYSCALL (statx,5 , fd, file,AT_NO_AUTOMOUNT | flag,STATX_BASIC_STATS , &tmp);if (rc ==0 )__cp_stat64_statx ((struct stat64 *)buf, &tmp); +# else +int rc =INLINE_SYSCALL (fstatat64,4 , fd, file, buf, flag);# endif return rc ?:stat_overflow (buf); }
sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat.c +5 -5
@@ -35,17 +35,17 @@ __lxstat (int vers, const char *name, struct stat *buf) {if (vers == _STAT_VER_KERNEL) { -#ifdef __NR_fstatat64 -int rc =INLINE_SYSCALL (fstatat64,4 ,AT_FDCWD , name, buf, -AT_SYMLINK_NOFOLLOW ); -#else +# if STAT64_IS_NOT_KERNEL_STAT64 || !defined(__NR_fstat64)struct statx tmp;int rc =INLINE_SYSCALL (statx,5 ,AT_FDCWD , name,AT_NO_AUTOMOUNT |AT_SYMLINK_NOFOLLOW ,STATX_BASIC_STATS , &tmp);if (rc ==0 )__cp_stat64_statx ((struct stat64 *)buf, &tmp); -#endif +# else +int rc =INLINE_SYSCALL (fstatat64,4 ,AT_FDCWD , name, buf, +AT_SYMLINK_NOFOLLOW ); +# endif return rc ?:stat_overflow (buf); } errno =EINVAL ;
sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat64.c +4 -4
@@ -40,10 +40,7 @@ __lxstat64 (int vers, const char *name, struct stat64 *buf) {if (vers == _STAT_VER_KERNEL) { -#ifdef __NR_fstatat64 -return INLINE_SYSCALL (fstatat64,4 ,AT_FDCWD , name, buf, -AT_SYMLINK_NOFOLLOW ); -#else +# if STAT64_IS_NOT_KERNEL_STAT64 || !defined(__NR_fstat64)struct statx tmp; int rc = INLINE_SYSCALL (statx, 5, AT_FDCWD, name, AT_NO_AUTOMOUNT | AT_SYMLINK_NOFOLLOW,
@@ -51,6 +48,9 @@ __lxstat64 (int vers, const char *name, struct stat64 *buf)if (rc ==0 )__cp_stat64_statx (buf, &tmp);return rc; +#else +return INLINE_SYSCALL (fstatat64,4 ,AT_FDCWD , name, buf, +AT_SYMLINK_NOFOLLOW );#endif }
sysdeps/unix/sysv/linux/generic/wordsize-32/xstat.c +3 -3
@@ -35,14 +35,14 @@ __xstat (int vers, const char *name, struct stat *buf) {if (vers == _STAT_VER_KERNEL) { -# ifdef __NR_fstatat64 -int rc =INLINE_SYSCALL (fstatat64,4 ,AT_FDCWD , name, buf,0 ); -# else +# if STAT64_IS_NOT_KERNEL_STAT64 || !defined(__NR_fstat64)struct statx tmp;int rc =INLINE_SYSCALL (statx,5 ,AT_FDCWD , name,AT_NO_AUTOMOUNT ,STATX_BASIC_STATS , &tmp);if (rc ==0 )__cp_stat64_statx ((struct stat64 *)buf, &tmp); +# else +int rc =INLINE_SYSCALL (fstatat64,4 ,AT_FDCWD , name, buf,0 );# endif return rc ?:stat_overflow (buf); }
sysdeps/unix/sysv/linux/generic/wordsize-32/xstat64.c +3 -3
@@ -40,15 +40,15 @@ __xstat64 (int vers, const char *name, struct stat64 *buf) {if (vers == _STAT_VER_KERNEL) { -#ifdef __NR_fstatat64 -return INLINE_SYSCALL (fstatat64,4 ,AT_FDCWD , name, buf,0 ); -#else +# if STAT64_IS_NOT_KERNEL_STAT64 || !defined(__NR_fstat64)struct statx tmp;int rc =INLINE_SYSCALL (statx,5 ,AT_FDCWD , name,AT_NO_AUTOMOUNT ,STATX_BASIC_STATS , &tmp);if (rc ==0 )__cp_stat64_statx (buf, &tmp);return rc; +#else +return INLINE_SYSCALL (fstatat64,4 ,AT_FDCWD , name, buf,0 );#endif } errno =EINVAL ;
sysdeps/unix/sysv/linux/hppa/kernel_stat.h +1 -0
@@ -32,3 +32,4 @@ struct kernel_stat {#define XSTAT_IS_XSTAT64 0#define STATFS_IS_STATFS64 0 +#define STAT64_IS_NOT_KERNEL_STAT64 0
sysdeps/unix/sysv/linux/ia64/kernel_stat.h +1 -0
@@ -19,3 +19,4 @@#define STAT_IS_KERNEL_STAT 1#define XSTAT_IS_XSTAT64 1#define STATFS_IS_STATFS64 0 +#define STAT64_IS_NOT_KERNEL_STAT64 0
sysdeps/unix/sysv/linux/kernel_stat.h +1 -0
@@ -36,3 +36,4 @@ struct kernel_stat#define XSTAT_IS_XSTAT64 0#define STATFS_IS_STATFS64 0 +#define STAT64_IS_NOT_KERNEL_STAT64 0
sysdeps/unix/sysv/linux/microblaze/kernel_stat.h +1 -0
@@ -50,3 +50,4 @@ struct kernel_stat#define XSTAT_IS_XSTAT64 0#define STATFS_IS_STATFS64 0 +#define STAT64_IS_NOT_KERNEL_STAT64 0
sysdeps/unix/sysv/linux/mips/kernel_stat.h +1 -0
@@ -58,3 +58,4 @@ struct kernel_stat#define XSTAT_IS_XSTAT64 0#define STATFS_IS_STATFS64 0 +#define STAT64_IS_NOT_KERNEL_STAT64 0
sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h +1 -0
@@ -49,3 +49,4 @@ struct kernel_stat#define XSTAT_IS_XSTAT64 0#define STATFS_IS_STATFS64 0 +#define STAT64_IS_NOT_KERNEL_STAT64 0
sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h +1 -0
@@ -19,3 +19,4 @@#define STAT_IS_KERNEL_STAT 1#define XSTAT_IS_XSTAT64 1#define STATFS_IS_STATFS64 0 +#define STAT64_IS_NOT_KERNEL_STAT64 0
sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h +1 -0
@@ -19,3 +19,4 @@#define STAT_IS_KERNEL_STAT 1#define XSTAT_IS_XSTAT64 1#define STATFS_IS_STATFS64 0 +#define STAT64_IS_NOT_KERNEL_STAT64 0
sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h +1 -0
@@ -33,3 +33,4 @@ struct kernel_stat#define XSTAT_IS_XSTAT64 0#define STATFS_IS_STATFS64 0 +#define STAT64_IS_NOT_KERNEL_STAT64 0
sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h +1 -0
@@ -46,3 +46,4 @@ struct kernel_stat64#define XSTAT_IS_XSTAT64 1#define STATFS_IS_STATFS64 0 +#define STAT64_IS_NOT_KERNEL_STAT64 0
sysdeps/unix/sysv/linux/statx_cp.c +1 -1
@@ -22,7 +22,7 @@#include <statx_cp.h> -#if !defined(__NR_fstat64) || !defined(__NR_fstatat64) +#if !defined(__NR_fstat64) || !defined(__NR_fstatat64) ||STAT64_IS_NOT_KERNEL_STAT64 void __cp_stat64_statx (struct stat64 *to,struct statx *from) {
sysdeps/unix/sysv/linux/x86_64/kernel_stat.h +1 -0
@@ -19,3 +19,4 @@#define STAT_IS_KERNEL_STAT 1#define XSTAT_IS_XSTAT64 1#define STATFS_IS_STATFS64 0 +#define STAT64_IS_NOT_KERNEL_STAT64 0
Signature · 7 lines
2.20.1 _______________________________________________ linux-snps-arc mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH v2] asm-generic ABI: Allow statx syscall despite fstatat64,fstat64
sysdeps/unix/sysv/linux/fxstat64.c int · line 36
Quoted 12 lines · Vineet Gupta
sysdeps/unix/sysv/linux/fxstat64.c +1
-3@@ -33,15 +33,15 @@ int ___fxstat64 (int vers, int fd, struct stat64 *buf) { int result; -#ifdef __NR_fstat64 - result =INLINE_SYSCALL (fstat64,2 , fd, buf); -#else +# if STAT64_IS_NOT_KERNEL_STAT64 || !defined(__NR_fstat64)
I don't think the extra space after "#" is correct here. We use such spaces to indicate the level of nesting inside outer #if conditionals, but there is no outer #if conditional around this one in this file, so "#if" without the space is correct.
There should be a space before '(' in the "defined" call.
Likewise in other files changed by this patch.
Signature · 7 lines
Joseph S. Myers [email protected] _______________________________________________ linux-snps-arc mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-snps-arc
PATCH v3 1/1 asm-generic ABI: Allow statx syscall despite fstatat64, fstat64
An old version of asm-generic syscall ABI (e.g. ARC 2013) provided fstat[at]64 syscalls for implementing the stat family.
These sycalls are passthru (no interworking/itemized-copy needed between kernel and user structs since they are binary comaptible). However with switch to 64-bit time_t the compatibily goes away so we need explicit interworking. Luckily such code already exists albeit it uses the statx syscall.
So this patch reworks the asm-generic based stat functions to use the statx code-path if the arch so desires. It essentially reworks the commit 6bbfc5c09fc5b5e3 ("Add statx conditionals for wordsize-32 *xstat.c")
This will be used by ARC port for 64-bit time_t. But it has no real bearing on 64-bit and can just be independently opted-in by an arch port provided the ABI supports it.
---
Changes since v2
* Fixup coding style for #if and defined
Changes since v1
* make the toggle #if style rather than #ifdef style
* define to 0 in all arches which don't use it
--- sysdeps/unix/sysv/linux/alpha/kernel_stat.h | 1 + sysdeps/unix/sysv/linux/fxstat64.c | 6 +++--- sysdeps/unix/sysv/linux/fxstatat64.c | 6 +++--- sysdeps/unix/sysv/linux/generic/kernel_stat.h | 7 +++++++ sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat.c | 6 +++--- sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat.c | 6 +++--- sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat.c | 10 +++++----- sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat64.c | 8 ++++---- sysdeps/unix/sysv/linux/generic/wordsize-32/xstat.c | 6 +++--- sysdeps/unix/sysv/linux/generic/wordsize-32/xstat64.c | 6 +++--- sysdeps/unix/sysv/linux/hppa/kernel_stat.h | 1 + sysdeps/unix/sysv/linux/ia64/kernel_stat.h | 1 + sysdeps/unix/sysv/linux/kernel_stat.h | 1 + sysdeps/unix/sysv/linux/microblaze/kernel_stat.h | 1 + sysdeps/unix/sysv/linux/mips/kernel_stat.h | 1 + .../unix/sysv/linux/powerpc/powerpc32/kernel_stat.h | 1 + .../unix/sysv/linux/powerpc/powerpc64/kernel_stat.h | 1 + sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h | 1 + sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h | 1 + sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h | 1 + sysdeps/unix/sysv/linux/statx_cp.c | 2 +- sysdeps/unix/sysv/linux/x86_64/kernel_stat.h | 1 + 22 files changed, 47 insertions(+), 28 deletions(-)
sysdeps/unix/sysv/linux/alpha/kernel_stat.h +1 -0
@@ -87,3 +87,4 @@ struct glibc21_stat#define XSTAT_IS_XSTAT64 1#define STATFS_IS_STATFS64 0 +#define STAT64_IS_NOT_KERNEL_STAT64 0
sysdeps/unix/sysv/linux/fxstat64.c +3 -3
@@ -33,14 +33,14 @@ int ___fxstat64 (int vers, int fd, struct stat64 *buf) { int result; -#ifdef __NR_fstat64 - result =INLINE_SYSCALL (fstat64,2 , fd, buf); -#else +#if STAT64_IS_NOT_KERNEL_STAT64 || !defined (__NR_fstat64)struct statx tmp; result =INLINE_SYSCALL (statx,5 , fd,"" ,AT_EMPTY_PATH ,STATX_BASIC_STATS , &tmp);if (result ==0 )__cp_stat64_statx (buf, &tmp); +#else + result =INLINE_SYSCALL (fstat64,2 , fd, buf);#endif return result; }
sysdeps/unix/sysv/linux/fxstatat64.c +3 -3
@@ -38,15 +38,15 @@ __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag)int result; -#ifdef __NR_fstatat64 - result =INTERNAL_SYSCALL_CALL (fstatat64, fd, file, st, flag); -#else +#if STAT64_IS_NOT_KERNEL_STAT64 || !defined (__NR_fstatat64)struct statx tmp; result =INTERNAL_SYSCALL_CALL (statx, fd, file,AT_NO_AUTOMOUNT | flag,STATX_BASIC_STATS , &tmp);if (result ==0 )__cp_stat64_statx (st, &tmp); +#else + result =INTERNAL_SYSCALL_CALL (fstatat64, fd, file, st, flag);#endif if (!__glibc_likely (INTERNAL_SYSCALL_ERROR_P (result)))return 0 ;
sysdeps/unix/sysv/linux/generic/kernel_stat.h +7 -0
@@ -28,3 +28,10 @@#endif #define STATFS_IS_STATFS64 0 + +/* Allows asm-generic ABI ports with fstat64 syscall to use statx syscall for +implement stat* wrappers. This is needed when glibc stat64 is not compatible +with kernel stat64 (due to 64-bit time_t). By default it is off unless +arch opts-in. */ + +#define STAT64_IS_NOT_KERNEL_STAT64 0
sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat.c +3 -3
@@ -36,14 +36,14 @@ __fxstat (int vers, int fd, struct stat *buf) {if (vers == _STAT_VER_KERNEL) { -# ifdef __NR_fstat64 -int rc =INLINE_SYSCALL (fstat64,2 , fd, buf); -# else +# if STAT64_IS_NOT_KERNEL_STAT64 || !defined (__NR_fstat64)struct statx tmp;int rc =INLINE_SYSCALL (statx,5 , fd,"" ,AT_EMPTY_PATH ,STATX_BASIC_STATS , &tmp);if (rc ==0 )__cp_stat64_statx ((struct stat64 *)buf, &tmp); +# else +int rc =INLINE_SYSCALL (fstat64,2 , fd, buf);# endif return rc ?:stat_overflow (buf); }
sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat.c +3 -3
@@ -36,15 +36,15 @@ __fxstatat (int vers, int fd, const char *file, struct stat *buf, int flag) {if (vers == _STAT_VER_KERNEL) { -# ifdef __NR_fstatat64 -int rc =INLINE_SYSCALL (fstatat64,4 , fd, file, buf, flag); -# else +# if STAT64_IS_NOT_KERNEL_STAT64 || !defined (__NR_fstat64)struct statx tmp;int rc =INLINE_SYSCALL (statx,5 , fd, file,AT_NO_AUTOMOUNT | flag,STATX_BASIC_STATS , &tmp);if (rc ==0 )__cp_stat64_statx ((struct stat64 *)buf, &tmp); +# else +int rc =INLINE_SYSCALL (fstatat64,4 , fd, file, buf, flag);# endif return rc ?:stat_overflow (buf); }
sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat.c +5 -5
@@ -35,17 +35,17 @@ __lxstat (int vers, const char *name, struct stat *buf) {if (vers == _STAT_VER_KERNEL) { -#ifdef __NR_fstatat64 -int rc =INLINE_SYSCALL (fstatat64,4 ,AT_FDCWD , name, buf, -AT_SYMLINK_NOFOLLOW ); -#else +# if STAT64_IS_NOT_KERNEL_STAT64 || !defined (__NR_fstat64)struct statx tmp;int rc =INLINE_SYSCALL (statx,5 ,AT_FDCWD , name,AT_NO_AUTOMOUNT |AT_SYMLINK_NOFOLLOW ,STATX_BASIC_STATS , &tmp);if (rc ==0 )__cp_stat64_statx ((struct stat64 *)buf, &tmp); -#endif +# else +int rc =INLINE_SYSCALL (fstatat64,4 ,AT_FDCWD , name, buf, +AT_SYMLINK_NOFOLLOW ); +# endif return rc ?:stat_overflow (buf); } errno =EINVAL ;
sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat64.c +4 -4
@@ -40,10 +40,7 @@ __lxstat64 (int vers, const char *name, struct stat64 *buf) {if (vers == _STAT_VER_KERNEL) { -#ifdef __NR_fstatat64 -return INLINE_SYSCALL (fstatat64,4 ,AT_FDCWD , name, buf, -AT_SYMLINK_NOFOLLOW ); -#else +#if STAT64_IS_NOT_KERNEL_STAT64 || !defined (__NR_fstat64)struct statx tmp; int rc = INLINE_SYSCALL (statx, 5, AT_FDCWD, name, AT_NO_AUTOMOUNT | AT_SYMLINK_NOFOLLOW,
@@ -51,6 +48,9 @@ __lxstat64 (int vers, const char *name, struct stat64 *buf)if (rc ==0 )__cp_stat64_statx (buf, &tmp);return rc; +#else +return INLINE_SYSCALL (fstatat64,4 ,AT_FDCWD , name, buf, +AT_SYMLINK_NOFOLLOW );#endif }
sysdeps/unix/sysv/linux/generic/wordsize-32/xstat.c +3 -3
@@ -35,14 +35,14 @@ __xstat (int vers, const char *name, struct stat *buf) {if (vers == _STAT_VER_KERNEL) { -# ifdef __NR_fstatat64 -int rc =INLINE_SYSCALL (fstatat64,4 ,AT_FDCWD , name, buf,0 ); -# else +# if STAT64_IS_NOT_KERNEL_STAT64 || !defined (__NR_fstat64)struct statx tmp;int rc =INLINE_SYSCALL (statx,5 ,AT_FDCWD , name,AT_NO_AUTOMOUNT ,STATX_BASIC_STATS , &tmp);if (rc ==0 )__cp_stat64_statx ((struct stat64 *)buf, &tmp); +# else +int rc =INLINE_SYSCALL (fstatat64,4 ,AT_FDCWD , name, buf,0 );# endif return rc ?:stat_overflow (buf); }
sysdeps/unix/sysv/linux/generic/wordsize-32/xstat64.c +3 -3
@@ -40,15 +40,15 @@ __xstat64 (int vers, const char *name, struct stat64 *buf) {if (vers == _STAT_VER_KERNEL) { -#ifdef __NR_fstatat64 -return INLINE_SYSCALL (fstatat64,4 ,AT_FDCWD , name, buf,0 ); -#else +#if STAT64_IS_NOT_KERNEL_STAT64 || !defined (__NR_fstat64)struct statx tmp;int rc =INLINE_SYSCALL (statx,5 ,AT_FDCWD , name,AT_NO_AUTOMOUNT ,STATX_BASIC_STATS , &tmp);if (rc ==0 )__cp_stat64_statx (buf, &tmp);return rc; +#else +return INLINE_SYSCALL (fstatat64,4 ,AT_FDCWD , name, buf,0 );#endif } errno =EINVAL ;
sysdeps/unix/sysv/linux/hppa/kernel_stat.h +1 -0
@@ -32,3 +32,4 @@ struct kernel_stat {#define XSTAT_IS_XSTAT64 0#define STATFS_IS_STATFS64 0 +#define STAT64_IS_NOT_KERNEL_STAT64 0
sysdeps/unix/sysv/linux/ia64/kernel_stat.h +1 -0
@@ -19,3 +19,4 @@#define STAT_IS_KERNEL_STAT 1#define XSTAT_IS_XSTAT64 1#define STATFS_IS_STATFS64 0 +#define STAT64_IS_NOT_KERNEL_STAT64 0
sysdeps/unix/sysv/linux/kernel_stat.h +1 -0
@@ -36,3 +36,4 @@ struct kernel_stat#define XSTAT_IS_XSTAT64 0#define STATFS_IS_STATFS64 0 +#define STAT64_IS_NOT_KERNEL_STAT64 0
sysdeps/unix/sysv/linux/microblaze/kernel_stat.h +1 -0
@@ -50,3 +50,4 @@ struct kernel_stat#define XSTAT_IS_XSTAT64 0#define STATFS_IS_STATFS64 0 +#define STAT64_IS_NOT_KERNEL_STAT64 0
sysdeps/unix/sysv/linux/mips/kernel_stat.h +1 -0
@@ -58,3 +58,4 @@ struct kernel_stat#define XSTAT_IS_XSTAT64 0#define STATFS_IS_STATFS64 0 +#define STAT64_IS_NOT_KERNEL_STAT64 0
sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h +1 -0
@@ -49,3 +49,4 @@ struct kernel_stat#define XSTAT_IS_XSTAT64 0#define STATFS_IS_STATFS64 0 +#define STAT64_IS_NOT_KERNEL_STAT64 0
sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h +1 -0
@@ -19,3 +19,4 @@#define STAT_IS_KERNEL_STAT 1#define XSTAT_IS_XSTAT64 1#define STATFS_IS_STATFS64 0 +#define STAT64_IS_NOT_KERNEL_STAT64 0
sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h +1 -0
@@ -19,3 +19,4 @@#define STAT_IS_KERNEL_STAT 1#define XSTAT_IS_XSTAT64 1#define STATFS_IS_STATFS64 0 +#define STAT64_IS_NOT_KERNEL_STAT64 0
sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h +1 -0
@@ -33,3 +33,4 @@ struct kernel_stat#define XSTAT_IS_XSTAT64 0#define STATFS_IS_STATFS64 0 +#define STAT64_IS_NOT_KERNEL_STAT64 0
sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h +1 -0
@@ -46,3 +46,4 @@ struct kernel_stat64#define XSTAT_IS_XSTAT64 1#define STATFS_IS_STATFS64 0 +#define STAT64_IS_NOT_KERNEL_STAT64 0
sysdeps/unix/sysv/linux/statx_cp.c +1 -1
@@ -22,7 +22,7 @@#include <statx_cp.h> -#if !defined(__NR_fstat64) || !defined(__NR_fstatat64) +#if !defined (__NR_fstat64) || !defined (__NR_fstatat64) ||STAT64_IS_NOT_KERNEL_STAT64 void __cp_stat64_statx (struct stat64 *to,struct statx *from) {
sysdeps/unix/sysv/linux/x86_64/kernel_stat.h +1 -0
@@ -19,3 +19,4 @@#define STAT_IS_KERNEL_STAT 1#define XSTAT_IS_XSTAT64 1#define STATFS_IS_STATFS64 0 +#define STAT64_IS_NOT_KERNEL_STAT64 0
Signature · 7 lines
2.20.1 _______________________________________________ linux-snps-arc mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Quoted 9 lines · Vineet Gupta
An old version of asm-generic syscall ABI (e.g. ARC 2013) provided fstat[at]64 syscalls for implementing the stat family.
These sycalls are passthru (no interworking/itemized-copy needed between kernel and user structs since they are binary comaptible). However with switch to 64-bit
time_tthe compatibily goes away so we need explicit interworking. Luckily such code already exists albeit it uses the statx syscall.
Quoted 7 lines
So this patch reworks the asm-generic based stat functions to use the statx code-path if the arch so desires. It essentially reworks the commit
6bbfc5c09fc5b5e3("Add statx conditionals for wordsize-32 *xstat.c")This will be used by ARC port for 64-bit
time_t. But it has no real bearing on 64-bit and can just be independently opted-in by an arch port provided the ABI supports it.
Oh wait. Can we avoid this churn by simply undef __NR_fstat64 and __NR_fstatat64 from ARC sysdep.h ? And it will then automatically fallback to statx code !
_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Quoted 2 lines · Vineet Gupta
Oh wait. Can we avoid this churn by simply undef
__NR_fstat64and__NR_fstatat64from ARCsysdep.h? And it will then automatically fallback to statx code !
If all files needing this information include sysdep.h, that might well work.
Signature · 7 lines
Joseph S. Myers [email protected] _______________________________________________ linux-snps-arc mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Quoted 7 lines · Joseph Myers
Quoted 2 lines · Vineet Gupta
Oh wait. Can we avoid this churn by simply undef
__NR_fstat64and__NR_fstatat64from ARCsysdep.h? And it will then automatically fallback to statx code !If all files needing this information include
sysdep.h, that might well work.
I agree that this is a valid concern. If we really want to make it water tight we could have the build system enforce this with -include or some such ?
_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc