[v2,2/2] Define __STATFS_MATCHES_STATFS64

Message ID 20190925003114.21546-2-alistair.francis@wdc.com
State Superseded
Headers show
Series
  • [v2,1/2] sysdeps/stat: Handle 64-bit ino_t types on 32-bit hosts
Related show

Commit Message

Alistair Francis Sept. 25, 2019, 12:31 a.m.
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
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: Define
	__STATFS_MATCHES_STATFS64 to handle 64-bit __fsblkcnt_t
	and t__fsfilcnt_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
 - Introduce __STATFS_MATCHES_STATFS64

 sysdeps/unix/sysv/linux/generic/bits/statfs.h          | 2 +-
 sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

-- 
2.23.0

Comments

Andreas Schwab Sept. 25, 2019, 7:38 a.m. | #1
On Sep 24 2019, Alistair Francis <alistair.francis@wdc.com> wrote:

> 	* sysdeps/unix/sysv/linux/generic/bits/statfs.h: Define

> 	__STATFS_MATCHES_STATFS64 to handle 64-bit __fsblkcnt_t

> 	and t__fsfilcnt_t types on 32-bit hosts.


The patch doesn't do that though.  It uses it, but doesn't define it.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
Alistair Francis Sept. 25, 2019, 10:53 p.m. | #2
On Wed, Sep 25, 2019 at 12:38 AM Andreas Schwab <schwab@suse.de> wrote:
>

> On Sep 24 2019, Alistair Francis <alistair.francis@wdc.com> wrote:

>

> >       * sysdeps/unix/sysv/linux/generic/bits/statfs.h: Define

> >       __STATFS_MATCHES_STATFS64 to handle 64-bit __fsblkcnt_t

> >       and t__fsfilcnt_t types on 32-bit hosts.

>

> The patch doesn't do that though.  It uses it, but doesn't define it.


There are currently no 32-bit hosts with 64-bit time_t in glibc. This
patch is in preparation of the RV32 series/other y2038 safe archs.

Alistair

>

> Andreas.

>

> --

> Andreas Schwab, SUSE Labs, schwab@suse.de

> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7

> "And now for something completely different."

Patch

diff --git a/sysdeps/unix/sysv/linux/generic/bits/statfs.h b/sysdeps/unix/sysv/linux/generic/bits/statfs.h
index c4069aba620..0ab96dc8c3e 100644
--- a/sysdeps/unix/sysv/linux/generic/bits/statfs.h
+++ b/sysdeps/unix/sysv/linux/generic/bits/statfs.h
@@ -32,7 +32,7 @@ 
    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) || defined (__STATFS_MATCHES_STATFS64)
 # 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..eb4373efe48 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 (__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
 }