public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 00/10] [f]stat[fs,vfs] consolidation
@ 2021-02-08 21:49 Adhemerval Zanella
  2021-02-08 21:49 ` [PATCH 01/10] linux: Fix STATFS_IS_STATFS64 definition Adhemerval Zanella
                   ` (10 more replies)
  0 siblings, 11 replies; 27+ messages in thread
From: Adhemerval Zanella @ 2021-02-08 21:49 UTC (permalink / raw)
  To: libc-alpha

The recent thread from OpenRISC work [1] showed that even through after
the stat refactor to add y2038 support, the default internals still do
not set a saner default ABI.

The 'generic' internal interface still assumes non-LFS support calls
and sets both the kernel_stat.h and the statfs.h with this assumption.
This is misleading and requires newer ports to override both definitions
(as done by arc and riscv32).

This a refactor set I intended to push and the idea is to make LFS only
support as default.  It requires to set XSTAT_IS_XSTAT64 to 1 and
STATFS_IS_STATFS64 to __STATFS_MATCHES_STATFS64 (the STAT_IS_KERNEL_STAT
is not really required for newer ports, only for older ones with
non-LFS ABI).

It allows to consolide the [f]stat[fs,vfs] using the same strategy done
for stat functions, with alpha being the only outlier (and the hackery
required to support moved to an alpha specific implementation).

The final patch also removes a recent addition to the 'generic' folder
(stat-check.c).  My longer plan is to remove the 'generic' folder
altogether, by consolidating the implementations, moving the outliers
to arch-specific implementations, and setting a more saner default abi
(that assumes LFS and 64-bit time).

[1] https://sourceware.org/pipermail/libc-alpha/2021-January/122167.html

Adhemerval Zanella (10):
  linux: Fix STATFS_IS_STATFS64 definition
  linux: Set default kernel_stat.h to LFS
  linux: Set LFS statfs as default
  linux: Consolidate fstatfs implementations
  linux: Consolidate statfs implementations
  linux: Consolidate fstatvfs implementations
  linux: Consolidate statvfs implementations
  linux: Consolidate internal_statvfs
  linux: Remove overflow.h
  linux: Remove stat-check.c

 include/sys/statfs.h                          |  7 +-
 include/sys/statvfs.h                         |  3 +-
 sysdeps/unix/sysv/linux/Makefile              |  2 +-
 .../{generic/wordsize-32 => alpha}/fstatfs.c  | 13 +---
 sysdeps/unix/sysv/linux/alpha/fstatfs64.c     | 52 ++++++++++++-
 sysdeps/unix/sysv/linux/alpha/fstatvfs.c      |  1 -
 sysdeps/unix/sysv/linux/alpha/fstatvfs64.c    |  1 -
 .../sysv/linux/alpha/internal_statvfs64.c     |  1 -
 .../{generic/wordsize-32 => alpha}/statfs.c   | 16 ++--
 sysdeps/unix/sysv/linux/alpha/statfs64.c      | 52 ++++++++++++-
 sysdeps/unix/sysv/linux/alpha/statvfs.c       |  1 -
 sysdeps/unix/sysv/linux/alpha/statvfs64.c     |  1 -
 sysdeps/unix/sysv/linux/alpha/syscalls.list   |  4 -
 sysdeps/unix/sysv/linux/arc/kernel_stat.h     | 27 -------
 sysdeps/unix/sysv/linux/arm/kernel_stat.h     | 40 ++++++++++
 .../linux/{generic => csky}/bits/statfs.h     | 11 ---
 .../sysv/linux/{riscv => csky}/kernel_stat.h  | 12 ++-
 sysdeps/unix/sysv/linux/fstatat64.c           | 12 +++
 sysdeps/unix/sysv/linux/fstatfs.c             | 62 +++++++++++++++
 sysdeps/unix/sysv/linux/fstatfs64.c           | 67 +++--------------
 sysdeps/unix/sysv/linux/fstatvfs.c            | 11 ++-
 sysdeps/unix/sysv/linux/fstatvfs64.c          | 53 +++++--------
 sysdeps/unix/sysv/linux/generic/Makefile      |  2 +-
 sysdeps/unix/sysv/linux/generic/stat-check.c  | 29 -------
 .../sysv/linux/generic/wordsize-32/overflow.h | 69 -----------------
 sysdeps/unix/sysv/linux/i386/kernel_stat.h    | 40 ++++++++++
 sysdeps/unix/sysv/linux/ia64/kernel_stat.h    | 22 ------
 sysdeps/unix/sysv/linux/internal_statvfs.c    | 70 +++++++++++------
 sysdeps/unix/sysv/linux/internal_statvfs.h    |  8 +-
 sysdeps/unix/sysv/linux/internal_statvfs64.c  |  4 -
 sysdeps/unix/sysv/linux/kernel_stat.h         | 58 +++++---------
 sysdeps/unix/sysv/linux/m68k/kernel_stat.h    | 40 ++++++++++
 sysdeps/unix/sysv/linux/mips/kernel_stat.h    |  6 +-
 .../sysv/linux/mips/mips64/n64/fstatfs64.c    |  1 -
 .../sysv/linux/mips/mips64/n64/statfs64.c     |  1 -
 .../sysv/linux/mips/mips64/n64/syscalls.list  |  3 -
 sysdeps/unix/sysv/linux/nios2/bits/statfs.h   | 75 +++++++++++++++++++
 .../linux/{generic => nios2}/kernel_stat.h    | 18 ++---
 .../linux/powerpc/powerpc64/kernel_stat.h     | 22 ------
 .../sysv/linux/s390/s390-32/kernel_stat.h     | 40 ++++++++++
 .../sysv/linux/s390/s390-64/kernel_stat.h     | 22 ------
 sysdeps/unix/sysv/linux/sh/kernel_stat.h      | 40 ++++++++++
 .../sysv/linux/sparc/sparc64/kernel_stat.h    |  7 +-
 sysdeps/unix/sysv/linux/statfs.c              | 61 +++++++++++++++
 sysdeps/unix/sysv/linux/statfs64.c            | 69 ++---------------
 sysdeps/unix/sysv/linux/statvfs.c             | 11 ++-
 sysdeps/unix/sysv/linux/statvfs64.c           | 54 +++++--------
 .../unix/sysv/linux/wordsize-64/fstatfs64.c   |  1 -
 .../unix/sysv/linux/wordsize-64/fstatvfs.c    |  5 --
 .../unix/sysv/linux/wordsize-64/fstatvfs64.c  |  1 -
 .../linux/wordsize-64/internal_statvfs64.c    |  1 -
 .../unix/sysv/linux/wordsize-64/statfs64.c    |  1 -
 sysdeps/unix/sysv/linux/wordsize-64/statvfs.c |  5 --
 .../unix/sysv/linux/wordsize-64/statvfs64.c   |  1 -
 .../unix/sysv/linux/wordsize-64/syscalls.list |  2 -
 sysdeps/unix/sysv/linux/x86_64/kernel_stat.h  | 22 ------
 sysdeps/unix/sysv/linux/xstatconv.c           |  7 +-
 57 files changed, 688 insertions(+), 579 deletions(-)
 rename sysdeps/unix/sysv/linux/{generic/wordsize-32 => alpha}/fstatfs.c (76%)
 delete mode 100644 sysdeps/unix/sysv/linux/alpha/fstatvfs.c
 delete mode 100644 sysdeps/unix/sysv/linux/alpha/fstatvfs64.c
 delete mode 100644 sysdeps/unix/sysv/linux/alpha/internal_statvfs64.c
 rename sysdeps/unix/sysv/linux/{generic/wordsize-32 => alpha}/statfs.c (72%)
 delete mode 100644 sysdeps/unix/sysv/linux/alpha/statvfs.c
 delete mode 100644 sysdeps/unix/sysv/linux/alpha/statvfs64.c
 delete mode 100644 sysdeps/unix/sysv/linux/arc/kernel_stat.h
 create mode 100644 sysdeps/unix/sysv/linux/arm/kernel_stat.h
 rename sysdeps/unix/sysv/linux/{generic => csky}/bits/statfs.h (79%)
 rename sysdeps/unix/sysv/linux/{riscv => csky}/kernel_stat.h (77%)
 create mode 100644 sysdeps/unix/sysv/linux/fstatfs.c
 delete mode 100644 sysdeps/unix/sysv/linux/generic/stat-check.c
 delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h
 create mode 100644 sysdeps/unix/sysv/linux/i386/kernel_stat.h
 delete mode 100644 sysdeps/unix/sysv/linux/ia64/kernel_stat.h
 delete mode 100644 sysdeps/unix/sysv/linux/internal_statvfs64.c
 create mode 100644 sysdeps/unix/sysv/linux/m68k/kernel_stat.h
 delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n64/fstatfs64.c
 delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n64/statfs64.c
 create mode 100644 sysdeps/unix/sysv/linux/nios2/bits/statfs.h
 rename sysdeps/unix/sysv/linux/{generic => nios2}/kernel_stat.h (71%)
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h
 create mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/kernel_stat.h
 delete mode 100644 sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h
 create mode 100644 sysdeps/unix/sysv/linux/sh/kernel_stat.h
 create mode 100644 sysdeps/unix/sysv/linux/statfs.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/fstatfs64.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/fstatvfs.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/fstatvfs64.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/internal_statvfs64.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/statfs64.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/statvfs.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/statvfs64.c
 delete mode 100644 sysdeps/unix/sysv/linux/x86_64/kernel_stat.h

-- 
2.25.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 01/10] linux: Fix STATFS_IS_STATFS64 definition
  2021-02-08 21:49 [PATCH 00/10] [f]stat[fs,vfs] consolidation Adhemerval Zanella
@ 2021-02-08 21:49 ` Adhemerval Zanella
  2021-02-11  0:37   ` Carlos O'Donell
  2021-02-08 21:49 ` [PATCH 02/10] linux: Set default kernel_stat.h to LFS Adhemerval Zanella
                   ` (9 subsequent siblings)
  10 siblings, 1 reply; 27+ messages in thread
From: Adhemerval Zanella @ 2021-02-08 21:49 UTC (permalink / raw)
  To: libc-alpha

aarch64, arc, ia64, mips64, powerpc64, riscv32, riscv64, s390x, sparc64,
and  x86_64 defines STATFS_IS_STATFS64 to 0, but all of them alias
both statfs to statfs64 and struct statfs has the same and layout of
struct statfs64.

The correct definition will be used on the {f}statfs{64} consolidation.

This patch does not change code generation since the symbols are
implemented using the auto-generation syscall for all the aforementioned
abis.
---
 sysdeps/unix/sysv/linux/aarch64/kernel_stat.h | 21 +++++++++++++++++++
 sysdeps/unix/sysv/linux/ia64/kernel_stat.h    |  2 +-
 sysdeps/unix/sysv/linux/mips/kernel_stat.h    |  6 +++++-
 .../linux/powerpc/powerpc64/kernel_stat.h     |  2 +-
 sysdeps/unix/sysv/linux/riscv/kernel_stat.h   |  2 +-
 .../sysv/linux/s390/s390-64/kernel_stat.h     |  2 +-
 .../sysv/linux/sparc/sparc64/kernel_stat.h    |  7 +++++--
 sysdeps/unix/sysv/linux/x86_64/kernel_stat.h  |  2 +-
 8 files changed, 36 insertions(+), 8 deletions(-)
 create mode 100644 sysdeps/unix/sysv/linux/aarch64/kernel_stat.h

diff --git a/sysdeps/unix/sysv/linux/aarch64/kernel_stat.h b/sysdeps/unix/sysv/linux/aarch64/kernel_stat.h
new file mode 100644
index 0000000000..33ad1b622b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/aarch64/kernel_stat.h
@@ -0,0 +1,21 @@
+/* Internal definitions for stat functions.  Linux/AARch64 version.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#define STAT_IS_KERNEL_STAT 1
+#define XSTAT_IS_XSTAT64 1
+#define STATFS_IS_STATFS64 1
diff --git a/sysdeps/unix/sysv/linux/ia64/kernel_stat.h b/sysdeps/unix/sysv/linux/ia64/kernel_stat.h
index e1eac69850..ee05a15590 100644
--- a/sysdeps/unix/sysv/linux/ia64/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/ia64/kernel_stat.h
@@ -19,4 +19,4 @@
 #define STAT_IS_KERNEL_STAT 1
 #define STAT64_IS_KERNEL_STAT64 1
 #define XSTAT_IS_XSTAT64 1
-#define STATFS_IS_STATFS64 0
+#define STATFS_IS_STATFS64 1
diff --git a/sysdeps/unix/sysv/linux/mips/kernel_stat.h b/sysdeps/unix/sysv/linux/mips/kernel_stat.h
index 21dba2de73..e4b0f211ca 100644
--- a/sysdeps/unix/sysv/linux/mips/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/mips/kernel_stat.h
@@ -62,6 +62,10 @@ struct kernel_stat
 #define STAT_IS_KERNEL_STAT 0
 #define STAT64_IS_KERNEL_STAT64 0
 #define XSTAT_IS_XSTAT64 0
-#define STATFS_IS_STATFS64 0
+#if _MIPS_SIM == _ABI64
+# define STATFS_IS_STATFS64 1
+#else
+# define STATFS_IS_STATFS64 0
+#endif
 
 #endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h b/sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h
index a1f66bcece..bc7390c9ff 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h
@@ -19,4 +19,4 @@
 #define STAT_IS_KERNEL_STAT 1
 #define STAT64_IS_KERNEL_STAT64 1
 #define XSTAT_IS_XSTAT64 1
-#define STATFS_IS_STATFS64 0
+#define STATFS_IS_STATFS64 1
diff --git a/sysdeps/unix/sysv/linux/riscv/kernel_stat.h b/sysdeps/unix/sysv/linux/riscv/kernel_stat.h
index ee8b37a9eb..4ad7913762 100644
--- a/sysdeps/unix/sysv/linux/riscv/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/riscv/kernel_stat.h
@@ -20,4 +20,4 @@
 #define STAT_IS_KERNEL_STAT 1
 
 #define XSTAT_IS_XSTAT64 1
-#define STATFS_IS_STATFS64 0
+#define STATFS_IS_STATFS64 1
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h b/sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h
index e1eac69850..ee05a15590 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h
@@ -19,4 +19,4 @@
 #define STAT_IS_KERNEL_STAT 1
 #define STAT64_IS_KERNEL_STAT64 1
 #define XSTAT_IS_XSTAT64 1
-#define STATFS_IS_STATFS64 0
+#define STATFS_IS_STATFS64 1
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h b/sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h
index 0f3d405239..29d18908da 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h
@@ -50,6 +50,9 @@ struct kernel_stat64
 #define STAT_IS_KERNEL_STAT 0
 #define STAT64_IS_KERNEL_STAT64 0
 #define XSTAT_IS_XSTAT64 1
-#define STATFS_IS_STATFS64 0
-
+#ifdef __arch64__
+# define STATFS_IS_STATFS64 1
+#else
+# define STATFS_IS_STATFS64 0
+#endif
 #endif /* _KERNEL_STAT_H  */
diff --git a/sysdeps/unix/sysv/linux/x86_64/kernel_stat.h b/sysdeps/unix/sysv/linux/x86_64/kernel_stat.h
index e1eac69850..ee05a15590 100644
--- a/sysdeps/unix/sysv/linux/x86_64/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/x86_64/kernel_stat.h
@@ -19,4 +19,4 @@
 #define STAT_IS_KERNEL_STAT 1
 #define STAT64_IS_KERNEL_STAT64 1
 #define XSTAT_IS_XSTAT64 1
-#define STATFS_IS_STATFS64 0
+#define STATFS_IS_STATFS64 1
-- 
2.25.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 02/10] linux: Set default kernel_stat.h to LFS
  2021-02-08 21:49 [PATCH 00/10] [f]stat[fs,vfs] consolidation Adhemerval Zanella
  2021-02-08 21:49 ` [PATCH 01/10] linux: Fix STATFS_IS_STATFS64 definition Adhemerval Zanella
@ 2021-02-08 21:49 ` Adhemerval Zanella
  2021-02-11  0:37   ` Carlos O'Donell
  2021-02-08 21:49 ` [PATCH 03/10] linux: Set LFS statfs as default Adhemerval Zanella
                   ` (8 subsequent siblings)
  10 siblings, 1 reply; 27+ messages in thread
From: Adhemerval Zanella @ 2021-02-08 21:49 UTC (permalink / raw)
  To: libc-alpha

The XSTAT_IS_XSTAT64 and STAT_IS_KERNEL_STAT flags are now set to 1 and
STATFS_IS_STATFS64 is set to __STATFS_MATCHES_STATFS64.  This makes the
default ABI for newer ports to provide only LFS calls.

A copy of non-LFS support is provided to 32-bit ABIS with non-LFS
support (arm, csky, i386, m68k, nios2, s390, and sh).  Is also allows
to remove the 64-bit ports, which already uses the default values.

This patch does not change the code generation.
---
 sysdeps/unix/sysv/linux/arc/kernel_stat.h     | 27 ---------
 sysdeps/unix/sysv/linux/arm/kernel_stat.h     | 40 +++++++++++++
 .../sysv/linux/{riscv => csky}/kernel_stat.h  | 12 ++--
 sysdeps/unix/sysv/linux/generic/kernel_stat.h | 30 ----------
 sysdeps/unix/sysv/linux/i386/kernel_stat.h    | 40 +++++++++++++
 sysdeps/unix/sysv/linux/ia64/kernel_stat.h    | 22 -------
 sysdeps/unix/sysv/linux/kernel_stat.h         | 58 +++++++------------
 sysdeps/unix/sysv/linux/m68k/kernel_stat.h    | 40 +++++++++++++
 .../linux/{aarch64 => nios2}/kernel_stat.h    |  9 +--
 .../linux/powerpc/powerpc64/kernel_stat.h     | 22 -------
 .../sysv/linux/s390/s390-32/kernel_stat.h     | 40 +++++++++++++
 .../sysv/linux/s390/s390-64/kernel_stat.h     | 22 -------
 sysdeps/unix/sysv/linux/sh/kernel_stat.h      | 40 +++++++++++++
 sysdeps/unix/sysv/linux/x86_64/kernel_stat.h  | 22 -------
 sysdeps/unix/sysv/linux/xstatconv.c           |  7 +--
 15 files changed, 231 insertions(+), 200 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/arc/kernel_stat.h
 create mode 100644 sysdeps/unix/sysv/linux/arm/kernel_stat.h
 rename sysdeps/unix/sysv/linux/{riscv => csky}/kernel_stat.h (77%)
 delete mode 100644 sysdeps/unix/sysv/linux/generic/kernel_stat.h
 create mode 100644 sysdeps/unix/sysv/linux/i386/kernel_stat.h
 delete mode 100644 sysdeps/unix/sysv/linux/ia64/kernel_stat.h
 create mode 100644 sysdeps/unix/sysv/linux/m68k/kernel_stat.h
 rename sysdeps/unix/sysv/linux/{aarch64 => nios2}/kernel_stat.h (78%)
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h
 create mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/kernel_stat.h
 delete mode 100644 sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h
 create mode 100644 sysdeps/unix/sysv/linux/sh/kernel_stat.h
 delete mode 100644 sysdeps/unix/sysv/linux/x86_64/kernel_stat.h

diff --git a/sysdeps/unix/sysv/linux/arc/kernel_stat.h b/sysdeps/unix/sysv/linux/arc/kernel_stat.h
deleted file mode 100644
index edd96b1b94..0000000000
--- a/sysdeps/unix/sysv/linux/arc/kernel_stat.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright (C) 2020-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <bits/wordsize.h>
-
-/* Needed to elide the itemized copy code in common xstatconv.c.  */
-#define STAT_IS_KERNEL_STAT 1
-#define STAT64_IS_KERNEL_STAT64 1
-
-/* Nice side-effect of 64-bit time_t switch is these are same.  */
-#define XSTAT_IS_XSTAT64 1
-
-#define STATFS_IS_STATFS64 0
diff --git a/sysdeps/unix/sysv/linux/arm/kernel_stat.h b/sysdeps/unix/sysv/linux/arm/kernel_stat.h
new file mode 100644
index 0000000000..b1bc1459f0
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/arm/kernel_stat.h
@@ -0,0 +1,40 @@
+/* Definition of `struct stat' used in the kernel..  */
+struct kernel_stat
+  {
+    unsigned short int st_dev;
+    unsigned short int __pad1;
+#define _HAVE___PAD1
+    unsigned long int st_ino;
+    unsigned short int st_mode;
+    unsigned short int st_nlink;
+    unsigned short int st_uid;
+    unsigned short int st_gid;
+    unsigned short int st_rdev;
+    unsigned short int __pad2;
+#define _HAVE___PAD2
+    unsigned long int st_size;
+    unsigned long int st_blksize;
+    unsigned long int st_blocks;
+    struct timespec st_atim;
+    struct timespec st_mtim;
+    struct timespec st_ctim;
+    unsigned long int __glibc_reserved4;
+#define _HAVE___UNUSED4
+    unsigned long int __glibc_reserved5;
+#define _HAVE___UNUSED5
+  };
+
+#define _HAVE_STAT___UNUSED4
+#define _HAVE_STAT___UNUSED5
+#define _HAVE_STAT___PAD1
+#define _HAVE_STAT___PAD2
+#define _HAVE_STAT_NSEC
+#define _HAVE_STAT64___PAD1
+#define _HAVE_STAT64___PAD2
+#define _HAVE_STAT64___ST_INO
+#define _HAVE_STAT64_NSEC
+
+#define STAT_IS_KERNEL_STAT 0
+#define STAT64_IS_KERNEL_STAT64 1
+#define XSTAT_IS_XSTAT64 0
+#define STATFS_IS_STATFS64 0
diff --git a/sysdeps/unix/sysv/linux/riscv/kernel_stat.h b/sysdeps/unix/sysv/linux/csky/kernel_stat.h
similarity index 77%
rename from sysdeps/unix/sysv/linux/riscv/kernel_stat.h
rename to sysdeps/unix/sysv/linux/csky/kernel_stat.h
index 4ad7913762..e993021a81 100644
--- a/sysdeps/unix/sysv/linux/riscv/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/csky/kernel_stat.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 2020-2021 Free Software Foundation, Inc.
+/* Internal definitions for stat functions.  Linux/csky.
+   Copyright (C) 2011-2021 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -15,9 +16,6 @@
    License along with the GNU C Library.  If not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <bits/wordsize.h>
-
-#define STAT_IS_KERNEL_STAT 1
-
-#define XSTAT_IS_XSTAT64 1
-#define STATFS_IS_STATFS64 1
+#define STAT_IS_KERNEL_STAT  1
+#define XSTAT_IS_XSTAT64     0
+#define STATFS_IS_STATFS64   0
diff --git a/sysdeps/unix/sysv/linux/generic/kernel_stat.h b/sysdeps/unix/sysv/linux/generic/kernel_stat.h
deleted file mode 100644
index 350f0cc1bb..0000000000
--- a/sysdeps/unix/sysv/linux/generic/kernel_stat.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Copyright (C) 2011-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <bits/wordsize.h>
-
-#define STAT_IS_KERNEL_STAT 1
-
-/* We provide separate 32-bit API versions that check for EOVERFLOW. */
-#if __WORDSIZE == 64
-# define XSTAT_IS_XSTAT64 1
-#else
-# define XSTAT_IS_XSTAT64 0
-#endif
-
-#define STATFS_IS_STATFS64 0
diff --git a/sysdeps/unix/sysv/linux/i386/kernel_stat.h b/sysdeps/unix/sysv/linux/i386/kernel_stat.h
new file mode 100644
index 0000000000..b1bc1459f0
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/i386/kernel_stat.h
@@ -0,0 +1,40 @@
+/* Definition of `struct stat' used in the kernel..  */
+struct kernel_stat
+  {
+    unsigned short int st_dev;
+    unsigned short int __pad1;
+#define _HAVE___PAD1
+    unsigned long int st_ino;
+    unsigned short int st_mode;
+    unsigned short int st_nlink;
+    unsigned short int st_uid;
+    unsigned short int st_gid;
+    unsigned short int st_rdev;
+    unsigned short int __pad2;
+#define _HAVE___PAD2
+    unsigned long int st_size;
+    unsigned long int st_blksize;
+    unsigned long int st_blocks;
+    struct timespec st_atim;
+    struct timespec st_mtim;
+    struct timespec st_ctim;
+    unsigned long int __glibc_reserved4;
+#define _HAVE___UNUSED4
+    unsigned long int __glibc_reserved5;
+#define _HAVE___UNUSED5
+  };
+
+#define _HAVE_STAT___UNUSED4
+#define _HAVE_STAT___UNUSED5
+#define _HAVE_STAT___PAD1
+#define _HAVE_STAT___PAD2
+#define _HAVE_STAT_NSEC
+#define _HAVE_STAT64___PAD1
+#define _HAVE_STAT64___PAD2
+#define _HAVE_STAT64___ST_INO
+#define _HAVE_STAT64_NSEC
+
+#define STAT_IS_KERNEL_STAT 0
+#define STAT64_IS_KERNEL_STAT64 1
+#define XSTAT_IS_XSTAT64 0
+#define STATFS_IS_STATFS64 0
diff --git a/sysdeps/unix/sysv/linux/ia64/kernel_stat.h b/sysdeps/unix/sysv/linux/ia64/kernel_stat.h
deleted file mode 100644
index ee05a15590..0000000000
--- a/sysdeps/unix/sysv/linux/ia64/kernel_stat.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Definition of `struct stat' used in the kernel.
-   Copyright (C) 2003-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#define STAT_IS_KERNEL_STAT 1
-#define STAT64_IS_KERNEL_STAT64 1
-#define XSTAT_IS_XSTAT64 1
-#define STATFS_IS_STATFS64 1
diff --git a/sysdeps/unix/sysv/linux/kernel_stat.h b/sysdeps/unix/sysv/linux/kernel_stat.h
index b1bc1459f0..6c1b175cb4 100644
--- a/sysdeps/unix/sysv/linux/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/kernel_stat.h
@@ -1,40 +1,22 @@
-/* Definition of `struct stat' used in the kernel..  */
-struct kernel_stat
-  {
-    unsigned short int st_dev;
-    unsigned short int __pad1;
-#define _HAVE___PAD1
-    unsigned long int st_ino;
-    unsigned short int st_mode;
-    unsigned short int st_nlink;
-    unsigned short int st_uid;
-    unsigned short int st_gid;
-    unsigned short int st_rdev;
-    unsigned short int __pad2;
-#define _HAVE___PAD2
-    unsigned long int st_size;
-    unsigned long int st_blksize;
-    unsigned long int st_blocks;
-    struct timespec st_atim;
-    struct timespec st_mtim;
-    struct timespec st_ctim;
-    unsigned long int __glibc_reserved4;
-#define _HAVE___UNUSED4
-    unsigned long int __glibc_reserved5;
-#define _HAVE___UNUSED5
-  };
+/* Internal definitions for stat functions.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
 
-#define _HAVE_STAT___UNUSED4
-#define _HAVE_STAT___UNUSED5
-#define _HAVE_STAT___PAD1
-#define _HAVE_STAT___PAD2
-#define _HAVE_STAT_NSEC
-#define _HAVE_STAT64___PAD1
-#define _HAVE_STAT64___PAD2
-#define _HAVE_STAT64___ST_INO
-#define _HAVE_STAT64_NSEC
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
 
-#define STAT_IS_KERNEL_STAT 0
-#define STAT64_IS_KERNEL_STAT64 1
-#define XSTAT_IS_XSTAT64 0
-#define STATFS_IS_STATFS64 0
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+/* The default Linux ABI assumes only LFS support.  */
+#define XSTAT_IS_XSTAT64     1
+#define STATFS_IS_STATFS64   __STATFS_MATCHES_STATFS64
+#define STAT_IS_KERNEL_STAT  1
diff --git a/sysdeps/unix/sysv/linux/m68k/kernel_stat.h b/sysdeps/unix/sysv/linux/m68k/kernel_stat.h
new file mode 100644
index 0000000000..b1bc1459f0
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/m68k/kernel_stat.h
@@ -0,0 +1,40 @@
+/* Definition of `struct stat' used in the kernel..  */
+struct kernel_stat
+  {
+    unsigned short int st_dev;
+    unsigned short int __pad1;
+#define _HAVE___PAD1
+    unsigned long int st_ino;
+    unsigned short int st_mode;
+    unsigned short int st_nlink;
+    unsigned short int st_uid;
+    unsigned short int st_gid;
+    unsigned short int st_rdev;
+    unsigned short int __pad2;
+#define _HAVE___PAD2
+    unsigned long int st_size;
+    unsigned long int st_blksize;
+    unsigned long int st_blocks;
+    struct timespec st_atim;
+    struct timespec st_mtim;
+    struct timespec st_ctim;
+    unsigned long int __glibc_reserved4;
+#define _HAVE___UNUSED4
+    unsigned long int __glibc_reserved5;
+#define _HAVE___UNUSED5
+  };
+
+#define _HAVE_STAT___UNUSED4
+#define _HAVE_STAT___UNUSED5
+#define _HAVE_STAT___PAD1
+#define _HAVE_STAT___PAD2
+#define _HAVE_STAT_NSEC
+#define _HAVE_STAT64___PAD1
+#define _HAVE_STAT64___PAD2
+#define _HAVE_STAT64___ST_INO
+#define _HAVE_STAT64_NSEC
+
+#define STAT_IS_KERNEL_STAT 0
+#define STAT64_IS_KERNEL_STAT64 1
+#define XSTAT_IS_XSTAT64 0
+#define STATFS_IS_STATFS64 0
diff --git a/sysdeps/unix/sysv/linux/aarch64/kernel_stat.h b/sysdeps/unix/sysv/linux/nios2/kernel_stat.h
similarity index 78%
rename from sysdeps/unix/sysv/linux/aarch64/kernel_stat.h
rename to sysdeps/unix/sysv/linux/nios2/kernel_stat.h
index 33ad1b622b..1af30dab6f 100644
--- a/sysdeps/unix/sysv/linux/aarch64/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/nios2/kernel_stat.h
@@ -1,6 +1,7 @@
-/* Internal definitions for stat functions.  Linux/AARch64 version.
+/* Internal definitions for stat functions.  Linux/nios2.
    Copyright (C) 2021 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
+   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
 
    The GNU C Library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -16,6 +17,6 @@
    License along with the GNU C Library.  If not, see
    <https://www.gnu.org/licenses/>.  */
 
