This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH v2 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 gmail dot com, Alistair Francis <alistair dot francis at wdc dot com>
- Date: Tue, 24 Sep 2019 17:31:13 -0700
- Subject: [PATCH v2 1/2] sysdeps/stat: Handle 64-bit ino_t types on 32-bit hosts
- Ironport-sdr: 5fm65oOHK3UXr1QfRQ4czSZyJMd7j4Butl6oygjSRVNO1hyM76uhLjZEDnDUIBkQ11ccU/SXAE i4geajWOZPKnNjEs6mP0MNYd0wnP0/rmsoar1PJmeRdmlNCUdP7YbDqExIUJlHo2OEiGfQL05X NuWIUXjhgd84GqdxSHOLSrR8zkXKwFxnK2ZDXv2JEYNHCs65jNb/LO96vkalhaACFGQhFa3E4n COZf2MRQ9SKZd/hQlYFoQzsBXO8+f+tsrbphSnGN4f8vwsmUS+kOfojMeLM1hiNpNIiVg6le97 Dt4=
- Ironport-sdr: QrL4/VfM+cdt2iMXNxwWuv1t3ZWVpxVJ3K3zD7SKLhv+ROFBXW1P8kxdfjpN6pcs/SeHfghiK+ f1YXq7ZhZzTm6k0PiwHznj4cUn4pA1t9p9U+fu4Jqu8yMz+XoFpuJ+KQz1cp3Y06upkhJnZsIS LoXkQMEBJHF09G4paVG31r6jtWqjZj+WNpxnz3MJj0mk7nuwss5mVdRrhbVdsSwLp7v33CLto1 poyeS9e/Kee9SCRVsT8EKgkKxb2X1rgu3R1/+LnJiARGSjrUyVAZP0QTCvUBL6mFZvG2QA4qid vpJWgEcFFplYguxAKlTSSWJo
- Ironport-sdr: 3MZV3hqslYmK7/XKXAzUY1CKZ02Bpz5a+QXH9FclMZJwjpofYFeJCE0EkiPHHQTC7xxw1f+bri ih3uv23MV3Te7KuMfGhle5+fC9PKoBjrhQx1ZA7mkbQJHpIWYF6id4J+ZD+91Wv4xuxIgZHEWj 4tyQ9ENQDzusufaW4zGpDRasKF1Xkw/2FWWZo53gf44+FauwOD4tpIQmzZ+4Uh3mmkgmpl1jGr kL955nLlKJuRM+1DdDUD080ACJUqdVfts84fVgdlQGsM82ujHoYkuwPrmaxY3FdD1aqbYrpHoe W6k=
- 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.
2019-09-16 Alistair Francis <alistair.francis@wdc.com>
* 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.
---
This change was tested by running user space tests for RV32 and RV64.
v2:
- Change to if defined instead of if == 1
sysdeps/unix/sysv/linux/generic/bits/stat.h | 5 ++++-
sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h | 4 ++++
2 files changed, 8 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..e580071d26c 100644
--- a/sysdeps/unix/sysv/linux/generic/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/generic/bits/stat.h
@@ -40,7 +40,10 @@
/* Versions of the `xmknod' interface. */
#define _MKNOD_VER_LINUX 0
-#if defined __USE_FILE_OFFSET64
+#if defined (__USE_FILE_OFFSET64) || 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) type64 name
#elif __WORDSIZE == 64
# define __field64(type, type64, name) type 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..3c21da501b2 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. */
--
2.23.0