From 7a6ca82f8007ddbd43e2b8fce806ba7101ee47f5 Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Wed, 19 Oct 2022 19:14:04 -0300 Subject: [PATCH] linux: Fix generic struct_stat for 64 bit time (BZ# 29657) The generic Linux struct_stat misses the conditionals to use bits/struct_stat_time64_helper.h in the __USE_TIME_BITS64 for architecture that uses __TIMESIZE == 32 (currently csky and nios2). Since newer ports should not support 32 bit time_t, the generic implementation should be used as default. For arm, hppa, and sh a copy of default struct_stat is added, while for csky and nios a new one based on generic is used, along with conditionals to use bits/struct_stat_time64_helper.h. The default struct_stat is also replaced with the generic one. Checked on aarch64-linux-gnu and arm-linux-gnueabihf. --- .../unix/sysv/linux/{ => arm}/bits/struct_stat.h | 2 +- .../sysv/linux/{generic => }/bits/struct_stat.h | 0 .../linux/{generic => csky}/bits/struct_stat.h | 28 ++++++++++++++-------- .../unix/sysv/linux/{ => hppa}/bits/struct_stat.h | 2 +- .../linux/{generic => nios2}/bits/struct_stat.h | 28 ++++++++++++++-------- .../unix/sysv/linux/{ => sh}/bits/struct_stat.h | 2 +- 6 files changed, 39 insertions(+), 23 deletions(-) copy sysdeps/unix/sysv/linux/{ => arm}/bits/struct_stat.h (99%) copy sysdeps/unix/sysv/linux/{generic => }/bits/struct_stat.h (100%) copy sysdeps/unix/sysv/linux/{generic => csky}/bits/struct_stat.h (92%) copy sysdeps/unix/sysv/linux/{ => hppa}/bits/struct_stat.h (99%) rename sysdeps/unix/sysv/linux/{generic => nios2}/bits/struct_stat.h (92%) copy sysdeps/unix/sysv/linux/{ => sh}/bits/struct_stat.h (99%) diff --git a/sysdeps/unix/sysv/linux/bits/struct_stat.h b/sysdeps/unix/sysv/linux/arm/bits/struct_stat.h similarity index 99% copy from sysdeps/unix/sysv/linux/bits/struct_stat.h copy to sysdeps/unix/sysv/linux/arm/bits/struct_stat.h index 25bd6cb638..30ee6279d2 100644 --- a/sysdeps/unix/sysv/linux/bits/struct_stat.h +++ b/sysdeps/unix/sysv/linux/arm/bits/struct_stat.h @@ -1,4 +1,4 @@ -/* Definition for struct stat. +/* Definition for struct stat. Linux/arm version. Copyright (C) 2020-2022 Free Software Foundation, Inc. This file is part of the GNU C Library. diff --git a/sysdeps/unix/sysv/linux/generic/bits/struct_stat.h b/sysdeps/unix/sysv/linux/bits/struct_stat.h similarity index 100% copy from sysdeps/unix/sysv/linux/generic/bits/struct_stat.h copy to sysdeps/unix/sysv/linux/bits/struct_stat.h diff --git a/sysdeps/unix/sysv/linux/generic/bits/struct_stat.h b/sysdeps/unix/sysv/linux/csky/bits/struct_stat.h similarity index 92% copy from sysdeps/unix/sysv/linux/generic/bits/struct_stat.h copy to sysdeps/unix/sysv/linux/csky/bits/struct_stat.h index fb11a3fba4..f0ee455748 100644 --- a/sysdeps/unix/sysv/linux/generic/bits/struct_stat.h +++ b/sysdeps/unix/sysv/linux/csky/bits/struct_stat.h @@ -1,4 +1,4 @@ -/* Definition for struct stat. +/* Definition for struct stat. Linux/csky version. Copyright (C) 2020-2022 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -43,6 +43,9 @@ struct stat { +#ifdef __USE_TIME_BITS64 +# include +#else __dev_t st_dev; /* Device. */ __field64(__ino_t, __ino64_t, st_ino); /* File serial number. */ __mode_t st_mode; /* File mode. */ @@ -55,7 +58,7 @@ struct stat __blksize_t st_blksize; /* Optimal block size for I/O. */ int __pad2; __field64(__blkcnt_t, __blkcnt64_t, st_blocks); /* 512-byte blocks */ -#ifdef __USE_XOPEN2K8 +# ifdef __USE_XOPEN2K8 /* Nanosecond resolution timestamps are stored in a format equivalent to 'struct timespec'. This is the type used whenever possible but the Unix namespace rules do not allow the @@ -65,18 +68,19 @@ struct stat struct timespec st_atim; /* Time of last access. */ struct timespec st_mtim; /* Time of last modification. */ struct timespec st_ctim; /* Time of last status change. */ -# define st_atime st_atim.tv_sec /* Backward compatibility. */ -# define st_mtime st_mtim.tv_sec -# define st_ctime st_ctim.tv_sec -#else +# define st_atime st_atim.tv_sec /* Backward compatibility. */ +# define st_mtime st_mtim.tv_sec +# define st_ctime st_ctim.tv_sec +# else __time_t st_atime; /* Time of last access. */ unsigned long int st_atimensec; /* Nscecs of last access. */ __time_t st_mtime; /* Time of last modification. */ unsigned long int st_mtimensec; /* Nsecs of last modification. */ __time_t st_ctime; /* Time of last status change. */ unsigned long int st_ctimensec; /* Nsecs of last status change. */ -#endif +# endif int __glibc_reserved[2]; +#endif }; #undef __field64 @@ -84,6 +88,9 @@ struct stat #ifdef __USE_LARGEFILE64 struct stat64 { +# ifdef __USE_TIME_BITS64 +# include +# else __dev_t st_dev; /* Device. */ __ino64_t st_ino; /* File serial number. */ __mode_t st_mode; /* File mode. */ @@ -96,7 +103,7 @@ struct stat64 __blksize_t st_blksize; /* Optimal block size for I/O. */ int __pad2; __blkcnt64_t st_blocks; /* Nr. 512-byte blocks allocated. */ -#ifdef __USE_XOPEN2K8 +# ifdef __USE_XOPEN2K8 /* Nanosecond resolution timestamps are stored in a format equivalent to 'struct timespec'. This is the type used whenever possible but the Unix namespace rules do not allow the @@ -106,15 +113,16 @@ struct stat64 struct timespec st_atim; /* Time of last access. */ struct timespec st_mtim; /* Time of last modification. */ struct timespec st_ctim; /* Time of last status change. */ -#else +# else __time_t st_atime; /* Time of last access. */ unsigned long int st_atimensec; /* Nscecs of last access. */ __time_t st_mtime; /* Time of last modification. */ unsigned long int st_mtimensec; /* Nsecs of last modification. */ __time_t st_ctime; /* Time of last status change. */ unsigned long int st_ctimensec; /* Nsecs of last status change. */ -#endif +# endif int __glibc_reserved[2]; +# endif }; #endif diff --git a/sysdeps/unix/sysv/linux/bits/struct_stat.h b/sysdeps/unix/sysv/linux/hppa/bits/struct_stat.h similarity index 99% copy from sysdeps/unix/sysv/linux/bits/struct_stat.h copy to sysdeps/unix/sysv/linux/hppa/bits/struct_stat.h index 25bd6cb638..38b6e13e68 100644 --- a/sysdeps/unix/sysv/linux/bits/struct_stat.h +++ b/sysdeps/unix/sysv/linux/hppa/bits/struct_stat.h @@ -1,4 +1,4 @@ -/* Definition for struct stat. +/* Definition for struct stat. Linux/hppa version. Copyright (C) 2020-2022 Free Software Foundation, Inc. This file is part of the GNU C Library. diff --git a/sysdeps/unix/sysv/linux/generic/bits/struct_stat.h b/sysdeps/unix/sysv/linux/nios2/bits/struct_stat.h similarity index 92% rename from sysdeps/unix/sysv/linux/generic/bits/struct_stat.h rename to sysdeps/unix/sysv/linux/nios2/bits/struct_stat.h index fb11a3fba4..e00e71173e 100644 --- a/sysdeps/unix/sysv/linux/generic/bits/struct_stat.h +++ b/sysdeps/unix/sysv/linux/nios2/bits/struct_stat.h @@ -1,4 +1,4 @@ -/* Definition for struct stat. +/* Definition for struct stat. Linux/nios2 version. Copyright (C) 2020-2022 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -43,6 +43,9 @@ struct stat { +#ifdef __USE_TIME_BITS64 +# include +#else __dev_t st_dev; /* Device. */ __field64(__ino_t, __ino64_t, st_ino); /* File serial number. */ __mode_t st_mode; /* File mode. */ @@ -55,7 +58,7 @@ struct stat __blksize_t st_blksize; /* Optimal block size for I/O. */ int __pad2; __field64(__blkcnt_t, __blkcnt64_t, st_blocks); /* 512-byte blocks */ -#ifdef __USE_XOPEN2K8 +# ifdef __USE_XOPEN2K8 /* Nanosecond resolution timestamps are stored in a format equivalent to 'struct timespec'. This is the type used whenever possible but the Unix namespace rules do not allow the @@ -65,18 +68,19 @@ struct stat struct timespec st_atim; /* Time of last access. */ struct timespec st_mtim; /* Time of last modification. */ struct timespec st_ctim; /* Time of last status change. */ -# define st_atime st_atim.tv_sec /* Backward compatibility. */ -# define st_mtime st_mtim.tv_sec -# define st_ctime st_ctim.tv_sec -#else +# define st_atime st_atim.tv_sec /* Backward compatibility. */ +# define st_mtime st_mtim.tv_sec +# define st_ctime st_ctim.tv_sec +# else __time_t st_atime; /* Time of last access. */ unsigned long int st_atimensec; /* Nscecs of last access. */ __time_t st_mtime; /* Time of last modification. */ unsigned long int st_mtimensec; /* Nsecs of last modification. */ __time_t st_ctime; /* Time of last status change. */ unsigned long int st_ctimensec; /* Nsecs of last status change. */ -#endif +# endif int __glibc_reserved[2]; +#endif }; #undef __field64 @@ -84,6 +88,9 @@ struct stat #ifdef __USE_LARGEFILE64 struct stat64 { +# ifdef __USE_TIME_BITS64 +# include +# else __dev_t st_dev; /* Device. */ __ino64_t st_ino; /* File serial number. */ __mode_t st_mode; /* File mode. */ @@ -96,7 +103,7 @@ struct stat64 __blksize_t st_blksize; /* Optimal block size for I/O. */ int __pad2; __blkcnt64_t st_blocks; /* Nr. 512-byte blocks allocated. */ -#ifdef __USE_XOPEN2K8 +# ifdef __USE_XOPEN2K8 /* Nanosecond resolution timestamps are stored in a format equivalent to 'struct timespec'. This is the type used whenever possible but the Unix namespace rules do not allow the @@ -106,15 +113,16 @@ struct stat64 struct timespec st_atim; /* Time of last access. */ struct timespec st_mtim; /* Time of last modification. */ struct timespec st_ctim; /* Time of last status change. */ -#else +# else __time_t st_atime; /* Time of last access. */ unsigned long int st_atimensec; /* Nscecs of last access. */ __time_t st_mtime; /* Time of last modification. */ unsigned long int st_mtimensec; /* Nsecs of last modification. */ __time_t st_ctime; /* Time of last status change. */ unsigned long int st_ctimensec; /* Nsecs of last status change. */ -#endif +# endif int __glibc_reserved[2]; +# endif }; #endif diff --git a/sysdeps/unix/sysv/linux/bits/struct_stat.h b/sysdeps/unix/sysv/linux/sh/bits/struct_stat.h similarity index 99% copy from sysdeps/unix/sysv/linux/bits/struct_stat.h copy to sysdeps/unix/sysv/linux/sh/bits/struct_stat.h index 25bd6cb638..0f7c9cdc89 100644 --- a/sysdeps/unix/sysv/linux/bits/struct_stat.h +++ b/sysdeps/unix/sysv/linux/sh/bits/struct_stat.h @@ -1,4 +1,4 @@ -/* Definition for struct stat. +/* Definition for struct stat. Linux/sh version. Copyright (C) 2020-2022 Free Software Foundation, Inc. This file is part of the GNU C Library. -- 2.11.4.GIT