-#define STAT_IS_KERNEL_STAT 1
-#define XSTAT_IS_XSTAT64 1
-#define STATFS_IS_STATFS64 1
+#define STAT_IS_KERNEL_STAT  1
+#define XSTAT_IS_XSTAT64     0
+#define STATFS_IS_STATFS64   0
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h b/sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h
deleted file mode 100644
index bc7390c9ff..0000000000
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Definition of `struct stat' used in the kernel.
-   Copyright (C) 2002-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#define STAT_IS_KERNEL_STAT 1
-#define STAT64_IS_KERNEL_STAT64 1
-#define XSTAT_IS_XSTAT64 1
-#define STATFS_IS_STATFS64 1
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/kernel_stat.h b/sysdeps/unix/sysv/linux/s390/s390-32/kernel_stat.h
new file mode 100644
index 0000000000..b1bc1459f0
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/kernel_stat.h
@@ -0,0 +1,40 @@
+/* Definition of `struct stat' used in the kernel..  */
+struct kernel_stat
+  {
+    unsigned short int st_dev;
+    unsigned short int __pad1;
+#define _HAVE___PAD1
+    unsigned long int st_ino;
+    unsigned short int st_mode;
+    unsigned short int st_nlink;
+    unsigned short int st_uid;
+    unsigned short int st_gid;
+    unsigned short int st_rdev;
+    unsigned short int __pad2;
+#define _HAVE___PAD2
+    unsigned long int st_size;
+    unsigned long int st_blksize;
+    unsigned long int st_blocks;
+    struct timespec st_atim;
+    struct timespec st_mtim;
+    struct timespec st_ctim;
+    unsigned long int __glibc_reserved4;
+#define _HAVE___UNUSED4
+    unsigned long int __glibc_reserved5;
+#define _HAVE___UNUSED5
+  };
+
+#define _HAVE_STAT___UNUSED4
+#define _HAVE_STAT___UNUSED5
+#define _HAVE_STAT___PAD1
+#define _HAVE_STAT___PAD2
+#define _HAVE_STAT_NSEC
+#define _HAVE_STAT64___PAD1
+#define _HAVE_STAT64___PAD2
+#define _HAVE_STAT64___ST_INO
+#define _HAVE_STAT64_NSEC
+
+#define STAT_IS_KERNEL_STAT 0
+#define STAT64_IS_KERNEL_STAT64 1
+#define XSTAT_IS_XSTAT64 0
+#define STATFS_IS_STATFS64 0
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h b/sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h
deleted file mode 100644
index ee05a15590..0000000000
--- a/sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Definition of `struct stat' used in the kernel.
-   Copyright (C) 2003-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#define STAT_IS_KERNEL_STAT 1
-#define STAT64_IS_KERNEL_STAT64 1
-#define XSTAT_IS_XSTAT64 1
-#define STATFS_IS_STATFS64 1
diff --git a/sysdeps/unix/sysv/linux/sh/kernel_stat.h b/sysdeps/unix/sysv/linux/sh/kernel_stat.h
new file mode 100644
index 0000000000..b1bc1459f0
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sh/kernel_stat.h
@@ -0,0 +1,40 @@
+/* Definition of `struct stat' used in the kernel..  */
+struct kernel_stat
+  {
+    unsigned short int st_dev;
+    unsigned short int __pad1;
+#define _HAVE___PAD1
+    unsigned long int st_ino;
+    unsigned short int st_mode;
+    unsigned short int st_nlink;
+    unsigned short int st_uid;
+    unsigned short int st_gid;
+    unsigned short int st_rdev;
+    unsigned short int __pad2;
+#define _HAVE___PAD2
+    unsigned long int st_size;
+    unsigned long int st_blksize;
+    unsigned long int st_blocks;
+    struct timespec st_atim;
+    struct timespec st_mtim;
+    struct timespec st_ctim;
+    unsigned long int __glibc_reserved4;
+#define _HAVE___UNUSED4
+    unsigned long int __glibc_reserved5;
+#define _HAVE___UNUSED5
+  };
+
+#define _HAVE_STAT___UNUSED4
+#define _HAVE_STAT___UNUSED5
+#define _HAVE_STAT___PAD1
+#define _HAVE_STAT___PAD2
+#define _HAVE_STAT_NSEC
+#define _HAVE_STAT64___PAD1
+#define _HAVE_STAT64___PAD2
+#define _HAVE_STAT64___ST_INO
+#define _HAVE_STAT64_NSEC
+
+#define STAT_IS_KERNEL_STAT 0
+#define STAT64_IS_KERNEL_STAT64 1
+#define XSTAT_IS_XSTAT64 0
+#define STATFS_IS_STATFS64 0
diff --git a/sysdeps/unix/sysv/linux/x86_64/kernel_stat.h b/sysdeps/unix/sysv/linux/x86_64/kernel_stat.h
deleted file mode 100644
index ee05a15590..0000000000
--- a/sysdeps/unix/sysv/linux/x86_64/kernel_stat.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Definition of `struct stat' used in the kernel.
-   Copyright (C) 2003-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#define STAT_IS_KERNEL_STAT 1
-#define STAT64_IS_KERNEL_STAT64 1
-#define XSTAT_IS_XSTAT64 1
-#define STATFS_IS_STATFS64 1
diff --git a/sysdeps/unix/sysv/linux/xstatconv.c b/sysdeps/unix/sysv/linux/xstatconv.c
index 5dfe7c5fb5..4d049d4555 100644
--- a/sysdeps/unix/sysv/linux/xstatconv.c
+++ b/sysdeps/unix/sysv/linux/xstatconv.c
@@ -21,12 +21,7 @@
 #include <kernel_stat.h>
 #include <sysdep.h>
 
-#if STAT_IS_KERNEL_STAT
-
-/* Dummy.  */
-struct kernel_stat;
-
-#else
+#if !STAT_IS_KERNEL_STAT
 
 #include <string.h>
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 03/10] linux: Set LFS statfs as default
  2021-02-08 21:49 [PATCH 00/10] [f]stat[fs,vfs] consolidation Adhemerval Zanella
  2021-02-08 21:49 ` [PATCH 01/10] linux: Fix STATFS_IS_STATFS64 definition Adhemerval Zanella
  2021-02-08 21:49 ` [PATCH 02/10] linux: Set default kernel_stat.h to LFS Adhemerval Zanella
@ 2021-02-08 21:49 ` Adhemerval Zanella
  2021-02-11  0:37   ` Carlos O'Donell
  2021-02-08 21:49 ` [PATCH 04/10] linux: Consolidate fstatfs implementations Adhemerval Zanella
                   ` (7 subsequent siblings)
  10 siblings, 1 reply; 27+ messages in thread
From: Adhemerval Zanella @ 2021-02-08 21:49 UTC (permalink / raw)
  To: libc-alpha

Currently glibc has three different struct statfs{64} definitions:

  1. Non-LFS support where non-LFS and LFS struct have different
     size: alpha, arm, hppa, i686, m68k, microblaze, mips (all abis),
     powerpc32, s390, sh4, and sparc.

  2. Non-LFS support where non-LFS and LFS struct have the same
     size: csky and nios2.

  3. Only LFS support (where both struct have the same size): arc,
     ia64, powerpc64 (including LE), riscv (both 32 and 64 bits),
     s390x, sparc64, and x86 (including x32).

The STATFS_IS_STATFS64/__STATFS_MATCHES_STATFS64 does not tell apart
between 1. and 2.; since for both the only difference is the struct
size (for 2. both non-LFS and LFS uses the same syscall, where for
1. the old non-LFS is used for {f}statfs).

This patch move the generic statfs.h for both csky and nios2, and
make the default definitions for newer ABIs to assume that only
LFS will be support (so there is no need to keep no-LFS and LFS
struct statfs with the same size, it will be implicit).

This patch does not change the code generation.
---
 .../linux/{generic => csky}/bits/statfs.h     | 11 ---
 sysdeps/unix/sysv/linux/nios2/bits/statfs.h   | 75 +++++++++++++++++++
 2 files changed, 75 insertions(+), 11 deletions(-)
 rename sysdeps/unix/sysv/linux/{generic => csky}/bits/statfs.h (79%)
 create mode 100644 sysdeps/unix/sysv/linux/nios2/bits/statfs.h

diff --git a/sysdeps/unix/sysv/linux/generic/bits/statfs.h b/sysdeps/unix/sysv/linux/csky/bits/statfs.h
similarity index 79%
rename from sysdeps/unix/sysv/linux/generic/bits/statfs.h
rename to sysdeps/unix/sysv/linux/csky/bits/statfs.h
index bef18a3696..131b6adfba 100644
--- a/sysdeps/unix/sysv/linux/generic/bits/statfs.h
+++ b/sysdeps/unix/sysv/linux/csky/bits/statfs.h
@@ -1,6 +1,5 @@
 /* Copyright (C) 2011-2021 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
-   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
 
    The GNU C Library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -24,18 +23,8 @@
 #include <bits/types.h>
 #include <bits/wordsize.h>
 
-/* 64-bit libc uses the kernel's 'struct statfs', accessed via the
-   statfs() syscall; 32-bit libc uses the kernel's 'struct statfs64'
-   and accesses it via the statfs64() syscall.  All the various
-   APIs offered by libc use the kernel shape for their struct statfs
-   structure; the only difference is that 32-bit programs not
-   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
 # define __field64(type, type64, name) type64 name
-#elif __WORDSIZE == 64 || __STATFS_MATCHES_STATFS64
-# define __field64(type, type64, name) type name
 #elif __BYTE_ORDER == __LITTLE_ENDIAN
 # define __field64(type, type64, name) \
   type name __attribute__((__aligned__ (__alignof__ (type64)))); int __##name##_pad
diff --git a/sysdeps/unix/sysv/linux/nios2/bits/statfs.h b/sysdeps/unix/sysv/linux/nios2/bits/statfs.h
new file mode 100644
index 0000000000..131b6adfba
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/bits/statfs.h
@@ -0,0 +1,75 @@
+/* Copyright (C) 2011-2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#ifndef _SYS_STATFS_H
+# error "Never include <bits/statfs.h> directly; use <sys/statfs.h> instead."
+#endif
+
+#include <bits/endian.h>
+#include <bits/types.h>
+#include <bits/wordsize.h>
+
+#if defined __USE_FILE_OFFSET64
+# define __field64(type, type64, name) type64 name
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
+# define __field64(type, type64, name) \
+  type name __attribute__((__aligned__ (__alignof__ (type64)))); int __##name##_pad
+#else
+# define __field64(type, type64, name) \
+  int __##name##_pad __attribute__((__aligned__ (__alignof__ (type64)))); type name
+#endif
+
+struct statfs
+  {
+    __SWORD_TYPE f_type;
+    __SWORD_TYPE f_bsize;
+    __field64(__fsblkcnt_t, __fsblkcnt64_t, f_blocks);
+    __field64(__fsblkcnt_t, __fsblkcnt64_t, f_bfree);
+    __field64(__fsblkcnt_t, __fsblkcnt64_t, f_bavail);
+    __field64(__fsfilcnt_t, __fsfilcnt64_t, f_files);
+    __field64(__fsfilcnt_t, __fsfilcnt64_t, f_ffree);
+    __fsid_t f_fsid;
+    __SWORD_TYPE f_namelen;
+    __SWORD_TYPE f_frsize;
+    __SWORD_TYPE f_flags;
+    __SWORD_TYPE f_spare[4];
+  };
+
+#undef __field64
+
+#ifdef __USE_LARGEFILE64
+struct statfs64
+  {
+    __SWORD_TYPE f_type;
+    __SWORD_TYPE f_bsize;
+    __fsblkcnt64_t f_blocks;
+    __fsblkcnt64_t f_bfree;
+    __fsblkcnt64_t f_bavail;
+    __fsfilcnt64_t f_files;
+    __fsfilcnt64_t f_ffree;
+    __fsid_t f_fsid;
+    __SWORD_TYPE f_namelen;
+    __SWORD_TYPE f_frsize;
+    __SWORD_TYPE f_flags;
+    __SWORD_TYPE f_spare[4];
+  };
+#endif
+
+/* Tell code we have these members.  */
+#define _STATFS_F_NAMELEN
+#define _STATFS_F_FRSIZE
+#define _STATFS_F_FLAGS
-- 
2.25.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 04/10] linux: Consolidate fstatfs implementations
  2021-02-08 21:49 [PATCH 00/10] [f]stat[fs,vfs] consolidation Adhemerval Zanella
                   ` (2 preceding siblings ...)
  2021-02-08 21:49 ` [PATCH 03/10] linux: Set LFS statfs as default Adhemerval Zanella
@ 2021-02-08 21:49 ` Adhemerval Zanella
  2021-02-11  0:38   ` Carlos O'Donell
  2021-02-08 21:49 ` [PATCH 05/10] linux: Consolidate statfs implementations Adhemerval Zanella
                   ` (6 subsequent siblings)
  10 siblings, 1 reply; 27+ messages in thread
From: Adhemerval Zanella @ 2021-02-08 21:49 UTC (permalink / raw)
  To: libc-alpha

The __NR_fstatfs64 syscall is supported on all architectures but
aarch64, mips64, riscv64, and x86_64.  And newer ABIs also uses
the new fstatfs64 interface (where the struct size is used as
second argument).

So the default implementation now uses:

  1. __NR_fstatfs64 for non-LFS call and handle overflow directly
     There is no need to handle __NR_fstatfs since all architecture
     that only support is are LFS only.

  2. __NR_fstatfs if defined or __NR_fstatfs64 otherwise for LFS
     call.

Alpha the only outlier, since it is a 64-bit architecture which
provides non-LFS interface and only provides __NR_fstatfs64 on
newer kernels.

Checked on x86_64-linux-gnu.
---
 include/sys/statfs.h                          |  7 +-
 .../{generic/wordsize-32 => alpha}/fstatfs.c  | 13 ++--
 sysdeps/unix/sysv/linux/alpha/fstatfs64.c     | 52 +++++++++++++-
 sysdeps/unix/sysv/linux/alpha/syscalls.list   |  1 -
 sysdeps/unix/sysv/linux/fstatfs.c             | 62 +++++++++++++++++
 sysdeps/unix/sysv/linux/fstatfs64.c           | 67 +++----------------
 .../sysv/linux/mips/mips64/n64/fstatfs64.c    |  1 -
 .../sysv/linux/mips/mips64/n64/syscalls.list  |  1 -
 .../unix/sysv/linux/wordsize-64/fstatfs64.c   |  1 -
 .../unix/sysv/linux/wordsize-64/syscalls.list |  1 -
 10 files changed, 129 insertions(+), 77 deletions(-)
 rename sysdeps/unix/sysv/linux/{generic/wordsize-32 => alpha}/fstatfs.c (76%)
 create mode 100644 sysdeps/unix/sysv/linux/fstatfs.c
 delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n64/fstatfs64.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/fstatfs64.c

diff --git a/include/sys/statfs.h b/include/sys/statfs.h
index 8a9f5a7b3b..756930a247 100644
--- a/include/sys/statfs.h
+++ b/include/sys/statfs.h
@@ -6,12 +6,11 @@
 /* Now define the internal interfaces.  */
 extern int __statfs (const char *__file, struct statfs *__buf);
 libc_hidden_proto (__statfs)
-extern int __fstatfs (int __fildes, struct statfs *__buf)
-     attribute_hidden;
+extern int __fstatfs (int __fildes, struct statfs *__buf);
+libc_hidden_proto (__fstatfs)
 extern int __statfs64 (const char *__file, struct statfs64 *__buf)
      attribute_hidden;
-extern int __fstatfs64 (int __fildes, struct statfs64 *__buf)
-     attribute_hidden;
+extern int __fstatfs64 (int __fildes, struct statfs64 *__buf);
 
 # endif /* !_ISOMAC */
 #endif
diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c b/sysdeps/unix/sysv/linux/alpha/fstatfs.c
similarity index 76%
rename from sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c
rename to sysdeps/unix/sysv/linux/alpha/fstatfs.c
index a611f33128..32c38d0db2 100644
--- a/sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c
+++ b/sysdeps/unix/sysv/linux/alpha/fstatfs.c
@@ -1,6 +1,6 @@
-/* Copyright (C) 2011-2021 Free Software Foundation, Inc.
+/* Get filesystem statistics.  Linux/alpha.
+   Copyright (C) 2011-2021 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
-   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
 
    The GNU C Library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -18,18 +18,13 @@
 
 #include <sys/statfs.h>
 #include <kernel_stat.h>
-#include <stddef.h>
 #include <sysdep.h>
 
-#if !STATFS_IS_STATFS64
-#include "overflow.h"
-
 /* Return information about the filesystem on which FD resides.  */
 int
 __fstatfs (int fd, struct statfs *buf)
 {
-  int rc = INLINE_SYSCALL (fstatfs64, 3, fd, sizeof (*buf), buf);
-  return rc ?: statfs_overflow (buf);
+  return INLINE_SYSCALL_CALL (fstatfs, fd, buf);
 }
+libc_hidden_def (__fstatfs)
 weak_alias (__fstatfs, fstatfs)
-#endif
diff --git a/sysdeps/unix/sysv/linux/alpha/fstatfs64.c b/sysdeps/unix/sysv/linux/alpha/fstatfs64.c
index 5639959adb..0391c08338 100644
--- a/sysdeps/unix/sysv/linux/alpha/fstatfs64.c
+++ b/sysdeps/unix/sysv/linux/alpha/fstatfs64.c
@@ -1 +1,51 @@
-#include <sysdeps/unix/sysv/linux/fstatfs64.c>
+/* Get filesystem statistics.  Linux/alpha.
+   Copyright (C) 1996-2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <sys/statfs.h>
+#include <sysdep.h>
+#include <kernel_stat.h>
+
+/* Return information about the filesystem on which FILE resides.  */
+int
+__fstatfs64 (int fd, struct statfs64 *buf)
+{
+  int r = INLINE_SYSCALL_CALL (fstatfs64, fd, sizeof (*buf), buf);
+#if __ASSUME_STATFS64 == 0
+  if (r == -1 && errno == ENOSYS)
+    {
+      struct statfs buf32;
+      if (__fstatfs (fd, &buf32) < 0)
+	return -1;
+
+      buf->f_type = buf32.f_type;
+      buf->f_bsize = buf32.f_bsize;
+      buf->f_blocks = buf32.f_blocks;
+      buf->f_bfree = buf32.f_bfree;
+      buf->f_bavail = buf32.f_bavail;
+      buf->f_files = buf32.f_files;
+      buf->f_ffree = buf32.f_ffree;
+      buf->f_fsid = buf32.f_fsid;
+      buf->f_namelen = buf32.f_namelen;
+      buf->f_frsize = buf32.f_frsize;
+      buf->f_flags = buf32.f_flags;
+      memcpy (buf->f_spare, buf32.f_spare, sizeof (buf32.f_spare));
+    }
+#endif
+  return r;
+}
+weak_alias (__fstatfs64, fstatfs64)
diff --git a/sysdeps/unix/sysv/linux/alpha/syscalls.list b/sysdeps/unix/sysv/linux/alpha/syscalls.list
index c7cbe886ea..8cb588cb2c 100644
--- a/sysdeps/unix/sysv/linux/alpha/syscalls.list
+++ b/sysdeps/unix/sysv/linux/alpha/syscalls.list
@@ -29,5 +29,4 @@ utimes		-	utimes		i:sp	__utimes	utimes@@GLIBC_2.1
 getrusage	-	getrusage	i:ip	__getrusage	getrusage@@GLIBC_2.1
 
 # avoid 64-bit aliases on 32-bit statfs syscalls
-fstatfs		-	fstatfs		i:ip	__fstatfs	fstatfs
 statfs		-	statfs		i:sp	__statfs	statfs
diff --git a/sysdeps/unix/sysv/linux/fstatfs.c b/sysdeps/unix/sysv/linux/fstatfs.c
new file mode 100644
index 0000000000..38d621967e
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/fstatfs.c
@@ -0,0 +1,62 @@
+/* Get filesystem statistics.  Linux version.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <sys/statfs.h>
+#include <time.h>
+#include <sysdep.h>
+#include <kernel_stat.h>
+
+#if !STATFS_IS_STATFS64
+
+/* Return information about the filesystem on which FILE resides.  */
+int
+__fstatfs (int fd, struct statfs *buf)
+{
+  struct statfs64 buf64;
+  int rc = INLINE_SYSCALL_CALL (fstatfs64, fd, sizeof (buf64), &buf64);
+  if (rc != 0)
+    return rc;
+
+  buf->f_type = buf64.f_type;
+  buf->f_bsize = buf64.f_bsize;
+  buf->f_blocks = buf64.f_blocks;
+  buf->f_bfree = buf64.f_bfree;
+  buf->f_bavail = buf64.f_bavail;
+  buf->f_files = buf64.f_files;
+  buf->f_ffree = buf64.f_ffree;
+  buf->f_fsid = buf64.f_fsid;
+  buf->f_namelen = buf64.f_namelen;
+  buf->f_frsize = buf64.f_frsize;
+  buf->f_flags = buf64.f_flags;
+  memcpy (buf->f_spare, buf64.f_spare, sizeof (buf64.f_spare));
+
+  if ((fsblkcnt_t) buf64.f_blocks != buf64.f_blocks
+      || (fsblkcnt_t) buf64.f_bfree != buf64.f_bfree
+      || (fsblkcnt_t) buf64.f_bavail != buf64.f_bavail
+      || (fsblkcnt_t) buf64.f_files != buf64.f_files
+      || (fsblkcnt_t) buf64.f_ffree != buf64.f_ffree)
+   {
+     __set_errno (EOVERFLOW);
+     return -1;
+   }
+
+  return 0;
+}
+libc_hidden_def (__fstatfs)
+weak_alias (__fstatfs, fstatfs)
+#endif
diff --git a/sysdeps/unix/sysv/linux/fstatfs64.c b/sysdeps/unix/sysv/linux/fstatfs64.c
index b5ff74d66c..e6aa643477 100644
--- a/sysdeps/unix/sysv/linux/fstatfs64.c
+++ b/sysdeps/unix/sysv/linux/fstatfs64.c
@@ -16,77 +16,28 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <string.h>
-#include <stddef.h>
+#define __fstatfs __fstatfs_disable
+#define fstatfs fstatfs_disable
+#include <sys/statfs.h>
 #include <sysdep.h>
 #include <kernel_stat.h>
-
-/* Hide the prototypes for __fstatfs and fstatfs so that GCC will not
-   complain about the different function signatures if they are aliased
-   to  __fstat64.  If STATFS_IS_STATFS64 is not zero then the statfs and
-   statfs64 structures have an identical layout but different type names.  */
-
-#if STATFS_IS_STATFS64
-# define __fstatfs __fstatfs_disable
-# define fstatfs fstatfs_disable
-#endif
-#include <sys/statfs.h>
-
-#include <kernel-features.h>
-
-/* Defined in statfs64.c.  */
-extern int __no_statfs64 attribute_hidden;
+#undef __fstatfs
+#undef fstatfs
 
 /* Return information about the filesystem on which FD resides.  */
 int
 __fstatfs64 (int fd, struct statfs64 *buf)
 {
 #ifdef __NR_fstatfs64
-# if __ASSUME_STATFS64 == 0
-  if (! __no_statfs64)
-# endif
-    {
-      int result = INLINE_SYSCALL (fstatfs64, 3, fd, sizeof (*buf), buf);
-
-# if __ASSUME_STATFS64 == 0
-      if (result == 0 || errno != ENOSYS)
-# endif
-	return result;
-
-# if __ASSUME_STATFS64 == 0
-      __no_statfs64 = 1;
-# endif
-    }
-#endif
-
-#if __ASSUME_STATFS64 == 0
-  struct statfs buf32;
-
-  if (__fstatfs (fd, &buf32) < 0)
-    return -1;
-
-  buf->f_type = buf32.f_type;
-  buf->f_bsize = buf32.f_bsize;
-  buf->f_blocks = buf32.f_blocks;
-  buf->f_bfree = buf32.f_bfree;
-  buf->f_bavail = buf32.f_bavail;
-  buf->f_files = buf32.f_files;
-  buf->f_ffree = buf32.f_ffree;
-  buf->f_fsid = buf32.f_fsid;
-  buf->f_namelen = buf32.f_namelen;
-  buf->f_frsize = buf32.f_frsize;
-  memcpy (buf->f_spare, buf32.f_spare, sizeof (buf32.f_spare));
-
-  return 0;
+  return INLINE_SYSCALL_CALL (fstatfs64, fd, sizeof (*buf), buf);
+#else
+  return INLINE_SYSCALL_CALL (fstatfs, fd, buf);
 #endif
 }
 weak_alias (__fstatfs64, fstatfs64)
 
-#undef __fstatfs
-#undef fstatfs
-
 #if STATFS_IS_STATFS64
 weak_alias (__fstatfs64, __fstatfs)
 weak_alias (__fstatfs64, fstatfs)
+libc_hidden_ver (__fstatfs64, __fstatfs)
 #endif
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/fstatfs64.c b/sysdeps/unix/sysv/linux/mips/mips64/n64/fstatfs64.c
deleted file mode 100644
index 6e25b021ab..0000000000
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/fstatfs64.c
+++ /dev/null
@@ -1 +0,0 @@
-/* Empty.  */
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
index 8e7d516a2a..b6a0c92829 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
@@ -4,7 +4,6 @@ prlimit		EXTRA	prlimit64	i:iipp	prlimit		prlimit64
 
 fanotify_mark	EXTRA	fanotify_mark	i:iiiis	fanotify_mark
 
-fstatfs		-	fstatfs		i:ip	__fstatfs	fstatfs fstatfs64 __fstatfs64
 statfs		-	statfs		i:sp	__statfs	statfs statfs64 __statfs64
 
 sendfile	-	sendfile	i:iipi	sendfile	sendfile64
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/fstatfs64.c b/sysdeps/unix/sysv/linux/wordsize-64/fstatfs64.c
deleted file mode 100644
index 2be4e59ba4..0000000000
--- a/sysdeps/unix/sysv/linux/wordsize-64/fstatfs64.c
+++ /dev/null
@@ -1 +0,0 @@
-/* fstatfs64 is the same as fstatfs. */
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
index 5de6ec823a..5a0c910847 100644
--- a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
@@ -1,6 +1,5 @@
 # File name	Caller	Syscall name	# args	Strong name	Weak names
 
-fstatfs		-	fstatfs		i:ip	__fstatfs	fstatfs fstatfs64 __fstatfs64
 statfs		-	statfs		i:sp	__statfs	statfs statfs64
 sendfile	-	sendfile	i:iipi	sendfile	sendfile64
 prlimit		EXTRA	prlimit64	i:iipp	prlimit		prlimit64
-- 
2.25.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 05/10] linux: Consolidate statfs implementations
  2021-02-08 21:49 [PATCH 00/10] [f]stat[fs,vfs] consolidation Adhemerval Zanella
                   ` (3 preceding siblings ...)
  2021-02-08 21:49 ` [PATCH 04/10] linux: Consolidate fstatfs implementations Adhemerval Zanella
@ 2021-02-08 21:49 ` Adhemerval Zanella
  2021-02-11  0:38   ` Carlos O'Donell
  2021-02-08 21:49 ` [PATCH 06/10] linux: Consolidate fstatvfs implementations Adhemerval Zanella
                   ` (5 subsequent siblings)
  10 siblings, 1 reply; 27+ messages in thread
From: Adhemerval Zanella @ 2021-02-08 21:49 UTC (permalink / raw)
  To: libc-alpha

The __NR_statfs64 syscall is supported on all architectures but
aarch64, mips64, riscv64, and x86_64.  And newer ABIs also uses
the new statfs64 interface (where the struct size is used as
second argument).

So the default implementation now uses:

  1. __NR_statfs64 for non-LFS call and handle overflow directly
     There is no need to handle __NR_statfs since all architecture
     that only support is are LFS only.

  2. __NR_statfs if defined or __NR_statfs64 otherwise for LFS
     call.

Alpha is the only outlier, since it is a 64-bit architecture which
provides non-LFS interface and only provides __NR_fstatfs64 on
newer kernels.

Checked on x86_64-linux-gnu.
---
 .../{generic/wordsize-32 => alpha}/statfs.c   | 16 ++---
 sysdeps/unix/sysv/linux/alpha/statfs64.c      | 52 +++++++++++++-
 sysdeps/unix/sysv/linux/alpha/syscalls.list   |  3 -
 .../sysv/linux/mips/mips64/n64/statfs64.c     |  1 -
 .../sysv/linux/mips/mips64/n64/syscalls.list  |  2 -
 sysdeps/unix/sysv/linux/statfs.c              | 61 ++++++++++++++++
 sysdeps/unix/sysv/linux/statfs64.c            | 69 +++----------------
 .../unix/sysv/linux/wordsize-64/statfs64.c    |  1 -
 .../unix/sysv/linux/wordsize-64/syscalls.list |  1 -
 9 files changed, 125 insertions(+), 81 deletions(-)
 rename sysdeps/unix/sysv/linux/{generic/wordsize-32 => alpha}/statfs.c (72%)
 delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n64/statfs64.c
 create mode 100644 sysdeps/unix/sysv/linux/statfs.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/statfs64.c

diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c b/sysdeps/unix/sysv/linux/alpha/statfs.c
similarity index 72%
rename from sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c
rename to sysdeps/unix/sysv/linux/alpha/statfs.c
index 2c51fbf1b0..33789768ed 100644
--- a/sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c
+++ b/sysdeps/unix/sysv/linux/alpha/statfs.c
@@ -1,6 +1,6 @@
-/* Copyright (C) 2011-2021 Free Software Foundation, Inc.
+/* Return information about the filesystem on which FILE resides.  Linux/alpha.
+   Copyright (C) 1996-2021 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
-   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
 
    The GNU C Library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -13,24 +13,18 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
+   License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
 #include <sys/statfs.h>
-#include <kernel_stat.h>
 #include <sysdep.h>
-
-#if !STATFS_IS_STATFS64
-#include "overflow.h"
+#include <kernel_stat.h>
 
 /* Return information about the filesystem on which FILE resides.  */
 int
 __statfs (const char *file, struct statfs *buf)
 {
-  int rc = INLINE_SYSCALL (statfs64, 3, file, sizeof (*buf), buf);
-  return rc ?: statfs_overflow (buf);
+  return INLINE_SYSCALL_CALL (statfs, file, buf);
 }
 libc_hidden_def (__statfs)
 weak_alias (__statfs, statfs)
-#endif
diff --git a/sysdeps/unix/sysv/linux/alpha/statfs64.c b/sysdeps/unix/sysv/linux/alpha/statfs64.c
index fe39cc4685..083b9a59f3 100644
--- a/sysdeps/unix/sysv/linux/alpha/statfs64.c
+++ b/sysdeps/unix/sysv/linux/alpha/statfs64.c
@@ -1 +1,51 @@
-#include <sysdeps/unix/sysv/linux/statfs64.c>
+/* Return information about the filesystem on which FILE resides.  Linux/alpha.
+   Copyright (C) 1996-2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <sys/statfs.h>
+#include <sysdep.h>
+#include <kernel_stat.h>
+
+/* Return information about the filesystem on which FILE resides.  */
+int
+__statfs64 (const char *file, struct statfs64 *buf)
+{
+  int r = INLINE_SYSCALL_CALL (statfs64, file, sizeof (*buf), buf);
+#if __ASSUME_STATFS64 == 0
+  if (r == -1 && errno == ENOSYS)
+    {
+      struct statfs buf32;
+      if (__statfs (file, &buf32) < 0)
+	return -1;
+
+      buf->f_type = buf32.f_type;
+      buf->f_bsize = buf32.f_bsize;
+      buf->f_blocks = buf32.f_blocks;
+      buf->f_bfree = buf32.f_bfree;
+      buf->f_bavail = buf32.f_bavail;
+      buf->f_files = buf32.f_files;
+      buf->f_ffree = buf32.f_ffree;
+      buf->f_fsid = buf32.f_fsid;
+      buf->f_namelen = buf32.f_namelen;
+      buf->f_frsize = buf32.f_frsize;
+      buf->f_flags = buf32.f_flags;
+      memcpy (buf->f_spare, buf32.f_spare, sizeof (buf32.f_spare));
+    }
+#endif
+  return r;
+}
+weak_alias (__statfs64, statfs64)
diff --git a/sysdeps/unix/sysv/linux/alpha/syscalls.list b/sysdeps/unix/sysv/linux/alpha/syscalls.list
index 8cb588cb2c..c848fcbd99 100644
--- a/sysdeps/unix/sysv/linux/alpha/syscalls.list
+++ b/sysdeps/unix/sysv/linux/alpha/syscalls.list
@@ -27,6 +27,3 @@ getitimer	-	getitimer	i:ip	__getitimer	getitimer@@GLIBC_2.1
 setitimer	-	setitimer	i:ipP	__setitimer	setitimer@@GLIBC_2.1
 utimes		-	utimes		i:sp	__utimes	utimes@@GLIBC_2.1
 getrusage	-	getrusage	i:ip	__getrusage	getrusage@@GLIBC_2.1
-
-# avoid 64-bit aliases on 32-bit statfs syscalls
-statfs		-	statfs		i:sp	__statfs	statfs
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/statfs64.c b/sysdeps/unix/sysv/linux/mips/mips64/n64/statfs64.c
deleted file mode 100644
index 6e25b021ab..0000000000
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/statfs64.c
+++ /dev/null
@@ -1 +0,0 @@
-/* Empty.  */
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
index b6a0c92829..e4e16dfa49 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
@@ -4,6 +4,4 @@ prlimit		EXTRA	prlimit64	i:iipp	prlimit		prlimit64
 
 fanotify_mark	EXTRA	fanotify_mark	i:iiiis	fanotify_mark
 
-statfs		-	statfs		i:sp	__statfs	statfs statfs64 __statfs64
-
 sendfile	-	sendfile	i:iipi	sendfile	sendfile64
diff --git a/sysdeps/unix/sysv/linux/statfs.c b/sysdeps/unix/sysv/linux/statfs.c
new file mode 100644
index 0000000000..ee248b4212
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/statfs.c
@@ -0,0 +1,61 @@
+/* Copyright (C) 2011-2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <sys/statfs.h>
+#include <time.h>
+#include <sysdep.h>
+#include <kernel_stat.h>
+
+#if !STATFS_IS_STATFS64
+
+/* Return information about the filesystem on which FILE resides.  */
+int
+__statfs (const char *file, struct statfs *buf)
+{
+  struct statfs64 buf64;
+  int rc = INLINE_SYSCALL_CALL (statfs64, file, sizeof (buf64), &buf64);
+  if (rc == 0)
+    {
+      buf->f_type = buf64.f_type;
+      buf->f_bsize = buf64.f_bsize;
+      buf->f_blocks = buf64.f_blocks;
+      buf->f_bfree = buf64.f_bfree;
+      buf->f_bavail = buf64.f_bavail;
+      buf->f_files = buf64.f_files;
+      buf->f_ffree = buf64.f_ffree;
+      buf->f_fsid = buf64.f_fsid;
+      buf->f_namelen = buf64.f_namelen;
+      buf->f_frsize = buf64.f_frsize;
+      buf->f_flags = buf64.f_flags;
+      memcpy (buf->f_spare, buf64.f_spare, sizeof (buf64.f_spare));
+
+      if ((fsblkcnt_t) buf64.f_blocks != buf64.f_blocks
+	  || (fsblkcnt_t) buf64.f_bfree != buf64.f_bfree
+	  || (fsblkcnt_t) buf64.f_bavail != buf64.f_bavail
+	  || (fsblkcnt_t) buf64.f_files != buf64.f_files
+	  || (fsblkcnt_t) buf64.f_ffree != buf64.f_ffree)
+	{
+	  __set_errno (EOVERFLOW);
+	  return -1;
+	}
+    }
+  return rc;
+}
+libc_hidden_def (__statfs)
+weak_alias (__statfs, statfs)
+#endif
diff --git a/sysdeps/unix/sysv/linux/statfs64.c b/sysdeps/unix/sysv/linux/statfs64.c
index c52b3d8ae6..4f68212e9f 100644
--- a/sysdeps/unix/sysv/linux/statfs64.c
+++ b/sysdeps/unix/sysv/linux/statfs64.c
@@ -16,79 +16,26 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <string.h>
-#include <stddef.h>
+#define __statfs __statfs_disable
+#define statfs statfs_disable
+#include <sys/statfs.h>
 #include <sysdep.h>
 #include <kernel_stat.h>
-
-/* Hide the prototypes for __statfs and statfs so that GCC will not
-   complain about the different function signatures if they are aliased
-   to  __stat64.  If STATFS_IS_STATFS64 is not zero then the statfs and
-   statfs64 structures have an identical layout but different type names.  */
-
-#if STATFS_IS_STATFS64
-# define __statfs __statfs_disable
-# define statfs statfs_disable
-#endif
-#include <sys/statfs.h>
-
-#include <kernel-features.h>
-
-
-# if __ASSUME_STATFS64 == 0
-int __no_statfs64 attribute_hidden;
-#endif
+#undef __statfs
+#undef statfs
 
 /* Return information about the filesystem on which FILE resides.  */
 int
 __statfs64 (const char *file, struct statfs64 *buf)
 {
 #ifdef __NR_statfs64
-# if __ASSUME_STATFS64 == 0
-  if (! __no_statfs64)
-# endif
-    {
-      int result = INLINE_SYSCALL (statfs64, 3, file, sizeof (*buf), buf);
-
-# if __ASSUME_STATFS64 == 0
-      if (result == 0 || errno != ENOSYS)
-# endif
-	return result;
-
-# if __ASSUME_STATFS64 == 0
-      __no_statfs64 = 1;
-# endif
-    }
-#endif
-
-#if __ASSUME_STATFS64 == 0
-  struct statfs buf32;
-
-  if (__statfs (file, &buf32) < 0)
-    return -1;
-
-  buf->f_type = buf32.f_type;
-  buf->f_bsize = buf32.f_bsize;
-  buf->f_blocks = buf32.f_blocks;
-  buf->f_bfree = buf32.f_bfree;
-  buf->f_bavail = buf32.f_bavail;
-  buf->f_files = buf32.f_files;
-  buf->f_ffree = buf32.f_ffree;
-  buf->f_fsid = buf32.f_fsid;
-  buf->f_namelen = buf32.f_namelen;
-  buf->f_frsize = buf32.f_frsize;
-  buf->f_flags = buf32.f_flags;
-  memcpy (buf->f_spare, buf32.f_spare, sizeof (buf32.f_spare));
-
-  return 0;
+  return INLINE_SYSCALL_CALL (statfs64, file, sizeof (*buf), buf);
+#else
+  return INLINE_SYSCALL_CALL (statfs, file, buf);
 #endif
 }
 weak_alias (__statfs64, statfs64)
 
-#undef __statfs
-#undef statfs
-
 #if STATFS_IS_STATFS64
 weak_alias (__statfs64, __statfs)
 weak_alias (__statfs64, statfs)
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/statfs64.c b/sysdeps/unix/sysv/linux/wordsize-64/statfs64.c
deleted file mode 100644
index 06bc68826f..0000000000
--- a/sysdeps/unix/sysv/linux/wordsize-64/statfs64.c
+++ /dev/null
@@ -1 +0,0 @@
-/* statfs64 is the same as statfs. */
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
index 5a0c910847..68e3c60536 100644
--- a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
@@ -1,6 +1,5 @@
 # File name	Caller	Syscall name	# args	Strong name	Weak names
 
-statfs		-	statfs		i:sp	__statfs	statfs statfs64
 sendfile	-	sendfile	i:iipi	sendfile	sendfile64
 prlimit		EXTRA	prlimit64	i:iipp	prlimit		prlimit64
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 06/10] linux: Consolidate fstatvfs implementations
  2021-02-08 21:49 [PATCH 00/10] [f]stat[fs,vfs] consolidation Adhemerval Zanella
                   ` (4 preceding siblings ...)
  2021-02-08 21:49 ` [PATCH 05/10] linux: Consolidate statfs implementations Adhemerval Zanella
@ 2021-02-08 21:49 ` Adhemerval Zanella
  2021-02-11  0:38   ` Carlos O'Donell
  2021-02-08 21:49 ` [PATCH 07/10] linux: Consolidate statvfs implementations Adhemerval Zanella
                   ` (4 subsequent siblings)
  10 siblings, 1 reply; 27+ messages in thread
From: Adhemerval Zanella @ 2021-02-08 21:49 UTC (permalink / raw)
  To: libc-alpha

There is no need to handle ENOSYS on fstatfs64 call, required only
for alpha (where is already fallbacks to fstatfs).  The wordsize
internal_statvfs64.c is removed, since how the LFS support is
provided by fstatvfs64.c (used on 64-bit architectures as well).

Checked on x86_64-linux-gnu.
---
 sysdeps/unix/sysv/linux/alpha/fstatvfs.c      |  1 -
 sysdeps/unix/sysv/linux/alpha/fstatvfs64.c    |  1 -
 sysdeps/unix/sysv/linux/fstatvfs.c            |  9 ++--
 sysdeps/unix/sysv/linux/fstatvfs64.c          | 53 +++++++------------
 .../unix/sysv/linux/wordsize-64/fstatvfs.c    |  5 --
 .../unix/sysv/linux/wordsize-64/fstatvfs64.c  |  1 -
 .../linux/wordsize-64/internal_statvfs64.c    |  1 -
 7 files changed, 25 insertions(+), 46 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/alpha/fstatvfs.c
 delete mode 100644 sysdeps/unix/sysv/linux/alpha/fstatvfs64.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/fstatvfs.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/fstatvfs64.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/internal_statvfs64.c

diff --git a/sysdeps/unix/sysv/linux/alpha/fstatvfs.c b/sysdeps/unix/sysv/linux/alpha/fstatvfs.c
deleted file mode 100644
index 92e772347b..0000000000
--- a/sysdeps/unix/sysv/linux/alpha/fstatvfs.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/fstatvfs.c>
diff --git a/sysdeps/unix/sysv/linux/alpha/fstatvfs64.c b/sysdeps/unix/sysv/linux/alpha/fstatvfs64.c
deleted file mode 100644
index 0f1e71027a..0000000000
--- a/sysdeps/unix/sysv/linux/alpha/fstatvfs64.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/fstatvfs64.c>
diff --git a/sysdeps/unix/sysv/linux/fstatvfs.c b/sysdeps/unix/sysv/linux/fstatvfs.c
index 8b67951ab6..0f56a13ca9 100644
--- a/sysdeps/unix/sysv/linux/fstatvfs.c
+++ b/sysdeps/unix/sysv/linux/fstatvfs.c
@@ -16,11 +16,13 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <stddef.h>
-#include <sys/stat.h>
+#include <sys/statvfs.h>
 #include <sys/statfs.h>
-#include "internal_statvfs.h"
+#include <internal_statvfs.h>
+#include <time.h>
+#include <kernel_stat.h>
 
+#if !STATFS_IS_STATFS64
 int
 __fstatvfs (int fd, struct statvfs *buf)
 {
@@ -38,3 +40,4 @@ __fstatvfs (int fd, struct statvfs *buf)
 }
 weak_alias (__fstatvfs, fstatvfs)
 libc_hidden_weak (fstatvfs)
+#endif
diff --git a/sysdeps/unix/sysv/linux/fstatvfs64.c b/sysdeps/unix/sysv/linux/fstatvfs64.c
index 6d2dbc5285..b95745e8b8 100644
--- a/sysdeps/unix/sysv/linux/fstatvfs64.c
+++ b/sysdeps/unix/sysv/linux/fstatvfs64.c
@@ -16,48 +16,33 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <string.h>
-#include <sys/stat.h>
+#define __fstatvfs __fstatvfs_disable
+#define fstatvfs fstatvfs_disable
+#include <sys/statvfs.h>
 #include <sys/statfs.h>
-#include "internal_statvfs.h"
-#include <kernel-features.h>
+#include <internal_statvfs.h>
+#include <time.h>
+#include <kernel_stat.h>
 
 /* Return information about the filesystem on which FD resides.  */
 int
 __fstatvfs64 (int fd, struct statvfs64 *buf)
 {
   struct statfs64 fsbuf;
-  int res = __fstatfs64 (fd, &fsbuf);
-
-#ifndef __ASSUME_STATFS64
-  if (res < 0 && errno == ENOSYS)
-    {
-      struct statvfs buf32;
-
-      res = fstatvfs (fd, &buf32);
-      if (res == 0)
-	{
-	  buf->f_bsize = buf32.f_bsize;
-	  buf->f_frsize = buf32.f_frsize;
-	  buf->f_blocks = buf32.f_blocks;
-	  buf->f_bfree = buf32.f_bfree;
-	  buf->f_bavail = buf32.f_bavail;
-	  buf->f_files = buf32.f_files;
-	  buf->f_ffree = buf32.f_ffree;
-	  buf->f_favail = buf32.f_favail;
-	  buf->f_fsid = buf32.f_fsid;
-	  buf->f_flag = buf32.f_flag;
-	  buf->f_namemax = buf32.f_namemax;
-	  memcpy (buf->__f_spare, buf32.__f_spare, sizeof (buf32.__f_spare));
-	}
-    }
-#endif
+  if (__fstatfs64 (fd, &fsbuf) < 0)
+    return -1;
 
-  if (res == 0)
-    /* Convert the result.  */
-    __internal_statvfs64 (NULL, buf, &fsbuf, fd);
+  /* Convert the result.  */
+  __internal_statvfs64 (NULL, buf, &fsbuf, fd);
 
-  return res;
+  return 0;
 }
 weak_alias (__fstatvfs64, fstatvfs64)
+
+#undef __fstatvfs
+#undef fstatvfs
+
+#if STATFS_IS_STATFS64
+weak_alias (__fstatvfs64, __fstatvfs)
+weak_alias (__fstatvfs64, fstatvfs)
+#endif
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/fstatvfs.c b/sysdeps/unix/sysv/linux/wordsize-64/fstatvfs.c
deleted file mode 100644
index 5803b6f882..0000000000
--- a/sysdeps/unix/sysv/linux/wordsize-64/fstatvfs.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#define __fstatvfs64(file, buf) __no_fstatvfs64(file, buf)
-#define fstatvfs64(file, buf) no_fstatvfs64(file, buf)
-#include "../fstatvfs.c"
-strong_alias (__fstatvfs, __fstatvfs64)
-weak_alias (__fstatvfs, fstatvfs64)
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/fstatvfs64.c b/sysdeps/unix/sysv/linux/wordsize-64/fstatvfs64.c
deleted file mode 100644
index 60f3dfec61..0000000000
--- a/sysdeps/unix/sysv/linux/wordsize-64/fstatvfs64.c
+++ /dev/null
@@ -1 +0,0 @@
-/* fstatvfs64 is the same as fstatvfs. */
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/internal_statvfs64.c b/sysdeps/unix/sysv/linux/wordsize-64/internal_statvfs64.c
deleted file mode 100644
index d2a3509c6d..0000000000
--- a/sysdeps/unix/sysv/linux/wordsize-64/internal_statvfs64.c
+++ /dev/null
@@ -1 +0,0 @@
-/* Nothing.  */
-- 
2.25.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 07/10] linux: Consolidate statvfs implementations
  2021-02-08 21:49 [PATCH 00/10] [f]stat[fs,vfs] consolidation Adhemerval Zanella
                   ` (5 preceding siblings ...)
  2021-02-08 21:49 ` [PATCH 06/10] linux: Consolidate fstatvfs implementations Adhemerval Zanella
@ 2021-02-08 21:49 ` Adhemerval Zanella
  2021-02-11  0:38   ` Carlos O'Donell
  2021-02-08 21:49 ` [PATCH 08/10] linux: Consolidate internal_statvfs Adhemerval Zanella
                   ` (3 subsequent siblings)
  10 siblings, 1 reply; 27+ messages in thread
From: Adhemerval Zanella @ 2021-02-08 21:49 UTC (permalink / raw)
  To: libc-alpha

There is no need to handle ENOSYS on fstatfs64 call, required only
for alpha (where is already fallbacks to fstatfs).

Checked on x86_64-linux-gnu.
---
 include/sys/statvfs.h                         |  3 +-
 sysdeps/unix/sysv/linux/alpha/statvfs.c       |  1 -
 sysdeps/unix/sysv/linux/alpha/statvfs64.c     |  1 -
 sysdeps/unix/sysv/linux/statvfs.c             |  9 ++--
 sysdeps/unix/sysv/linux/statvfs64.c           | 54 +++++++------------
 sysdeps/unix/sysv/linux/wordsize-64/statvfs.c |  5 --
 .../unix/sysv/linux/wordsize-64/statvfs64.c   |  1 -
 7 files changed, 26 insertions(+), 48 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/alpha/statvfs.c
 delete mode 100644 sysdeps/unix/sysv/linux/alpha/statvfs64.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/statvfs.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/statvfs64.c

diff --git a/include/sys/statvfs.h b/include/sys/statvfs.h
index 4cd1977c35..d7fe33119a 100644
--- a/include/sys/statvfs.h
+++ b/include/sys/statvfs.h
@@ -3,8 +3,7 @@
 
 #ifndef _ISOMAC
 /* Now define the internal interfaces.  */
-extern int __statvfs64 (const char *__file, struct statvfs64 *__buf)
-     attribute_hidden;
+extern int __statvfs64 (const char *__file, struct statvfs64 *__buf);
 extern int __fstatvfs64 (int __fildes, struct statvfs64 *__buf)
      attribute_hidden;
 
diff --git a/sysdeps/unix/sysv/linux/alpha/statvfs.c b/sysdeps/unix/sysv/linux/alpha/statvfs.c
deleted file mode 100644
index 78069e96f4..0000000000
--- a/sysdeps/unix/sysv/linux/alpha/statvfs.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/statvfs.c>
diff --git a/sysdeps/unix/sysv/linux/alpha/statvfs64.c b/sysdeps/unix/sysv/linux/alpha/statvfs64.c
deleted file mode 100644
index c80e17751d..0000000000
--- a/sysdeps/unix/sysv/linux/alpha/statvfs64.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/statvfs64.c>
diff --git a/sysdeps/unix/sysv/linux/statvfs.c b/sysdeps/unix/sysv/linux/statvfs.c
index 8895694e5d..f165899711 100644
--- a/sysdeps/unix/sysv/linux/statvfs.c
+++ b/sysdeps/unix/sysv/linux/statvfs.c
@@ -16,11 +16,13 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <stddef.h>
-#include <sys/stat.h>
+#include <sys/statvfs.h>
 #include <sys/statfs.h>
-#include "internal_statvfs.h"
+#include <internal_statvfs.h>
+#include <time.h>
+#include <kernel_stat.h>
 
+#if !STATFS_IS_STATFS64
 int
 __statvfs (const char *file, struct statvfs *buf)
 {
@@ -38,3 +40,4 @@ __statvfs (const char *file, struct statvfs *buf)
 }
 weak_alias (__statvfs, statvfs)
 libc_hidden_weak (statvfs)
+#endif
diff --git a/sysdeps/unix/sysv/linux/statvfs64.c b/sysdeps/unix/sysv/linux/statvfs64.c
index b03a88816c..3d29908afa 100644
--- a/sysdeps/unix/sysv/linux/statvfs64.c
+++ b/sysdeps/unix/sysv/linux/statvfs64.c
@@ -16,49 +16,33 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <stddef.h>
-#include <string.h>
-#include <sys/stat.h>
+#define __statvfs __statvfs_disable
+#define statvfs statvfs_disable
+#include <sys/statvfs.h>
 #include <sys/statfs.h>
-#include "internal_statvfs.h"
-#include <kernel-features.h>
+#include <internal_statvfs.h>
+#include <time.h>
+#include <kernel_stat.h>
 
 /* Return information about the filesystem on which FILE resides.  */
 int
 __statvfs64 (const char *file, struct statvfs64 *buf)
 {
   struct statfs64 fsbuf;
-  int res = __statfs64 (file, &fsbuf);
+  if (__statfs64 (file, &fsbuf) < 0)
+    return -1;
 
-#ifndef __ASSUME_STATFS64
-  if (res < 0 && errno == ENOSYS)
-    {
-      struct statvfs buf32;
+  /* Convert the result.  */
+  __internal_statvfs64 (file, buf, &fsbuf, -1);
 
-      res = statvfs (file, &buf32);
-      if (res == 0)
-	{
-	  buf->f_bsize = buf32.f_bsize;
-	  buf->f_frsize = buf32.f_frsize;
-	  buf->f_blocks = buf32.f_blocks;
-	  buf->f_bfree = buf32.f_bfree;
-	  buf->f_bavail = buf32.f_bavail;
-	  buf->f_files = buf32.f_files;
-	  buf->f_ffree = buf32.f_ffree;
-	  buf->f_favail = buf32.f_favail;
-	  buf->f_fsid = buf32.f_fsid;
-	  buf->f_flag = buf32.f_flag;
-	  buf->f_namemax = buf32.f_namemax;
-	  memcpy (buf->__f_spare, buf32.__f_spare, sizeof (buf32.__f_spare));
-	}
-    }
-#endif
-
-  if (res == 0)
-    /* Convert the result.  */
-    __internal_statvfs64 (file, buf, &fsbuf, -1);
-
-  return res;
+  return 0;
 }
 weak_alias (__statvfs64, statvfs64)
+
+#undef __statvfs
+#undef statvfs
+
+#if STATFS_IS_STATFS64
+weak_alias (__statvfs64, __statvfs)
+weak_alias (__statvfs64, statvfs)
+#endif
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/statvfs.c b/sysdeps/unix/sysv/linux/wordsize-64/statvfs.c
deleted file mode 100644
index 1e1c96333b..0000000000
--- a/sysdeps/unix/sysv/linux/wordsize-64/statvfs.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#define __statvfs64(file, buf) __no_statvfs64(file, buf)
-#define statvfs64(file, buf) no_statvfs64(file, buf)
-#include "../statvfs.c"
-strong_alias (__statvfs, __statvfs64)
-weak_alias (__statvfs, statvfs64)
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/statvfs64.c b/sysdeps/unix/sysv/linux/wordsize-64/statvfs64.c
deleted file mode 100644
index 510015e420..0000000000
--- a/sysdeps/unix/sysv/linux/wordsize-64/statvfs64.c
+++ /dev/null
@@ -1 +0,0 @@
-/* statvfs64 is the same as statvfs. */
-- 
2.25.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 08/10] linux: Consolidate internal_statvfs
  2021-02-08 21:49 [PATCH 00/10] [f]stat[fs,vfs] consolidation Adhemerval Zanella
                   ` (6 preceding siblings ...)
  2021-02-08 21:49 ` [PATCH 07/10] linux: Consolidate statvfs implementations Adhemerval Zanella
@ 2021-02-08 21:49 ` Adhemerval Zanella
  2021-02-11  0:38   ` Carlos O'Donell
  2021-02-08 21:49 ` [PATCH 09/10] linux: Remove overflow.h Adhemerval Zanella
                   ` (2 subsequent siblings)
  10 siblings, 1 reply; 27+ messages in thread
From: Adhemerval Zanella @ 2021-02-08 21:49 UTC (permalink / raw)
  To: libc-alpha

Remove the internal_statvfs64.c and open code the implementation
on internal_statvfs.c.  The alpha is now unrequired, the generic
implementation also handles it.

Also, removed unused includes on internal_statvfs.c, and remove
unused arguments on __internal_statvfs{64}.
---
 sysdeps/unix/sysv/linux/Makefile              |  2 +-
 .../sysv/linux/alpha/internal_statvfs64.c     |  1 -
 sysdeps/unix/sysv/linux/fstatvfs.c            |  2 +-
 sysdeps/unix/sysv/linux/fstatvfs64.c          |  2 +-
 sysdeps/unix/sysv/linux/internal_statvfs.c    | 70 +++++++++++++------
 sysdeps/unix/sysv/linux/internal_statvfs.h    |  8 +--
 sysdeps/unix/sysv/linux/internal_statvfs64.c  |  4 --
 sysdeps/unix/sysv/linux/statvfs.c             |  2 +-
 sysdeps/unix/sysv/linux/statvfs64.c           |  2 +-
 9 files changed, 56 insertions(+), 37 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/alpha/internal_statvfs64.c
 delete mode 100644 sysdeps/unix/sysv/linux/internal_statvfs64.c

diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index a0a6dcef17..488114a41e 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -273,7 +273,7 @@ CFLAGS-ypclnt.c = -DUSE_BINDINGDIR=1
 endif
 
 ifeq ($(subdir),io)
-sysdep_routines += xstatconv internal_statvfs internal_statvfs64 \
+sysdep_routines += xstatconv internal_statvfs \
 		   sync_file_range fallocate fallocate64 \
 		   close_nocancel fcntl_nocancel \
 		   open_nocancel open64_nocancel \
diff --git a/sysdeps/unix/sysv/linux/alpha/internal_statvfs64.c b/sysdeps/unix/sysv/linux/alpha/internal_statvfs64.c
deleted file mode 100644
index 81d18f7bb2..0000000000
--- a/sysdeps/unix/sysv/linux/alpha/internal_statvfs64.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/internal_statvfs64.c>
diff --git a/sysdeps/unix/sysv/linux/fstatvfs.c b/sysdeps/unix/sysv/linux/fstatvfs.c
index 0f56a13ca9..ba3fd22cfb 100644
--- a/sysdeps/unix/sysv/linux/fstatvfs.c
+++ b/sysdeps/unix/sysv/linux/fstatvfs.c
@@ -33,7 +33,7 @@ __fstatvfs (int fd, struct statvfs *buf)
     return -1;
 
   /* Convert the result.  */
-  __internal_statvfs (NULL, buf, &fsbuf, fd);
+  __internal_statvfs (buf, &fsbuf);
 
   /* We signal success if the statfs call succeeded.  */
   return 0;
diff --git a/sysdeps/unix/sysv/linux/fstatvfs64.c b/sysdeps/unix/sysv/linux/fstatvfs64.c
index b95745e8b8..ba869f594c 100644
--- a/sysdeps/unix/sysv/linux/fstatvfs64.c
+++ b/sysdeps/unix/sysv/linux/fstatvfs64.c
@@ -33,7 +33,7 @@ __fstatvfs64 (int fd, struct statvfs64 *buf)
     return -1;
 
   /* Convert the result.  */
-  __internal_statvfs64 (NULL, buf, &fsbuf, fd);
+  __internal_statvfs64 (buf, &fsbuf);
 
   return 0;
 }
diff --git a/sysdeps/unix/sysv/linux/internal_statvfs.c b/sysdeps/unix/sysv/linux/internal_statvfs.c
index 4d9064141c..39fcb5d429 100644
--- a/sysdeps/unix/sysv/linux/internal_statvfs.c
+++ b/sysdeps/unix/sysv/linux/internal_statvfs.c
@@ -16,37 +16,61 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <assert.h>
-#include <errno.h>
-#include <mntent.h>
-#include <paths.h>
-#include <stdbool.h>
-#include <stdio_ext.h>
-#include <string.h>
-#include <sys/mount.h>
-#include <sys/stat.h>
 #include <sys/statfs.h>
-#include "internal_statvfs.h"
-#include "linux_fsinfo.h"
-#include <kernel-features.h>
-
+#include <sys/statvfs.h>
+#include <internal_statvfs.h>
+#include <string.h>
+#include <time.h>
+#include <kernel_stat.h>
 
 /* Special internal-only bit value.  */
-#define ST_VALID 0x0020
+# define ST_VALID 0x0020
 
-
-#ifndef STATFS
-# define STATFS statfs
-# define STATVFS statvfs
-# define INTERNAL_STATVFS __internal_statvfs
-#else
-extern int __statvfs_getflags (const char *name, int fstype, int fd);
+#if !STATFS_IS_STATFS64
+void
+__internal_statvfs (struct statvfs *buf, const struct statfs *fsbuf)
+{
+  /* Now fill in the fields we have information for.  */
+  buf->f_bsize = fsbuf->f_bsize;
+  /* Linux has the f_frsize size only in later version of the kernel.
+     If the value is not filled in use f_bsize.  */
+  buf->f_frsize = fsbuf->f_frsize ?: fsbuf->f_bsize;
+  buf->f_blocks = fsbuf->f_blocks;
+  buf->f_bfree = fsbuf->f_bfree;
+  buf->f_bavail = fsbuf->f_bavail;
+  buf->f_files = fsbuf->f_files;
+  buf->f_ffree = fsbuf->f_ffree;
+  if (sizeof (buf->f_fsid) == sizeof (fsbuf->f_fsid))
+    /* The shifting uses 'unsigned long long int' even though the target
+       field might only have 32 bits.  This is OK since the 'if' branch
+       is not used in this case but the compiler would still generate
+       warnings.  */
+    buf->f_fsid = ((fsbuf->f_fsid.__val[0]
+		    & ((1ULL << (8 * sizeof (fsbuf->f_fsid.__val[0]))) - 1))
+		   | ((unsigned long long int) fsbuf->f_fsid.__val[1]
+		      << (8 * (sizeof (buf->f_fsid)
+			       - sizeof (fsbuf->f_fsid.__val[0])))));
+  else
+    /* We cannot help here.  The statvfs element is not large enough to
+       contain both words of the statfs f_fsid field.  */
+    buf->f_fsid = fsbuf->f_fsid.__val[0];
+#ifdef _STATVFSBUF_F_UNUSED
+  buf->__f_unused = 0;
 #endif
+  buf->f_namemax = fsbuf->f_namelen;
+  memset (buf->__f_spare, '\0', sizeof (buf->__f_spare));
+
+  /* What remains to do is to fill the fields f_favail and f_flag.  */
+
+  /* XXX I have no idea how to compute f_favail.  Any idea???  */
+  buf->f_favail = buf->f_ffree;
 
+  buf->f_flag = fsbuf->f_flags ^ ST_VALID;
+}
+#endif
 
 void
-INTERNAL_STATVFS (const char *name, struct STATVFS *buf,
-		  struct STATFS *fsbuf, int fd)
+__internal_statvfs64 (struct statvfs64 *buf, const struct statfs64 *fsbuf)
 {
   /* Now fill in the fields we have information for.  */
   buf->f_bsize = fsbuf->f_bsize;
diff --git a/sysdeps/unix/sysv/linux/internal_statvfs.h b/sysdeps/unix/sysv/linux/internal_statvfs.h
index 9ac675c2e8..a8e9aec2c8 100644
--- a/sysdeps/unix/sysv/linux/internal_statvfs.h
+++ b/sysdeps/unix/sysv/linux/internal_statvfs.h
@@ -18,9 +18,9 @@
 
 #include <sys/statvfs.h>
 
-extern void __internal_statvfs (const char *name, struct statvfs *buf,
-				struct statfs *fsbuf, int fd)
+extern void __internal_statvfs (struct statvfs *buf,
+				const struct statfs *fsbuf)
       attribute_hidden;
-extern void __internal_statvfs64 (const char *name, struct statvfs64 *buf,
-				  struct statfs64 *fsbuf, int fd)
+extern void __internal_statvfs64 (struct statvfs64 *buf,
+				  const struct statfs64 *fsbuf)
       attribute_hidden;
diff --git a/sysdeps/unix/sysv/linux/internal_statvfs64.c b/sysdeps/unix/sysv/linux/internal_statvfs64.c
deleted file mode 100644
index 49e7689f8b..0000000000
--- a/sysdeps/unix/sysv/linux/internal_statvfs64.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#define STATFS statfs64
-#define STATVFS statvfs64
-#define INTERNAL_STATVFS __internal_statvfs64
-#include "internal_statvfs.c"
diff --git a/sysdeps/unix/sysv/linux/statvfs.c b/sysdeps/unix/sysv/linux/statvfs.c
index f165899711..210242b9a0 100644
--- a/sysdeps/unix/sysv/linux/statvfs.c
+++ b/sysdeps/unix/sysv/linux/statvfs.c
@@ -33,7 +33,7 @@ __statvfs (const char *file, struct statvfs *buf)
     return -1;
 
   /* Convert the result.  */
-  __internal_statvfs (file, buf, &fsbuf, -1);
+  __internal_statvfs (buf, &fsbuf);
 
   /* We signal success if the statfs call succeeded.  */
   return 0;
diff --git a/sysdeps/unix/sysv/linux/statvfs64.c b/sysdeps/unix/sysv/linux/statvfs64.c
index 3d29908afa..3f03b7edb8 100644
--- a/sysdeps/unix/sysv/linux/statvfs64.c
+++ b/sysdeps/unix/sysv/linux/statvfs64.c
@@ -33,7 +33,7 @@ __statvfs64 (const char *file, struct statvfs64 *buf)
     return -1;
 
   /* Convert the result.  */
-  __internal_statvfs64 (file, buf, &fsbuf, -1);
+  __internal_statvfs64 (buf, &fsbuf);
 
   return 0;
 }
-- 
2.25.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 09/10] linux: Remove overflow.h
  2021-02-08 21:49 [PATCH 00/10] [f]stat[fs,vfs] consolidation Adhemerval Zanella
                   ` (7 preceding siblings ...)
  2021-02-08 21:49 ` [PATCH 08/10] linux: Consolidate internal_statvfs Adhemerval Zanella
@ 2021-02-08 21:49 ` Adhemerval Zanella
  2021-02-11  0:38   ` Carlos O'Donell
  2021-02-08 21:49 ` [PATCH 10/10] linux: Remove stat-check.c Adhemerval Zanella
  2021-02-11  0:37 ` [PATCH 00/10] [f]stat[fs,vfs] consolidation Carlos O'Donell
  10 siblings, 1 reply; 27+ messages in thread
From: Adhemerval Zanella @ 2021-02-08 21:49 UTC (permalink / raw)
  To: libc-alpha

The header is not used anywhere, the required functions are provided
by other implementations.
---
 .../sysv/linux/generic/wordsize-32/overflow.h | 69 -------------------
 1 file changed, 69 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h

diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h b/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h
deleted file mode 100644
index f2a58d654f..0000000000
--- a/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* Overflow tests for stat, statfs, and lseek functions.
-   Copyright (C) 2011-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <sys/stat.h>
-#include <sys/statfs.h>
-#include <sys/types.h>
-
-/* Test for overflows of structures where we ask the kernel to fill them
-   in with standard 64-bit syscalls but return them through APIs that
-   only expose the low 32 bits of some fields.  */
-
-static inline off_t lseek_overflow (loff_t res)
-{
-  off_t retval = (off_t) res;
-  if (retval == res)
-    return retval;
-
-  __set_errno (EOVERFLOW);
-  return (off_t) -1;
-}
-
-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.  */
-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
-	  || (buf->f_files == -1U && buf->__f_files_pad == -1))
-      && (buf->__f_ffree_pad == 0
-	  || (buf->f_ffree == -1U && buf->__f_ffree_pad == -1)))
-    return 0;
-
-  __set_errno (EOVERFLOW);
-  return -1;
-#endif
-}
-- 
2.25.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 10/10] linux: Remove stat-check.c
  2021-02-08 21:49 [PATCH 00/10] [f]stat[fs,vfs] consolidation Adhemerval Zanella
                   ` (8 preceding siblings ...)
  2021-02-08 21:49 ` [PATCH 09/10] linux: Remove overflow.h Adhemerval Zanella
@ 2021-02-08 21:49 ` Adhemerval Zanella
  2021-02-11  0:38   ` Carlos O'Donell
  2021-02-11  0:37 ` [PATCH 00/10] [f]stat[fs,vfs] consolidation Carlos O'Donell
  10 siblings, 1 reply; 27+ messages in thread
