This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH 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: 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:16:59 -0700
- Subject: [PATCH 1/2] sysdeps/stat: Handle 64-bit ino_t types on 32-bit hosts
- Ironport-sdr: kpVYai3zx+u2GE4/mRYSa/ZjG8HWyOtAyNJG0oSx7oBAHS5f56bJcMr6OuJ9Xo20UieISfbRd2 ex4acMSLBrNrgC4K/zF/4ko5ymcWQ+H8pRZ2Y5YsailcTyPTuc1aUhpdTOHT3nJyZiRcMtED+H Dk+WDkRpAIRReB2dsGhE2hSc2tIrWw2DKn7FfPu5PmSjIEKcUTgtDn7ISYEQe/v9v6PF0gGtiN xCeBpBS507wmECtDdbFJ9UbOTTKkpYzxdjNkTyJEyKx4UYKIjZR9vB0y7lXsIxF+diJWdsPmxS zxk=
- Ironport-sdr: ig2R6Yg0zFncIm0zlpT1JX3KxXoN0Dh7/hAbEh8Gh0NBV8rUw/+wAuQeO+9vwdmNhllgEoqqLD QAb3YHV8nnVMI+nrnEWl+9IBsUjRohv9scpomF4qxJZyMy2nHwZ2xttf6VQu6eX5hOg8OUkLRg tbR4RDLYCC82a0roKZOiCN1seeXsMAb5M/CuJafIX9tzwv77psDixj0C1q6TM3apbzIbOBYSK1 HOZVldPOqBm7X5GYaLkvqG1XulzMVsJ6pJrbObBFGEPkAKi/gPqAJ2at1pTE8Yo3h6qN3YVmKg W4/YU6SlD0A45KWq9LWQ1k8g
- Ironport-sdr: C4WgxnpEXPoPpFOCaFp3d7Ww0T4zHqeeygZ95a7hN0nZYfsLg0Jh/ZQ7PepUgz+6f4/GUdXUZe qAIeUczmj6Y8oIqpe58/vzysC+z1aHdD4rxmx6FAXYvgM6GPWRYum8WkxW+mJbcRXn+aLpaNZP 7gm4SF2b2rzUwEATl3spU/YkB5VCXrhKzlWJI9m3WqlV2IW0jphiy8KvEuI1xEiDQONxrStKD6 j4YtqG/M/LEu01nDk6XL7elYwZGxYILCAn8JwohT6W9eCwkND8pzx83h2ocHiINSyKfZ0nK51m Avg=
- 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.
---
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 62aeea5a88d..acd8e7c79a6 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) || __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 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