[v4,2/2] Define __STATFS_MATCHES_STATFS64
Commit Message
Add a new macro __STATFS_MATCHES_STATFS64 that specifies if fsblkcnt_t
matches fsblkcnt64_t and if fsfilcnt_t matches fsfilcnt64_t.
On a 32-bit platform with a 64-bit ino_t type (__STATFS_MATCHES_STATFS64
== 1) 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.
* bits/typesizes.h: Define __STATFS_MATCHES_STATFS64 to handle
64-bit __fsblkcnt_t and __fsfilcnt_t types on 32-bit hosts.
* sysdeps/unix/sysv/linux/generic/bits/statfs.h: Likewise.
* sysdeps/unix/sysv/linux/generic/bits/typesizes.h: Likewise.
* sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h: Likewise.
* sysdeps/unix/sysv/linux/s390/bits/typesizes.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/bits/typesizes.h: Likewise.
* sysdeps/unix/sysv/linux/x86/bits/typesizes.h: Likewise.
---
bits/typesizes.h | 5 +++++
sysdeps/unix/sysv/linux/generic/bits/statfs.h | 2 +-
sysdeps/unix/sysv/linux/generic/bits/typesizes.h | 6 +++++-
sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h | 4 ++++
sysdeps/unix/sysv/linux/s390/bits/typesizes.h | 5 +++++
sysdeps/unix/sysv/linux/sparc/bits/typesizes.h | 5 +++++
sysdeps/unix/sysv/linux/x86/bits/typesizes.h | 5 +++++
7 files changed, 30 insertions(+), 2 deletions(-)
Comments
On Wed, 16 Oct 2019, Alistair Francis wrote:
> Add a new macro __STATFS_MATCHES_STATFS64 that specifies if fsblkcnt_t
> matches fsblkcnt64_t and if fsfilcnt_t matches fsfilcnt64_t.
>
> On a 32-bit platform with a 64-bit ino_t type (__STATFS_MATCHES_STATFS64
> == 1) 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.
>
> * bits/typesizes.h: Define __STATFS_MATCHES_STATFS64 to handle
> 64-bit __fsblkcnt_t and __fsfilcnt_t types on 32-bit hosts.
> * sysdeps/unix/sysv/linux/generic/bits/statfs.h: Likewise.
> * sysdeps/unix/sysv/linux/generic/bits/typesizes.h: Likewise.
> * sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h: Likewise.
> * sysdeps/unix/sysv/linux/s390/bits/typesizes.h: Likewise.
> * sysdeps/unix/sysv/linux/sparc/bits/typesizes.h: Likewise.
> * sysdeps/unix/sysv/linux/x86/bits/typesizes.h: Likewise.
Note that you no longer need to write ChangeLog entries.
I don't follow the logic for which bits/typesizes.h headers you're
updating. You're updating some for architectures not using linux/generic,
which I think is the right thing to do - make them provide the defined
API, whether or not they currently use any code that actually tests the
__STATFS_MATCHES_STATFS64 macro. But you're not updating
sysdeps/unix/sysv/linux/alpha/bits/typesizes.h or
sysdeps/mach/hurd/bits/typesizes.h; I'd expect those to be updated as well
for consistency.
On Fri, Oct 18, 2019 at 8:14 AM Joseph Myers <joseph@codesourcery.com> wrote:
>
> On Wed, 16 Oct 2019, Alistair Francis wrote:
>
> > Add a new macro __STATFS_MATCHES_STATFS64 that specifies if fsblkcnt_t
> > matches fsblkcnt64_t and if fsfilcnt_t matches fsfilcnt64_t.
> >
> > On a 32-bit platform with a 64-bit ino_t type (__STATFS_MATCHES_STATFS64
> > == 1) 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.
> >
> > * bits/typesizes.h: Define __STATFS_MATCHES_STATFS64 to handle
> > 64-bit __fsblkcnt_t and __fsfilcnt_t types on 32-bit hosts.
> > * sysdeps/unix/sysv/linux/generic/bits/statfs.h: Likewise.
> > * sysdeps/unix/sysv/linux/generic/bits/typesizes.h: Likewise.
> > * sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h: Likewise.
> > * sysdeps/unix/sysv/linux/s390/bits/typesizes.h: Likewise.
> > * sysdeps/unix/sysv/linux/sparc/bits/typesizes.h: Likewise.
> > * sysdeps/unix/sysv/linux/x86/bits/typesizes.h: Likewise.
>
> Note that you no longer need to write ChangeLog entries.
>
> I don't follow the logic for which bits/typesizes.h headers you're
> updating. You're updating some for architectures not using linux/generic,
> which I think is the right thing to do - make them provide the defined
> API, whether or not they currently use any code that actually tests the
> __STATFS_MATCHES_STATFS64 macro. But you're not updating
> sysdeps/unix/sysv/linux/alpha/bits/typesizes.h or
> sysdeps/mach/hurd/bits/typesizes.h; I'd expect those to be updated as well
> for consistency.
I just missed those two, I have updated them.
Alistair
>
> --
> Joseph S. Myers
> joseph@codesourcery.com
@@ -72,8 +72,13 @@
/* And for rlim_t and rlim64_t. */
# define __RLIM_T_MATCHES_RLIM64_T 1
+
+/* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. */
+# define __STATFS_MATCHES_STATFS64 1
#else
# define __RLIM_T_MATCHES_RLIM64_T 0
+
+# define __STATFS_MATCHES_STATFS64 0
#endif
/* Number of descriptors that can fit in an `fd_set'. */
@@ -34,7 +34,7 @@
#if defined __USE_FILE_OFFSET64
# define __field64(type, type64, name) type64 name
-#elif __WORDSIZE == 64
+#elif __WORDSIZE == 64 || __STATFS_MATCHES_STATFS64
# define __field64(type, type64, name) type name
#elif __BYTE_ORDER == __LITTLE_ENDIAN
# define __field64(type, type64, name) \
@@ -73,10 +73,14 @@
/* And for __rlim_t and __rlim64_t. */
# define __RLIM_T_MATCHES_RLIM64_T 1
+
+/* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. */
+# define __STATFS_MATCHES_STATFS64 1
#else
# define __RLIM_T_MATCHES_RLIM64_T 0
-#endif
+# define __STATFS_MATCHES_STATFS64 0
+#endif
/* Number of descriptors that can fit in an `fd_set'. */
#define __FD_SETSIZE 1024
@@ -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 __STATFS_MATCHES_STATFS64
+ 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
}
@@ -78,8 +78,13 @@
/* And for __rlim_t and __rlim64_t. */
# define __RLIM_T_MATCHES_RLIM64_T 1
+
+/* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. */
+# define __STATFS_MATCHES_STATFS64 1
#else
# define __RLIM_T_MATCHES_RLIM64_T 0
+
+# define __STATFS_MATCHES_STATFS64 0
#endif
/* Number of descriptors that can fit in an `fd_set'. */
@@ -72,8 +72,13 @@
/* And for __rlim_t and __rlim64_t. */
# define __RLIM_T_MATCHES_RLIM64_T 1
+
+/* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. */
+# define __STATFS_MATCHES_STATFS64 1
#else
# define __RLIM_T_MATCHES_RLIM64_T 0
+
+# define __STATFS_MATCHES_STATFS64 0
#endif
/* Number of descriptors that can fit in an `fd_set'. */
@@ -84,8 +84,13 @@
/* And for __rlim_t and __rlim64_t. */
# define __RLIM_T_MATCHES_RLIM64_T 1
+
+/* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. */
+# define __STATFS_MATCHES_STATFS64 1
#else
# define __RLIM_T_MATCHES_RLIM64_T 0
+
+# define __STATFS_MATCHES_STATFS64 0
#endif
/* Number of descriptors that can fit in an `fd_set'. */