From: Adhemerval Zanella @ 2021-02-08 21:49 UTC (permalink / raw)
  To: libc-alpha

The check is moved to LFS fstatat implementation (since it is the
code that actually implements the syscall).
---
 sysdeps/unix/sysv/linux/fstatat64.c          | 12 ++++++++
 sysdeps/unix/sysv/linux/generic/Makefile     |  2 +-
 sysdeps/unix/sysv/linux/generic/stat-check.c | 29 --------------------
 3 files changed, 13 insertions(+), 30 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/generic/stat-check.c

diff --git a/sysdeps/unix/sysv/linux/fstatat64.c b/sysdeps/unix/sysv/linux/fstatat64.c
index ab41f19e94..a609b4d3ff 100644
--- a/sysdeps/unix/sysv/linux/fstatat64.c
+++ b/sysdeps/unix/sysv/linux/fstatat64.c
@@ -28,6 +28,18 @@
 #include <kstat_cp.h>
 #include <stat_t64_cp.h>
 
+#if __TIMESIZE == 64 \
+     && (__WORDSIZE == 32 \
+     && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE == 32))
+/* Sanity check to avoid newer 32-bit ABI to support non-LFS calls. */
+_Static_assert (sizeof (__off_t) == sizeof (__off64_t),
+                "__blkcnt_t and __blkcnt64_t must match");
+_Static_assert (sizeof (__ino_t) == sizeof (__ino64_t),
+                "__blkcnt_t and __blkcnt64_t must match");
+_Static_assert (sizeof (__blkcnt_t) == sizeof (__blkcnt64_t),
+                "__blkcnt_t and __blkcnt64_t must match");
+#endif
+
 int
 __fstatat64_time64 (int fd, const char *file, struct __stat64_t64 *buf,
 		    int flag)
