This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH 2/2] sysdeps/statfs: 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: joseph at codesourcery dot com, alistair dot francis at wdc dot com, macro at wdc dot com, alistair23 at gmail dot com
- Date: Mon, 16 Sep 2019 15:17:00 -0700
- Subject: [PATCH 2/2] sysdeps/statfs: Handle 64-bit ino_t types on 32-bit hosts
- Ironport-sdr: V1LCrrCUAikN1Yoh+QdciQ0xgqunhR4VZvX/zk4tO9jIgZUwuAm8LUDmdwOQbdnT/t+oYJHMaG zHgIQOZ2h5m4VnRXA4Jryx4WTvp7Gxo2Tek1S1FmbzMfznNcFmdcFBc6MVdWzbP33o9QtoL2cK vKw5Nej63vFLIpLdNtBB5vbGvnKE7QiDTjpaq1IQFHyxRCO6DaVZjLaU2UGm7JTN0oZp4khgYY Ok/Ur7VB1YA5IMvBDraCId2cW5Ptg3psDc7rR505MMDtAdGO9gEj9C6vBhipNN4oytvP+EERw5 qZ8=
- Ironport-sdr: j7nzqtu0t2IKXpzjzUIr1iL8RNy5sCv9vg/6WVDPRnOXHTJd/7rdslhoP9WFa7oY58fhUe7O99 BPm0cJTuNDI0Sz0kaPt9jPb2msLRL44OL2vaPLuEwT99mISx1i40ySoS21AZBr86kuIYGAb9lo uC+fDDV1HHJSxIugt4iaKky8RTvbxTDmPtR1b040/21JC/jPsb9v2Y8yGvffrrTdWMRzWbvT/x zfdROV7KmhnCgkUF7kF0iOMQS1/CnY5cx9kKWBjhBycDAIkJdzY4WRQdmbmT4QKTRusXHtyQs3 K4GgAbox9KLw6rmBiYLtpWsS
- Ironport-sdr: uVF0E3EX8i11c2Mg24ogwF9eACKmBQxwhVUBHBYVT3IdwQsqviMMn269u1McooEnWEnJbGbiGC mnSufXR5NnWLOXF/rJsiDGEUzh4TaHyKeENyb4wwHIcbZj+tCSAEq3z1WB3BPBGVlD3d17YrXC fHi92uCMFdnEnZgIkEoPYC7jQxIVUcWpuF18Nd6x0BuDBkoAQDVJbGgu3yL9ehv8DGlpZS512i EnCMZCMLQbqal6t4YoVglceREdA0jApADau8ucoXGIfXnTe2qhSHGEG4OlJAa14hqq1j+MWWRR n30=
- References: <20190916221700.22039-1-alistair.francis@wdc.com>
- 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 statfs 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/statfs.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/bits/statfs.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/statfs.h b/sysdeps/unix/sysv/linux/generic/bits/statfs.h
index 3472084ade0..eab1439acff 100644
--- a/sysdeps/unix/sysv/linux/generic/bits/statfs.h
+++ b/sysdeps/unix/sysv/linux/generic/bits/statfs.h
@@ -32,7 +32,10 @@
using __USE_FILE_OFFSET64 only see the low 32 bits of some
of the fields (the __fsblkcnt_t and __fsfilcnt_t fields). */
-#if defined __USE_FILE_OFFSET64
+#if defined(__USE_FILE_OFFSET64) || __INO_T_MATCHES_INO64_T == 1
+# if __INO_T_MATCHES_INO64_T == 1 && __OFF_T_MATCHES_OFF64_T != 1
+# 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 3c21da501b2..df35c69c09f 100644
--- a/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h
+++ b/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h
@@ -51,6 +51,9 @@ static inline int stat_overflow (struct stat *buf)
/* Note that f_files and f_ffree may validly be a sign-extended -1. */
static inline int statfs_overflow (struct statfs *buf)
{
+#if defined (__INO_T_MATCHES_INO64_T)
+ return 0;
+#else
if (buf->__f_blocks_pad == 0 && buf->__f_bfree_pad == 0
&& buf->__f_bavail_pad == 0
&& (buf->__f_files_pad == 0
@@ -61,4 +64,5 @@ static inline int statfs_overflow (struct statfs *buf)
__set_errno (EOVERFLOW);
return -1;
+#endif
}
--
2.23.0