This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH v4 1/2] sysdeps/stat: Handle 64-bit ino_t types on 32-bit hosts
- From: Alistair Francis <alistair dot francis at wdc dot com>
- To: libc-alpha at sourceware dot org
- Cc: alistair23 at gmaill dot com, Alistair Francis <alistair dot francis at wdc dot com>
- Date: Wed, 16 Oct 2019 16:44:06 -0700
- Subject: [PATCH v4 1/2] sysdeps/stat: Handle 64-bit ino_t types on 32-bit hosts
- Ironport-sdr: Ncb16topTn4Vb1E2bJlPRJgYfkQYMhVY0GbbBDE4jPvu8hs4txGv/0+Aa/oQ9/h/U+QARdXJW4 Xjyiw+wwzkmljjYzJIvrHPOqLDXAFkuNiThwPSiBwEgaW6aywqsOx2lQ4mI+pNwgqq6Uo7IRPg UDU4Y3BeOfYlWj+GnFCzP4S+zr86GDt4hS4Svdrlj+dD1qH2OZx5yVm3teuVmgq7zHs7Y0fwdE ZcncXQPPI4LpV7SBzGCxRqKTyaTYRasBakXYwjBuA9AjU0kkbY76eKxUzas/PyuYnSECz4Pgi5 2to=
- Ironport-sdr: qSlDkX/8iWAZ8o1D0i9+Bs4sSWUQG03Zjlb/cHhmf2PLcccv+6GpWQX1QXXViI0hZ/yr+yoyl7 xpb08cNNrmZKvM89cyIxZUMPbyap7Nc085VA6TKyhy5atL+n9nGFVyNU0R6gJMGM7b3hjF03g+ O+uI10rJxI2FdRpHA1SMjHoPFgjlmAcvMHDfVSFDvsmBRfO1R4S187YtUdN/yOYhJVLU9ydxU3 UFEFbcvJpc+aHNEo3gdyrvBPPnp+07BTNoOPn78T954A6bn5InZzVgTVEJ//vxEDOJty5rk1Oq 0AAdSm0sLoAahzSwku4z/TU2
- Ironport-sdr: qp8qpxqeiJrRuh2rfeYHWZuaEU3rpy485/JH6TAju/mbQw8Ey2DZgL0cAvtHzQd6rvQRE0T8BX 7DiRQRWKRVpamPifFRDxoVjQpMmGDNLHbVP4UXydjieMuFjKNaf+eNmxsDRrwIprBXyIK58C4Z QUWE7jCGj6bpGRYVInT8eJbVFjH5ubMSvG1Pcxl71QzXGMfTkzTpQ4GmCXtXzJlxjo8iWCtUyh Fga5mv3Imqld9cBfCNGgs9SV1JW6jLnyoS1vFwBgjRB8pYde7gtqw1E6a8cIN421m7NGtXnF8s qdQ=
- Wdcironportexception: Internal
On a 32-bit platform with a 64-bit ino_t type (__INO_T_MATCHES_INO64_T
defined) we want to update the stat struct to remove the padding as it
isn't required. As we don't have the padding we also need to update the
overflow checker to not access the undefined members.
* sysdeps/unix/sysv/linux/generic/bits/stat.h: Handle 64-bit ino_t types
on 32-bit hosts.
* sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h: Likewise.
* sysdeps/unix/sysv/linux/generic/xstat.c: Ensure __blkcnt_t == __blkcnt64_t
if __INO_T_MATCHES_INO64_T is defined.
---
sysdeps/unix/sysv/linux/generic/bits/stat.h | 5 ++++-
sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h | 4 ++++
sysdeps/unix/sysv/linux/generic/xstat.c | 5 +++++
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/sysdeps/unix/sysv/linux/generic/bits/stat.h b/sysdeps/unix/sysv/linux/generic/bits/stat.h
index 1565f3f8248..34c455ed786 100644
--- a/sysdeps/unix/sysv/linux/generic/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/generic/bits/stat.h
@@ -42,7 +42,10 @@
#if defined __USE_FILE_OFFSET64
# define __field64(type, type64, name) type64 name
-#elif __WORDSIZE == 64
+#elif __WORDSIZE == 64 || defined __INO_T_MATCHES_INO64_T
+# if defined __INO_T_MATCHES_INO64_T && !defined __OFF_T_MATCHES_OFF64_T
+# error "ino_t and off_t must both be the same type"
+# endif
# define __field64(type, type64, name) type name
#elif __BYTE_ORDER == __LITTLE_ENDIAN
# define __field64(type, type64, name) \
diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h b/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h
index 45efcd8fd34..66546b07ccd 100644
--- a/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h
+++ b/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h
@@ -36,12 +36,16 @@ static inline off_t lseek_overflow (loff_t res)
static inline int stat_overflow (struct stat *buf)
{
+#if defined __INO_T_MATCHES_INO64_T
+ return 0;
+#else
if (buf->__st_ino_pad == 0 && buf->__st_size_pad == 0
&& buf->__st_blocks_pad == 0)
return 0;
__set_errno (EOVERFLOW);
return -1;
+#endif
}
/* Note that f_files and f_ffree may validly be a sign-extended -1. */
diff --git a/sysdeps/unix/sysv/linux/generic/xstat.c b/sysdeps/unix/sysv/linux/generic/xstat.c
index 75ceb9bc74b..ece14fc5838 100644
--- a/sysdeps/unix/sysv/linux/generic/xstat.c
+++ b/sysdeps/unix/sysv/linux/generic/xstat.c
@@ -28,6 +28,11 @@
#include <sysdep.h>
#include <sys/syscall.h>
+#if __INO_T_MATCHES_INO64_T
+_Static_assert (sizeof (__blkcnt_t) == sizeof (__blkcnt64_t),
+ "__blkcnt_t and __blkcnt64_t must match");
+#endif
+
/* Get information about the file NAME in BUF. */
int
__xstat (int vers, const char *name, struct stat *buf)
--
2.23.0