diff --git a/sysdeps/unix/sysv/linux/generic/Makefile b/sysdeps/unix/sysv/linux/generic/Makefile
index 124f83a0ab..7e27e79772 100644
--- a/sysdeps/unix/sysv/linux/generic/Makefile
+++ b/sysdeps/unix/sysv/linux/generic/Makefile
@@ -1,3 +1,3 @@
 ifeq ($(subdir),misc)
-sysdep_routines += epoll_create inotify_init stat-check
+sysdep_routines += epoll_create inotify_init
 endif
diff --git a/sysdeps/unix/sysv/linux/generic/stat-check.c b/sysdeps/unix/sysv/linux/generic/stat-check.c
deleted file mode 100644
index e09264dd3a..0000000000
--- a/sysdeps/unix/sysv/linux/generic/stat-check.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Static assert for __blkcnt64_t when __INO_T_MATCHES_INO64_T is defined.
-   Copyright (C) 2019-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <sys/stat.h>
-#include <bits/typesizes.h>
-
-/* This is due to the layout code in bits/stat.h and the overflow handling in
-   wordsize-32/overflow.h, requiring either all or none of the three types
-   concerned to have padding.  */
-
-#if defined __INO_T_MATCHES_INO64_T
-_Static_assert (sizeof (__blkcnt_t) == sizeof (__blkcnt64_t),
-                "__blkcnt_t and __blkcnt64_t must match");
-#endif
-- 
2.25.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 00/10] [f]stat[fs,vfs] consolidation
  2021-02-08 21:49 [PATCH 00/10] [f]stat[fs,vfs] consolidation Adhemerval Zanella
                   ` (9 preceding siblings ...)
  2021-02-08 21:49 ` [PATCH 10/10] linux: Remove stat-check.c Adhemerval Zanella
@ 2021-02-11  0:37 ` Carlos O'Donell
  2021-02-11 20:08   ` Joseph Myers
  10 siblings, 1 reply; 27+ messages in thread
From: Carlos O'Donell @ 2021-02-11  0:37 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 2/8/21 4:49 PM, Adhemerval Zanella via Libc-alpha wrote:
> The recent thread from OpenRISC work [1] showed that even through after
> the stat refactor to add y2038 support, the default internals still do
> not set a saner default ABI.
> 
> The 'generic' internal interface still assumes non-LFS support calls
> and sets both the kernel_stat.h and the statfs.h with this assumption.
> This is misleading and requires newer ports to override both definitions
> (as done by arc and riscv32).
> 
> This a refactor set I intended to push and the idea is to make LFS only
> support as default.  It requires to set XSTAT_IS_XSTAT64 to 1 and
> STATFS_IS_STATFS64 to __STATFS_MATCHES_STATFS64 (the STAT_IS_KERNEL_STAT
> is not really required for newer ports, only for older ones with
> non-LFS ABI).
> 
> It allows to consolide the [f]stat[fs,vfs] using the same strategy done
> for stat functions, with alpha being the only outlier (and the hackery
> required to support moved to an alpha specific implementation).
> 
> The final patch also removes a recent addition to the 'generic' folder
> (stat-check.c).  My longer plan is to remove the 'generic' folder
> altogether, by consolidating the implementations, moving the outliers
> to arch-specific implementations, and setting a more saner default abi
> (that assumes LFS and 64-bit time).

Overall I think this goes in the right direction, moving the old defaults
to new defaults and flipping all the flags to match the newer defaults.

I've given each patch a light review, and I think it helps cleanup the
existing mess of code.

> [1] https://sourceware.org/pipermail/libc-alpha/2021-January/122167.html
> 
> Adhemerval Zanella (10):
>   linux: Fix STATFS_IS_STATFS64 definition
>   linux: Set default kernel_stat.h to LFS
>   linux: Set LFS statfs as default
>   linux: Consolidate fstatfs implementations
>   linux: Consolidate statfs implementations
>   linux: Consolidate fstatvfs implementations
>   linux: Consolidate statvfs implementations
>   linux: Consolidate internal_statvfs
>   linux: Remove overflow.h
>   linux: Remove stat-check.c
> 
>  include/sys/statfs.h                          |  7 +-
>  include/sys/statvfs.h                         |  3 +-
>  sysdeps/unix/sysv/linux/Makefile              |  2 +-
>  .../{generic/wordsize-32 => alpha}/fstatfs.c  | 13 +---
>  sysdeps/unix/sysv/linux/alpha/fstatfs64.c     | 52 ++++++++++++-
>  sysdeps/unix/sysv/linux/alpha/fstatvfs.c      |  1 -
>  sysdeps/unix/sysv/linux/alpha/fstatvfs64.c    |  1 -
>  .../sysv/linux/alpha/internal_statvfs64.c     |  1 -
>  .../{generic/wordsize-32 => alpha}/statfs.c   | 16 ++--
>  sysdeps/unix/sysv/linux/alpha/statfs64.c      | 52 ++++++++++++-
>  sysdeps/unix/sysv/linux/alpha/statvfs.c       |  1 -
>  sysdeps/unix/sysv/linux/alpha/statvfs64.c     |  1 -
>  sysdeps/unix/sysv/linux/alpha/syscalls.list   |  4 -
>  sysdeps/unix/sysv/linux/arc/kernel_stat.h     | 27 -------
>  sysdeps/unix/sysv/linux/arm/kernel_stat.h     | 40 ++++++++++
>  .../linux/{generic => csky}/bits/statfs.h     | 11 ---
>  .../sysv/linux/{riscv => csky}/kernel_stat.h  | 12 ++-
>  sysdeps/unix/sysv/linux/fstatat64.c           | 12 +++
>  sysdeps/unix/sysv/linux/fstatfs.c             | 62 +++++++++++++++
>  sysdeps/unix/sysv/linux/fstatfs64.c           | 67 +++--------------
>  sysdeps/unix/sysv/linux/fstatvfs.c            | 11 ++-
>  sysdeps/unix/sysv/linux/fstatvfs64.c          | 53 +++++--------
>  sysdeps/unix/sysv/linux/generic/Makefile      |  2 +-
>  sysdeps/unix/sysv/linux/generic/stat-check.c  | 29 -------
>  .../sysv/linux/generic/wordsize-32/overflow.h | 69 -----------------
>  sysdeps/unix/sysv/linux/i386/kernel_stat.h    | 40 ++++++++++
>  sysdeps/unix/sysv/linux/ia64/kernel_stat.h    | 22 ------
>  sysdeps/unix/sysv/linux/internal_statvfs.c    | 70 +++++++++++------
>  sysdeps/unix/sysv/linux/internal_statvfs.h    |  8 +-
>  sysdeps/unix/sysv/linux/internal_statvfs64.c  |  4 -
>  sysdeps/unix/sysv/linux/kernel_stat.h         | 58 +++++---------
>  sysdeps/unix/sysv/linux/m68k/kernel_stat.h    | 40 ++++++++++
>  sysdeps/unix/sysv/linux/mips/kernel_stat.h    |  6 +-
>  .../sysv/linux/mips/mips64/n64/fstatfs64.c    |  1 -
>  .../sysv/linux/mips/mips64/n64/statfs64.c     |  1 -
>  .../sysv/linux/mips/mips64/n64/syscalls.list  |  3 -
>  sysdeps/unix/sysv/linux/nios2/bits/statfs.h   | 75 +++++++++++++++++++
>  .../linux/{generic => nios2}/kernel_stat.h    | 18 ++---
>  .../linux/powerpc/powerpc64/kernel_stat.h     | 22 ------
>  .../sysv/linux/s390/s390-32/kernel_stat.h     | 40 ++++++++++
>  .../sysv/linux/s390/s390-64/kernel_stat.h     | 22 ------
>  sysdeps/unix/sysv/linux/sh/kernel_stat.h      | 40 ++++++++++
>  .../sysv/linux/sparc/sparc64/kernel_stat.h    |  7 +-
>  sysdeps/unix/sysv/linux/statfs.c              | 61 +++++++++++++++
>  sysdeps/unix/sysv/linux/statfs64.c            | 69 ++---------------
>  sysdeps/unix/sysv/linux/statvfs.c             | 11 ++-
>  sysdeps/unix/sysv/linux/statvfs64.c           | 54 +++++--------
>  .../unix/sysv/linux/wordsize-64/fstatfs64.c   |  1 -
>  .../unix/sysv/linux/wordsize-64/fstatvfs.c    |  5 --
>  .../unix/sysv/linux/wordsize-64/fstatvfs64.c  |  1 -
>  .../linux/wordsize-64/internal_statvfs64.c    |  1 -
>  .../unix/sysv/linux/wordsize-64/statfs64.c    |  1 -
>  sysdeps/unix/sysv/linux/wordsize-64/statvfs.c |  5 --
>  .../unix/sysv/linux/wordsize-64/statvfs64.c   |  1 -
>  .../unix/sysv/linux/wordsize-64/syscalls.list |  2 -
>  sysdeps/unix/sysv/linux/x86_64/kernel_stat.h  | 22 ------
>  sysdeps/unix/sysv/linux/xstatconv.c           |  7 +-
>  57 files changed, 688 insertions(+), 579 deletions(-)
>  rename sysdeps/unix/sysv/linux/{generic/wordsize-32 => alpha}/fstatfs.c (76%)
>  delete mode 100644 sysdeps/unix/sysv/linux/alpha/fstatvfs.c
>  delete mode 100644 sysdeps/unix/sysv/linux/alpha/fstatvfs64.c
>  delete mode 100644 sysdeps/unix/sysv/linux/alpha/internal_statvfs64.c
>  rename sysdeps/unix/sysv/linux/{generic/wordsize-32 => alpha}/statfs.c (72%)
>  delete mode 100644 sysdeps/unix/sysv/linux/alpha/statvfs.c
>  delete mode 100644 sysdeps/unix/sysv/linux/alpha/statvfs64.c
>  delete mode 100644 sysdeps/unix/sysv/linux/arc/kernel_stat.h
>  create mode 100644 sysdeps/unix/sysv/linux/arm/kernel_stat.h
>  rename sysdeps/unix/sysv/linux/{generic => csky}/bits/statfs.h (79%)
>  rename sysdeps/unix/sysv/linux/{riscv => csky}/kernel_stat.h (77%)
>  create mode 100644 sysdeps/unix/sysv/linux/fstatfs.c
>  delete mode 100644 sysdeps/unix/sysv/linux/generic/stat-check.c
>  delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h
>  create mode 100644 sysdeps/unix/sysv/linux/i386/kernel_stat.h
>  delete mode 100644 sysdeps/unix/sysv/linux/ia64/kernel_stat.h
>  delete mode 100644 sysdeps/unix/sysv/linux/internal_statvfs64.c
>  create mode 100644 sysdeps/unix/sysv/linux/m68k/kernel_stat.h
>  delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n64/fstatfs64.c
>  delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n64/statfs64.c
>  create mode 100644 sysdeps/unix/sysv/linux/nios2/bits/statfs.h
>  rename sysdeps/unix/sysv/linux/{generic => nios2}/kernel_stat.h (71%)
>  delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h
>  create mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/kernel_stat.h
>  delete mode 100644 sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h
>  create mode 100644 sysdeps/unix/sysv/linux/sh/kernel_stat.h
>  create mode 100644 sysdeps/unix/sysv/linux/statfs.c
>  delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/fstatfs64.c
>  delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/fstatvfs.c
>  delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/fstatvfs64.c
>  delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/internal_statvfs64.c
>  delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/statfs64.c
>  delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/statvfs.c
>  delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/statvfs64.c
>  delete mode 100644 sysdeps/unix/sysv/linux/x86_64/kernel_stat.h
> 


-- 
Cheers,
Carlos.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 01/10] linux: Fix STATFS_IS_STATFS64 definition
  2021-02-08 21:49 ` [PATCH 01/10] linux: Fix STATFS_IS_STATFS64 definition Adhemerval Zanella
@ 2021-02-11  0:37   ` Carlos O'Donell
  0 siblings, 0 replies; 27+ messages in thread
From: Carlos O'Donell @ 2021-02-11  0:37 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 2/8/21 4:49 PM, Adhemerval Zanella via Libc-alpha wrote:
> aarch64, arc, ia64, mips64, powerpc64, riscv32, riscv64, s390x, sparc64,
> and  x86_64 defines STATFS_IS_STATFS64 to 0, but all of them alias
> both statfs to statfs64 and struct statfs has the same and layout of
> struct statfs64.
> 
> The correct definition will be used on the {f}statfs{64} consolidation.
> 
> This patch does not change code generation since the symbols are
> implemented using the auto-generation syscall for all the aforementioned
> abis.

This is sane. LGTM.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

> ---
>  sysdeps/unix/sysv/linux/aarch64/kernel_stat.h | 21 +++++++++++++++++++
>  sysdeps/unix/sysv/linux/ia64/kernel_stat.h    |  2 +-
>  sysdeps/unix/sysv/linux/mips/kernel_stat.h    |  6 +++++-
>  .../linux/powerpc/powerpc64/kernel_stat.h     |  2 +-
>  sysdeps/unix/sysv/linux/riscv/kernel_stat.h   |  2 +-
>  .../sysv/linux/s390/s390-64/kernel_stat.h     |  2 +-
>  .../sysv/linux/sparc/sparc64/kernel_stat.h    |  7 +++++--
>  sysdeps/unix/sysv/linux/x86_64/kernel_stat.h  |  2 +-
>  8 files changed, 36 insertions(+), 8 deletions(-)
>  create mode 100644 sysdeps/unix/sysv/linux/aarch64/kernel_stat.h
> 
> diff --git a/sysdeps/unix/sysv/linux/aarch64/kernel_stat.h b/sysdeps/unix/sysv/linux/aarch64/kernel_stat.h
> new file mode 100644
> index 0000000000..33ad1b622b
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/aarch64/kernel_stat.h
> @@ -0,0 +1,21 @@
> +/* Internal definitions for stat functions.  Linux/AARch64 version.
> +   Copyright (C) 2021 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library.  If not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#define STAT_IS_KERNEL_STAT 1
> +#define XSTAT_IS_XSTAT64 1
> +#define STATFS_IS_STATFS64 1
> diff --git a/sysdeps/unix/sysv/linux/ia64/kernel_stat.h b/sysdeps/unix/sysv/linux/ia64/kernel_stat.h
> index e1eac69850..ee05a15590 100644
> --- a/sysdeps/unix/sysv/linux/ia64/kernel_stat.h
> +++ b/sysdeps/unix/sysv/linux/ia64/kernel_stat.h
> @@ -19,4 +19,4 @@
>  #define STAT_IS_KERNEL_STAT 1
>  #define STAT64_IS_KERNEL_STAT64 1
>  #define XSTAT_IS_XSTAT64 1
> -#define STATFS_IS_STATFS64 0
> +#define STATFS_IS_STATFS64 1
> diff --git a/sysdeps/unix/sysv/linux/mips/kernel_stat.h b/sysdeps/unix/sysv/linux/mips/kernel_stat.h
> index 21dba2de73..e4b0f211ca 100644
> --- a/sysdeps/unix/sysv/linux/mips/kernel_stat.h
> +++ b/sysdeps/unix/sysv/linux/mips/kernel_stat.h
> @@ -62,6 +62,10 @@ struct kernel_stat
>  #define STAT_IS_KERNEL_STAT 0
>  #define STAT64_IS_KERNEL_STAT64 0
>  #define XSTAT_IS_XSTAT64 0
> -#define STATFS_IS_STATFS64 0
> +#if _MIPS_SIM == _ABI64
> +# define STATFS_IS_STATFS64 1
> +#else
> +# define STATFS_IS_STATFS64 0
> +#endif
>  
>  #endif
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h b/sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h
> index a1f66bcece..bc7390c9ff 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h
> @@ -19,4 +19,4 @@
>  #define STAT_IS_KERNEL_STAT 1
>  #define STAT64_IS_KERNEL_STAT64 1
>  #define XSTAT_IS_XSTAT64 1
> -#define STATFS_IS_STATFS64 0
> +#define STATFS_IS_STATFS64 1
> diff --git a/sysdeps/unix/sysv/linux/riscv/kernel_stat.h b/sysdeps/unix/sysv/linux/riscv/kernel_stat.h
> index ee8b37a9eb..4ad7913762 100644
> --- a/sysdeps/unix/sysv/linux/riscv/kernel_stat.h
> +++ b/sysdeps/unix/sysv/linux/riscv/kernel_stat.h
> @@ -20,4 +20,4 @@
>  #define STAT_IS_KERNEL_STAT 1
>  
>  #define XSTAT_IS_XSTAT64 1
> -#define STATFS_IS_STATFS64 0
> +#define STATFS_IS_STATFS64 1
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h b/sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h
> index e1eac69850..ee05a15590 100644
> --- a/sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h
> +++ b/sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h
> @@ -19,4 +19,4 @@
>  #define STAT_IS_KERNEL_STAT 1
>  #define STAT64_IS_KERNEL_STAT64 1
>  #define XSTAT_IS_XSTAT64 1
> -#define STATFS_IS_STATFS64 0
> +#define STATFS_IS_STATFS64 1
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h b/sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h
> index 0f3d405239..29d18908da 100644
> --- a/sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h
> +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h
> @@ -50,6 +50,9 @@ struct kernel_stat64
>  #define STAT_IS_KERNEL_STAT 0
>  #define STAT64_IS_KERNEL_STAT64 0
>  #define XSTAT_IS_XSTAT64 1
> -#define STATFS_IS_STATFS64 0
> -
> +#ifdef __arch64__
> +# define STATFS_IS_STATFS64 1
> +#else
> +# define STATFS_IS_STATFS64 0
> +#endif
>  #endif /* _KERNEL_STAT_H  */
> diff --git a/sysdeps/unix/sysv/linux/x86_64/kernel_stat.h b/sysdeps/unix/sysv/linux/x86_64/kernel_stat.h
> index e1eac69850..ee05a15590 100644
> --- a/sysdeps/unix/sysv/linux/x86_64/kernel_stat.h
> +++ b/sysdeps/unix/sysv/linux/x86_64/kernel_stat.h
> @@ -19,4 +19,4 @@
>  #define STAT_IS_KERNEL_STAT 1
>  #define STAT64_IS_KERNEL_STAT64 1
>  #define XSTAT_IS_XSTAT64 1
> -#define STATFS_IS_STATFS64 0
> +#define STATFS_IS_STATFS64 1
> 


-- 
Cheers,
Carlos.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 02/10] linux: Set default kernel_stat.h to LFS
  2021-02-08 21:49 ` [PATCH 02/10] linux: Set default kernel_stat.h to LFS Adhemerval Zanella
@ 2021-02-11  0:37   ` Carlos O'Donell
  0 siblings, 0 replies; 27+ messages in thread
From: Carlos O'Donell @ 2021-02-11  0:37 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 2/8/21 4:49 PM, Adhemerval Zanella via Libc-alpha wrote:
> The XSTAT_IS_XSTAT64 and STAT_IS_KERNEL_STAT flags are now set to 1 and
> STATFS_IS_STATFS64 is set to __STATFS_MATCHES_STATFS64.  This makes the
> default ABI for newer ports to provide only LFS calls.
> 
> A copy of non-LFS support is provided to 32-bit ABIS with non-LFS
> support (arm, csky, i386, m68k, nios2, s390, and sh).  Is also allows
> to remove the 64-bit ports, which already uses the default values.
> 
> This patch does not change the code generation.

This is also sane, and starts working towards LFS by default.

LGTM.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

> ---
>  sysdeps/unix/sysv/linux/arc/kernel_stat.h     | 27 ---------
>  sysdeps/unix/sysv/linux/arm/kernel_stat.h     | 40 +++++++++++++
>  .../sysv/linux/{riscv => csky}/kernel_stat.h  | 12 ++--
>  sysdeps/unix/sysv/linux/generic/kernel_stat.h | 30 ----------
>  sysdeps/unix/sysv/linux/i386/kernel_stat.h    | 40 +++++++++++++
>  sysdeps/unix/sysv/linux/ia64/kernel_stat.h    | 22 -------
>  sysdeps/unix/sysv/linux/kernel_stat.h         | 58 +++++++------------
>  sysdeps/unix/sysv/linux/m68k/kernel_stat.h    | 40 +++++++++++++
>  .../linux/{aarch64 => nios2}/kernel_stat.h    |  9 +--
>  .../linux/powerpc/powerpc64/kernel_stat.h     | 22 -------
>  .../sysv/linux/s390/s390-32/kernel_stat.h     | 40 +++++++++++++
>  .../sysv/linux/s390/s390-64/kernel_stat.h     | 22 -------
>  sysdeps/unix/sysv/linux/sh/kernel_stat.h      | 40 +++++++++++++
>  sysdeps/unix/sysv/linux/x86_64/kernel_stat.h  | 22 -------
>  sysdeps/unix/sysv/linux/xstatconv.c           |  7 +--
>  15 files changed, 231 insertions(+), 200 deletions(-)
>  delete mode 100644 sysdeps/unix/sysv/linux/arc/kernel_stat.h
>  create mode 100644 sysdeps/unix/sysv/linux/arm/kernel_stat.h
>  rename sysdeps/unix/sysv/linux/{riscv => csky}/kernel_stat.h (77%)
>  delete mode 100644 sysdeps/unix/sysv/linux/generic/kernel_stat.h
>  create mode 100644 sysdeps/unix/sysv/linux/i386/kernel_stat.h
>  delete mode 100644 sysdeps/unix/sysv/linux/ia64/kernel_stat.h
>  create mode 100644 sysdeps/unix/sysv/linux/m68k/kernel_stat.h
>  rename sysdeps/unix/sysv/linux/{aarch64 => nios2}/kernel_stat.h (78%)
>  delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h
>  create mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/kernel_stat.h
>  delete mode 100644 sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h
>  create mode 100644 sysdeps/unix/sysv/linux/sh/kernel_stat.h
>  delete mode 100644 sysdeps/unix/sysv/linux/x86_64/kernel_stat.h
> 
> diff --git a/sysdeps/unix/sysv/linux/arc/kernel_stat.h b/sysdeps/unix/sysv/linux/arc/kernel_stat.h
> deleted file mode 100644
> index edd96b1b94..0000000000
> --- a/sysdeps/unix/sysv/linux/arc/kernel_stat.h
> +++ /dev/null
> @@ -1,27 +0,0 @@
> -/* Copyright (C) 2020-2021 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library.  If not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -#include <bits/wordsize.h>
> -
> -/* Needed to elide the itemized copy code in common xstatconv.c.  */
> -#define STAT_IS_KERNEL_STAT 1
> -#define STAT64_IS_KERNEL_STAT64 1
> -
> -/* Nice side-effect of 64-bit time_t switch is these are same.  */
> -#define XSTAT_IS_XSTAT64 1
> -
> -#define STATFS_IS_STATFS64 0
> diff --git a/sysdeps/unix/sysv/linux/arm/kernel_stat.h b/sysdeps/unix/sysv/linux/arm/kernel_stat.h
> new file mode 100644
> index 0000000000..b1bc1459f0
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/arm/kernel_stat.h
> @@ -0,0 +1,40 @@
> +/* Definition of `struct stat' used in the kernel..  */
> +struct kernel_stat
> +  {
> +    unsigned short int st_dev;
> +    unsigned short int __pad1;
> +#define _HAVE___PAD1
> +    unsigned long int st_ino;
> +    unsigned short int st_mode;
> +    unsigned short int st_nlink;
> +    unsigned short int st_uid;
> +    unsigned short int st_gid;
> +    unsigned short int st_rdev;
> +    unsigned short int __pad2;
> +#define _HAVE___PAD2
> +    unsigned long int st_size;
> +    unsigned long int st_blksize;
> +    unsigned long int st_blocks;
> +    struct timespec st_atim;
> +    struct timespec st_mtim;
> +    struct timespec st_ctim;
> +    unsigned long int __glibc_reserved4;
> +#define _HAVE___UNUSED4
> +    unsigned long int __glibc_reserved5;
> +#define _HAVE___UNUSED5
> +  };
> +
> +#define _HAVE_STAT___UNUSED4
> +#define _HAVE_STAT___UNUSED5
> +#define _HAVE_STAT___PAD1
> +#define _HAVE_STAT___PAD2
> +#define _HAVE_STAT_NSEC
> +#define _HAVE_STAT64___PAD1
> +#define _HAVE_STAT64___PAD2
> +#define _HAVE_STAT64___ST_INO
> +#define _HAVE_STAT64_NSEC
> +
> +#define STAT_IS_KERNEL_STAT 0
> +#define STAT64_IS_KERNEL_STAT64 1
> +#define XSTAT_IS_XSTAT64 0
> +#define STATFS_IS_STATFS64 0
> diff --git a/sysdeps/unix/sysv/linux/riscv/kernel_stat.h b/sysdeps/unix/sysv/linux/csky/kernel_stat.h
> similarity index 77%
> rename from sysdeps/unix/sysv/linux/riscv/kernel_stat.h
> rename to sysdeps/unix/sysv/linux/csky/kernel_stat.h
> index 4ad7913762..e993021a81 100644
> --- a/sysdeps/unix/sysv/linux/riscv/kernel_stat.h
> +++ b/sysdeps/unix/sysv/linux/csky/kernel_stat.h
> @@ -1,4 +1,5 @@
> -/* Copyright (C) 2020-2021 Free Software Foundation, Inc.
> +/* Internal definitions for stat functions.  Linux/csky.
> +   Copyright (C) 2011-2021 Free Software Foundation, Inc.
>     This file is part of the GNU C Library.
>  
>     The GNU C Library is free software; you can redistribute it and/or
> @@ -15,9 +16,6 @@
>     License along with the GNU C Library.  If not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -#include <bits/wordsize.h>
> -
> -#define STAT_IS_KERNEL_STAT 1
> -
> -#define XSTAT_IS_XSTAT64 1
> -#define STATFS_IS_STATFS64 1
> +#define STAT_IS_KERNEL_STAT  1
> +#define XSTAT_IS_XSTAT64     0
> +#define STATFS_IS_STATFS64   0
> diff --git a/sysdeps/unix/sysv/linux/generic/kernel_stat.h b/sysdeps/unix/sysv/linux/generic/kernel_stat.h
> deleted file mode 100644
> index 350f0cc1bb..0000000000
> --- a/sysdeps/unix/sysv/linux/generic/kernel_stat.h
> +++ /dev/null
> @@ -1,30 +0,0 @@
> -/* Copyright (C) 2011-2021 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library.  If not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -#include <bits/wordsize.h>
> -
> -#define STAT_IS_KERNEL_STAT 1
> -
> -/* We provide separate 32-bit API versions that check for EOVERFLOW. */
> -#if __WORDSIZE == 64
> -# define XSTAT_IS_XSTAT64 1
> -#else
> -# define XSTAT_IS_XSTAT64 0
> -#endif
> -
> -#define STATFS_IS_STATFS64 0
> diff --git a/sysdeps/unix/sysv/linux/i386/kernel_stat.h b/sysdeps/unix/sysv/linux/i386/kernel_stat.h
> new file mode 100644
> index 0000000000..b1bc1459f0
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/i386/kernel_stat.h
> @@ -0,0 +1,40 @@
> +/* Definition of `struct stat' used in the kernel..  */
> +struct kernel_stat
> +  {
> +    unsigned short int st_dev;
> +    unsigned short int __pad1;
> +#define _HAVE___PAD1
> +    unsigned long int st_ino;
> +    unsigned short int st_mode;
> +    unsigned short int st_nlink;
> +    unsigned short int st_uid;
> +    unsigned short int st_gid;
> +    unsigned short int st_rdev;
> +    unsigned short int __pad2;
> +#define _HAVE___PAD2
> +    unsigned long int st_size;
> +    unsigned long int st_blksize;
> +    unsigned long int st_blocks;
> +    struct timespec st_atim;
> +    struct timespec st_mtim;
> +    struct timespec st_ctim;
> +    unsigned long int __glibc_reserved4;
> +#define _HAVE___UNUSED4
> +    unsigned long int __glibc_reserved5;
> +#define _HAVE___UNUSED5
> +  };
> +
> +#define _HAVE_STAT___UNUSED4
> +#define _HAVE_STAT___UNUSED5
> +#define _HAVE_STAT___PAD1
> +#define _HAVE_STAT___PAD2
> +#define _HAVE_STAT_NSEC
> +#define _HAVE_STAT64___PAD1
> +#define _HAVE_STAT64___PAD2
> +#define _HAVE_STAT64___ST_INO
> +#define _HAVE_STAT64_NSEC
> +
> +#define STAT_IS_KERNEL_STAT 0
> +#define STAT64_IS_KERNEL_STAT64 1
> +#define XSTAT_IS_XSTAT64 0
> +#define STATFS_IS_STATFS64 0
> diff --git a/sysdeps/unix/sysv/linux/ia64/kernel_stat.h b/sysdeps/unix/sysv/linux/ia64/kernel_stat.h
> deleted file mode 100644
> index ee05a15590..0000000000
> --- a/sysdeps/unix/sysv/linux/ia64/kernel_stat.h
> +++ /dev/null
> @@ -1,22 +0,0 @@
> -/* Definition of `struct stat' used in the kernel.
> -   Copyright (C) 2003-2021 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library; if not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -#define STAT_IS_KERNEL_STAT 1
> -#define STAT64_IS_KERNEL_STAT64 1
> -#define XSTAT_IS_XSTAT64 1
> -#define STATFS_IS_STATFS64 1
> diff --git a/sysdeps/unix/sysv/linux/kernel_stat.h b/sysdeps/unix/sysv/linux/kernel_stat.h
> index b1bc1459f0..6c1b175cb4 100644
> --- a/sysdeps/unix/sysv/linux/kernel_stat.h
> +++ b/sysdeps/unix/sysv/linux/kernel_stat.h
> @@ -1,40 +1,22 @@
> -/* Definition of `struct stat' used in the kernel..  */
> -struct kernel_stat
> -  {
> -    unsigned short int st_dev;
> -    unsigned short int __pad1;
> -#define _HAVE___PAD1
> -    unsigned long int st_ino;
> -    unsigned short int st_mode;
> -    unsigned short int st_nlink;
> -    unsigned short int st_uid;
> -    unsigned short int st_gid;
> -    unsigned short int st_rdev;
> -    unsigned short int __pad2;
> -#define _HAVE___PAD2
> -    unsigned long int st_size;
> -    unsigned long int st_blksize;
> -    unsigned long int st_blocks;
> -    struct timespec st_atim;
> -    struct timespec st_mtim;
> -    struct timespec st_ctim;
> -    unsigned long int __glibc_reserved4;
> -#define _HAVE___UNUSED4
> -    unsigned long int __glibc_reserved5;
> -#define _HAVE___UNUSED5
> -  };
> +/* Internal definitions for stat functions.
> +   Copyright (C) 2021 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
>  
> -#define _HAVE_STAT___UNUSED4
> -#define _HAVE_STAT___UNUSED5
> -#define _HAVE_STAT___PAD1
> -#define _HAVE_STAT___PAD2
> -#define _HAVE_STAT_NSEC
> -#define _HAVE_STAT64___PAD1
> -#define _HAVE_STAT64___PAD2
> -#define _HAVE_STAT64___ST_INO
> -#define _HAVE_STAT64_NSEC
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
>  
> -#define STAT_IS_KERNEL_STAT 0
> -#define STAT64_IS_KERNEL_STAT64 1
> -#define XSTAT_IS_XSTAT64 0
> -#define STATFS_IS_STATFS64 0
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +/* The default Linux ABI assumes only LFS support.  */
> +#define XSTAT_IS_XSTAT64     1
> +#define STATFS_IS_STATFS64   __STATFS_MATCHES_STATFS64
> +#define STAT_IS_KERNEL_STAT  1
> diff --git a/sysdeps/unix/sysv/linux/m68k/kernel_stat.h b/sysdeps/unix/sysv/linux/m68k/kernel_stat.h
> new file mode 100644
> index 0000000000..b1bc1459f0
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/m68k/kernel_stat.h
> @@ -0,0 +1,40 @@
> +/* Definition of `struct stat' used in the kernel..  */
> +struct kernel_stat
> +  {
> +    unsigned short int st_dev;
> +    unsigned short int __pad1;
> +#define _HAVE___PAD1
> +    unsigned long int st_ino;
> +    unsigned short int st_mode;
> +    unsigned short int st_nlink;
> +    unsigned short int st_uid;
> +    unsigned short int st_gid;
> +    unsigned short int st_rdev;
> +    unsigned short int __pad2;
> +#define _HAVE___PAD2
> +    unsigned long int st_size;
> +    unsigned long int st_blksize;
> +    unsigned long int st_blocks;
> +    struct timespec st_atim;
> +    struct timespec st_mtim;
> +    struct timespec st_ctim;
> +    unsigned long int __glibc_reserved4;
> +#define _HAVE___UNUSED4
> +    unsigned long int __glibc_reserved5;
> +#define _HAVE___UNUSED5
> +  };
> +
> +#define _HAVE_STAT___UNUSED4
> +#define _HAVE_STAT___UNUSED5
> +#define _HAVE_STAT___PAD1
> +#define _HAVE_STAT___PAD2
> +#define _HAVE_STAT_NSEC
> +#define _HAVE_STAT64___PAD1
> +#define _HAVE_STAT64___PAD2
> +#define _HAVE_STAT64___ST_INO
> +#define _HAVE_STAT64_NSEC
> +
> +#define STAT_IS_KERNEL_STAT 0
> +#define STAT64_IS_KERNEL_STAT64 1
> +#define XSTAT_IS_XSTAT64 0
> +#define STATFS_IS_STATFS64 0
> diff --git a/sysdeps/unix/sysv/linux/aarch64/kernel_stat.h b/sysdeps/unix/sysv/linux/nios2/kernel_stat.h
> similarity index 78%
> rename from sysdeps/unix/sysv/linux/aarch64/kernel_stat.h
> rename to sysdeps/unix/sysv/linux/nios2/kernel_stat.h
> index 33ad1b622b..1af30dab6f 100644
> --- a/sysdeps/unix/sysv/linux/aarch64/kernel_stat.h
> +++ b/sysdeps/unix/sysv/linux/nios2/kernel_stat.h
> @@ -1,6 +1,7 @@
> -/* Internal definitions for stat functions.  Linux/AARch64 version.
> +/* Internal definitions for stat functions.  Linux/nios2.
>     Copyright (C) 2021 Free Software Foundation, Inc.
>     This file is part of the GNU C Library.
> +   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
>  
>     The GNU C Library is free software; you can redistribute it and/or
>     modify it under the terms of the GNU Lesser General Public
> @@ -16,6 +17,6 @@
>     License along with the GNU C Library.  If not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -#define STAT_IS_KERNEL_STAT 1
> -#define XSTAT_IS_XSTAT64 1
> -#define STATFS_IS_STATFS64 1
> +#define STAT_IS_KERNEL_STAT  1
> +#define XSTAT_IS_XSTAT64     0
> +#define STATFS_IS_STATFS64   0
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h b/sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h
> deleted file mode 100644
> index bc7390c9ff..0000000000
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h
> +++ /dev/null
> @@ -1,22 +0,0 @@
> -/* Definition of `struct stat' used in the kernel.
> -   Copyright (C) 2002-2021 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library; if not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -#define STAT_IS_KERNEL_STAT 1
> -#define STAT64_IS_KERNEL_STAT64 1
> -#define XSTAT_IS_XSTAT64 1
> -#define STATFS_IS_STATFS64 1
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/kernel_stat.h b/sysdeps/unix/sysv/linux/s390/s390-32/kernel_stat.h
> new file mode 100644
> index 0000000000..b1bc1459f0
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/s390/s390-32/kernel_stat.h
> @@ -0,0 +1,40 @@
> +/* Definition of `struct stat' used in the kernel..  */
> +struct kernel_stat
> +  {
> +    unsigned short int st_dev;
> +    unsigned short int __pad1;
> +#define _HAVE___PAD1
> +    unsigned long int st_ino;
> +    unsigned short int st_mode;
> +    unsigned short int st_nlink;
> +    unsigned short int st_uid;
> +    unsigned short int st_gid;
> +    unsigned short int st_rdev;
> +    unsigned short int __pad2;
> +#define _HAVE___PAD2
> +    unsigned long int st_size;
> +    unsigned long int st_blksize;
> +    unsigned long int st_blocks;
> +    struct timespec st_atim;
> +    struct timespec st_mtim;
> +    struct timespec st_ctim;
> +    unsigned long int __glibc_reserved4;
> +#define _HAVE___UNUSED4
> +    unsigned long int __glibc_reserved5;
> +#define _HAVE___UNUSED5
> +  };
> +
> +#define _HAVE_STAT___UNUSED4
> +#define _HAVE_STAT___UNUSED5
> +#define _HAVE_STAT___PAD1
> +#define _HAVE_STAT___PAD2
> +#define _HAVE_STAT_NSEC
> +#define _HAVE_STAT64___PAD1
> +#define _HAVE_STAT64___PAD2
> +#define _HAVE_STAT64___ST_INO
> +#define _HAVE_STAT64_NSEC
> +
> +#define STAT_IS_KERNEL_STAT 0
> +#define STAT64_IS_KERNEL_STAT64 1
> +#define XSTAT_IS_XSTAT64 0
> +#define STATFS_IS_STATFS64 0
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h b/sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h
> deleted file mode 100644
> index ee05a15590..0000000000
> --- a/sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h
> +++ /dev/null
> @@ -1,22 +0,0 @@
> -/* Definition of `struct stat' used in the kernel.
> -   Copyright (C) 2003-2021 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library; if not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -#define STAT_IS_KERNEL_STAT 1
> -#define STAT64_IS_KERNEL_STAT64 1
> -#define XSTAT_IS_XSTAT64 1
> -#define STATFS_IS_STATFS64 1
> diff --git a/sysdeps/unix/sysv/linux/sh/kernel_stat.h b/sysdeps/unix/sysv/linux/sh/kernel_stat.h
> new file mode 100644
> index 0000000000..b1bc1459f0
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/sh/kernel_stat.h
> @@ -0,0 +1,40 @@
> +/* Definition of `struct stat' used in the kernel..  */
> +struct kernel_stat
> +  {
> +    unsigned short int st_dev;
> +    unsigned short int __pad1;
> +#define _HAVE___PAD1
> +    unsigned long int st_ino;
> +    unsigned short int st_mode;
> +    unsigned short int st_nlink;
> +    unsigned short int st_uid;
> +    unsigned short int st_gid;
> +    unsigned short int st_rdev;
> +    unsigned short int __pad2;
> +#define _HAVE___PAD2
> +    unsigned long int st_size;
> +    unsigned long int st_blksize;
> +    unsigned long int st_blocks;
> +    struct timespec st_atim;
> +    struct timespec st_mtim;
> +    struct timespec st_ctim;
> +    unsigned long int __glibc_reserved4;
> +#define _HAVE___UNUSED4
> +    unsigned long int __glibc_reserved5;
> +#define _HAVE___UNUSED5
> +  };
> +
> +#define _HAVE_STAT___UNUSED4
> +#define _HAVE_STAT___UNUSED5
> +#define _HAVE_STAT___PAD1
> +#define _HAVE_STAT___PAD2
> +#define _HAVE_STAT_NSEC
> +#define _HAVE_STAT64___PAD1
> +#define _HAVE_STAT64___PAD2
> +#define _HAVE_STAT64___ST_INO
> +#define _HAVE_STAT64_NSEC
> +
> +#define STAT_IS_KERNEL_STAT 0
> +#define STAT64_IS_KERNEL_STAT64 1
> +#define XSTAT_IS_XSTAT64 0
> +#define STATFS_IS_STATFS64 0
> diff --git a/sysdeps/unix/sysv/linux/x86_64/kernel_stat.h b/sysdeps/unix/sysv/linux/x86_64/kernel_stat.h
> deleted file mode 100644
> index ee05a15590..0000000000
> --- a/sysdeps/unix/sysv/linux/x86_64/kernel_stat.h
> +++ /dev/null
> @@ -1,22 +0,0 @@
> -/* Definition of `struct stat' used in the kernel.
> -   Copyright (C) 2003-2021 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library; if not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -#define STAT_IS_KERNEL_STAT 1
> -#define STAT64_IS_KERNEL_STAT64 1
> -#define XSTAT_IS_XSTAT64 1
> -#define STATFS_IS_STATFS64 1
> diff --git a/sysdeps/unix/sysv/linux/xstatconv.c b/sysdeps/unix/sysv/linux/xstatconv.c
> index 5dfe7c5fb5..4d049d4555 100644
> --- a/sysdeps/unix/sysv/linux/xstatconv.c
> +++ b/sysdeps/unix/sysv/linux/xstatconv.c
> @@ -21,12 +21,7 @@
>  #include <kernel_stat.h>
>  #include <sysdep.h>
>  
> -#if STAT_IS_KERNEL_STAT
> -
> -/* Dummy.  */
> -struct kernel_stat;
> -
> -#else
> +#if !STAT_IS_KERNEL_STAT
>  
>  #include <string.h>
>  
> 


-- 
Cheers,
Carlos.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 03/10] linux: Set LFS statfs as default
  2021-02-08 21:49 ` [PATCH 03/10] linux: Set LFS statfs as default Adhemerval Zanella
@ 2021-02-11  0:37   ` Carlos O'Donell
  0 siblings, 0 replies; 27+ messages in thread
From: Carlos O'Donell @ 2021-02-11  0:37 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 2/8/21 4:49 PM, Adhemerval Zanella via Libc-alpha wrote:
> Currently glibc has three different struct statfs{64} definitions:
> 
>   1. Non-LFS support where non-LFS and LFS struct have different
>      size: alpha, arm, hppa, i686, m68k, microblaze, mips (all abis),
>      powerpc32, s390, sh4, and sparc.

Correct, generally 32-bit targets.

> 
>   2. Non-LFS support where non-LFS and LFS struct have the same
>      size: csky and nios2.

Usually newer ports.

> 
>   3. Only LFS support (where both struct have the same size): arc,
>      ia64, powerpc64 (including LE), riscv (both 32 and 64 bits),
>      s390x, sparc64, and x86 (including x32).

Usually 64-bit ports or very new 32-bit ports aligned with LFS.

> The STATFS_IS_STATFS64/__STATFS_MATCHES_STATFS64 does not tell apart
> between 1. and 2.; since for both the only difference is the struct
> size (for 2. both non-LFS and LFS uses the same syscall, where for
> 1. the old non-LFS is used for {f}statfs).
> 
> This patch move the generic statfs.h for both csky and nios2, and
> make the default definitions for newer ABIs to assume that only
> LFS will be support (so there is no need to keep no-LFS and LFS
> struct statfs with the same size, it will be implicit).

Good cleanup.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

> 
> This patch does not change the code generation.
> ---
>  .../linux/{generic => csky}/bits/statfs.h     | 11 ---
>  sysdeps/unix/sysv/linux/nios2/bits/statfs.h   | 75 +++++++++++++++++++
>  2 files changed, 75 insertions(+), 11 deletions(-)
>  rename sysdeps/unix/sysv/linux/{generic => csky}/bits/statfs.h (79%)
>  create mode 100644 sysdeps/unix/sysv/linux/nios2/bits/statfs.h
> 
> diff --git a/sysdeps/unix/sysv/linux/generic/bits/statfs.h b/sysdeps/unix/sysv/linux/csky/bits/statfs.h
> similarity index 79%
> rename from sysdeps/unix/sysv/linux/generic/bits/statfs.h
> rename to sysdeps/unix/sysv/linux/csky/bits/statfs.h
> index bef18a3696..131b6adfba 100644
> --- a/sysdeps/unix/sysv/linux/generic/bits/statfs.h
> +++ b/sysdeps/unix/sysv/linux/csky/bits/statfs.h
> @@ -1,6 +1,5 @@
>  /* Copyright (C) 2011-2021 Free Software Foundation, Inc.
>     This file is part of the GNU C Library.
> -   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
>  
>     The GNU C Library is free software; you can redistribute it and/or
>     modify it under the terms of the GNU Lesser General Public
> @@ -24,18 +23,8 @@
>  #include <bits/types.h>
>  #include <bits/wordsize.h>
>  
> -/* 64-bit libc uses the kernel's 'struct statfs', accessed via the
> -   statfs() syscall; 32-bit libc uses the kernel's 'struct statfs64'
> -   and accesses it via the statfs64() syscall.  All the various
> -   APIs offered by libc use the kernel shape for their struct statfs
> -   structure; the only difference is that 32-bit programs not
> -   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
>  # define __field64(type, type64, name) type64 name
> -#elif __WORDSIZE == 64 || __STATFS_MATCHES_STATFS64
> -# define __field64(type, type64, name) type name
>  #elif __BYTE_ORDER == __LITTLE_ENDIAN
>  # define __field64(type, type64, name) \
>    type name __attribute__((__aligned__ (__alignof__ (type64)))); int __##name##_pad
> diff --git a/sysdeps/unix/sysv/linux/nios2/bits/statfs.h b/sysdeps/unix/sysv/linux/nios2/bits/statfs.h
> new file mode 100644
> index 0000000000..131b6adfba
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/nios2/bits/statfs.h
> @@ -0,0 +1,75 @@
> +/* Copyright (C) 2011-2021 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library.  If not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#ifndef _SYS_STATFS_H
> +# error "Never include <bits/statfs.h> directly; use <sys/statfs.h> instead."
> +#endif
> +
> +#include <bits/endian.h>
> +#include <bits/types.h>
> +#include <bits/wordsize.h>
> +
> +#if defined __USE_FILE_OFFSET64
> +# define __field64(type, type64, name) type64 name
> +#elif __BYTE_ORDER == __LITTLE_ENDIAN
> +# define __field64(type, type64, name) \
> +  type name __attribute__((__aligned__ (__alignof__ (type64)))); int __##name##_pad
> +#else
> +# define __field64(type, type64, name) \
> +  int __##name##_pad __attribute__((__aligned__ (__alignof__ (type64)))); type name
> +#endif
> +
> +struct statfs
> +  {
> +    __SWORD_TYPE f_type;
> +    __SWORD_TYPE f_bsize;
> +    __field64(__fsblkcnt_t, __fsblkcnt64_t, f_blocks);
> +    __field64(__fsblkcnt_t, __fsblkcnt64_t, f_bfree);
> +    __field64(__fsblkcnt_t, __fsblkcnt64_t, f_bavail);
> +    __field64(__fsfilcnt_t, __fsfilcnt64_t, f_files);
> +    __field64(__fsfilcnt_t, __fsfilcnt64_t, f_ffree);
> +    __fsid_t f_fsid;
> +    __SWORD_TYPE f_namelen;
> +    __SWORD_TYPE f_frsize;
> +    __SWORD_TYPE f_flags;
> +    __SWORD_TYPE f_spare[4];
> +  };
> +
> +#undef __field64
> +
> +#ifdef __USE_LARGEFILE64
> +struct statfs64
> +  {
> +    __SWORD_TYPE f_type;
> +    __SWORD_TYPE f_bsize;
> +    __fsblkcnt64_t f_blocks;
> +    __fsblkcnt64_t f_bfree;
> +    __fsblkcnt64_t f_bavail;
> +    __fsfilcnt64_t f_files;
> +    __fsfilcnt64_t f_ffree;
> +    __fsid_t f_fsid;
> +    __SWORD_TYPE f_namelen;
> +    __SWORD_TYPE f_frsize;
> +    __SWORD_TYPE f_flags;
> +    __SWORD_TYPE f_spare[4];
> +  };
> +#endif
> +
> +/* Tell code we have these members.  */
> +#define _STATFS_F_NAMELEN
> +#define _STATFS_F_FRSIZE
> +#define _STATFS_F_FLAGS
> 


-- 
Cheers,
Carlos.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 04/10] linux: Consolidate fstatfs implementations
  2021-02-08 21:49 ` [PATCH 04/10] linux: Consolidate fstatfs implementations Adhemerval Zanella
@ 2021-02-11  0:38   ` Carlos O'Donell
  0 siblings, 0 replies; 27+ messages in thread
From: Carlos O'Donell @ 2021-02-11  0:38 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 2/8/21 4:49 PM, Adhemerval Zanella via Libc-alpha wrote:
> The __NR_fstatfs64 syscall is supported on all architectures but
> aarch64, mips64, riscv64, and x86_64.  And newer ABIs also uses
> the new fstatfs64 interface (where the struct size is used as
> second argument).
> 
> So the default implementation now uses:
> 
>   1. __NR_fstatfs64 for non-LFS call and handle overflow directly
>      There is no need to handle __NR_fstatfs since all architecture
>      that only support is are LFS only.

Agreed.

> 
>   2. __NR_fstatfs if defined or __NR_fstatfs64 otherwise for LFS
>      call.

OK.

> 
> Alpha the only outlier, since it is a 64-bit architecture which
> provides non-LFS interface and only provides __NR_fstatfs64 on
> newer kernels.

LGTM.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

> 
> Checked on x86_64-linux-gnu.
> ---
>  include/sys/statfs.h                          |  7 +-
>  .../{generic/wordsize-32 => alpha}/fstatfs.c  | 13 ++--
>  sysdeps/unix/sysv/linux/alpha/fstatfs64.c     | 52 +++++++++++++-
>  sysdeps/unix/sysv/linux/alpha/syscalls.list   |  1 -
>  sysdeps/unix/sysv/linux/fstatfs.c             | 62 +++++++++++++++++
>  sysdeps/unix/sysv/linux/fstatfs64.c           | 67 +++----------------
>  .../sysv/linux/mips/mips64/n64/fstatfs64.c    |  1 -
>  .../sysv/linux/mips/mips64/n64/syscalls.list  |  1 -
>  .../unix/sysv/linux/wordsize-64/fstatfs64.c   |  1 -
>  .../unix/sysv/linux/wordsize-64/syscalls.list |  1 -
>  10 files changed, 129 insertions(+), 77 deletions(-)
>  rename sysdeps/unix/sysv/linux/{generic/wordsize-32 => alpha}/fstatfs.c (76%)
>  create mode 100644 sysdeps/unix/sysv/linux/fstatfs.c
>  delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n64/fstatfs64.c
>  delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/fstatfs64.c
> 
> diff --git a/include/sys/statfs.h b/include/sys/statfs.h
> index 8a9f5a7b3b..756930a247 100644
> --- a/include/sys/statfs.h
> +++ b/include/sys/statfs.h
> @@ -6,12 +6,11 @@
>  /* Now define the internal interfaces.  */
>  extern int __statfs (const char *__file, struct statfs *__buf);
>  libc_hidden_proto (__statfs)
> -extern int __fstatfs (int __fildes, struct statfs *__buf)
> -     attribute_hidden;
> +extern int __fstatfs (int __fildes, struct statfs *__buf);
> +libc_hidden_proto (__fstatfs)
>  extern int __statfs64 (const char *__file, struct statfs64 *__buf)
>       attribute_hidden;
> -extern int __fstatfs64 (int __fildes, struct statfs64 *__buf)
> -     attribute_hidden;
> +extern int __fstatfs64 (int __fildes, struct statfs64 *__buf);
>  
>  # endif /* !_ISOMAC */
>  #endif
> diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c b/sysdeps/unix/sysv/linux/alpha/fstatfs.c
> similarity index 76%
> rename from sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c
> rename to sysdeps/unix/sysv/linux/alpha/fstatfs.c
> index a611f33128..32c38d0db2 100644
> --- a/sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c
> +++ b/sysdeps/unix/sysv/linux/alpha/fstatfs.c
> @@ -1,6 +1,6 @@
> -/* Copyright (C) 2011-2021 Free Software Foundation, Inc.
> +/* Get filesystem statistics.  Linux/alpha.
> +   Copyright (C) 2011-2021 Free Software Foundation, Inc.
>     This file is part of the GNU C Library.
> -   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
>  
>     The GNU C Library is free software; you can redistribute it and/or
>     modify it under the terms of the GNU Lesser General Public
> @@ -18,18 +18,13 @@
>  
>  #include <sys/statfs.h>
>  #include <kernel_stat.h>
> -#include <stddef.h>
>  #include <sysdep.h>
>  
> -#if !STATFS_IS_STATFS64
> -#include "overflow.h"
> -
>  /* Return information about the filesystem on which FD resides.  */
>  int
>  __fstatfs (int fd, struct statfs *buf)
>  {
> -  int rc = INLINE_SYSCALL (fstatfs64, 3, fd, sizeof (*buf), buf);
> -  return rc ?: statfs_overflow (buf);
> +  return INLINE_SYSCALL_CALL (fstatfs, fd, buf);
>  }
> +libc_hidden_def (__fstatfs)
>  weak_alias (__fstatfs, fstatfs)
> -#endif
> diff --git a/sysdeps/unix/sysv/linux/alpha/fstatfs64.c b/sysdeps/unix/sysv/linux/alpha/fstatfs64.c
> index 5639959adb..0391c08338 100644
> --- a/sysdeps/unix/sysv/linux/alpha/fstatfs64.c
> +++ b/sysdeps/unix/sysv/linux/alpha/fstatfs64.c
> @@ -1 +1,51 @@
> -#include <sysdeps/unix/sysv/linux/fstatfs64.c>
> +/* Get filesystem statistics.  Linux/alpha.
> +   Copyright (C) 1996-2021 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <sys/statfs.h>
> +#include <sysdep.h>
> +#include <kernel_stat.h>
> +
> +/* Return information about the filesystem on which FILE resides.  */
> +int
> +__fstatfs64 (int fd, struct statfs64 *buf)
> +{
> +  int r = INLINE_SYSCALL_CALL (fstatfs64, fd, sizeof (*buf), buf);
> +#if __ASSUME_STATFS64 == 0
> +  if (r == -1 && errno == ENOSYS)
> +    {
> +      struct statfs buf32;
> +      if (__fstatfs (fd, &buf32) < 0)
> +	return -1;
> +
> +      buf->f_type = buf32.f_type;
> +      buf->f_bsize = buf32.f_bsize;
> +      buf->f_blocks = buf32.f_blocks;
> +      buf->f_bfree = buf32.f_bfree;
> +      buf->f_bavail = buf32.f_bavail;
> +      buf->f_files = buf32.f_files;
> +      buf->f_ffree = buf32.f_ffree;
> +      buf->f_fsid = buf32.f_fsid;
> +      buf->f_namelen = buf32.f_namelen;
> +      buf->f_frsize = buf32.f_frsize;
> +      buf->f_flags = buf32.f_flags;
> +      memcpy (buf->f_spare, buf32.f_spare, sizeof (buf32.f_spare));
> +    }
> +#endif
> +  return r;
> +}
> +weak_alias (__fstatfs64, fstatfs64)
> diff --git a/sysdeps/unix/sysv/linux/alpha/syscalls.list b/sysdeps/unix/sysv/linux/alpha/syscalls.list
> index c7cbe886ea..8cb588cb2c 100644
> --- a/sysdeps/unix/sysv/linux/alpha/syscalls.list
> +++ b/sysdeps/unix/sysv/linux/alpha/syscalls.list
> @@ -29,5 +29,4 @@ utimes		-	utimes		i:sp	__utimes	utimes@@GLIBC_2.1
>  getrusage	-	getrusage	i:ip	__getrusage	getrusage@@GLIBC_2.1
>  
>  # avoid 64-bit aliases on 32-bit statfs syscalls
> -fstatfs		-	fstatfs		i:ip	__fstatfs	fstatfs
>  statfs		-	statfs		i:sp	__statfs	statfs
> diff --git a/sysdeps/unix/sysv/linux/fstatfs.c b/sysdeps/unix/sysv/linux/fstatfs.c
> new file mode 100644
> index 0000000000..38d621967e
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/fstatfs.c
> @@ -0,0 +1,62 @@
> +/* Get filesystem statistics.  Linux version.
> +   Copyright (C) 2021 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library.  If not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <sys/statfs.h>
> +#include <time.h>
> +#include <sysdep.h>
> +#include <kernel_stat.h>
> +
> +#if !STATFS_IS_STATFS64
> +
> +/* Return information about the filesystem on which FILE resides.  */
> +int
> +__fstatfs (int fd, struct statfs *buf)
> +{
> +  struct statfs64 buf64;
> +  int rc = INLINE_SYSCALL_CALL (fstatfs64, fd, sizeof (buf64), &buf64);
> +  if (rc != 0)
> +    return rc;
> +
> +  buf->f_type = buf64.f_type;
> +  buf->f_bsize = buf64.f_bsize;
> +  buf->f_blocks = buf64.f_blocks;
> +  buf->f_bfree = buf64.f_bfree;
> +  buf->f_bavail = buf64.f_bavail;
> +  buf->f_files = buf64.f_files;
> +  buf->f_ffree = buf64.f_ffree;
> +  buf->f_fsid = buf64.f_fsid;
> +  buf->f_namelen = buf64.f_namelen;
> +  buf->f_frsize = buf64.f_frsize;
> +  buf->f_flags = buf64.f_flags;
> +  memcpy (buf->f_spare, buf64.f_spare, sizeof (buf64.f_spare));
> +
> +  if ((fsblkcnt_t) buf64.f_blocks != buf64.f_blocks
> +      || (fsblkcnt_t) buf64.f_bfree != buf64.f_bfree
> +      || (fsblkcnt_t) buf64.f_bavail != buf64.f_bavail
> +      || (fsblkcnt_t) buf64.f_files != buf64.f_files
> +      || (fsblkcnt_t) buf64.f_ffree != buf64.f_ffree)
> +   {
> +     __set_errno (EOVERFLOW);
> +     return -1;
> +   }
> +
> +  return 0;
> +}
> +libc_hidden_def (__fstatfs)
> +weak_alias (__fstatfs, fstatfs)
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/fstatfs64.c b/sysdeps/unix/sysv/linux/fstatfs64.c
> index b5ff74d66c..e6aa643477 100644
> --- a/sysdeps/unix/sysv/linux/fstatfs64.c
> +++ b/sysdeps/unix/sysv/linux/fstatfs64.c
> @@ -16,77 +16,28 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -#include <errno.h>
> -#include <string.h>
> -#include <stddef.h>
> +#define __fstatfs __fstatfs_disable
> +#define fstatfs fstatfs_disable
> +#include <sys/statfs.h>
>  #include <sysdep.h>
>  #include <kernel_stat.h>
> -
> -/* Hide the prototypes for __fstatfs and fstatfs so that GCC will not
> -   complain about the different function signatures if they are aliased
> -   to  __fstat64.  If STATFS_IS_STATFS64 is not zero then the statfs and
> -   statfs64 structures have an identical layout but different type names.  */
> -
> -#if STATFS_IS_STATFS64
> -# define __fstatfs __fstatfs_disable
> -# define fstatfs fstatfs_disable
> -#endif
> -#include <sys/statfs.h>
> -
> -#include <kernel-features.h>
> -
> -/* Defined in statfs64.c.  */
> -extern int __no_statfs64 attribute_hidden;
> +#undef __fstatfs
> +#undef fstatfs
>  
>  /* Return information about the filesystem on which FD resides.  */
>  int
>  __fstatfs64 (int fd, struct statfs64 *buf)
>  {
>  #ifdef __NR_fstatfs64
> -# if __ASSUME_STATFS64 == 0
> -  if (! __no_statfs64)
> -# endif
> -    {
> -      int result = INLINE_SYSCALL (fstatfs64, 3, fd, sizeof (*buf), buf);
> -
> -# if __ASSUME_STATFS64 == 0
> -      if (result == 0 || errno != ENOSYS)
> -# endif
> -	return result;
> -
> -# if __ASSUME_STATFS64 == 0
> -      __no_statfs64 = 1;
> -# endif
> -    }
> -#endif
> -
> -#if __ASSUME_STATFS64 == 0
> -  struct statfs buf32;
> -
> -  if (__fstatfs (fd, &buf32) < 0)
> -    return -1;
> -
> -  buf->f_type = buf32.f_type;
> -  buf->f_bsize = buf32.f_bsize;
> -  buf->f_blocks = buf32.f_blocks;
> -  buf->f_bfree = buf32.f_bfree;
> -  buf->f_bavail = buf32.f_bavail;
> -  buf->f_files = buf32.f_files;
> -  buf->f_ffree = buf32.f_ffree;
> -  buf->f_fsid = buf32.f_fsid;
> -  buf->f_namelen = buf32.f_namelen;
> -  buf->f_frsize = buf32.f_frsize;
> -  memcpy (buf->f_spare, buf32.f_spare, sizeof (buf32.f_spare));
> -
> -  return 0;
> +  return INLINE_SYSCALL_CALL (fstatfs64, fd, sizeof (*buf), buf);
> +#else
> +  return INLINE_SYSCALL_CALL (fstatfs, fd, buf);
>  #endif
>  }
>  weak_alias (__fstatfs64, fstatfs64)
>  
> -#undef __fstatfs
> -#undef fstatfs
> -
>  #if STATFS_IS_STATFS64
>  weak_alias (__fstatfs64, __fstatfs)
>  weak_alias (__fstatfs64, fstatfs)
> +libc_hidden_ver (__fstatfs64, __fstatfs)
>  #endif
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/fstatfs64.c b/sysdeps/unix/sysv/linux/mips/mips64/n64/fstatfs64.c
> deleted file mode 100644
> index 6e25b021ab..0000000000
> --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/fstatfs64.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -/* Empty.  */
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
> index 8e7d516a2a..b6a0c92829 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
> @@ -4,7 +4,6 @@ prlimit		EXTRA	prlimit64	i:iipp	prlimit		prlimit64
>  
>  fanotify_mark	EXTRA	fanotify_mark	i:iiiis	fanotify_mark
>  
> -fstatfs		-	fstatfs		i:ip	__fstatfs	fstatfs fstatfs64 __fstatfs64
>  statfs		-	statfs		i:sp	__statfs	statfs statfs64 __statfs64
>  
>  sendfile	-	sendfile	i:iipi	sendfile	sendfile64
> diff --git a/sysdeps/unix/sysv/linux/wordsize-64/fstatfs64.c b/sysdeps/unix/sysv/linux/wordsize-64/fstatfs64.c
> deleted file mode 100644
> index 2be4e59ba4..0000000000
> --- a/sysdeps/unix/sysv/linux/wordsize-64/fstatfs64.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -/* fstatfs64 is the same as fstatfs. */
> diff --git a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
> index 5de6ec823a..5a0c910847 100644
> --- a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
> +++ b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
> @@ -1,6 +1,5 @@
>  # File name	Caller	Syscall name	# args	Strong name	Weak names
>  
> -fstatfs		-	fstatfs		i:ip	__fstatfs	fstatfs fstatfs64 __fstatfs64
>  statfs		-	statfs		i:sp	__statfs	statfs statfs64
>  sendfile	-	sendfile	i:iipi	sendfile	sendfile64
>  prlimit		EXTRA	prlimit64	i:iipp	prlimit		prlimit64
> 


-- 
Cheers,
Carlos.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 05/10] linux: Consolidate statfs implementations
  2021-02-08 21:49 ` [PATCH 05/10] linux: Consolidate statfs implementations Adhemerval Zanella
@ 2021-02-11  0:38   ` Carlos O'Donell
  0 siblings, 0 replies; 27+ messages in thread
From: Carlos O'Donell @ 2021-02-11  0:38 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 2/8/21 4:49 PM, Adhemerval Zanella via Libc-alpha wrote:
> The __NR_statfs64 syscall is supported on all architectures but
> aarch64, mips64, riscv64, and x86_64.  And newer ABIs also uses
> the new statfs64 interface (where the struct size is used as
> second argument).
> 
> So the default implementation now uses:
> 
>   1. __NR_statfs64 for non-LFS call and handle overflow directly
>      There is no need to handle __NR_statfs since all architecture
>      that only support is are LFS only.

OK.

>   2. __NR_statfs if defined or __NR_statfs64 otherwise for LFS
>      call.

OK.

> Alpha is the only outlier, since it is a 64-bit architecture which
> provides non-LFS interface and only provides __NR_fstatfs64 on
> newer kernels.

OK.

LGTM.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

> Checked on x86_64-linux-gnu.
> ---
>  .../{generic/wordsize-32 => alpha}/statfs.c   | 16 ++---
>  sysdeps/unix/sysv/linux/alpha/statfs64.c      | 52 +++++++++++++-
>  sysdeps/unix/sysv/linux/alpha/syscalls.list   |  3 -
>  .../sysv/linux/mips/mips64/n64/statfs64.c     |  1 -
>  .../sysv/linux/mips/mips64/n64/syscalls.list  |  2 -
>  sysdeps/unix/sysv/linux/statfs.c              | 61 ++++++++++++++++
>  sysdeps/unix/sysv/linux/statfs64.c            | 69 +++----------------
>  .../unix/sysv/linux/wordsize-64/statfs64.c    |  1 -
>  .../unix/sysv/linux/wordsize-64/syscalls.list |  1 -
>  9 files changed, 125 insertions(+), 81 deletions(-)
>  rename sysdeps/unix/sysv/linux/{generic/wordsize-32 => alpha}/statfs.c (72%)
>  delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n64/statfs64.c
>  create mode 100644 sysdeps/unix/sysv/linux/statfs.c
>  delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/statfs64.c
> 
> diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c b/sysdeps/unix/sysv/linux/alpha/statfs.c
> similarity index 72%
> rename from sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c
> rename to sysdeps/unix/sysv/linux/alpha/statfs.c
> index 2c51fbf1b0..33789768ed 100644
> --- a/sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c
> +++ b/sysdeps/unix/sysv/linux/alpha/statfs.c
> @@ -1,6 +1,6 @@
> -/* Copyright (C) 2011-2021 Free Software Foundation, Inc.
> +/* Return information about the filesystem on which FILE resides.  Linux/alpha.
> +   Copyright (C) 1996-2021 Free Software Foundation, Inc.
>     This file is part of the GNU C Library.
> -   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
>  
>     The GNU C Library is free software; you can redistribute it and/or
>     modify it under the terms of the GNU Lesser General Public
> @@ -13,24 +13,18 @@
>     Lesser General Public License for more details.
>  
>     You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library.  If not, see
> +   License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -#include <errno.h>
>  #include <sys/statfs.h>
> -#include <kernel_stat.h>
>  #include <sysdep.h>
> -
> -#if !STATFS_IS_STATFS64
> -#include "overflow.h"
> +#include <kernel_stat.h>
>  
>  /* Return information about the filesystem on which FILE resides.  */
>  int
>  __statfs (const char *file, struct statfs *buf)
>  {
> -  int rc = INLINE_SYSCALL (statfs64, 3, file, sizeof (*buf), buf);
> -  return rc ?: statfs_overflow (buf);
> +  return INLINE_SYSCALL_CALL (statfs, file, buf);
>  }
>  libc_hidden_def (__statfs)
>  weak_alias (__statfs, statfs)
> -#endif
> diff --git a/sysdeps/unix/sysv/linux/alpha/statfs64.c b/sysdeps/unix/sysv/linux/alpha/statfs64.c
> index fe39cc4685..083b9a59f3 100644
> --- a/sysdeps/unix/sysv/linux/alpha/statfs64.c
> +++ b/sysdeps/unix/sysv/linux/alpha/statfs64.c
> @@ -1 +1,51 @@
> -#include <sysdeps/unix/sysv/linux/statfs64.c>
> +/* Return information about the filesystem on which FILE resides.  Linux/alpha.
> +   Copyright (C) 1996-2021 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <sys/statfs.h>
> +#include <sysdep.h>
> +#include <kernel_stat.h>
> +
> +/* Return information about the filesystem on which FILE resides.  */
> +int
> +__statfs64 (const char *file, struct statfs64 *buf)
> +{
> +  int r = INLINE_SYSCALL_CALL (statfs64, file, sizeof (*buf), buf);
> +#if __ASSUME_STATFS64 == 0
> +  if (r == -1 && errno == ENOSYS)
> +    {
> +      struct statfs buf32;
> +      if (__statfs (file, &buf32) < 0)
> +	return -1;
> +
> +      buf->f_type = buf32.f_type;
> +      buf->f_bsize = buf32.f_bsize;
> +      buf->f_blocks = buf32.f_blocks;
> +      buf->f_bfree = buf32.f_bfree;
> +      buf->f_bavail = buf32.f_bavail;
> +      buf->f_files = buf32.f_files;
> +      buf->f_ffree = buf32.f_ffree;
> +      buf->f_fsid = buf32.f_fsid;
> +      buf->f_namelen = buf32.f_namelen;
> +      buf->f_frsize = buf32.f_frsize;
> +      buf->f_flags = buf32.f_flags;
> +      memcpy (buf->f_spare, buf32.f_spare, sizeof (buf32.f_spare));
> +    }
> +#endif
> +  return r;
> +}
> +weak_alias (__statfs64, statfs64)
> diff --git a/sysdeps/unix/sysv/linux/alpha/syscalls.list b/sysdeps/unix/sysv/linux/alpha/syscalls.list
> index 8cb588cb2c..c848fcbd99 100644
> --- a/sysdeps/unix/sysv/linux/alpha/syscalls.list
> +++ b/sysdeps/unix/sysv/linux/alpha/syscalls.list
> @@ -27,6 +27,3 @@ getitimer	-	getitimer	i:ip	__getitimer	getitimer@@GLIBC_2.1
>  setitimer	-	setitimer	i:ipP	__setitimer	setitimer@@GLIBC_2.1
>  utimes		-	utimes		i:sp	__utimes	utimes@@GLIBC_2.1
>  getrusage	-	getrusage	i:ip	__getrusage	getrusage@@GLIBC_2.1
> -
> -# avoid 64-bit aliases on 32-bit statfs syscalls
> -statfs		-	statfs		i:sp	__statfs	statfs
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/statfs64.c b/sysdeps/unix/sysv/linux/mips/mips64/n64/statfs64.c
> deleted file mode 100644
> index 6e25b021ab..0000000000
> --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/statfs64.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -/* Empty.  */
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
> index b6a0c92829..e4e16dfa49 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
> @@ -4,6 +4,4 @@ prlimit		EXTRA	prlimit64	i:iipp	prlimit		prlimit64
>  
>  fanotify_mark	EXTRA	fanotify_mark	i:iiiis	fanotify_mark
>  
> -statfs		-	statfs		i:sp	__statfs	statfs statfs64 __statfs64
> -
>  sendfile	-	sendfile	i:iipi	sendfile	sendfile64
> diff --git a/sysdeps/unix/sysv/linux/statfs.c b/sysdeps/unix/sysv/linux/statfs.c
> new file mode 100644
> index 0000000000..ee248b4212
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/statfs.c
> @@ -0,0 +1,61 @@
> +/* Copyright (C) 2011-2021 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library.  If not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <sys/statfs.h>
> +#include <time.h>
> +#include <sysdep.h>
> +#include <kernel_stat.h>
> +
> +#if !STATFS_IS_STATFS64
> +
> +/* Return information about the filesystem on which FILE resides.  */
> +int
> +__statfs (const char *file, struct statfs *buf)
> +{
> +  struct statfs64 buf64;
> +  int rc = INLINE_SYSCALL_CALL (statfs64, file, sizeof (buf64), &buf64);
> +  if (rc == 0)
> +    {
> +      buf->f_type = buf64.f_type;
> +      buf->f_bsize = buf64.f_bsize;
> +      buf->f_blocks = buf64.f_blocks;
> +      buf->f_bfree = buf64.f_bfree;
> +      buf->f_bavail = buf64.f_bavail;
> +      buf->f_files = buf64.f_files;
> +      buf->f_ffree = buf64.f_ffree;
> +      buf->f_fsid = buf64.f_fsid;
> +      buf->f_namelen = buf64.f_namelen;
> +      buf->f_frsize = buf64.f_frsize;
> +      buf->f_flags = buf64.f_flags;
> +      memcpy (buf->f_spare, buf64.f_spare, sizeof (buf64.f_spare));
> +
> +      if ((fsblkcnt_t) buf64.f_blocks != buf64.f_blocks
> +	  || (fsblkcnt_t) buf64.f_bfree != buf64.f_bfree
> +	  || (fsblkcnt_t) buf64.f_bavail != buf64.f_bavail
> +	  || (fsblkcnt_t) buf64.f_files != buf64.f_files
> +	  || (fsblkcnt_t) buf64.f_ffree != buf64.f_ffree)
> +	{
> +	  __set_errno (EOVERFLOW);
> +	  return -1;
> +	}
> +    }
> +  return rc;
> +}
> +libc_hidden_def (__statfs)
> +weak_alias (__statfs, statfs)
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/statfs64.c b/sysdeps/unix/sysv/linux/statfs64.c
> index c52b3d8ae6..4f68212e9f 100644
> --- a/sysdeps/unix/sysv/linux/statfs64.c
> +++ b/sysdeps/unix/sysv/linux/statfs64.c
> @@ -16,79 +16,26 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -#include <errno.h>
> -#include <string.h>
> -#include <stddef.h>
> +#define __statfs __statfs_disable
> +#define statfs statfs_disable
> +#include <sys/statfs.h>
>  #include <sysdep.h>
>  #include <kernel_stat.h>
> -
> -/* Hide the prototypes for __statfs and statfs so that GCC will not
> -   complain about the different function signatures if they are aliased
> -   to  __stat64.  If STATFS_IS_STATFS64 is not zero then the statfs and
> -   statfs64 structures have an identical layout but different type names.  */
> -
> -#if STATFS_IS_STATFS64
> -# define __statfs __statfs_disable
> -# define statfs statfs_disable
> -#endif
> -#include <sys/statfs.h>
> -
> -#include <kernel-features.h>
> -
> -
> -# if __ASSUME_STATFS64 == 0
> -int __no_statfs64 attribute_hidden;
> -#endif
> +#undef __statfs
> +#undef statfs
>  
>  /* Return information about the filesystem on which FILE resides.  */
>  int
>  __statfs64 (const char *file, struct statfs64 *buf)
>  {
>  #ifdef __NR_statfs64
> -# if __ASSUME_STATFS64 == 0
> -  if (! __no_statfs64)
> -# endif
> -    {
> -      int result = INLINE_SYSCALL (statfs64, 3, file, sizeof (*buf), buf);
> -
> -# if __ASSUME_STATFS64 == 0
> -      if (result == 0 || errno != ENOSYS)
> -# endif
> -	return result;
> -
> -# if __ASSUME_STATFS64 == 0
> -      __no_statfs64 = 1;
> -# endif
> -    }
> -#endif
> -
> -#if __ASSUME_STATFS64 == 0
> -  struct statfs buf32;
> -
> -  if (__statfs (file, &buf32) < 0)
> -    return -1;
> -
> -  buf->f_type = buf32.f_type;
> -  buf->f_bsize = buf32.f_bsize;
> -  buf->f_blocks = buf32.f_blocks;
> -  buf->f_bfree = buf32.f_bfree;
> -  buf->f_bavail = buf32.f_bavail;
> -  buf->f_files = buf32.f_files;
> -  buf->f_ffree = buf32.f_ffree;
> -  buf->f_fsid = buf32.f_fsid;
> -  buf->f_namelen = buf32.f_namelen;
> -  buf->f_frsize = buf32.f_frsize;
> -  buf->f_flags = buf32.f_flags;
> -  memcpy (buf->f_spare, buf32.f_spare, sizeof (buf32.f_spare));
> -
> -  return 0;
> +  return INLINE_SYSCALL_CALL (statfs64, file, sizeof (*buf), buf);
> +#else
> +  return INLINE_SYSCALL_CALL (statfs, file, buf);
>  #endif
>  }
>  weak_alias (__statfs64, statfs64)
>  
> -#undef __statfs
> -#undef statfs
> -
>  #if STATFS_IS_STATFS64
>  weak_alias (__statfs64, __statfs)
>  weak_alias (__statfs64, statfs)
> diff --git a/sysdeps/unix/sysv/linux/wordsize-64/statfs64.c b/sysdeps/unix/sysv/linux/wordsize-64/statfs64.c
> deleted file mode 100644
> index 06bc68826f..0000000000
> --- a/sysdeps/unix/sysv/linux/wordsize-64/statfs64.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -/* statfs64 is the same as statfs. */
> diff --git a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
> index 5a0c910847..68e3c60536 100644
> --- a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
> +++ b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
> @@ -1,6 +1,5 @@
>  # File name	Caller	Syscall name	# args	Strong name	Weak names
>  
> -statfs		-	statfs		i:sp	__statfs	statfs statfs64
>  sendfile	-	sendfile	i:iipi	sendfile	sendfile64
>  prlimit		EXTRA	prlimit64	i:iipp	prlimit		prlimit64
>  
> 


-- 
Cheers,
Carlos.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 06/10] linux: Consolidate fstatvfs implementations
  2021-02-08 21:49 ` [PATCH 06/10] linux: Consolidate fstatvfs implementations Adhemerval Zanella
@ 2021-02-11  0:38   ` Carlos O'Donell
  0 siblings, 0 replies; 27+ messages in thread
From: Carlos O'Donell @ 2021-02-11  0:38 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 2/8/21 4:49 PM, Adhemerval Zanella via Libc-alpha wrote:
> There is no need to handle ENOSYS on fstatfs64 call, required only
> for alpha (where is already fallbacks to fstatfs).  The wordsize
> internal_statvfs64.c is removed, since how the LFS support is
> provided by fstatvfs64.c (used on 64-bit architectures as well).

LGTM.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
 
> Checked on x86_64-linux-gnu.
> ---
>  sysdeps/unix/sysv/linux/alpha/fstatvfs.c      |  1 -
>  sysdeps/unix/sysv/linux/alpha/fstatvfs64.c    |  1 -
>  sysdeps/unix/sysv/linux/fstatvfs.c            |  9 ++--
>  sysdeps/unix/sysv/linux/fstatvfs64.c          | 53 +++++++------------
>  .../unix/sysv/linux/wordsize-64/fstatvfs.c    |  5 --
>  .../unix/sysv/linux/wordsize-64/fstatvfs64.c  |  1 -
>  .../linux/wordsize-64/internal_statvfs64.c    |  1 -
>  7 files changed, 25 insertions(+), 46 deletions(-)
>  delete mode 100644 sysdeps/unix/sysv/linux/alpha/fstatvfs.c
>  delete mode 100644 sysdeps/unix/sysv/linux/alpha/fstatvfs64.c
>  delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/fstatvfs.c
>  delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/fstatvfs64.c
>  delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/internal_statvfs64.c
> 
> diff --git a/sysdeps/unix/sysv/linux/alpha/fstatvfs.c b/sysdeps/unix/sysv/linux/alpha/fstatvfs.c
> deleted file mode 100644
> index 92e772347b..0000000000
> --- a/sysdeps/unix/sysv/linux/alpha/fstatvfs.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/fstatvfs.c>
> diff --git a/sysdeps/unix/sysv/linux/alpha/fstatvfs64.c b/sysdeps/unix/sysv/linux/alpha/fstatvfs64.c
> deleted file mode 100644
> index 0f1e71027a..0000000000
> --- a/sysdeps/unix/sysv/linux/alpha/fstatvfs64.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/fstatvfs64.c>
> diff --git a/sysdeps/unix/sysv/linux/fstatvfs.c b/sysdeps/unix/sysv/linux/fstatvfs.c
> index 8b67951ab6..0f56a13ca9 100644
> --- a/sysdeps/unix/sysv/linux/fstatvfs.c
> +++ b/sysdeps/unix/sysv/linux/fstatvfs.c
> @@ -16,11 +16,13 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -#include <stddef.h>
> -#include <sys/stat.h>
> +#include <sys/statvfs.h>
>  #include <sys/statfs.h>
> -#include "internal_statvfs.h"
> +#include <internal_statvfs.h>
> +#include <time.h>
> +#include <kernel_stat.h>
>  
> +#if !STATFS_IS_STATFS64
>  int
>  __fstatvfs (int fd, struct statvfs *buf)
>  {
> @@ -38,3 +40,4 @@ __fstatvfs (int fd, struct statvfs *buf)
>  }
>  weak_alias (__fstatvfs, fstatvfs)
>  libc_hidden_weak (fstatvfs)
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/fstatvfs64.c b/sysdeps/unix/sysv/linux/fstatvfs64.c
> index 6d2dbc5285..b95745e8b8 100644
> --- a/sysdeps/unix/sysv/linux/fstatvfs64.c
> +++ b/sysdeps/unix/sysv/linux/fstatvfs64.c
> @@ -16,48 +16,33 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -#include <errno.h>
> -#include <string.h>
> -#include <sys/stat.h>
> +#define __fstatvfs __fstatvfs_disable
> +#define fstatvfs fstatvfs_disable
> +#include <sys/statvfs.h>
>  #include <sys/statfs.h>
> -#include "internal_statvfs.h"
> -#include <kernel-features.h>
> +#include <internal_statvfs.h>
> +#include <time.h>
> +#include <kernel_stat.h>
>  
>  /* Return information about the filesystem on which FD resides.  */
>  int
>  __fstatvfs64 (int fd, struct statvfs64 *buf)
>  {
>    struct statfs64 fsbuf;
> -  int res = __fstatfs64 (fd, &fsbuf);
> -
> -#ifndef __ASSUME_STATFS64
> -  if (res < 0 && errno == ENOSYS)
> -    {
> -      struct statvfs buf32;
> -
> -      res = fstatvfs (fd, &buf32);
> -      if (res == 0)
> -	{
> -	  buf->f_bsize = buf32.f_bsize;
> -	  buf->f_frsize = buf32.f_frsize;
> -	  buf->f_blocks = buf32.f_blocks;
> -	  buf->f_bfree = buf32.f_bfree;
> -	  buf->f_bavail = buf32.f_bavail;
> -	  buf->f_files = buf32.f_files;
> -	  buf->f_ffree = buf32.f_ffree;
> -	  buf->f_favail = buf32.f_favail;
> -	  buf->f_fsid = buf32.f_fsid;
> -	  buf->f_flag = buf32.f_flag;
> -	  buf->f_namemax = buf32.f_namemax;
> -	  memcpy (buf->__f_spare, buf32.__f_spare, sizeof (buf32.__f_spare));
> -	}
> -    }
> -#endif
> +  if (__fstatfs64 (fd, &fsbuf) < 0)
> +    return -1;
>  
> -  if (res == 0)
> -    /* Convert the result.  */
> -    __internal_statvfs64 (NULL, buf, &fsbuf, fd);
> +  /* Convert the result.  */
> +  __internal_statvfs64 (NULL, buf, &fsbuf, fd);
>  
> -  return res;
> +  return 0;
>  }
>  weak_alias (__fstatvfs64, fstatvfs64)
> +
> +#undef __fstatvfs
> +#undef fstatvfs
> +
> +#if STATFS_IS_STATFS64
> +weak_alias (__fstatvfs64, __fstatvfs)
> +weak_alias (__fstatvfs64, fstatvfs)
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/wordsize-64/fstatvfs.c b/sysdeps/unix/sysv/linux/wordsize-64/fstatvfs.c
> deleted file mode 100644
> index 5803b6f882..0000000000
> --- a/sysdeps/unix/sysv/linux/wordsize-64/fstatvfs.c
> +++ /dev/null
> @@ -1,5 +0,0 @@
> -#define __fstatvfs64(file, buf) __no_fstatvfs64(file, buf)
> -#define fstatvfs64(file, buf) no_fstatvfs64(file, buf)
> -#include "../fstatvfs.c"
> -strong_alias (__fstatvfs, __fstatvfs64)
> -weak_alias (__fstatvfs, fstatvfs64)
> diff --git a/sysdeps/unix/sysv/linux/wordsize-64/fstatvfs64.c b/sysdeps/unix/sysv/linux/wordsize-64/fstatvfs64.c
> deleted file mode 100644
> index 60f3dfec61..0000000000
> --- a/sysdeps/unix/sysv/linux/wordsize-64/fstatvfs64.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -/* fstatvfs64 is the same as fstatvfs. */
> diff --git a/sysdeps/unix/sysv/linux/wordsize-64/internal_statvfs64.c b/sysdeps/unix/sysv/linux/wordsize-64/internal_statvfs64.c
> deleted file mode 100644
> index d2a3509c6d..0000000000
> --- a/sysdeps/unix/sysv/linux/wordsize-64/internal_statvfs64.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -/* Nothing.  */
> 


-- 
Cheers,
Carlos.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 07/10] linux: Consolidate statvfs implementations
  2021-02-08 21:49 ` [PATCH 07/10] linux: Consolidate statvfs implementations Adhemerval Zanella
@ 2021-02-11  0:38   ` Carlos O'Donell
  0 siblings, 0 replies; 27+ messages in thread
From: Carlos O'Donell @ 2021-02-11  0:38 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 2/8/21 4:49 PM, Adhemerval Zanella via Libc-alpha wrote:
> There is no need to handle ENOSYS on fstatfs64 call, required only
> for alpha (where is already fallbacks to fstatfs).
> 
> Checked on x86_64-linux-gnu.

LGTM.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

> ---
>  include/sys/statvfs.h                         |  3 +-
>  sysdeps/unix/sysv/linux/alpha/statvfs.c       |  1 -
>  sysdeps/unix/sysv/linux/alpha/statvfs64.c     |  1 -
>  sysdeps/unix/sysv/linux/statvfs.c             |  9 ++--
>  sysdeps/unix/sysv/linux/statvfs64.c           | 54 +++++++------------
>  sysdeps/unix/sysv/linux/wordsize-64/statvfs.c |  5 --
>  .../unix/sysv/linux/wordsize-64/statvfs64.c   |  1 -
>  7 files changed, 26 insertions(+), 48 deletions(-)
>  delete mode 100644 sysdeps/unix/sysv/linux/alpha/statvfs.c
>  delete mode 100644 sysdeps/unix/sysv/linux/alpha/statvfs64.c
>  delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/statvfs.c
>  delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/statvfs64.c
> 
> diff --git a/include/sys/statvfs.h b/include/sys/statvfs.h
> index 4cd1977c35..d7fe33119a 100644
> --- a/include/sys/statvfs.h
> +++ b/include/sys/statvfs.h
> @@ -3,8 +3,7 @@
>  
>  #ifndef _ISOMAC
>  /* Now define the internal interfaces.  */
> -extern int __statvfs64 (const char *__file, struct statvfs64 *__buf)
> -     attribute_hidden;
> +extern int __statvfs64 (const char *__file, struct statvfs64 *__buf);

OK.

>  extern int __fstatvfs64 (int __fildes, struct statvfs64 *__buf)
>       attribute_hidden;
>  
> diff --git a/sysdeps/unix/sysv/linux/alpha/statvfs.c b/sysdeps/unix/sysv/linux/alpha/statvfs.c
> deleted file mode 100644
> index 78069e96f4..0000000000
> --- a/sysdeps/unix/sysv/linux/alpha/statvfs.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/statvfs.c>
> diff --git a/sysdeps/unix/sysv/linux/alpha/statvfs64.c b/sysdeps/unix/sysv/linux/alpha/statvfs64.c
> deleted file mode 100644
> index c80e17751d..0000000000
> --- a/sysdeps/unix/sysv/linux/alpha/statvfs64.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/statvfs64.c>
> diff --git a/sysdeps/unix/sysv/linux/statvfs.c b/sysdeps/unix/sysv/linux/statvfs.c
> index 8895694e5d..f165899711 100644
> --- a/sysdeps/unix/sysv/linux/statvfs.c
> +++ b/sysdeps/unix/sysv/linux/statvfs.c
> @@ -16,11 +16,13 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -#include <stddef.h>
> -#include <sys/stat.h>
> +#include <sys/statvfs.h>
>  #include <sys/statfs.h>
> -#include "internal_statvfs.h"
> +#include <internal_statvfs.h>
> +#include <time.h>
> +#include <kernel_stat.h>
>  
> +#if !STATFS_IS_STATFS64
>  int
>  __statvfs (const char *file, struct statvfs *buf)
>  {
> @@ -38,3 +40,4 @@ __statvfs (const char *file, struct statvfs *buf)
>  }
>  weak_alias (__statvfs, statvfs)
>  libc_hidden_weak (statvfs)
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/statvfs64.c b/sysdeps/unix/sysv/linux/statvfs64.c
> index b03a88816c..3d29908afa 100644
> --- a/sysdeps/unix/sysv/linux/statvfs64.c
> +++ b/sysdeps/unix/sysv/linux/statvfs64.c
> @@ -16,49 +16,33 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -#include <errno.h>
> -#include <stddef.h>
> -#include <string.h>
> -#include <sys/stat.h>
> +#define __statvfs __statvfs_disable
> +#define statvfs statvfs_disable
> +#include <sys/statvfs.h>
>  #include <sys/statfs.h>
> -#include "internal_statvfs.h"
> -#include <kernel-features.h>
> +#include <internal_statvfs.h>
> +#include <time.h>
> +#include <kernel_stat.h>
>  
>  /* Return information about the filesystem on which FILE resides.  */
>  int
>  __statvfs64 (const char *file, struct statvfs64 *buf)
>  {
>    struct statfs64 fsbuf;
> -  int res = __statfs64 (file, &fsbuf);
> +  if (__statfs64 (file, &fsbuf) < 0)
> +    return -1;
>  
> -#ifndef __ASSUME_STATFS64
> -  if (res < 0 && errno == ENOSYS)
> -    {
> -      struct statvfs buf32;
> +  /* Convert the result.  */
> +  __internal_statvfs64 (file, buf, &fsbuf, -1);
>  
> -      res = statvfs (file, &buf32);
> -      if (res == 0)
> -	{
> -	  buf->f_bsize = buf32.f_bsize;
> -	  buf->f_frsize = buf32.f_frsize;
> -	  buf->f_blocks = buf32.f_blocks;
> -	  buf->f_bfree = buf32.f_bfree;
> -	  buf->f_bavail = buf32.f_bavail;
> -	  buf->f_files = buf32.f_files;
> -	  buf->f_ffree = buf32.f_ffree;
> -	  buf->f_favail = buf32.f_favail;
> -	  buf->f_fsid = buf32.f_fsid;
> -	  buf->f_flag = buf32.f_flag;
> -	  buf->f_namemax = buf32.f_namemax;
> -	  memcpy (buf->__f_spare, buf32.__f_spare, sizeof (buf32.__f_spare));
> -	}
> -    }
> -#endif
> -
> -  if (res == 0)
> -    /* Convert the result.  */
> -    __internal_statvfs64 (file, buf, &fsbuf, -1);
> -
> -  return res;
> +  return 0;
>  }
>  weak_alias (__statvfs64, statvfs64)
> +
> +#undef __statvfs
> +#undef statvfs
> +
> +#if STATFS_IS_STATFS64
> +weak_alias (__statvfs64, __statvfs)
> +weak_alias (__statvfs64, statvfs)
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/wordsize-64/statvfs.c b/sysdeps/unix/sysv/linux/wordsize-64/statvfs.c
> deleted file mode 100644
> index 1e1c96333b..0000000000
> --- a/sysdeps/unix/sysv/linux/wordsize-64/statvfs.c
> +++ /dev/null
> @@ -1,5 +0,0 @@
> -#define __statvfs64(file, buf) __no_statvfs64(file, buf)
> -#define statvfs64(file, buf) no_statvfs64(file, buf)
> -#include "../statvfs.c"
> -strong_alias (__statvfs, __statvfs64)
> -weak_alias (__statvfs, statvfs64)
> diff --git a/sysdeps/unix/sysv/linux/wordsize-64/statvfs64.c b/sysdeps/unix/sysv/linux/wordsize-64/statvfs64.c
> deleted file mode 100644
> index 510015e420..0000000000
> --- a/sysdeps/unix/sysv/linux/wordsize-64/statvfs64.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -/* statvfs64 is the same as statvfs. */
> 


-- 
Cheers,
Carlos.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 08/10] linux: Consolidate internal_statvfs
  2021-02-08 21:49 ` [PATCH 08/10] linux: Consolidate internal_statvfs Adhemerval Zanella
@ 2021-02-11  0:38   ` Carlos O'Donell
  0 siblings, 0 replies; 27+ messages in thread
From: Carlos O'Donell @ 2021-02-11  0:38 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 2/8/21 4:49 PM, Adhemerval Zanella via Libc-alpha wrote:
> Remove the internal_statvfs64.c and open code the implementation
> on internal_statvfs.c.  The alpha is now unrequired, the generic
> implementation also handles it.
> 
> Also, removed unused includes on internal_statvfs.c, and remove
> unused arguments on __internal_statvfs{64}.

Cleans up the interfaces.

LGTM.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

> ---
>  sysdeps/unix/sysv/linux/Makefile              |  2 +-
>  .../sysv/linux/alpha/internal_statvfs64.c     |  1 -
>  sysdeps/unix/sysv/linux/fstatvfs.c            |  2 +-
>  sysdeps/unix/sysv/linux/fstatvfs64.c          |  2 +-
>  sysdeps/unix/sysv/linux/internal_statvfs.c    | 70 +++++++++++++------
>  sysdeps/unix/sysv/linux/internal_statvfs.h    |  8 +--
>  sysdeps/unix/sysv/linux/internal_statvfs64.c  |  4 --
>  sysdeps/unix/sysv/linux/statvfs.c             |  2 +-
>  sysdeps/unix/sysv/linux/statvfs64.c           |  2 +-
>  9 files changed, 56 insertions(+), 37 deletions(-)
>  delete mode 100644 sysdeps/unix/sysv/linux/alpha/internal_statvfs64.c
>  delete mode 100644 sysdeps/unix/sysv/linux/internal_statvfs64.c
> 
> diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
> index a0a6dcef17..488114a41e 100644
> --- a/sysdeps/unix/sysv/linux/Makefile
> +++ b/sysdeps/unix/sysv/linux/Makefile
> @@ -273,7 +273,7 @@ CFLAGS-ypclnt.c = -DUSE_BINDINGDIR=1
>  endif
>  
>  ifeq ($(subdir),io)
> -sysdep_routines += xstatconv internal_statvfs internal_statvfs64 \
> +sysdep_routines += xstatconv internal_statvfs \
>  		   sync_file_range fallocate fallocate64 \
>  		   close_nocancel fcntl_nocancel \
>  		   open_nocancel open64_nocancel \
> diff --git a/sysdeps/unix/sysv/linux/alpha/internal_statvfs64.c b/sysdeps/unix/sysv/linux/alpha/internal_statvfs64.c
> deleted file mode 100644
> index 81d18f7bb2..0000000000
> --- a/sysdeps/unix/sysv/linux/alpha/internal_statvfs64.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/internal_statvfs64.c>
> diff --git a/sysdeps/unix/sysv/linux/fstatvfs.c b/sysdeps/unix/sysv/linux/fstatvfs.c
> index 0f56a13ca9..ba3fd22cfb 100644
> --- a/sysdeps/unix/sysv/linux/fstatvfs.c
> +++ b/sysdeps/unix/sysv/linux/fstatvfs.c
> @@ -33,7 +33,7 @@ __fstatvfs (int fd, struct statvfs *buf)
>      return -1;
>  
>    /* Convert the result.  */
> -  __internal_statvfs (NULL, buf, &fsbuf, fd);
> +  __internal_statvfs (buf, &fsbuf);
>  
>    /* We signal success if the statfs call succeeded.  */
>    return 0;
> diff --git a/sysdeps/unix/sysv/linux/fstatvfs64.c b/sysdeps/unix/sysv/linux/fstatvfs64.c
> index b95745e8b8..ba869f594c 100644
> --- a/sysdeps/unix/sysv/linux/fstatvfs64.c
> +++ b/sysdeps/unix/sysv/linux/fstatvfs64.c
> @@ -33,7 +33,7 @@ __fstatvfs64 (int fd, struct statvfs64 *buf)
>      return -1;
>  
>    /* Convert the result.  */
> -  __internal_statvfs64 (NULL, buf, &fsbuf, fd);
> +  __internal_statvfs64 (buf, &fsbuf);
>  
>    return 0;
>  }
> diff --git a/sysdeps/unix/sysv/linux/internal_statvfs.c b/sysdeps/unix/sysv/linux/internal_statvfs.c
> index 4d9064141c..39fcb5d429 100644
> --- a/sysdeps/unix/sysv/linux/internal_statvfs.c
> +++ b/sysdeps/unix/sysv/linux/internal_statvfs.c
> @@ -16,37 +16,61 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -#include <assert.h>
> -#include <errno.h>
> -#include <mntent.h>
> -#include <paths.h>
> -#include <stdbool.h>
> -#include <stdio_ext.h>
> -#include <string.h>
> -#include <sys/mount.h>
> -#include <sys/stat.h>
>  #include <sys/statfs.h>
> -#include "internal_statvfs.h"
> -#include "linux_fsinfo.h"
> -#include <kernel-features.h>
> -
> +#include <sys/statvfs.h>
> +#include <internal_statvfs.h>
> +#include <string.h>
> +#include <time.h>
> +#include <kernel_stat.h>
>  
>  /* Special internal-only bit value.  */
> -#define ST_VALID 0x0020
> +# define ST_VALID 0x0020
>  
> -
> -#ifndef STATFS
> -# define STATFS statfs
> -# define STATVFS statvfs
> -# define INTERNAL_STATVFS __internal_statvfs
> -#else
> -extern int __statvfs_getflags (const char *name, int fstype, int fd);
> +#if !STATFS_IS_STATFS64
> +void
> +__internal_statvfs (struct statvfs *buf, const struct statfs *fsbuf)
> +{
> +  /* Now fill in the fields we have information for.  */
> +  buf->f_bsize = fsbuf->f_bsize;
> +  /* Linux has the f_frsize size only in later version of the kernel.
> +     If the value is not filled in use f_bsize.  */
> +  buf->f_frsize = fsbuf->f_frsize ?: fsbuf->f_bsize;
> +  buf->f_blocks = fsbuf->f_blocks;
> +  buf->f_bfree = fsbuf->f_bfree;
> +  buf->f_bavail = fsbuf->f_bavail;
> +  buf->f_files = fsbuf->f_files;
> +  buf->f_ffree = fsbuf->f_ffree;
> +  if (sizeof (buf->f_fsid) == sizeof (fsbuf->f_fsid))
> +    /* The shifting uses 'unsigned long long int' even though the target
> +       field might only have 32 bits.  This is OK since the 'if' branch
> +       is not used in this case but the compiler would still generate
> +       warnings.  */
> +    buf->f_fsid = ((fsbuf->f_fsid.__val[0]
> +		    & ((1ULL << (8 * sizeof (fsbuf->f_fsid.__val[0]))) - 1))
> +		   | ((unsigned long long int) fsbuf->f_fsid.__val[1]
> +		      << (8 * (sizeof (buf->f_fsid)
> +			       - sizeof (fsbuf->f_fsid.__val[0])))));
> +  else
> +    /* We cannot help here.  The statvfs element is not large enough to
> +       contain both words of the statfs f_fsid field.  */
> +    buf->f_fsid = fsbuf->f_fsid.__val[0];
> +#ifdef _STATVFSBUF_F_UNUSED
> +  buf->__f_unused = 0;
>  #endif
> +  buf->f_namemax = fsbuf->f_namelen;
> +  memset (buf->__f_spare, '\0', sizeof (buf->__f_spare));
> +
> +  /* What remains to do is to fill the fields f_favail and f_flag.  */
> +
> +  /* XXX I have no idea how to compute f_favail.  Any idea???  */
> +  buf->f_favail = buf->f_ffree;
>  
> +  buf->f_flag = fsbuf->f_flags ^ ST_VALID;
> +}
> +#endif
>  
>  void
> -INTERNAL_STATVFS (const char *name, struct STATVFS *buf,
> -		  struct STATFS *fsbuf, int fd)
> +__internal_statvfs64 (struct statvfs64 *buf, const struct statfs64 *fsbuf)
>  {
>    /* Now fill in the fields we have information for.  */
>    buf->f_bsize = fsbuf->f_bsize;
> diff --git a/sysdeps/unix/sysv/linux/internal_statvfs.h b/sysdeps/unix/sysv/linux/internal_statvfs.h
> index 9ac675c2e8..a8e9aec2c8 100644
> --- a/sysdeps/unix/sysv/linux/internal_statvfs.h
> +++ b/sysdeps/unix/sysv/linux/internal_statvfs.h
> @@ -18,9 +18,9 @@
>  
>  #include <sys/statvfs.h>
>  
> -extern void __internal_statvfs (const char *name, struct statvfs *buf,
> -				struct statfs *fsbuf, int fd)
> +extern void __internal_statvfs (struct statvfs *buf,
> +				const struct statfs *fsbuf)
>        attribute_hidden;
> -extern void __internal_statvfs64 (const char *name, struct statvfs64 *buf,
> -				  struct statfs64 *fsbuf, int fd)
> +extern void __internal_statvfs64 (struct statvfs64 *buf,
> +				  const struct statfs64 *fsbuf)
>        attribute_hidden;
> diff --git a/sysdeps/unix/sysv/linux/internal_statvfs64.c b/sysdeps/unix/sysv/linux/internal_statvfs64.c
> deleted file mode 100644
> index 49e7689f8b..0000000000
> --- a/sysdeps/unix/sysv/linux/internal_statvfs64.c
> +++ /dev/null
> @@ -1,4 +0,0 @@
> -#define STATFS statfs64
> -#define STATVFS statvfs64
> -#define INTERNAL_STATVFS __internal_statvfs64
> -#include "internal_statvfs.c"
> diff --git a/sysdeps/unix/sysv/linux/statvfs.c b/sysdeps/unix/sysv/linux/statvfs.c
> index f165899711..210242b9a0 100644
> --- a/sysdeps/unix/sysv/linux/statvfs.c
> +++ b/sysdeps/unix/sysv/linux/statvfs.c
> @@ -33,7 +33,7 @@ __statvfs (const char *file, struct statvfs *buf)
>      return -1;
>  
>    /* Convert the result.  */
> -  __internal_statvfs (file, buf, &fsbuf, -1);
> +  __internal_statvfs (buf, &fsbuf);
>  
>    /* We signal success if the statfs call succeeded.  */
>    return 0;
> diff --git a/sysdeps/unix/sysv/linux/statvfs64.c b/sysdeps/unix/sysv/linux/statvfs64.c
> index 3d29908afa..3f03b7edb8 100644
> --- a/sysdeps/unix/sysv/linux/statvfs64.c
> +++ b/sysdeps/unix/sysv/linux/statvfs64.c
> @@ -33,7 +33,7 @@ __statvfs64 (const char *file, struct statvfs64 *buf)
>      return -1;
>  
>    /* Convert the result.  */
> -  __internal_statvfs64 (file, buf, &fsbuf, -1);
> +  __internal_statvfs64 (buf, &fsbuf);
>  
>    return 0;
>  }
> 


-- 
Cheers,
Carlos.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 09/10] linux: Remove overflow.h
  2021-02-08 21:49 ` [PATCH 09/10] linux: Remove overflow.h Adhemerval Zanella
@ 2021-02-11  0:38   ` Carlos O'Donell
  0 siblings, 0 replies; 27+ messages in thread
From: Carlos O'Donell @ 2021-02-11  0:38 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 2/8/21 4:49 PM, Adhemerval Zanella via Libc-alpha wrote:
> The header is not used anywhere, the required functions are provided
> by other implementations.

LGTM.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

> ---
>  .../sysv/linux/generic/wordsize-32/overflow.h | 69 -------------------
>  1 file changed, 69 deletions(-)
>  delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h
> 
> diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h b/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h
> deleted file mode 100644
> index f2a58d654f..0000000000
> --- a/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h
> +++ /dev/null
> @@ -1,69 +0,0 @@
> -/* Overflow tests for stat, statfs, and lseek functions.
> -   Copyright (C) 2011-2021 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library.  If not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -#include <sys/stat.h>
> -#include <sys/statfs.h>
> -#include <sys/types.h>
> -
> -/* Test for overflows of structures where we ask the kernel to fill them
> -   in with standard 64-bit syscalls but return them through APIs that
> -   only expose the low 32 bits of some fields.  */
> -
> -static inline off_t lseek_overflow (loff_t res)
> -{
> -  off_t retval = (off_t) res;
> -  if (retval == res)
> -    return retval;
> -
> -  __set_errno (EOVERFLOW);
> -  return (off_t) -1;
> -}
> -
> -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.  */
> -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
> -	  || (buf->f_files == -1U && buf->__f_files_pad == -1))
> -      && (buf->__f_ffree_pad == 0
> -	  || (buf->f_ffree == -1U && buf->__f_ffree_pad == -1)))
> -    return 0;
> -
> -  __set_errno (EOVERFLOW);
> -  return -1;
> -#endif
> -}
> 


-- 
Cheers,
Carlos.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 10/10] linux: Remove stat-check.c
  2021-02-08 21:49 ` [PATCH 10/10] linux: Remove stat-check.c Adhemerval Zanella
@ 2021-02-11  0:38   ` Carlos O'Donell
  0 siblings, 0 replies; 27+ messages in thread
From: Carlos O'Donell @ 2021-02-11  0:38 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 2/8/21 4:49 PM, Adhemerval Zanella via Libc-alpha wrote:
> The check is moved to LFS fstatat implementation (since it is the
> code that actually implements the syscall).

LGTM.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

> ---
>  sysdeps/unix/sysv/linux/fstatat64.c          | 12 ++++++++
>  sysdeps/unix/sysv/linux/generic/Makefile     |  2 +-
>  sysdeps/unix/sysv/linux/generic/stat-check.c | 29 --------------------
>  3 files changed, 13 insertions(+), 30 deletions(-)
>  delete mode 100644 sysdeps/unix/sysv/linux/generic/stat-check.c
> 
> diff --git a/sysdeps/unix/sysv/linux/fstatat64.c b/sysdeps/unix/sysv/linux/fstatat64.c
> index ab41f19e94..a609b4d3ff 100644
> --- a/sysdeps/unix/sysv/linux/fstatat64.c
> +++ b/sysdeps/unix/sysv/linux/fstatat64.c
> @@ -28,6 +28,18 @@
>  #include <kstat_cp.h>
>  #include <stat_t64_cp.h>
>  
> +#if __TIMESIZE == 64 \
> +     && (__WORDSIZE == 32 \
> +     && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE == 32))
> +/* Sanity check to avoid newer 32-bit ABI to support non-LFS calls. */
> +_Static_assert (sizeof (__off_t) == sizeof (__off64_t),
> +                "__blkcnt_t and __blkcnt64_t must match");
> +_Static_assert (sizeof (__ino_t) == sizeof (__ino64_t),
> +                "__blkcnt_t and __blkcnt64_t must match");
> +_Static_assert (sizeof (__blkcnt_t) == sizeof (__blkcnt64_t),
> +                "__blkcnt_t and __blkcnt64_t must match");
> +#endif
> +
>  int
>  __fstatat64_time64 (int fd, const char *file, struct __stat64_t64 *buf,
>  		    int flag)
> diff --git a/sysdeps/unix/sysv/linux/generic/Makefile b/sysdeps/unix/sysv/linux/generic/Makefile
> index 124f83a0ab..7e27e79772 100644
> --- a/sysdeps/unix/sysv/linux/generic/Makefile
> +++ b/sysdeps/unix/sysv/linux/generic/Makefile
> @@ -1,3 +1,3 @@
>  ifeq ($(subdir),misc)
> -sysdep_routines += epoll_create inotify_init stat-check
> +sysdep_routines += epoll_create inotify_init
>  endif
> diff --git a/sysdeps/unix/sysv/linux/generic/stat-check.c b/sysdeps/unix/sysv/linux/generic/stat-check.c
> deleted file mode 100644
> index e09264dd3a..0000000000
> --- a/sysdeps/unix/sysv/linux/generic/stat-check.c
> +++ /dev/null
> @@ -1,29 +0,0 @@
> -/* Static assert for __blkcnt64_t when __INO_T_MATCHES_INO64_T is defined.
> -   Copyright (C) 2019-2021 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library.  If not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -#include <sys/stat.h>
> -#include <bits/typesizes.h>
> -
> -/* This is due to the layout code in bits/stat.h and the overflow handling in
> -   wordsize-32/overflow.h, requiring either all or none of the three types
> -   concerned to have padding.  */
> -
> -#if defined __INO_T_MATCHES_INO64_T
> -_Static_assert (sizeof (__blkcnt_t) == sizeof (__blkcnt64_t),
> -                "__blkcnt_t and __blkcnt64_t must match");
> -#endif
> 


-- 
Cheers,
Carlos.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 00/10] [f]stat[fs,vfs] consolidation
  2021-02-11  0:37 ` [PATCH 00/10] [f]stat[fs,vfs] consolidation Carlos O'Donell
@ 2021-02-11 20:08   ` Joseph Myers
  2021-02-11 20:13     ` Carlos O'Donell
  0 siblings, 1 reply; 27+ messages in thread
From: Joseph Myers @ 2021-02-11 20:08 UTC (permalink / raw)
  To: Carlos O'Donell; +Cc: Adhemerval Zanella, libc-alpha

There is now a build failure for Hurd that looks like it probably comes 
from one of these changes.

../sysdeps/mach/hurd/fstatfs.c:31:24: error: 'fstatfs' aliased to undefined symbol '__fstatfs'
   31 | weak_alias (__fstatfs, fstatfs)
      |                        ^~~~~~~
./../include/libc-symbols.h:152:26: note: in definition of macro '_weak_alias'
  152 |   extern __typeof (name) aliasname __attribute__ ((weak, alias (#name))) \
      |                          ^~~~~~~~~
../sysdeps/mach/hurd/fstatfs.c:31:1: note: in expansion of macro 'weak_alias'
   31 | weak_alias (__fstatfs, fstatfs)
      | ^~~~~~~~~~

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 00/10] [f]stat[fs,vfs] consolidation
  2021-02-11 20:08   ` Joseph Myers
@ 2021-02-11 20:13     ` Carlos O'Donell
  2021-02-11 20:17       ` Adhemerval Zanella
  0 siblings, 1 reply; 27+ messages in thread
From: Carlos O'Donell @ 2021-02-11 20:13 UTC (permalink / raw)
  To: Joseph Myers, Adhemerval Zanella; +Cc: libc-alpha

On 2/11/21 3:08 PM, Joseph Myers wrote:
> There is now a build failure for Hurd that looks like it probably comes 
> from one of these changes.
> 
> ../sysdeps/mach/hurd/fstatfs.c:31:24: error: 'fstatfs' aliased to undefined symbol '__fstatfs'
>    31 | weak_alias (__fstatfs, fstatfs)
>       |                        ^~~~~~~
> ./../include/libc-symbols.h:152:26: note: in definition of macro '_weak_alias'
>   152 |   extern __typeof (name) aliasname __attribute__ ((weak, alias (#name))) \
>       |                          ^~~~~~~~~
> ../sysdeps/mach/hurd/fstatfs.c:31:1: note: in expansion of macro 'weak_alias'
>    31 | weak_alias (__fstatfs, fstatfs)
>       | ^~~~~~~~~~
> 

I didn't run a full bmg build for reviewing.

I should though just to review such refactoring.

Adhemerval, Are you able to look into this?

-- 
Cheers,
Carlos.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 00/10] [f]stat[fs,vfs] consolidation
  2021-02-11 20:13     ` Carlos O'Donell
@ 2021-02-11 20:17       ` Adhemerval Zanella
  2021-02-11 20:30         ` Carlos O'Donell
  0 siblings, 1 reply; 27+ messages in thread
From: Adhemerval Zanella @ 2021-02-11 20:17 UTC (permalink / raw)
  To: Carlos O'Donell, Joseph Myers; +Cc: libc-alpha



On 11/02/2021 17:13, Carlos O'Donell wrote:
> On 2/11/21 3:08 PM, Joseph Myers wrote:
>> There is now a build failure for Hurd that looks like it probably comes 
>> from one of these changes.
>>
>> ../sysdeps/mach/hurd/fstatfs.c:31:24: error: 'fstatfs' aliased to undefined symbol '__fstatfs'
>>    31 | weak_alias (__fstatfs, fstatfs)
>>       |                        ^~~~~~~
>> ./../include/libc-symbols.h:152:26: note: in definition of macro '_weak_alias'
>>   152 |   extern __typeof (name) aliasname __attribute__ ((weak, alias (#name))) \
>>       |                          ^~~~~~~~~
>> ../sysdeps/mach/hurd/fstatfs.c:31:1: note: in expansion of macro 'weak_alias'
>>    31 | weak_alias (__fstatfs, fstatfs)
>>       | ^~~~~~~~~~
>>
> 
> I didn't run a full bmg build for reviewing.
> 
> I should though just to review such refactoring.
> 
> Adhemerval, Are you able to look into this?
> 

Working on it, I forgot to fire up a hurd build for this one...

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 00/10] [f]stat[fs,vfs] consolidation
  2021-02-11 20:17       ` Adhemerval Zanella
@ 2021-02-11 20:30         ` Carlos O'Donell
  2021-02-11 20:32           ` DJ Delorie
  0 siblings, 1 reply; 27+ messages in thread
From: Carlos O'Donell @ 2021-02-11 20:30 UTC (permalink / raw)
  To: Adhemerval Zanella, Joseph Myers, DJ Delorie; +Cc: libc-alpha

On 2/11/21 3:17 PM, Adhemerval Zanella wrote:
> 
> 
> On 11/02/2021 17:13, Carlos O'Donell wrote:
>> On 2/11/21 3:08 PM, Joseph Myers wrote:
>>> There is now a build failure for Hurd that looks like it probably comes 
>>> from one of these changes.
>>>
>>> ../sysdeps/mach/hurd/fstatfs.c:31:24: error: 'fstatfs' aliased to undefined symbol '__fstatfs'
>>>    31 | weak_alias (__fstatfs, fstatfs)
>>>       |                        ^~~~~~~
>>> ./../include/libc-symbols.h:152:26: note: in definition of macro '_weak_alias'
>>>   152 |   extern __typeof (name) aliasname __attribute__ ((weak, alias (#name))) \
>>>       |                          ^~~~~~~~~
>>> ../sysdeps/mach/hurd/fstatfs.c:31:1: note: in expansion of macro 'weak_alias'
>>>    31 | weak_alias (__fstatfs, fstatfs)
>>>       | ^~~~~~~~~~
>>>
>>
>> I didn't run a full bmg build for reviewing.
>>
>> I should though just to review such refactoring.
>>
>> Adhemerval, Are you able to look into this?
>>
> 
> Working on it, I forgot to fire up a hurd build for this one...

DJ,

/buildon build-many-glibcs ;-)


-- 
Cheers,
Carlos.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 00/10] [f]stat[fs,vfs] consolidation
  2021-02-11 20:30         ` Carlos O'Donell
@ 2021-02-11 20:32           ` DJ Delorie
  0 siblings, 0 replies; 27+ messages in thread
From: DJ Delorie @ 2021-02-11 20:32 UTC (permalink / raw)
  To: Carlos O'Donell; +Cc: adhemerval.zanella, joseph, libc-alpha

"Carlos O'Donell" <carlos@redhat.com> writes:
>> Working on it, I forgot to fire up a hurd build for this one...
>
> DJ,
>
> /buildon build-many-glibcs ;-)

I'm typing as fast as I can!!!   ;-)

(and you forgot to gpg-sign the request ;)


^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2021-02-11 20:33 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-08 21:49 [PATCH 00/10] [f]stat[fs,vfs] consolidation Adhemerval Zanella
2021-02-08 21:49 ` [PATCH 01/10] linux: Fix STATFS_IS_STATFS64 definition Adhemerval Zanella
2021-02-11  0:37   ` Carlos O'Donell
2021-02-08 21:49 ` [PATCH 02/10] linux: Set default kernel_stat.h to LFS Adhemerval Zanella
2021-02-11  0:37   ` Carlos O'Donell
2021-02-08 21:49 ` [PATCH 03/10] linux: Set LFS statfs as default Adhemerval Zanella
2021-02-11  0:37   ` Carlos O'Donell
2021-02-08 21:49 ` [PATCH 04/10] linux: Consolidate fstatfs implementations Adhemerval Zanella
2021-02-11  0:38   ` Carlos O'Donell
2021-02-08 21:49 ` [PATCH 05/10] linux: Consolidate statfs implementations Adhemerval Zanella
2021-02-11  0:38   ` Carlos O'Donell
2021-02-08 21:49 ` [PATCH 06/10] linux: Consolidate fstatvfs implementations Adhemerval Zanella
2021-02-11  0:38   ` Carlos O'Donell
2021-02-08 21:49 ` [PATCH 07/10] linux: Consolidate statvfs implementations Adhemerval Zanella
2021-02-11  0:38   ` Carlos O'Donell
2021-02-08 21:49 ` [PATCH 08/10] linux: Consolidate internal_statvfs Adhemerval Zanella
2021-02-11  0:38   ` Carlos O'Donell
2021-02-08 21:49 ` [PATCH 09/10] linux: Remove overflow.h Adhemerval Zanella
2021-02-11  0:38   ` Carlos O'Donell
2021-02-08 21:49 ` [PATCH 10/10] linux: Remove stat-check.c Adhemerval Zanella
2021-02-11  0:38   ` Carlos O'Donell
2021-02-11  0:37 ` [PATCH 00/10] [f]stat[fs,vfs] consolidation Carlos O'Donell
2021-02-11 20:08   ` Joseph Myers
2021-02-11 20:13     ` Carlos O'Donell
2021-02-11 20:17       ` Adhemerval Zanella
2021-02-11 20:30         ` Carlos O'Donell
2021-02-11 20:32           ` DJ Delorie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).