unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 00/16] Add y2038 support for stat functions
@ 2020-07-23 19:46 Adhemerval Zanella via Libc-alpha
  2020-07-23 19:46 ` [PATCH 01/16] linux: Always define STAT_IS_KERNEL_STAT Adhemerval Zanella via Libc-alpha
                   ` (15 more replies)
  0 siblings, 16 replies; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-07-23 19:46 UTC (permalink / raw)
  To: libc-alpha; +Cc: Alistair Francis

As discussed in a previous thread [1], the {f,l}stat{at}{64} functions
use an old mechanism prior symbol versioning to provide a compatibility
layer.  As described in the thread, this approach has some drawbacks so
I decided to use the anoother strategy which requires a lot of plumbing.

So the first 6 patches consolidate the various {f,l}xstat{64} linux
implementations.  I tried to keep as less arch-specific implementations
as possible (there are still outliers such as alpha and mips).  The
xstat implementation is mainly responsible to issue the correct syscall,
the heavy lifting of handling the _STAT_VER versions are done on the
xstat_conv functions (which is not changed on this patchset).

The next patch removes all internal usage of xstat function by replacing
with the stat one.  It would allow to move the xstat function later to
compat symbols.

Some Linux consolidation is also done to avoid need to replicate the new
y2038 stat struct on multiple architectures or add syscall support on
multiple symbols.  First the struct stat is moved to its own header and
stat/lstat/fstat is implemented on top on fstatat.

Finally fstatat is implemented without calling fxstatat and xstat symbols
are moved to compat ones.

The y2038 stat struct is added as as generic definition for all Linux
ABIs and it is disentangled from kernel ABI.

The patchset also removes the mknod{at} static wrapper and move them
to libc symbols.  I decided to send it along this patchset because its
defintion are entangled on platform specific header and moving them to
compat symbols allow to simplify the stat code as well.

[1] https://sourceware.org/pipermail/libc-alpha/2020-July/116342.html

Adhemerval Zanella (16):
  linux: Always define STAT_IS_KERNEL_STAT
  linux: Define STAT64_IS_KERNEL_STAT64
  linux: Consolidate xstat{64}
  linux: Consolidate lxstat{64}
  linux: Consolidate fxstat{64}
  linux: Consolidate fxstatat{64}
  Linux: Consolidate xmknod
  Remove internal usage of extensible stat functions
  Remove stat wrapper functions, move them to exported symbols
  Remove mknod wrapper functions, move them to symbols
  linux: Move the struct stat{64} to struct_stat.h
  linux: Implement {l}fstat{at} in terms of fstatat
  linux: Disentangle fstatat from fxstatat
  linux: Move {f}xstat{at} to compat symbols
  linux: Add {f}stat{at} y2038 support
  linux: Move xmknoda{at} to compat symbols

 catgets/open_catalog.c                        |   2 +-
 csu/check_fds.c                               |   2 +-
 elf/cache.c                                   |   4 +-
 elf/dl-load.c                                 |   4 +-
 elf/dl-misc.c                                 |   2 +-
 elf/dl-profile.c                              |   2 +-
 iconv/gconv_cache.c                           |   2 +-
 include/sys/stat.h                            | 166 +++++++++++++-----
 inet/rcmd.c                                   |   4 +-
 inet/ruserpass.c                              |   2 +-
 intl/loadmsgcat.c                             |   2 +-
 io/Makefile                                   |   7 +-
 io/Versions                                   |   5 +
 io/file_change_detection.c                    |   4 +-
 io/fstat.c                                    |  33 +---
 io/fstat64.c                                  |  36 +---
 io/fstatat.c                                  |  36 +---
 io/fstatat64.c                                |  36 +---
 io/fts.c                                      |  15 +-
 io/fts64.c                                    |   5 +-
 io/ftw.c                                      |  46 ++---
 io/ftw64.c                                    |   8 +-
 io/getdirname.c                               |   4 +-
 io/lstat.c                                    |  33 +---
 io/lstat64.c                                  |  36 +---
 io/mkdirat.c                                  |   2 +-
 io/mkfifoat.c                                 |   2 +-
 io/mknod.c                                    |  35 +---
 io/mknodat.c                                  |  35 +---
 io/openat.c                                   |   2 +-
 io/openat64.c                                 |   2 +-
 io/stat.c                                     |  34 +---
 io/stat64.c                                   |  36 +---
 io/sys/stat.h                                 | 159 -----------------
 io/xmknodat.c                                 |   2 +-
 libio/fileops.c                               |   2 +-
 locale/loadarchive.c                          |   4 +-
 locale/loadlocale.c                           |   4 +-
 misc/daemon.c                                 |   2 +-
 misc/getusershell.c                           |   2 +-
 nptl/sem_open.c                               |   2 +-
 nscd/gai.c                                    |   5 +
 nscd/nscd_helper.c                            |   2 +-
 posix/glob.c                                  |   7 -
 stdlib/canonicalize.c                         |   2 +-
 sysdeps/generic/struct_stat_time64.h          |   7 +
 sysdeps/generic/xstatver.h                    |   4 +
 sysdeps/gnu/glob64-lstat-compat.c             |   2 +-
 sysdeps/gnu/glob64.c                          |   2 +-
 sysdeps/mach/hurd/i386/libc.abilist           |  10 ++
 sysdeps/mach/hurd/ptsname.c                   |   2 +-
 sysdeps/mach/hurd/xmknod.c                    |   1 -
 sysdeps/mach/hurd/xmknodat.c                  |   2 -
 sysdeps/posix/dl-fileid.h                     |   2 +-
 sysdeps/posix/euidaccess.c                    |   2 +-
 sysdeps/posix/fdopendir.c                     |   2 +-
 sysdeps/posix/fpathconf.c                     |   2 +-
 sysdeps/posix/getaddrinfo.c                   |   4 +-
 sysdeps/posix/isfdtype.c                      |   2 +-
 sysdeps/posix/mkfifo.c                        |   3 +-
 sysdeps/posix/mkfifoat.c                      |   3 +-
 sysdeps/posix/opendir.c                       |   2 +-
 sysdeps/posix/pathconf.c                      |   2 +-
 sysdeps/posix/posix_fallocate.c               |   2 +-
 sysdeps/posix/posix_fallocate64.c             |   2 +-
 sysdeps/posix/sysconf.c                       |   2 +-
 sysdeps/posix/tempname.c                      |   5 +-
 sysdeps/unix/sysv/linux/Makefile              |   8 +-
 sysdeps/unix/sysv/linux/aarch64/libc.abilist  |  10 ++
 .../alpha/bits/{stat.h => struct_stat.h}      |  56 +-----
 sysdeps/unix/sysv/linux/alpha/dl-fxstatat64.c |   1 -
 .../sysv/linux/alpha/{fxstat.c => fxstat64.c} |  56 +++---
 sysdeps/unix/sysv/linux/alpha/fxstatat.c      |  52 ------
 .../{generic/xstat.c => alpha/fxstatat64.c}   |  35 ++--
 sysdeps/unix/sysv/linux/alpha/kernel_stat.h   |   2 +
 sysdeps/unix/sysv/linux/alpha/libc.abilist    |  10 ++
 .../sysv/linux/alpha/{lxstat.c => lxstat64.c} |  55 +++---
 .../sysv/linux/alpha/{xstat.c => xstat64.c}   |  55 +++---
 sysdeps/unix/sysv/linux/alpha/xstatver.h      |  14 ++
 sysdeps/unix/sysv/linux/arc/kernel_stat.h     |   1 +
 sysdeps/unix/sysv/linux/arc/libc.abilist      |  10 ++
 sysdeps/unix/sysv/linux/arm/fxstat.c          |   1 -
 sysdeps/unix/sysv/linux/arm/fxstatat.c        |   1 -
 sysdeps/unix/sysv/linux/arm/le/libc.abilist   |  10 ++
 sysdeps/unix/sysv/linux/arm/lxstat.c          |   1 -
 sysdeps/unix/sysv/linux/arm/xstat.c           |   1 -
 sysdeps/unix/sysv/linux/bits/stat.h           | 114 +-----------
 sysdeps/unix/sysv/linux/bits/struct_stat.h    | 131 ++++++++++++++
 sysdeps/unix/sysv/linux/csky/libc.abilist     |  10 ++
 sysdeps/unix/sysv/linux/faccessat.c           |   2 +-
 sysdeps/unix/sysv/linux/fexecve.c             |   4 +-
 sysdeps/unix/sysv/linux/fstat.c               |  42 +++++
 sysdeps/unix/sysv/linux/fstat64.c             |  52 ++++++
 sysdeps/unix/sysv/linux/fstatat.c             |  92 ++++++++++
 sysdeps/unix/sysv/linux/fstatat64.c           | 125 +++++++++++++
 sysdeps/unix/sysv/linux/fxstat.c              |  67 +++----
 sysdeps/unix/sysv/linux/fxstat64.c            |  56 +++---
 sysdeps/unix/sysv/linux/fxstatat.c            |  63 +++----
 sysdeps/unix/sysv/linux/fxstatat64.c          |  75 +++++---
 .../generic/bits/{stat.h => struct_stat.h}    |  59 +------
 sysdeps/unix/sysv/linux/generic/lxstat.c      |  48 -----
 .../sysv/linux/generic/wordsize-32/fxstat.c   |  57 ------
 .../sysv/linux/generic/wordsize-32/fxstat64.c |  36 ----
 .../sysv/linux/generic/wordsize-32/fxstatat.c |  56 ------
 .../sysv/linux/generic/wordsize-32/lxstat.c   |  55 ------
 .../sysv/linux/generic/wordsize-32/lxstat64.c |  66 -------
 .../sysv/linux/generic/wordsize-32/xstat.c    |  54 ------
 .../sysv/linux/generic/wordsize-32/xstat64.c  |  63 -------
 sysdeps/unix/sysv/linux/generic/xmknod.c      |  54 ------
 sysdeps/unix/sysv/linux/generic/xstatver.h    |  10 ++
 sysdeps/unix/sysv/linux/hppa/fxstat.c         |   1 -
 sysdeps/unix/sysv/linux/hppa/fxstatat.c       |   1 -
 sysdeps/unix/sysv/linux/hppa/kernel_stat.h    |   2 +
 sysdeps/unix/sysv/linux/hppa/libc.abilist     |  10 ++
 sysdeps/unix/sysv/linux/hppa/lxstat.c         |   1 -
 sysdeps/unix/sysv/linux/hppa/xstat.c          |   1 -
 sysdeps/unix/sysv/linux/i386/fxstat.c         |  59 -------
 sysdeps/unix/sysv/linux/i386/fxstatat.c       |  54 ------
 sysdeps/unix/sysv/linux/i386/libc.abilist     |  10 ++
 sysdeps/unix/sysv/linux/i386/lxstat.c         |  60 -------
 sysdeps/unix/sysv/linux/i386/xstat.c          |  59 -------
 .../linux/ia64/bits/{stat.h => struct_stat.h} |  53 +-----
 sysdeps/unix/sysv/linux/ia64/kernel_stat.h    |   1 +
 sysdeps/unix/sysv/linux/ia64/libc.abilist     |  10 ++
 sysdeps/unix/sysv/linux/ia64/xstatver.h       |  10 ++
 sysdeps/unix/sysv/linux/kernel_stat.h         |   2 +
 sysdeps/unix/sysv/linux/kstat_cp.h            |   2 +
 sysdeps/unix/sysv/linux/lstat.c               |  42 +++++
 sysdeps/unix/sysv/linux/lstat64.c             |  51 ++++++
 sysdeps/unix/sysv/linux/lxstat.c              |  69 ++++----
 sysdeps/unix/sysv/linux/lxstat64.c            |  71 ++++++--
 .../linux/m68k/bits/{stat.h => struct_stat.h} |  57 +-----
 sysdeps/unix/sysv/linux/m68k/fxstat.c         |   1 -
 sysdeps/unix/sysv/linux/m68k/fxstatat.c       |   1 -
 sysdeps/unix/sysv/linux/m68k/lxstat.c         |   1 -
 .../unix/sysv/linux/m68k/m680x0/libc.abilist  |  10 ++
 sysdeps/unix/sysv/linux/m68k/xstat.c          |   1 -
 sysdeps/unix/sysv/linux/m68k/xstatver.h       |  13 ++
 .../sysv/linux/microblaze/be/libc.abilist     |  10 ++
 .../microblaze/bits/{stat.h => struct_stat.h} |  65 ++-----
 sysdeps/unix/sysv/linux/microblaze/fxstat.c   |   1 -
 sysdeps/unix/sysv/linux/microblaze/fxstatat.c |   1 -
 .../unix/sysv/linux/microblaze/kernel_stat.h  |   2 +
 sysdeps/unix/sysv/linux/microblaze/lxstat.c   |   1 -
 sysdeps/unix/sysv/linux/microblaze/xstat.c    |   1 -
 sysdeps/unix/sysv/linux/microblaze/xstatver.h |  13 ++
 .../linux/mips/bits/{stat.h => struct_stat.h} |  57 +-----
 sysdeps/unix/sysv/linux/mips/fxstat.c         |  49 ++++++
 sysdeps/unix/sysv/linux/mips/kernel_stat.h    |   7 +
 .../sysv/linux/{wordsize-64 => mips}/lxstat.c |  44 ++---
 .../sysv/linux/mips/mips32/fpu/libc.abilist   |  10 ++
 .../unix/sysv/linux/mips/mips32/fxstatat.c    |   1 -
 .../unix/sysv/linux/mips/mips64/fxstat64.c    |  21 +--
 .../fxstat.c => mips/mips64/fxstatat.c}       |  33 ++--
 .../unix/sysv/linux/mips/mips64/fxstatat64.c  |  35 ++--
 .../unix/sysv/linux/mips/mips64/kstat_cp.h    |  71 ++++++++
 .../unix/sysv/linux/mips/mips64/lxstat64.c    |  22 +--
 .../sysv/linux/mips/mips64/n32/libc.abilist   |  10 ++
 .../sysv/linux/mips/mips64/n64/libc.abilist   |  10 ++
 .../unix/sysv/linux/mips/mips64/statx_cp.c    |   3 -
 sysdeps/unix/sysv/linux/mips/mips64/xstat64.c |  25 ++-
 .../sysv/linux/{wordsize-64 => mips}/xstat.c  |  41 +++--
 sysdeps/unix/sysv/linux/mips/xstatver.h       |  13 ++
 sysdeps/unix/sysv/linux/mknod.c               |  28 +++
 sysdeps/unix/sysv/linux/mknodat.c             |  41 +++++
 sysdeps/unix/sysv/linux/nios2/libc.abilist    |  10 ++
 sysdeps/unix/sysv/linux/oldglob.c             |   2 +-
 sysdeps/unix/sysv/linux/pathconf.c            |   4 +-
 .../powerpc/bits/{stat.h => struct_stat.h}    |  64 +------
 .../linux/powerpc/powerpc32/fpu/libc.abilist  |  10 ++
 .../sysv/linux/powerpc/powerpc32/fxstat.c     |   1 -
 .../sysv/linux/powerpc/powerpc32/fxstatat.c   |   1 -
 .../linux/powerpc/powerpc32/kernel_stat.h     |   2 +
 .../sysv/linux/powerpc/powerpc32/lxstat.c     |   2 -
 .../unix/sysv/linux/powerpc/powerpc32/xstat.c |   1 -
 .../linux/powerpc/powerpc64/be/libc.abilist   |  10 ++
 .../linux/powerpc/powerpc64/kernel_stat.h     |   1 +
 .../linux/powerpc/powerpc64/le/libc.abilist   |  10 ++
 sysdeps/unix/sysv/linux/powerpc/xstatver.h    |  17 ++
 sysdeps/unix/sysv/linux/ptsname.c             |   4 +-
 .../unix/sysv/linux/riscv/rv64/libc.abilist   |  10 ++
 .../linux/s390/bits/{stat.h => struct_stat.h} |  68 +------
 sysdeps/unix/sysv/linux/s390/s390-32/fxstat.c |   1 -
 .../unix/sysv/linux/s390/s390-32/fxstatat.c   |   1 -
 .../unix/sysv/linux/s390/s390-32/libc.abilist |  10 ++
 sysdeps/unix/sysv/linux/s390/s390-32/lxstat.c |   1 -
 sysdeps/unix/sysv/linux/s390/s390-32/xstat.c  |   1 -
 .../sysv/linux/s390/s390-64/kernel_stat.h     |   1 +
 .../unix/sysv/linux/s390/s390-64/libc.abilist |  10 ++
 sysdeps/unix/sysv/linux/s390/xstatver.h       |  20 +++
 sysdeps/unix/sysv/linux/sh/fxstat.c           |   1 -
 sysdeps/unix/sysv/linux/sh/fxstatat.c         |   1 -
 sysdeps/unix/sysv/linux/sh/le/libc.abilist    |  10 ++
 sysdeps/unix/sysv/linux/sh/lxstat.c           |   2 -
 sysdeps/unix/sysv/linux/sh/xstat.c            |   1 -
 .../sparc/bits/{stat.h => struct_stat.h}      |  60 +------
 .../unix/sysv/linux/sparc/sparc32/fxstat.c    |   1 -
 .../unix/sysv/linux/sparc/sparc32/fxstatat.c  |   1 -
 .../sysv/linux/sparc/sparc32/kernel_stat.h    |   2 +
 .../sysv/linux/sparc/sparc32/libc.abilist     |  10 ++
 .../unix/sysv/linux/sparc/sparc32/lxstat.c    |   2 -
 sysdeps/unix/sysv/linux/sparc/sparc32/xstat.c |   1 -
 .../sysv/linux/sparc/sparc64/dl-fxstatat64.c  |   1 -
 .../unix/sysv/linux/sparc/sparc64/fxstat.c    |   1 -
 .../unix/sysv/linux/sparc/sparc64/fxstatat.c  |   1 -
 .../sysv/linux/sparc/sparc64/kernel_stat.h    |   7 +
 .../unix/sysv/linux/sparc/sparc64/kstat_cp.h  |  46 +++++
 .../sysv/linux/sparc/sparc64/libc.abilist     |  10 ++
 .../unix/sysv/linux/sparc/sparc64/lxstat.c    |   1 -
 sysdeps/unix/sysv/linux/sparc/sparc64/xstat.c |   1 -
 sysdeps/unix/sysv/linux/sparc/xstatver.h      |  13 ++
 sysdeps/unix/sysv/linux/stat.c                |  42 +++++
 sysdeps/unix/sysv/linux/stat64.c              |  52 ++++++
 sysdeps/unix/sysv/linux/stat_t64_cp.c         |  92 ++++++++++
 .../fxstatat64.c => stat_t64_cp.h}            |  27 +--
 sysdeps/unix/sysv/linux/statx_cp.c            |  54 ++++++
 sysdeps/unix/sysv/linux/statx_cp.h            |   6 +
 sysdeps/unix/sysv/linux/struct_stat_time64.h  | 122 +++++++++++++
 sysdeps/unix/sysv/linux/ttyname.c             |   8 +-
 sysdeps/unix/sysv/linux/ttyname_r.c           |   8 +-
 .../sysv/linux/wordsize-64/dl-fxstatat64.c    |   1 -
 .../unix/sysv/linux/wordsize-64/fxstat64.c    |   1 -
 .../unix/sysv/linux/wordsize-64/fxstatat.c    |  48 -----
 .../unix/sysv/linux/wordsize-64/fxstatat64.c  |   1 -
 .../unix/sysv/linux/wordsize-64/lxstat64.c    |   1 -
 sysdeps/unix/sysv/linux/wordsize-64/xstat64.c |   1 -
 .../linux/x86/bits/{stat.h => struct_stat.h}  |  67 +------
 sysdeps/unix/sysv/linux/x86/xstatver.h        |  16 ++
 .../unix/sysv/linux/x86_64/64/libc.abilist    |  10 ++
 sysdeps/unix/sysv/linux/x86_64/kernel_stat.h  |   1 +
 .../unix/sysv/linux/x86_64/x32/libc.abilist   |  10 ++
 sysdeps/unix/sysv/linux/xmknod.c              |  24 +--
 sysdeps/unix/sysv/linux/xmknodat.c            |  23 +--
 sysdeps/unix/sysv/linux/xstat.c               |  68 ++++---
 sysdeps/unix/sysv/linux/xstat64.c             |  64 +++++--
 sysdeps/unix/sysv/linux/xstatconv.c           |   2 +-
 sysdeps/unix/sysv/linux/xstatconv.h           |   2 +-
 sysdeps/unix/sysv/linux/xstatover.h           |  67 +++++++
 sysdeps/unix/sysv/linux/xstatver.h            |  13 ++
 sysvipc/ftok.c                                |   2 +-
 time/getdate.c                                |   2 +-
 time/tzfile.c                                 |   4 +-
 242 files changed, 2587 insertions(+), 2627 deletions(-)
 create mode 100644 sysdeps/generic/struct_stat_time64.h
 create mode 100644 sysdeps/generic/xstatver.h
 rename sysdeps/unix/sysv/linux/alpha/bits/{stat.h => struct_stat.h} (68%)
 delete mode 100644 sysdeps/unix/sysv/linux/alpha/dl-fxstatat64.c
 rename sysdeps/unix/sysv/linux/alpha/{fxstat.c => fxstat64.c} (53%)
 delete mode 100644 sysdeps/unix/sysv/linux/alpha/fxstatat.c
 rename sysdeps/unix/sysv/linux/{generic/xstat.c => alpha/fxstatat64.c} (56%)
 rename sysdeps/unix/sysv/linux/alpha/{lxstat.c => lxstat64.c} (55%)
 rename sysdeps/unix/sysv/linux/alpha/{xstat.c => xstat64.c} (55%)
 create mode 100644 sysdeps/unix/sysv/linux/alpha/xstatver.h
 delete mode 100644 sysdeps/unix/sysv/linux/arm/fxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/arm/fxstatat.c
 delete mode 100644 sysdeps/unix/sysv/linux/arm/lxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/arm/xstat.c
 create mode 100644 sysdeps/unix/sysv/linux/bits/struct_stat.h
 create mode 100644 sysdeps/unix/sysv/linux/fstat.c
 create mode 100644 sysdeps/unix/sysv/linux/fstat64.c
 create mode 100644 sysdeps/unix/sysv/linux/fstatat.c
 create mode 100644 sysdeps/unix/sysv/linux/fstatat64.c
 rename sysdeps/unix/sysv/linux/generic/bits/{stat.h => struct_stat.h} (70%)
 delete mode 100644 sysdeps/unix/sysv/linux/generic/lxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat64.c
 delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat.c
 delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat64.c
 delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/xstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/xstat64.c
 delete mode 100644 sysdeps/unix/sysv/linux/generic/xmknod.c
 create mode 100644 sysdeps/unix/sysv/linux/generic/xstatver.h
 delete mode 100644 sysdeps/unix/sysv/linux/hppa/fxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/hppa/fxstatat.c
 delete mode 100644 sysdeps/unix/sysv/linux/hppa/lxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/hppa/xstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/i386/fxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/i386/fxstatat.c
 delete mode 100644 sysdeps/unix/sysv/linux/i386/lxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/i386/xstat.c
 rename sysdeps/unix/sysv/linux/ia64/bits/{stat.h => struct_stat.h} (72%)
 create mode 100644 sysdeps/unix/sysv/linux/ia64/xstatver.h
 create mode 100644 sysdeps/unix/sysv/linux/kstat_cp.h
 create mode 100644 sysdeps/unix/sysv/linux/lstat.c
 create mode 100644 sysdeps/unix/sysv/linux/lstat64.c
 rename sysdeps/unix/sysv/linux/m68k/bits/{stat.h => struct_stat.h} (72%)
 delete mode 100644 sysdeps/unix/sysv/linux/m68k/fxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/m68k/fxstatat.c
 delete mode 100644 sysdeps/unix/sysv/linux/m68k/lxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/m68k/xstat.c
 create mode 100644 sysdeps/unix/sysv/linux/m68k/xstatver.h
 rename sysdeps/unix/sysv/linux/microblaze/bits/{stat.h => struct_stat.h} (77%)
 delete mode 100644 sysdeps/unix/sysv/linux/microblaze/fxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/microblaze/fxstatat.c
 delete mode 100644 sysdeps/unix/sysv/linux/microblaze/lxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/microblaze/xstat.c
 create mode 100644 sysdeps/unix/sysv/linux/microblaze/xstatver.h
 rename sysdeps/unix/sysv/linux/mips/bits/{stat.h => struct_stat.h} (81%)
 create mode 100644 sysdeps/unix/sysv/linux/mips/fxstat.c
 rename sysdeps/unix/sysv/linux/{wordsize-64 => mips}/lxstat.c (59%)
 delete mode 100644 sysdeps/unix/sysv/linux/mips/mips32/fxstatat.c
 rename sysdeps/unix/sysv/linux/{wordsize-64/fxstat.c => mips/mips64/fxstatat.c} (62%)
 create mode 100644 sysdeps/unix/sysv/linux/mips/mips64/kstat_cp.h
 delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/statx_cp.c
 rename sysdeps/unix/sysv/linux/{wordsize-64 => mips}/xstat.c (66%)
 create mode 100644 sysdeps/unix/sysv/linux/mips/xstatver.h
 create mode 100644 sysdeps/unix/sysv/linux/mknod.c
 create mode 100644 sysdeps/unix/sysv/linux/mknodat.c
 rename sysdeps/unix/sysv/linux/powerpc/bits/{stat.h => struct_stat.h} (82%)
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/fxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/fxstatat.c
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/lxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/xstat.c
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/xstatver.h
 rename sysdeps/unix/sysv/linux/s390/bits/{stat.h => struct_stat.h} (80%)
 delete mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/fxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/fxstatat.c
 delete mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/lxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/xstat.c
 create mode 100644 sysdeps/unix/sysv/linux/s390/xstatver.h
 delete mode 100644 sysdeps/unix/sysv/linux/sh/fxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/sh/fxstatat.c
 delete mode 100644 sysdeps/unix/sysv/linux/sh/lxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/sh/xstat.c
 rename sysdeps/unix/sysv/linux/sparc/bits/{stat.h => struct_stat.h} (72%)
 delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/fxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/fxstatat.c
 delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/lxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/xstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/dl-fxstatat64.c
 delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/fxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/fxstatat.c
 create mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/kstat_cp.h
 delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/lxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/xstat.c
 create mode 100644 sysdeps/unix/sysv/linux/sparc/xstatver.h
 create mode 100644 sysdeps/unix/sysv/linux/stat.c
 create mode 100644 sysdeps/unix/sysv/linux/stat64.c
 create mode 100644 sysdeps/unix/sysv/linux/stat_t64_cp.c
 rename sysdeps/unix/sysv/linux/{generic/wordsize-32/fxstatat64.c => stat_t64_cp.h} (51%)
 create mode 100644 sysdeps/unix/sysv/linux/struct_stat_time64.h
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/dl-fxstatat64.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/fxstat64.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/fxstatat64.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/lxstat64.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/xstat64.c
 rename sysdeps/unix/sysv/linux/x86/bits/{stat.h => struct_stat.h} (73%)
 create mode 100644 sysdeps/unix/sysv/linux/x86/xstatver.h
 create mode 100644 sysdeps/unix/sysv/linux/xstatover.h
 create mode 100644 sysdeps/unix/sysv/linux/xstatver.h

-- 
2.25.1


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

* [PATCH 01/16] linux: Always define STAT_IS_KERNEL_STAT
  2020-07-23 19:46 [PATCH 00/16] Add y2038 support for stat functions Adhemerval Zanella via Libc-alpha
@ 2020-07-23 19:46 ` Adhemerval Zanella via Libc-alpha
  2020-07-24  8:17   ` Lukasz Majewski
  2020-07-23 19:46 ` [PATCH 02/16] linux: Define STAT64_IS_KERNEL_STAT64 Adhemerval Zanella via Libc-alpha
                   ` (14 subsequent siblings)
  15 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-07-23 19:46 UTC (permalink / raw)
  To: libc-alpha; +Cc: Alistair Francis

It allows to check for its value instead of its existence.

Checked with a build for all affected ABIS.
---
 sysdeps/unix/sysv/linux/alpha/kernel_stat.h             | 1 +
 sysdeps/unix/sysv/linux/fxstat.c                        | 2 +-
 sysdeps/unix/sysv/linux/fxstatat.c                      | 4 ++--
 sysdeps/unix/sysv/linux/hppa/kernel_stat.h              | 1 +
 sysdeps/unix/sysv/linux/kernel_stat.h                   | 1 +
 sysdeps/unix/sysv/linux/lxstat.c                        | 2 +-
 sysdeps/unix/sysv/linux/microblaze/kernel_stat.h        | 1 +
 sysdeps/unix/sysv/linux/mips/kernel_stat.h              | 1 +
 sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h | 1 +
 sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h     | 1 +
 sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h     | 1 +
 sysdeps/unix/sysv/linux/xstat.c                         | 2 +-
 sysdeps/unix/sysv/linux/xstatconv.c                     | 2 +-
 sysdeps/unix/sysv/linux/xstatconv.h                     | 2 +-
 14 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/alpha/kernel_stat.h b/sysdeps/unix/sysv/linux/alpha/kernel_stat.h
index d637e099cf..9bcc96c577 100644
--- a/sysdeps/unix/sysv/linux/alpha/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/alpha/kernel_stat.h
@@ -85,5 +85,6 @@ struct glibc21_stat
     long __glibc_reserved[4];
   };
 
+#define STAT_IS_KERNEL_STAT 0
 #define XSTAT_IS_XSTAT64 1
 #define STATFS_IS_STATFS64 0
diff --git a/sysdeps/unix/sysv/linux/fxstat.c b/sysdeps/unix/sysv/linux/fxstat.c
index ce474dcd47..a88404b5c3 100644
--- a/sysdeps/unix/sysv/linux/fxstat.c
+++ b/sysdeps/unix/sysv/linux/fxstat.c
@@ -38,7 +38,7 @@ __fxstat (int vers, int fd, struct stat *buf)
   if (vers == _STAT_VER_KERNEL)
     return INLINE_SYSCALL (fstat, 2, fd, buf);
 
-#ifdef STAT_IS_KERNEL_STAT
+#if STAT_IS_KERNEL_STAT
   return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
 #else
   struct kernel_stat kbuf;
diff --git a/sysdeps/unix/sysv/linux/fxstatat.c b/sysdeps/unix/sysv/linux/fxstatat.c
index 3eb898e322..937fec45c2 100644
--- a/sysdeps/unix/sysv/linux/fxstatat.c
+++ b/sysdeps/unix/sysv/linux/fxstatat.c
@@ -37,7 +37,7 @@ int
 __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
 {
   int result;
-#ifdef STAT_IS_KERNEL_STAT
+#if STAT_IS_KERNEL_STAT
 # define kst (*st)
 #else
   struct kernel_stat kst;
@@ -46,7 +46,7 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
   result = INTERNAL_SYSCALL_CALL (newfstatat, fd, file, &kst, flag);
   if (!__glibc_likely (INTERNAL_SYSCALL_ERROR_P (result)))
     {
-#ifdef STAT_IS_KERNEL_STAT
+#if STAT_IS_KERNEL_STAT
       return 0;
 #else
       return __xstat_conv (vers, &kst, st);
diff --git a/sysdeps/unix/sysv/linux/hppa/kernel_stat.h b/sysdeps/unix/sysv/linux/hppa/kernel_stat.h
index a3ac53a1ef..0cbd010fc3 100644
--- a/sysdeps/unix/sysv/linux/hppa/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/hppa/kernel_stat.h
@@ -30,5 +30,6 @@ struct kernel_stat {
 #define _HAVE_STAT_NSEC
 #define _HAVE_STAT64_NSEC
 
+#define STAT_IS_KERNEL_STAT 0
 #define XSTAT_IS_XSTAT64 0
 #define STATFS_IS_STATFS64 0
diff --git a/sysdeps/unix/sysv/linux/kernel_stat.h b/sysdeps/unix/sysv/linux/kernel_stat.h
index eecc962de3..ff54a4524c 100644
--- a/sysdeps/unix/sysv/linux/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/kernel_stat.h
@@ -34,5 +34,6 @@ struct kernel_stat
 #define _HAVE_STAT64___ST_INO
 #define _HAVE_STAT64_NSEC
 
+#define STAT_IS_KERNEL_STAT 0
 #define XSTAT_IS_XSTAT64 0
 #define STATFS_IS_STATFS64 0
diff --git a/sysdeps/unix/sysv/linux/lxstat.c b/sysdeps/unix/sysv/linux/lxstat.c
index e0cfc4f1fa..dcd685873d 100644
--- a/sysdeps/unix/sysv/linux/lxstat.c
+++ b/sysdeps/unix/sysv/linux/lxstat.c
@@ -37,7 +37,7 @@ __lxstat (int vers, const char *name, struct stat *buf)
   if (vers == _STAT_VER_KERNEL)
     return INLINE_SYSCALL (lstat, 2, name, buf);
 
-#ifdef STAT_IS_KERNEL_STAT
+#if STAT_IS_KERNEL_STAT
   return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
 #else
   struct kernel_stat kbuf;
diff --git a/sysdeps/unix/sysv/linux/microblaze/kernel_stat.h b/sysdeps/unix/sysv/linux/microblaze/kernel_stat.h
index 765e0dca67..4daaedc4b6 100644
--- a/sysdeps/unix/sysv/linux/microblaze/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/microblaze/kernel_stat.h
@@ -48,5 +48,6 @@ struct kernel_stat
 #define _HAVE_STAT64___UNUSED5
 };
 
+#define STAT_IS_KERNEL_STAT 0
 #define XSTAT_IS_XSTAT64 0
 #define STATFS_IS_STATFS64 0
diff --git a/sysdeps/unix/sysv/linux/mips/kernel_stat.h b/sysdeps/unix/sysv/linux/mips/kernel_stat.h
index 388df1bfff..e75f3e805b 100644
--- a/sysdeps/unix/sysv/linux/mips/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/mips/kernel_stat.h
@@ -56,5 +56,6 @@ struct kernel_stat
   };
 #endif
 
+#define STAT_IS_KERNEL_STAT 0
 #define XSTAT_IS_XSTAT64 0
 #define STATFS_IS_STATFS64 0
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h b/sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h
index c5948a4d3c..75610b8df3 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h
@@ -47,5 +47,6 @@ struct kernel_stat
 #define _HAVE_STAT64___PAD2
 #define _HAVE_STAT64_NSEC
 
+#define STAT_IS_KERNEL_STAT 0
 #define XSTAT_IS_XSTAT64 0
 #define STATFS_IS_STATFS64 0
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h b/sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h
index a4416009f1..5c8cacaf67 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h
@@ -31,5 +31,6 @@ struct kernel_stat
 #define _HAVE_STAT_NSEC
 #define _HAVE_STAT64_NSEC
 
+#define STAT_IS_KERNEL_STAT 0
 #define XSTAT_IS_XSTAT64 0
 #define STATFS_IS_STATFS64 0
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h b/sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h
index 30afb553b9..d14b2487ac 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h
@@ -44,5 +44,6 @@ struct kernel_stat64
     long int __glibc_reserved[3];
   };
 
+#define STAT_IS_KERNEL_STAT 0
 #define XSTAT_IS_XSTAT64 1
 #define STATFS_IS_STATFS64 0
diff --git a/sysdeps/unix/sysv/linux/xstat.c b/sysdeps/unix/sysv/linux/xstat.c
index a93d635611..76c90e20c7 100644
--- a/sysdeps/unix/sysv/linux/xstat.c
+++ b/sysdeps/unix/sysv/linux/xstat.c
@@ -37,7 +37,7 @@ __xstat (int vers, const char *name, struct stat *buf)
   if (vers == _STAT_VER_KERNEL)
     return INLINE_SYSCALL (stat, 2, name, buf);
 
-#ifdef STAT_IS_KERNEL_STAT
+#if STAT_IS_KERNEL_STAT
   return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
 #else
   struct kernel_stat kbuf;
diff --git a/sysdeps/unix/sysv/linux/xstatconv.c b/sysdeps/unix/sysv/linux/xstatconv.c
index c01fb00a3a..3622a82cd0 100644
--- a/sysdeps/unix/sysv/linux/xstatconv.c
+++ b/sysdeps/unix/sysv/linux/xstatconv.c
@@ -20,7 +20,7 @@
 #include <sys/stat.h>
 #include <kernel_stat.h>
 
-#ifdef STAT_IS_KERNEL_STAT
+#if STAT_IS_KERNEL_STAT
 
 /* Dummy.  */
 struct kernel_stat;
diff --git a/sysdeps/unix/sysv/linux/xstatconv.h b/sysdeps/unix/sysv/linux/xstatconv.h
index 39102c9469..5319236cae 100644
--- a/sysdeps/unix/sysv/linux/xstatconv.h
+++ b/sysdeps/unix/sysv/linux/xstatconv.h
@@ -16,7 +16,7 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#ifndef STAT_IS_KERNEL_STAT
+#if !STAT_IS_KERNEL_STAT
 extern int __xstat_conv (int vers, struct kernel_stat *kbuf, void *ubuf)
   attribute_hidden;
 extern int __xstat64_conv (int vers, struct kernel_stat *kbuf, void *ubuf)
-- 
2.25.1


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

* [PATCH 02/16] linux: Define STAT64_IS_KERNEL_STAT64
  2020-07-23 19:46 [PATCH 00/16] Add y2038 support for stat functions Adhemerval Zanella via Libc-alpha
  2020-07-23 19:46 ` [PATCH 01/16] linux: Always define STAT_IS_KERNEL_STAT Adhemerval Zanella via Libc-alpha
@ 2020-07-23 19:46 ` Adhemerval Zanella via Libc-alpha
  2020-07-24  8:20   ` Lukasz Majewski
  2020-07-23 19:46 ` [PATCH 03/16] linux: Consolidate xstat{64} Adhemerval Zanella via Libc-alpha
                   ` (13 subsequent siblings)
  15 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-07-23 19:46 UTC (permalink / raw)
  To: libc-alpha; +Cc: Alistair Francis

It indicates that the glibc export stat64 is similar in size and
layout of the kernel stat64 used on the syscall.  It is not currently
used on stat implementation, but the idea is to indicate whether
to use the kernel_stat to issue on the syscall on the *stat*64
variant (more specifically on mips which its exported ABI does not
match the kernel).
---
 sysdeps/unix/sysv/linux/alpha/kernel_stat.h             | 1 +
 sysdeps/unix/sysv/linux/arc/kernel_stat.h               | 1 +
 sysdeps/unix/sysv/linux/hppa/kernel_stat.h              | 1 +
 sysdeps/unix/sysv/linux/ia64/kernel_stat.h              | 1 +
 sysdeps/unix/sysv/linux/kernel_stat.h                   | 1 +
 sysdeps/unix/sysv/linux/microblaze/kernel_stat.h        | 1 +
 sysdeps/unix/sysv/linux/mips/kernel_stat.h              | 6 ++++++
 sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h | 1 +
 sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h | 1 +
 sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h      | 1 +
 sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h     | 1 +
 sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h     | 6 ++++++
 sysdeps/unix/sysv/linux/x86_64/kernel_stat.h            | 1 +
 13 files changed, 23 insertions(+)

diff --git a/sysdeps/unix/sysv/linux/alpha/kernel_stat.h b/sysdeps/unix/sysv/linux/alpha/kernel_stat.h
index 9bcc96c577..ff69045f8f 100644
--- a/sysdeps/unix/sysv/linux/alpha/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/alpha/kernel_stat.h
@@ -86,5 +86,6 @@ struct glibc21_stat
   };
 
 #define STAT_IS_KERNEL_STAT 0
+#define STAT64_IS_KERNEL_STAT64 1
 #define XSTAT_IS_XSTAT64 1
 #define STATFS_IS_STATFS64 0
diff --git a/sysdeps/unix/sysv/linux/arc/kernel_stat.h b/sysdeps/unix/sysv/linux/arc/kernel_stat.h
index 8fdd86b9e8..fd9b113f45 100644
--- a/sysdeps/unix/sysv/linux/arc/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/arc/kernel_stat.h
@@ -19,6 +19,7 @@
 
 /* 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
diff --git a/sysdeps/unix/sysv/linux/hppa/kernel_stat.h b/sysdeps/unix/sysv/linux/hppa/kernel_stat.h
index 0cbd010fc3..e8ad135e70 100644
--- a/sysdeps/unix/sysv/linux/hppa/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/hppa/kernel_stat.h
@@ -31,5 +31,6 @@ struct kernel_stat {
 #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
index b38bf741d3..c96a0589dc 100644
--- a/sysdeps/unix/sysv/linux/ia64/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/ia64/kernel_stat.h
@@ -17,5 +17,6 @@
    <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 0
diff --git a/sysdeps/unix/sysv/linux/kernel_stat.h b/sysdeps/unix/sysv/linux/kernel_stat.h
index ff54a4524c..b1bc1459f0 100644
--- a/sysdeps/unix/sysv/linux/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/kernel_stat.h
@@ -35,5 +35,6 @@ struct kernel_stat
 #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/microblaze/kernel_stat.h b/sysdeps/unix/sysv/linux/microblaze/kernel_stat.h
index 4daaedc4b6..9ab1e50115 100644
--- a/sysdeps/unix/sysv/linux/microblaze/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/microblaze/kernel_stat.h
@@ -49,5 +49,6 @@ struct kernel_stat
 };
 
 #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/mips/kernel_stat.h b/sysdeps/unix/sysv/linux/mips/kernel_stat.h
index e75f3e805b..21dba2de73 100644
--- a/sysdeps/unix/sysv/linux/mips/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/mips/kernel_stat.h
@@ -1,3 +1,6 @@
+#ifndef _KERNEL_STAT_H
+#define _KERNEL_STAT_H
+
 #include <sgidefs.h>
 /* As tempting as it is to define XSTAT_IS_XSTAT64 for n64, the
    userland data structures are not identical, because of different
@@ -57,5 +60,8 @@ struct kernel_stat
 #endif
 
 #define STAT_IS_KERNEL_STAT 0
+#define STAT64_IS_KERNEL_STAT64 0
 #define XSTAT_IS_XSTAT64 0
 #define STATFS_IS_STATFS64 0
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h b/sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h
index 75610b8df3..5757e65f8e 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h
@@ -48,5 +48,6 @@ struct kernel_stat
 #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/powerpc/powerpc64/kernel_stat.h b/sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h
index 5c10da3356..9f11b69e4f 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h
@@ -17,5 +17,6 @@
    <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 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
index b38bf741d3..c96a0589dc 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h
@@ -17,5 +17,6 @@
    <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 0
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h b/sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h
index 5c8cacaf67..4a2df42d37 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h
@@ -32,5 +32,6 @@ struct kernel_stat
 #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/sparc/sparc64/kernel_stat.h b/sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h
index d14b2487ac..0f3d405239 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h
@@ -1,3 +1,6 @@
+#ifndef _KERNEL_STAT_H
+#define _KERNEL_STAT_H
+
 /* Definition of `struct stat' used in the kernel */
 struct kernel_stat
   {
@@ -45,5 +48,8 @@ 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
+
+#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 b38bf741d3..c96a0589dc 100644
--- a/sysdeps/unix/sysv/linux/x86_64/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/x86_64/kernel_stat.h
@@ -17,5 +17,6 @@
    <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 0
-- 
2.25.1


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

* [PATCH 03/16] linux: Consolidate xstat{64}
  2020-07-23 19:46 [PATCH 00/16] Add y2038 support for stat functions Adhemerval Zanella via Libc-alpha
  2020-07-23 19:46 ` [PATCH 01/16] linux: Always define STAT_IS_KERNEL_STAT Adhemerval Zanella via Libc-alpha
  2020-07-23 19:46 ` [PATCH 02/16] linux: Define STAT64_IS_KERNEL_STAT64 Adhemerval Zanella via Libc-alpha
@ 2020-07-23 19:46 ` Adhemerval Zanella via Libc-alpha
  2020-07-23 20:51   ` Joseph Myers
                     ` (2 more replies)
  2020-07-23 19:46 ` [PATCH 04/16] linux: Consolidate lxstat{64} Adhemerval Zanella via Libc-alpha
                   ` (12 subsequent siblings)
  15 siblings, 3 replies; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-07-23 19:46 UTC (permalink / raw)
  To: libc-alpha; +Cc: Alistair Francis

The LFS support is implemented on xstat64.c, instead of xstat.c for
64-bit architectures.  The xstat.c implements the non-LFS it is
no-op for !XSTAT_IS_XSTAT64.

The generic non-LFS implementation handle two cases:

  1. New kABIs which uses generic pre 64-bit time Linux ABI (csky and
     nios): it issues __NR_fstat64 plus handle the overflow on st_ino,
     st_size, or st_blocks.  It only handles _STAT_VER_KERNEL.

  2. Old KABIs with old non-LFS support (arm, i386, hppa, m68k,
     microblaze, s390, sh, powerpc, and sparc32).  For _STAT_VER_KERNEL
     it issues __NR_stat, otherwise it issues __NR_stat64 and convert
     to non-LFS stat struct handling possible overflows on st_ino,
     st_size, or st_blocks.

Also the  non-LFS mips is an outlier and it has its own implementation
since _STAT_VER_LINUX requires a different conversion function (it uses
the kernel_stat as the syscall argument since its exported ABI is
different than the kernel one for both non-LFS and LFS implementation).

The generic LFS implementation handles multiple cases:

  1. XSTAT_IS_XSTAT64 being 1:

    1.1. Old 64-bit kABI (ia64, powerpc64*, s390x, sparc64, x86_64): it
         issues __NR_stat for _STAT_VER_KERNEL or _STAT_VER_LINUX.

    1.2. New kABIs which uses generic 64-bit Linux ABI (aarch64 and
         riscv64): it issues __NR_newfstatat and only for
         _STAT_VER_KERNEL.

    1.3. New 32-bit kABIs with only 64-bit time_t support (arc and
	 riscv32): it issues __NR_statx and covert to struct stat64.

  2. Old ABIs with XSTAT_IS_XSTAT64 being 0:

    2.1. New kABIs which uses generic pre 64-bit time Linux ABI (csky
	 and nios2): it issues __NR_fstatat64 for _STAT_VER_KERNEL.

    2.2. Old kABIs with old non-LFS support (arm, i386, hppa, m68k,
	 microblaze, s390, sh, mips32, powerpc32, and sparc32): it
	 issues __NR_stat64.

Also, two special cases requires specific LFS implementations:

  1. alpha: it requires to handle _STAT_VER_KERNEL64 to call __NR_stat64
     or use the kernel_stat with __NR_stat otherwise.

  2. mips64: as for non-LFS implementation its ABIs differ from glibc
     exported one, which requires an specific conversion function to
     handle the kernel_stat.

Checked with a build for all affected ABIs. I also checked on x86_64,
i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and s390x.
---
 sysdeps/unix/sysv/linux/alpha/xstat.c         | 57 ----------------
 .../{generic/xstat.c => alpha/xstat64.c}      | 47 ++++++-------
 sysdeps/unix/sysv/linux/arm/xstat.c           |  1 -
 .../sysv/linux/generic/wordsize-32/xstat.c    | 54 ---------------
 .../sysv/linux/generic/wordsize-32/xstat64.c  | 63 -----------------
 sysdeps/unix/sysv/linux/hppa/xstat.c          |  1 -
 sysdeps/unix/sysv/linux/i386/xstat.c          | 59 ----------------
 sysdeps/unix/sysv/linux/m68k/xstat.c          |  1 -
 sysdeps/unix/sysv/linux/microblaze/xstat.c    |  1 -
 sysdeps/unix/sysv/linux/mips/mips64/xstat64.c | 16 +----
 .../sysv/linux/{wordsize-64 => mips}/xstat.c  | 32 +++++----
 .../unix/sysv/linux/powerpc/powerpc32/xstat.c |  1 -
 sysdeps/unix/sysv/linux/s390/s390-32/xstat.c  |  1 -
 sysdeps/unix/sysv/linux/sh/xstat.c            |  1 -
 sysdeps/unix/sysv/linux/sparc/sparc32/xstat.c |  1 -
 sysdeps/unix/sysv/linux/sparc/sparc64/xstat.c |  1 -
 sysdeps/unix/sysv/linux/wordsize-64/xstat64.c |  1 -
 sysdeps/unix/sysv/linux/xstat.c               | 60 +++++++++--------
 sysdeps/unix/sysv/linux/xstat64.c             | 51 ++++++++++++--
 sysdeps/unix/sysv/linux/xstatover.h           | 67 +++++++++++++++++++
 20 files changed, 184 insertions(+), 332 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/alpha/xstat.c
 rename sysdeps/unix/sysv/linux/{generic/xstat.c => alpha/xstat64.c} (57%)
 delete mode 100644 sysdeps/unix/sysv/linux/arm/xstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/xstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/xstat64.c
 delete mode 100644 sysdeps/unix/sysv/linux/hppa/xstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/i386/xstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/m68k/xstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/microblaze/xstat.c
 rename sysdeps/unix/sysv/linux/{wordsize-64 => mips}/xstat.c (67%)
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/xstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/xstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/sh/xstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/xstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/xstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/xstat64.c
 create mode 100644 sysdeps/unix/sysv/linux/xstatover.h

diff --git a/sysdeps/unix/sysv/linux/alpha/xstat.c b/sysdeps/unix/sysv/linux/alpha/xstat.c
deleted file mode 100644
index 3ba1ae1811..0000000000
--- a/sysdeps/unix/sysv/linux/alpha/xstat.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/* xstat using old-style Unix stat system call.
-   Copyright (C) 2004-2020 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 __xstat64 __xstat64_disable
-
-#include <errno.h>
-#include <stddef.h>
-#include <sys/stat.h>
-#include <kernel_stat.h>
-#include <sysdep.h>
-#include <sys/syscall.h>
-#include <xstatconv.h>
-
-#undef __xstat64
-
-
-/* Get information about the file NAME in BUF.  */
-int
-__xstat (int vers, const char *name, struct stat *buf)
-{
-  int result;
-  struct kernel_stat kbuf;
-
-  if (vers == _STAT_VER_KERNEL64)
-    {
-      result = INTERNAL_SYSCALL_CALL (stat64, name, buf);
-      if (__glibc_likely (!INTERNAL_SYSCALL_ERROR_P (result)))
-	return result;
-      __set_errno (INTERNAL_SYSCALL_ERRNO (result));
-      return -1;
-    }
-
-  result = INTERNAL_SYSCALL_CALL (stat, name, &kbuf);
-  if (__glibc_likely (!INTERNAL_SYSCALL_ERROR_P (result)))
-    return __xstat_conv (vers, &kbuf, buf);
-  __set_errno (INTERNAL_SYSCALL_ERRNO (result));
-  return -1;
-}
-hidden_def (__xstat)
-weak_alias (__xstat, _xstat);
-strong_alias (__xstat, __xstat64);
-hidden_ver (__xstat, __xstat64)
diff --git a/sysdeps/unix/sysv/linux/generic/xstat.c b/sysdeps/unix/sysv/linux/alpha/xstat64.c
similarity index 57%
rename from sysdeps/unix/sysv/linux/generic/xstat.c
rename to sysdeps/unix/sysv/linux/alpha/xstat64.c
index 2eb27a6f91..ac1af53780 100644
--- a/sysdeps/unix/sysv/linux/generic/xstat.c
+++ b/sysdeps/unix/sysv/linux/alpha/xstat64.c
@@ -1,6 +1,6 @@
-/* Copyright (C) 2011-2020 Free Software Foundation, Inc.
+/* xstat using old-style Unix stat system call.
+   Copyright (C) 2004-2020 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,33 +16,34 @@
    License along with the GNU C Library.  If not, see
    <https://www.gnu.org/licenses/>.  */
 
-/* Ignore prototype to avoid error if we alias __xstat and __xstat64. */
-#define __xstat64 __xstat64_disable
-
-#include <errno.h>
-#include <stddef.h>
-#include <fcntl.h>
+#define __xstat __redirect___xstat
 #include <sys/stat.h>
+#undef __xstat
+#include <fcntl.h>
 #include <kernel_stat.h>
-
 #include <sysdep.h>
-#include <sys/syscall.h>
+#include <xstatconv.h>
 
 /* Get information about the file NAME in BUF.  */
 int
-__xstat (int vers, const char *name, struct stat *buf)
+__xstat64 (int vers, const char *name, struct stat64 *buf)
 {
-  if (vers == _STAT_VER_KERNEL)
-    return INLINE_SYSCALL (newfstatat, 4, AT_FDCWD, name, buf, 0);
-
-  errno = EINVAL;
-  return -1;
+  switch (vers)
+    {
+    case _STAT_VER_KERNEL64:
+      return INLINE_SYSCALL_CALL (stat64, name, buf);
+
+    default:
+      {
+        struct kernel_stat kbuf;
+	int r = INTERNAL_SYSCALL_CALL (stat, name, &kbuf);
+	if (r == 0)
+	  return __xstat_conv (vers, &kbuf, buf);
+	return INLINE_SYSCALL_ERROR_RETURN_VALUE (-r);
+      }
+    }
 }
+weak_alias (__xstat64, __xstat);
+weak_alias (__xstat64, __GI___xstat);
 
-hidden_def (__xstat)
-weak_alias (__xstat, _xstat);
-#if XSTAT_IS_XSTAT64
-#undef __xstat64
-strong_alias (__xstat, __xstat64);
-hidden_ver (__xstat, __xstat64)
-#endif
+hidden_def (__xstat64)
diff --git a/sysdeps/unix/sysv/linux/arm/xstat.c b/sysdeps/unix/sysv/linux/arm/xstat.c
deleted file mode 100644
index e9869f5508..0000000000
--- a/sysdeps/unix/sysv/linux/arm/xstat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/xstat.c>
diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/xstat.c b/sysdeps/unix/sysv/linux/generic/wordsize-32/xstat.c
deleted file mode 100644
index a4a921c1ea..0000000000
--- a/sysdeps/unix/sysv/linux/generic/wordsize-32/xstat.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Copyright (C) 2011-2020 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 <errno.h>
-#include <stddef.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <kernel_stat.h>
-
-#include <sysdep.h>
-#include <sys/syscall.h>
-
-#if !XSTAT_IS_XSTAT64
-#include "overflow.h"
-#include <statx_cp.h>
-
-/* Get information about the file NAME in BUF.  */
-int
-__xstat (int vers, const char *name, struct stat *buf)
-{
-  if (vers == _STAT_VER_KERNEL)
-    {
-# ifdef __NR_fstatat64
-      int rc = INLINE_SYSCALL (fstatat64, 4, AT_FDCWD, name, buf, 0);
-# else
-      struct statx tmp;
-      int rc = INLINE_SYSCALL (statx, 5, AT_FDCWD, name, AT_NO_AUTOMOUNT,
-                               STATX_BASIC_STATS, &tmp);
-      if (rc == 0)
-        __cp_stat64_statx ((struct stat64 *)buf, &tmp);
-# endif
-      return rc ?: stat_overflow (buf);
-    }
-
-  errno = EINVAL;
-  return -1;
-}
-hidden_def (__xstat)
-#endif
diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/xstat64.c b/sysdeps/unix/sysv/linux/generic/wordsize-32/xstat64.c
deleted file mode 100644
index 0848b5a4b4..0000000000
--- a/sysdeps/unix/sysv/linux/generic/wordsize-32/xstat64.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/* Copyright (C) 2011-2020 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/>.  */
-
-/* Hide the prototype for __xstat so that GCC will not complain about
-   the different function signature if it is aliased to  __xstat64.
-   If XSTAT_IS_XSTAT64 is set to non-zero then the stat and stat64
-   structures have an identical layout but different type names.  */
-
-#define __xstat __xstat_disable
-
-#include <errno.h>
-#include <stddef.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <kernel_stat.h>
-
-#include <sysdep.h>
-#include <sys/syscall.h>
-
-#include <statx_cp.h>
-
-/* Get information about the file NAME in BUF.  */
-int
-__xstat64 (int vers, const char *name, struct stat64 *buf)
-{
-  if (vers == _STAT_VER_KERNEL)
-    {
-#ifdef __NR_fstatat64
-      return INLINE_SYSCALL (fstatat64, 4, AT_FDCWD, name, buf, 0);
-#else
-      struct statx tmp;
-      int rc = INLINE_SYSCALL (statx, 5, AT_FDCWD, name, AT_NO_AUTOMOUNT,
-                               STATX_BASIC_STATS, &tmp);
-      if (rc == 0)
-        __cp_stat64_statx (buf, &tmp);
-      return rc;
-#endif
-    }
-  errno = EINVAL;
-  return -1;
-}
-hidden_def (__xstat64)
-
-#undef __xstat
-#if XSTAT_IS_XSTAT64
-strong_alias (__xstat64, __xstat)
-hidden_ver (__xstat64, __xstat)
-#endif
diff --git a/sysdeps/unix/sysv/linux/hppa/xstat.c b/sysdeps/unix/sysv/linux/hppa/xstat.c
deleted file mode 100644
index e9869f5508..0000000000
--- a/sysdeps/unix/sysv/linux/hppa/xstat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/xstat.c>
diff --git a/sysdeps/unix/sysv/linux/i386/xstat.c b/sysdeps/unix/sysv/linux/i386/xstat.c
deleted file mode 100644
index 96f67168ac..0000000000
--- a/sysdeps/unix/sysv/linux/i386/xstat.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/* xstat using old-style Unix stat system call.
-   Copyright (C) 1991-2020 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/>.  */
-
-/* Ho hum, if xstat == xstat64 we must get rid of the prototype or gcc
-   will complain since they don't strictly match.  */
-#define __xstat64 __xstat64_disable
-
-#include <errno.h>
-#include <stddef.h>
-#include <sys/stat.h>
-#include <kernel_stat.h>
-
-#include <sysdep.h>
-#include <sys/syscall.h>
-
-#include <xstatconv.h>
-
-
-/* Get information about the file NAME in BUF.  */
-int
-__xstat (int vers, const char *name, struct stat *buf)
-{
-  int result;
-
-  if (vers == _STAT_VER_KERNEL)
-    return INLINE_SYSCALL (stat, 2, name, buf);
-
-  {
-    struct stat64 buf64;
-
-    result = INTERNAL_SYSCALL_CALL (stat64, name, &buf64);
-    if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result)))
-      return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (result));
-    else
-      return __xstat32_conv (vers, &buf64, buf);
-  }
-}
-hidden_def (__xstat)
-weak_alias (__xstat, _xstat);
-#if XSTAT_IS_XSTAT64
-# undef __xstat64
-strong_alias (__xstat, __xstat64);
-hidden_ver (__xstat, __xstat64)
-#endif
diff --git a/sysdeps/unix/sysv/linux/m68k/xstat.c b/sysdeps/unix/sysv/linux/m68k/xstat.c
deleted file mode 100644
index e9869f5508..0000000000
--- a/sysdeps/unix/sysv/linux/m68k/xstat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/xstat.c>
diff --git a/sysdeps/unix/sysv/linux/microblaze/xstat.c b/sysdeps/unix/sysv/linux/microblaze/xstat.c
deleted file mode 100644
index e9869f5508..0000000000
--- a/sysdeps/unix/sysv/linux/microblaze/xstat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/xstat.c>
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/xstat64.c b/sysdeps/unix/sysv/linux/mips/mips64/xstat64.c
index 7eee9e67d4..99b03c7593 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/xstat64.c
+++ b/sysdeps/unix/sysv/linux/mips/mips64/xstat64.c
@@ -1,4 +1,4 @@
-/* xstat64 using 64-bit MIPS stat system call.
+/* xstat64 using Linux stat64 system call.
    Copyright (C) 1991-2020 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -16,14 +16,9 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <stddef.h>
 #include <sys/stat.h>
 #include <kernel_stat.h>
-
 #include <sysdep.h>
-#include <sys/syscall.h>
-
 #include <xstatconv.h>
 
 /* Get information about the file NAME in BUF.  */
@@ -31,14 +26,9 @@
 int
 __xstat64 (int vers, const char *name, struct stat64 *buf)
 {
-  int result;
   struct kernel_stat kbuf;
-
-  result = INLINE_SYSCALL (stat, 2, name, &kbuf);
-  if (result == 0)
-    result = __xstat64_conv (vers, &kbuf, buf);
-
-  return result;
+  int r = INLINE_SYSCALL_CALL (stat, name, &kbuf);
+  return r ?: __xstat64_conv (vers, &kbuf, buf);
 }
 
 hidden_def (__xstat64)
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/xstat.c b/sysdeps/unix/sysv/linux/mips/xstat.c
similarity index 67%
rename from sysdeps/unix/sysv/linux/wordsize-64/xstat.c
rename to sysdeps/unix/sysv/linux/mips/xstat.c
index 438d54d291..835691cf89 100644
--- a/sysdeps/unix/sysv/linux/wordsize-64/xstat.c
+++ b/sysdeps/unix/sysv/linux/mips/xstat.c
@@ -16,29 +16,27 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-/* Ho hum, since xstat == xstat64 we must get rid of the prototype or gcc
-   will complain since they don't strictly match.  */
-#define __xstat64 __xstat64_disable
-
-#include <errno.h>
-#include <stddef.h>
 #include <sys/stat.h>
-
+#include <fcntl.h>
+#include <kernel_stat.h>
 #include <sysdep.h>
-#include <sys/syscall.h>
+#include <xstatconv.h>
 
 /* Get information about the file NAME in BUF.  */
 int
 __xstat (int vers, const char *name, struct stat *buf)
 {
-  if (vers == _STAT_VER_KERNEL || vers == _STAT_VER_LINUX)
-    return INLINE_SYSCALL (stat, 2, name, buf);
-
-  __set_errno (EINVAL);
-  return -1;
+  switch (vers)
+    {
+    case _STAT_VER_KERNEL:
+      return INLINE_SYSCALL_CALL (stat, name, buf);
+
+    default:
+      {
+	struct kernel_stat kbuf;
+	int r = INTERNAL_SYSCALL_CALL (stat, name, &kbuf);
+	return r ?: __xstat_conv (vers, &kbuf, buf);
+      }
+    }
 }
 hidden_def (__xstat)
-weak_alias (__xstat, _xstat);
-#undef __xstat64
-strong_alias (__xstat, __xstat64);
-hidden_ver (__xstat, __xstat64)
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/xstat.c b/sysdeps/unix/sysv/linux/powerpc/powerpc32/xstat.c
deleted file mode 100644
index e9869f5508..0000000000
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/xstat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/xstat.c>
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/xstat.c b/sysdeps/unix/sysv/linux/s390/s390-32/xstat.c
deleted file mode 100644
index e9869f5508..0000000000
--- a/sysdeps/unix/sysv/linux/s390/s390-32/xstat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/xstat.c>
diff --git a/sysdeps/unix/sysv/linux/sh/xstat.c b/sysdeps/unix/sysv/linux/sh/xstat.c
deleted file mode 100644
index e9869f5508..0000000000
--- a/sysdeps/unix/sysv/linux/sh/xstat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/xstat.c>
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/xstat.c b/sysdeps/unix/sysv/linux/sparc/sparc32/xstat.c
deleted file mode 100644
index e9869f5508..0000000000
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/xstat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/xstat.c>
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/xstat.c b/sysdeps/unix/sysv/linux/sparc/sparc64/xstat.c
deleted file mode 100644
index c3b00cb1d4..0000000000
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/xstat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../i386/xstat.c"
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/xstat64.c b/sysdeps/unix/sysv/linux/wordsize-64/xstat64.c
deleted file mode 100644
index e7acd3b45e..0000000000
--- a/sysdeps/unix/sysv/linux/wordsize-64/xstat64.c
+++ /dev/null
@@ -1 +0,0 @@
-/* xstat64 is in xstat.c */
diff --git a/sysdeps/unix/sysv/linux/xstat.c b/sysdeps/unix/sysv/linux/xstat.c
index 76c90e20c7..0ae52b1901 100644
--- a/sysdeps/unix/sysv/linux/xstat.c
+++ b/sysdeps/unix/sysv/linux/xstat.c
@@ -16,44 +16,46 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-/* Ho hum, if xstat == xstat64 we must get rid of the prototype or gcc
-   will complain since they don't strictly match.  */
-#define __xstat64 __xstat64_disable
-
-#include <errno.h>
-#include <stddef.h>
 #include <sys/stat.h>
+#include <fcntl.h>
 #include <kernel_stat.h>
-
 #include <sysdep.h>
-#include <sys/syscall.h>
 
-#include <xstatconv.h>
+#if !XSTAT_IS_XSTAT64
+# include <xstatconv.h>
+# include <xstatover.h>
 
 /* Get information about the file NAME in BUF.  */
 int
 __xstat (int vers, const char *name, struct stat *buf)
 {
-  if (vers == _STAT_VER_KERNEL)
-    return INLINE_SYSCALL (stat, 2, name, buf);
-
-#if STAT_IS_KERNEL_STAT
-  return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
-#else
-  struct kernel_stat kbuf;
-  int result;
-
-  result = INLINE_SYSCALL (stat, 2, name, &kbuf);
-  if (result == 0)
-    result = __xstat_conv (vers, &kbuf, buf);
-
-  return result;
+  switch (vers)
+    {
+    case _STAT_VER_KERNEL:
+      {
+# if STAT_IS_KERNEL_STAT
+	/* New kABIs which uses generic pre 64-bit time Linux ABI,
+	   e.g. csky, nios2  */
+	int r = INLINE_SYSCALL_CALL (fstatat64, AT_FDCWD, name, buf, 0);
+	return r ?: stat_overflow (buf);
+# else
+	/* Old kABIs with old non-LFS support, e.g. arm, i386, hppa, m68k,
+	   microblaze, s390, sh, powerpc, and sparc32.  */
+	return INLINE_SYSCALL_CALL (stat, name, buf);
+# endif
+      }
+
+    default:
+      {
+# if STAT_IS_KERNEL_STAT
+	return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+# else
+	struct stat64 buf64;
+	int r = INLINE_SYSCALL_CALL (stat64, name, &buf64);
+	return r ?: __xstat32_conv (vers, &buf64, buf);
 #endif
+      }
+    }
 }
 hidden_def (__xstat)
-weak_alias (__xstat, _xstat);
-#if XSTAT_IS_XSTAT64
-#undef __xstat64
-strong_alias (__xstat, __xstat64);
-hidden_ver (__xstat, __xstat64)
-#endif
+#endif /* XSTAT_IS_XSTAT64  */
diff --git a/sysdeps/unix/sysv/linux/xstat64.c b/sysdeps/unix/sysv/linux/xstat64.c
index 16c6e69710..4feb55f429 100644
--- a/sysdeps/unix/sysv/linux/xstat64.c
+++ b/sysdeps/unix/sysv/linux/xstat64.c
@@ -16,24 +16,61 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <stddef.h>
+#define __xstat __redirect___xstat
 #include <sys/stat.h>
+#undef __xstat
+#include <fcntl.h>
 #include <kernel_stat.h>
-
 #include <sysdep.h>
-#include <sys/syscall.h>
+#include <xstatconv.h>
+#include <statx_cp.h>
 
 /* Get information about the file NAME in BUF.  */
 
 int
 ___xstat64 (int vers, const char *name, struct stat64 *buf)
 {
-  int result;
-  result = INLINE_SYSCALL (stat64, 2, name, buf);
-  return result;
+#if XSTAT_IS_XSTAT64
+# if defined __NR_stat
+  /* Old 64-bit kABI, e.g. ia64, powerpc64*, s390x, sparc64, x86_64.  */
+  if (vers == _STAT_VER_KERNEL || vers == _STAT_VER_LINUX)
+    return INLINE_SYSCALL_CALL (stat, name, buf);
+# elif defined __NR_newfstatat
+  /* New kABIs which uses generic 64-bit Linux ABI, e.g. aarch64, riscv64.  */
+  if (vers == _STAT_VER_KERNEL)
+    return INLINE_SYSCALL_CALL (newfstatat, AT_FDCWD, name, buf, 0);
+# else
+  /* New 32-bit kABIs with only 64-bit time_t support, e.g. arc, riscv32.  */
+  if (vers == _STAT_VER_KERNEL)
+    {
+      struct statx tmp;
+      int r = INLINE_SYSCALL_CALL (statx, AT_FDCWD, name, AT_NO_AUTOMOUNT,
+				   STATX_BASIC_STATS, &tmp);
+      if (r == 0)
+	__cp_stat64_statx (buf, &tmp);
+      return r;
+     }
+# endif
+#else
+# if STAT_IS_KERNEL_STAT
+  /* New kABIs which uses generic pre 64-bit time Linux ABI,
+     e.g. csky, nios2  */
+  if (vers == _STAT_VER_KERNEL)
+    return INLINE_SYSCALL_CALL (fstatat64, AT_FDCWD, name, buf, 0);
+# else
+  /* Old kABIs with old non-LFS support, e.g. arm, i386, hppa, m68k,
+     microblaze, s390, sh, mips32, powerpc32, and sparc32.  */
+  return INLINE_SYSCALL_CALL (stat64, name, buf);
+# endif /* STAT_IS_KERNEL_STAT  */
+#endif /* XSTAT_IS_XSTAT64  */
+
+  return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
 }
 
+#if XSTAT_IS_XSTAT64
+weak_alias (___xstat64, __xstat);
+weak_alias (___xstat64, __GI___xstat);
+#endif
 
 #include <shlib-compat.h>
 
diff --git a/sysdeps/unix/sysv/linux/xstatover.h b/sysdeps/unix/sysv/linux/xstatover.h
new file mode 100644
index 0000000000..20178114f9
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/xstatover.h
@@ -0,0 +1,67 @@
+/* Overflow tests for stat, statfs, and lseek functions.
+   Copyright (C) 2020 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 <sys/statfs.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 || !STAT_IS_KERNEL_STAT
+  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 || !STAT_IS_KERNEL_STAT
+  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 related	[flat|nested] 80+ messages in thread

* [PATCH 04/16] linux: Consolidate lxstat{64}
  2020-07-23 19:46 [PATCH 00/16] Add y2038 support for stat functions Adhemerval Zanella via Libc-alpha
                   ` (2 preceding siblings ...)
  2020-07-23 19:46 ` [PATCH 03/16] linux: Consolidate xstat{64} Adhemerval Zanella via Libc-alpha
@ 2020-07-23 19:46 ` Adhemerval Zanella via Libc-alpha
  2020-07-24  8:43   ` Lukasz Majewski
  2020-07-23 19:46 ` [PATCH 05/16] linux: Consolidate fxstat{64} Adhemerval Zanella via Libc-alpha
                   ` (11 subsequent siblings)
  15 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-07-23 19:46 UTC (permalink / raw)
  To: libc-alpha; +Cc: Alistair Francis

The LFS support is implemented on lxstat64.c, instead of lxstat.c for
64-bit architectures.  The xstat.c implements the non-LFS and it is
a no-op for !XSTAT_IS_XSTAT64.

The generic non-LFS implementation handles two cases:

  1. New kABIs which uses generic pre 64-bit time Linux ABI (csky and
     nios): it issues __NR_fstat64 with AT_SYMLINK_NOFOLLOW plus handles
     the possible overflow off st_ino, st_size, or st_blocks.  It only
     handles _STAT_VER_KERNEL.

  2. Old KABIs with old non-LFS support (arm, i386, hppa, m68k,
     microblaze, s390, sh, powerpc, and sparc32).  For _STAT_VER_KERNEL
     it issues __NR_lstat, otherwise it isseus __NR_lstat64 and convert
     to non-LFS stat struct and handle possible overflows on st_ino,
     st_size, or st_blocks.

Also non-LFS mips is an outlier and it has its own implementation since
_STAT_VER_LINUX requires a different conversion function (it uses the
kernel_stat as the syscall argument since its exported ABI is different
than the kernel one for both non-LFS and LFS implementation).

The generic LFS implementation handles multiple cases:

  1. XSTAT_IS_XSTAT64 being 1:

    1.1. Old 64-bit kABI (ia64, powerpc64*, s390x, sparc64, x86_64): it
         issues __NR_lstat for _STAT_VER_KERNEL or _STAT_VER_LINUX.

    1.2. New kABIs which uses generic 64-bit Linux ABI (aarch64 and
         riscv64): it issues __NR_newfstatat with AT_SYMLINK_NOFOLLOW and
         only for _STAT_VER_KERNEL.

    1.3. New 32-bit kABIs with only 64-bit time_t support (arc and
         riscv32): it issues __NR_statx and covert to struct stat64.

  2. Old ABIs with XSTAT_IS_XSTAT64 being 0:

    2.1. New kABIs which uses generic pre 64-bit time Linux ABI (csky
	 and nios2): it issues __NR_fstatat64 for _STAT_VER_KERNEL.

    2.2. Old kABIs with old non-LFS support (arm, i386, hppa, m68k,
	 microblaze, s390, sh, mips32, powerpc32, and sparc32): it
	 issues __NR_lstat64.

Also, two special cases requires specific LFS implementations:

  1. alpha: it requires to handle _STAT_VER_KERNEL64 to issue
     __NR_lstat64 and use the kernel_stat with __NR_lstat otherwise.

  2. mips64: as for non-LFS implementation its ABIs differ from
     glibc exported one, which requires a specific conversion
     function to handle the kernel_stat.

Checked with a build for all affected ABIs. I also checked on x86_64,
i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and s390x.
---
 sysdeps/unix/sysv/linux/alpha/lxstat.c        | 57 ----------------
 .../{generic/lxstat.c => alpha/lxstat64.c}    | 47 ++++++-------
 sysdeps/unix/sysv/linux/arm/lxstat.c          |  1 -
 .../sysv/linux/generic/wordsize-32/lxstat.c   | 55 ----------------
 .../sysv/linux/generic/wordsize-32/lxstat64.c | 66 -------------------
 sysdeps/unix/sysv/linux/hppa/lxstat.c         |  1 -
 sysdeps/unix/sysv/linux/i386/lxstat.c         | 60 -----------------
 sysdeps/unix/sysv/linux/lxstat.c              | 64 +++++++++---------
 sysdeps/unix/sysv/linux/lxstat64.c            | 58 +++++++++++++---
 sysdeps/unix/sysv/linux/m68k/lxstat.c         |  1 -
 sysdeps/unix/sysv/linux/microblaze/lxstat.c   |  1 -
 .../sysv/linux/{wordsize-64 => mips}/lxstat.c | 37 +++++------
 .../unix/sysv/linux/mips/mips64/lxstat64.c    | 14 +---
 .../sysv/linux/powerpc/powerpc32/lxstat.c     |  2 -
 sysdeps/unix/sysv/linux/s390/s390-32/lxstat.c |  1 -
 sysdeps/unix/sysv/linux/sh/lxstat.c           |  2 -
 .../unix/sysv/linux/sparc/sparc32/lxstat.c    |  2 -
 .../unix/sysv/linux/sparc/sparc64/lxstat.c    |  1 -
 .../unix/sysv/linux/wordsize-64/lxstat64.c    |  1 -
 19 files changed, 126 insertions(+), 345 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/alpha/lxstat.c
 rename sysdeps/unix/sysv/linux/{generic/lxstat.c => alpha/lxstat64.c} (55%)
 delete mode 100644 sysdeps/unix/sysv/linux/arm/lxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat64.c
 delete mode 100644 sysdeps/unix/sysv/linux/hppa/lxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/i386/lxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/m68k/lxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/microblaze/lxstat.c
 rename sysdeps/unix/sysv/linux/{wordsize-64 => mips}/lxstat.c (60%)
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/lxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/lxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/sh/lxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/lxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/lxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/lxstat64.c

diff --git a/sysdeps/unix/sysv/linux/alpha/lxstat.c b/sysdeps/unix/sysv/linux/alpha/lxstat.c
deleted file mode 100644
index eb03a5fbfe..0000000000
--- a/sysdeps/unix/sysv/linux/alpha/lxstat.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/* lxstat using old-style Unix stat system call.
-   Copyright (C) 2004-2020 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 __lxstat64 __lxstat64_disable
-
-#include <errno.h>
-#include <stddef.h>
-#include <sys/stat.h>
-#include <kernel_stat.h>
-#include <sysdep.h>
-#include <sys/syscall.h>
-#include <xstatconv.h>
-
-#undef __lxstat64
-
-
-/* Get information about the file NAME in BUF.  */
-int
-__lxstat (int vers, const char *name, struct stat *buf)
-{
-  int result;
-  struct kernel_stat kbuf;
-
-  if (vers == _STAT_VER_KERNEL64)
-    {
-      result = INTERNAL_SYSCALL_CALL (lstat64, name, buf);
-      if (__glibc_likely (!INTERNAL_SYSCALL_ERROR_P (result)))
-	return result;
-      __set_errno (INTERNAL_SYSCALL_ERRNO (result));
-      return -1;
-    }
-
-  result = INTERNAL_SYSCALL_CALL (lstat, name, &kbuf);
-  if (__glibc_likely (!INTERNAL_SYSCALL_ERROR_P (result)))
-    return __xstat_conv (vers, &kbuf, buf);
-  __set_errno (INTERNAL_SYSCALL_ERRNO (result));
-  return -1;
-}
-hidden_def (__lxstat)
-weak_alias (__lxstat, _lxstat);
-strong_alias (__lxstat, __lxstat64);
-hidden_ver (__lxstat, __lxstat64)
diff --git a/sysdeps/unix/sysv/linux/generic/lxstat.c b/sysdeps/unix/sysv/linux/alpha/lxstat64.c
similarity index 55%
rename from sysdeps/unix/sysv/linux/generic/lxstat.c
rename to sysdeps/unix/sysv/linux/alpha/lxstat64.c
index 1cf082961a..90dc0c7ce7 100644
--- a/sysdeps/unix/sysv/linux/generic/lxstat.c
+++ b/sysdeps/unix/sysv/linux/alpha/lxstat64.c
@@ -1,6 +1,6 @@
-/* Copyright (C) 2011-2020 Free Software Foundation, Inc.
+/* lxstat using old-style Unix stat system call.
+   Copyright (C) 2004-2020 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,33 +16,34 @@
    License along with the GNU C Library.  If not, see
    <https://www.gnu.org/licenses/>.  */
 
-/* Ignore prototype to avoid error if we alias __lxstat and __lxstat64. */
-#define __lxstat64 __lxstat64_disable
-
-#include <errno.h>
-#include <stddef.h>
-#include <fcntl.h>
+#define __lxstat __redirect___lxstat
 #include <sys/stat.h>
+#undef __lxstat
+#include <fcntl.h>
 #include <kernel_stat.h>
-
 #include <sysdep.h>
-#include <sys/syscall.h>
+#include <xstatconv.h>
 
 /* Get information about the file NAME in BUF.  */
 int
-__lxstat (int vers, const char *name, struct stat *buf)
+__lxstat64 (int vers, const char *name, struct stat64 *buf)
 {
-  if (vers == _STAT_VER_KERNEL)
-    return INLINE_SYSCALL (newfstatat, 4, AT_FDCWD, name, buf,
-                           AT_SYMLINK_NOFOLLOW);
-  errno = EINVAL;
-  return -1;
+  switch (vers)
+    {
+    case _STAT_VER_KERNEL64:
+      return INLINE_SYSCALL_CALL (lstat64, name, buf);
+
+    default:
+      {
+        struct kernel_stat kbuf;
+	int r = INTERNAL_SYSCALL_CALL (lstat, name, &kbuf);
+	if (r == 0)
+	  return __xstat_conv (vers, &kbuf, buf);
+	return INLINE_SYSCALL_ERROR_RETURN_VALUE (-r);
+      }
+    }
 }
+weak_alias (__lxstat64, __lxstat);
+weak_alias (__lxstat64, __GI___lxstat);
 
-hidden_def (__lxstat)
-weak_alias (__lxstat, _lxstat);
-#if XSTAT_IS_XSTAT64
-#undef __lxstat64
-strong_alias (__lxstat, __lxstat64);
-hidden_ver (__lxstat, __lxstat64)
-#endif
+hidden_def (__lxstat64)
diff --git a/sysdeps/unix/sysv/linux/arm/lxstat.c b/sysdeps/unix/sysv/linux/arm/lxstat.c
deleted file mode 100644
index 0efa0aea49..0000000000
--- a/sysdeps/unix/sysv/linux/arm/lxstat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/lxstat.c>
diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat.c b/sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat.c
deleted file mode 100644
index bd02631d68..0000000000
--- a/sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/* Copyright (C) 2011-2020 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 <errno.h>
-#include <stddef.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <kernel_stat.h>
-
-#include <sysdep.h>
-#include <sys/syscall.h>
-
-#if !XSTAT_IS_XSTAT64
-#include "overflow.h"
-#include <statx_cp.h>
-
-/* Get information about the file NAME in BUF.  */
-int
-__lxstat (int vers, const char *name, struct stat *buf)
-{
-  if (vers == _STAT_VER_KERNEL)
-    {
-#ifdef __NR_fstatat64
-      int rc = INLINE_SYSCALL (fstatat64, 4, AT_FDCWD, name, buf,
-                               AT_SYMLINK_NOFOLLOW);
-#else
-      struct statx tmp;
-      int rc = INLINE_SYSCALL (statx, 5, AT_FDCWD, name,
-                               AT_NO_AUTOMOUNT | AT_SYMLINK_NOFOLLOW,
-                               STATX_BASIC_STATS, &tmp);
-      if (rc == 0)
-        __cp_stat64_statx ((struct stat64 *)buf, &tmp);
-#endif
-      return rc ?: stat_overflow (buf);
-    }
-  errno = EINVAL;
-  return -1;
-}
-hidden_def (__lxstat)
-#endif
diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat64.c b/sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat64.c
deleted file mode 100644
index 3eab0a1847..0000000000
--- a/sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat64.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/* Copyright (C) 2011-2020 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/>.  */
-
-/* Hide the prototype for __lxstat so that GCC will not complain about
-   the different function signature if it is aliased to  __lxstat64.
-   If XSTAT_IS_XSTAT64 is set to non-zero then the stat and stat64
-   structures have an identical layout but different type names.  */
-
-#define __lxstat __lxstat_disable
-
-#include <errno.h>
-#include <stddef.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <kernel_stat.h>
-
-#include <sysdep.h>
-#include <sys/syscall.h>
-
-#include <statx_cp.h>
-
-/* Get information about the file NAME in BUF.  */
-int
-__lxstat64 (int vers, const char *name, struct stat64 *buf)
-{
-  if (vers == _STAT_VER_KERNEL)
-    {
-#ifdef __NR_fstatat64
-      return INLINE_SYSCALL (fstatat64, 4, AT_FDCWD, name, buf,
-                             AT_SYMLINK_NOFOLLOW);
-#else
-      struct statx tmp;
-      int rc = INLINE_SYSCALL (statx, 5, AT_FDCWD, name,
-                               AT_NO_AUTOMOUNT | AT_SYMLINK_NOFOLLOW,
-                               STATX_BASIC_STATS, &tmp);
-      if (rc == 0)
-        __cp_stat64_statx (buf, &tmp);
-      return rc;
-#endif
-    }
-
-  errno = EINVAL;
-  return -1;
-}
-hidden_def (__lxstat64)
-
-#undef __lxstat
-#if XSTAT_IS_XSTAT64
-strong_alias (__lxstat64, __lxstat)
-hidden_ver (__lxstat64, __lxstat)
-#endif
diff --git a/sysdeps/unix/sysv/linux/hppa/lxstat.c b/sysdeps/unix/sysv/linux/hppa/lxstat.c
deleted file mode 100644
index 0efa0aea49..0000000000
--- a/sysdeps/unix/sysv/linux/hppa/lxstat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/lxstat.c>
diff --git a/sysdeps/unix/sysv/linux/i386/lxstat.c b/sysdeps/unix/sysv/linux/i386/lxstat.c
deleted file mode 100644
index e960077893..0000000000
--- a/sysdeps/unix/sysv/linux/i386/lxstat.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/* lxstat using old-style Unix lstat system call.
-   Copyright (C) 1991-2020 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/>.  */
-
-/* Ho hum, if xstat == xstat64 we must get rid of the prototype or gcc
-   will complain since they don't strictly match.  */
-#define __lxstat64 __lxstat64_disable
-
-#include <errno.h>
-#include <stddef.h>
-#include <sys/stat.h>
-#include <kernel_stat.h>
-
-#include <sysdep.h>
-#include <sys/syscall.h>
-
-#include <xstatconv.h>
-
-
-/* Get information about the file NAME in BUF.  */
-int
-__lxstat (int vers, const char *name, struct stat *buf)
-{
-  int result;
-
-  if (vers == _STAT_VER_KERNEL)
-    return INLINE_SYSCALL (lstat, 2, name, buf);
-
-  {
-    struct stat64 buf64;
-
-    result = INTERNAL_SYSCALL_CALL (lstat64, name, &buf64);
-    if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result)))
-      return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (result));
-    else
-      return __xstat32_conv (vers, &buf64, buf);
-  }
-}
-
-hidden_def (__lxstat)
-weak_alias (__lxstat, _lxstat);
-#if XSTAT_IS_XSTAT64
-#undef __lxstat64
-strong_alias (__lxstat, __lxstat64);
-hidden_ver (__lxstat, __lxstat64)
-#endif
diff --git a/sysdeps/unix/sysv/linux/lxstat.c b/sysdeps/unix/sysv/linux/lxstat.c
index dcd685873d..dc63d20061 100644
--- a/sysdeps/unix/sysv/linux/lxstat.c
+++ b/sysdeps/unix/sysv/linux/lxstat.c
@@ -1,4 +1,4 @@
-/* lxstat using old-style Unix lstat system call.
+/* lxstat using old-style Unix stat system call.
    Copyright (C) 1991-2020 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -16,45 +16,47 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-/* Ho hum, if xstat == xstat64 we must get rid of the prototype or gcc
-   will complain since they don't strictly match.  */
-#define __lxstat64 __lxstat64_disable
-
-#include <errno.h>
-#include <stddef.h>
 #include <sys/stat.h>
+#include <fcntl.h>
 #include <kernel_stat.h>
-
 #include <sysdep.h>
-#include <sys/syscall.h>
 
-#include <xstatconv.h>
+#if !XSTAT_IS_XSTAT64
+# include <xstatconv.h>
+# include <xstatover.h>
 
 /* Get information about the file NAME in BUF.  */
 int
 __lxstat (int vers, const char *name, struct stat *buf)
 {
-  if (vers == _STAT_VER_KERNEL)
-    return INLINE_SYSCALL (lstat, 2, name, buf);
-
-#if STAT_IS_KERNEL_STAT
-  return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
-#else
-  struct kernel_stat kbuf;
-  int result;
-
-  result = INLINE_SYSCALL (lstat, 2, name, &kbuf);
-  if (result == 0)
-    result = __xstat_conv (vers, &kbuf, buf);
-
-  return result;
+  switch (vers)
+    {
+    case _STAT_VER_KERNEL:
+      {
+# if STAT_IS_KERNEL_STAT
+	/* New kABIs which uses generic pre 64-bit time Linux ABI,
+	   e.g. csky, nios2  */
+	int r = INLINE_SYSCALL_CALL (fstatat64, AT_FDCWD, name, buf,
+				     AT_SYMLINK_NOFOLLOW);
+	return r ?: stat_overflow (buf);
+# else
+	/* Old kABIs with old non-LFS support, e.g. arm, i386, hppa, m68k,
+	   microblaze, s390, sh, powerpc, and sparc.  */
+	return INLINE_SYSCALL_CALL (lstat, name, buf);
+# endif
+      }
+
+    default:
+      {
+# if STAT_IS_KERNEL_STAT
+	return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+# else
+	struct stat64 buf64;
+	int r = INTERNAL_SYSCALL_CALL (lstat64, name, &buf64);
+	return r ?: __xstat32_conv (vers, &buf64, buf);
 #endif
+      }
+    }
 }
-
 hidden_def (__lxstat)
-weak_alias (__lxstat, _lxstat);
-#if XSTAT_IS_XSTAT64
-#undef __lxstat64
-strong_alias (__lxstat, __lxstat64);
-hidden_ver (__lxstat, __lxstat64)
-#endif
+#endif /* XSTAT_IS_XSTAT64  */
diff --git a/sysdeps/unix/sysv/linux/lxstat64.c b/sysdeps/unix/sysv/linux/lxstat64.c
index 0ea8399d68..375013e9b1 100644
--- a/sysdeps/unix/sysv/linux/lxstat64.c
+++ b/sysdeps/unix/sysv/linux/lxstat64.c
@@ -1,5 +1,5 @@
 /* lxstat64 using Linux lstat64 system call.
-   Copyright (C) 1997-2020 Free Software Foundation, Inc.
+   Copyright (C) 1991-2020 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
@@ -16,23 +16,65 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <stddef.h>
+#define __lxstat __redirect___lxstat
 #include <sys/stat.h>
+#undef __lxstat
+#include <fcntl.h>
 #include <kernel_stat.h>
-
 #include <sysdep.h>
-#include <sys/syscall.h>
+#include <xstatconv.h>
+#include <statx_cp.h>
 
 /* Get information about the file NAME in BUF.  */
+
 int
 ___lxstat64 (int vers, const char *name, struct stat64 *buf)
 {
-  int result;
-  result = INLINE_SYSCALL (lstat64, 2, name, buf);
-  return result;
+#if XSTAT_IS_XSTAT64
+# if defined __NR_lstat
+  /* Old 64-bit kABI, e.g. ia64, powerpc64*, s390x, sparc64, x86_64.  */
+  if (vers == _STAT_VER_KERNEL || vers == _STAT_VER_LINUX)
+    return INLINE_SYSCALL_CALL (lstat, name, buf);
+# elif defined __NR_newfstatat
+  /* New kABIs which uses generic 64-bit Linux ABI, e.g. aarch64, riscv64.  */
+  if (vers == _STAT_VER_KERNEL)
+    return INLINE_SYSCALL_CALL (newfstatat, AT_FDCWD, name, buf,
+				AT_SYMLINK_NOFOLLOW);
+# else
+  /* New 32-bit kABIs with only 64-bit time_t support, e.g. arc, riscv32.  */
+  if (vers == _STAT_VER_KERNEL)
+    {
+      struct statx tmp;
+      int r = INLINE_SYSCALL_CALL (statx, AT_FDCWD, name,
+				   AT_NO_AUTOMOUNT | AT_SYMLINK_NOFOLLOW,
+				   STATX_BASIC_STATS, &tmp);
+      if (r == 0)
+	__cp_stat64_statx (buf, &tmp);
+      return r;
+     }
+# endif
+#else
+# if STAT_IS_KERNEL_STAT
+  /* New kABIs which uses generic pre 64-bit time Linux ABI,
+     e.g. csky, nios2  */
+  if (vers == _STAT_VER_KERNEL)
+    return INLINE_SYSCALL_CALL (fstatat64, AT_FDCWD, name, buf,
+				AT_SYMLINK_NOFOLLOW);
+# else
+  /* Old kABIs with old non-LFS support, e.g. arm, i386, hppa, m68k,
+     microblaze, s390, sh, mips32, powerpc32, and sparc32.  */
+  return INLINE_SYSCALL_CALL (lstat64, name, buf);
+# endif /* STAT_IS_KERNEL_STAT  */
+#endif /* XSTAT_IS_XSTAT64  */
+
+  return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
 }
 
+#if XSTAT_IS_XSTAT64
+weak_alias (___lxstat64, __lxstat);
+weak_alias (___lxstat64, __GI___lxstat);
+#endif
+
 #include <shlib-compat.h>
 
 #if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2)
diff --git a/sysdeps/unix/sysv/linux/m68k/lxstat.c b/sysdeps/unix/sysv/linux/m68k/lxstat.c
deleted file mode 100644
index 0efa0aea49..0000000000
--- a/sysdeps/unix/sysv/linux/m68k/lxstat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/lxstat.c>
diff --git a/sysdeps/unix/sysv/linux/microblaze/lxstat.c b/sysdeps/unix/sysv/linux/microblaze/lxstat.c
deleted file mode 100644
index 0efa0aea49..0000000000
--- a/sysdeps/unix/sysv/linux/microblaze/lxstat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/lxstat.c>
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/lxstat.c b/sysdeps/unix/sysv/linux/mips/lxstat.c
similarity index 60%
rename from sysdeps/unix/sysv/linux/wordsize-64/lxstat.c
rename to sysdeps/unix/sysv/linux/mips/lxstat.c
index 156fbe7c64..eb07549adf 100644
--- a/sysdeps/unix/sysv/linux/wordsize-64/lxstat.c
+++ b/sysdeps/unix/sysv/linux/mips/lxstat.c
@@ -1,4 +1,4 @@
-/* lxstat using old-style Unix lstat system call.
+/* lxstat using old-style Unix stat system call.
    Copyright (C) 1991-2020 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -16,30 +16,27 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-/* Ho hum, since xstat == xstat64 we must get rid of the prototype or gcc
-   will complain since they don't strictly match.  */
-#define __lxstat64 __lxstat64_disable
-
-#include <errno.h>
-#include <stddef.h>
 #include <sys/stat.h>
-
+#include <fcntl.h>
+#include <kernel_stat.h>
 #include <sysdep.h>
-#include <sys/syscall.h>
+#include <xstatconv.h>
 
-/* Get information about the file FD in BUF.  */
+/* Get information about the file NAME in BUF.  */
 int
 __lxstat (int vers, const char *name, struct stat *buf)
 {
-  if (vers == _STAT_VER_KERNEL || vers == _STAT_VER_LINUX)
-    return INLINE_SYSCALL (lstat, 2, name, buf);
-
-  __set_errno (EINVAL);
-  return -1;
+  switch (vers)
+    {
+    case _STAT_VER_KERNEL:
+      return INLINE_SYSCALL_CALL (lstat, name, buf);
+
+    default:
+      {
+	struct kernel_stat kbuf;
+	int r = INTERNAL_SYSCALL_CALL (lstat, name, &kbuf);
+	return r ?: __xstat_conv (vers, &kbuf, buf);
+      }
+    }
 }
-
 hidden_def (__lxstat)
-weak_alias (__lxstat, _lxstat);
-#undef __lxstat64
-strong_alias (__lxstat, __lxstat64);
-hidden_ver (__lxstat, __lxstat64)
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/lxstat64.c b/sysdeps/unix/sysv/linux/mips/mips64/lxstat64.c
index 62d4fe70eb..28bac57e58 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/lxstat64.c
+++ b/sysdeps/unix/sysv/linux/mips/mips64/lxstat64.c
@@ -16,28 +16,18 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <stddef.h>
 #include <sys/stat.h>
 #include <kernel_stat.h>
-
 #include <sysdep.h>
-#include <sys/syscall.h>
-
 #include <xstatconv.h>
 
 /* Get information about the file NAME in BUF.  */
 int
 __lxstat64 (int vers, const char *name, struct stat64 *buf)
 {
-  int result;
   struct kernel_stat kbuf;
-
-  result = INLINE_SYSCALL (lstat, 2, name, &kbuf);
-  if (result == 0)
-    result = __xstat64_conv (vers, &kbuf, buf);
-
-  return result;
+  int r = INLINE_SYSCALL_CALL (lstat, name, &kbuf);
+  return r ?: __xstat64_conv (vers, &kbuf, buf);
 }
 
 hidden_def (__lxstat64)
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/lxstat.c b/sysdeps/unix/sysv/linux/powerpc/powerpc32/lxstat.c
deleted file mode 100644
index 2371cd9719..0000000000
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/lxstat.c
+++ /dev/null
@@ -1,2 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/lxstat.c>
-
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/lxstat.c b/sysdeps/unix/sysv/linux/s390/s390-32/lxstat.c
deleted file mode 100644
index 0efa0aea49..0000000000
--- a/sysdeps/unix/sysv/linux/s390/s390-32/lxstat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/lxstat.c>
diff --git a/sysdeps/unix/sysv/linux/sh/lxstat.c b/sysdeps/unix/sysv/linux/sh/lxstat.c
deleted file mode 100644
index 2371cd9719..0000000000
--- a/sysdeps/unix/sysv/linux/sh/lxstat.c
+++ /dev/null
@@ -1,2 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/lxstat.c>
-
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/lxstat.c b/sysdeps/unix/sysv/linux/sparc/sparc32/lxstat.c
deleted file mode 100644
index 2371cd9719..0000000000
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/lxstat.c
+++ /dev/null
@@ -1,2 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/lxstat.c>
-
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/lxstat.c b/sysdeps/unix/sysv/linux/sparc/sparc64/lxstat.c
deleted file mode 100644
index 7f1e98e433..0000000000
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/lxstat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../i386/lxstat.c"
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/lxstat64.c b/sysdeps/unix/sysv/linux/wordsize-64/lxstat64.c
deleted file mode 100644
index bb5dbd0fff..0000000000
--- a/sysdeps/unix/sysv/linux/wordsize-64/lxstat64.c
+++ /dev/null
@@ -1 +0,0 @@
-/* lxstat64 is in lxstat.c */
-- 
2.25.1


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

* [PATCH 05/16] linux: Consolidate fxstat{64}
  2020-07-23 19:46 [PATCH 00/16] Add y2038 support for stat functions Adhemerval Zanella via Libc-alpha
                   ` (3 preceding siblings ...)
  2020-07-23 19:46 ` [PATCH 04/16] linux: Consolidate lxstat{64} Adhemerval Zanella via Libc-alpha
@ 2020-07-23 19:46 ` Adhemerval Zanella via Libc-alpha
  2020-07-24  9:04   ` Lukasz Majewski
  2020-07-23 19:46 ` [PATCH 06/16] linux: Consolidate fxstatat{64} Adhemerval Zanella via Libc-alpha
                   ` (10 subsequent siblings)
  15 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-07-23 19:46 UTC (permalink / raw)
  To: libc-alpha; +Cc: Alistair Francis

The LFS support is implemented on fxstat64.c, instead of fxstat.c for
64-bit architectures.  The fxstat.c implements the non-LFS and it is
a no-op for !XSTAT_IS_XSTAT64.

The generic non-LFS implementation handles two cases:

  1. New kABIs which uses generic pre 64-bit time Linux ABI (csky and
     nios): it issuess __NR_fstat64 plus handle the overflow on st_ino,
     st_size, or st_blocks.  It only handles _STAT_VER_KERNEL.

  2. Old KABIs with old non-LFS support (arm, i386, hppa, m68k,
     microblaze, s390, sh, powerpc, and sparc32).  For _STAT_VER_KERNEL
     it issues __NR_fstat, otherwise it calls __NR_fstat64 and convert
     to non-LFS stat struct and handle possible overflows on st_ino,
     st_size, or st_blocks.

Also non-LFS mips is an outlier and it has its own implementation since
_STAT_VER_LINUX requires a different conversion function (it uses the
kernel_stat as the sysissues argument since its exported ABI is
different than the kernel one for both non-LFS and LFS implementation).

The generic LFS implementation handles multiple cases:

  1. XSTAT_IS_XSTAT64 being 1:

    1.1. 64-bit kABI (aarch64, ia64, powerpc64*, s390x, sparc64,
	 riscv64, and x86_64): it issuess __NR_fstat for
	 _STAT_VER_KERNEL or _STAT_VER_LINUX.

    1.2. New 32-bit kABIs with only 64-bit time_t support (arc and
	 riscv32): it issuess __NR_statx and covert to struct stat64.

  2. Old ABIs with XSTAT_IS_XSTAT64 being 0 (arm, csky, i386, hppa,
     m68k, microblaze, mips32, nios2, sh, powerpc32, and sparc32): it
     issues __NR_fstat64.

Also, two special cases requires specific implementations:

  1. alpha: it requires to handle _STAT_VER_KERNEL64 to issues
     __NR_fstat64 and use the kernel_stat with __NR_fstat otherwise.

  2. mips64: as for non-LFS implementation its ABIs differ from
     glibc exported one, which requires an specific conversion
     function to handle the kernel_stat.

Checked with a build for all affected ABIs. I also checked on x86_64,
i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and s390x.
---
 .../sysv/linux/alpha/{fxstat.c => fxstat64.c} | 48 ++++++--------
 sysdeps/unix/sysv/linux/arm/fxstat.c          |  1 -
 sysdeps/unix/sysv/linux/fxstat.c              | 62 +++++++++----------
 sysdeps/unix/sysv/linux/fxstat64.c            | 43 ++++++++-----
 .../sysv/linux/generic/wordsize-32/fxstat.c   | 57 -----------------
 .../sysv/linux/generic/wordsize-32/fxstat64.c | 36 -----------
 sysdeps/unix/sysv/linux/hppa/fxstat.c         |  1 -
 sysdeps/unix/sysv/linux/i386/fxstat.c         | 59 ------------------
 sysdeps/unix/sysv/linux/m68k/fxstat.c         |  1 -
 sysdeps/unix/sysv/linux/microblaze/fxstat.c   |  1 -
 .../sysv/linux/{wordsize-64 => mips}/fxstat.c | 37 +++++------
 .../unix/sysv/linux/mips/mips64/fxstat64.c    | 13 +---
 .../sysv/linux/powerpc/powerpc32/fxstat.c     |  1 -
 sysdeps/unix/sysv/linux/s390/s390-32/fxstat.c |  1 -
 sysdeps/unix/sysv/linux/sh/fxstat.c           |  1 -
 .../unix/sysv/linux/sparc/sparc32/fxstat.c    |  1 -
 .../unix/sysv/linux/sparc/sparc64/fxstat.c    |  1 -
 .../unix/sysv/linux/wordsize-64/fxstat64.c    |  1 -
 18 files changed, 97 insertions(+), 268 deletions(-)
 rename sysdeps/unix/sysv/linux/alpha/{fxstat.c => fxstat64.c} (53%)
 delete mode 100644 sysdeps/unix/sysv/linux/arm/fxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat64.c
 delete mode 100644 sysdeps/unix/sysv/linux/hppa/fxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/i386/fxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/m68k/fxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/microblaze/fxstat.c
 rename sysdeps/unix/sysv/linux/{wordsize-64 => mips}/fxstat.c (60%)
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/fxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/fxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/sh/fxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/fxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/fxstat.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/fxstat64.c

diff --git a/sysdeps/unix/sysv/linux/alpha/fxstat.c b/sysdeps/unix/sysv/linux/alpha/fxstat64.c
similarity index 53%
rename from sysdeps/unix/sysv/linux/alpha/fxstat.c
rename to sysdeps/unix/sysv/linux/alpha/fxstat64.c
index 0978610bf0..286a2f0a6c 100644
--- a/sysdeps/unix/sysv/linux/alpha/fxstat.c
+++ b/sysdeps/unix/sysv/linux/alpha/fxstat64.c
@@ -1,4 +1,4 @@
-/* fxstat using old-style Unix stat system call.
+/* fxstat64 using old-style Unix stat system call.
    Copyright (C) 2004-2020 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -16,42 +16,32 @@
    License along with the GNU C Library.  If not, see
    <https://www.gnu.org/licenses/>.  */
 
-#define __fxstat64 __fxstat64_disable
-
-#include <errno.h>
-#include <stddef.h>
+#define __fxstat __redirect___fxstat64
 #include <sys/stat.h>
+#undef __fxstat
 #include <kernel_stat.h>
 #include <sysdep.h>
-#include <sys/syscall.h>
 #include <xstatconv.h>
 
-#undef __fxstat64
-
-
 /* Get information about the file NAME in BUF.  */
 int
-__fxstat (int vers, int fd, struct stat *buf)
+__fxstat64 (int vers, int fd, struct stat64 *buf)
 {
-  int result;
-  struct kernel_stat kbuf;
-
-  if (vers == _STAT_VER_KERNEL64)
+  switch (vers)
     {
-      result = INTERNAL_SYSCALL_CALL (fstat64, fd, buf);
-      if (__glibc_likely (!INTERNAL_SYSCALL_ERROR_P (result)))
-	return result;
-      __set_errno (INTERNAL_SYSCALL_ERRNO (result));
-      return -1;
+    case _STAT_VER_KERNEL64:
+      return INLINE_SYSCALL_CALL (fstat64, fd, buf);
+
+    default:
+      {
+        struct kernel_stat kbuf;
+	int r = INTERNAL_SYSCALL_CALL (fstat, fd, &kbuf);
+	if (r == 0)
+	  return __xstat_conv (vers, &kbuf, buf);
+	return INLINE_SYSCALL_ERROR_RETURN_VALUE (-r);
+      }
     }
-
-  result = INTERNAL_SYSCALL_CALL (fstat, fd, &kbuf);
-  if (__glibc_likely (!INTERNAL_SYSCALL_ERROR_P (result)))
-    return __xstat_conv (vers, &kbuf, buf);
-  __set_errno (INTERNAL_SYSCALL_ERRNO (result));
-  return -1;
 }
-hidden_def (__fxstat)
-weak_alias (__fxstat, _fxstat);
-strong_alias (__fxstat, __fxstat64);
-hidden_ver (__fxstat, __fxstat64)
+hidden_def (__fxstat64)
+strong_alias (__fxstat64, __fxstat);
+hidden_ver (__fxstat64, __fxstat)
diff --git a/sysdeps/unix/sysv/linux/arm/fxstat.c b/sysdeps/unix/sysv/linux/arm/fxstat.c
deleted file mode 100644
index 4f219f0b9d..0000000000
--- a/sysdeps/unix/sysv/linux/arm/fxstat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/fxstat.c>
diff --git a/sysdeps/unix/sysv/linux/fxstat.c b/sysdeps/unix/sysv/linux/fxstat.c
index a88404b5c3..b46e344d0e 100644
--- a/sysdeps/unix/sysv/linux/fxstat.c
+++ b/sysdeps/unix/sysv/linux/fxstat.c
@@ -16,46 +16,46 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-/* Ho hum, if xstat == xstat64 we must get rid of the prototype or gcc
-   will complain since they don't strictly match.  */
-#define __fxstat64 __fxstat64_disable
-
-#include <errno.h>
-#include <stddef.h>
-#include <sys/types.h>
 #include <sys/stat.h>
+#include <fcntl.h>
 #include <kernel_stat.h>
-
 #include <sysdep.h>
-#include <sys/syscall.h>
 
-#include <xstatconv.h>
+#if !XSTAT_IS_XSTAT64
+# include <xstatconv.h>
+# include <xstatover.h>
 
 /* Get information about the file FD in BUF.  */
 int
 __fxstat (int vers, int fd, struct stat *buf)
 {
-  if (vers == _STAT_VER_KERNEL)
-    return INLINE_SYSCALL (fstat, 2, fd, buf);
-
-#if STAT_IS_KERNEL_STAT
-  return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
-#else
-  struct kernel_stat kbuf;
-  int result;
-
-  result = INLINE_SYSCALL (fstat, 2, fd, &kbuf);
-  if (result == 0)
-    result = __xstat_conv (vers, &kbuf, buf);
-
-  return result;
+  switch (vers)
+    {
+    case _STAT_VER_KERNEL:
+      {
+# if STAT_IS_KERNEL_STAT
+	/* New kABIs which uses generic pre 64-bit time Linux ABI,
+	   e.g. csky, nios2  */
+	int r = INLINE_SYSCALL_CALL (fstat64, fd, buf);
+	return r ?: stat_overflow (buf);
+# else
+	/* Old kABIs with old non-LFS support, e.g. arm, i386, hppa, m68k,
+	   microblaze, s390, sh, powerpc, and sparc.  */
+	return INLINE_SYSCALL_CALL (fstat, fd, buf);
+# endif
+      }
+
+    default:
+      {
+# if STAT_IS_KERNEL_STAT
+	return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+# else
+	struct stat64 buf64;
+	int r = INLINE_SYSCALL_CALL (fstat64, fd, &buf64);
+	return r ?: __xstat32_conv (vers, &buf64, buf);
 #endif
+      }
+    }
 }
-
 hidden_def (__fxstat)
-weak_alias (__fxstat, _fxstat);
-#if XSTAT_IS_XSTAT64
-#undef __fxstat64
-strong_alias (__fxstat, __fxstat64);
-hidden_ver (__fxstat, __fxstat64)
-#endif
+#endif /* XSTAT_IS_XSTAT64  */
diff --git a/sysdeps/unix/sysv/linux/fxstat64.c b/sysdeps/unix/sysv/linux/fxstat64.c
index 9133a0a29b..d3834f1ce2 100644
--- a/sysdeps/unix/sysv/linux/fxstat64.c
+++ b/sysdeps/unix/sysv/linux/fxstat64.c
@@ -16,15 +16,13 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <stddef.h>
-#include <fcntl.h>
+#define __fxstat __redirect___fxstat
 #include <sys/stat.h>
+#undef __fxstat
+#include <fcntl.h>
 #include <kernel_stat.h>
-
 #include <sysdep.h>
-#include <sys/syscall.h>
-
+#include <xstatconv.h>
 #include <statx_cp.h>
 
 /* Get information about the file FD in BUF.  */
@@ -32,17 +30,27 @@
 int
 ___fxstat64 (int vers, int fd, struct stat64 *buf)
 {
-  int result;
-#ifdef __NR_fstat64
-  result = INLINE_SYSCALL (fstat64, 2, fd, buf);
-#else
+#if XSTAT_IS_XSTAT64
+# ifdef __NR_fstat
+  /* 64-bit kABI, e.g. aarch64, ia64, powerpc64*, s390x, sparc64, riscv64,
+     and x86_64.  */
+  if (vers == _STAT_VER_KERNEL || vers == _STAT_VER_LINUX)
+    return INLINE_SYSCALL_CALL (fstat, fd, buf);
+  return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+# else
+  /* New 32-bit kABIs with only 64-bit time_t support, e.g. arc, riscv32.  */
   struct statx tmp;
-  result = INLINE_SYSCALL (statx, 5, fd, "", AT_EMPTY_PATH, STATX_BASIC_STATS,
-                           &tmp);
-  if (result == 0)
+  int r = INLINE_SYSCALL_CALL (statx, fd, "", AT_EMPTY_PATH,
+			       STATX_BASIC_STATS, &tmp);
+  if (r == 0)
     __cp_stat64_statx (buf, &tmp);
-#endif
-  return result;
+  return r;
+# endif
+#else
+  /* All kABIs with non-LFS support, e.g. arm, csky, i386, hppa, m68k,
+     microblaze, mips32, nios2, sh, powerpc32, and sparc32.  */
+  return INLINE_SYSCALL_CALL (fstat64, fd, buf);
+#endif /* XSTAT_IS_XSTAT64  */
 }
 
 #include <shlib-compat.h>
@@ -56,3 +64,8 @@ hidden_ver (___fxstat64, __fxstat64)
 strong_alias (___fxstat64, __fxstat64)
 hidden_def (__fxstat64)
 #endif
+
+#if XSTAT_IS_XSTAT64
+strong_alias (__fxstat64, __fxstat);
+hidden_ver (__fxstat64, __fxstat)
+#endif
diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat.c b/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat.c
deleted file mode 100644
index 850450e1e8..0000000000
--- a/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Copyright (C) 2011-2020 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 <errno.h>
-#include <stddef.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <kernel_stat.h>
-
-#include <sysdep.h>
-#include <sys/syscall.h>
-
-#if !XSTAT_IS_XSTAT64
-#include "overflow.h"
-#include <statx_cp.h>
-
-/* Get information about the file FD in BUF.  */
-int
-__fxstat (int vers, int fd, struct stat *buf)
-{
-  if (vers == _STAT_VER_KERNEL)
-    {
-# ifdef __NR_fstat64
-      int rc = INLINE_SYSCALL (fstat64, 2, fd, buf);
-# else
-      struct statx tmp;
-      int rc = INLINE_SYSCALL (statx, 5, fd, "", AT_EMPTY_PATH,
-                               STATX_BASIC_STATS, &tmp);
-      if (rc == 0)
-        __cp_stat64_statx ((struct stat64 *)buf, &tmp);
-# endif
-      return rc ?: stat_overflow (buf);
-    }
-
-  errno = EINVAL;
-  return -1;
-}
-
-hidden_def (__fxstat)
-weak_alias (__fxstat, _fxstat);
-#endif
diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat64.c b/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat64.c
deleted file mode 100644
index b4a2a5b417..0000000000
--- a/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat64.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/* __fxstat64 () implementation.
-   Copyright (C) 2016-2020 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/>.  */
-
-/* Hide the prototypes for __fxstat and _fxstat so that GCC will not
-   complain about the different function signatures if they are aliased
-   to  __fxstat64.  If XSTAT_IS_XSTAT64 is set to non-zero then the stat and
-   stat64 structures have an identical layout but different type names.  */
-
-#define __fxstat __fxstat_disable
-#define _fxstat _fxstat_disable
-
-#include <sysdeps/unix/sysv/linux/fxstat64.c>
-
-#undef __fxstat
-#undef _fxstat
-#if XSTAT_IS_XSTAT64
-weak_alias (__fxstat64, __fxstat)
-weak_alias (__fxstat64, _fxstat)
-hidden_ver (__fxstat64, __fxstat)
-#endif
diff --git a/sysdeps/unix/sysv/linux/hppa/fxstat.c b/sysdeps/unix/sysv/linux/hppa/fxstat.c
deleted file mode 100644
index 4f219f0b9d..0000000000
--- a/sysdeps/unix/sysv/linux/hppa/fxstat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/fxstat.c>
diff --git a/sysdeps/unix/sysv/linux/i386/fxstat.c b/sysdeps/unix/sysv/linux/i386/fxstat.c
deleted file mode 100644
index db59baa71b..0000000000
--- a/sysdeps/unix/sysv/linux/i386/fxstat.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/* fxstat using old-style Unix fstat system call.
-   Copyright (C) 1991-2020 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/>.  */
-
-/* Ho hum, if xstat == xstat64 we must get rid of the prototype or gcc
-   will complain since they don't strictly match.  */
-#define __fxstat64 __fxstat64_disable
-
-#include <errno.h>
-#include <stddef.h>
-#include <sys/stat.h>
-#include <kernel_stat.h>
-
-#include <sysdep.h>
-#include <sys/syscall.h>
-
-#include <xstatconv.h>
-
-/* Get information about the file FD in BUF.  */
-int
-__fxstat (int vers, int fd, struct stat *buf)
-{
-  int result;
-
-  if (vers == _STAT_VER_KERNEL)
-    return INLINE_SYSCALL (fstat, 2, fd, buf);
-
-  {
-    struct stat64 buf64;
-
-    result = INTERNAL_SYSCALL_CALL (fstat64, fd, &buf64);
-    if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result)))
-      return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (result));
-    else
-      return __xstat32_conv (vers, &buf64, buf);
-  }
-}
-
-hidden_def (__fxstat)
-weak_alias (__fxstat, _fxstat);
-#if XSTAT_IS_XSTAT64
-#undef __fxstat64
-strong_alias (__fxstat, __fxstat64);
-hidden_ver (__fxstat, __fxstat64)
-#endif
diff --git a/sysdeps/unix/sysv/linux/m68k/fxstat.c b/sysdeps/unix/sysv/linux/m68k/fxstat.c
deleted file mode 100644
index 4f219f0b9d..0000000000
--- a/sysdeps/unix/sysv/linux/m68k/fxstat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/fxstat.c>
diff --git a/sysdeps/unix/sysv/linux/microblaze/fxstat.c b/sysdeps/unix/sysv/linux/microblaze/fxstat.c
deleted file mode 100644
index 4f219f0b9d..0000000000
--- a/sysdeps/unix/sysv/linux/microblaze/fxstat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/fxstat.c>
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/fxstat.c b/sysdeps/unix/sysv/linux/mips/fxstat.c
similarity index 60%
rename from sysdeps/unix/sysv/linux/wordsize-64/fxstat.c
rename to sysdeps/unix/sysv/linux/mips/fxstat.c
index 24bfe847d7..16c3cefee2 100644
--- a/sysdeps/unix/sysv/linux/wordsize-64/fxstat.c
+++ b/sysdeps/unix/sysv/linux/mips/fxstat.c
@@ -1,4 +1,4 @@
-/* fxstat using old-style Unix fstat system call.
+/* fxstat using old-style Unix stat system call.
    Copyright (C) 1991-2020 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -16,30 +16,27 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-/* Ho hum, since xstat == xstat64 we must get rid of the prototype or gcc
-   will complain since they don't strictly match.  */
-#define __fxstat64 __fxstat64_disable
-
-#include <errno.h>
-#include <stddef.h>
 #include <sys/stat.h>
-
+#include <fcntl.h>
+#include <kernel_stat.h>
 #include <sysdep.h>
-#include <sys/syscall.h>
+#include <xstatconv.h>
 
-/* Get information about the file FD in BUF.  */
+/* Get information about the file NAME in BUF.  */
 int
 __fxstat (int vers, int fd, struct stat *buf)
 {
-  if (vers == _STAT_VER_KERNEL || vers == _STAT_VER_LINUX)
-    return INLINE_SYSCALL (fstat, 2, fd, buf);
-
-  __set_errno (EINVAL);
-  return -1;
+  switch (vers)
+    {
+    case _STAT_VER_KERNEL:
+      return INLINE_SYSCALL_CALL (fstat, fd, buf);
+
+    default:
+      {
+	struct kernel_stat kbuf;
+	int r = INTERNAL_SYSCALL_CALL (fstat, fd, &kbuf);
+	return r ?: __xstat_conv (vers, &kbuf, buf);
+      }
+    }
 }
-
 hidden_def (__fxstat)
-weak_alias (__fxstat, _fxstat);
-#undef __fxstat64
-strong_alias (__fxstat, __fxstat64);
-hidden_ver (__fxstat, __fxstat64)
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/fxstat64.c b/sysdeps/unix/sysv/linux/mips/mips64/fxstat64.c
index 8dd3d92eb1..3fcdd9f1ee 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/fxstat64.c
+++ b/sysdeps/unix/sysv/linux/mips/mips64/fxstat64.c
@@ -16,14 +16,9 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <stddef.h>
 #include <sys/stat.h>
 #include <kernel_stat.h>
-
 #include <sysdep.h>
-#include <sys/syscall.h>
-
 #include <xstatconv.h>
 
 /* Get information about the file FD in BUF.  */
@@ -31,14 +26,10 @@
 int
 __fxstat64 (int vers, int fd, struct stat64 *buf)
 {
-  int result;
   struct kernel_stat kbuf;
+  int r = INLINE_SYSCALL_CALL (fstat, fd, &kbuf);
+  return r ?: __xstat64_conv (vers, &kbuf, buf);
 
-  result = INLINE_SYSCALL (fstat, 2, fd, &kbuf);
-  if (result == 0)
-    result = __xstat64_conv (vers, &kbuf, buf);
-
-  return result;
 }
 
 hidden_def (__fxstat64)
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fxstat.c b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fxstat.c
deleted file mode 100644
index 4f219f0b9d..0000000000
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fxstat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/fxstat.c>
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/fxstat.c b/sysdeps/unix/sysv/linux/s390/s390-32/fxstat.c
deleted file mode 100644
index 4f219f0b9d..0000000000
--- a/sysdeps/unix/sysv/linux/s390/s390-32/fxstat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/fxstat.c>
diff --git a/sysdeps/unix/sysv/linux/sh/fxstat.c b/sysdeps/unix/sysv/linux/sh/fxstat.c
deleted file mode 100644
index 4f219f0b9d..0000000000
--- a/sysdeps/unix/sysv/linux/sh/fxstat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/fxstat.c>
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/fxstat.c b/sysdeps/unix/sysv/linux/sparc/sparc32/fxstat.c
deleted file mode 100644
index 4f219f0b9d..0000000000
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/fxstat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/fxstat.c>
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/fxstat.c b/sysdeps/unix/sysv/linux/sparc/sparc64/fxstat.c
deleted file mode 100644
index e328ccbab0..0000000000
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/fxstat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../i386/fxstat.c"
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/fxstat64.c b/sysdeps/unix/sysv/linux/wordsize-64/fxstat64.c
deleted file mode 100644
index 9eff9ebeb7..0000000000
--- a/sysdeps/unix/sysv/linux/wordsize-64/fxstat64.c
+++ /dev/null
@@ -1 +0,0 @@
-/* fxstat64 is in fxstat.c */
-- 
2.25.1


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

* [PATCH 06/16] linux: Consolidate fxstatat{64}
  2020-07-23 19:46 [PATCH 00/16] Add y2038 support for stat functions Adhemerval Zanella via Libc-alpha
                   ` (4 preceding siblings ...)
  2020-07-23 19:46 ` [PATCH 05/16] linux: Consolidate fxstat{64} Adhemerval Zanella via Libc-alpha
@ 2020-07-23 19:46 ` Adhemerval Zanella via Libc-alpha
  2020-07-24  9:14   ` Lukasz Majewski
  2020-07-23 19:46 ` [PATCH 07/16] Linux: Consolidate xmknod Adhemerval Zanella via Libc-alpha
                   ` (9 subsequent siblings)
  15 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-07-23 19:46 UTC (permalink / raw)
  To: libc-alpha; +Cc: Alistair Francis

The LFS support is implemented on fxstat64.c, instead of fxstat.c for
64-bit architectures.  The fxstatat.c implements the non-LFS and it is
a no-op for !XSTAT_IS_XSTAT64.

The generic non-LFS implementation handles two cases:

  1. New kABIs which uses generic pre 64-bit time Linux ABI (csky and
     nios): it issues __NR_fstatat64 plus handle the overflow on st_ino,
     st_size, or st_blocks.  It only handles _STAT_VER_KERNEL.

  2. Old kABIs with old non-LFS support (arm, i386, hppa, m68k, mips32,
     microblaze, s390, sh, powerpc, and sparc32).  it issues
     __NR_fstatat64 and convert to non-LFS stat struct based on the
     version.

Also non-LFS mips64 is an outlier and it has its own implementation
since _STAT_VER_LINUX requires a different conversion function (it
uses the kernel_stat as the sysissues argument since its exported ABI
is different than the kernel one for both non-LFS and LFS
implementation).

The generic LFS implementation handles multiple cases:

  1. XSTAT_IS_XSTAT64 being 1:

    1.1. 64-bit kABI (aarch64, ia64, powerpc64*, s390x, riscv64, and
         x86_64): it issues __NR_newfstatat for _STAT_VER_KERNEL or
         _STAT_VER_LINUX.

    1.2. 64-bit kABI outlier (sparc64): it issuess fstatat64 with a
         temporary stat64 and convert to output stat64 based on the
         input version (and using a sparc64 specific __xstat32_conv).

    1.3. New 32-bit kABIs with only 64-bit time_t support (arc and
	 riscv32): it issues __NR_statx and covert to struct stat64.

  2. Old ABIs with XSTAT_IS_XSTAT64 being 0 (arm, csky, i386, hppa, m68k,
     microblaze, mips32, nios2, sh, powerpc32, and sparc32): it issues
     __NR_fstat64.

Also, two special cases requires specific implementations:

  1. alpha: it uses the __NR_fstatat64 syscall instead.

  2. mips64: as for non-LFS implementation its ABIs differ from
     glibc exported one, which requires an specific conversion
     function to handle the kernel_stat.

Checked with a build for all affected ABIs. I also checked on x86_64,
i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and s390x.
---
 sysdeps/unix/sysv/linux/Makefile              |  3 +-
 sysdeps/unix/sysv/linux/alpha/dl-fxstatat64.c |  1 -
 sysdeps/unix/sysv/linux/alpha/fxstatat.c      | 52 ---------------
 .../wordsize-32 => alpha}/fxstatat64.c        | 35 +++++-----
 sysdeps/unix/sysv/linux/arm/fxstatat.c        |  1 -
 sysdeps/unix/sysv/linux/fxstatat.c            | 53 ++++++---------
 sysdeps/unix/sysv/linux/fxstatat64.c          | 65 +++++++++++--------
 .../sysv/linux/generic/wordsize-32/fxstatat.c | 56 ----------------
 sysdeps/unix/sysv/linux/hppa/fxstatat.c       |  1 -
 sysdeps/unix/sysv/linux/i386/fxstatat.c       | 54 ---------------
 sysdeps/unix/sysv/linux/m68k/fxstatat.c       |  1 -
 sysdeps/unix/sysv/linux/microblaze/fxstatat.c |  1 -
 .../unix/sysv/linux/mips/mips32/fxstatat.c    |  1 -
 .../{wordsize-64 => mips/mips64}/fxstatat.c   | 33 +++-------
 .../unix/sysv/linux/mips/mips64/fxstatat64.c  | 28 ++------
 .../sysv/linux/powerpc/powerpc32/fxstatat.c   |  1 -
 .../unix/sysv/linux/s390/s390-32/fxstatat.c   |  1 -
 sysdeps/unix/sysv/linux/sh/fxstatat.c         |  1 -
 .../unix/sysv/linux/sparc/sparc32/fxstatat.c  |  1 -
 .../sysv/linux/sparc/sparc64/dl-fxstatat64.c  |  1 -
 .../unix/sysv/linux/sparc/sparc64/fxstatat.c  |  1 -
 .../sysv/linux/wordsize-64/dl-fxstatat64.c    |  1 -
 .../unix/sysv/linux/wordsize-64/fxstatat64.c  |  1 -
 23 files changed, 92 insertions(+), 301 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/alpha/dl-fxstatat64.c
 delete mode 100644 sysdeps/unix/sysv/linux/alpha/fxstatat.c
 rename sysdeps/unix/sysv/linux/{generic/wordsize-32 => alpha}/fxstatat64.c (53%)
 delete mode 100644 sysdeps/unix/sysv/linux/arm/fxstatat.c
 delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat.c
 delete mode 100644 sysdeps/unix/sysv/linux/hppa/fxstatat.c
 delete mode 100644 sysdeps/unix/sysv/linux/i386/fxstatat.c
 delete mode 100644 sysdeps/unix/sysv/linux/m68k/fxstatat.c
 delete mode 100644 sysdeps/unix/sysv/linux/microblaze/fxstatat.c
 delete mode 100644 sysdeps/unix/sysv/linux/mips/mips32/fxstatat.c
 rename sysdeps/unix/sysv/linux/{wordsize-64 => mips/mips64}/fxstatat.c (56%)
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/fxstatat.c
 delete mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/fxstatat.c
 delete mode 100644 sysdeps/unix/sysv/linux/sh/fxstatat.c
 delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/fxstatat.c
 delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/dl-fxstatat64.c
 delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/fxstatat.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/dl-fxstatat64.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/fxstatat64.c

diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 9b2a253032..3c28adae0d 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -280,8 +280,7 @@ tests += tst-fallocate tst-fallocate64 tst-o_path-locks
 endif
 
 ifeq ($(subdir),elf)
-sysdep-rtld-routines += dl-brk dl-sbrk dl-getcwd dl-openat64 dl-opendir \
-			dl-fxstatat64
+sysdep-rtld-routines += dl-brk dl-sbrk dl-getcwd dl-openat64 dl-opendir
 
 libof-lddlibc4 = lddlibc4
 
diff --git a/sysdeps/unix/sysv/linux/alpha/dl-fxstatat64.c b/sysdeps/unix/sysv/linux/alpha/dl-fxstatat64.c
deleted file mode 100644
index 330b33f7c7..0000000000
--- a/sysdeps/unix/sysv/linux/alpha/dl-fxstatat64.c
+++ /dev/null
@@ -1 +0,0 @@
-#include "fxstatat.c"
diff --git a/sysdeps/unix/sysv/linux/alpha/fxstatat.c b/sysdeps/unix/sysv/linux/alpha/fxstatat.c
deleted file mode 100644
index c5953d250a..0000000000
--- a/sysdeps/unix/sysv/linux/alpha/fxstatat.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/* Copyright (C) 2005-2020 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 __fxstatat64 __fxstatat64_disable
-
-#include <errno.h>
-#include <fcntl.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <sys/stat.h>
-#include <kernel_stat.h>
-#include <sysdep.h>
-#include <sys/syscall.h>
-#include <xstatconv.h>
-
-#undef __fxstatat64
-
-/* Get information about the file NAME in BUF.  */
-int
-__fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
-{
-  int result, errno_out;
-
-  /* ??? The __fxstatat entry point is new enough that it must be using
-     vers == _STAT_VER_KERNEL64.  For the benefit of dl-fxstatat64.c, we
-     cannot actually check this, lest the compiler not optimize the rest
-     of the function away.  */
-
-  result = INTERNAL_SYSCALL_CALL (fstatat64, fd, file, st, flag);
-  if (__glibc_likely (!INTERNAL_SYSCALL_ERROR_P (result)))
-    return result;
-  errno_out = INTERNAL_SYSCALL_ERRNO (result);
-  __set_errno (errno_out);
-  return -1;
-}
-libc_hidden_def (__fxstatat)
-strong_alias (__fxstatat, __fxstatat64);
-libc_hidden_ver(__fxstatat, __fxstatat64);
diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat64.c b/sysdeps/unix/sysv/linux/alpha/fxstatat64.c
similarity index 53%
rename from sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat64.c
rename to sysdeps/unix/sysv/linux/alpha/fxstatat64.c
index 894f6dd396..f10c1d31e8 100644
--- a/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat64.c
+++ b/sysdeps/unix/sysv/linux/alpha/fxstatat64.c
@@ -1,7 +1,6 @@
-/* __fxstatat64 () implementation.
-   Copyright (C) 2016-2020 Free Software Foundation, Inc.
+/* fxstat using old-style Unix stat system call.
+   Copyright (C) 2004-2020 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
@@ -17,21 +16,21 @@
    License along with the GNU C Library.  If not, see
    <https://www.gnu.org/licenses/>.  */
 
-/* Hide the prototype for __fxstatat so that GCC will not complain about
-   the different function signature if it is aliased to  __fxstatat64.
-   If XSTAT_IS_XSTAT64 is set to non-zero then the stat and stat64 structures
-   have an identical layout but different type names.  */
-
-#define __fxstatat __fxstatat_disable
-
+#define __fxstatat __redirect___fxstatat64
 #include <sys/stat.h>
-#undef _STAT_VER_LINUX
-#define _STAT_VER_LINUX _STAT_VER_KERNEL
-
-#include <sysdeps/unix/sysv/linux/fxstatat64.c>
-
 #undef __fxstatat
-#if XSTAT_IS_XSTAT64
-weak_alias (__fxstatat64, __fxstatat)
-libc_hidden_ver (__fxstatat64, __fxstatat)
+#include <kernel_stat.h>
+#include <sysdep.h>
+#include <xstatconv.h>
+
+/* Get information about the file NAME in BUF.  */
+int
+__fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag)
+{
+  return INLINE_SYSCALL_CALL (fstatat64, fd, file, st, flag);
+}
+libc_hidden_def (__fxstatat64)
+#if IS_IN(libc)
+strong_alias (__fxstatat64, __fxstatat);
+hidden_ver (__fxstatat64, __fxstatat)
 #endif
diff --git a/sysdeps/unix/sysv/linux/arm/fxstatat.c b/sysdeps/unix/sysv/linux/arm/fxstatat.c
deleted file mode 100644
index 0f8b3135d8..0000000000
--- a/sysdeps/unix/sysv/linux/arm/fxstatat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/fxstatat.c>
diff --git a/sysdeps/unix/sysv/linux/fxstatat.c b/sysdeps/unix/sysv/linux/fxstatat.c
index 937fec45c2..0291a2c598 100644
--- a/sysdeps/unix/sysv/linux/fxstatat.c
+++ b/sysdeps/unix/sysv/linux/fxstatat.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2005-2020 Free Software Foundation, Inc.
+/* fxstatat used on fstatat, Linux implementation.
+   Copyright (C) 2005-2020 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,48 +16,36 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-/* Ho hum, if fxstatat == fxstatat64 we must get rid of the prototype or gcc
-   will complain since they don't strictly match.  */
-#define __fxstatat64 __fxstatat64_disable
-
-#include <errno.h>
-#include <fcntl.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <string.h>
 #include <sys/stat.h>
+#include <fcntl.h>
 #include <kernel_stat.h>
-
 #include <sysdep.h>
-#include <sys/syscall.h>
 
-#include <xstatconv.h>
+#if !XSTAT_IS_XSTAT64
+# include <xstatconv.h>
+# include <xstatover.h>
 
-/* Get information about the file NAME in BUF.  */
+/* Get information about the file FD in BUF.  */
 int
 __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
 {
-  int result;
 #if STAT_IS_KERNEL_STAT
-# define kst (*st)
-#else
-  struct kernel_stat kst;
-#endif
-
-  result = INTERNAL_SYSCALL_CALL (newfstatat, fd, file, &kst, flag);
-  if (!__glibc_likely (INTERNAL_SYSCALL_ERROR_P (result)))
+  /* New kABIs which uses generic pre 64-bit time Linux ABI, e.g.
+     csky, nios2  */
+  if (vers == _STAT_VER_KERNEL)
     {
-#if STAT_IS_KERNEL_STAT
-      return 0;
+      int r = INLINE_SYSCALL_CALL (fstatat64, fd, file, st, flag);
+      return r ?: stat_overflow (st);
+    }
+  return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
 #else
-      return __xstat_conv (vers, &kst, st);
+  /* Old kABIs with old non-LFS support, e.g. arm, i386, hppa, m68k, mips32,
+     microblaze, s390, sh, powerpc32, and sparc32.  */
+  struct stat64 st64;
+  int r = INLINE_SYSCALL_CALL (fstatat64, fd, file, &st64, flag);
+  return r ?: __xstat32_conv (vers, &st64, st);
 #endif
-    }
-  return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (result));
 }
 libc_hidden_def (__fxstatat)
-#if XSTAT_IS_XSTAT64
-# undef __fxstatat64
-strong_alias (__fxstatat, __fxstatat64);
-libc_hidden_def (__fxstatat64)
-#endif
+
+#endif /* XSTAT_IS_XSTAT64  */
diff --git a/sysdeps/unix/sysv/linux/fxstatat64.c b/sysdeps/unix/sysv/linux/fxstatat64.c
index e24b456604..ac33ab4fc9 100644
--- a/sysdeps/unix/sysv/linux/fxstatat64.c
+++ b/sysdeps/unix/sysv/linux/fxstatat64.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2005-2020 Free Software Foundation, Inc.
+/* fxstatat64 used on fstatat64, Linux implementation.
+   Copyright (C) 2005-2020 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,41 +16,53 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <fcntl.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <string.h>
+#define __fxstatat __redirect___fxstatat
 #include <sys/stat.h>
+#undef __fxstatat
+#include <fcntl.h>
 #include <kernel_stat.h>
-
 #include <sysdep.h>
-#include <sys/syscall.h>
-
+#include <xstatconv.h>
 #include <statx_cp.h>
 
-/* Get information about the file NAME in BUF.  */
+/* Get information about the file FD in BUF.  */
 
 int
 __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag)
 {
-  if (__glibc_unlikely (vers != _STAT_VER_LINUX))
-    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
-
-  int result;
-
-#ifdef __NR_fstatat64
-  result = INTERNAL_SYSCALL_CALL (fstatat64, fd, file, st, flag);
+#if XSTAT_IS_XSTAT64
+# ifdef __NR_newfstatat
+  /* 64-bit kABI, e.g. aarch64, ia64, powerpc64*, s390x, riscv64, and
+     x86_64.  */
+  if (vers == _STAT_VER_KERNEL || vers == _STAT_VER_LINUX)
+    return INLINE_SYSCALL_CALL (newfstatat, fd, file, st, flag);
+# elif defined __NR_fstatat64
+  /* 64-bit kABI outlier, e.g. sparc64.  */
+  struct stat64 st64;
+  int r = INLINE_SYSCALL_CALL (fstatat64, fd, file, &st64, flag);
+  return r ?: __xstat32_conv (vers, &st64, (struct stat *) st);
+# else
+  /* New 32-bit kABIs with only 64-bit time_t support, e.g. arc, riscv32.  */
+  if (vers == _STAT_VER_KERNEL)
+    {
+      struct statx tmp;
+      int r = INLINE_SYSCALL_CALL (statx, fd, file, AT_NO_AUTOMOUNT | flag,
+				   STATX_BASIC_STATS, &tmp);
+      if (r == 0)
+	__cp_stat64_statx (st, &tmp);
+      return r;
+    }
+# endif
 #else
-  struct statx tmp;
-
-  result = INTERNAL_SYSCALL_CALL (statx, fd, file, AT_NO_AUTOMOUNT | flag,
-				  STATX_BASIC_STATS, &tmp);
-  if (result == 0)
-    __cp_stat64_statx (st, &tmp);
+  /* All kABIs with non-LFS support, e.g. arm, csky, i386, hppa, m68k,
+     microblaze, mips32, nios2, sh, powerpc32, and sparc32.  */
+  if (vers == _STAT_VER_LINUX)
+    return INLINE_SYSCALL_CALL (fstatat64, fd, file, st, flag);
 #endif
-  if (!__glibc_likely (INTERNAL_SYSCALL_ERROR_P (result)))
-    return 0;
-  return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (result));
+  return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
 }
 libc_hidden_def (__fxstatat64)
+#if XSTAT_IS_XSTAT64 && IS_IN(libc)
+strong_alias (__fxstatat64, __fxstatat);
+hidden_ver (__fxstatat64, __fxstatat)
+#endif
diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat.c b/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat.c
deleted file mode 100644
index 8df65ebea0..0000000000
--- a/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Copyright (C) 2011-2020 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 <errno.h>
-#include <fcntl.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <sys/stat.h>
-#include <kernel_stat.h>
-
-#include <sysdep.h>
-#include <sys/syscall.h>
-
-#if !XSTAT_IS_XSTAT64
-#include "overflow.h"
-#include <statx_cp.h>
-
-/* Get information about the file NAME in BUF.  */
-int
-__fxstatat (int vers, int fd, const char *file, struct stat *buf, int flag)
-{
-  if (vers == _STAT_VER_KERNEL)
-    {
-# ifdef __NR_fstatat64
-      int rc = INLINE_SYSCALL (fstatat64, 4, fd, file, buf, flag);
-# else
-      struct statx tmp;
-      int rc = INLINE_SYSCALL (statx, 5, fd, file,
-                               AT_NO_AUTOMOUNT | flag,
-                               STATX_BASIC_STATS, &tmp);
-      if (rc == 0)
-        __cp_stat64_statx ((struct stat64 *)buf, &tmp);
-# endif
-      return rc ?: stat_overflow (buf);
-    }
-
-  errno = EINVAL;
-  return -1;
-}
-libc_hidden_def (__fxstatat)
-#endif
diff --git a/sysdeps/unix/sysv/linux/hppa/fxstatat.c b/sysdeps/unix/sysv/linux/hppa/fxstatat.c
deleted file mode 100644
index 0f8b3135d8..0000000000
--- a/sysdeps/unix/sysv/linux/hppa/fxstatat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/fxstatat.c>
diff --git a/sysdeps/unix/sysv/linux/i386/fxstatat.c b/sysdeps/unix/sysv/linux/i386/fxstatat.c
deleted file mode 100644
index f720f6e429..0000000000
--- a/sysdeps/unix/sysv/linux/i386/fxstatat.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Copyright (C) 2005-2020 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/>.  */
-
-/* Ho hum, if fxstatat == fxstatat64 we must get rid of the prototype or gcc
-   will complain since they don't strictly match.  */
-#define __fxstatat64 __fxstatat64_disable
-
-#include <errno.h>
-#include <fcntl.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <kernel_stat.h>
-
-#include <sysdep.h>
-#include <sys/syscall.h>
-
-#include <xstatconv.h>
-
-
-/* Get information about the file NAME relative to FD in ST.  */
-int
-__fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
-{
-  int result;
-  struct stat64 st64;
-
-  result = INTERNAL_SYSCALL_CALL (fstatat64, fd, file, &st64, flag);
-  if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result)))
-    return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (result));
-  else
-    return __xstat32_conv (vers, &st64, st);
-}
-libc_hidden_def (__fxstatat)
-#if XSTAT_IS_XSTAT64
-# undef __fxstatat64
-strong_alias (__fxstatat, __fxstatat64);
-libc_hidden_ver (__fxstatat, __fxstatat64)
-#endif
diff --git a/sysdeps/unix/sysv/linux/m68k/fxstatat.c b/sysdeps/unix/sysv/linux/m68k/fxstatat.c
deleted file mode 100644
index 0f8b3135d8..0000000000
--- a/sysdeps/unix/sysv/linux/m68k/fxstatat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/fxstatat.c>
diff --git a/sysdeps/unix/sysv/linux/microblaze/fxstatat.c b/sysdeps/unix/sysv/linux/microblaze/fxstatat.c
deleted file mode 100644
index 0f8b3135d8..0000000000
--- a/sysdeps/unix/sysv/linux/microblaze/fxstatat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/fxstatat.c>
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fxstatat.c b/sysdeps/unix/sysv/linux/mips/mips32/fxstatat.c
deleted file mode 100644
index 0f8b3135d8..0000000000
--- a/sysdeps/unix/sysv/linux/mips/mips32/fxstatat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/fxstatat.c>
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c b/sysdeps/unix/sysv/linux/mips/mips64/fxstatat.c
similarity index 56%
rename from sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c
rename to sysdeps/unix/sysv/linux/mips/mips64/fxstatat.c
index b8f5ab562e..58410a1441 100644
--- a/sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c
+++ b/sysdeps/unix/sysv/linux/mips/mips64/fxstatat.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2005-2020 Free Software Foundation, Inc.
+/* fxstat using old-style Unix fstat system call.
+   Copyright (C) 1991-2020 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,34 +16,18 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-/* Ho hum, since fxstatat == fxstatat64 we must get rid of the
-   prototype or gcc will complain since they don't strictly match.  */
-#define __fxstatat64 __fxstatat64_disable
-
-#include <errno.h>
-#include <fcntl.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <string.h>
 #include <sys/stat.h>
-
+#include <fcntl.h>
+#include <kernel_stat.h>
 #include <sysdep.h>
-#include <sys/syscall.h>
-
+#include <xstatconv.h>
 
-/* Get information about the file NAME relative to FD in ST.  */
+/* Get information about the file FD in BUF.  */
 int
 __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
 {
-  if (vers != _STAT_VER_KERNEL && vers != _STAT_VER_LINUX)
-    {
-      __set_errno (EINVAL);
-      return -1;
-    }
-
-  return INLINE_SYSCALL (newfstatat, 4, fd, file, st, flag);
+  struct kernel_stat kst;
+  int r = INLINE_SYSCALL_CALL (newfstatat, fd, file, &kst, flag);
+  return r ?: __xstat_conv (vers, &kst, st);
 }
 libc_hidden_def (__fxstatat)
-#undef __fxstatat64
-strong_alias (__fxstatat, __fxstatat64);
-strong_alias (__fxstatat64, __GI___fxstatat64)
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c b/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c
index 62df5fb26c..e5416d8971 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c
+++ b/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c
@@ -15,17 +15,9 @@
    License along with the GNU C Library.  If not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <fcntl.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <string.h>
 #include <sys/stat.h>
 #include <kernel_stat.h>
-
 #include <sysdep.h>
-#include <sys/syscall.h>
-
 #include <xstatconv.h>
 
 /* Get information about the file NAME in BUF.  */
@@ -33,22 +25,12 @@
 int
 __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag)
 {
-  if (__builtin_expect (vers != _STAT_VER_LINUX, 0))
-    {
-      __set_errno (EINVAL);
-      return -1;
-    }
-
-  int result;
-  struct kernel_stat kst;
-
-  result = INTERNAL_SYSCALL_CALL (newfstatat, fd, file, &kst, flag);
-  if (!__glibc_likely (INTERNAL_SYSCALL_ERROR_P (result)))
-    return __xstat64_conv (vers, &kst, st);
-  else
+  if (vers == _STAT_VER_LINUX)
     {
-      __set_errno (INTERNAL_SYSCALL_ERRNO (result));
-      return -1;
+      struct kernel_stat kst;
+      int r = INLINE_SYSCALL_CALL (newfstatat, fd, file, &kst, flag);;
+      return r ?: __xstat64_conv (vers, &kst, st);
     }
+  return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
 }
 libc_hidden_def (__fxstatat64)
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fxstatat.c b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fxstatat.c
deleted file mode 100644
index 0f8b3135d8..0000000000
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fxstatat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/fxstatat.c>
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/fxstatat.c b/sysdeps/unix/sysv/linux/s390/s390-32/fxstatat.c
deleted file mode 100644
index 0f8b3135d8..0000000000
--- a/sysdeps/unix/sysv/linux/s390/s390-32/fxstatat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/fxstatat.c>
diff --git a/sysdeps/unix/sysv/linux/sh/fxstatat.c b/sysdeps/unix/sysv/linux/sh/fxstatat.c
deleted file mode 100644
index 0f8b3135d8..0000000000
--- a/sysdeps/unix/sysv/linux/sh/fxstatat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/fxstatat.c>
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/fxstatat.c b/sysdeps/unix/sysv/linux/sparc/sparc32/fxstatat.c
deleted file mode 100644
index 0f8b3135d8..0000000000
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/fxstatat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/fxstatat.c>
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/dl-fxstatat64.c b/sysdeps/unix/sysv/linux/sparc/sparc64/dl-fxstatat64.c
deleted file mode 100644
index 330b33f7c7..0000000000
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/dl-fxstatat64.c
+++ /dev/null
@@ -1 +0,0 @@
-#include "fxstatat.c"
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/fxstatat.c b/sysdeps/unix/sysv/linux/sparc/sparc64/fxstatat.c
deleted file mode 100644
index db08af8e0f..0000000000
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/fxstatat.c
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../i386/fxstatat.c"
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/dl-fxstatat64.c b/sysdeps/unix/sysv/linux/wordsize-64/dl-fxstatat64.c
deleted file mode 100644
index 330b33f7c7..0000000000
--- a/sysdeps/unix/sysv/linux/wordsize-64/dl-fxstatat64.c
+++ /dev/null
@@ -1 +0,0 @@
-#include "fxstatat.c"
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/fxstatat64.c b/sysdeps/unix/sysv/linux/wordsize-64/fxstatat64.c
deleted file mode 100644
index 05e7f413bb..0000000000
--- a/sysdeps/unix/sysv/linux/wordsize-64/fxstatat64.c
+++ /dev/null
@@ -1 +0,0 @@
-/* fxstatat64 is in fxstatat.c */
-- 
2.25.1


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

* [PATCH 07/16] Linux: Consolidate xmknod
  2020-07-23 19:46 [PATCH 00/16] Add y2038 support for stat functions Adhemerval Zanella via Libc-alpha
                   ` (5 preceding siblings ...)
  2020-07-23 19:46 ` [PATCH 06/16] linux: Consolidate fxstatat{64} Adhemerval Zanella via Libc-alpha
@ 2020-07-23 19:46 ` Adhemerval Zanella via Libc-alpha
  2020-07-24  9:14   ` Lukasz Majewski
  2020-07-23 19:46 ` [PATCH 08/16] Remove internal usage of extensible stat functions Adhemerval Zanella via Libc-alpha
                   ` (8 subsequent siblings)
  15 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-07-23 19:46 UTC (permalink / raw)
  To: libc-alpha; +Cc: Alistair Francis

The __NR_mknodat syscall is supported on all kernels, so the generic
implementation is used as default.

Checked on x86_64-linux-gnu and i686-linux-gnu.
---
 sysdeps/unix/sysv/linux/generic/xmknod.c | 54 ------------------------
 sysdeps/unix/sysv/linux/xmknod.c         |  8 ++--
 2 files changed, 3 insertions(+), 59 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/generic/xmknod.c

diff --git a/sysdeps/unix/sysv/linux/generic/xmknod.c b/sysdeps/unix/sysv/linux/generic/xmknod.c
deleted file mode 100644
index a51fcbee22..0000000000
--- a/sysdeps/unix/sysv/linux/generic/xmknod.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Copyright (C) 2011-2020 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 <errno.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/sysmacros.h>
-
-#include <sysdep.h>
-#include <sys/syscall.h>
-
-/* Create a device file named PATH, with permission and special bits MODE
-   and device number DEV (which can be constructed from major and minor
-   device numbers with the `makedev' macro above).  */
-int
-__xmknod (int vers, const char *path, mode_t mode, dev_t *dev)
-{
-  unsigned long long int k_dev;
-
-  if (vers != _MKNOD_VER)
-    {
-      __set_errno (EINVAL);
-      return -1;
-    }
-
-  /* We must convert the value to dev_t type used by the kernel.  */
-  k_dev = (*dev) & ((1ULL << 32) - 1);
-  if (k_dev != *dev)
-    {
-      __set_errno (EINVAL);
-      return -1;
-    }
-
-  return INLINE_SYSCALL (mknodat, 4, AT_FDCWD, path, mode,
-                         (unsigned int) k_dev);
-}
-weak_alias (__xmknod, _xmknod)
-libc_hidden_def (__xmknod)
diff --git a/sysdeps/unix/sysv/linux/xmknod.c b/sysdeps/unix/sysv/linux/xmknod.c
index 5d0ae97c34..42809d4c57 100644
--- a/sysdeps/unix/sysv/linux/xmknod.c
+++ b/sysdeps/unix/sysv/linux/xmknod.c
@@ -16,13 +16,10 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/sysmacros.h>
-
+#include <fcntl.h>
 #include <sysdep.h>
-#include <sys/syscall.h>
 
 /* Create a device file named PATH, with permission and special bits MODE
    and device number DEV (which can be constructed from major and minor
@@ -40,7 +37,8 @@ __xmknod (int vers, const char *path, mode_t mode, dev_t *dev)
   if (k_dev != *dev)
     return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
 
-  return INLINE_SYSCALL (mknod, 3, path, mode, (unsigned int) k_dev);
+  return INLINE_SYSCALL_CALL (mknodat, AT_FDCWD, path, mode,
+			      (unsigned int) k_dev);
 }
 
 weak_alias (__xmknod, _xmknod)
-- 
2.25.1


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

* [PATCH 08/16] Remove internal usage of extensible stat functions
  2020-07-23 19:46 [PATCH 00/16] Add y2038 support for stat functions Adhemerval Zanella via Libc-alpha
                   ` (6 preceding siblings ...)
  2020-07-23 19:46 ` [PATCH 07/16] Linux: Consolidate xmknod Adhemerval Zanella via Libc-alpha
@ 2020-07-23 19:46 ` Adhemerval Zanella via Libc-alpha
  2020-07-24  9:16   ` Lukasz Majewski
  2020-07-23 19:46 ` [PATCH 09/16] Remove stat wrapper functions, move them to exported symbols Adhemerval Zanella via Libc-alpha
                   ` (7 subsequent siblings)
  15 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-07-23 19:46 UTC (permalink / raw)
  To: libc-alpha; +Cc: Alistair Francis

It replaces the internal usage of __{f,l}xstat{at}{64} with the
__{f,l}stat{at}{64}.  It should not change the generate code since
sys/stat.h explicit defines redirections to internal calls back to
xstat* symbols.

Checked with a build for all affected ABIs.  I also check on
x86_64-linux-gnu and i686-linux-gnu.
---
 catgets/open_catalog.c              |  2 +-
 csu/check_fds.c                     |  2 +-
 elf/cache.c                         |  4 +--
 elf/dl-load.c                       |  4 +--
 elf/dl-misc.c                       |  2 +-
 elf/dl-profile.c                    |  2 +-
 iconv/gconv_cache.c                 |  2 +-
 include/sys/stat.h                  |  1 +
 inet/rcmd.c                         |  4 +--
 inet/ruserpass.c                    |  2 +-
 intl/loadmsgcat.c                   |  2 +-
 io/file_change_detection.c          |  4 +--
 io/fts.c                            | 15 +++++-----
 io/fts64.c                          |  5 ++--
 io/ftw.c                            | 46 ++++++++++++++---------------
 io/ftw64.c                          |  8 ++---
 io/getdirname.c                     |  4 +--
 io/mkdirat.c                        |  2 +-
 io/mkfifoat.c                       |  2 +-
 io/openat.c                         |  2 +-
 io/openat64.c                       |  2 +-
 io/xmknodat.c                       |  2 +-
 libio/fileops.c                     |  2 +-
 locale/loadarchive.c                |  4 +--
 locale/loadlocale.c                 |  4 +--
 misc/daemon.c                       |  2 +-
 misc/getusershell.c                 |  2 +-
 nptl/sem_open.c                     |  2 +-
 nscd/nscd_helper.c                  |  2 +-
 posix/glob.c                        |  7 -----
 stdlib/canonicalize.c               |  2 +-
 sysdeps/gnu/glob64-lstat-compat.c   |  2 +-
 sysdeps/gnu/glob64.c                |  2 +-
 sysdeps/mach/hurd/ptsname.c         |  2 +-
 sysdeps/posix/dl-fileid.h           |  2 +-
 sysdeps/posix/euidaccess.c          |  2 +-
 sysdeps/posix/fdopendir.c           |  2 +-
 sysdeps/posix/fpathconf.c           |  2 +-
 sysdeps/posix/getaddrinfo.c         |  4 +--
 sysdeps/posix/isfdtype.c            |  2 +-
 sysdeps/posix/opendir.c             |  2 +-
 sysdeps/posix/pathconf.c            |  2 +-
 sysdeps/posix/posix_fallocate.c     |  2 +-
 sysdeps/posix/posix_fallocate64.c   |  2 +-
 sysdeps/posix/sysconf.c             |  2 +-
 sysdeps/posix/tempname.c            |  5 ++--
 sysdeps/unix/sysv/linux/faccessat.c |  2 +-
 sysdeps/unix/sysv/linux/fexecve.c   |  4 +--
 sysdeps/unix/sysv/linux/oldglob.c   |  2 +-
 sysdeps/unix/sysv/linux/pathconf.c  |  4 +--
 sysdeps/unix/sysv/linux/ptsname.c   |  4 +--
 sysdeps/unix/sysv/linux/ttyname.c   |  8 ++---
 sysdeps/unix/sysv/linux/ttyname_r.c |  8 ++---
 sysvipc/ftok.c                      |  2 +-
 time/getdate.c                      |  2 +-
 time/tzfile.c                       |  4 +--
 56 files changed, 108 insertions(+), 113 deletions(-)

diff --git a/catgets/open_catalog.c b/catgets/open_catalog.c
index 6b14963d78..cf8d635ae7 100644
--- a/catgets/open_catalog.c
+++ b/catgets/open_catalog.c
@@ -194,7 +194,7 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var,
       return -1;
     }
 
-  if (__builtin_expect (__fxstat64 (_STAT_VER, fd, &st), 0) < 0)
+  if (__builtin_expect (__fstat64 (fd, &st), 0) < 0)
     goto close_unlock_return;
 
   if (__builtin_expect (!S_ISREG (st.st_mode), 0)
diff --git a/csu/check_fds.c b/csu/check_fds.c
index 30634b81a7..29d9d04acb 100644
--- a/csu/check_fds.c
+++ b/csu/check_fds.c
@@ -71,7 +71,7 @@ check_one_fd (int fd, int mode)
 	 decsriptor numbers, in this order.  */
       struct stat64 st;
       if (__builtin_expect (nullfd != fd, 0)
-	  || __builtin_expect (__fxstat64 (_STAT_VER, fd, &st), 0) != 0
+	  || __builtin_expect (__fstat64 (fd, &st), 0) != 0
 	  || __builtin_expect (S_ISCHR (st.st_mode), 1) == 0
 	  || st.st_rdev != dev)
 	/* We cannot even give an error message here since it would
diff --git a/elf/cache.c b/elf/cache.c
index d92b4e59c1..1eb1455883 100644
--- a/elf/cache.c
+++ b/elf/cache.c
@@ -163,7 +163,7 @@ print_cache (const char *cache_name)
     error (EXIT_FAILURE, errno, _("Can't open cache file %s\n"), cache_name);
 
   struct stat64 st;
-  if (fstat64 (fd, &st) < 0
+  if (__fstat64 (fd, &st) < 0
       /* No need to map the file if it is empty.  */
       || st.st_size == 0)
     {
@@ -699,7 +699,7 @@ load_aux_cache (const char *aux_cache_name)
     }
 
   struct stat64 st;
-  if (fstat64 (fd, &st) < 0 || st.st_size < sizeof (struct aux_cache_file))
+  if (__fstat64 (fd, &st) < 0 || st.st_size < sizeof (struct aux_cache_file))
     {
       close (fd);
       init_aux_cache ();
diff --git a/elf/dl-load.c b/elf/dl-load.c
index e39980fb19..646c5dca40 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -1914,7 +1914,7 @@ open_path (const char *name, size_t namelen, int mode,
 
 		  buf[buflen - namelen - 1] = '\0';
 
-		  if (__xstat64 (_STAT_VER, buf, &st) != 0
+		  if (__stat64 (buf, &st) != 0
 		      || ! S_ISDIR (st.st_mode))
 		    /* The directory does not exist or it is no directory.  */
 		    this_dir->status[cnt] = nonexisting;
@@ -1934,7 +1934,7 @@ open_path (const char *name, size_t namelen, int mode,
 		 directories and so exploit the bugs.  */
 	      struct stat64 st;
 
-	      if (__fxstat64 (_STAT_VER, fd, &st) != 0
+	      if (__fstat64 (fd, &st) != 0
 		  || (st.st_mode & S_ISUID) == 0)
 		{
 		  /* The shared object cannot be tested for being SUID
diff --git a/elf/dl-misc.c b/elf/dl-misc.c
index f9d1fd7993..aee62e1e60 100644
--- a/elf/dl-misc.c
+++ b/elf/dl-misc.c
@@ -47,7 +47,7 @@ _dl_sysdep_read_whole_file (const char *file, size_t *sizep, int prot)
   int fd = __open64_nocancel (file, O_RDONLY | O_CLOEXEC);
   if (fd >= 0)
     {
-      if (__fxstat64 (_STAT_VER, fd, &st) >= 0)
+      if (__fstat64 (fd, &st) >= 0)
 	{
 	  *sizep = st.st_size;
 
diff --git a/elf/dl-profile.c b/elf/dl-profile.c
index c681f5415c..89dd70ba3b 100644
--- a/elf/dl-profile.c
+++ b/elf/dl-profile.c
@@ -342,7 +342,7 @@ _dl_start_profile (void)
       return;
     }
 
-  if (__fxstat64 (_STAT_VER, fd, &st) < 0 || !S_ISREG (st.st_mode))
+  if (__fstat64 (fd, &st) < 0 || !S_ISREG (st.st_mode))
     {
       /* Not stat'able or not a regular file => don't use it.  */
       errstr = "%s: cannot stat file: %s\n";
diff --git a/iconv/gconv_cache.c b/iconv/gconv_cache.c
index 9fe371b4c0..b326cd19e2 100644
--- a/iconv/gconv_cache.c
+++ b/iconv/gconv_cache.c
@@ -64,7 +64,7 @@ __gconv_load_cache (void)
     return -1;
 
   /* Get information about the file.  */
-  if (__builtin_expect (__fxstat64 (_STAT_VER, fd, &st), 0) < 0
+  if (__builtin_expect (__fstat64 (fd, &st), 0) < 0
       /* We do not have to start looking at the file if it cannot contain
 	 at least the cache header.  */
       || (size_t) st.st_size < sizeof (struct gconvcache_header))
diff --git a/include/sys/stat.h b/include/sys/stat.h
index 92284ca48b..f8847cf73e 100644
--- a/include/sys/stat.h
+++ b/include/sys/stat.h
@@ -53,6 +53,7 @@ extern __typeof (__fxstatat64) __fxstatat64 attribute_hidden;
 #define lstat64(fname, buf)  __lxstat64 (_STAT_VER, fname, buf)
 #define __lstat64(fname, buf)  __lxstat64 (_STAT_VER, fname, buf)
 #define stat64(fname, buf) __xstat64 (_STAT_VER, fname, buf)
+#define __stat64(fname, buf) __xstat64 (_STAT_VER, fname, buf)
 #define fstat64(fd, buf) __fxstat64 (_STAT_VER, fd, buf)
 #define __fstat64(fd, buf) __fxstat64 (_STAT_VER, fd, buf)
 #define fstat(fd, buf) __fxstat (_STAT_VER, fd, buf)
diff --git a/inet/rcmd.c b/inet/rcmd.c
index 8a9616f847..452ff7d099 100644
--- a/inet/rcmd.c
+++ b/inet/rcmd.c
@@ -474,7 +474,7 @@ iruserfopen (const char *file, uid_t okuser)
   /* If not a regular file, if owned by someone other than user or
      root, if writeable by anyone but the owner, or if hardlinked
      anywhere, quit.  */
-  if (__lxstat64 (_STAT_VER, file, &st))
+  if (__lstat64 (file, &st))
     cp = _("lstat failed");
   else if (!S_ISREG (st.st_mode))
     cp = _("not regular file");
@@ -483,7 +483,7 @@ iruserfopen (const char *file, uid_t okuser)
       res = fopen (file, "rce");
       if (!res)
 	cp = _("cannot open");
-      else if (__fxstat64 (_STAT_VER, fileno (res), &st) < 0)
+      else if (__fstat64 (fileno (res), &st) < 0)
 	cp = _("fstat failed");
       else if (st.st_uid && st.st_uid != okuser)
 	cp = _("bad owner");
diff --git a/inet/ruserpass.c b/inet/ruserpass.c
index 4fa6520c1a..d61a72877d 100644
--- a/inet/ruserpass.c
+++ b/inet/ruserpass.c
@@ -174,7 +174,7 @@ next:
 			break;
 		case PASSWD:
 			if (strcmp(*aname, "anonymous") &&
-			    fstat64(fileno(cfile), &stb) >= 0 &&
+			    __fstat64(fileno(cfile), &stb) >= 0 &&
 			    (stb.st_mode & 077) != 0) {
 	warnx(_("Error: .netrc file is readable by others."));
 	warnx(_("Remove 'password' line or make file unreadable by others."));
diff --git a/intl/loadmsgcat.c b/intl/loadmsgcat.c
index 91c1ef156a..d44a4a0b14 100644
--- a/intl/loadmsgcat.c
+++ b/intl/loadmsgcat.c
@@ -804,7 +804,7 @@ _nl_load_domain (struct loaded_l10nfile *domain_file,
   /* We must know about the size of the file.  */
   if (
 #ifdef _LIBC
-      __builtin_expect (fstat64 (fd, &st) != 0, 0)
+      __builtin_expect (__fstat64 (fd, &st) != 0, 0)
 #else
       __builtin_expect (fstat (fd, &st) != 0, 0)
 #endif
diff --git a/io/file_change_detection.c b/io/file_change_detection.c
index c6d700ed05..f52d8fecfa 100644
--- a/io/file_change_detection.c
+++ b/io/file_change_detection.c
@@ -67,7 +67,7 @@ __file_change_detection_for_path (struct file_change_detection *file,
                                   const char *path)
 {
   struct stat64 st;
-  if (stat64 (path, &st) != 0)
+  if (__stat64 (path, &st) != 0)
     switch (errno)
       {
       case EACCES:
@@ -105,7 +105,7 @@ __file_change_detection_for_fp (struct file_change_detection *file,
   else
     {
       struct stat64 st;
-      if (fstat64 (__fileno (fp), &st) != 0)
+      if (__fstat64 (__fileno (fp), &st) != 0)
         /* If we already have a file descriptor, all errors are fatal.  */
         return false;
       else
diff --git a/io/fts.c b/io/fts.c
index ba83691859..9668a205c3 100644
--- a/io/fts.c
+++ b/io/fts.c
@@ -81,8 +81,9 @@ static char sccsid[] = "@(#)fts.c	8.6 (Berkeley) 8/14/94";
 # define FTSOBJ FTS
 # define FTSENTRY FTSENT
 # define INO_T ino_t
-# define STAT stat
-# define LSTAT lstat
+# define STRUCT_STAT stat
+# define STAT __stat
+# define LSTAT __lstat
 #endif
 
 static FTSENTRY	*fts_alloc (FTSOBJ *, const char *, size_t);
@@ -872,7 +873,7 @@ fts_stat (FTSOBJ *sp, FTSENTRY *p, int follow)
 	FTSENTRY *t;
 	dev_t dev;
 	INO_T ino;
-	struct STAT *sbp, sb;
+	struct STRUCT_STAT *sbp, sb;
 	int saved_errno;
 
 	/* If user needs stat info, stat buffer already allocated. */
@@ -906,7 +907,7 @@ fts_stat (FTSOBJ *sp, FTSENTRY *p, int follow)
 		}
 	} else if (LSTAT(p->fts_accpath, sbp)) {
 		p->fts_errno = errno;
-err:		memset(sbp, 0, sizeof(struct STAT));
+err:		memset(sbp, 0, sizeof(struct STRUCT_STAT));
 		return (FTS_NS);
 	}
 
@@ -996,7 +997,7 @@ fts_alloc (FTSOBJ *sp, const char *name, size_t namelen)
 	 */
 	len = sizeof(FTSENTRY) + namelen;
 	if (!ISSET(FTS_NOSTAT))
-		len += sizeof(struct STAT) + ALIGNBYTES;
+		len += sizeof(struct STRUCT_STAT) + ALIGNBYTES;
 	if ((p = malloc(len)) == NULL)
 		return (NULL);
 
@@ -1005,7 +1006,7 @@ fts_alloc (FTSOBJ *sp, const char *name, size_t namelen)
 	p->fts_name[namelen] = '\0';
 
 	if (!ISSET(FTS_NOSTAT))
-		p->fts_statp = (struct STAT *)ALIGN(p->fts_name + namelen + 2);
+		p->fts_statp = (struct STRUCT_STAT *)ALIGN(p->fts_name + namelen + 2);
 	p->fts_namelen = namelen;
 	p->fts_path = sp->fts_path;
 	p->fts_errno = 0;
@@ -1116,7 +1117,7 @@ fts_safe_changedir (FTSOBJ *sp, FTSENTRY *p, int fd, const char *path)
 		return (0);
 	if (fd < 0 && (newfd = __open(path, O_RDONLY, 0)) < 0)
 		return (-1);
-	if (__fxstat64(_STAT_VER, newfd, &sb)) {
+	if (__fstat64(newfd, &sb)) {
 		ret = -1;
 		goto bail;
 	}
diff --git a/io/fts64.c b/io/fts64.c
index 3d9c779791..466703da37 100644
--- a/io/fts64.c
+++ b/io/fts64.c
@@ -24,7 +24,8 @@
 #define FTSOBJ FTS64
 #define FTSENTRY FTSENT64
 #define INO_T ino64_t
-#define STAT stat64
-#define LSTAT lstat64
+#define STRUCT_STAT stat64
+#define STAT __stat64
+#define LSTAT __lstat64
 
 #include "fts.c"
diff --git a/io/ftw.c b/io/ftw.c
index 8c79d29a9e..7104816e85 100644
--- a/io/ftw.c
+++ b/io/ftw.c
@@ -135,15 +135,15 @@ int rpl_lstat (const char *, struct stat *);
 # define NFTW_OLD_NAME __old_nftw
 # define NFTW_NEW_NAME __new_nftw
 # define INO_T ino_t
-# define STAT stat
+# define STRUCT_STAT stat
 # ifdef _LIBC
-#  define LXSTAT __lxstat
-#  define XSTAT __xstat
-#  define FXSTATAT __fxstatat
+#  define LSTAT __lstat
+#  define STAT __stat
+#  define FSTATAT __fstatat
 # else
-#  define LXSTAT(V,f,sb) lstat (f,sb)
-#  define XSTAT(V,f,sb) stat (f,sb)
-#  define FXSTATAT(V,d,f,sb,m) fstatat (d, f, sb, m)
+#  define LSTAT lstat
+#  define XTAT stat
+#  define FSTATAT fstatat
 # endif
 # define FTW_FUNC_T __ftw_func_t
 # define NFTW_FUNC_T __nftw_func_t
@@ -219,7 +219,7 @@ static const int ftw_arr[] =
 
 
 /* Forward declarations of local functions.  */
-static int ftw_dir (struct ftw_data *data, struct STAT *st,
+static int ftw_dir (struct ftw_data *data, struct STRUCT_STAT *st,
 		    struct dir_data *old_dir);
 
 
@@ -239,7 +239,7 @@ object_compare (const void *p1, const void *p2)
 
 
 static int
-add_object (struct ftw_data *data, struct STAT *st)
+add_object (struct ftw_data *data, struct STRUCT_STAT *st)
 {
   struct known_object *newp = malloc (sizeof (struct known_object));
   if (newp == NULL)
@@ -251,7 +251,7 @@ add_object (struct ftw_data *data, struct STAT *st)
 
 
 static inline int
-find_object (struct ftw_data *data, struct STAT *st)
+find_object (struct ftw_data *data, struct STRUCT_STAT *st)
 {
   struct known_object obj;
   obj.dev = st->st_dev;
@@ -378,7 +378,7 @@ static int
 process_entry (struct ftw_data *data, struct dir_data *dir, const char *name,
 	       size_t namlen, int d_type)
 {
-  struct STAT st;
+  struct STRUCT_STAT st;
   int result = 0;
   int flag = 0;
   size_t new_buflen;
@@ -405,16 +405,16 @@ process_entry (struct ftw_data *data, struct dir_data *dir, const char *name,
 
   int statres;
   if (dir->streamfd != -1)
-    statres = FXSTATAT (_STAT_VER, dir->streamfd, name, &st,
-			(data->flags & FTW_PHYS) ? AT_SYMLINK_NOFOLLOW : 0);
+    statres = FSTATAT (dir->streamfd, name, &st,
+		       (data->flags & FTW_PHYS) ? AT_SYMLINK_NOFOLLOW : 0);
   else
     {
       if ((data->flags & FTW_CHDIR) == 0)
 	name = data->dirbuf;
 
       statres = ((data->flags & FTW_PHYS)
-		 ? LXSTAT (_STAT_VER, name, &st)
-		 : XSTAT (_STAT_VER, name, &st));
+		 ? LSTAT (name, &st)
+		 : STAT (name, &st));
     }
 
   if (statres < 0)
@@ -430,10 +430,10 @@ process_entry (struct ftw_data *data, struct dir_data *dir, const char *name,
 	     it should contain information about the link (ala lstat).
 	     We do our best to fill in what data we can.  */
 	  if (dir->streamfd != -1)
-	    statres = FXSTATAT (_STAT_VER, dir->streamfd, name, &st,
-				AT_SYMLINK_NOFOLLOW);
+	    statres = FSTATAT (dir->streamfd, name, &st,
+			       AT_SYMLINK_NOFOLLOW);
 	  else
-	    statres = LXSTAT (_STAT_VER, name, &st);
+	    statres = LSTAT (name, &st);
 	  if (statres == 0 && S_ISLNK (st.st_mode))
 	    flag = FTW_SLN;
 	  else
@@ -476,7 +476,7 @@ process_entry (struct ftw_data *data, struct dir_data *dir, const char *name,
 
 static int
 __attribute ((noinline))
-ftw_dir (struct ftw_data *data, struct STAT *st, struct dir_data *old_dir)
+ftw_dir (struct ftw_data *data, struct STRUCT_STAT *st, struct dir_data *old_dir)
 {
   struct dir_data dir;
   struct dirent64 *d;
@@ -630,7 +630,7 @@ ftw_startup (const char *dir, int is_nftw, void *func, int descriptors,
 	     int flags)
 {
   struct ftw_data data;
-  struct STAT st;
+  struct STRUCT_STAT st;
   int result = 0;
   int save_err;
   int cwdfd = -1;
@@ -740,12 +740,12 @@ ftw_startup (const char *dir, int is_nftw, void *func, int descriptors,
 	name = data.dirbuf;
 
       if (((flags & FTW_PHYS)
-	   ? LXSTAT (_STAT_VER, name, &st)
-	   : XSTAT (_STAT_VER, name, &st)) < 0)
+	   ? LSTAT (name, &st)
+	   : STAT (name, &st)) < 0)
 	{
 	  if (!(flags & FTW_PHYS)
 	      && errno == ENOENT
-	      && LXSTAT (_STAT_VER, name, &st) == 0
+	      && LSTAT (name, &st) == 0
 	      && S_ISLNK (st.st_mode))
 	    result = (*data.func) (data.dirbuf, &st, data.cvt_arr[FTW_SLN],
 				   &data.ftw);
diff --git a/io/ftw64.c b/io/ftw64.c
index 20c43d9616..8daf8777cf 100644
--- a/io/ftw64.c
+++ b/io/ftw64.c
@@ -22,10 +22,10 @@
 #define NFTW_OLD_NAME __old_nftw64
 #define NFTW_NEW_NAME __new_nftw64
 #define INO_T ino64_t
-#define STAT stat64
-#define LXSTAT __lxstat64
-#define XSTAT __xstat64
-#define FXSTATAT __fxstatat64
+#define STRUCT_STAT stat64
+#define LSTAT __lstat64
+#define STAT __stat64
+#define FSTATAT __fstatat64
 #define FTW_FUNC_T __ftw64_func_t
 #define NFTW_FUNC_T __nftw64_func_t
 
diff --git a/io/getdirname.c b/io/getdirname.c
index dd69e4e281..2465b62ad2 100644
--- a/io/getdirname.c
+++ b/io/getdirname.c
@@ -32,8 +32,8 @@ get_current_dir_name (void)
 
   pwd = getenv ("PWD");
   if (pwd != NULL
-      && stat64 (".", &dotstat) == 0
-      && stat64 (pwd, &pwdstat) == 0
+      && __stat64 (".", &dotstat) == 0
+      && __stat64 (pwd, &pwdstat) == 0
       && pwdstat.st_dev == dotstat.st_dev
       && pwdstat.st_ino == dotstat.st_ino)
     /* The PWD value is correct.  Use it.  */
diff --git a/io/mkdirat.c b/io/mkdirat.c
index cfe01b5748..094f0d7e0e 100644
--- a/io/mkdirat.c
+++ b/io/mkdirat.c
@@ -36,7 +36,7 @@ mkdirat (int fd, const char *path, mode_t mode)
     {
       /* Check FD is associated with a directory.  */
       struct stat64 st;
-      if (__fxstat64 (_STAT_VER, fd, &st) != 0)
+      if (__fstat64 (fd, &st) != 0)
 	return -1;
 
       if (!S_ISDIR (st.st_mode))
diff --git a/io/mkfifoat.c b/io/mkfifoat.c
index 409f55112c..f2af653399 100644
--- a/io/mkfifoat.c
+++ b/io/mkfifoat.c
@@ -37,7 +37,7 @@ mkfifoat (int fd, const char *path, mode_t mode)
     {
       /* Check FD is associated with a directory.  */
       struct stat64 st;
-      if (__fxstat64 (_STAT_VER, fd, &st) != 0)
+      if (__fstat64 (fd, &st) != 0)
 	return -1;
 
       if (!S_ISDIR (st.st_mode))
diff --git a/io/openat.c b/io/openat.c
index a7ce65bee2..a2e86eddeb 100644
--- a/io/openat.c
+++ b/io/openat.c
@@ -47,7 +47,7 @@ __openat (int fd, const char *file, int oflag, ...)
     {
       /* Check FD is associated with a directory.  */
       struct stat64 st;
-      if (__fxstat64 (_STAT_VER, fd, &st) != 0)
+      if (__fstat64 (fd, &st) != 0)
 	return -1;
 
       if (!S_ISDIR (st.st_mode))
diff --git a/io/openat64.c b/io/openat64.c
index b66979c035..a4bb188eb2 100644
--- a/io/openat64.c
+++ b/io/openat64.c
@@ -40,7 +40,7 @@ __openat64 (int fd, const char *file, int oflag, ...)
     {
       /* Check FD is associated with a directory.  */
       struct stat64 st;
-      if (__fxstat64 (_STAT_VER, fd, &st) != 0)
+      if (__fstat64 (fd, &st) != 0)
 	return -1;
 
       if (!S_ISDIR (st.st_mode))
diff --git a/io/xmknodat.c b/io/xmknodat.c
index 0e69db1940..b6c668170b 100644
--- a/io/xmknodat.c
+++ b/io/xmknodat.c
@@ -44,7 +44,7 @@ __xmknodat (int vers, int fd, const char *path, mode_t mode, dev_t *dev)
     {
       /* Check FD is associated with a directory.  */
       struct stat64 st;
-      if (__fxstat64 (_STAT_VER, fd, &st) != 0)
+      if (__fstat64 (fd, &st) != 0)
 	return -1;
 
       if (!S_ISDIR (st.st_mode))
diff --git a/libio/fileops.c b/libio/fileops.c
index bc76f3549f..99f06efc10 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -1145,7 +1145,7 @@ libc_hidden_def (_IO_file_seek)
 int
 _IO_file_stat (FILE *fp, void *st)
 {
-  return __fxstat64 (_STAT_VER, fp->_fileno, (struct stat64 *) st);
+  return __fstat64 (fp->_fileno, (struct stat64 *) st);
 }
 libc_hidden_def (_IO_file_stat)
 
diff --git a/locale/loadarchive.c b/locale/loadarchive.c
index ba0fe45648..8de6a327a4 100644
--- a/locale/loadarchive.c
+++ b/locale/loadarchive.c
@@ -207,7 +207,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
 	/* Cannot open the archive, for whatever reason.  */
 	return NULL;
 
-      if (__fxstat64 (_STAT_VER, fd, &archive_stat) == -1)
+      if (__fstat64 (fd, &archive_stat) == -1)
 	{
 	  /* stat failed, very strange.  */
 	close_and_out:
@@ -405,7 +405,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
 	      /* Now verify we think this is really the same archive file
 		 we opened before.  If it has been changed we cannot trust
 		 the header we read previously.  */
-	      if (__fxstat64 (_STAT_VER, fd, &st) < 0
+	      if (__fstat64 (fd, &st) < 0
 		  || st.st_size != archive_stat.st_size
 		  || st.st_mtime != archive_stat.st_mtime
 		  || st.st_dev != archive_stat.st_dev
diff --git a/locale/loadlocale.c b/locale/loadlocale.c
index 2fcb348d1d..82c745d9a2 100644
--- a/locale/loadlocale.c
+++ b/locale/loadlocale.c
@@ -180,7 +180,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
     /* Cannot open the file.  */
     return;
 
-  if (__builtin_expect (__fxstat64 (_STAT_VER, fd, &st), 0) < 0)
+  if (__builtin_expect (__fstat64 (fd, &st), 0) < 0)
     {
     puntfd:
       __close_nocancel_nostatus (fd);
@@ -206,7 +206,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
       if (__builtin_expect (fd, 0) < 0)
 	return;
 
-      if (__builtin_expect (__fxstat64 (_STAT_VER, fd, &st), 0) < 0)
+      if (__builtin_expect (__fstat64 (fd, &st), 0) < 0)
 	goto puntfd;
     }
 
diff --git a/misc/daemon.c b/misc/daemon.c
index 21e785966a..0e688f4d74 100644
--- a/misc/daemon.c
+++ b/misc/daemon.c
@@ -64,7 +64,7 @@ daemon (int nochdir, int noclose)
 		struct stat64 st;
 
 		if ((fd = __open_nocancel(_PATH_DEVNULL, O_RDWR, 0)) != -1
-		    && (__builtin_expect (__fxstat64 (_STAT_VER, fd, &st), 0)
+		    && (__builtin_expect (__fstat64 (fd, &st), 0)
 			== 0)) {
 			if (__builtin_expect (S_ISCHR (st.st_mode), 1) != 0
 #if defined DEV_NULL_MAJOR && defined DEV_NULL_MINOR
diff --git a/misc/getusershell.c b/misc/getusershell.c
index fc2c43b771..11f5aa83f8 100644
--- a/misc/getusershell.c
+++ b/misc/getusershell.c
@@ -106,7 +106,7 @@ initshells (void)
 	strings = NULL;
 	if ((fp = fopen(_PATH_SHELLS, "rce")) == NULL)
 		goto init_okshells_noclose;
-	if (fstat64(fileno(fp), &statb) == -1) {
+	if (__fstat64(fileno(fp), &statb) == -1) {
 	init_okshells:
 		(void)fclose(fp);
 	init_okshells_noclose:
diff --git a/nptl/sem_open.c b/nptl/sem_open.c
index b022cbfd9a..05e286002b 100644
--- a/nptl/sem_open.c
+++ b/nptl/sem_open.c
@@ -68,7 +68,7 @@ check_add_mapping (const char *name, size_t namelen, int fd, sem_t *existing)
 
   /* Get the information about the file.  */
   struct stat64 st;
-  if (__fxstat64 (_STAT_VER, fd, &st) == 0)
+  if (__fstat64 (fd, &st) == 0)
     {
       /* Get the lock.  */
       lll_lock (__sem_mappings_lock, LLL_PRIVATE);
diff --git a/nscd/nscd_helper.c b/nscd/nscd_helper.c
index a4f3312f90..41c7937fcd 100644
--- a/nscd/nscd_helper.c
+++ b/nscd/nscd_helper.c
@@ -325,7 +325,7 @@ __nscd_get_mapping (request_type type, const char *key,
   if (__glibc_unlikely (n == keylen))
     {
       struct stat64 st;
-      if (__builtin_expect (fstat64 (mapfd, &st) != 0, 0)
+      if (__builtin_expect (__fstat64 (mapfd, &st) != 0, 0)
 	  || __builtin_expect (st.st_size < sizeof (struct database_pers_head),
 			       0))
 	goto out_close;
diff --git a/posix/glob.c b/posix/glob.c
index 4580cefb9f..b4b34945e2 100644
--- a/posix/glob.c
+++ b/posix/glob.c
@@ -49,12 +49,6 @@
 # define readdir(str) __readdir64 (str)
 # define getpwnam_r(name, bufp, buf, len, res) \
     __getpwnam_r (name, bufp, buf, len, res)
-# ifndef __lstat64
-#  define __lstat64(fname, buf) __lxstat64 (_STAT_VER, fname, buf)
-# endif
-# ifndef __stat64
-#  define __stat64(fname, buf) __xstat64 (_STAT_VER, fname, buf)
-# endif
 # define struct_stat64		struct stat64
 # define FLEXIBLE_ARRAY_MEMBER
 # include <shlib-compat.h>
@@ -63,7 +57,6 @@
 # define __getlogin_r(buf, len) getlogin_r (buf, len)
 # define __lstat64(fname, buf)  lstat (fname, buf)
 # define __stat64(fname, buf)   stat (fname, buf)
-# define __fxstatat64(_, d, f, st, flag) fstatat (d, f, st, flag)
 # define struct_stat64          struct stat
 # ifndef __MVS__
 #  define __alloca              alloca
diff --git a/stdlib/canonicalize.c b/stdlib/canonicalize.c
index cbd885a3c5..3fcb399a5d 100644
--- a/stdlib/canonicalize.c
+++ b/stdlib/canonicalize.c
@@ -158,7 +158,7 @@ __realpath (const char *name, char *resolved)
 	  dest = __mempcpy (dest, start, end - start);
 	  *dest = '\0';
 
-	  if (__lxstat64 (_STAT_VER, rpath, &st) < 0)
+	  if (__lstat64 (rpath, &st) < 0)
 	    goto error;
 
 	  if (S_ISLNK (st.st_mode))
diff --git a/sysdeps/gnu/glob64-lstat-compat.c b/sysdeps/gnu/glob64-lstat-compat.c
index 47b5e88498..ac1fe1496a 100644
--- a/sysdeps/gnu/glob64-lstat-compat.c
+++ b/sysdeps/gnu/glob64-lstat-compat.c
@@ -32,7 +32,7 @@
 #undef stat
 #define stat stat64
 #undef __stat
-#define __stat(file, buf) __xstat64 (_STAT_VER, file, buf)
+#define __stat(file, buf) __stat64 (file, buf)
 
 #define COMPILE_GLOB64	1
 
diff --git a/sysdeps/gnu/glob64.c b/sysdeps/gnu/glob64.c
index 42b5b225ca..32ac018fde 100644
--- a/sysdeps/gnu/glob64.c
+++ b/sysdeps/gnu/glob64.c
@@ -12,7 +12,7 @@
 #undef stat
 #define stat stat64
 #undef __stat
-#define __stat(file, buf) __xstat64 (_STAT_VER, file, buf)
+#define __stat(file, buf) __stat64 (file, buf)
 
 #define COMPILE_GLOB64	1
 
diff --git a/sysdeps/mach/hurd/ptsname.c b/sysdeps/mach/hurd/ptsname.c
index 9627f970f9..065ba2a268 100644
--- a/sysdeps/mach/hurd/ptsname.c
+++ b/sysdeps/mach/hurd/ptsname.c
@@ -63,7 +63,7 @@ __ptsname_internal (int fd, char *buf, size_t buflen, struct stat64 *stp)
 
   if (stp)
     {
-      if (__xstat64 (_STAT_VER, peername, stp) < 0)
+      if (__stat64 (peername, stp) < 0)
 	return errno;
     }
 
diff --git a/sysdeps/posix/dl-fileid.h b/sysdeps/posix/dl-fileid.h
index 7d1e9e4950..b3c8166701 100644
--- a/sysdeps/posix/dl-fileid.h
+++ b/sysdeps/posix/dl-fileid.h
@@ -34,7 +34,7 @@ _dl_get_file_id (int fd, struct r_file_id *id)
 {
   struct stat64 st;
 
-  if (__glibc_unlikely (__fxstat64 (_STAT_VER, fd, &st) < 0))
+  if (__glibc_unlikely (__fstat64 (fd, &st) < 0))
     return false;
 
   id->dev = st.st_dev;
diff --git a/sysdeps/posix/euidaccess.c b/sysdeps/posix/euidaccess.c
index 8a2776d502..050d370f4c 100644
--- a/sysdeps/posix/euidaccess.c
+++ b/sysdeps/posix/euidaccess.c
@@ -140,7 +140,7 @@ euidaccess (const char *path, int mode)
     return access (path, mode);
 #endif
 
-  if (stat64 (path, &stats))
+  if (__stat64 (path, &stats))
     return -1;
 
   mode &= (X_OK | W_OK | R_OK);	/* Clear any bogus bits. */
diff --git a/sysdeps/posix/fdopendir.c b/sysdeps/posix/fdopendir.c
index b690f7fc88..e424fbdaa2 100644
--- a/sysdeps/posix/fdopendir.c
+++ b/sysdeps/posix/fdopendir.c
@@ -29,7 +29,7 @@ __fdopendir (int fd)
 {
   struct stat64 statbuf;
 
-  if (__builtin_expect (__fxstat64 (_STAT_VER, fd, &statbuf), 0) < 0)
+  if (__builtin_expect (__fstat64 (fd, &statbuf), 0) < 0)
     return NULL;
   if (__glibc_unlikely (! S_ISDIR (statbuf.st_mode)))
     {
diff --git a/sysdeps/posix/fpathconf.c b/sysdeps/posix/fpathconf.c
index 1863be64e0..3a9fb1513f 100644
--- a/sysdeps/posix/fpathconf.c
+++ b/sysdeps/posix/fpathconf.c
@@ -133,7 +133,7 @@ __fpathconf (int fd, int name)
 	/* AIO is only allowed on regular files and block devices.  */
 	struct stat64 st;
 
-	if (__fxstat64 (_STAT_VER, fd, &st) < 0
+	if (__fstat64 (fd, &st) < 0
 	    || (! S_ISREG (st.st_mode) && ! S_ISBLK (st.st_mode)))
 	  return -1;
 	else
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index ed04e564f9..82c898fe35 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -1785,7 +1785,7 @@ gaiconf_init (void)
   if (fp != NULL)
     {
       struct stat64 st;
-      if (__fxstat64 (_STAT_VER, fileno (fp), &st) != 0)
+      if (__fstat64 (fileno (fp), &st) != 0)
 	{
 	  fclose (fp);
 	  goto no_file;
@@ -2138,7 +2138,7 @@ static void
 gaiconf_reload (void)
 {
   struct stat64 st;
-  if (__xstat64 (_STAT_VER, GAICONF_FNAME, &st) != 0
+  if (stat64 (GAICONF_FNAME, &st) != 0
       || !check_gaiconf_mtime (&st))
     gaiconf_init ();
 }
diff --git a/sysdeps/posix/isfdtype.c b/sysdeps/posix/isfdtype.c
index 20c6309220..3c63a33e88 100644
--- a/sysdeps/posix/isfdtype.c
+++ b/sysdeps/posix/isfdtype.c
@@ -29,7 +29,7 @@ isfdtype (int fildes, int fdtype)
 
   {
     int save_error = errno;
-    result = fstat64 (fildes, &st);
+    result = __fstat64 (fildes, &st);
     __set_errno (save_error);
   }
 
diff --git a/sysdeps/posix/opendir.c b/sysdeps/posix/opendir.c
index c6ab79246c..e89e09bfc7 100644
--- a/sysdeps/posix/opendir.c
+++ b/sysdeps/posix/opendir.c
@@ -56,7 +56,7 @@ opendir_tail (int fd)
      `stat' call.  The S_ISDIR check is superfluous if O_DIRECTORY works,
      but it's cheap and we need the stat call for st_blksize anyway.  */
   struct stat64 statbuf;
-  if (__glibc_unlikely (__fxstat64 (_STAT_VER, fd, &statbuf) < 0))
+  if (__glibc_unlikely (__fstat64 (fd, &statbuf) < 0))
     goto lose;
   if (__glibc_unlikely (! S_ISDIR (statbuf.st_mode)))
     {
diff --git a/sysdeps/posix/pathconf.c b/sysdeps/posix/pathconf.c
index 5819f03aa7..084c5fab59 100644
--- a/sysdeps/posix/pathconf.c
+++ b/sysdeps/posix/pathconf.c
@@ -131,7 +131,7 @@ __pathconf (const char *path, int name)
 	/* AIO is only allowed on regular files and block devices.  */
 	struct stat64 st;
 
-	if (__xstat64 (_STAT_VER, path, &st) < 0
+	if (__stat64 (path, &st) < 0
 	    || (! S_ISREG (st.st_mode) && ! S_ISBLK (st.st_mode)))
 	  return -1;
 	else
diff --git a/sysdeps/posix/posix_fallocate.c b/sysdeps/posix/posix_fallocate.c
index e7fccfc1c8..c9cf17bc7b 100644
--- a/sysdeps/posix/posix_fallocate.c
+++ b/sysdeps/posix/posix_fallocate.c
@@ -48,7 +48,7 @@ posix_fallocate (int fd, __off_t offset, __off_t len)
   }
 
   /* We have to make sure that this is really a regular file.  */
-  if (__fxstat64 (_STAT_VER, fd, &st) != 0)
+  if (__fstat64 (fd, &st) != 0)
     return EBADF;
   if (S_ISFIFO (st.st_mode))
     return ESPIPE;
diff --git a/sysdeps/posix/posix_fallocate64.c b/sysdeps/posix/posix_fallocate64.c
index f9d4fe5ca3..4f8fe47b18 100644
--- a/sysdeps/posix/posix_fallocate64.c
+++ b/sysdeps/posix/posix_fallocate64.c
@@ -48,7 +48,7 @@ __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len)
   }
 
   /* We have to make sure that this is really a regular file.  */
-  if (__fxstat64 (_STAT_VER, fd, &st) != 0)
+  if (__fstat64 (fd, &st) != 0)
     return EBADF;
   if (S_ISFIFO (st.st_mode))
     return ESPIPE;
diff --git a/sysdeps/posix/sysconf.c b/sysdeps/posix/sysconf.c
index 35ba7f8103..8f7c4708df 100644
--- a/sysdeps/posix/sysconf.c
+++ b/sysdeps/posix/sysconf.c
@@ -1216,7 +1216,7 @@ __sysconf_check_spec (const char *spec)
 	  spec, speclen + 1);
 
   struct stat64 st;
-  long int ret = __xstat64 (_STAT_VER, name, &st) >= 0 ? 1 : -1;
+  long int ret = __stat64 (name, &st) >= 0 ? 1 : -1;
 
   __set_errno (save_errno);
   return ret;
diff --git a/sysdeps/posix/tempname.c b/sysdeps/posix/tempname.c
index cd48385a40..3dd8f1e1ef 100644
--- a/sysdeps/posix/tempname.c
+++ b/sysdeps/posix/tempname.c
@@ -65,7 +65,6 @@
 # define __getpid getpid
 # define __mkdir mkdir
 # define __open open
-# define __lxstat64(version, file, buf) lstat (file, buf)
 # define __secure_getenv secure_getenv
 #endif
 
@@ -96,7 +95,7 @@ static int
 direxists (const char *dir)
 {
   struct_stat64 buf;
-  return __xstat64 (_STAT_VER, dir, &buf) == 0 && S_ISDIR (buf.st_mode);
+  return __stat64 (dir, &buf) == 0 && S_ISDIR (buf.st_mode);
 }
 
 /* Path search algorithm, for tmpnam, tmpfile, etc.  If DIR is
@@ -254,7 +253,7 @@ __gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
 	     succeeds if __xstat fails because the name does not exist.
 	     Note the continue to bypass the common logic at the bottom
 	     of the loop.  */
-	  if (__lxstat64 (_STAT_VER, tmpl, &st) < 0)
+	  if (__lstat64 (tmpl, &st) < 0)
 	    {
 	      if (errno == ENOENT)
 		{
diff --git a/sysdeps/unix/sysv/linux/faccessat.c b/sysdeps/unix/sysv/linux/faccessat.c
index e4f18ab2db..5a660f5201 100644
--- a/sysdeps/unix/sysv/linux/faccessat.c
+++ b/sysdeps/unix/sysv/linux/faccessat.c
@@ -37,7 +37,7 @@ faccessat (int fd, const char *file, int mode, int flag)
     return INLINE_SYSCALL (faccessat, 3, fd, file, mode);
 
   struct stat64 stats;
-  if (__fxstatat64 (_STAT_VER, fd, file, &stats, flag & AT_SYMLINK_NOFOLLOW))
+  if (__fstatat64 (fd, file, &stats, flag & AT_SYMLINK_NOFOLLOW))
     return -1;
 
   mode &= (X_OK | W_OK | R_OK);	/* Clear any bogus bits. */
diff --git a/sysdeps/unix/sysv/linux/fexecve.c b/sysdeps/unix/sysv/linux/fexecve.c
index 23c9799f5d..1fe3a23333 100644
--- a/sysdeps/unix/sysv/linux/fexecve.c
+++ b/sysdeps/unix/sysv/linux/fexecve.c
@@ -60,8 +60,8 @@ fexecve (int fd, char *const argv[], char *const envp[])
 
   /* We come here only if the 'execve' call fails.  Determine whether
      /proc is mounted.  If not we return ENOSYS.  */
-  struct stat st;
-  if (stat ("/proc/self/fd", &st) != 0 && errno == ENOENT)
+  struct stat64 st;
+  if (__stat64 ("/proc/self/fd", &st) != 0 && errno == ENOENT)
     save = ENOSYS;
 
   __set_errno (save);
diff --git a/sysdeps/unix/sysv/linux/oldglob.c b/sysdeps/unix/sysv/linux/oldglob.c
index a034c2d930..59bf89dc1d 100644
--- a/sysdeps/unix/sysv/linux/oldglob.c
+++ b/sysdeps/unix/sysv/linux/oldglob.c
@@ -31,7 +31,7 @@ libc_hidden_proto (__old_glob64);
 #undef stat
 #define stat stat64
 #undef __stat
-#define __stat(file, buf) __xstat64 (_STAT_VER, file, buf)
+#define __stat(file, buf) __stat64 (file, buf)
 
 /* Avoid calling gl_lstat with GLOB_ALTDIRFUNC.  */
 #define GLOB_NO_LSTAT
diff --git a/sysdeps/unix/sysv/linux/pathconf.c b/sysdeps/unix/sysv/linux/pathconf.c
index fec1a142e7..e59b8ab341 100644
--- a/sysdeps/unix/sysv/linux/pathconf.c
+++ b/sysdeps/unix/sysv/linux/pathconf.c
@@ -67,7 +67,7 @@ distinguish_extX (const struct statfs *fsbuf, const char *file, int fd)
   char path[PATH_MAX];
   struct stat64 st;
 
-  if ((file == NULL ? fstat64 (fd, &st) : stat64 (file, &st)) != 0)
+  if ((file == NULL ? __fstat64 (fd, &st) : __stat64 (file, &st)) != 0)
     /* Strange.  The statfd call worked, but stat fails.  Default to
        the more pessimistic value.  */
     return EXT2_LINK_MAX;
@@ -110,7 +110,7 @@ distinguish_extX (const struct statfs *fsbuf, const char *file, int fd)
 	    continue;
 
 	  struct stat64 fsst;
-	  if (stat64 (mntbuf.mnt_dir, &fsst) >= 0
+	  if (__stat64 (mntbuf.mnt_dir, &fsst) >= 0
 	      && st.st_dev == fsst.st_dev)
 	    {
 	      if (strcmp (mntbuf.mnt_type, "ext4") == 0)
diff --git a/sysdeps/unix/sysv/linux/ptsname.c b/sysdeps/unix/sysv/linux/ptsname.c
index 81d9d26f1e..4c569bf264 100644
--- a/sysdeps/unix/sysv/linux/ptsname.c
+++ b/sysdeps/unix/sysv/linux/ptsname.c
@@ -114,7 +114,7 @@ __ptsname_internal (int fd, char *buf, size_t buflen, struct stat64 *stp)
 	  return ERANGE;
 	}
 
-      if (__fxstat64 (_STAT_VER, fd, stp) < 0)
+      if (__fstat64 (fd, stp) < 0)
 	return errno;
 
       /* Check if FD really is a master pseudo terminal.  */
@@ -138,7 +138,7 @@ __ptsname_internal (int fd, char *buf, size_t buflen, struct stat64 *stp)
       p[2] = '\0';
     }
 
-  if (__xstat64 (_STAT_VER, buf, stp) < 0)
+  if (__stat64 (buf, stp) < 0)
     return errno;
 
   /* Check if the name we're about to return really corresponds to a
diff --git a/sysdeps/unix/sysv/linux/ttyname.c b/sysdeps/unix/sysv/linux/ttyname.c
index c05ca687f5..5fa6645353 100644
--- a/sysdeps/unix/sysv/linux/ttyname.c
+++ b/sysdeps/unix/sysv/linux/ttyname.c
@@ -84,7 +84,7 @@ getttyname (const char *dev, const struct stat64 *mytty, int save, int *dostat)
 	    *((char *) __mempcpy (getttyname_name, dev, devlen - 1)) = '/';
 	  }
 	memcpy (&getttyname_name[devlen], d->d_name, dlen);
-	if (__xstat64 (_STAT_VER, getttyname_name, &st) == 0
+	if (__stat64 (getttyname_name, &st) == 0
 	    && is_mytty (mytty, &st))
 	  {
 	    (void) __closedir (dirstream);
@@ -125,7 +125,7 @@ ttyname (int fd)
   if (__glibc_unlikely (__tcgetattr (fd, &term) < 0))
     return NULL;
 
-  if (__fxstat64 (_STAT_VER, fd, &st) < 0)
+  if (__fstat64 (fd, &st) < 0)
     return NULL;
 
   /* We try using the /proc filesystem.  */
@@ -162,14 +162,14 @@ ttyname (int fd)
 
       /* Verify readlink result, fall back on iterating through devices.  */
       if (ttyname_buf[0] == '/'
-	  && __xstat64 (_STAT_VER, ttyname_buf, &st1) == 0
+	  && __stat64 (ttyname_buf, &st1) == 0
 	  && is_mytty (&st, &st1))
 	return ttyname_buf;
 
       doispty = 1;
     }
 
-  if (__xstat64 (_STAT_VER, "/dev/pts", &st1) == 0 && S_ISDIR (st1.st_mode))
+  if (__stat64 ("/dev/pts", &st1) == 0 && S_ISDIR (st1.st_mode))
     {
       name = getttyname ("/dev/pts", &st, save, &dostat);
     }
diff --git a/sysdeps/unix/sysv/linux/ttyname_r.c b/sysdeps/unix/sysv/linux/ttyname_r.c
index 4a1ae40bb2..ad8cd28158 100644
--- a/sysdeps/unix/sysv/linux/ttyname_r.c
+++ b/sysdeps/unix/sysv/linux/ttyname_r.c
@@ -71,7 +71,7 @@ getttyname_r (char *buf, size_t buflen, const struct stat64 *mytty,
 	cp = __stpncpy (buf + devlen, d->d_name, needed);
 	cp[0] = '\0';
 
-	if (__xstat64 (_STAT_VER, buf, &st) == 0
+	if (__stat64 (buf, &st) == 0
 	    && is_mytty (mytty, &st))
 	  {
 	    (void) __closedir (dirstream);
@@ -118,7 +118,7 @@ __ttyname_r (int fd, char *buf, size_t buflen)
   if (__glibc_unlikely (__tcgetattr (fd, &term) < 0))
     return errno;
 
-  if (__fxstat64 (_STAT_VER, fd, &st) < 0)
+  if (__fstat64 (fd, &st) < 0)
     return errno;
 
   /* We try using the /proc filesystem.  */
@@ -146,7 +146,7 @@ __ttyname_r (int fd, char *buf, size_t buflen)
 
       /* Verify readlink result, fall back on iterating through devices.  */
       if (buf[0] == '/'
-	  && __xstat64 (_STAT_VER, buf, &st1) == 0
+	  && __stat64 (buf, &st1) == 0
 	  && is_mytty (&st, &st1))
 	return 0;
 
@@ -157,7 +157,7 @@ __ttyname_r (int fd, char *buf, size_t buflen)
   memcpy (buf, "/dev/pts/", sizeof ("/dev/pts/"));
   buflen -= sizeof ("/dev/pts/") - 1;
 
-  if (__xstat64 (_STAT_VER, buf, &st1) == 0 && S_ISDIR (st1.st_mode))
+  if (__stat64 (buf, &st1) == 0 && S_ISDIR (st1.st_mode))
     {
       ret = getttyname_r (buf, buflen, &st, save,
 			  &dostat);
diff --git a/sysvipc/ftok.c b/sysvipc/ftok.c
index 0b6dab403f..a65dbd520a 100644
--- a/sysvipc/ftok.c
+++ b/sysvipc/ftok.c
@@ -25,7 +25,7 @@ ftok (const char *pathname, int proj_id)
   struct stat64 st;
   key_t key;
 
-  if (__xstat64 (_STAT_VER, pathname, &st) < 0)
+  if (__stat64 (pathname, &st) < 0)
     return (key_t) -1;
 
   key = ((st.st_ino & 0xffff) | ((st.st_dev & 0xff) << 16)
diff --git a/time/getdate.c b/time/getdate.c
index d5c01b8446..ddd97ba277 100644
--- a/time/getdate.c
+++ b/time/getdate.c
@@ -121,7 +121,7 @@ __getdate_r (const char *string, struct tm *tp)
   if (datemsk == NULL || *datemsk == '\0')
     return 1;
 
-  if (stat64 (datemsk, &st) < 0)
+  if (__stat64 (datemsk, &st) < 0)
     return 3;
 
   if (!S_ISREG (st.st_mode))
diff --git a/time/tzfile.c b/time/tzfile.c
index af6da1bf00..e8084a86e8 100644
--- a/time/tzfile.c
+++ b/time/tzfile.c
@@ -152,7 +152,7 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
   /* If we were already using tzfile, check whether the file changed.  */
   struct stat64 st;
   if (was_using_tzfile
-      && stat64 (file, &st) == 0
+      && __stat64 (file, &st) == 0
       && tzfile_ino == st.st_ino && tzfile_dev == st.st_dev
       && tzfile_mtime == st.st_mtime)
     goto done;  /* Nothing to do.  */
@@ -164,7 +164,7 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
     goto ret_free_transitions;
 
   /* Get information about the file we are actually using.  */
-  if (fstat64 (__fileno (f), &st) != 0)
+  if (__fstat64 (__fileno (f), &st) != 0)
     goto lose;
 
   free ((void *) transitions);
-- 
2.25.1


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

* [PATCH 09/16] Remove stat wrapper functions, move them to exported symbols
  2020-07-23 19:46 [PATCH 00/16] Add y2038 support for stat functions Adhemerval Zanella via Libc-alpha
                   ` (7 preceding siblings ...)
  2020-07-23 19:46 ` [PATCH 08/16] Remove internal usage of extensible stat functions Adhemerval Zanella via Libc-alpha
@ 2020-07-23 19:46 ` Adhemerval Zanella via Libc-alpha
  2020-07-24  9:23   ` Lukasz Majewski
  2020-07-23 19:46 ` [PATCH 10/16] Remove mknod wrapper functions, move them to symbols Adhemerval Zanella via Libc-alpha
                   ` (6 subsequent siblings)
  15 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-07-23 19:46 UTC (permalink / raw)
  To: libc-alpha; +Cc: Alistair Francis

This patch removes the stat, stat64, lstat, lstat64, fstat, fstat64,
fstatat, and fstatat64 static wrapper and add the symbol on the libc
with the expected names.

Both the prototypes of the internal symbol linked by the static
wrappers and the inline redirectors are also removed from the installed
sys/stat.h header file.  The wrapper implementation license is also
change from LGPL to GPL.

Internally the _STAT_VER* definitions are moved to a arch-specific
xstatver.h file.  The internal defines that redirects internals
{f}stat{at} to their {f}xstat{at} counterparts are removed for Linux
(!NO_RTLD_HIDDEN).  Hurd still requires them since {f}stat{at} pulls
extra objects that makes the loader build fail otherwise (I haven't
dig into why exactly).

Checked with a build for all affected Linux ABIs and Hurd.  I checked
also on x86_64-linux-gnu and i686-linux-gnu.
---
 include/sys/stat.h                            |  94 ++++++++-----
 io/Makefile                                   |   4 +-
 io/Versions                                   |   4 +
 io/fstat.c                                    |  33 +----
 io/fstat64.c                                  |  36 +----
 io/fstatat.c                                  |  36 +----
 io/fstatat64.c                                |  36 +----
 io/lstat.c                                    |  33 +----
 io/lstat64.c                                  |  36 +----
 io/stat.c                                     |  34 +----
 io/stat64.c                                   |  36 +----
 io/sys/stat.h                                 | 129 ------------------
 nscd/gai.c                                    |   5 +
 sysdeps/generic/xstatver.h                    |   3 +
 sysdeps/mach/hurd/i386/libc.abilist           |   8 ++
 sysdeps/posix/getaddrinfo.c                   |   2 +-
 sysdeps/unix/sysv/linux/aarch64/libc.abilist  |   8 ++
 sysdeps/unix/sysv/linux/alpha/bits/stat.h     |   9 --
 sysdeps/unix/sysv/linux/alpha/libc.abilist    |   8 ++
 sysdeps/unix/sysv/linux/alpha/xstatver.h      |   9 ++
 sysdeps/unix/sysv/linux/arc/libc.abilist      |   8 ++
 sysdeps/unix/sysv/linux/arm/le/libc.abilist   |   8 ++
 sysdeps/unix/sysv/linux/bits/stat.h           |   6 -
 sysdeps/unix/sysv/linux/csky/libc.abilist     |   8 ++
 sysdeps/unix/sysv/linux/generic/bits/stat.h   |  11 --
 sysdeps/unix/sysv/linux/generic/xstatver.h    |   5 +
 sysdeps/unix/sysv/linux/hppa/libc.abilist     |   8 ++
 sysdeps/unix/sysv/linux/i386/libc.abilist     |   8 ++
 sysdeps/unix/sysv/linux/ia64/bits/stat.h      |   5 -
 sysdeps/unix/sysv/linux/ia64/libc.abilist     |   8 ++
 sysdeps/unix/sysv/linux/ia64/xstatver.h       |   5 +
 sysdeps/unix/sysv/linux/m68k/bits/stat.h      |   7 -
 .../unix/sysv/linux/m68k/m680x0/libc.abilist  |   8 ++
 sysdeps/unix/sysv/linux/m68k/xstatver.h       |   7 +
 .../sysv/linux/microblaze/be/libc.abilist     |   8 ++
 .../unix/sysv/linux/microblaze/bits/stat.h    |   7 -
 sysdeps/unix/sysv/linux/microblaze/xstatver.h |   7 +
 sysdeps/unix/sysv/linux/mips/bits/stat.h      |   7 -
 .../sysv/linux/mips/mips32/fpu/libc.abilist   |   8 ++
 .../sysv/linux/mips/mips64/n32/libc.abilist   |   8 ++
 .../sysv/linux/mips/mips64/n64/libc.abilist   |   8 ++
 sysdeps/unix/sysv/linux/mips/xstatver.h       |   7 +
 sysdeps/unix/sysv/linux/nios2/libc.abilist    |   8 ++
 sysdeps/unix/sysv/linux/powerpc/bits/stat.h   |  11 --
 .../linux/powerpc/powerpc32/fpu/libc.abilist  |   8 ++
 .../linux/powerpc/powerpc64/be/libc.abilist   |   8 ++
 .../linux/powerpc/powerpc64/le/libc.abilist   |   8 ++
 sysdeps/unix/sysv/linux/powerpc/xstatver.h    |  11 ++
 .../unix/sysv/linux/riscv/rv64/libc.abilist   |   8 ++
 sysdeps/unix/sysv/linux/s390/bits/stat.h      |  12 --
 .../unix/sysv/linux/s390/s390-32/libc.abilist |   8 ++
 .../unix/sysv/linux/s390/s390-64/libc.abilist |   8 ++
 sysdeps/unix/sysv/linux/s390/xstatver.h       |  16 +++
 sysdeps/unix/sysv/linux/sh/le/libc.abilist    |   8 ++
 sysdeps/unix/sysv/linux/sparc/bits/stat.h     |   7 -
 .../sysv/linux/sparc/sparc32/libc.abilist     |   8 ++
 .../sysv/linux/sparc/sparc64/libc.abilist     |   8 ++
 sysdeps/unix/sysv/linux/sparc/xstatver.h      |   7 +
 sysdeps/unix/sysv/linux/x86/bits/stat.h       |  10 --
 sysdeps/unix/sysv/linux/x86/xstatver.h        |  13 ++
 .../unix/sysv/linux/x86_64/64/libc.abilist    |   8 ++
 .../unix/sysv/linux/x86_64/x32/libc.abilist   |   8 ++
 sysdeps/unix/sysv/linux/xstatver.h            |   7 +
 63 files changed, 414 insertions(+), 501 deletions(-)
 create mode 100644 sysdeps/generic/xstatver.h
 create mode 100644 sysdeps/unix/sysv/linux/alpha/xstatver.h
 create mode 100644 sysdeps/unix/sysv/linux/generic/xstatver.h
 create mode 100644 sysdeps/unix/sysv/linux/ia64/xstatver.h
 create mode 100644 sysdeps/unix/sysv/linux/m68k/xstatver.h
 create mode 100644 sysdeps/unix/sysv/linux/microblaze/xstatver.h
 create mode 100644 sysdeps/unix/sysv/linux/mips/xstatver.h
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/xstatver.h
 create mode 100644 sysdeps/unix/sysv/linux/s390/xstatver.h
 create mode 100644 sysdeps/unix/sysv/linux/sparc/xstatver.h
 create mode 100644 sysdeps/unix/sysv/linux/x86/xstatver.h
 create mode 100644 sysdeps/unix/sysv/linux/xstatver.h

diff --git a/include/sys/stat.h b/include/sys/stat.h
index f8847cf73e..0be918a7a7 100644
--- a/include/sys/stat.h
+++ b/include/sys/stat.h
@@ -2,10 +2,26 @@
 #include <io/sys/stat.h>
 
 #ifndef _ISOMAC
+# include <xstatver.h>
+
 /* Now define the internal interfaces. */
 extern int __stat (const char *__file, struct stat *__buf);
+extern int __stat64 (const char *__file, struct stat64 *__buf);
 extern int __fstat (int __fd, struct stat *__buf);
+extern int __fstat64 (int __fd, struct stat64 *__buf);
 extern int __lstat (const char *__file, struct stat *__buf);
+extern int __lstat64 (const char *__file, struct stat64 *__buf);
+extern int __fstatat (int dirfd, const char *pathname, struct stat *buf,
+		      int flags);
+extern int __fstatat64 (int dirfd, const char *pathname, struct stat64 *buf,
+			int flags);
+# if IS_IN (libc) || (IS_IN (rtld) && !defined NO_RTLD_HIDDEN)
+hidden_proto (__stat64)
+hidden_proto (__fstat64)
+hidden_proto (__lstat64)
+hidden_proto (__fstatat64)
+# endif
+
 extern int __chmod (const char *__file, __mode_t __mode);
 libc_hidden_proto (__chmod)
 extern int __fchmod (int __fd, __mode_t __mode);
@@ -13,20 +29,9 @@ libc_hidden_proto (fchmodat)
 extern __mode_t __umask (__mode_t __mask);
 extern int __mkdir (const char *__path, __mode_t __mode);
 libc_hidden_proto (__mkdir)
+
 extern int __mknod (const char *__path,
 		    __mode_t __mode, __dev_t __dev);
-#if IS_IN (libc) || (IS_IN (rtld) && !defined NO_RTLD_HIDDEN)
-hidden_proto (__fxstat)
-hidden_proto (__fxstat64)
-hidden_proto (__lxstat)
-hidden_proto (__lxstat64)
-hidden_proto (__xstat)
-hidden_proto (__xstat64)
-#endif
-extern __inline__ int __stat (const char *__path, struct stat *__statbuf)
-{
-  return __xstat (_STAT_VER, __path, __statbuf);
-}
 libc_hidden_proto (__xmknod)
 extern __inline__ int __mknod (const char *__path, __mode_t __mode,
 			       __dev_t __dev)
@@ -35,32 +40,47 @@ extern __inline__ int __mknod (const char *__path, __mode_t __mode,
 }
 libc_hidden_proto (__xmknodat)
 
-libc_hidden_proto (__fxstatat)
-libc_hidden_proto (__fxstatat64)
-
-# if IS_IN (rtld) && !defined NO_RTLD_HIDDEN
-extern __typeof (__fxstatat64) __fxstatat64 attribute_hidden;
+int __fxstat (int __ver, int __fildes, struct stat *__stat_buf);
+int __xstat (int __ver, const char *__filename,
+	     struct stat *__stat_buf);
+int __lxstat (int __ver, const char *__filename, struct stat *__stat_buf);
+int __fxstatat (int __ver, int __fildes, const char *__filename,
+		struct stat *__stat_buf, int __flag);
+int __fxstat64 (int ver, int __fildes, struct stat64 *__stat_buf);
+int __xstat64 (int ver, const char *__filename, struct stat64 *__stat_buf);
+int __lxstat64 (int ver, const char *__filename, struct stat64 *__stat_buf);
+int __fxstatat64 (int ver, int __fildes, const char *__filename,
+		  struct stat64 *__stat_buf, int __flag);
+libc_hidden_proto (__fxstat);
+libc_hidden_proto (__xstat);
+libc_hidden_proto (__lxstat);
+libc_hidden_proto (__fxstatat);
+# if IS_IN (libc) || (IS_IN (rtld) && !defined NO_RTLD_HIDDEN)
+hidden_proto (__fxstat64);
+hidden_proto (__xstat64);
+hidden_proto (__lxstat64);
+hidden_proto (__fxstatat64);
 # endif
 
-/* The `stat', `fstat', `lstat' functions have to be handled special since
-   even while not compiling the library with optimization calls to these
-   functions in the shared library must reference the `xstat' etc functions.
-   We have to use macros but we cannot define them in the normal headers
-   since on user level we must use real functions.  */
-#define stat(fname, buf) __xstat (_STAT_VER, fname, buf)
-#define lstat(fname, buf)  __lxstat (_STAT_VER, fname, buf)
-#define __lstat(fname, buf)  __lxstat (_STAT_VER, fname, buf)
-#define lstat64(fname, buf)  __lxstat64 (_STAT_VER, fname, buf)
-#define __lstat64(fname, buf)  __lxstat64 (_STAT_VER, fname, buf)
-#define stat64(fname, buf) __xstat64 (_STAT_VER, fname, buf)
-#define __stat64(fname, buf) __xstat64 (_STAT_VER, fname, buf)
-#define fstat64(fd, buf) __fxstat64 (_STAT_VER, fd, buf)
-#define __fstat64(fd, buf) __fxstat64 (_STAT_VER, fd, buf)
-#define fstat(fd, buf) __fxstat (_STAT_VER, fd, buf)
-#define __fstat(fd, buf) __fxstat (_STAT_VER, fd, buf)
-#define __fstatat(dfd, fname, buf, flag) \
-  __fxstatat (_STAT_VER, dfd, fname, buf, flag)
-#define __fstatat64(dfd, fname, buf, flag) \
-  __fxstatat64 (_STAT_VER, dfd, fname, buf, flag)
+# ifdef NO_RTLD_HIDDEN
+/* These are still required for Hurd.  */
+#  define stat(fname, buf) __xstat (_STAT_VER, fname, buf)
+#  define lstat(fname, buf)  __lxstat (_STAT_VER, fname, buf)
+#  define __lstat(fname, buf)  __lxstat (_STAT_VER, fname, buf)
+#  define lstat64(fname, buf)  __lxstat64 (_STAT_VER, fname, buf)
+#  define __lstat64(fname, buf)  __lxstat64 (_STAT_VER, fname, buf)
+#  define stat64(fname, buf) __xstat64 (_STAT_VER, fname, buf)
+#  define __stat64(fname, buf) __xstat64 (_STAT_VER, fname, buf)
+#  define fstat64(fd, buf) __fxstat64 (_STAT_VER, fd, buf)
+#  define __fstat64(fd, buf) __fxstat64 (_STAT_VER, fd, buf)
+#  define fstat(fd, buf) __fxstat (_STAT_VER, fd, buf)
+#  define __fstat(fd, buf) __fxstat (_STAT_VER, fd, buf)
+#  define __fstatat(dfd, fname, buf, flag) \
+    __fxstatat (_STAT_VER, dfd, fname, buf, flag)
+#  define __fstatat64(dfd, fname, buf, flag) \
+    __fxstatat64 (_STAT_VER, dfd, fname, buf, flag)
+# endif /* NO_RTLD_HIDDEN  */
+
 #endif
+
 #endif
diff --git a/io/Makefile b/io/Makefile
index cf380f3516..cee356b666 100644
--- a/io/Makefile
+++ b/io/Makefile
@@ -60,8 +60,7 @@ routines :=								\
 # These routines will be omitted from the libc shared object.
 # Instead the static object files will be included in a special archive
 # linked against when the shared library will be used.
-static-only-routines = stat fstat lstat stat64 fstat64 lstat64	\
-		       fstatat fstatat64 mknod mknodat
+static-only-routines = mknod mknodat
 
 others		:= pwd
 test-srcs	:= ftwtest
@@ -78,6 +77,7 @@ tests		:= test-utime test-stat test-stat2 test-lfs tst-getcwd \
 
 # Likewise for statx, but we do not need static linking here.
 tests-internal += tst-statx
+tests-static += tst-statx
 
 ifeq ($(run-built-tests),yes)
 tests-special += $(objpfx)ftwtest.out
diff --git a/io/Versions b/io/Versions
index ee468055ff..f6db0e84ad 100644
--- a/io/Versions
+++ b/io/Versions
@@ -132,6 +132,9 @@ libc {
     fcntl64;
     statx;
   }
+  GLIBC_2.33 {
+    stat; stat64; fstat; fstat64; lstat; lstat64; fstatat; fstatat64;
+  }
   GLIBC_PRIVATE {
     __libc_fcntl64;
     __fcntl_nocancel;
@@ -141,5 +144,6 @@ libc {
     __file_change_detection_for_stat;
     __file_change_detection_for_path;
     __file_change_detection_for_fp;
+    __fstat64;
   }
 }
diff --git a/io/fstat.c b/io/fstat.c
index 6ce077dc4a..faadd75e31 100644
--- a/io/fstat.c
+++ b/io/fstat.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1996-2020 Free Software Foundation, Inc.
+/* Get file status.
+   Copyright (C) 1996-2020 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
@@ -6,23 +7,6 @@
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.
 
-   In addition to the permissions in the GNU Lesser General Public
-   License, the Free Software Foundation gives you unlimited
-   permission to link the compiled version of this file with other
-   programs, and to distribute those programs without any restriction
-   coming from the use of this file. (The GNU Lesser General Public
-   License restrictions do apply in other respects; for example, they
-   cover modification of the file, and distribution when not linked
-   into another program.)
-
-   Note that people who make modified versions of this file are not
-   obligated to grant this special exception for their modified
-   versions; it is their choice whether to do so. The GNU Lesser
-   General Public License gives permission to release a modified
-   version without this exception; this exception also makes it
-   possible to release a modified version which carries forward this
-   exception.
-
    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
@@ -34,22 +18,11 @@
 
 #include <sys/stat.h>
 
-/* This definition is only used if inlining fails for this function; see
-   the last page of <sys/stat.h>.  The real work is done by the `x'
-   function which is passed a version number argument.  We arrange in the
-   makefile that when not inlined this function is always statically
-   linked; that way a dynamically-linked executable always encodes the
-   version number corresponding to the data structures it uses, so the `x'
-   functions in the shared library can adapt without needing to recompile
-   all callers.  */
-
-#undef fstat
 #undef __fstat
 int
-attribute_hidden
 __fstat (int fd, struct stat *buf)
 {
   return __fxstat (_STAT_VER, fd, buf);
 }
 
-weak_hidden_alias (__fstat, fstat)
+weak_alias (__fstat, fstat)
diff --git a/io/fstat64.c b/io/fstat64.c
index c4dd3acd60..b1fc17e5bf 100644
--- a/io/fstat64.c
+++ b/io/fstat64.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1996-2020 Free Software Foundation, Inc.
+/* Get file status.
+   Copyright (C) 1996-2020 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
@@ -6,23 +7,6 @@
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.
 
-   In addition to the permissions in the GNU Lesser General Public
-   License, the Free Software Foundation gives you unlimited
-   permission to link the compiled version of this file with other
-   programs, and to distribute those programs without any restriction
-   coming from the use of this file. (The GNU Lesser General Public
-   License restrictions do apply in other respects; for example, they
-   cover modification of the file, and distribution when not linked
-   into another program.)
-
-   Note that people who make modified versions of this file are not
-   obligated to grant this special exception for their modified
-   versions; it is their choice whether to do so. The GNU Lesser
-   General Public License gives permission to release a modified
-   version without this exception; this exception also makes it
-   possible to release a modified version which carries forward this
-   exception.
-
    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
@@ -34,19 +18,11 @@
 
 #include <sys/stat.h>
 
-/* This definition is only used if inlining fails for this function; see
-   the last page of <sys/stat.h>.  The real work is done by the `x'
-   function which is passed a version number argument.  We arrange in the
-   makefile that when not inlined this function is always statically
-   linked; that way a dynamically-linked executable always encodes the
-   version number corresponding to the data structures it uses, so the `x'
-   functions in the shared library can adapt without needing to recompile
-   all callers.  */
-
-#undef fstat64
+#undef __fstat64
 int
-attribute_hidden
-fstat64 (int fd, struct stat64 *buf)
+__fstat64 (int fd, struct stat64 *buf)
 {
   return __fxstat64 (_STAT_VER, fd, buf);
 }
+hidden_def (__fstat64)
+weak_alias (__fstat64, fstat64)
diff --git a/io/fstatat.c b/io/fstatat.c
index edc773487a..12443c2ff4 100644
--- a/io/fstatat.c
+++ b/io/fstatat.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2005-2020 Free Software Foundation, Inc.
+/* Get file status.
+   Copyright (C) 2005-2020 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
@@ -6,23 +7,6 @@
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.
 
-   In addition to the permissions in the GNU Lesser General Public
-   License, the Free Software Foundation gives you unlimited
-   permission to link the compiled version of this file with other
-   programs, and to distribute those programs without any restriction
-   coming from the use of this file. (The GNU Lesser General Public
-   License restrictions do apply in other respects; for example, they
-   cover modification of the file, and distribution when not linked
-   into another program.)
-
-   Note that people who make modified versions of this file are not
-   obligated to grant this special exception for their modified
-   versions; it is their choice whether to do so. The GNU Lesser
-   General Public License gives permission to release a modified
-   version without this exception; this exception also makes it
-   possible to release a modified version which carries forward this
-   exception.
-
    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
@@ -34,19 +18,11 @@
 
 #include <sys/stat.h>
 
-/* This definition is only used if inlining fails for this function; see
-   the last page of <sys/stat.h>.  The real work is done by the `x'
-   function which is passed a version number argument.  We arrange in the
-   makefile that when not inlined this function is always statically
-   linked; that way a dynamically-linked executable always encodes the
-   version number corresponding to the data structures it uses, so the `x'
-   functions in the shared library can adapt without needing to recompile
-   all callers.  */
-
-#undef fstatat
+#undef __fstatat
 int
-attribute_hidden
-fstatat (int fd, const char *file, struct stat *buf, int flag)
+__fstatat (int fd, const char *file, struct stat *buf, int flag)
 {
   return __fxstatat (_STAT_VER, fd, file, buf, flag);
 }
+
+weak_alias (__fstatat, fstatat)
diff --git a/io/fstatat64.c b/io/fstatat64.c
index b57133bd90..5ba4cdf68a 100644
--- a/io/fstatat64.c
+++ b/io/fstatat64.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2005-2020 Free Software Foundation, Inc.
+/* Get file status.
+   Copyright (C) 2005-2020 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
@@ -6,23 +7,6 @@
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.
 
-   In addition to the permissions in the GNU Lesser General Public
-   License, the Free Software Foundation gives you unlimited
-   permission to link the compiled version of this file with other
-   programs, and to distribute those programs without any restriction
-   coming from the use of this file. (The GNU Lesser General Public
-   License restrictions do apply in other respects; for example, they
-   cover modification of the file, and distribution when not linked
-   into another program.)
-
-   Note that people who make modified versions of this file are not
-   obligated to grant this special exception for their modified
-   versions; it is their choice whether to do so. The GNU Lesser
-   General Public License gives permission to release a modified
-   version without this exception; this exception also makes it
-   possible to release a modified version which carries forward this
-   exception.
-
    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
@@ -34,19 +18,11 @@
 
 #include <sys/stat.h>
 
-/* This definition is only used if inlining fails for this function; see
-   the last page of <sys/stat.h>.  The real work is done by the `x'
-   function which is passed a version number argument.  We arrange in the
-   makefile that when not inlined this function is always statically
-   linked; that way a dynamically-linked executable always encodes the
-   version number corresponding to the data structures it uses, so the `x'
-   functions in the shared library can adapt without needing to recompile
-   all callers.  */
-
-#undef fstatat64
+#undef __fstatat64
 int
-attribute_hidden
-fstatat64 (int fd, const char *file, struct stat64 *buf, int flag)
+__fstatat64 (int fd, const char *file, struct stat64 *buf, int flag)
 {
   return __fxstatat64 (_STAT_VER, fd, file, buf, flag);
 }
+hidden_def (__fstatat64)
+weak_alias (__fstatat64, fstatat64)
diff --git a/io/lstat.c b/io/lstat.c
index 7134741106..2a046c05e1 100644
--- a/io/lstat.c
+++ b/io/lstat.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1996-2020 Free Software Foundation, Inc.
+/* Get file status.
+   Copyright (C) 1996-2020 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
@@ -6,23 +7,6 @@
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.
 
-   In addition to the permissions in the GNU Lesser General Public
-   License, the Free Software Foundation gives you unlimited
-   permission to link the compiled version of this file with other
-   programs, and to distribute those programs without any restriction
-   coming from the use of this file. (The GNU Lesser General Public
-   License restrictions do apply in other respects; for example, they
-   cover modification of the file, and distribution when not linked
-   into another program.)
-
-   Note that people who make modified versions of this file are not
-   obligated to grant this special exception for their modified
-   versions; it is their choice whether to do so. The GNU Lesser
-   General Public License gives permission to release a modified
-   version without this exception; this exception also makes it
-   possible to release a modified version which carries forward this
-   exception.
-
    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
@@ -34,22 +18,11 @@
 
 #include <sys/stat.h>
 
-/* This definition is only used if inlining fails for this function; see
-   the last page of <sys/stat.h>.  The real work is done by the `x'
-   function which is passed a version number argument.  We arrange in the
-   makefile that when not inlined this function is always statically
-   linked; that way a dynamically-linked executable always encodes the
-   version number corresponding to the data structures it uses, so the `x'
-   functions in the shared library can adapt without needing to recompile
-   all callers.  */
-
-#undef lstat
 #undef __lstat
 int
-attribute_hidden
 __lstat (const char *file, struct stat *buf)
 {
   return __lxstat (_STAT_VER, file, buf);
 }
 
-weak_hidden_alias (__lstat, lstat)
+weak_alias (__lstat, lstat)
diff --git a/io/lstat64.c b/io/lstat64.c
index a890da71a8..a73c5a2541 100644
--- a/io/lstat64.c
+++ b/io/lstat64.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1996-2020 Free Software Foundation, Inc.
+/* Get file status.
+   Copyright (C) 1996-2020 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
@@ -6,23 +7,6 @@
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.
 
-   In addition to the permissions in the GNU Lesser General Public
-   License, the Free Software Foundation gives you unlimited
-   permission to link the compiled version of this file with other
-   programs, and to distribute those programs without any restriction
-   coming from the use of this file. (The GNU Lesser General Public
-   License restrictions do apply in other respects; for example, they
-   cover modification of the file, and distribution when not linked
-   into another program.)
-
-   Note that people who make modified versions of this file are not
-   obligated to grant this special exception for their modified
-   versions; it is their choice whether to do so. The GNU Lesser
-   General Public License gives permission to release a modified
-   version without this exception; this exception also makes it
-   possible to release a modified version which carries forward this
-   exception.
-
    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
@@ -34,19 +18,11 @@
 
 #include <sys/stat.h>
 
-/* This definition is only used if inlining fails for this function; see
-   the last page of <sys/stat.h>.  The real work is done by the `x'
-   function which is passed a version number argument.  We arrange in the
-   makefile that when not inlined this function is always statically
-   linked; that way a dynamically-linked executable always encodes the
-   version number corresponding to the data structures it uses, so the `x'
-   functions in the shared library can adapt without needing to recompile
-   all callers.  */
-
-#undef lstat64
+#undef __lstat64
 int
-attribute_hidden
-lstat64 (const char *file, struct stat64 *buf)
+__lstat64 (const char *file, struct stat64 *buf)
 {
   return __lxstat64 (_STAT_VER, file, buf);
 }
+hidden_def (__lstat64)
+weak_alias (__lstat64, lstat64)
diff --git a/io/stat.c b/io/stat.c
index 8c3cd877c8..b3d06107e3 100644
--- a/io/stat.c
+++ b/io/stat.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1996-2020 Free Software Foundation, Inc.
+/* Get file status.
+   Copyright (C) 1996-2020 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
@@ -6,23 +7,6 @@
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.
 
-   In addition to the permissions in the GNU Lesser General Public
-   License, the Free Software Foundation gives you unlimited
-   permission to link the compiled version of this file with other
-   programs, and to distribute those programs without any restriction
-   coming from the use of this file. (The GNU Lesser General Public
-   License restrictions do apply in other respects; for example, they
-   cover modification of the file, and distribution when not linked
-   into another program.)
-
-   Note that people who make modified versions of this file are not
-   obligated to grant this special exception for their modified
-   versions; it is their choice whether to do so. The GNU Lesser
-   General Public License gives permission to release a modified
-   version without this exception; this exception also makes it
-   possible to release a modified version which carries forward this
-   exception.
-
    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
@@ -34,21 +18,11 @@
 
 #include <sys/stat.h>
 
-/* This definition is only used if inlining fails for this function; see
-   the last page of <sys/stat.h>.  The real work is done by the `x'
-   function which is passed a version number argument.  We arrange in the
-   makefile that when not inlined this function is always statically
-   linked; that way a dynamically-linked executable always encodes the
-   version number corresponding to the data structures it uses, so the `x'
-   functions in the shared library can adapt without needing to recompile
-   all callers.  */
-
-#undef stat
+#undef __stat
 int
-attribute_hidden
 __stat (const char *file, struct stat *buf)
 {
   return __xstat (_STAT_VER, file, buf);
 }
 
-weak_hidden_alias (__stat, stat)
+weak_alias (__stat, stat)
diff --git a/io/stat64.c b/io/stat64.c
index 8b6b662f3a..41e8905c4e 100644
--- a/io/stat64.c
+++ b/io/stat64.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1996-2020 Free Software Foundation, Inc.
+/* Get file status.
+   Copyright (C) 1996-2020 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
@@ -6,23 +7,6 @@
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.
 
-   In addition to the permissions in the GNU Lesser General Public
-   License, the Free Software Foundation gives you unlimited
-   permission to link the compiled version of this file with other
-   programs, and to distribute those programs without any restriction
-   coming from the use of this file. (The GNU Lesser General Public
-   License restrictions do apply in other respects; for example, they
-   cover modification of the file, and distribution when not linked
-   into another program.)
-
-   Note that people who make modified versions of this file are not
-   obligated to grant this special exception for their modified
-   versions; it is their choice whether to do so. The GNU Lesser
-   General Public License gives permission to release a modified
-   version without this exception; this exception also makes it
-   possible to release a modified version which carries forward this
-   exception.
-
    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
@@ -34,19 +18,11 @@
 
 #include <sys/stat.h>
 
-/* This definition is only used if inlining fails for this function; see
-   the last page of <sys/stat.h>.  The real work is done by the `x'
-   function which is passed a version number argument.  We arrange in the
-   makefile that when not inlined this function is always statically
-   linked; that way a dynamically-linked executable always encodes the
-   version number corresponding to the data structures it uses, so the `x'
-   functions in the shared library can adapt without needing to recompile
-   all callers.  */
-
-#undef stat64
+#undef __stat64
 int
-attribute_hidden
-stat64 (const char *file, struct stat64 *buf)
+__stat64 (const char *file, struct stat64 *buf)
 {
   return __xstat64 (_STAT_VER, file, buf);
 }
+hidden_def (__stat64)
+weak_alias (__stat64, stat64)
diff --git a/io/sys/stat.h b/io/sys/stat.h
index ce014d03a5..83cf253c72 100644
--- a/io/sys/stat.h
+++ b/io/sys/stat.h
@@ -368,73 +368,10 @@ extern int utimensat (int __fd, const char *__path,
 extern int futimens (int __fd, const struct timespec __times[2]) __THROW;
 #endif
 \f
-/* To allow the `struct stat' structure and the file type `mode_t'
-   bits to vary without changing shared library major version number,
-   the `stat' family of functions and `mknod' are in fact inline
-   wrappers around calls to `xstat', `fxstat', `lxstat', and `xmknod',
-   which all take a leading version-number argument designating the
-   data structure and bits used.  <bits/stat.h> defines _STAT_VER with
-   the version number corresponding to `struct stat' as defined in
-   that file; and _MKNOD_VER with the version number corresponding to
-   the S_IF* macros defined therein.  It is arranged that when not
-   inlined these function are always statically linked; that way a
-   dynamically-linked executable always encodes the version number
-   corresponding to the data structures it uses, so the `x' functions
-   in the shared library can adapt without needing to recompile all
-   callers.  */
-
-#ifndef _STAT_VER
-# define _STAT_VER	0
-#endif
 #ifndef _MKNOD_VER
 # define _MKNOD_VER	0
 #endif
 
-/* Wrappers for stat and mknod system calls.  */
-#ifndef __USE_FILE_OFFSET64
-extern int __fxstat (int __ver, int __fildes, struct stat *__stat_buf)
-     __THROW __nonnull ((3));
-extern int __xstat (int __ver, const char *__filename,
-		    struct stat *__stat_buf) __THROW __nonnull ((2, 3));
-extern int __lxstat (int __ver, const char *__filename,
-		     struct stat *__stat_buf) __THROW __nonnull ((2, 3));
-extern int __fxstatat (int __ver, int __fildes, const char *__filename,
-		       struct stat *__stat_buf, int __flag)
-     __THROW __nonnull ((3, 4));
-#else
-# ifdef __REDIRECT_NTH
-extern int __REDIRECT_NTH (__fxstat, (int __ver, int __fildes,
-				      struct stat *__stat_buf), __fxstat64)
-     __nonnull ((3));
-extern int __REDIRECT_NTH (__xstat, (int __ver, const char *__filename,
-				     struct stat *__stat_buf), __xstat64)
-     __nonnull ((2, 3));
-extern int __REDIRECT_NTH (__lxstat, (int __ver, const char *__filename,
-				      struct stat *__stat_buf), __lxstat64)
-     __nonnull ((2, 3));
-extern int __REDIRECT_NTH (__fxstatat, (int __ver, int __fildes,
-					const char *__filename,
-					struct stat *__stat_buf, int __flag),
-			   __fxstatat64) __nonnull ((3, 4));
-
-# else
-#  define __fxstat __fxstat64
-#  define __xstat __xstat64
-#  define __lxstat __lxstat64
-# endif
-#endif
-
-#ifdef __USE_LARGEFILE64
-extern int __fxstat64 (int __ver, int __fildes, struct stat64 *__stat_buf)
-     __THROW __nonnull ((3));
-extern int __xstat64 (int __ver, const char *__filename,
-		      struct stat64 *__stat_buf) __THROW __nonnull ((2, 3));
-extern int __lxstat64 (int __ver, const char *__filename,
-		       struct stat64 *__stat_buf) __THROW __nonnull ((2, 3));
-extern int __fxstatat64 (int __ver, int __fildes, const char *__filename,
-			 struct stat64 *__stat_buf, int __flag)
-     __THROW __nonnull ((3, 4));
-#endif
 extern int __xmknod (int __ver, const char *__path, __mode_t __mode,
 		     __dev_t *__dev) __THROW __nonnull ((2, 4));
 
@@ -447,37 +384,6 @@ extern int __xmknodat (int __ver, int __fd, const char *__path,
 #endif
 
 #ifdef __USE_EXTERN_INLINES
-/* Inlined versions of the real stat and mknod functions.  */
-
-__extern_inline int
-__NTH (stat (const char *__path, struct stat *__statbuf))
-{
-  return __xstat (_STAT_VER, __path, __statbuf);
-}
-
-# if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
-__extern_inline int
-__NTH (lstat (const char *__path, struct stat *__statbuf))
-{
-  return __lxstat (_STAT_VER, __path, __statbuf);
-}
-# endif
-
-__extern_inline int
-__NTH (fstat (int __fd, struct stat *__statbuf))
-{
-  return __fxstat (_STAT_VER, __fd, __statbuf);
-}
-
-# ifdef __USE_ATFILE
-__extern_inline int
-__NTH (fstatat (int __fd, const char *__filename, struct stat *__statbuf,
-		int __flag))
-{
-  return __fxstatat (_STAT_VER, __fd, __filename, __statbuf, __flag);
-}
-# endif
-
 # ifdef __USE_MISC
 __extern_inline int
 __NTH (mknod (const char *__path, __mode_t __mode, __dev_t __dev))
@@ -494,41 +400,6 @@ __NTH (mknodat (int __fd, const char *__path, __mode_t __mode,
   return __xmknodat (_MKNOD_VER, __fd, __path, __mode, &__dev);
 }
 # endif
-
-# if defined __USE_LARGEFILE64 \
-  && (! defined __USE_FILE_OFFSET64 \
-      || (defined __REDIRECT_NTH && defined __OPTIMIZE__))
-__extern_inline int
-__NTH (stat64 (const char *__path, struct stat64 *__statbuf))
-{
-  return __xstat64 (_STAT_VER, __path, __statbuf);
-}
-
-#  if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
-__extern_inline int
-__NTH (lstat64 (const char *__path, struct stat64 *__statbuf))
-{
-  return __lxstat64 (_STAT_VER, __path, __statbuf);
-}
-#  endif
-
-__extern_inline int
-__NTH (fstat64 (int __fd, struct stat64 *__statbuf))
-{
-  return __fxstat64 (_STAT_VER, __fd, __statbuf);
-}
-
-#  ifdef __USE_ATFILE
-__extern_inline int
-__NTH (fstatat64 (int __fd, const char *__filename, struct stat64 *__statbuf,
-		  int __flag))
-{
-  return __fxstatat64 (_STAT_VER, __fd, __filename, __statbuf, __flag);
-}
-#  endif
-
-# endif
-
 #endif
 
 __END_DECLS
diff --git a/nscd/gai.c b/nscd/gai.c
index 2e19530102..b0058bc873 100644
--- a/nscd/gai.c
+++ b/nscd/gai.c
@@ -16,6 +16,7 @@
    along with this program; if not, see <https://www.gnu.org/licenses/>.  */
 
 #include <alloca.h>
+#include <sys/stat.h>
 
 /* This file uses the getaddrinfo code but it compiles it without NSCD
    support.  We just need a few symbol renames.  */
@@ -32,6 +33,10 @@
 #define __libc_use_alloca(size) (size <= __MAX_ALLOCA_CUTOFF)
 #define __getifaddrs getifaddrs
 #define __freeifaddrs freeifaddrs
+#undef __fstat64
+#define __fstat64 fstat64
+#undef __stat64
+#define __stat64 stat64
 
 /* We are nscd, so we don't want to be talking to ourselves.  */
 #undef  USE_NSCD
diff --git a/sysdeps/generic/xstatver.h b/sysdeps/generic/xstatver.h
new file mode 100644
index 0000000000..d727c98a16
--- /dev/null
+++ b/sysdeps/generic/xstatver.h
@@ -0,0 +1,3 @@
+/* Versions of the 'struct stat' data structure used in compatibility xstat
+   functions.  */
+#define _STAT_VER 0
diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist
index 5f6154d518..74a4ed5c1d 100644
--- a/sysdeps/mach/hurd/i386/libc.abilist
+++ b/sysdeps/mach/hurd/i386/libc.abilist
@@ -2192,6 +2192,14 @@ GLIBC_2.32 thrd_current F
 GLIBC_2.32 thrd_equal F
 GLIBC_2.32 thrd_sleep F
 GLIBC_2.32 thrd_yield F
+GLIBC_2.33 fstat F
+GLIBC_2.33 fstat64 F
+GLIBC_2.33 fstatat F
+GLIBC_2.33 fstatat64 F
+GLIBC_2.33 lstat F
+GLIBC_2.33 lstat64 F
+GLIBC_2.33 stat F
+GLIBC_2.33 stat64 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 82c898fe35..ad4923ddbc 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -2138,7 +2138,7 @@ static void
 gaiconf_reload (void)
 {
   struct stat64 st;
-  if (stat64 (GAICONF_FNAME, &st) != 0
+  if (__stat64 (GAICONF_FNAME, &st) != 0
       || !check_gaiconf_mtime (&st))
     gaiconf_init ();
 }
diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
index 6cd61988b4..03e4ae9296 100644
--- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
@@ -2160,3 +2160,11 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 fstat F
+GLIBC_2.33 fstat64 F
+GLIBC_2.33 fstatat F
+GLIBC_2.33 fstatat64 F
+GLIBC_2.33 lstat F
+GLIBC_2.33 lstat64 F
+GLIBC_2.33 stat F
+GLIBC_2.33 stat64 F
diff --git a/sysdeps/unix/sysv/linux/alpha/bits/stat.h b/sysdeps/unix/sysv/linux/alpha/bits/stat.h
index 0064ca09ff..1fc27936b9 100644
--- a/sysdeps/unix/sysv/linux/alpha/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/alpha/bits/stat.h
@@ -22,15 +22,6 @@
 #ifndef _BITS_STAT_H
 #define _BITS_STAT_H	1
 
-/* Versions of the `struct stat' data structure.  */
-#define _STAT_VER_KERNEL	0
-#define _STAT_VER_GLIBC2	1
-#define _STAT_VER_GLIBC2_1	2
-#define _STAT_VER_KERNEL64	3
-#define _STAT_VER_GLIBC2_3_4	3
-#define _STAT_VER_LINUX		3
-#define _STAT_VER		_STAT_VER_LINUX
-
 /* Versions of the `xmknod' interface.  */
 #define _MKNOD_VER_LINUX	0
 
diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist
index 8edb5deea1..5b752ef4a8 100644
--- a/sysdeps/unix/sysv/linux/alpha/libc.abilist
+++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist
@@ -2242,6 +2242,14 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 fstat F
+GLIBC_2.33 fstat64 F
+GLIBC_2.33 fstatat F
+GLIBC_2.33 fstatat64 F
+GLIBC_2.33 lstat F
+GLIBC_2.33 lstat64 F
+GLIBC_2.33 stat F
+GLIBC_2.33 stat64 F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/alpha/xstatver.h b/sysdeps/unix/sysv/linux/alpha/xstatver.h
new file mode 100644
index 0000000000..bbb9469617
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/alpha/xstatver.h
@@ -0,0 +1,9 @@
+/* Versions of the 'struct stat' data structure used in compatibility xstat
+   functions.  */
+#define _STAT_VER_KERNEL	0
+#define _STAT_VER_GLIBC2	1
+#define _STAT_VER_GLIBC2_1	2
+#define _STAT_VER_KERNEL64	3
+#define _STAT_VER_GLIBC2_3_4	3
+#define _STAT_VER_LINUX		3
+#define _STAT_VER		_STAT_VER_LINUX
diff --git a/sysdeps/unix/sysv/linux/arc/libc.abilist b/sysdeps/unix/sysv/linux/arc/libc.abilist
index df13f49e15..925b532383 100644
--- a/sysdeps/unix/sysv/linux/arc/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arc/libc.abilist
@@ -1920,3 +1920,11 @@ GLIBC_2.32 wprintf F
 GLIBC_2.32 write F
 GLIBC_2.32 writev F
 GLIBC_2.32 wscanf F
+GLIBC_2.33 fstat F
+GLIBC_2.33 fstat64 F
+GLIBC_2.33 fstatat F
+GLIBC_2.33 fstatat64 F
+GLIBC_2.33 lstat F
+GLIBC_2.33 lstat64 F
+GLIBC_2.33 stat F
+GLIBC_2.33 stat64 F
diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
index a83cc81958..a4c1a7c03c 100644
--- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
@@ -141,6 +141,14 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 fstat F
+GLIBC_2.33 fstat64 F
+GLIBC_2.33 fstatat F
+GLIBC_2.33 fstatat64 F
+GLIBC_2.33 lstat F
+GLIBC_2.33 lstat64 F
+GLIBC_2.33 stat F
+GLIBC_2.33 stat64 F
 GLIBC_2.4 _Exit F
 GLIBC_2.4 _IO_2_1_stderr_ D 0xa0
 GLIBC_2.4 _IO_2_1_stdin_ D 0xa0
diff --git a/sysdeps/unix/sysv/linux/bits/stat.h b/sysdeps/unix/sysv/linux/bits/stat.h
index 240628a6f4..b542623208 100644
--- a/sysdeps/unix/sysv/linux/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/bits/stat.h
@@ -23,12 +23,6 @@
 #define _BITS_STAT_H	1
 
 /* Versions of the `struct stat' data structure.  */
-#define _STAT_VER_LINUX_OLD	1
-#define _STAT_VER_KERNEL	1
-#define _STAT_VER_SVR4		2
-#define _STAT_VER_LINUX		3
-#define _STAT_VER		_STAT_VER_LINUX	/* The one defined below.  */
-
 /* Versions of the `xmknod' interface.  */
 #define _MKNOD_VER_LINUX	1
 #define _MKNOD_VER_SVR4		2
diff --git a/sysdeps/unix/sysv/linux/csky/libc.abilist b/sysdeps/unix/sysv/linux/csky/libc.abilist
index 32887b1c58..799873e189 100644
--- a/sysdeps/unix/sysv/linux/csky/libc.abilist
+++ b/sysdeps/unix/sysv/linux/csky/libc.abilist
@@ -2104,3 +2104,11 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 fstat F
+GLIBC_2.33 fstat64 F
+GLIBC_2.33 fstatat F
+GLIBC_2.33 fstatat64 F
+GLIBC_2.33 lstat F
+GLIBC_2.33 lstat64 F
+GLIBC_2.33 stat F
+GLIBC_2.33 stat64 F
diff --git a/sysdeps/unix/sysv/linux/generic/bits/stat.h b/sysdeps/unix/sysv/linux/generic/bits/stat.h
index 8d0980f0f5..35e14a47c6 100644
--- a/sysdeps/unix/sysv/linux/generic/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/generic/bits/stat.h
@@ -26,17 +26,6 @@
 #include <bits/endian.h>
 #include <bits/wordsize.h>
 
-/* 64-bit libc uses the kernel's 'struct stat', accessed via the
-   stat() syscall; 32-bit libc uses the kernel's 'struct stat64'
-   and accesses it via the stat64() syscall.  All the various
-   APIs offered by libc use the kernel shape for their struct stat
-   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 (specifically st_ino, st_size, and st_blocks).  */
-#define _STAT_VER_KERNEL	0
-#define _STAT_VER_LINUX		0
-#define _STAT_VER		_STAT_VER_KERNEL
-
 /* Versions of the `xmknod' interface.  */
 #define _MKNOD_VER_LINUX	0
 
diff --git a/sysdeps/unix/sysv/linux/generic/xstatver.h b/sysdeps/unix/sysv/linux/generic/xstatver.h
new file mode 100644
index 0000000000..8675db494c
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/generic/xstatver.h
@@ -0,0 +1,5 @@
+/* Versions of the 'struct stat' data structure used in compatibility xstat
+   functions.  */
+#define _STAT_VER_KERNEL	0
+#define _STAT_VER_LINUX		0
+#define _STAT_VER		_STAT_VER_KERNEL
diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist
index baf425072b..95c7bf4f06 100644
--- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
+++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
@@ -2063,6 +2063,14 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 fstat F
+GLIBC_2.33 fstat64 F
+GLIBC_2.33 fstatat F
+GLIBC_2.33 fstatat64 F
+GLIBC_2.33 lstat F
+GLIBC_2.33 lstat64 F
+GLIBC_2.33 stat F
+GLIBC_2.33 stat64 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist
index 8b0242a9b1..e7cf5cdb98 100644
--- a/sysdeps/unix/sysv/linux/i386/libc.abilist
+++ b/sysdeps/unix/sysv/linux/i386/libc.abilist
@@ -2229,6 +2229,14 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 fstat F
+GLIBC_2.33 fstat64 F
+GLIBC_2.33 fstatat F
+GLIBC_2.33 fstatat64 F
+GLIBC_2.33 lstat F
+GLIBC_2.33 lstat64 F
+GLIBC_2.33 stat F
+GLIBC_2.33 stat64 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/ia64/bits/stat.h b/sysdeps/unix/sysv/linux/ia64/bits/stat.h
index 608e988ae6..8ec2e4c81f 100644
--- a/sysdeps/unix/sysv/linux/ia64/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/ia64/bits/stat.h
@@ -22,11 +22,6 @@
 #ifndef _BITS_STAT_H
 #define _BITS_STAT_H	1
 
-/* Versions of the `struct stat' data structure.  */
-#define _STAT_VER_KERNEL	0
-#define _STAT_VER_LINUX		1
-#define _STAT_VER		_STAT_VER_LINUX
-
 /* Versions of the `xmknod' interface.  */
 #define _MKNOD_VER_LINUX	0
 
diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist
index b6ba86dbe9..beeb905efd 100644
--- a/sysdeps/unix/sysv/linux/ia64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist
@@ -2095,6 +2095,14 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 fstat F
+GLIBC_2.33 fstat64 F
+GLIBC_2.33 fstatat F
+GLIBC_2.33 fstatat64 F
+GLIBC_2.33 lstat F
+GLIBC_2.33 lstat64 F
+GLIBC_2.33 stat F
+GLIBC_2.33 stat64 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/ia64/xstatver.h b/sysdeps/unix/sysv/linux/ia64/xstatver.h
new file mode 100644
index 0000000000..4f02f697ad
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/ia64/xstatver.h
@@ -0,0 +1,5 @@
+/* Versions of the 'struct stat' data structure used in compatibility xstat
+   functions.  */
+#define _STAT_VER_KERNEL	0
+#define _STAT_VER_LINUX		1
+#define _STAT_VER		_STAT_VER_LINUX
diff --git a/sysdeps/unix/sysv/linux/m68k/bits/stat.h b/sysdeps/unix/sysv/linux/m68k/bits/stat.h
index 453dcac709..bf41776e6c 100644
--- a/sysdeps/unix/sysv/linux/m68k/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/m68k/bits/stat.h
@@ -22,13 +22,6 @@
 #ifndef _BITS_STAT_H
 #define _BITS_STAT_H	1
 
-/* Versions of the `struct stat' data structure.  */
-#define _STAT_VER_LINUX_OLD	1
-#define _STAT_VER_KERNEL	1
-#define _STAT_VER_SVR4		2
-#define _STAT_VER_LINUX		3
-#define _STAT_VER		_STAT_VER_LINUX	/* The one defined below.  */
-
 /* Versions of the `xmknod' interface.  */
 #define _MKNOD_VER_LINUX	1
 #define _MKNOD_VER_SVR4		2
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
index 2d726097ca..ed34e1fc82 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
@@ -2175,6 +2175,14 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 fstat F
+GLIBC_2.33 fstat64 F
+GLIBC_2.33 fstatat F
+GLIBC_2.33 fstatat64 F
+GLIBC_2.33 lstat F
+GLIBC_2.33 lstat64 F
+GLIBC_2.33 stat F
+GLIBC_2.33 stat64 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/m68k/xstatver.h b/sysdeps/unix/sysv/linux/m68k/xstatver.h
new file mode 100644
index 0000000000..59dba71dd1
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/m68k/xstatver.h
@@ -0,0 +1,7 @@
+/* Versions of the 'struct stat' data structure used in compatibility xstat
+   functions.  */
+#define _STAT_VER_LINUX_OLD	1
+#define _STAT_VER_KERNEL	1
+#define _STAT_VER_SVR4		2
+#define _STAT_VER_LINUX		3
+#define _STAT_VER		_STAT_VER_LINUX
diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
index 7c78649e03..e00f5115b2 100644
--- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
@@ -2155,3 +2155,11 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 fstat F
+GLIBC_2.33 fstat64 F
+GLIBC_2.33 fstatat F
+GLIBC_2.33 fstatat64 F
+GLIBC_2.33 lstat F
+GLIBC_2.33 lstat64 F
+GLIBC_2.33 stat F
+GLIBC_2.33 stat64 F
diff --git a/sysdeps/unix/sysv/linux/microblaze/bits/stat.h b/sysdeps/unix/sysv/linux/microblaze/bits/stat.h
index c5817e5b77..51316a8c1b 100644
--- a/sysdeps/unix/sysv/linux/microblaze/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/microblaze/bits/stat.h
@@ -23,13 +23,6 @@
 #ifndef _BITS_STAT_H
 #define _BITS_STAT_H	1
 
-/* Versions of the `struct stat' data structure.  */
-#define _STAT_VER_LINUX_OLD    1
-#define _STAT_VER_KERNEL       1
-#define _STAT_VER_SVR4         2
-#define _STAT_VER_LINUX        3
-#define _STAT_VER              _STAT_VER_LINUX  /* The one defined below.  */
-
 /* Versions of the `xmknod' interface.  */
 #define _MKNOD_VER_LINUX       1
 #define _MKNOD_VER_SVR4        2
diff --git a/sysdeps/unix/sysv/linux/microblaze/xstatver.h b/sysdeps/unix/sysv/linux/microblaze/xstatver.h
new file mode 100644
index 0000000000..bddaa0d5ec
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/microblaze/xstatver.h
@@ -0,0 +1,7 @@
+/* Versions of the 'struct stat' data structure used in compatibility xstat
+   functions.  */
+#define _STAT_VER_LINUX_OLD    1
+#define _STAT_VER_KERNEL       1
+#define _STAT_VER_SVR4         2
+#define _STAT_VER_LINUX        3
+#define _STAT_VER              _STAT_VER_LINUX  /* The one defined below.  */
diff --git a/sysdeps/unix/sysv/linux/mips/bits/stat.h b/sysdeps/unix/sysv/linux/mips/bits/stat.h
index b0e6726655..cfeb4ce6a4 100644
--- a/sysdeps/unix/sysv/linux/mips/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/mips/bits/stat.h
@@ -24,13 +24,6 @@
 
 #include <sgidefs.h>
 
-/* Versions of the `struct stat' data structure.  */
-#define _STAT_VER_LINUX_OLD	1
-#define _STAT_VER_KERNEL	1
-#define _STAT_VER_SVR4		2
-#define _STAT_VER_LINUX		3
-#define _STAT_VER		_STAT_VER_LINUX /* The one defined below.  */
-
 /* Versions of the `xmknod' interface.  */
 #define _MKNOD_VER_LINUX	1
 #define _MKNOD_VER_SVR4		2
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
index 9fa655b3a5..fe9ba4e982 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
@@ -2146,6 +2146,14 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 fstat F
+GLIBC_2.33 fstat64 F
+GLIBC_2.33 fstatat F
+GLIBC_2.33 fstatat64 F
+GLIBC_2.33 lstat F
+GLIBC_2.33 lstat64 F
+GLIBC_2.33 stat F
+GLIBC_2.33 stat64 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
index de990933cf..e67591e710 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
@@ -2152,6 +2152,14 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 fstat F
+GLIBC_2.33 fstat64 F
+GLIBC_2.33 fstatat F
+GLIBC_2.33 fstatat64 F
+GLIBC_2.33 lstat F
+GLIBC_2.33 lstat64 F
+GLIBC_2.33 stat F
+GLIBC_2.33 stat64 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
index 754491f209..e4eb9e6bbf 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
@@ -2146,6 +2146,14 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 fstat F
+GLIBC_2.33 fstat64 F
+GLIBC_2.33 fstatat F
+GLIBC_2.33 fstatat64 F
+GLIBC_2.33 lstat F
+GLIBC_2.33 lstat64 F
+GLIBC_2.33 stat F
+GLIBC_2.33 stat64 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/mips/xstatver.h b/sysdeps/unix/sysv/linux/mips/xstatver.h
new file mode 100644
index 0000000000..59dba71dd1
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/mips/xstatver.h
@@ -0,0 +1,7 @@
+/* Versions of the 'struct stat' data structure used in compatibility xstat
+   functions.  */
+#define _STAT_VER_LINUX_OLD	1
+#define _STAT_VER_KERNEL	1
+#define _STAT_VER_SVR4		2
+#define _STAT_VER_LINUX		3
+#define _STAT_VER		_STAT_VER_LINUX
diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist
index 36a875115c..0878998441 100644
--- a/sysdeps/unix/sysv/linux/nios2/libc.abilist
+++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist
@@ -2193,3 +2193,11 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 fstat F
+GLIBC_2.33 fstat64 F
+GLIBC_2.33 fstatat F
+GLIBC_2.33 fstatat64 F
+GLIBC_2.33 lstat F
+GLIBC_2.33 lstat64 F
+GLIBC_2.33 stat F
+GLIBC_2.33 stat64 F
diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/stat.h b/sysdeps/unix/sysv/linux/powerpc/bits/stat.h
index 61781bd902..40ea9a96d4 100644
--- a/sysdeps/unix/sysv/linux/powerpc/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/powerpc/bits/stat.h
@@ -24,17 +24,6 @@
 
 #include <bits/wordsize.h>
 
-/* Versions of the `struct stat' data structure.  */
-#define _STAT_VER_LINUX_OLD	1
-#define _STAT_VER_KERNEL	1
-#define _STAT_VER_SVR4		2
-#define _STAT_VER_LINUX	  3
-#if __WORDSIZE == 32
-# define _STAT_VER		_STAT_VER_LINUX
-#else
-# define _STAT_VER		_STAT_VER_KERNEL
-#endif
-
 /* Versions of the `xmknod' interface.  */
 #define _MKNOD_VER_LINUX	1
 #define _MKNOD_VER_SVR4		2
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
index 6de9bed51d..993c957e8e 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
@@ -2202,6 +2202,14 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 fstat F
+GLIBC_2.33 fstat64 F
+GLIBC_2.33 fstatat F
+GLIBC_2.33 fstatat64 F
+GLIBC_2.33 lstat F
+GLIBC_2.33 lstat64 F
+GLIBC_2.33 stat F
+GLIBC_2.33 stat64 F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
index 92114806ac..25a8e828e9 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
@@ -2065,6 +2065,14 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 fstat F
+GLIBC_2.33 fstat64 F
+GLIBC_2.33 fstatat F
+GLIBC_2.33 fstatat64 F
+GLIBC_2.33 lstat F
+GLIBC_2.33 lstat64 F
+GLIBC_2.33 stat F
+GLIBC_2.33 stat64 F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
index b01fdcfae1..46ae28e552 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
@@ -2355,3 +2355,11 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 fstat F
+GLIBC_2.33 fstat64 F
+GLIBC_2.33 fstatat F
+GLIBC_2.33 fstatat64 F
+GLIBC_2.33 lstat F
+GLIBC_2.33 lstat64 F
+GLIBC_2.33 stat F
+GLIBC_2.33 stat64 F
diff --git a/sysdeps/unix/sysv/linux/powerpc/xstatver.h b/sysdeps/unix/sysv/linux/powerpc/xstatver.h
new file mode 100644
index 0000000000..1656e2f7e4
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/xstatver.h
@@ -0,0 +1,11 @@
+/* Versions of the 'struct stat' data structure used in compatibility xstat
+   functions.  */
+#define _STAT_VER_LINUX_OLD	1
+#define _STAT_VER_KERNEL	1
+#define _STAT_VER_SVR4		2
+#define _STAT_VER_LINUX	  3
+#if __WORDSIZE == 32
+# define _STAT_VER		_STAT_VER_LINUX
+#else
+# define _STAT_VER		_STAT_VER_KERNEL
+#endif
diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
index 45cbeb1d98..1044aa6be2 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
@@ -2122,3 +2122,11 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 fstat F
+GLIBC_2.33 fstat64 F
+GLIBC_2.33 fstatat F
+GLIBC_2.33 fstatat64 F
+GLIBC_2.33 lstat F
+GLIBC_2.33 lstat64 F
+GLIBC_2.33 stat F
+GLIBC_2.33 stat64 F
diff --git a/sysdeps/unix/sysv/linux/s390/bits/stat.h b/sysdeps/unix/sysv/linux/s390/bits/stat.h
index b383a98692..d12055529a 100644
--- a/sysdeps/unix/sysv/linux/s390/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/s390/bits/stat.h
@@ -25,21 +25,9 @@
 #include <bits/wordsize.h>
 
 #if __WORDSIZE == 64
-/* Versions of the `struct stat' data structure.  */
-# define _STAT_VER_KERNEL	0
-# define _STAT_VER_LINUX	1
-# define _STAT_VER		_STAT_VER_LINUX
-
 /* Versions of the `xmknod' interface.	*/
 #define _MKNOD_VER_LINUX	0
 #else
-/* Versions of the `struct stat' data structure.  */
-# define _STAT_VER_LINUX_OLD	1
-# define _STAT_VER_KERNEL	1
-# define _STAT_VER_SVR4		2
-# define _STAT_VER_LINUX	3
-# define _STAT_VER		_STAT_VER_LINUX
-
 /* Versions of the `xmknod' interface.  */
 # define _MKNOD_VER_LINUX	1
 # define _MKNOD_VER_SVR4	2
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
index d0752dba6c..6b1fa7e67f 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
@@ -2200,6 +2200,14 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 fstat F
+GLIBC_2.33 fstat64 F
+GLIBC_2.33 fstatat F
+GLIBC_2.33 fstatat64 F
+GLIBC_2.33 lstat F
+GLIBC_2.33 lstat64 F
+GLIBC_2.33 stat F
+GLIBC_2.33 stat64 F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
index af5f14d1c6..0aec094e7b 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
@@ -2101,6 +2101,14 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 fstat F
+GLIBC_2.33 fstat64 F
+GLIBC_2.33 fstatat F
+GLIBC_2.33 fstatat64 F
+GLIBC_2.33 lstat F
+GLIBC_2.33 lstat64 F
+GLIBC_2.33 stat F
+GLIBC_2.33 stat64 F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/s390/xstatver.h b/sysdeps/unix/sysv/linux/s390/xstatver.h
new file mode 100644
index 0000000000..5ad0db2797
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/s390/xstatver.h
@@ -0,0 +1,16 @@
+/* Versions of the 'struct stat' data structure used in compatibility xstat
+   functions.  */
+
+#include <bits/wordsize.h>
+
+#if __WORDSIZE == 64
+# define _STAT_VER_KERNEL	0
+# define _STAT_VER_LINUX	1
+# define _STAT_VER		_STAT_VER_LINUX
+#else
+# define _STAT_VER_LINUX_OLD	1
+# define _STAT_VER_KERNEL	1
+# define _STAT_VER_SVR4		2
+# define _STAT_VER_LINUX	3
+# define _STAT_VER		_STAT_VER_LINUX
+#endif
diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
index 182970a708..e2ae13d4fa 100644
--- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
@@ -2067,6 +2067,14 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 fstat F
+GLIBC_2.33 fstat64 F
+GLIBC_2.33 fstatat F
+GLIBC_2.33 fstatat64 F
+GLIBC_2.33 lstat F
+GLIBC_2.33 lstat64 F
+GLIBC_2.33 stat F
+GLIBC_2.33 stat64 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/sparc/bits/stat.h b/sysdeps/unix/sysv/linux/sparc/bits/stat.h
index 7379f2232d..7af17b5c40 100644
--- a/sysdeps/unix/sysv/linux/sparc/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/sparc/bits/stat.h
@@ -22,13 +22,6 @@
 #ifndef _BITS_STAT_H
 #define _BITS_STAT_H	1
 
-/* Versions of the `struct stat' data structure.  */
-#define _STAT_VER_LINUX_OLD	1
-#define _STAT_VER_KERNEL	1
-#define _STAT_VER_SVR4		2
-#define _STAT_VER_LINUX		3
-#define _STAT_VER		_STAT_VER_LINUX	/* The one defined below.  */
-
 /* Versions of the `xmknod' interface.  */
 #define _MKNOD_VER_LINUX	1
 #define _MKNOD_VER_SVR4		2
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
index a2521c3ee3..886e01960f 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
@@ -2191,6 +2191,14 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 fstat F
+GLIBC_2.33 fstat64 F
+GLIBC_2.33 fstatat F
+GLIBC_2.33 fstatat64 F
+GLIBC_2.33 lstat F
+GLIBC_2.33 lstat64 F
+GLIBC_2.33 stat F
+GLIBC_2.33 stat64 F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
index d8188903f9..33b068201a 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
@@ -2118,6 +2118,14 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 fstat F
+GLIBC_2.33 fstat64 F
+GLIBC_2.33 fstatat F
+GLIBC_2.33 fstatat64 F
+GLIBC_2.33 lstat F
+GLIBC_2.33 lstat64 F
+GLIBC_2.33 stat F
+GLIBC_2.33 stat64 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/sparc/xstatver.h b/sysdeps/unix/sysv/linux/sparc/xstatver.h
new file mode 100644
index 0000000000..ae92b530e7
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sparc/xstatver.h
@@ -0,0 +1,7 @@
+/* Versions of the 'struct stat' data structure used in compatibility xstat
+   functions.  */
+#define _STAT_VER_LINUX_OLD	1
+#define _STAT_VER_KERNEL	1
+#define _STAT_VER_SVR4		2
+#define _STAT_VER_LINUX		3
+#define _STAT_VER		_STAT_VER_LINUX	/* The one defined below.  */
diff --git a/sysdeps/unix/sysv/linux/x86/bits/stat.h b/sysdeps/unix/sysv/linux/x86/bits/stat.h
index 25dec69dda..f132569e9d 100644
--- a/sysdeps/unix/sysv/linux/x86/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/x86/bits/stat.h
@@ -24,25 +24,15 @@
 
 /* Versions of the `struct stat' data structure.  */
 #ifndef __x86_64__
-# define _STAT_VER_LINUX_OLD	1
-# define _STAT_VER_KERNEL	1
-# define _STAT_VER_SVR4		2
-# define _STAT_VER_LINUX	3
-
 /* i386 versions of the `xmknod' interface.  */
 # define _MKNOD_VER_LINUX	1
 # define _MKNOD_VER_SVR4	2
 # define _MKNOD_VER		_MKNOD_VER_LINUX /* The bits defined below.  */
 #else
-# define _STAT_VER_KERNEL	0
-# define _STAT_VER_LINUX	1
-
 /* x86-64 versions of the `xmknod' interface.  */
 # define _MKNOD_VER_LINUX	0
 #endif
 
-#define _STAT_VER		_STAT_VER_LINUX
-
 struct stat
   {
     __dev_t st_dev;		/* Device.  */
diff --git a/sysdeps/unix/sysv/linux/x86/xstatver.h b/sysdeps/unix/sysv/linux/x86/xstatver.h
new file mode 100644
index 0000000000..6f047a346d
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/x86/xstatver.h
@@ -0,0 +1,13 @@
+/* Versions of the 'struct stat' data structure used in compatibility xstat
+   functions.  */
+#ifndef __x86_64__
+# define _STAT_VER_LINUX_OLD	1
+# define _STAT_VER_KERNEL	1
+# define _STAT_VER_SVR4		2
+# define _STAT_VER_LINUX	3
+#else
+# define _STAT_VER_KERNEL	0
+# define _STAT_VER_LINUX	1
+#endif
+#define _STAT_VER		_STAT_VER_LINUX
+
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
index 1a96103c68..f767bdde24 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
@@ -2076,6 +2076,14 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 fstat F
+GLIBC_2.33 fstat64 F
+GLIBC_2.33 fstatat F
+GLIBC_2.33 fstatat64 F
+GLIBC_2.33 lstat F
+GLIBC_2.33 lstat64 F
+GLIBC_2.33 stat F
+GLIBC_2.33 stat64 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
index 35745a75b6..535862a51e 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
@@ -2173,3 +2173,11 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 fstat F
+GLIBC_2.33 fstat64 F
+GLIBC_2.33 fstatat F
+GLIBC_2.33 fstatat64 F
+GLIBC_2.33 lstat F
+GLIBC_2.33 lstat64 F
+GLIBC_2.33 stat F
+GLIBC_2.33 stat64 F
diff --git a/sysdeps/unix/sysv/linux/xstatver.h b/sysdeps/unix/sysv/linux/xstatver.h
new file mode 100644
index 0000000000..59dba71dd1
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/xstatver.h
@@ -0,0 +1,7 @@
+/* Versions of the 'struct stat' data structure used in compatibility xstat
+   functions.  */
+#define _STAT_VER_LINUX_OLD	1
+#define _STAT_VER_KERNEL	1
+#define _STAT_VER_SVR4		2
+#define _STAT_VER_LINUX		3
+#define _STAT_VER		_STAT_VER_LINUX
-- 
2.25.1


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

* [PATCH 10/16] Remove mknod wrapper functions, move them to symbols
  2020-07-23 19:46 [PATCH 00/16] Add y2038 support for stat functions Adhemerval Zanella via Libc-alpha
                   ` (8 preceding siblings ...)
  2020-07-23 19:46 ` [PATCH 09/16] Remove stat wrapper functions, move them to exported symbols Adhemerval Zanella via Libc-alpha
@ 2020-07-23 19:46 ` Adhemerval Zanella via Libc-alpha
  2020-07-23 20:53   ` Joseph Myers
                     ` (2 more replies)
  2020-07-23 19:46 ` [PATCH 11/16] linux: Move the struct stat{64} to struct_stat.h Adhemerval Zanella via Libc-alpha
                   ` (5 subsequent siblings)
  15 siblings, 3 replies; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-07-23 19:46 UTC (permalink / raw)
  To: libc-alpha; +Cc: Alistair Francis

This patch removes the mknod and mknodat static wrapper and add the
symbols on the libc with the expected names.

Both the prototypes of the internal symbol linked by the static
wrappers and the inline redirectors are also removed from the installed
sys/stat.h header file.  The wrapper implementation license is also
change from LGPL to GPL.

Internally the _STAT_VER* definitions are moved to the arch-specific
xstatver.h file.

Checked with a build for all affected Linux ABIs and Hurd.  I checked
also on x86_64-linux-gnu and i686-linux-gnu.
---
 include/sys/stat.h                            | 13 ++++---
 io/Makefile                                   |  5 ---
 io/Versions                                   |  1 +
 io/mknod.c                                    | 35 +++----------------
 io/mknodat.c                                  | 35 +++----------------
 io/sys/stat.h                                 | 30 ----------------
 sysdeps/generic/xstatver.h                    |  1 +
 sysdeps/mach/hurd/i386/libc.abilist           |  2 ++
 sysdeps/posix/mkfifo.c                        |  3 +-
 sysdeps/posix/mkfifoat.c                      |  3 +-
 sysdeps/unix/sysv/linux/aarch64/libc.abilist  |  2 ++
 sysdeps/unix/sysv/linux/alpha/bits/stat.h     |  4 ---
 sysdeps/unix/sysv/linux/alpha/libc.abilist    |  2 ++
 sysdeps/unix/sysv/linux/alpha/xstatver.h      |  5 +++
 sysdeps/unix/sysv/linux/arc/libc.abilist      |  2 ++
 sysdeps/unix/sysv/linux/arm/le/libc.abilist   |  2 ++
 sysdeps/unix/sysv/linux/bits/stat.h           |  7 ----
 sysdeps/unix/sysv/linux/csky/libc.abilist     |  2 ++
 sysdeps/unix/sysv/linux/generic/bits/stat.h   |  3 --
 sysdeps/unix/sysv/linux/generic/xstatver.h    |  5 +++
 sysdeps/unix/sysv/linux/hppa/libc.abilist     |  2 ++
 sysdeps/unix/sysv/linux/i386/libc.abilist     |  2 ++
 sysdeps/unix/sysv/linux/ia64/bits/stat.h      |  3 --
 sysdeps/unix/sysv/linux/ia64/libc.abilist     |  2 ++
 sysdeps/unix/sysv/linux/ia64/xstatver.h       |  5 +++
 sysdeps/unix/sysv/linux/m68k/bits/stat.h      |  6 ----
 .../unix/sysv/linux/m68k/m680x0/libc.abilist  |  2 ++
 sysdeps/unix/sysv/linux/m68k/xstatver.h       |  6 ++++
 .../sysv/linux/microblaze/be/libc.abilist     |  2 ++
 .../unix/sysv/linux/microblaze/bits/stat.h    |  5 ---
 sysdeps/unix/sysv/linux/microblaze/xstatver.h |  6 ++++
 sysdeps/unix/sysv/linux/mips/bits/stat.h      |  5 ---
 .../sysv/linux/mips/mips32/fpu/libc.abilist   |  2 ++
 .../sysv/linux/mips/mips64/n32/libc.abilist   |  2 ++
 .../sysv/linux/mips/mips64/n64/libc.abilist   |  2 ++
 sysdeps/unix/sysv/linux/mips/xstatver.h       |  6 ++++
 sysdeps/unix/sysv/linux/nios2/libc.abilist    |  2 ++
 sysdeps/unix/sysv/linux/powerpc/bits/stat.h   |  5 ---
 .../linux/powerpc/powerpc32/fpu/libc.abilist  |  2 ++
 .../linux/powerpc/powerpc64/be/libc.abilist   |  2 ++
 .../linux/powerpc/powerpc64/le/libc.abilist   |  2 ++
 sysdeps/unix/sysv/linux/powerpc/xstatver.h    |  6 ++++
 .../unix/sysv/linux/riscv/rv64/libc.abilist   |  2 ++
 sysdeps/unix/sysv/linux/s390/bits/stat.h      | 10 ------
 .../unix/sysv/linux/s390/s390-32/libc.abilist |  2 ++
 .../unix/sysv/linux/s390/s390-64/libc.abilist |  2 ++
 sysdeps/unix/sysv/linux/s390/xstatver.h       |  6 +++-
 sysdeps/unix/sysv/linux/sh/le/libc.abilist    |  2 ++
 sysdeps/unix/sysv/linux/sparc/bits/stat.h     |  6 ----
 .../sysv/linux/sparc/sparc32/libc.abilist     |  2 ++
 .../sysv/linux/sparc/sparc64/libc.abilist     |  2 ++
 sysdeps/unix/sysv/linux/sparc/xstatver.h      |  6 ++++
 sysdeps/unix/sysv/linux/x86/bits/stat.h       | 11 ------
 sysdeps/unix/sysv/linux/x86/xstatver.h        |  5 ++-
 .../unix/sysv/linux/x86_64/64/libc.abilist    |  2 ++
 .../unix/sysv/linux/x86_64/x32/libc.abilist   |  2 ++
 sysdeps/unix/sysv/linux/xstatver.h            |  6 ++++
 57 files changed, 133 insertions(+), 172 deletions(-)

diff --git a/include/sys/stat.h b/include/sys/stat.h
index 0be918a7a7..04b825df4a 100644
--- a/include/sys/stat.h
+++ b/include/sys/stat.h
@@ -30,14 +30,17 @@ extern __mode_t __umask (__mode_t __mask);
 extern int __mkdir (const char *__path, __mode_t __mode);
 libc_hidden_proto (__mkdir)
 
+extern int __mknodat (int fd, const char *path, mode_t mode, dev_t dev);
+libc_hidden_proto (__mknodat);
 extern int __mknod (const char *__path,
 		    __mode_t __mode, __dev_t __dev);
+libc_hidden_proto (__mknod);
+
+extern int __xmknod (int __ver, const char *__path, __mode_t __mode,
+		     __dev_t *__dev);
 libc_hidden_proto (__xmknod)
-extern __inline__ int __mknod (const char *__path, __mode_t __mode,
-			       __dev_t __dev)
-{
-  return __xmknod (_MKNOD_VER, __path, __mode, &__dev);
-}
+extern int __xmknodat (int __ver, int __fd, const char *__path,
+		       __mode_t __mode, __dev_t *__dev);
 libc_hidden_proto (__xmknodat)
 
 int __fxstat (int __ver, int __fildes, struct stat *__stat_buf);
diff --git a/io/Makefile b/io/Makefile
index cee356b666..2ed86c530e 100644
--- a/io/Makefile
+++ b/io/Makefile
@@ -57,11 +57,6 @@ routines :=								\
 	sendfile sendfile64 copy_file_range 				\
 	utimensat futimens file_change_detection
 
-# These routines will be omitted from the libc shared object.
-# Instead the static object files will be included in a special archive
-# linked against when the shared library will be used.
-static-only-routines = mknod mknodat
-
 others		:= pwd
 test-srcs	:= ftwtest
 tests		:= test-utime test-stat test-stat2 test-lfs tst-getcwd \
diff --git a/io/Versions b/io/Versions
index f6db0e84ad..49c4d2d40a 100644
--- a/io/Versions
+++ b/io/Versions
@@ -134,6 +134,7 @@ libc {
   }
   GLIBC_2.33 {
     stat; stat64; fstat; fstat64; lstat; lstat64; fstatat; fstatat64;
+    mknod; mknodat;
   }
   GLIBC_PRIVATE {
     __libc_fcntl64;
diff --git a/io/mknod.c b/io/mknod.c
index ac96829230..7f88633198 100644
--- a/io/mknod.c
+++ b/io/mknod.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1995-2020 Free Software Foundation, Inc.
+/* Create a special or ordinary file.
+   Copyright (C) 1995-2020 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
@@ -6,23 +7,6 @@
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.
 
-   In addition to the permissions in the GNU Lesser General Public
-   License, the Free Software Foundation gives you unlimited
-   permission to link the compiled version of this file with other
-   programs, and to distribute those programs without any restriction
-   coming from the use of this file. (The GNU Lesser General Public
-   License restrictions do apply in other respects; for example, they
-   cover modification of the file, and distribution when not linked
-   into another program.)
-
-   Note that people who make modified versions of this file are not
-   obligated to grant this special exception for their modified
-   versions; it is their choice whether to do so. The GNU Lesser
-   General Public License gives permission to release a modified
-   version without this exception; this exception also makes it
-   possible to release a modified version which carries forward this
-   exception.
-
    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
@@ -32,24 +16,13 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-
 #include <sys/types.h>
 #include <sys/stat.h>
 
-/* This definition is only used if inlining fails for this function; see
-   the last page of <sys/stat.h>.  The real work is done by the `x'
-   function which is passed a version number argument.  We arrange in the
-   makefile that when not inlined this function is always statically
-   linked; that way a dynamically-linked executable always encodes the
-   version number corresponding to the data structures it uses, so the `x'
-   functions in the shared library can adapt without needing to recompile
-   all callers.  */
-
 int
-attribute_hidden
 __mknod (const char *path, mode_t mode, dev_t dev)
 {
   return __xmknod (_MKNOD_VER, path, mode, &dev);
 }
-
-weak_hidden_alias (__mknod, mknod)
+libc_hidden_def (__mknod)
+weak_alias (__mknod, mknod)
diff --git a/io/mknodat.c b/io/mknodat.c
index 65c9f1aa9c..6ec1c1648c 100644
--- a/io/mknodat.c
+++ b/io/mknodat.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1995-2020 Free Software Foundation, Inc.
+/* Create a special or ordinary file.
+   Copyright (C) 1995-2020 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
@@ -6,23 +7,6 @@
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.
 
-   In addition to the permissions in the GNU Lesser General Public
-   License, the Free Software Foundation gives you unlimited
-   permission to link the compiled version of this file with other
-   programs, and to distribute those programs without any restriction
-   coming from the use of this file. (The GNU Lesser General Public
-   License restrictions do apply in other respects; for example, they
-   cover modification of the file, and distribution when not linked
-   into another program.)
-
-   Note that people who make modified versions of this file are not
-   obligated to grant this special exception for their modified
-   versions; it is their choice whether to do so. The GNU Lesser
-   General Public License gives permission to release a modified
-   version without this exception; this exception also makes it
-   possible to release a modified version which carries forward this
-   exception.
-
    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
@@ -32,22 +16,13 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-
 #include <sys/types.h>
 #include <sys/stat.h>
 
-/* This definition is only used if inlining fails for this function; see
-   the last page of <sys/stat.h>.  The real work is done by the `x'
-   function which is passed a version number argument.  We arrange in the
-   makefile that when not inlined this function is always statically
-   linked; that way a dynamically-linked executable always encodes the
-   version number corresponding to the data structures it uses, so the `x'
-   functions in the shared library can adapt without needing to recompile
-   all callers.  */
-
 int
-attribute_hidden
-mknodat (int fd, const char *path, mode_t mode, dev_t dev)
+__mknodat (int fd, const char *path, mode_t mode, dev_t dev)
 {
   return __xmknodat (_MKNOD_VER, fd, path, mode, &dev);
 }
+libc_hidden_def (__mknodat)
+weak_alias (__mknodat, mknodat)
diff --git a/io/sys/stat.h b/io/sys/stat.h
index 83cf253c72..58c3770622 100644
--- a/io/sys/stat.h
+++ b/io/sys/stat.h
@@ -367,41 +367,11 @@ extern int utimensat (int __fd, const char *__path,
 /* Set file access and modification times of the file associated with FD.  */
 extern int futimens (int __fd, const struct timespec __times[2]) __THROW;
 #endif
-\f
-#ifndef _MKNOD_VER
-# define _MKNOD_VER	0
-#endif
-
-extern int __xmknod (int __ver, const char *__path, __mode_t __mode,
-		     __dev_t *__dev) __THROW __nonnull ((2, 4));
-
-extern int __xmknodat (int __ver, int __fd, const char *__path,
-		       __mode_t __mode, __dev_t *__dev)
-     __THROW __nonnull ((3, 5));
 
 #ifdef __USE_GNU
 # include <bits/statx.h>
 #endif
 
-#ifdef __USE_EXTERN_INLINES
-# ifdef __USE_MISC
-__extern_inline int
-__NTH (mknod (const char *__path, __mode_t __mode, __dev_t __dev))
-{
-  return __xmknod (_MKNOD_VER, __path, __mode, &__dev);
-}
-# endif
-
-# ifdef __USE_ATFILE
-__extern_inline int
-__NTH (mknodat (int __fd, const char *__path, __mode_t __mode,
-		__dev_t __dev))
-{
-  return __xmknodat (_MKNOD_VER, __fd, __path, __mode, &__dev);
-}
-# endif
-#endif
-
 __END_DECLS
 
 
diff --git a/sysdeps/generic/xstatver.h b/sysdeps/generic/xstatver.h
index d727c98a16..281013b2f1 100644
--- a/sysdeps/generic/xstatver.h
+++ b/sysdeps/generic/xstatver.h
@@ -1,3 +1,4 @@
 /* Versions of the 'struct stat' data structure used in compatibility xstat
    functions.  */
 #define _STAT_VER 0
+#define _MKNOD_VER 0
diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist
index 74a4ed5c1d..b4e39285d0 100644
--- a/sysdeps/mach/hurd/i386/libc.abilist
+++ b/sysdeps/mach/hurd/i386/libc.abilist
@@ -2198,6 +2198,8 @@ GLIBC_2.33 fstatat F
 GLIBC_2.33 fstatat64 F
 GLIBC_2.33 lstat F
 GLIBC_2.33 lstat64 F
+GLIBC_2.33 mknod F
+GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
 GLIBC_2.4 __confstr_chk F
diff --git a/sysdeps/posix/mkfifo.c b/sysdeps/posix/mkfifo.c
index 61f62e2e96..0b89f6c291 100644
--- a/sysdeps/posix/mkfifo.c
+++ b/sysdeps/posix/mkfifo.c
@@ -24,6 +24,5 @@
 int
 mkfifo (const char *path, mode_t mode)
 {
-  dev_t dev = 0;
-  return __xmknod (_MKNOD_VER, path, mode | S_IFIFO, &dev);
+  return __mknod (path, mode | S_IFIFO, 0);
 }
diff --git a/sysdeps/posix/mkfifoat.c b/sysdeps/posix/mkfifoat.c
index 5287fe8782..d1e0977ba1 100644
--- a/sysdeps/posix/mkfifoat.c
+++ b/sysdeps/posix/mkfifoat.c
@@ -23,6 +23,5 @@
 int
 mkfifoat (int fd, const char *file, mode_t mode)
 {
-  dev_t dev = 0;
-  return __xmknodat (_MKNOD_VER, fd, file, mode | S_IFIFO, &dev);
+  return __mknodat (fd, file, mode | S_IFIFO, 0);
 }
diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
index 03e4ae9296..54b707b9cc 100644
--- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
@@ -2166,5 +2166,7 @@ GLIBC_2.33 fstatat F
 GLIBC_2.33 fstatat64 F
 GLIBC_2.33 lstat F
 GLIBC_2.33 lstat64 F
+GLIBC_2.33 mknod F
+GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
diff --git a/sysdeps/unix/sysv/linux/alpha/bits/stat.h b/sysdeps/unix/sysv/linux/alpha/bits/stat.h
index 1fc27936b9..d20fb5a4b0 100644
--- a/sysdeps/unix/sysv/linux/alpha/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/alpha/bits/stat.h
@@ -22,10 +22,6 @@
 #ifndef _BITS_STAT_H
 #define _BITS_STAT_H	1
 
-/* Versions of the `xmknod' interface.  */
-#define _MKNOD_VER_LINUX	0
-
-
 /* Nanosecond resolution timestamps are stored in a format equivalent to
    'struct timespec'.  This is the type used whenever possible but the
    Unix namespace rules do not allow the identifier 'timespec' to appear
diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist
index 5b752ef4a8..9b429fd28f 100644
--- a/sysdeps/unix/sysv/linux/alpha/libc.abilist
+++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist
@@ -2248,6 +2248,8 @@ GLIBC_2.33 fstatat F
 GLIBC_2.33 fstatat64 F
 GLIBC_2.33 lstat F
 GLIBC_2.33 lstat64 F
+GLIBC_2.33 mknod F
+GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
 GLIBC_2.4 _IO_fprintf F
diff --git a/sysdeps/unix/sysv/linux/alpha/xstatver.h b/sysdeps/unix/sysv/linux/alpha/xstatver.h
index bbb9469617..1cb5d26bb1 100644
--- a/sysdeps/unix/sysv/linux/alpha/xstatver.h
+++ b/sysdeps/unix/sysv/linux/alpha/xstatver.h
@@ -7,3 +7,8 @@
 #define _STAT_VER_GLIBC2_3_4	3
 #define _STAT_VER_LINUX		3
 #define _STAT_VER		_STAT_VER_LINUX
+
+/* Versions of the 'xmknod' interface used in compatibility xmknod
+   functions.  */
+#define _MKNOD_VER_LINUX	0
+#define _MKNOD_VER		_MKNOD_VER_LINUX
diff --git a/sysdeps/unix/sysv/linux/arc/libc.abilist b/sysdeps/unix/sysv/linux/arc/libc.abilist
index 925b532383..7ed5340364 100644
--- a/sysdeps/unix/sysv/linux/arc/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arc/libc.abilist
@@ -1926,5 +1926,7 @@ GLIBC_2.33 fstatat F
 GLIBC_2.33 fstatat64 F
 GLIBC_2.33 lstat F
 GLIBC_2.33 lstat64 F
+GLIBC_2.33 mknod F
+GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
index a4c1a7c03c..3ec1cbdfbc 100644
--- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
@@ -147,6 +147,8 @@ GLIBC_2.33 fstatat F
 GLIBC_2.33 fstatat64 F
 GLIBC_2.33 lstat F
 GLIBC_2.33 lstat64 F
+GLIBC_2.33 mknod F
+GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
 GLIBC_2.4 _Exit F
diff --git a/sysdeps/unix/sysv/linux/bits/stat.h b/sysdeps/unix/sysv/linux/bits/stat.h
index b542623208..0669451f69 100644
--- a/sysdeps/unix/sysv/linux/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/bits/stat.h
@@ -22,13 +22,6 @@
 #ifndef _BITS_STAT_H
 #define _BITS_STAT_H	1
 
-/* Versions of the `struct stat' data structure.  */
-/* Versions of the `xmknod' interface.  */
-#define _MKNOD_VER_LINUX	1
-#define _MKNOD_VER_SVR4		2
-#define _MKNOD_VER		_MKNOD_VER_LINUX /* The bits defined below.  */
-
-
 struct stat
   {
     __dev_t st_dev;			/* Device.  */
diff --git a/sysdeps/unix/sysv/linux/csky/libc.abilist b/sysdeps/unix/sysv/linux/csky/libc.abilist
index 799873e189..301fd728d7 100644
--- a/sysdeps/unix/sysv/linux/csky/libc.abilist
+++ b/sysdeps/unix/sysv/linux/csky/libc.abilist
@@ -2110,5 +2110,7 @@ GLIBC_2.33 fstatat F
 GLIBC_2.33 fstatat64 F
 GLIBC_2.33 lstat F
 GLIBC_2.33 lstat64 F
+GLIBC_2.33 mknod F
+GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
diff --git a/sysdeps/unix/sysv/linux/generic/bits/stat.h b/sysdeps/unix/sysv/linux/generic/bits/stat.h
index 35e14a47c6..1b586d72fa 100644
--- a/sysdeps/unix/sysv/linux/generic/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/generic/bits/stat.h
@@ -26,9 +26,6 @@
 #include <bits/endian.h>
 #include <bits/wordsize.h>
 
-/* Versions of the `xmknod' interface.  */
-#define _MKNOD_VER_LINUX	0
-
 #if defined __USE_FILE_OFFSET64
 # define __field64(type, type64, name) type64 name
 #elif __WORDSIZE == 64 || defined __INO_T_MATCHES_INO64_T
diff --git a/sysdeps/unix/sysv/linux/generic/xstatver.h b/sysdeps/unix/sysv/linux/generic/xstatver.h
index 8675db494c..d8fd35beb6 100644
--- a/sysdeps/unix/sysv/linux/generic/xstatver.h
+++ b/sysdeps/unix/sysv/linux/generic/xstatver.h
@@ -3,3 +3,8 @@
 #define _STAT_VER_KERNEL	0
 #define _STAT_VER_LINUX		0
 #define _STAT_VER		_STAT_VER_KERNEL
+
+/* Versions of the 'xmknod' interface used in compatibility xmknod
+   functions.  */
+#define _MKNOD_VER_LINUX	0
+#define _MKNOD_VER		_MKNOD_VER_LINUX
diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist
index 95c7bf4f06..84834052e1 100644
--- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
+++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
@@ -2069,6 +2069,8 @@ GLIBC_2.33 fstatat F
 GLIBC_2.33 fstatat64 F
 GLIBC_2.33 lstat F
 GLIBC_2.33 lstat64 F
+GLIBC_2.33 mknod F
+GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
 GLIBC_2.4 __confstr_chk F
diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist
index e7cf5cdb98..b82debaba4 100644
--- a/sysdeps/unix/sysv/linux/i386/libc.abilist
+++ b/sysdeps/unix/sysv/linux/i386/libc.abilist
@@ -2235,6 +2235,8 @@ GLIBC_2.33 fstatat F
 GLIBC_2.33 fstatat64 F
 GLIBC_2.33 lstat F
 GLIBC_2.33 lstat64 F
+GLIBC_2.33 mknod F
+GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
 GLIBC_2.4 __confstr_chk F
diff --git a/sysdeps/unix/sysv/linux/ia64/bits/stat.h b/sysdeps/unix/sysv/linux/ia64/bits/stat.h
index 8ec2e4c81f..6937f3227a 100644
--- a/sysdeps/unix/sysv/linux/ia64/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/ia64/bits/stat.h
@@ -22,9 +22,6 @@
 #ifndef _BITS_STAT_H
 #define _BITS_STAT_H	1
 
-/* Versions of the `xmknod' interface.  */
-#define _MKNOD_VER_LINUX	0
-
 struct stat
   {
     __dev_t st_dev;		/* Device.  */
diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist
index beeb905efd..475b7af1a5 100644
--- a/sysdeps/unix/sysv/linux/ia64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist
@@ -2101,6 +2101,8 @@ GLIBC_2.33 fstatat F
 GLIBC_2.33 fstatat64 F
 GLIBC_2.33 lstat F
 GLIBC_2.33 lstat64 F
+GLIBC_2.33 mknod F
+GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
 GLIBC_2.4 __confstr_chk F
diff --git a/sysdeps/unix/sysv/linux/ia64/xstatver.h b/sysdeps/unix/sysv/linux/ia64/xstatver.h
index 4f02f697ad..f24ab4a9ee 100644
--- a/sysdeps/unix/sysv/linux/ia64/xstatver.h
+++ b/sysdeps/unix/sysv/linux/ia64/xstatver.h
@@ -3,3 +3,8 @@
 #define _STAT_VER_KERNEL	0
 #define _STAT_VER_LINUX		1
 #define _STAT_VER		_STAT_VER_LINUX
+
+/* Versions of the 'xmknod' interface used in compatibility xmknod
+   functions.  */
+#define _MKNOD_VER_LINUX	0
+#define _MKNOD_VER		_MKNOD_VER_LINUX
diff --git a/sysdeps/unix/sysv/linux/m68k/bits/stat.h b/sysdeps/unix/sysv/linux/m68k/bits/stat.h
index bf41776e6c..c6f761fcc0 100644
--- a/sysdeps/unix/sysv/linux/m68k/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/m68k/bits/stat.h
@@ -22,12 +22,6 @@
 #ifndef _BITS_STAT_H
 #define _BITS_STAT_H	1
 
-/* Versions of the `xmknod' interface.  */
-#define _MKNOD_VER_LINUX	1
-#define _MKNOD_VER_SVR4		2
-#define _MKNOD_VER		_MKNOD_VER_LINUX /* The bits defined below.  */
-
-
 struct stat
   {
     __dev_t st_dev;			/* Device.  */
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
index ed34e1fc82..29127e1341 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
@@ -2181,6 +2181,8 @@ GLIBC_2.33 fstatat F
 GLIBC_2.33 fstatat64 F
 GLIBC_2.33 lstat F
 GLIBC_2.33 lstat64 F
+GLIBC_2.33 mknod F
+GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
 GLIBC_2.4 __confstr_chk F
diff --git a/sysdeps/unix/sysv/linux/m68k/xstatver.h b/sysdeps/unix/sysv/linux/m68k/xstatver.h
index 59dba71dd1..8e1801b603 100644
--- a/sysdeps/unix/sysv/linux/m68k/xstatver.h
+++ b/sysdeps/unix/sysv/linux/m68k/xstatver.h
@@ -5,3 +5,9 @@
 #define _STAT_VER_SVR4		2
 #define _STAT_VER_LINUX		3
 #define _STAT_VER		_STAT_VER_LINUX
+
+/* Versions of the 'xmknod' interface used in compatibility xmknod
+   functions.  */
+#define _MKNOD_VER_LINUX	1
+#define _MKNOD_VER_SVR4		2
+#define _MKNOD_VER		_MKNOD_VER_LINUX
diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
index e00f5115b2..e5b4cecacd 100644
--- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
@@ -2161,5 +2161,7 @@ GLIBC_2.33 fstatat F
 GLIBC_2.33 fstatat64 F
 GLIBC_2.33 lstat F
 GLIBC_2.33 lstat64 F
+GLIBC_2.33 mknod F
+GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
diff --git a/sysdeps/unix/sysv/linux/microblaze/bits/stat.h b/sysdeps/unix/sysv/linux/microblaze/bits/stat.h
index 51316a8c1b..b3068e5c98 100644
--- a/sysdeps/unix/sysv/linux/microblaze/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/microblaze/bits/stat.h
@@ -23,11 +23,6 @@
 #ifndef _BITS_STAT_H
 #define _BITS_STAT_H	1
 
-/* Versions of the `xmknod' interface.  */
-#define _MKNOD_VER_LINUX       1
-#define _MKNOD_VER_SVR4        2
-#define _MKNOD_VER             _MKNOD_VER_LINUX  /* The bits defined below.  */
-
 #ifndef __USE_FILE_OFFSET64
 struct stat
 {
diff --git a/sysdeps/unix/sysv/linux/microblaze/xstatver.h b/sysdeps/unix/sysv/linux/microblaze/xstatver.h
index bddaa0d5ec..790cc834d2 100644
--- a/sysdeps/unix/sysv/linux/microblaze/xstatver.h
+++ b/sysdeps/unix/sysv/linux/microblaze/xstatver.h
@@ -5,3 +5,9 @@
 #define _STAT_VER_SVR4         2
 #define _STAT_VER_LINUX        3
 #define _STAT_VER              _STAT_VER_LINUX  /* The one defined below.  */
+
+/* Versions of the 'xmknod' interface used in compatibility xmknod
+   functions.  */
+#define _MKNOD_VER_LINUX       1
+#define _MKNOD_VER_SVR4        2
+#define _MKNOD_VER             _MKNOD_VER_LINUX
diff --git a/sysdeps/unix/sysv/linux/mips/bits/stat.h b/sysdeps/unix/sysv/linux/mips/bits/stat.h
index cfeb4ce6a4..f229c58013 100644
--- a/sysdeps/unix/sysv/linux/mips/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/mips/bits/stat.h
@@ -24,11 +24,6 @@
 
 #include <sgidefs.h>
 
-/* Versions of the `xmknod' interface.  */
-#define _MKNOD_VER_LINUX	1
-#define _MKNOD_VER_SVR4		2
-#define _MKNOD_VER		_MKNOD_VER_LINUX /* The bits defined below.  */
-
 
 #if _MIPS_SIM == _ABIO32
 /* Structure describing file characteristics.  */
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
index fe9ba4e982..b9f56007a2 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
@@ -2152,6 +2152,8 @@ GLIBC_2.33 fstatat F
 GLIBC_2.33 fstatat64 F
 GLIBC_2.33 lstat F
 GLIBC_2.33 lstat64 F
+GLIBC_2.33 mknod F
+GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
 GLIBC_2.4 __confstr_chk F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
index e67591e710..c161ef11b5 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
@@ -2158,6 +2158,8 @@ GLIBC_2.33 fstatat F
 GLIBC_2.33 fstatat64 F
 GLIBC_2.33 lstat F
 GLIBC_2.33 lstat64 F
+GLIBC_2.33 mknod F
+GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
 GLIBC_2.4 __confstr_chk F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
index e4eb9e6bbf..d4b1528e7a 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
@@ -2152,6 +2152,8 @@ GLIBC_2.33 fstatat F
 GLIBC_2.33 fstatat64 F
 GLIBC_2.33 lstat F
 GLIBC_2.33 lstat64 F
+GLIBC_2.33 mknod F
+GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
 GLIBC_2.4 __confstr_chk F
diff --git a/sysdeps/unix/sysv/linux/mips/xstatver.h b/sysdeps/unix/sysv/linux/mips/xstatver.h
index 59dba71dd1..8e1801b603 100644
--- a/sysdeps/unix/sysv/linux/mips/xstatver.h
+++ b/sysdeps/unix/sysv/linux/mips/xstatver.h
@@ -5,3 +5,9 @@
 #define _STAT_VER_SVR4		2
 #define _STAT_VER_LINUX		3
 #define _STAT_VER		_STAT_VER_LINUX
+
+/* Versions of the 'xmknod' interface used in compatibility xmknod
+   functions.  */
+#define _MKNOD_VER_LINUX	1
+#define _MKNOD_VER_SVR4		2
+#define _MKNOD_VER		_MKNOD_VER_LINUX
diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist
index 0878998441..68fca4e650 100644
--- a/sysdeps/unix/sysv/linux/nios2/libc.abilist
+++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist
@@ -2199,5 +2199,7 @@ GLIBC_2.33 fstatat F
 GLIBC_2.33 fstatat64 F
 GLIBC_2.33 lstat F
 GLIBC_2.33 lstat64 F
+GLIBC_2.33 mknod F
+GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/stat.h b/sysdeps/unix/sysv/linux/powerpc/bits/stat.h
index 40ea9a96d4..80c9dc23ac 100644
--- a/sysdeps/unix/sysv/linux/powerpc/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/powerpc/bits/stat.h
@@ -24,11 +24,6 @@
 
 #include <bits/wordsize.h>
 
-/* Versions of the `xmknod' interface.  */
-#define _MKNOD_VER_LINUX	1
-#define _MKNOD_VER_SVR4		2
-#define _MKNOD_VER		_MKNOD_VER_LINUX /* The bits defined below.  */
-
 
 #if __WORDSIZE == 32
 
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
index 993c957e8e..bec34b2128 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
@@ -2208,6 +2208,8 @@ GLIBC_2.33 fstatat F
 GLIBC_2.33 fstatat64 F
 GLIBC_2.33 lstat F
 GLIBC_2.33 lstat64 F
+GLIBC_2.33 mknod F
+GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
 GLIBC_2.4 _IO_fprintf F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
index 25a8e828e9..35bd161c79 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
@@ -2071,6 +2071,8 @@ GLIBC_2.33 fstatat F
 GLIBC_2.33 fstatat64 F
 GLIBC_2.33 lstat F
 GLIBC_2.33 lstat64 F
+GLIBC_2.33 mknod F
+GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
 GLIBC_2.4 _IO_fprintf F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
index 46ae28e552..f1c8ad9cc5 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
@@ -2361,5 +2361,7 @@ GLIBC_2.33 fstatat F
 GLIBC_2.33 fstatat64 F
 GLIBC_2.33 lstat F
 GLIBC_2.33 lstat64 F
+GLIBC_2.33 mknod F
+GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
diff --git a/sysdeps/unix/sysv/linux/powerpc/xstatver.h b/sysdeps/unix/sysv/linux/powerpc/xstatver.h
index 1656e2f7e4..aa61dfd678 100644
--- a/sysdeps/unix/sysv/linux/powerpc/xstatver.h
+++ b/sysdeps/unix/sysv/linux/powerpc/xstatver.h
@@ -9,3 +9,9 @@
 #else
 # define _STAT_VER		_STAT_VER_KERNEL
 #endif
+
+/* Versions of the 'xmknod' interface used in compatibility xmknod
+   functions.  */
+#define _MKNOD_VER_LINUX	1
+#define _MKNOD_VER_SVR4		2
+#define _MKNOD_VER		_MKNOD_VER_LINUX
diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
index 1044aa6be2..fdfc373871 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
@@ -2128,5 +2128,7 @@ GLIBC_2.33 fstatat F
 GLIBC_2.33 fstatat64 F
 GLIBC_2.33 lstat F
 GLIBC_2.33 lstat64 F
+GLIBC_2.33 mknod F
+GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
diff --git a/sysdeps/unix/sysv/linux/s390/bits/stat.h b/sysdeps/unix/sysv/linux/s390/bits/stat.h
index d12055529a..75fa871a1d 100644
--- a/sysdeps/unix/sysv/linux/s390/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/s390/bits/stat.h
@@ -24,16 +24,6 @@
 
 #include <bits/wordsize.h>
 
-#if __WORDSIZE == 64
-/* Versions of the `xmknod' interface.	*/
-#define _MKNOD_VER_LINUX	0
-#else
-/* Versions of the `xmknod' interface.  */
-# define _MKNOD_VER_LINUX	1
-# define _MKNOD_VER_SVR4	2
-# define _MKNOD_VER		_MKNOD_VER_LINUX
-#endif
-
 #if __WORDSIZE == 64
 struct stat
   {
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
index 6b1fa7e67f..47591dc5b5 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
@@ -2206,6 +2206,8 @@ GLIBC_2.33 fstatat F
 GLIBC_2.33 fstatat64 F
 GLIBC_2.33 lstat F
 GLIBC_2.33 lstat64 F
+GLIBC_2.33 mknod F
+GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
 GLIBC_2.4 _IO_fprintf F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
index 0aec094e7b..bd96aeaff7 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
@@ -2107,6 +2107,8 @@ GLIBC_2.33 fstatat F
 GLIBC_2.33 fstatat64 F
 GLIBC_2.33 lstat F
 GLIBC_2.33 lstat64 F
+GLIBC_2.33 mknod F
+GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
 GLIBC_2.4 _IO_fprintf F
diff --git a/sysdeps/unix/sysv/linux/s390/xstatver.h b/sysdeps/unix/sysv/linux/s390/xstatver.h
index 5ad0db2797..aeaf852ee5 100644
--- a/sysdeps/unix/sysv/linux/s390/xstatver.h
+++ b/sysdeps/unix/sysv/linux/s390/xstatver.h
@@ -7,10 +7,14 @@
 # define _STAT_VER_KERNEL	0
 # define _STAT_VER_LINUX	1
 # define _STAT_VER		_STAT_VER_LINUX
+# define _MKNOD_VER_LINUX	0
 #else
 # define _STAT_VER_LINUX_OLD	1
 # define _STAT_VER_KERNEL	1
 # define _STAT_VER_SVR4		2
 # define _STAT_VER_LINUX	3
-# define _STAT_VER		_STAT_VER_LINUX
+# define _MKNOD_VER_LINUX	1
+# define _MKNOD_VER_SVR4	2
 #endif
+#define _STAT_VER		_STAT_VER_LINUX
+#define _MKNOD_VER		_MKNOD_VER_LINUX
diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
index e2ae13d4fa..b4cebb11dd 100644
--- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
@@ -2073,6 +2073,8 @@ GLIBC_2.33 fstatat F
 GLIBC_2.33 fstatat64 F
 GLIBC_2.33 lstat F
 GLIBC_2.33 lstat64 F
+GLIBC_2.33 mknod F
+GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
 GLIBC_2.4 __confstr_chk F
diff --git a/sysdeps/unix/sysv/linux/sparc/bits/stat.h b/sysdeps/unix/sysv/linux/sparc/bits/stat.h
index 7af17b5c40..d10ebb1a9a 100644
--- a/sysdeps/unix/sysv/linux/sparc/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/sparc/bits/stat.h
@@ -22,12 +22,6 @@
 #ifndef _BITS_STAT_H
 #define _BITS_STAT_H	1
 
-/* Versions of the `xmknod' interface.  */
-#define _MKNOD_VER_LINUX	1
-#define _MKNOD_VER_SVR4		2
-#define _MKNOD_VER		_MKNOD_VER_LINUX /* The bits defined below.  */
-
-
 struct stat
   {
     __dev_t st_dev;			/* Device.  */
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
index 886e01960f..f208405859 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
@@ -2197,6 +2197,8 @@ GLIBC_2.33 fstatat F
 GLIBC_2.33 fstatat64 F
 GLIBC_2.33 lstat F
 GLIBC_2.33 lstat64 F
+GLIBC_2.33 mknod F
+GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
 GLIBC_2.4 _IO_fprintf F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
index 33b068201a..44e68aded2 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
@@ -2124,6 +2124,8 @@ GLIBC_2.33 fstatat F
 GLIBC_2.33 fstatat64 F
 GLIBC_2.33 lstat F
 GLIBC_2.33 lstat64 F
+GLIBC_2.33 mknod F
+GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
 GLIBC_2.4 __confstr_chk F
diff --git a/sysdeps/unix/sysv/linux/sparc/xstatver.h b/sysdeps/unix/sysv/linux/sparc/xstatver.h
index ae92b530e7..693b41c3ac 100644
--- a/sysdeps/unix/sysv/linux/sparc/xstatver.h
+++ b/sysdeps/unix/sysv/linux/sparc/xstatver.h
@@ -5,3 +5,9 @@
 #define _STAT_VER_SVR4		2
 #define _STAT_VER_LINUX		3
 #define _STAT_VER		_STAT_VER_LINUX	/* The one defined below.  */
+
+/* Versions of the 'xmknod' interface used in compatibility xmknod
+   functions.  */
+#define _MKNOD_VER_LINUX	1
+#define _MKNOD_VER_SVR4		2
+#define _MKNOD_VER		_MKNOD_VER_LINUX
diff --git a/sysdeps/unix/sysv/linux/x86/bits/stat.h b/sysdeps/unix/sysv/linux/x86/bits/stat.h
index f132569e9d..2c0a3f120b 100644
--- a/sysdeps/unix/sysv/linux/x86/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/x86/bits/stat.h
@@ -22,17 +22,6 @@
 #ifndef _BITS_STAT_H
 #define _BITS_STAT_H	1
 
-/* Versions of the `struct stat' data structure.  */
-#ifndef __x86_64__
-/* i386 versions of the `xmknod' interface.  */
-# define _MKNOD_VER_LINUX	1
-# define _MKNOD_VER_SVR4	2
-# define _MKNOD_VER		_MKNOD_VER_LINUX /* The bits defined below.  */
-#else
-/* x86-64 versions of the `xmknod' interface.  */
-# define _MKNOD_VER_LINUX	0
-#endif
-
 struct stat
   {
     __dev_t st_dev;		/* Device.  */
diff --git a/sysdeps/unix/sysv/linux/x86/xstatver.h b/sysdeps/unix/sysv/linux/x86/xstatver.h
index 6f047a346d..678d5bc022 100644
--- a/sysdeps/unix/sysv/linux/x86/xstatver.h
+++ b/sysdeps/unix/sysv/linux/x86/xstatver.h
@@ -5,9 +5,12 @@
 # define _STAT_VER_KERNEL	1
 # define _STAT_VER_SVR4		2
 # define _STAT_VER_LINUX	3
+# define _MKNOD_VER_LINUX	1
+# define _MKNOD_VER_SVR4	2
 #else
 # define _STAT_VER_KERNEL	0
 # define _STAT_VER_LINUX	1
+# define _MKNOD_VER_LINUX	0
 #endif
 #define _STAT_VER		_STAT_VER_LINUX
-
+#define _MKNOD_VER		_MKNOD_VER_LINUX
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
index f767bdde24..51e76861f6 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
@@ -2082,6 +2082,8 @@ GLIBC_2.33 fstatat F
 GLIBC_2.33 fstatat64 F
 GLIBC_2.33 lstat F
 GLIBC_2.33 lstat64 F
+GLIBC_2.33 mknod F
+GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
 GLIBC_2.4 __confstr_chk F
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
index 535862a51e..f83473c11f 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
@@ -2179,5 +2179,7 @@ GLIBC_2.33 fstatat F
 GLIBC_2.33 fstatat64 F
 GLIBC_2.33 lstat F
 GLIBC_2.33 lstat64 F
+GLIBC_2.33 mknod F
+GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
diff --git a/sysdeps/unix/sysv/linux/xstatver.h b/sysdeps/unix/sysv/linux/xstatver.h
index 59dba71dd1..8e1801b603 100644
--- a/sysdeps/unix/sysv/linux/xstatver.h
+++ b/sysdeps/unix/sysv/linux/xstatver.h
@@ -5,3 +5,9 @@
 #define _STAT_VER_SVR4		2
 #define _STAT_VER_LINUX		3
 #define _STAT_VER		_STAT_VER_LINUX
+
+/* Versions of the 'xmknod' interface used in compatibility xmknod
+   functions.  */
+#define _MKNOD_VER_LINUX	1
+#define _MKNOD_VER_SVR4		2
+#define _MKNOD_VER		_MKNOD_VER_LINUX
-- 
2.25.1


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

* [PATCH 11/16] linux: Move the struct stat{64} to struct_stat.h
  2020-07-23 19:46 [PATCH 00/16] Add y2038 support for stat functions Adhemerval Zanella via Libc-alpha
                   ` (9 preceding siblings ...)
  2020-07-23 19:46 ` [PATCH 10/16] Remove mknod wrapper functions, move them to symbols Adhemerval Zanella via Libc-alpha
@ 2020-07-23 19:46 ` Adhemerval Zanella via Libc-alpha
  2020-07-24  9:27   ` Lukasz Majewski
  2020-07-23 19:46 ` [PATCH 12/16] linux: Implement {l}fstat{at} in terms of fstatat Adhemerval Zanella via Libc-alpha
                   ` (4 subsequent siblings)
  15 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-07-23 19:46 UTC (permalink / raw)
  To: libc-alpha; +Cc: Alistair Francis

The common definitions are moved to a Linux generic stat.h while
the struct stat{64} definition are moved to a arch-specific
struct_stat.h header.

Checked with a build for all affected Linux ABIs.  I checked also
on x86_64-linux-gnu and i686-linux-gnu.
---
 sysdeps/unix/sysv/linux/Makefile              |   3 +-
 .../alpha/bits/{stat.h => struct_stat.h}      |  43 +-----
 sysdeps/unix/sysv/linux/bits/stat.h           | 101 +-------------
 sysdeps/unix/sysv/linux/bits/struct_stat.h    | 131 ++++++++++++++++++
 .../generic/bits/{stat.h => struct_stat.h}    |  45 +-----
 .../linux/ia64/bits/{stat.h => struct_stat.h} |  45 +-----
 .../linux/m68k/bits/{stat.h => struct_stat.h} |  44 +-----
 .../microblaze/bits/{stat.h => struct_stat.h} |  53 ++-----
 .../linux/mips/bits/{stat.h => struct_stat.h} |  45 +-----
 .../powerpc/bits/{stat.h => struct_stat.h}    |  48 +------
 .../linux/s390/bits/{stat.h => struct_stat.h} |  46 +-----
 .../sparc/bits/{stat.h => struct_stat.h}      |  49 ++-----
 .../linux/x86/bits/{stat.h => struct_stat.h}  |  46 +-----
 13 files changed, 206 insertions(+), 493 deletions(-)
 rename sysdeps/unix/sysv/linux/alpha/bits/{stat.h => struct_stat.h} (72%)
 create mode 100644 sysdeps/unix/sysv/linux/bits/struct_stat.h
 rename sysdeps/unix/sysv/linux/generic/bits/{stat.h => struct_stat.h} (77%)
 rename sysdeps/unix/sysv/linux/ia64/bits/{stat.h => struct_stat.h} (75%)
 rename sysdeps/unix/sysv/linux/m68k/bits/{stat.h => struct_stat.h} (77%)
 rename sysdeps/unix/sysv/linux/microblaze/bits/{stat.h => struct_stat.h} (81%)
 rename sysdeps/unix/sysv/linux/mips/bits/{stat.h => struct_stat.h} (85%)
 rename sysdeps/unix/sysv/linux/powerpc/bits/{stat.h => struct_stat.h} (85%)
 rename sysdeps/unix/sysv/linux/s390/bits/{stat.h => struct_stat.h} (85%)
 rename sysdeps/unix/sysv/linux/sparc/bits/{stat.h => struct_stat.h} (77%)
 rename sysdeps/unix/sysv/linux/x86/bits/{stat.h => struct_stat.h} (79%)

diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 3c28adae0d..f189f65daf 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -94,7 +94,8 @@ sysdep_headers += sys/mount.h sys/acct.h \
 		  bits/types/struct_semid_ds.h \
 		  bits/types/struct_msqid_ds.h \
 		  bits/types/struct_shmid_ds.h \
-		  bits/ipc-perm.h
+		  bits/ipc-perm.h \
+		  bits/struct_stat.h
 
 tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
 	 tst-quota tst-sync_file_range tst-sysconf-iov_max tst-ttyname \
diff --git a/sysdeps/unix/sysv/linux/alpha/bits/stat.h b/sysdeps/unix/sysv/linux/alpha/bits/struct_stat.h
similarity index 72%
rename from sysdeps/unix/sysv/linux/alpha/bits/stat.h
rename to sysdeps/unix/sysv/linux/alpha/bits/struct_stat.h
index d20fb5a4b0..1c9b4248b8 100644
--- a/sysdeps/unix/sysv/linux/alpha/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/alpha/bits/struct_stat.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1996-2020 Free Software Foundation, Inc.
+/* Definition for struct stat.
+   Copyright (C) 2020 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
@@ -16,11 +17,11 @@
    <https://www.gnu.org/licenses/>.  */
 
 #if !defined _SYS_STAT_H && !defined _FCNTL_H
-# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
+# error "Never include <bits/struct_stat.h> directly; use <sys/stat.h> instead."
 #endif
 
-#ifndef _BITS_STAT_H
-#define _BITS_STAT_H	1
+#ifndef _BITS_STRUCT_STAT_H
+#define _BITS_STRUCT_STAT_H	1
 
 /* Nanosecond resolution timestamps are stored in a format equivalent to
    'struct timespec'.  This is the type used whenever possible but the
@@ -111,37 +112,5 @@ struct stat64
 #define _STATBUF_ST_RDEV
 #define _STATBUF_ST_NSEC
 
-/* Encoding of the file mode.  */
 
-#define	__S_IFMT	0170000	/* These bits determine file type.  */
-
-/* File types.  */
-#define	__S_IFDIR	0040000	/* Directory.  */
-#define	__S_IFCHR	0020000	/* Character device.  */
-#define	__S_IFBLK	0060000	/* Block device.  */
-#define	__S_IFREG	0100000	/* Regular file.  */
-#define	__S_IFIFO	0010000	/* FIFO.  */
-#define	__S_IFLNK	0120000	/* Symbolic link.  */
-#define	__S_IFSOCK	0140000	/* Socket.  */
-
-/* POSIX.1b objects.  Note that these macros always evaluate to zero.  But
-   they do it by enforcing the correct use of the macros.  */
-#define __S_TYPEISMQ(buf)  ((buf)->st_mode - (buf)->st_mode)
-#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
-#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
-
-/* Protection bits.  */
-
-#define	__S_ISUID	04000	/* Set user ID on execution.  */
-#define	__S_ISGID	02000	/* Set group ID on execution.  */
-#define	__S_ISVTX	01000	/* Save swapped text after use (sticky).  */
-#define	__S_IREAD	0400	/* Read by owner.  */
-#define	__S_IWRITE	0200	/* Write by owner.  */
-#define	__S_IEXEC	0100	/* Execute by owner.  */
-
-#ifdef __USE_ATFILE
-# define UTIME_NOW	((1l << 30) - 1l)
-# define UTIME_OMIT	((1l << 30) - 2l)
-#endif
-
-#endif /* bits/stat.h */
+#endif /* _BITS_STRUCT_STAT_H  */
diff --git a/sysdeps/unix/sysv/linux/bits/stat.h b/sysdeps/unix/sysv/linux/bits/stat.h
index 0669451f69..85c4c7769e 100644
--- a/sysdeps/unix/sysv/linux/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/bits/stat.h
@@ -22,106 +22,7 @@
 #ifndef _BITS_STAT_H
 #define _BITS_STAT_H	1
 
-struct stat
-  {
-    __dev_t st_dev;			/* Device.  */
-    unsigned short int __pad1;
-#ifndef __USE_FILE_OFFSET64
-    __ino_t st_ino;			/* File serial number.	*/
-#else
-    __ino_t __st_ino;			/* 32bit file serial number.	*/
-#endif
-    __mode_t st_mode;			/* File mode.  */
-    __nlink_t st_nlink;			/* Link count.  */
-    __uid_t st_uid;			/* User ID of the file's owner.	*/
-    __gid_t st_gid;			/* Group ID of the file's group.*/
-    __dev_t st_rdev;			/* Device number, if device.  */
-    unsigned short int __pad2;
-#ifndef __USE_FILE_OFFSET64
-    __off_t st_size;			/* Size of file, in bytes.  */
-#else
-    __off64_t st_size;			/* Size of file, in bytes.  */
-#endif
-    __blksize_t st_blksize;		/* Optimal block size for I/O.  */
-
-#ifndef __USE_FILE_OFFSET64
-    __blkcnt_t st_blocks;		/* Number 512-byte blocks allocated. */
-#else
-    __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
-#endif
-#ifdef __USE_XOPEN2K8
-    /* Nanosecond resolution timestamps are stored in a format
-       equivalent to 'struct timespec'.  This is the type used
-       whenever possible but the Unix namespace rules do not allow the
-       identifier 'timespec' to appear in the <sys/stat.h> header.
-       Therefore we have to handle the use of this header in strictly
-       standard-compliant sources special.  */
-    struct timespec st_atim;		/* Time of last access.  */
-    struct timespec st_mtim;		/* Time of last modification.  */
-    struct timespec st_ctim;		/* Time of last status change.  */
-# define st_atime st_atim.tv_sec	/* Backward compatibility.  */
-# define st_mtime st_mtim.tv_sec
-# define st_ctime st_ctim.tv_sec
-#else
-    __time_t st_atime;			/* Time of last access.  */
-    unsigned long int st_atimensec;	/* Nscecs of last access.  */
-    __time_t st_mtime;			/* Time of last modification.  */
-    unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
-    __time_t st_ctime;			/* Time of last status change.  */
-    unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
-#endif
-#ifndef __USE_FILE_OFFSET64
-    unsigned long int __glibc_reserved4;
-    unsigned long int __glibc_reserved5;
-#else
-    __ino64_t st_ino;			/* File serial number.	*/
-#endif
-  };
-
-#ifdef __USE_LARGEFILE64
-struct stat64
-  {
-    __dev_t st_dev;			/* Device.  */
-    unsigned int __pad1;
-
-    __ino_t __st_ino;			/* 32bit file serial number.	*/
-    __mode_t st_mode;			/* File mode.  */
-    __nlink_t st_nlink;			/* Link count.  */
-    __uid_t st_uid;			/* User ID of the file's owner.	*/
-    __gid_t st_gid;			/* Group ID of the file's group.*/
-    __dev_t st_rdev;			/* Device number, if device.  */
-    unsigned int __pad2;
-    __off64_t st_size;			/* Size of file, in bytes.  */
-    __blksize_t st_blksize;		/* Optimal block size for I/O.  */
-
-    __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
-# ifdef __USE_XOPEN2K8
-    /* Nanosecond resolution timestamps are stored in a format
-       equivalent to 'struct timespec'.  This is the type used
-       whenever possible but the Unix namespace rules do not allow the
-       identifier 'timespec' to appear in the <sys/stat.h> header.
-       Therefore we have to handle the use of this header in strictly
-       standard-compliant sources special.  */
-    struct timespec st_atim;		/* Time of last access.  */
-    struct timespec st_mtim;		/* Time of last modification.  */
-    struct timespec st_ctim;		/* Time of last status change.  */
-# else
-    __time_t st_atime;			/* Time of last access.  */
-    unsigned long int st_atimensec;	/* Nscecs of last access.  */
-    __time_t st_mtime;			/* Time of last modification.  */
-    unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
-    __time_t st_ctime;			/* Time of last status change.  */
-    unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
-# endif
-    __ino64_t st_ino;			/* File serial number.		*/
-  };
-#endif
-
-/* Tell code we have these members.  */
-#define	_STATBUF_ST_BLKSIZE
-#define _STATBUF_ST_RDEV
-/* Nanosecond resolution time values are supported.  */
-#define _STATBUF_ST_NSEC
+#include <bits/struct_stat.h>
 
 /* Encoding of the file mode.  */
 
diff --git a/sysdeps/unix/sysv/linux/bits/struct_stat.h b/sysdeps/unix/sysv/linux/bits/struct_stat.h
new file mode 100644
index 0000000000..344bffece6
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/bits/struct_stat.h
@@ -0,0 +1,131 @@
+/* Definition for struct stat.
+   Copyright (C) 2020 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/>.  */
+
+#if !defined _SYS_STAT_H && !defined _FCNTL_H
+# error "Never include <bits/struct_stat.h> directly; use <sys/stat.h> instead."
+#endif
+
+#ifndef _BITS_STRUCT_STAT_H
+#define _BITS_STRUCT_STAT_H	1
+
+#include <bits/endian.h>
+#include <bits/wordsize.h>
+
+struct stat
+  {
+    __dev_t st_dev;			/* Device.  */
+    unsigned short int __pad1;
+#ifndef __USE_FILE_OFFSET64
+    __ino_t st_ino;			/* File serial number.	*/
+#else
+    __ino_t __st_ino;			/* 32bit file serial number.	*/
+#endif
+    __mode_t st_mode;			/* File mode.  */
+    __nlink_t st_nlink;			/* Link count.  */
+    __uid_t st_uid;			/* User ID of the file's owner.	*/
+    __gid_t st_gid;			/* Group ID of the file's group.*/
+    __dev_t st_rdev;			/* Device number, if device.  */
+    unsigned short int __pad2;
+#ifndef __USE_FILE_OFFSET64
+    __off_t st_size;			/* Size of file, in bytes.  */
+#else
+    __off64_t st_size;			/* Size of file, in bytes.  */
+#endif
+    __blksize_t st_blksize;		/* Optimal block size for I/O.  */
+
+#ifndef __USE_FILE_OFFSET64
+    __blkcnt_t st_blocks;		/* Number 512-byte blocks allocated. */
+#else
+    __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
+#endif
+#ifdef __USE_XOPEN2K8
+    /* Nanosecond resolution timestamps are stored in a format
+       equivalent to 'struct timespec'.  This is the type used
+       whenever possible but the Unix namespace rules do not allow the
+       identifier 'timespec' to appear in the <sys/stat.h> header.
+       Therefore we have to handle the use of this header in strictly
+       standard-compliant sources special.  */
+    struct timespec st_atim;		/* Time of last access.  */
+    struct timespec st_mtim;		/* Time of last modification.  */
+    struct timespec st_ctim;		/* Time of last status change.  */
+# define st_atime st_atim.tv_sec	/* Backward compatibility.  */
+# define st_mtime st_mtim.tv_sec
+# define st_ctime st_ctim.tv_sec
+#else
+    __time_t st_atime;			/* Time of last access.  */
+    unsigned long int st_atimensec;	/* Nscecs of last access.  */
+    __time_t st_mtime;			/* Time of last modification.  */
+    unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
+    __time_t st_ctime;			/* Time of last status change.  */
+    unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
+#endif
+#ifndef __USE_FILE_OFFSET64
+    unsigned long int __glibc_reserved4;
+    unsigned long int __glibc_reserved5;
+#else
+    __ino64_t st_ino;			/* File serial number.	*/
+#endif
+  };
+
+#ifdef __USE_LARGEFILE64
+struct stat64
+  {
+    __dev_t st_dev;			/* Device.  */
+    unsigned int __pad1;
+
+    __ino_t __st_ino;			/* 32bit file serial number.	*/
+    __mode_t st_mode;			/* File mode.  */
+    __nlink_t st_nlink;			/* Link count.  */
+    __uid_t st_uid;			/* User ID of the file's owner.	*/
+    __gid_t st_gid;			/* Group ID of the file's group.*/
+    __dev_t st_rdev;			/* Device number, if device.  */
+    unsigned int __pad2;
+    __off64_t st_size;			/* Size of file, in bytes.  */
+    __blksize_t st_blksize;		/* Optimal block size for I/O.  */
+
+    __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
+# ifdef __USE_XOPEN2K8
+    /* Nanosecond resolution timestamps are stored in a format
+       equivalent to 'struct timespec'.  This is the type used
+       whenever possible but the Unix namespace rules do not allow the
+       identifier 'timespec' to appear in the <sys/stat.h> header.
+       Therefore we have to handle the use of this header in strictly
+       standard-compliant sources special.  */
+    struct timespec st_atim;		/* Time of last access.  */
+    struct timespec st_mtim;		/* Time of last modification.  */
+    struct timespec st_ctim;		/* Time of last status change.  */
+# else
+    __time_t st_atime;			/* Time of last access.  */
+    unsigned long int st_atimensec;	/* Nscecs of last access.  */
+    __time_t st_mtime;			/* Time of last modification.  */
+    unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
+    __time_t st_ctime;			/* Time of last status change.  */
+    unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
+# endif
+    __ino64_t st_ino;			/* File serial number.		*/
+  };
+#endif
+
+/* Tell code we have these members.  */
+#define	_STATBUF_ST_BLKSIZE
+#define _STATBUF_ST_RDEV
+/* Nanosecond resolution time values are supported.  */
+#define _STATBUF_ST_NSEC
+
+
+#endif /* _BITS_STRUCT_STAT_H  */
diff --git a/sysdeps/unix/sysv/linux/generic/bits/stat.h b/sysdeps/unix/sysv/linux/generic/bits/struct_stat.h
similarity index 77%
rename from sysdeps/unix/sysv/linux/generic/bits/stat.h
rename to sysdeps/unix/sysv/linux/generic/bits/struct_stat.h
index 1b586d72fa..5049956030 100644
--- a/sysdeps/unix/sysv/linux/generic/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/generic/bits/struct_stat.h
@@ -1,6 +1,6 @@
-/* Copyright (C) 2011-2020 Free Software Foundation, Inc.
+/* Definition for struct stat.
+   Copyright (C) 2020 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
@@ -17,11 +17,11 @@
    <https://www.gnu.org/licenses/>.  */
 
 #if !defined _SYS_STAT_H && !defined _FCNTL_H
-# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
+# error "Never include <bits/struct_stat.h> directly; use <sys/stat.h> instead."
 #endif
 
-#ifndef _BITS_STAT_H
-#define _BITS_STAT_H	1
+#ifndef _BITS_STRUCT_STAT_H
+#define _BITS_STRUCT_STAT_H	1
 
 #include <bits/endian.h>
 #include <bits/wordsize.h>
@@ -124,37 +124,4 @@ struct stat64
 /* Nanosecond resolution time values are supported.  */
 #define _STATBUF_ST_NSEC
 
-/* Encoding of the file mode.  */
-
-#define	__S_IFMT	0170000	/* These bits determine file type.  */
-
-/* File types.  */
-#define	__S_IFDIR	0040000	/* Directory.  */
-#define	__S_IFCHR	0020000	/* Character device.  */
-#define	__S_IFBLK	0060000	/* Block device.  */
-#define	__S_IFREG	0100000	/* Regular file.  */
-#define	__S_IFIFO	0010000	/* FIFO.  */
-#define	__S_IFLNK	0120000	/* Symbolic link.  */
-#define	__S_IFSOCK	0140000	/* Socket.  */
-
-/* POSIX.1b objects.  Note that these macros always evaluate to zero.  But
-   they do it by enforcing the correct use of the macros.  */
-#define __S_TYPEISMQ(buf)  ((buf)->st_mode - (buf)->st_mode)
-#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
-#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
-
-/* Protection bits.  */
-
-#define	__S_ISUID	04000	/* Set user ID on execution.  */
-#define	__S_ISGID	02000	/* Set group ID on execution.  */
-#define	__S_ISVTX	01000	/* Save swapped text after use (sticky).  */
-#define	__S_IREAD	0400	/* Read by owner.  */
-#define	__S_IWRITE	0200	/* Write by owner.  */
-#define	__S_IEXEC	0100	/* Execute by owner.  */
-
-#ifdef __USE_ATFILE
-# define UTIME_NOW	((1l << 30) - 1l)
-# define UTIME_OMIT	((1l << 30) - 2l)
-#endif
-
-#endif /* bits/stat.h */
+#endif /* _BITS_STRUCT_STAT_H  */
diff --git a/sysdeps/unix/sysv/linux/ia64/bits/stat.h b/sysdeps/unix/sysv/linux/ia64/bits/struct_stat.h
similarity index 75%
rename from sysdeps/unix/sysv/linux/ia64/bits/stat.h
rename to sysdeps/unix/sysv/linux/ia64/bits/struct_stat.h
index 6937f3227a..b2272a55b1 100644
--- a/sysdeps/unix/sysv/linux/ia64/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/ia64/bits/struct_stat.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1999-2020 Free Software Foundation, Inc.
+/* Definition for struct stat.
+   Copyright (C) 2020 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
@@ -12,15 +13,15 @@
    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/>.  */
 
 #if !defined _SYS_STAT_H && !defined _FCNTL_H
-# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
+# error "Never include <bits/struct_stat.h> directly; use <sys/stat.h> instead."
 #endif
 
-#ifndef _BITS_STAT_H
-#define _BITS_STAT_H	1
+#ifndef _BITS_STRUCT_STAT_H
+#define _BITS_STRUCT_STAT_H	1
 
 struct stat
   {
@@ -105,37 +106,5 @@ struct stat64
 /* Nanosecond resolution time values are supported.  */
 #define _STATBUF_ST_NSEC
 
-/* Encoding of the file mode.  */
 
-#define	__S_IFMT	0170000	/* These bits determine file type.  */
-
-/* File types.  */
-#define	__S_IFDIR	0040000	/* Directory.  */
-#define	__S_IFCHR	0020000	/* Character device.  */
-#define	__S_IFBLK	0060000	/* Block device.  */
-#define	__S_IFREG	0100000	/* Regular file.  */
-#define	__S_IFIFO	0010000	/* FIFO.  */
-#define	__S_IFLNK	0120000	/* Symbolic link.  */
-#define	__S_IFSOCK	0140000	/* Socket.  */
-
-/* POSIX.1b objects.  Note that these macros always evaluate to zero.  But
-   they do it by enforcing the correct use of the macros.  */
-#define __S_TYPEISMQ(buf)  ((buf)->st_mode - (buf)->st_mode)
-#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
-#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
-
-/* Protection bits.  */
-
-#define	__S_ISUID	04000	/* Set user ID on execution.  */
-#define	__S_ISGID	02000	/* Set group ID on execution.  */
-#define	__S_ISVTX	01000	/* Save swapped text after use (sticky).  */
-#define	__S_IREAD	0400	/* Read by owner.  */
-#define	__S_IWRITE	0200	/* Write by owner.  */
-#define	__S_IEXEC	0100	/* Execute by owner.  */
-
-#ifdef __USE_ATFILE
-# define UTIME_NOW	((1l << 30) - 1l)
-# define UTIME_OMIT	((1l << 30) - 2l)
-#endif
-
-#endif	/* bits//stat.h */
+#endif /* _BITS_STRUCT_STAT_H  */
diff --git a/sysdeps/unix/sysv/linux/m68k/bits/stat.h b/sysdeps/unix/sysv/linux/m68k/bits/struct_stat.h
similarity index 77%
rename from sysdeps/unix/sysv/linux/m68k/bits/stat.h
rename to sysdeps/unix/sysv/linux/m68k/bits/struct_stat.h
index c6f761fcc0..bf457a0db7 100644
--- a/sysdeps/unix/sysv/linux/m68k/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/m68k/bits/struct_stat.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
+/* Definition for struct stat.
+   Copyright (C) 2020 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
@@ -16,11 +17,11 @@
    <https://www.gnu.org/licenses/>.  */
 
 #if !defined _SYS_STAT_H && !defined _FCNTL_H
-# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
+# error "Never include <bits/struct_stat.h> directly; use <sys/stat.h> instead."
 #endif
 
-#ifndef _BITS_STAT_H
-#define _BITS_STAT_H	1
+#ifndef _BITS_STRUCT_STAT_H
+#define _BITS_STRUCT_STAT_H	1
 
 struct stat
   {
@@ -123,37 +124,4 @@ struct stat64
 /* Nanosecond resolution time values are supported.  */
 #define _STATBUF_ST_NSEC
 
-/* Encoding of the file mode.  */
-
-#define	__S_IFMT	0170000	/* These bits determine file type.  */
-
-/* File types.  */
-#define	__S_IFDIR	0040000	/* Directory.  */
-#define	__S_IFCHR	0020000	/* Character device.  */
-#define	__S_IFBLK	0060000	/* Block device.  */
-#define	__S_IFREG	0100000	/* Regular file.  */
-#define	__S_IFIFO	0010000	/* FIFO.  */
-#define	__S_IFLNK	0120000	/* Symbolic link.  */
-#define	__S_IFSOCK	0140000	/* Socket.  */
-
-/* POSIX.1b objects.  Note that these macros always evaluate to zero.  But
-   they do it by enforcing the correct use of the macros.  */
-#define __S_TYPEISMQ(buf)  ((buf)->st_mode - (buf)->st_mode)
-#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
-#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
-
-/* Protection bits.  */
-
-#define	__S_ISUID	04000	/* Set user ID on execution.  */
-#define	__S_ISGID	02000	/* Set group ID on execution.  */
-#define	__S_ISVTX	01000	/* Save swapped text after use (sticky).  */
-#define	__S_IREAD	0400	/* Read by owner.  */
-#define	__S_IWRITE	0200	/* Write by owner.  */
-#define	__S_IEXEC	0100	/* Execute by owner.  */
-
-#ifdef __USE_ATFILE
-# define UTIME_NOW	((1l << 30) - 1l)
-# define UTIME_OMIT	((1l << 30) - 2l)
-#endif
-
-#endif	/* bits/stat.h */
+#endif /* _BITS_STRUCT_STAT_H  */
diff --git a/sysdeps/unix/sysv/linux/microblaze/bits/stat.h b/sysdeps/unix/sysv/linux/microblaze/bits/struct_stat.h
similarity index 81%
rename from sysdeps/unix/sysv/linux/microblaze/bits/stat.h
rename to sysdeps/unix/sysv/linux/microblaze/bits/struct_stat.h
index b3068e5c98..db81543b23 100644
--- a/sysdeps/unix/sysv/linux/microblaze/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/microblaze/bits/struct_stat.h
@@ -1,11 +1,11 @@
-/* Copyright (C) 1997-2020 Free Software Foundation, Inc.
-
+/* Definition for struct stat.
+   Copyright (C) 2020 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.
+   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
@@ -13,15 +13,15 @@
    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/>.  */
 
 #if !defined _SYS_STAT_H && !defined _FCNTL_H
-# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
+# error "Never include <bits/struct_stat.h> directly; use <sys/stat.h> instead."
 #endif
 
-#ifndef _BITS_STAT_H
-#define _BITS_STAT_H	1
+#ifndef _BITS_STRUCT_STAT_H
+#define _BITS_STRUCT_STAT_H	1
 
 #ifndef __USE_FILE_OFFSET64
 struct stat
@@ -155,37 +155,4 @@ struct stat64
 /* Nanosecond resolution time values are supported.  */
 #define _STATBUF_ST_NSEC
 
-/* Encoding of the file mode.  */
-
-#define __S_IFMT        0170000 /* These bits determine file type.  */
-
-/* File types.  */
-#define __S_IFDIR       0040000 /* Directory.  */
-#define __S_IFCHR       0020000 /* Character device.  */
-#define __S_IFBLK       0060000 /* Block device.  */
-#define __S_IFREG       0100000 /* Regular file.  */
-#define __S_IFIFO       0010000 /* FIFO.  */
-#define __S_IFLNK       0120000 /* Symbolic link.  */
-#define __S_IFSOCK      0140000 /* Socket.  */
-
-/* POSIX.1b objects.  Note that these macros always evaluate to zero.  But
-   they do it by enforcing the correct use of the macros.  */
-#define __S_TYPEISMQ(buf)  ((buf)->st_mode - (buf)->st_mode)
-#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
-#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
-
-/* Protection bits.  */
-
-#define __S_ISUID       04000   /* Set user ID on execution.  */
-#define __S_ISGID       02000   /* Set group ID on execution.  */
-#define __S_ISVTX       01000   /* Save swapped text after use (sticky).  */
-#define __S_IREAD       0400    /* Read by owner.  */
-#define __S_IWRITE      0200    /* Write by owner.  */
-#define __S_IEXEC       0100    /* Execute by owner.  */
-
-#ifdef __USE_ATFILE
-# define UTIME_NOW	((1l << 30) - 1l)
-# define UTIME_OMIT	((1l << 30) - 2l)
-#endif
-
-#endif	/* bits/stat.h.  */
+#endif /* _BITS_STRUCT_STAT_H  */
diff --git a/sysdeps/unix/sysv/linux/mips/bits/stat.h b/sysdeps/unix/sysv/linux/mips/bits/struct_stat.h
similarity index 85%
rename from sysdeps/unix/sysv/linux/mips/bits/stat.h
rename to sysdeps/unix/sysv/linux/mips/bits/struct_stat.h
index f229c58013..5abd71fc23 100644
--- a/sysdeps/unix/sysv/linux/mips/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/mips/bits/struct_stat.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
+/* Definition for struct stat.
+   Copyright (C) 2020 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
@@ -16,15 +17,14 @@
    <https://www.gnu.org/licenses/>.  */
 
 #if !defined _SYS_STAT_H && !defined _FCNTL_H
-# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
+# error "Never include <bits/struct_stat.h> directly; use <sys/stat.h> instead."
 #endif
 
-#ifndef _BITS_STAT_H
-#define _BITS_STAT_H	1
+#ifndef _BITS_STRUCT_STAT_H
+#define _BITS_STRUCT_STAT_H	1
 
 #include <sgidefs.h>
 
-
 #if _MIPS_SIM == _ABIO32
 /* Structure describing file characteristics.  */
 struct stat
@@ -215,37 +215,4 @@ struct stat64
 #define	_STATBUF_ST_BLKSIZE
 #define	_STATBUF_ST_RDEV
 
-/* Encoding of the file mode.  */
-
-#define	__S_IFMT	0170000	/* These bits determine file type.  */
-
-/* File types.  */
-#define	__S_IFDIR	0040000	/* Directory.  */
-#define	__S_IFCHR	0020000	/* Character device.  */
-#define	__S_IFBLK	0060000	/* Block device.  */
-#define	__S_IFREG	0100000	/* Regular file.  */
-#define	__S_IFIFO	0010000	/* FIFO.  */
-#define	__S_IFLNK	0120000	/* Symbolic link.  */
-#define	__S_IFSOCK	0140000	/* Socket.  */
-
-/* POSIX.1b objects.  Note that these macros always evaluate to zero.  But
-   they do it by enforcing the correct use of the macros.  */
-#define __S_TYPEISMQ(buf)  ((buf)->st_mode - (buf)->st_mode)
-#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
-#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
-
-/* Protection bits.  */
-
-#define	__S_ISUID	04000	/* Set user ID on execution.  */
-#define	__S_ISGID	02000	/* Set group ID on execution.  */
-#define	__S_ISVTX	01000	/* Save swapped text after use (sticky).  */
-#define	__S_IREAD	0400	/* Read by owner.  */
-#define	__S_IWRITE	0200	/* Write by owner.  */
-#define	__S_IEXEC	0100	/* Execute by owner.  */
-
-#ifdef __USE_ATFILE
-# define UTIME_NOW	((1l << 30) - 1l)
-# define UTIME_OMIT	((1l << 30) - 2l)
-#endif
-
-#endif	/* bits/stat.h */
+#endif /* _BITS_STRUCT_STAT_H  */
diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/stat.h b/sysdeps/unix/sysv/linux/powerpc/bits/struct_stat.h
similarity index 85%
rename from sysdeps/unix/sysv/linux/powerpc/bits/stat.h
rename to sysdeps/unix/sysv/linux/powerpc/bits/struct_stat.h
index 80c9dc23ac..cb41adc7c0 100644
--- a/sysdeps/unix/sysv/linux/powerpc/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/powerpc/bits/struct_stat.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
+/* Definition for struct stat.
+   Copyright (C) 2020 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
@@ -12,19 +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/>.  */
 
 #if !defined _SYS_STAT_H && !defined _FCNTL_H
-# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
+# error "Never include <bits/struct_stat.h> directly; use <sys/stat.h> instead."
 #endif
 
-#ifndef _BITS_STAT_H
-#define _BITS_STAT_H	1
+#ifndef _BITS_STRUCT_STAT_H
+#define _BITS_STRUCT_STAT_H	1
 
 #include <bits/wordsize.h>
 
-
 #if __WORDSIZE == 32
 
 struct stat
@@ -216,44 +216,10 @@ struct stat64
 # endif /* __USE_LARGEFILE64 */
 #endif
 
-
 /* Tell code we have these members.  */
 #define	_STATBUF_ST_BLKSIZE
 #define _STATBUF_ST_RDEV
 /* Nanosecond resolution time values are supported.  */
 #define _STATBUF_ST_NSEC
 
-/* Encoding of the file mode.  */
-
-#define	__S_IFMT	0170000	/* These bits determine file type.  */
-
-/* File types.  */
-#define	__S_IFDIR	0040000	/* Directory.  */
-#define	__S_IFCHR	0020000	/* Character device.  */
-#define	__S_IFBLK	0060000	/* Block device.  */
-#define	__S_IFREG	0100000	/* Regular file.  */
-#define	__S_IFIFO	0010000	/* FIFO.  */
-#define	__S_IFLNK	0120000	/* Symbolic link.  */
-#define	__S_IFSOCK	0140000	/* Socket.  */
-
-/* POSIX.1b objects.  Note that these macros always evaluate to zero.  But
-   they do it by enforcing the correct use of the macros.  */
-#define __S_TYPEISMQ(buf)  ((buf)->st_mode - (buf)->st_mode)
-#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
-#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
-
-/* Protection bits.  */
-
-#define	__S_ISUID	04000	/* Set user ID on execution.  */
-#define	__S_ISGID	02000	/* Set group ID on execution.  */
-#define	__S_ISVTX	01000	/* Save swapped text after use (sticky).  */
-#define	__S_IREAD	0400	/* Read by owner.  */
-#define	__S_IWRITE	0200	/* Write by owner.  */
-#define	__S_IEXEC	0100	/* Execute by owner.  */
-
-#ifdef __USE_ATFILE
-# define UTIME_NOW	((1l << 30) - 1l)
-# define UTIME_OMIT	((1l << 30) - 2l)
-#endif
-
-#endif	/* bits/stat.h */
+#endif /* _BITS_STRUCT_STAT_H  */
diff --git a/sysdeps/unix/sysv/linux/s390/bits/stat.h b/sysdeps/unix/sysv/linux/s390/bits/struct_stat.h
similarity index 85%
rename from sysdeps/unix/sysv/linux/s390/bits/stat.h
rename to sysdeps/unix/sysv/linux/s390/bits/struct_stat.h
index 75fa871a1d..10e7eb0221 100644
--- a/sysdeps/unix/sysv/linux/s390/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/s390/bits/struct_stat.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000-2020 Free Software Foundation, Inc.
+/* Definition for struct stat.
+   Copyright (C) 2020 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
@@ -12,15 +13,15 @@
    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/>.  */
 
 #if !defined _SYS_STAT_H && !defined _FCNTL_H
-# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
+# error "Never include <bits/struct_stat.h> directly; use <sys/stat.h> instead."
 #endif
 
-#ifndef _BITS_STAT_H
-#define _BITS_STAT_H	1
+#ifndef _BITS_STRUCT_STAT_H
+#define _BITS_STRUCT_STAT_H	1
 
 #include <bits/wordsize.h>
 
@@ -207,37 +208,4 @@ struct stat64
 /* Nanosecond resolution time values are supported.  */
 #define _STATBUF_ST_NSEC
 
-/* Encoding of the file mode.  */
-
-#define	__S_IFMT	0170000	/* These bits determine file type.  */
-
-/* File types.  */
-#define	__S_IFDIR	0040000	/* Directory.  */
-#define	__S_IFCHR	0020000	/* Character device.  */
-#define	__S_IFBLK	0060000	/* Block device.  */
-#define	__S_IFREG	0100000	/* Regular file.  */
-#define	__S_IFIFO	0010000	/* FIFO.  */
-#define	__S_IFLNK	0120000	/* Symbolic link.  */
-#define	__S_IFSOCK	0140000	/* Socket.  */
-
-/* POSIX.1b objects.  Note that these macros always evaluate to zero.  But
-   they do it by enforcing the correct use of the macros.  */
-#define __S_TYPEISMQ(buf)  ((buf)->st_mode - (buf)->st_mode)
-#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
-#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
-
-/* Protection bits.  */
-
-#define	__S_ISUID	04000	/* Set user ID on execution.  */
-#define	__S_ISGID	02000	/* Set group ID on execution.  */
-#define	__S_ISVTX	01000	/* Save swapped text after use (sticky).  */
-#define	__S_IREAD	0400	/* Read by owner.  */
-#define	__S_IWRITE	0200	/* Write by owner.  */
-#define	__S_IEXEC	0100	/* Execute by owner.  */
-
-#ifdef __USE_ATFILE
-# define UTIME_NOW	((1l << 30) - 1l)
-# define UTIME_OMIT	((1l << 30) - 2l)
-#endif
-
-#endif	/* bits/stat.h */
+#endif /* _BITS_STRUCT_STAT_H  */
diff --git a/sysdeps/unix/sysv/linux/sparc/bits/stat.h b/sysdeps/unix/sysv/linux/sparc/bits/struct_stat.h
similarity index 77%
rename from sysdeps/unix/sysv/linux/sparc/bits/stat.h
rename to sysdeps/unix/sysv/linux/sparc/bits/struct_stat.h
index d10ebb1a9a..546811539a 100644
--- a/sysdeps/unix/sysv/linux/sparc/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/sparc/bits/struct_stat.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
+/* Definition for struct stat.
+   Copyright (C) 2020 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
@@ -12,15 +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/>.  */
 
 #if !defined _SYS_STAT_H && !defined _FCNTL_H
-# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
+# error "Never include <bits/struct_stat.h> directly; use <sys/stat.h> instead."
 #endif
 
-#ifndef _BITS_STAT_H
-#define _BITS_STAT_H	1
+#ifndef _BITS_STRUCT_STAT_H
+#define _BITS_STRUCT_STAT_H	1
+
+#include <bits/endian.h>
+#include <bits/wordsize.h>
 
 struct stat
   {
@@ -124,37 +128,4 @@ struct stat64
 /* Nanosecond resolution time values are supported.  */
 #define _STATBUF_ST_NSEC
 
-/* Encoding of the file mode.  */
-
-#define	__S_IFMT	0170000	/* These bits determine file type.  */
-
-/* File types.  */
-#define	__S_IFDIR	0040000	/* Directory.  */
-#define	__S_IFCHR	0020000	/* Character device.  */
-#define	__S_IFBLK	0060000	/* Block device.  */
-#define	__S_IFREG	0100000	/* Regular file.  */
-#define	__S_IFIFO	0010000	/* FIFO.  */
-#define	__S_IFLNK	0120000	/* Symbolic link.  */
-#define	__S_IFSOCK	0140000	/* Socket.  */
-
-/* POSIX.1b objects.  Note that these macros always evaluate to zero.  But
-   they do it by enforcing the correct use of the macros.  */
-#define __S_TYPEISMQ(buf)  ((buf)->st_mode - (buf)->st_mode)
-#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
-#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
-
-/* Protection bits.  */
-
-#define	__S_ISUID	04000	/* Set user ID on execution.  */
-#define	__S_ISGID	02000	/* Set group ID on execution.  */
-#define	__S_ISVTX	01000	/* Save swapped text after use (sticky).  */
-#define	__S_IREAD	0400	/* Read by owner.  */
-#define	__S_IWRITE	0200	/* Write by owner.  */
-#define	__S_IEXEC	0100	/* Execute by owner.  */
-
-#ifdef __USE_ATFILE
-# define UTIME_NOW	((1l << 30) - 1l)
-# define UTIME_OMIT	((1l << 30) - 2l)
-#endif
-
-#endif	/* bits/stat.h */
+#endif /* _BITS_STRUCT_STAT_H  */
diff --git a/sysdeps/unix/sysv/linux/x86/bits/stat.h b/sysdeps/unix/sysv/linux/x86/bits/struct_stat.h
similarity index 79%
rename from sysdeps/unix/sysv/linux/x86/bits/stat.h
rename to sysdeps/unix/sysv/linux/x86/bits/struct_stat.h
index 2c0a3f120b..dae7aa46b3 100644
--- a/sysdeps/unix/sysv/linux/x86/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/x86/bits/struct_stat.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1999-2020 Free Software Foundation, Inc.
+/* Definition for struct stat.
+   Copyright (C) 2020 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
@@ -12,15 +13,15 @@
    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/>.  */
 
 #if !defined _SYS_STAT_H && !defined _FCNTL_H
-# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
+# error "Never include <bits/struct_stat.h> directly; use <sys/stat.h> instead."
 #endif
 
-#ifndef _BITS_STAT_H
-#define _BITS_STAT_H	1
+#ifndef _BITS_STRUCT_STAT_H
+#define _BITS_STRUCT_STAT_H	1
 
 struct stat
   {
@@ -153,37 +154,4 @@ struct stat64
 /* Nanosecond resolution time values are supported.  */
 #define _STATBUF_ST_NSEC
 
-/* Encoding of the file mode.  */
-
-#define	__S_IFMT	0170000	/* These bits determine file type.  */
-
-/* File types.  */
-#define	__S_IFDIR	0040000	/* Directory.  */
-#define	__S_IFCHR	0020000	/* Character device.  */
-#define	__S_IFBLK	0060000	/* Block device.  */
-#define	__S_IFREG	0100000	/* Regular file.  */
-#define	__S_IFIFO	0010000	/* FIFO.  */
-#define	__S_IFLNK	0120000	/* Symbolic link.  */
-#define	__S_IFSOCK	0140000	/* Socket.  */
-
-/* POSIX.1b objects.  Note that these macros always evaluate to zero.  But
-   they do it by enforcing the correct use of the macros.  */
-#define __S_TYPEISMQ(buf)  ((buf)->st_mode - (buf)->st_mode)
-#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
-#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
-
-/* Protection bits.  */
-
-#define	__S_ISUID	04000	/* Set user ID on execution.  */
-#define	__S_ISGID	02000	/* Set group ID on execution.  */
-#define	__S_ISVTX	01000	/* Save swapped text after use (sticky).  */
-#define	__S_IREAD	0400	/* Read by owner.  */
-#define	__S_IWRITE	0200	/* Write by owner.  */
-#define	__S_IEXEC	0100	/* Execute by owner.  */
-
-#ifdef __USE_ATFILE
-# define UTIME_NOW	((1l << 30) - 1l)
-# define UTIME_OMIT	((1l << 30) - 2l)
-#endif
-
-#endif	/* bits/stat.h */
+#endif /* _BITS_STRUCT_STAT_H  */
-- 
2.25.1


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

* [PATCH 12/16] linux: Implement {l}fstat{at} in terms of fstatat
  2020-07-23 19:46 [PATCH 00/16] Add y2038 support for stat functions Adhemerval Zanella via Libc-alpha
                   ` (10 preceding siblings ...)
  2020-07-23 19:46 ` [PATCH 11/16] linux: Move the struct stat{64} to struct_stat.h Adhemerval Zanella via Libc-alpha
@ 2020-07-23 19:46 ` Adhemerval Zanella via Libc-alpha
  2020-07-24  9:29   ` Lukasz Majewski
  2020-07-23 19:46 ` [PATCH 13/16] linux: Disentangle fstatat from fxstatat Adhemerval Zanella via Libc-alpha
                   ` (3 subsequent siblings)
  15 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-07-23 19:46 UTC (permalink / raw)
  To: libc-alpha; +Cc: Alistair Francis

Both fstatat and fstata64 calls the old fxstatat and fxstatat64
repectivelly with _STAT_VER, the one currently exported as default
for all ABIs.

Checked on x86_64-linux-gnu and i686-linux-gnu.
---
 sysdeps/unix/sysv/linux/fstat.c     | 31 +++++++++++++++++++++++
 sysdeps/unix/sysv/linux/fstat64.c   | 38 +++++++++++++++++++++++++++++
 sysdeps/unix/sysv/linux/fstatat.c   | 30 +++++++++++++++++++++++
 sysdeps/unix/sysv/linux/fstatat64.c | 38 +++++++++++++++++++++++++++++
 sysdeps/unix/sysv/linux/lstat.c     | 31 +++++++++++++++++++++++
 sysdeps/unix/sysv/linux/lstat64.c   | 38 +++++++++++++++++++++++++++++
 sysdeps/unix/sysv/linux/stat.c      | 31 +++++++++++++++++++++++
 sysdeps/unix/sysv/linux/stat64.c    | 38 +++++++++++++++++++++++++++++
 8 files changed, 275 insertions(+)
 create mode 100644 sysdeps/unix/sysv/linux/fstat.c
 create mode 100644 sysdeps/unix/sysv/linux/fstat64.c
 create mode 100644 sysdeps/unix/sysv/linux/fstatat.c
 create mode 100644 sysdeps/unix/sysv/linux/fstatat64.c
 create mode 100644 sysdeps/unix/sysv/linux/lstat.c
 create mode 100644 sysdeps/unix/sysv/linux/lstat64.c
 create mode 100644 sysdeps/unix/sysv/linux/stat.c
 create mode 100644 sysdeps/unix/sysv/linux/stat64.c

diff --git a/sysdeps/unix/sysv/linux/fstat.c b/sysdeps/unix/sysv/linux/fstat.c
new file mode 100644
index 0000000000..bdbeded956
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/fstat.c
@@ -0,0 +1,31 @@
+/* Get file status.  Linux version.
+   Copyright (C) 2020 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 <kernel_stat.h>
+#include <fcntl.h>
+
+#if !XSTAT_IS_XSTAT64
+int
+__fstat (int fd, struct stat *buf)
+{
+  return __fstatat (fd, "", buf, AT_EMPTY_PATH);
+}
+
+weak_alias (__fstat, fstat)
+#endif
diff --git a/sysdeps/unix/sysv/linux/fstat64.c b/sysdeps/unix/sysv/linux/fstat64.c
new file mode 100644
index 0000000000..c2ff1ff577
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/fstat64.c
@@ -0,0 +1,38 @@
+/* Get file status.  Linux version.
+   Copyright (C) 2020 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 __fstat __redirect___fstat
+#define fstat   __redirect_fstat
+#include <sys/stat.h>
+#undef __fstat
+#undef fstat
+#include <fcntl.h>
+#include <kernel_stat.h>
+
+int
+__fstat64 (int fd, struct stat64 *buf)
+{
+  return __fstatat64 (fd, "", buf, AT_EMPTY_PATH);
+}
+hidden_def (__fstat64)
+weak_alias (__fstat64, fstat64)
+
+#if XSTAT_IS_XSTAT64
+strong_alias (__fstat64, __fstat)
+weak_alias (__fstat64, fstat)
+#endif
diff --git a/sysdeps/unix/sysv/linux/fstatat.c b/sysdeps/unix/sysv/linux/fstatat.c
new file mode 100644
index 0000000000..457496605c
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/fstatat.c
@@ -0,0 +1,30 @@
+/* Get file status.  Linux version.
+   Copyright (C) 2020 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 <kernel_stat.h>
+
+#if !XSTAT_IS_XSTAT64
+int
+__fstatat (int fd, const char *file, struct stat *buf, int flag)
+{
+  return __fxstatat (_STAT_VER, fd, file, buf, flag);
+}
+
+weak_alias (__fstatat, fstatat)
+#endif
diff --git a/sysdeps/unix/sysv/linux/fstatat64.c b/sysdeps/unix/sysv/linux/fstatat64.c
new file mode 100644
index 0000000000..46487919e6
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/fstatat64.c
@@ -0,0 +1,38 @@
+/* Get file status.  Linux version.
+   Copyright (C) 2020 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 __fstatat __redirect___fstatat
+#define fstatat   __redirect_fstatat
+#include <sys/stat.h>
+#undef __fstatat
+#undef fstatat
+#include <kernel_stat.h>
+
+int
+__fstatat64 (int fd, const char *file, struct stat64 *buf, int flag)
+{
+  return __fxstatat64 (_STAT_VER, fd, file, buf, flag);
+}
+hidden_def (__fstatat64)
+weak_alias (__fstatat64, fstatat64)
+
+#if XSTAT_IS_XSTAT64
+strong_alias (__fstatat64, __fstatat)
+weak_alias (__fstatat64, fstatat)
+strong_alias (__fstatat64, __GI___fstatat);
+#endif
diff --git a/sysdeps/unix/sysv/linux/lstat.c b/sysdeps/unix/sysv/linux/lstat.c
new file mode 100644
index 0000000000..b0bdeee9e9
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/lstat.c
@@ -0,0 +1,31 @@
+/* Get file status.  Linux version.
+   Copyright (C) 2020 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 <fcntl.h>
+#include <kernel_stat.h>
+
+#if !XSTAT_IS_XSTAT64
+int
+__lstat (const char *file, struct stat *buf)
+{
+  return __fstatat (AT_FDCWD, file, buf, AT_SYMLINK_NOFOLLOW);
+}
+
+weak_alias (__lstat, lstat)
+#endif
diff --git a/sysdeps/unix/sysv/linux/lstat64.c b/sysdeps/unix/sysv/linux/lstat64.c
new file mode 100644
index 0000000000..e5f02e9822
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/lstat64.c
@@ -0,0 +1,38 @@
+/* Get file status.
+   Copyright (C) 1996-2020 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 __lstat __redirect___lstat
+#define lstat   __redirect_lstat
+#include <sys/stat.h>
+#undef __lstat
+#undef lstat
+#include <fcntl.h>
+#include <kernel_stat.h>
+
+int
+__lstat64 (const char *file, struct stat64 *buf)
+{
+  return __fstatat64 (AT_FDCWD, file, buf, AT_SYMLINK_NOFOLLOW);
+}
+hidden_def (__lstat64)
+weak_alias (__lstat64, lstat64)
+
+#if XSTAT_IS_XSTAT64
+strong_alias (__lstat64, __lstat)
+weak_alias (__lstat64, lstat)
+#endif
diff --git a/sysdeps/unix/sysv/linux/stat.c b/sysdeps/unix/sysv/linux/stat.c
new file mode 100644
index 0000000000..a77502eb95
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/stat.c
@@ -0,0 +1,31 @@
+/* Get file status.  Linux version.
+   Copyright (C) 2020 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 <fcntl.h>
+#include <kernel_stat.h>
+
+#if !XSTAT_IS_XSTAT64
+int
+__stat (const char *file, struct stat *buf)
+{
+  return __fstatat (AT_FDCWD, file, buf, 0);
+}
+
+weak_alias (__stat, stat)
+#endif
diff --git a/sysdeps/unix/sysv/linux/stat64.c b/sysdeps/unix/sysv/linux/stat64.c
new file mode 100644
index 0000000000..2f40037c2c
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/stat64.c
@@ -0,0 +1,38 @@
+/* Get file status.  Linux version.
+   Copyright (C) 2020 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 __redirect___stat
+#define stat   __redirect_stat
+#include <sys/stat.h>
+#undef __stat
+#undef stat
+#include <fcntl.h>
+#include <kernel_stat.h>
+
+int
+__stat64 (const char *file, struct stat64 *buf)
+{
+  return __fstatat64 (AT_FDCWD, file, buf, 0);
+}
+hidden_def (__stat64)
+weak_alias (__stat64, stat64)
+
+#if XSTAT_IS_XSTAT64
+strong_alias (__stat64, __stat)
+weak_alias (__stat64, stat)
+#endif
-- 
2.25.1


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

* [PATCH 13/16] linux: Disentangle fstatat from fxstatat
  2020-07-23 19:46 [PATCH 00/16] Add y2038 support for stat functions Adhemerval Zanella via Libc-alpha
                   ` (11 preceding siblings ...)
  2020-07-23 19:46 ` [PATCH 12/16] linux: Implement {l}fstat{at} in terms of fstatat Adhemerval Zanella via Libc-alpha
@ 2020-07-23 19:46 ` Adhemerval Zanella via Libc-alpha
  2020-07-24  9:39   ` Lukasz Majewski
  2020-07-24 10:25   ` Florian Weimer via Libc-alpha
  2020-07-23 19:46 ` [PATCH 14/16] linux: Move {f}xstat{at} to compat symbols Adhemerval Zanella via Libc-alpha
                   ` (2 subsequent siblings)
  15 siblings, 2 replies; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-07-23 19:46 UTC (permalink / raw)
  To: libc-alpha; +Cc: Alistair Francis

It implements all the requires syscall for the all Linux kABIS on
fstatat{64} itself instead of calling fxstatat{64}.

On non-LFS implementation, it handles 3 cases:

  1. New kABIs which uses generic pre 64-bit time Linux ABI (csky and
     nios): it issues __NR_fstat64 plus handle the overflow on st_ino,
     st_size, or st_blocks.

  2. Old KABIs with old non-LFS support (arm, i386, hppa, m68k,
     microblaze, mips32, s390, sh, powerpc, and sparc32): it issues
     __NR_fstatat64 and convert the result to struct stat.

  3. 64-bit kABI outliers (mips64 and mips64-n32): it issues
     __NR_newfstatat and convert the result to struct stat.

The generic LFS implementation handles multiple cases:

  1. XSTAT_IS_XSTAT64 being 1:

    1.1. 64-bit kABI (aarch64, ia64, powerpc64*, s390x, riscv64, and
         x86_64): it issues __NR_newfstatat.

    1.2. 64-bit kABI outlier (alpha): it issues __NR_fstatat64.

    1.3. 64-bit kABI outlier where struct stat64 does not match kernel
         one (sparc64): it issues __NR_fstatat64 and convert the result
         to struct stat64.

    1.4. 32-bit kABI with default 64-bit time_t (arc, riscv32): it
         issues __NR_statx and convert the result to struct stat64.

  2. Old ABIs with XSTAT_IS_XSTAT64 being 0:

    2.1. All kABIs with non-LFS support (arm, csky, i386, hppa, m68k,
         microblaze, nios2, sh, powerpc32, and sparc32): it issues
         __NR_fstatat64.

    2.2. 64-bit kABI outliers (mips64 and mips64-n32): it issues
         __NR_newfstatat and convert the result to struct stat64.

It allows to remove all the hidden definitions from the {f,l}xstat{64}
(some are still kept because Hurd requires it).

Checked with a build for all affected ABIs. I also checked on x86_64,
i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and s390x.
---
 include/sys/stat.h                            | 32 ++++++--
 sysdeps/unix/sysv/linux/alpha/fxstat64.c      |  2 -
 sysdeps/unix/sysv/linux/alpha/fxstatat64.c    |  4 -
 sysdeps/unix/sysv/linux/alpha/lxstat64.c      |  3 -
 sysdeps/unix/sysv/linux/alpha/xstat64.c       |  3 -
 sysdeps/unix/sysv/linux/fstatat.c             | 56 ++++++++++++-
 sysdeps/unix/sysv/linux/fstatat64.c           | 45 ++++++++++-
 sysdeps/unix/sysv/linux/fxstat.c              |  1 -
 sysdeps/unix/sysv/linux/fxstat64.c            |  3 -
 sysdeps/unix/sysv/linux/fxstatat.c            |  2 -
 sysdeps/unix/sysv/linux/fxstatat64.c          |  4 +-
 sysdeps/unix/sysv/linux/kstat_cp.h            |  2 +
 sysdeps/unix/sysv/linux/lxstat.c              |  1 -
 sysdeps/unix/sysv/linux/lxstat64.c            |  2 -
 sysdeps/unix/sysv/linux/mips/fxstat.c         |  1 -
 sysdeps/unix/sysv/linux/mips/lxstat.c         |  1 -
 .../unix/sysv/linux/mips/mips64/fxstat64.c    |  2 -
 .../unix/sysv/linux/mips/mips64/fxstatat.c    |  1 -
 .../unix/sysv/linux/mips/mips64/fxstatat64.c  |  1 -
 .../unix/sysv/linux/mips/mips64/kstat_cp.h    | 80 +++++++++++++++++++
 .../unix/sysv/linux/mips/mips64/lxstat64.c    |  2 -
 sysdeps/unix/sysv/linux/mips/mips64/xstat64.c |  2 -
 sysdeps/unix/sysv/linux/mips/xstat.c          |  1 -
 .../unix/sysv/linux/sparc/sparc64/kstat_cp.h  | 46 +++++++++++
 sysdeps/unix/sysv/linux/xstat.c               |  1 -
 sysdeps/unix/sysv/linux/xstat64.c             |  2 -
 26 files changed, 253 insertions(+), 47 deletions(-)
 create mode 100644 sysdeps/unix/sysv/linux/kstat_cp.h
 create mode 100644 sysdeps/unix/sysv/linux/mips/mips64/kstat_cp.h
 create mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/kstat_cp.h

diff --git a/include/sys/stat.h b/include/sys/stat.h
index 04b825df4a..199173b007 100644
--- a/include/sys/stat.h
+++ b/include/sys/stat.h
@@ -3,6 +3,28 @@
 
 #ifndef _ISOMAC
 # include <xstatver.h>
+# include <stdbool.h>
+
+static inline bool
+in_ino_t_range (__ino64_t v)
+{
+  __ino_t s = v;
+  return s == v;
+}
+
+static inline bool
+in_off_t_range (__off64_t v)
+{
+  __off_t s = v;
+  return s == v;
+}
+
+static inline bool
+in_blkcnt_t_range (__blkcnt64_t v)
+{
+  __blkcnt_t s = v;
+  return s == v;
+}
 
 /* Now define the internal interfaces. */
 extern int __stat (const char *__file, struct stat *__buf);
@@ -54,19 +76,19 @@ int __xstat64 (int ver, const char *__filename, struct stat64 *__stat_buf);
 int __lxstat64 (int ver, const char *__filename, struct stat64 *__stat_buf);
 int __fxstatat64 (int ver, int __fildes, const char *__filename,
 		  struct stat64 *__stat_buf, int __flag);
+
+# ifdef NO_RTLD_HIDDEN
+/* These are still required for Hurd.  */
 libc_hidden_proto (__fxstat);
 libc_hidden_proto (__xstat);
 libc_hidden_proto (__lxstat);
 libc_hidden_proto (__fxstatat);
-# if IS_IN (libc) || (IS_IN (rtld) && !defined NO_RTLD_HIDDEN)
+#  if IS_IN (libc)
 hidden_proto (__fxstat64);
 hidden_proto (__xstat64);
 hidden_proto (__lxstat64);
 hidden_proto (__fxstatat64);
-# endif
-
-# ifdef NO_RTLD_HIDDEN
-/* These are still required for Hurd.  */
+#  endif
 #  define stat(fname, buf) __xstat (_STAT_VER, fname, buf)
 #  define lstat(fname, buf)  __lxstat (_STAT_VER, fname, buf)
 #  define __lstat(fname, buf)  __lxstat (_STAT_VER, fname, buf)
diff --git a/sysdeps/unix/sysv/linux/alpha/fxstat64.c b/sysdeps/unix/sysv/linux/alpha/fxstat64.c
index 286a2f0a6c..9d6b8eca32 100644
--- a/sysdeps/unix/sysv/linux/alpha/fxstat64.c
+++ b/sysdeps/unix/sysv/linux/alpha/fxstat64.c
@@ -42,6 +42,4 @@ __fxstat64 (int vers, int fd, struct stat64 *buf)
       }
     }
 }
-hidden_def (__fxstat64)
 strong_alias (__fxstat64, __fxstat);
-hidden_ver (__fxstat64, __fxstat)
diff --git a/sysdeps/unix/sysv/linux/alpha/fxstatat64.c b/sysdeps/unix/sysv/linux/alpha/fxstatat64.c
index f10c1d31e8..997fb87ac6 100644
--- a/sysdeps/unix/sysv/linux/alpha/fxstatat64.c
+++ b/sysdeps/unix/sysv/linux/alpha/fxstatat64.c
@@ -29,8 +29,4 @@ __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag)
 {
   return INLINE_SYSCALL_CALL (fstatat64, fd, file, st, flag);
 }
-libc_hidden_def (__fxstatat64)
-#if IS_IN(libc)
 strong_alias (__fxstatat64, __fxstatat);
-hidden_ver (__fxstatat64, __fxstatat)
-#endif
diff --git a/sysdeps/unix/sysv/linux/alpha/lxstat64.c b/sysdeps/unix/sysv/linux/alpha/lxstat64.c
index 90dc0c7ce7..38f132f15e 100644
--- a/sysdeps/unix/sysv/linux/alpha/lxstat64.c
+++ b/sysdeps/unix/sysv/linux/alpha/lxstat64.c
@@ -44,6 +44,3 @@ __lxstat64 (int vers, const char *name, struct stat64 *buf)
     }
 }
 weak_alias (__lxstat64, __lxstat);
-weak_alias (__lxstat64, __GI___lxstat);
-
-hidden_def (__lxstat64)
diff --git a/sysdeps/unix/sysv/linux/alpha/xstat64.c b/sysdeps/unix/sysv/linux/alpha/xstat64.c
index ac1af53780..c856c95dc5 100644
--- a/sysdeps/unix/sysv/linux/alpha/xstat64.c
+++ b/sysdeps/unix/sysv/linux/alpha/xstat64.c
@@ -44,6 +44,3 @@ __xstat64 (int vers, const char *name, struct stat64 *buf)
     }
 }
 weak_alias (__xstat64, __xstat);
-weak_alias (__xstat64, __GI___xstat);
-
-hidden_def (__xstat64)
diff --git a/sysdeps/unix/sysv/linux/fstatat.c b/sysdeps/unix/sysv/linux/fstatat.c
index 457496605c..03ddb3f493 100644
--- a/sysdeps/unix/sysv/linux/fstatat.c
+++ b/sysdeps/unix/sysv/linux/fstatat.c
@@ -18,12 +18,64 @@
 
 #include <sys/stat.h>
 #include <kernel_stat.h>
+#include <sysdep.h>
 
 #if !XSTAT_IS_XSTAT64
+# include <kstat_cp.h>
+
 int
-__fstatat (int fd, const char *file, struct stat *buf, int flag)
+__fstatat (int fd, const char *file, struct stat *st, int flag)
 {
-  return __fxstatat (_STAT_VER, fd, file, buf, flag);
+# if STAT_IS_KERNEL_STAT
+  /* New kABIs which uses generic pre 64-bit time Linux ABI, e.g.
+     csky, nios2  */
+  int r = INLINE_SYSCALL_CALL (fstatat64, fd, file, st, flag);
+  if (r == 0 && (st->__st_ino_pad != 0
+		 || st->__st_size_pad != 0
+		 || st->__st_blocks_pad != 0))
+    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW);
+  return r;
+# else
+#  ifdef __NR_fstatat64
+  /* Old KABIs with old non-LFS support, e.g. arm, i386, hppa, m68k, mips32,
+     microblaze, s390, sh, powerpc, and sparc.  */
+  struct stat64 st64;
+  int r = INLINE_SYSCALL_CALL (fstatat64, fd, file, &st64, flag);
+  if (r == 0)
+    {
+      if (! in_ino_t_range (st64.st_ino)
+	  || ! in_off_t_range (st64.st_size)
+	  || ! in_blkcnt_t_range (st64.st_blocks))
+	return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW);
+
+      /* Clear internal pad and reserved fields.  */
+      memset (st, 0, sizeof (*st));
+
+      st->st_dev = st64.st_dev,
+      st->st_ino = st64.st_ino;
+      st->st_mode = st64.st_mode;
+      st->st_nlink = st64.st_nlink;
+      st->st_uid = st64.st_uid;
+      st->st_gid = st64.st_gid;
+      st->st_rdev = st64.st_rdev;
+      st->st_size = st64.st_size;
+      st->st_blksize = st64.st_blksize;
+      st->st_blocks  = st64.st_blocks;
+      st->st_atim.tv_sec = st64.st_atim.tv_sec;
+      st->st_atim.tv_nsec = st64.st_atim.tv_nsec;
+      st->st_mtim.tv_sec = st64.st_mtim.tv_sec;
+      st->st_mtim.tv_nsec = st64.st_mtim.tv_nsec;
+      st->st_ctim.tv_sec = st64.st_ctim.tv_sec;
+      st->st_ctim.tv_nsec = st64.st_ctim.tv_nsec;
+    }
+  return r;
+#  else
+  /* 64-bit kabi outlier, e.g. mips64 and mips64-n32.  */
+  struct kernel_stat kst;
+  int r = INTERNAL_SYSCALL_CALL (newfstatat, fd, file, &kst, flag);
+  return r ?: __cp_kstat_stat (&kst, st);
+#  endif /* __nr_fstatat64  */
+# endif /* STAT_IS_KERNEL_STAT  */
 }
 
 weak_alias (__fstatat, fstatat)
diff --git a/sysdeps/unix/sysv/linux/fstatat64.c b/sysdeps/unix/sysv/linux/fstatat64.c
index 46487919e6..82fab107a5 100644
--- a/sysdeps/unix/sysv/linux/fstatat64.c
+++ b/sysdeps/unix/sysv/linux/fstatat64.c
@@ -21,12 +21,53 @@
 #include <sys/stat.h>
 #undef __fstatat
 #undef fstatat
+#include <fcntl.h>
+
 #include <kernel_stat.h>
+#include <sysdep.h>
+
+#include <statx_cp.h>
+#include <kstat_cp.h>
 
 int
-__fstatat64 (int fd, const char *file, struct stat64 *buf, int flag)
+__fstatat64 (int fd, const char *file, struct stat64 *st, int flag)
 {
-  return __fxstatat64 (_STAT_VER, fd, file, buf, flag);
+#if XSTAT_IS_XSTAT64
+# ifdef __NR_newfstatat
+  /* 64-bit kABI, e.g. aarch64, ia64, powerpc64*, s390x, riscv64, and
+     x86_64.  */
+  return INLINE_SYSCALL_CALL (newfstatat, fd, file, st, flag);
+# elif defined __NR_fstatat64
+#  if STAT64_IS_KERNEL_STAT64
+  /* 64-bit kABI outlier, e.g. alpha.  */
+  return INLINE_SYSCALL_CALL (fstatat64, fd, file, st, flag);
+#  else
+  /* 64-bit kABI outlier, e.g. sparc64.  */
+  struct kernel_stat64 kst64;
+  int r = INLINE_SYSCALL_CALL (fstatat64, fd, file, &kst64, flag);
+  return r ?: __cp_stat64_kstat64 (st, &kst64);
+#  endif
+# else
+  /* 32-bit kABI with default 64-bit time_t, e.g. arc, riscv32.  */
+  struct statx tmp;
+  int r = INLINE_SYSCALL_CALL (statx, fd, file, AT_NO_AUTOMOUNT | flag,
+			       STATX_BASIC_STATS, &tmp);
+  if (r == 0)
+    __cp_stat64_statx (st, &tmp);
+  return r;
+# endif
+#else
+# ifdef __NR_fstatat64
+  /* All kABIs with non-LFS support, e.g. arm, csky, i386, hppa, m68k,
+     microblaze, nios2, sh, powerpc32, and sparc32.  */
+  return INLINE_SYSCALL_CALL (fstatat64, fd, file, st, flag);
+# else
+  /* 64-bit kabi outlier, e.g. mips64 and mips64-n32.  */
+  struct kernel_stat kst;
+  int r = INTERNAL_SYSCALL_CALL (newfstatat, fd, file, &kst, flag);
+  return r ?: __cp_kstat_stat64 (&kst, st);
+# endif
+#endif
 }
 hidden_def (__fstatat64)
 weak_alias (__fstatat64, fstatat64)
diff --git a/sysdeps/unix/sysv/linux/fxstat.c b/sysdeps/unix/sysv/linux/fxstat.c
index b46e344d0e..f78497ea92 100644
--- a/sysdeps/unix/sysv/linux/fxstat.c
+++ b/sysdeps/unix/sysv/linux/fxstat.c
@@ -57,5 +57,4 @@ __fxstat (int vers, int fd, struct stat *buf)
       }
     }
 }
-hidden_def (__fxstat)
 #endif /* XSTAT_IS_XSTAT64  */
diff --git a/sysdeps/unix/sysv/linux/fxstat64.c b/sysdeps/unix/sysv/linux/fxstat64.c
index d3834f1ce2..6ae7babccc 100644
--- a/sysdeps/unix/sysv/linux/fxstat64.c
+++ b/sysdeps/unix/sysv/linux/fxstat64.c
@@ -59,13 +59,10 @@ ___fxstat64 (int vers, int fd, struct stat64 *buf)
 versioned_symbol (libc, ___fxstat64, __fxstat64, GLIBC_2_2);
 strong_alias (___fxstat64, __old__fxstat64)
 compat_symbol (libc, __old__fxstat64, __fxstat64, GLIBC_2_1);
-hidden_ver (___fxstat64, __fxstat64)
 #else
 strong_alias (___fxstat64, __fxstat64)
-hidden_def (__fxstat64)
 #endif
 
 #if XSTAT_IS_XSTAT64
 strong_alias (__fxstat64, __fxstat);
-hidden_ver (__fxstat64, __fxstat)
 #endif
diff --git a/sysdeps/unix/sysv/linux/fxstatat.c b/sysdeps/unix/sysv/linux/fxstatat.c
index 0291a2c598..1a60fc10e3 100644
--- a/sysdeps/unix/sysv/linux/fxstatat.c
+++ b/sysdeps/unix/sysv/linux/fxstatat.c
@@ -46,6 +46,4 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
   return r ?: __xstat32_conv (vers, &st64, st);
 #endif
 }
-libc_hidden_def (__fxstatat)
-
 #endif /* XSTAT_IS_XSTAT64  */
diff --git a/sysdeps/unix/sysv/linux/fxstatat64.c b/sysdeps/unix/sysv/linux/fxstatat64.c
index ac33ab4fc9..7fe034809c 100644
--- a/sysdeps/unix/sysv/linux/fxstatat64.c
+++ b/sysdeps/unix/sysv/linux/fxstatat64.c
@@ -61,8 +61,6 @@ __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag)
 #endif
   return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
 }
-libc_hidden_def (__fxstatat64)
-#if XSTAT_IS_XSTAT64 && IS_IN(libc)
+#if XSTAT_IS_XSTAT64
 strong_alias (__fxstatat64, __fxstatat);
-hidden_ver (__fxstatat64, __fxstatat)
 #endif
diff --git a/sysdeps/unix/sysv/linux/kstat_cp.h b/sysdeps/unix/sysv/linux/kstat_cp.h
new file mode 100644
index 0000000000..8fa43ed2e1
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/kstat_cp.h
@@ -0,0 +1,2 @@
+/* Empty, it is overridden by an architecture which might require copy to ro
+   from a kernel_stat stat struct to glibc export stat{64}.  */
diff --git a/sysdeps/unix/sysv/linux/lxstat.c b/sysdeps/unix/sysv/linux/lxstat.c
index dc63d20061..156173a4e1 100644
--- a/sysdeps/unix/sysv/linux/lxstat.c
+++ b/sysdeps/unix/sysv/linux/lxstat.c
@@ -58,5 +58,4 @@ __lxstat (int vers, const char *name, struct stat *buf)
       }
     }
 }
-hidden_def (__lxstat)
 #endif /* XSTAT_IS_XSTAT64  */
diff --git a/sysdeps/unix/sysv/linux/lxstat64.c b/sysdeps/unix/sysv/linux/lxstat64.c
index 375013e9b1..29bd1cdf72 100644
--- a/sysdeps/unix/sysv/linux/lxstat64.c
+++ b/sysdeps/unix/sysv/linux/lxstat64.c
@@ -81,8 +81,6 @@ weak_alias (___lxstat64, __GI___lxstat);
 versioned_symbol (libc, ___lxstat64, __lxstat64, GLIBC_2_2);
 strong_alias (___lxstat64, __old__lxstat64)
 compat_symbol (libc, __old__lxstat64, __lxstat64, GLIBC_2_1);
-hidden_ver (___lxstat64, __lxstat64)
 #else
 strong_alias (___lxstat64, __lxstat64);
-hidden_def (__lxstat64)
 #endif
diff --git a/sysdeps/unix/sysv/linux/mips/fxstat.c b/sysdeps/unix/sysv/linux/mips/fxstat.c
index 16c3cefee2..4585c2362b 100644
--- a/sysdeps/unix/sysv/linux/mips/fxstat.c
+++ b/sysdeps/unix/sysv/linux/mips/fxstat.c
@@ -39,4 +39,3 @@ __fxstat (int vers, int fd, struct stat *buf)
       }
     }
 }
-hidden_def (__fxstat)
diff --git a/sysdeps/unix/sysv/linux/mips/lxstat.c b/sysdeps/unix/sysv/linux/mips/lxstat.c
index eb07549adf..62a3b15b32 100644
--- a/sysdeps/unix/sysv/linux/mips/lxstat.c
+++ b/sysdeps/unix/sysv/linux/mips/lxstat.c
@@ -39,4 +39,3 @@ __lxstat (int vers, const char *name, struct stat *buf)
       }
     }
 }
-hidden_def (__lxstat)
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/fxstat64.c b/sysdeps/unix/sysv/linux/mips/mips64/fxstat64.c
index 3fcdd9f1ee..e6c1cacd4b 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/fxstat64.c
+++ b/sysdeps/unix/sysv/linux/mips/mips64/fxstat64.c
@@ -31,5 +31,3 @@ __fxstat64 (int vers, int fd, struct stat64 *buf)
   return r ?: __xstat64_conv (vers, &kbuf, buf);
 
 }
-
-hidden_def (__fxstat64)
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/fxstatat.c b/sysdeps/unix/sysv/linux/mips/mips64/fxstatat.c
index 58410a1441..e384dbab8b 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/fxstatat.c
+++ b/sysdeps/unix/sysv/linux/mips/mips64/fxstatat.c
@@ -30,4 +30,3 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
   int r = INLINE_SYSCALL_CALL (newfstatat, fd, file, &kst, flag);
   return r ?: __xstat_conv (vers, &kst, st);
 }
-libc_hidden_def (__fxstatat)
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c b/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c
index e5416d8971..cfd172d301 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c
+++ b/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c
@@ -33,4 +33,3 @@ __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag)
     }
   return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
 }
-libc_hidden_def (__fxstatat64)
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/kstat_cp.h b/sysdeps/unix/sysv/linux/mips/mips64/kstat_cp.h
new file mode 100644
index 0000000000..7f226416f9
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/mips/mips64/kstat_cp.h
@@ -0,0 +1,80 @@
+/* Struct stat/stat64 to stat/stat64 conversion for Linux.
+   Copyright (C) 2020 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 <kernel_stat.h>
+
+static inline int
+__cp_kstat_stat (const struct kernel_stat *kst, struct stat *st)
+{
+  st->st_dev = kst->st_dev;
+  memset (&st->st_pad1, 0, sizeof (st->st_pad1));
+  st->st_ino = kst->st_ino;
+  if (st->st_ino != kst->st_ino)
+    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW);
+  st->st_mode = kst->st_mode;
+  st->st_nlink = kst->st_nlink;
+  st->st_uid = kst->st_uid;
+  st->st_gid = kst->st_gid;
+  st->st_rdev = kst->st_rdev;
+  memset (&st->st_pad2, 0, sizeof (st->st_pad2));
+  st->st_size = kst->st_size;
+  if (st->st_size != kst->st_size)
+    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW);
+  st->st_pad3 = 0;
+  st->st_atim.tv_sec = kst->st_atime_sec;
+  st->st_atim.tv_nsec = kst->st_atime_nsec;
+  st->st_mtim.tv_sec = kst->st_mtime_sec;
+  st->st_mtim.tv_nsec = kst->st_mtime_nsec;
+  st->st_ctim.tv_sec = kst->st_ctime_sec;
+  st->st_ctim.tv_nsec = kst->st_ctime_nsec;
+  st->st_blksize = kst->st_blksize;
+  st->st_blocks = kst->st_blocks;
+  if (st->st_blocks != kst->st_blocks)
+    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW);
+  memset (&st->st_pad5, 0, sizeof (st->st_pad5));
+
+  return 0;
+}
+
+static inline int
+__cp_kstat_stat64 (const struct kernel_stat *kst, struct stat64 *st)
+{
+  st->st_dev = kst->st_dev;
+  memset (&st->st_pad1, 0, sizeof (st->st_pad1));
+  st->st_ino = kst->st_ino;
+  st->st_mode = kst->st_mode;
+  st->st_nlink = kst->st_nlink;
+  st->st_uid = kst->st_uid;
+  st->st_gid = kst->st_gid;
+  st->st_rdev = kst->st_rdev;
+  memset (&st->st_pad2, 0, sizeof (st->st_pad2));
+  st->st_pad3 = 0;
+  st->st_size = kst->st_size;
+  st->st_blksize = kst->st_blksize;
+  st->st_blocks = kst->st_blocks;
+  st->st_atim.tv_sec = kst->st_atime_sec;
+  st->st_atim.tv_nsec = kst->st_atime_nsec;
+  st->st_mtim.tv_sec = kst->st_mtime_sec;
+  st->st_mtim.tv_nsec = kst->st_mtime_nsec;
+  st->st_ctim.tv_sec = kst->st_ctime_sec;
+  st->st_ctim.tv_nsec = kst->st_ctime_nsec;
+  memset (&st->st_pad4, 0, sizeof (st->st_pad4));
+
+  return 0;
+}
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/lxstat64.c b/sysdeps/unix/sysv/linux/mips/mips64/lxstat64.c
index 28bac57e58..0f3934f8c8 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/lxstat64.c
+++ b/sysdeps/unix/sysv/linux/mips/mips64/lxstat64.c
@@ -29,5 +29,3 @@ __lxstat64 (int vers, const char *name, struct stat64 *buf)
   int r = INLINE_SYSCALL_CALL (lstat, name, &kbuf);
   return r ?: __xstat64_conv (vers, &kbuf, buf);
 }
-
-hidden_def (__lxstat64)
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/xstat64.c b/sysdeps/unix/sysv/linux/mips/mips64/xstat64.c
index 99b03c7593..64d2952276 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/xstat64.c
+++ b/sysdeps/unix/sysv/linux/mips/mips64/xstat64.c
@@ -30,5 +30,3 @@ __xstat64 (int vers, const char *name, struct stat64 *buf)
   int r = INLINE_SYSCALL_CALL (stat, name, &kbuf);
   return r ?: __xstat64_conv (vers, &kbuf, buf);
 }
-
-hidden_def (__xstat64)
diff --git a/sysdeps/unix/sysv/linux/mips/xstat.c b/sysdeps/unix/sysv/linux/mips/xstat.c
index 835691cf89..d6ff5ccbe0 100644
--- a/sysdeps/unix/sysv/linux/mips/xstat.c
+++ b/sysdeps/unix/sysv/linux/mips/xstat.c
@@ -39,4 +39,3 @@ __xstat (int vers, const char *name, struct stat *buf)
       }
     }
 }
-hidden_def (__xstat)
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/kstat_cp.h b/sysdeps/unix/sysv/linux/sparc/sparc64/kstat_cp.h
new file mode 100644
index 0000000000..0599b6a49e
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/kstat_cp.h
@@ -0,0 +1,46 @@
+/* Struct kernel_stat64 to stat64.  Linux/SPARC version.
+   Copyright (C) 2020 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 <errno.h>
+
+static inline int
+__cp_stat64_kstat64 (struct stat64 *st64, const struct kernel_stat64 *kst64)
+{
+  st64->st_dev = kst64->st_dev;
+  st64->__pad1 = 0;
+  st64->st_ino = kst64->st_ino;
+  st64->st_mode = kst64->st_mode;
+  st64->st_nlink = kst64->st_nlink;
+  st64->st_uid = kst64->st_uid;
+  st64->st_gid = kst64->st_gid;
+  st64->st_rdev = kst64->st_rdev;
+  st64->__pad2 = 0;
+  st64->st_size = kst64->st_size;
+  st64->st_blksize = kst64->st_blksize;
+  st64->st_blocks = kst64->st_blocks;
+  st64->st_atim.tv_sec = kst64->st_atime_sec;
+  st64->st_atim.tv_nsec = kst64->st_atime_nsec;
+  st64->st_mtim.tv_sec = kst64->st_mtime_sec;
+  st64->st_mtim.tv_nsec = kst64->st_mtime_nsec;
+  st64->st_ctim.tv_sec = kst64->st_ctime_sec;
+  st64->st_ctim.tv_nsec = kst64->st_ctime_nsec;
+  st64->__glibc_reserved4 = 0;
+  st64->__glibc_reserved5 = 0;
+
+  return 0;
+}
diff --git a/sysdeps/unix/sysv/linux/xstat.c b/sysdeps/unix/sysv/linux/xstat.c
index 0ae52b1901..a971e8cf6a 100644
--- a/sysdeps/unix/sysv/linux/xstat.c
+++ b/sysdeps/unix/sysv/linux/xstat.c
@@ -57,5 +57,4 @@ __xstat (int vers, const char *name, struct stat *buf)
       }
     }
 }
-hidden_def (__xstat)
 #endif /* XSTAT_IS_XSTAT64  */
diff --git a/sysdeps/unix/sysv/linux/xstat64.c b/sysdeps/unix/sysv/linux/xstat64.c
index 4feb55f429..e3a42966f5 100644
--- a/sysdeps/unix/sysv/linux/xstat64.c
+++ b/sysdeps/unix/sysv/linux/xstat64.c
@@ -78,8 +78,6 @@ weak_alias (___xstat64, __GI___xstat);
 versioned_symbol (libc, ___xstat64, __xstat64, GLIBC_2_2);
 strong_alias (___xstat64, __old__xstat64)
 compat_symbol (libc, __old__xstat64, __xstat64, GLIBC_2_1);
-hidden_ver (___xstat64, __xstat64)
 #else
 strong_alias (___xstat64, __xstat64)
-hidden_def (__xstat64)
 #endif
-- 
2.25.1


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

* [PATCH 14/16] linux: Move {f}xstat{at} to compat symbols
  2020-07-23 19:46 [PATCH 00/16] Add y2038 support for stat functions Adhemerval Zanella via Libc-alpha
                   ` (12 preceding siblings ...)
  2020-07-23 19:46 ` [PATCH 13/16] linux: Disentangle fstatat from fxstatat Adhemerval Zanella via Libc-alpha
@ 2020-07-23 19:46 ` Adhemerval Zanella via Libc-alpha
  2020-07-24  9:40   ` Lukasz Majewski
  2020-10-21  5:21   ` __xstat et al. as compat symbols (was: Re: [PATCH 14/16] linux: Move {f}xstat{at} to compat symbols) Florian Weimer via Libc-alpha
  2020-07-23 19:46 ` [PATCH 15/16] linux: Add {f}stat{at} y2038 support Adhemerval Zanella via Libc-alpha
  2020-07-23 19:46 ` [PATCH 16/16] linux: Move xmknoda{at} to compat symbols Adhemerval Zanella via Libc-alpha
  15 siblings, 2 replies; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-07-23 19:46 UTC (permalink / raw)
  To: libc-alpha; +Cc: Alistair Francis

They are not used internally anymore.

Checked with a build for all affected Linux ABIs.  I checked also
on x86_64-linux-gnu and i686-linux-gnu.
---
 sysdeps/unix/sysv/linux/alpha/fxstat64.c      | 12 ++++++++++-
 sysdeps/unix/sysv/linux/alpha/fxstatat64.c    |  9 +++++++-
 sysdeps/unix/sysv/linux/alpha/lxstat64.c      | 12 ++++++++++-
 sysdeps/unix/sysv/linux/alpha/xstat64.c       | 12 ++++++++++-
 sysdeps/unix/sysv/linux/fxstat.c              |  8 +++++++
 sysdeps/unix/sysv/linux/fxstat64.c            | 14 +++++++++----
 sysdeps/unix/sysv/linux/fxstatat.c            |  8 +++++++
 sysdeps/unix/sysv/linux/fxstatat64.c          | 12 ++++++++++-
 sysdeps/unix/sysv/linux/lxstat.c              |  8 +++++++
 sysdeps/unix/sysv/linux/lxstat64.c            | 21 ++++++++++++-------
 sysdeps/unix/sysv/linux/mips/fxstat.c         |  8 +++++++
 sysdeps/unix/sysv/linux/mips/lxstat.c         |  8 +++++++
 .../unix/sysv/linux/mips/mips64/fxstat64.c    |  8 +++++++
 .../unix/sysv/linux/mips/mips64/fxstatat.c    |  8 +++++++
 .../unix/sysv/linux/mips/mips64/fxstatat64.c  |  8 +++++++
 .../unix/sysv/linux/mips/mips64/lxstat64.c    |  8 +++++++
 sysdeps/unix/sysv/linux/mips/mips64/xstat64.c |  9 +++++++-
 sysdeps/unix/sysv/linux/mips/xstat.c          |  8 +++++++
 sysdeps/unix/sysv/linux/xstat.c               |  9 ++++++++
 sysdeps/unix/sysv/linux/xstat64.c             | 15 ++++++++-----
 20 files changed, 182 insertions(+), 23 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/alpha/fxstat64.c b/sysdeps/unix/sysv/linux/alpha/fxstat64.c
index 9d6b8eca32..bcfb55050c 100644
--- a/sysdeps/unix/sysv/linux/alpha/fxstat64.c
+++ b/sysdeps/unix/sysv/linux/alpha/fxstat64.c
@@ -22,9 +22,11 @@
 #include <kernel_stat.h>
 #include <sysdep.h>
 #include <xstatconv.h>
+#include <shlib-compat.h>
 
 /* Get information about the file NAME in BUF.  */
 int
+attribute_compat_text_section
 __fxstat64 (int vers, int fd, struct stat64 *buf)
 {
   switch (vers)
@@ -42,4 +44,12 @@ __fxstat64 (int vers, int fd, struct stat64 *buf)
       }
     }
 }
-strong_alias (__fxstat64, __fxstat);
+
+#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
+strong_alias (__fxstat64, __fxstat_compat)
+compat_symbol (libc, __fxstat_compat, __fxstat, GLIBC_2_0);
+#endif
+
+#if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_33)
+compat_symbol (libc, __fxstat64, __fxstat64, GLIBC_2_1);
+#endif
diff --git a/sysdeps/unix/sysv/linux/alpha/fxstatat64.c b/sysdeps/unix/sysv/linux/alpha/fxstatat64.c
index 997fb87ac6..fa3074eeca 100644
--- a/sysdeps/unix/sysv/linux/alpha/fxstatat64.c
+++ b/sysdeps/unix/sysv/linux/alpha/fxstatat64.c
@@ -22,11 +22,18 @@
 #include <kernel_stat.h>
 #include <sysdep.h>
 #include <xstatconv.h>
+#include <shlib-compat.h>
 
+#if SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
 /* Get information about the file NAME in BUF.  */
 int
+attribute_compat_text_section
 __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag)
 {
   return INLINE_SYSCALL_CALL (fstatat64, fd, file, st, flag);
 }
-strong_alias (__fxstatat64, __fxstatat);
+strong_alias (__fxstatat64, __fxstatat_compat)
+compat_symbol (libc, __fxstatat_compat, __fxstatat, GLIBC_2_4);
+
+compat_symbol (libc, __fxstatat64, __fxstatat64, GLIBC_2_4);
+#endif
diff --git a/sysdeps/unix/sysv/linux/alpha/lxstat64.c b/sysdeps/unix/sysv/linux/alpha/lxstat64.c
index 38f132f15e..7424b2f621 100644
--- a/sysdeps/unix/sysv/linux/alpha/lxstat64.c
+++ b/sysdeps/unix/sysv/linux/alpha/lxstat64.c
@@ -23,9 +23,11 @@
 #include <kernel_stat.h>
 #include <sysdep.h>
 #include <xstatconv.h>
+#include <shlib-compat.h>
 
 /* Get information about the file NAME in BUF.  */
 int
+attribute_compat_text_section
 __lxstat64 (int vers, const char *name, struct stat64 *buf)
 {
   switch (vers)
@@ -43,4 +45,12 @@ __lxstat64 (int vers, const char *name, struct stat64 *buf)
       }
     }
 }
-weak_alias (__lxstat64, __lxstat);
+
+#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
+strong_alias (__lxstat64, __lxstat_compat)
+compat_symbol (libc, __lxstat_compat, __lxstat, GLIBC_2_0);
+#endif
+
+#if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_33)
+compat_symbol (libc, __lxstat64, __lxstat64, GLIBC_2_1);
+#endif
diff --git a/sysdeps/unix/sysv/linux/alpha/xstat64.c b/sysdeps/unix/sysv/linux/alpha/xstat64.c
index c856c95dc5..59f7ddae7f 100644
--- a/sysdeps/unix/sysv/linux/alpha/xstat64.c
+++ b/sysdeps/unix/sysv/linux/alpha/xstat64.c
@@ -23,9 +23,11 @@
 #include <kernel_stat.h>
 #include <sysdep.h>
 #include <xstatconv.h>
+#include <shlib-compat.h>
 
 /* Get information about the file NAME in BUF.  */
 int
+attribute_compat_text_section
 __xstat64 (int vers, const char *name, struct stat64 *buf)
 {
   switch (vers)
@@ -43,4 +45,12 @@ __xstat64 (int vers, const char *name, struct stat64 *buf)
       }
     }
 }
-weak_alias (__xstat64, __xstat);
+
+#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
+strong_alias (__xstat64, __xstat_compat)
+compat_symbol (libc, __xstat_compat, __xstat, GLIBC_2_0);
+#endif
+
+#if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_33)
+compat_symbol (libc, __xstat64, __xstat64, GLIBC_2_1);
+#endif
diff --git a/sysdeps/unix/sysv/linux/fxstat.c b/sysdeps/unix/sysv/linux/fxstat.c
index f78497ea92..649bb95252 100644
--- a/sysdeps/unix/sysv/linux/fxstat.c
+++ b/sysdeps/unix/sysv/linux/fxstat.c
@@ -24,9 +24,13 @@
 #if !XSTAT_IS_XSTAT64
 # include <xstatconv.h>
 # include <xstatover.h>
+# include <shlib-compat.h>
+
+# if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
 
 /* Get information about the file FD in BUF.  */
 int
+attribute_compat_text_section
 __fxstat (int vers, int fd, struct stat *buf)
 {
   switch (vers)
@@ -57,4 +61,8 @@ __fxstat (int vers, int fd, struct stat *buf)
       }
     }
 }
+
+compat_symbol (libc, __fxstat, __fxstat, GLIBC_2_0);
+# endif /* SHLIB_COMPAT  */
+
 #endif /* XSTAT_IS_XSTAT64  */
diff --git a/sysdeps/unix/sysv/linux/fxstat64.c b/sysdeps/unix/sysv/linux/fxstat64.c
index 6ae7babccc..726dfd0ad6 100644
--- a/sysdeps/unix/sysv/linux/fxstat64.c
+++ b/sysdeps/unix/sysv/linux/fxstat64.c
@@ -24,10 +24,14 @@
 #include <sysdep.h>
 #include <xstatconv.h>
 #include <statx_cp.h>
+#include <shlib-compat.h>
+
+#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
 
 /* Get information about the file FD in BUF.  */
 
 int
+attribute_compat_text_section
 ___fxstat64 (int vers, int fd, struct stat64 *buf)
 {
 #if XSTAT_IS_XSTAT64
@@ -53,16 +57,18 @@ ___fxstat64 (int vers, int fd, struct stat64 *buf)
 #endif /* XSTAT_IS_XSTAT64  */
 }
 
-#include <shlib-compat.h>
-
 #if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2)
-versioned_symbol (libc, ___fxstat64, __fxstat64, GLIBC_2_2);
+compat_symbol (libc, ___fxstat64, __fxstat64, GLIBC_2_2);
 strong_alias (___fxstat64, __old__fxstat64)
 compat_symbol (libc, __old__fxstat64, __fxstat64, GLIBC_2_1);
 #else
 strong_alias (___fxstat64, __fxstat64)
+compat_symbol (libc, ___fxstat64, __fxstat64, GLIBC_2_2);
 #endif
 
 #if XSTAT_IS_XSTAT64
-strong_alias (__fxstat64, __fxstat);
+strong_alias (___fxstat64, __fxstat_compat)
+compat_symbol (libc, __fxstat_compat, __fxstat, GLIBC_2_2);
 #endif
+
+#endif /* SHLIB_COMPAT  */
diff --git a/sysdeps/unix/sysv/linux/fxstatat.c b/sysdeps/unix/sysv/linux/fxstatat.c
index 1a60fc10e3..2083e18eac 100644
--- a/sysdeps/unix/sysv/linux/fxstatat.c
+++ b/sysdeps/unix/sysv/linux/fxstatat.c
@@ -24,9 +24,13 @@
 #if !XSTAT_IS_XSTAT64
 # include <xstatconv.h>
 # include <xstatover.h>
+# include <shlib-compat.h>
+
+# if SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
 
 /* Get information about the file FD in BUF.  */
 int
+attribute_compat_text_section
 __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
 {
 #if STAT_IS_KERNEL_STAT
@@ -46,4 +50,8 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
   return r ?: __xstat32_conv (vers, &st64, st);
 #endif
 }
+
+compat_symbol (libc, __fxstatat, __fxstatat, GLIBC_2_4);
+# endif /* SHLIB_COMPAT  */
+
 #endif /* XSTAT_IS_XSTAT64  */
diff --git a/sysdeps/unix/sysv/linux/fxstatat64.c b/sysdeps/unix/sysv/linux/fxstatat64.c
index 7fe034809c..8a505451d9 100644
--- a/sysdeps/unix/sysv/linux/fxstatat64.c
+++ b/sysdeps/unix/sysv/linux/fxstatat64.c
@@ -24,10 +24,14 @@
 #include <sysdep.h>
 #include <xstatconv.h>
 #include <statx_cp.h>
+#include <shlib-compat.h>
+
+#if SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
 
 /* Get information about the file FD in BUF.  */
 
 int
+attribute_compat_text_section
 __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag)
 {
 #if XSTAT_IS_XSTAT64
@@ -61,6 +65,12 @@ __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag)
 #endif
   return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
 }
+
+compat_symbol (libc, __fxstatat64, __fxstatat64, GLIBC_2_4);
+
 #if XSTAT_IS_XSTAT64
-strong_alias (__fxstatat64, __fxstatat);
+strong_alias (__fxstatat64, __fxstatat_compat)
+compat_symbol (libc, __fxstatat_compat, __fxstatat, GLIBC_2_4);
 #endif
+
+#endif /* SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)  */
diff --git a/sysdeps/unix/sysv/linux/lxstat.c b/sysdeps/unix/sysv/linux/lxstat.c
index 156173a4e1..f307aa4942 100644
--- a/sysdeps/unix/sysv/linux/lxstat.c
+++ b/sysdeps/unix/sysv/linux/lxstat.c
@@ -20,13 +20,17 @@
 #include <fcntl.h>
 #include <kernel_stat.h>
 #include <sysdep.h>
+#include <shlib-compat.h>
 
 #if !XSTAT_IS_XSTAT64
 # include <xstatconv.h>
 # include <xstatover.h>
 
+# if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
+
 /* Get information about the file NAME in BUF.  */
 int
+attribute_compat_text_section
 __lxstat (int vers, const char *name, struct stat *buf)
 {
   switch (vers)
@@ -58,4 +62,8 @@ __lxstat (int vers, const char *name, struct stat *buf)
       }
     }
 }
+
+compat_symbol (libc, __lxstat, __lxstat, GLIBC_2_0);
+# endif /* SHLIB_COMPAT  */
+
 #endif /* XSTAT_IS_XSTAT64  */
diff --git a/sysdeps/unix/sysv/linux/lxstat64.c b/sysdeps/unix/sysv/linux/lxstat64.c
index 29bd1cdf72..660d59aea3 100644
--- a/sysdeps/unix/sysv/linux/lxstat64.c
+++ b/sysdeps/unix/sysv/linux/lxstat64.c
@@ -24,10 +24,14 @@
 #include <sysdep.h>
 #include <xstatconv.h>
 #include <statx_cp.h>
+#include <shlib-compat.h>
+
+#if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_33)
 
 /* Get information about the file NAME in BUF.  */
 
 int
+attribute_compat_text_section
 ___lxstat64 (int vers, const char *name, struct stat64 *buf)
 {
 #if XSTAT_IS_XSTAT64
@@ -70,17 +74,18 @@ ___lxstat64 (int vers, const char *name, struct stat64 *buf)
   return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
 }
 
-#if XSTAT_IS_XSTAT64
-weak_alias (___lxstat64, __lxstat);
-weak_alias (___lxstat64, __GI___lxstat);
-#endif
-
-#include <shlib-compat.h>
-
 #if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2)
-versioned_symbol (libc, ___lxstat64, __lxstat64, GLIBC_2_2);
+compat_symbol (libc, ___lxstat64, __lxstat64, GLIBC_2_2);
 strong_alias (___lxstat64, __old__lxstat64)
 compat_symbol (libc, __old__lxstat64, __lxstat64, GLIBC_2_1);
 #else
 strong_alias (___lxstat64, __lxstat64);
+compat_symbol (libc, ___lxstat64, __lxstat64, GLIBC_2_2);
 #endif
+
+#if XSTAT_IS_XSTAT64
+strong_alias (___lxstat64,__lxstat_compat)
+compat_symbol (libc, __lxstat_compat, __lxstat, GLIBC_2_2);
+#endif
+
+#endif /* SHLIB_COMPAT  */
diff --git a/sysdeps/unix/sysv/linux/mips/fxstat.c b/sysdeps/unix/sysv/linux/mips/fxstat.c
index 4585c2362b..cb9f656628 100644
--- a/sysdeps/unix/sysv/linux/mips/fxstat.c
+++ b/sysdeps/unix/sysv/linux/mips/fxstat.c
@@ -21,9 +21,13 @@
 #include <kernel_stat.h>
 #include <sysdep.h>
 #include <xstatconv.h>
+#include <shlib-compat.h>
+
+#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
 
 /* Get information about the file NAME in BUF.  */
 int
+attribute_compat_text_section
 __fxstat (int vers, int fd, struct stat *buf)
 {
   switch (vers)
@@ -39,3 +43,7 @@ __fxstat (int vers, int fd, struct stat *buf)
       }
     }
 }
+
+compat_symbol (libc, __fxstat, __fxstat, GLIBC_2_0);
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/mips/lxstat.c b/sysdeps/unix/sysv/linux/mips/lxstat.c
index 62a3b15b32..ebd05cca50 100644
--- a/sysdeps/unix/sysv/linux/mips/lxstat.c
+++ b/sysdeps/unix/sysv/linux/mips/lxstat.c
@@ -21,9 +21,13 @@
 #include <kernel_stat.h>
 #include <sysdep.h>
 #include <xstatconv.h>
+#include <shlib-compat.h>
+
+#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
 
 /* Get information about the file NAME in BUF.  */
 int
+attribute_compat_text_section
 __lxstat (int vers, const char *name, struct stat *buf)
 {
   switch (vers)
@@ -39,3 +43,7 @@ __lxstat (int vers, const char *name, struct stat *buf)
       }
     }
 }
+
+compat_symbol (libc, __lxstat, __lxstat, GLIBC_2_0);
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/fxstat64.c b/sysdeps/unix/sysv/linux/mips/mips64/fxstat64.c
index e6c1cacd4b..855c650814 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/fxstat64.c
+++ b/sysdeps/unix/sysv/linux/mips/mips64/fxstat64.c
@@ -20,10 +20,14 @@
 #include <kernel_stat.h>
 #include <sysdep.h>
 #include <xstatconv.h>
+#include <shlib-compat.h>
+
+#if SHLIB_COMPAT(libc, GLIBC_2_2, GLIBC_2_33)
 
 /* Get information about the file FD in BUF.  */
 
 int
+attribute_compat_text_section
 __fxstat64 (int vers, int fd, struct stat64 *buf)
 {
   struct kernel_stat kbuf;
@@ -31,3 +35,7 @@ __fxstat64 (int vers, int fd, struct stat64 *buf)
   return r ?: __xstat64_conv (vers, &kbuf, buf);
 
 }
+
+compat_symbol (libc, __fxstat64, __fxstat64, GLIBC_2_2);
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/fxstatat.c b/sysdeps/unix/sysv/linux/mips/mips64/fxstatat.c
index e384dbab8b..1c1fbb02c2 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/fxstatat.c
+++ b/sysdeps/unix/sysv/linux/mips/mips64/fxstatat.c
@@ -21,12 +21,20 @@
 #include <kernel_stat.h>
 #include <sysdep.h>
 #include <xstatconv.h>
+#include <shlib-compat.h>
+
+#if SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
 
 /* Get information about the file FD in BUF.  */
 int
+attribute_compat_text_section
 __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
 {
   struct kernel_stat kst;
   int r = INLINE_SYSCALL_CALL (newfstatat, fd, file, &kst, flag);
   return r ?: __xstat_conv (vers, &kst, st);
 }
+
+compat_symbol (libc, __fxstatat, __fxstatat, GLIBC_2_4);
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c b/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c
index cfd172d301..f40a2c5aa8 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c
+++ b/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c
@@ -19,10 +19,14 @@
 #include <kernel_stat.h>
 #include <sysdep.h>
 #include <xstatconv.h>
+#include <shlib-compat.h>
+
+#if SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
 
 /* Get information about the file NAME in BUF.  */
 
 int
+attribute_compat_text_section
 __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag)
 {
   if (vers == _STAT_VER_LINUX)
@@ -33,3 +37,7 @@ __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag)
     }
   return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
 }
+
+compat_symbol (libc, __fxstatat64, __fxstatat64, GLIBC_2_4);
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/lxstat64.c b/sysdeps/unix/sysv/linux/mips/mips64/lxstat64.c
index 0f3934f8c8..752c5284a7 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/lxstat64.c
+++ b/sysdeps/unix/sysv/linux/mips/mips64/lxstat64.c
@@ -20,12 +20,20 @@
 #include <kernel_stat.h>
 #include <sysdep.h>
 #include <xstatconv.h>
+#include <shlib-compat.h>
+
+#if SHLIB_COMPAT(libc, GLIBC_2_2, GLIBC_2_33)
 
 /* Get information about the file NAME in BUF.  */
 int
+attribute_compat_text_section
 __lxstat64 (int vers, const char *name, struct stat64 *buf)
 {
   struct kernel_stat kbuf;
   int r = INLINE_SYSCALL_CALL (lstat, name, &kbuf);
   return r ?: __xstat64_conv (vers, &kbuf, buf);
 }
+
+compat_symbol (libc, __lxstat64, __lxstat64, GLIBC_2_2);
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/xstat64.c b/sysdeps/unix/sysv/linux/mips/mips64/xstat64.c
index 64d2952276..a620ba2f1f 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/xstat64.c
+++ b/sysdeps/unix/sysv/linux/mips/mips64/xstat64.c
@@ -20,13 +20,20 @@
 #include <kernel_stat.h>
 #include <sysdep.h>
 #include <xstatconv.h>
+#include <shlib-compat.h>
 
-/* Get information about the file NAME in BUF.  */
+#if SHLIB_COMPAT(libc, GLIBC_2_2, GLIBC_2_33)
 
+/* Get information about the file NAME in BUF.  */
 int
+attribute_compat_text_section
 __xstat64 (int vers, const char *name, struct stat64 *buf)
 {
   struct kernel_stat kbuf;
   int r = INLINE_SYSCALL_CALL (stat, name, &kbuf);
   return r ?: __xstat64_conv (vers, &kbuf, buf);
 }
+
+compat_symbol (libc, __xstat64, __xstat64, GLIBC_2_2);
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/mips/xstat.c b/sysdeps/unix/sysv/linux/mips/xstat.c
index d6ff5ccbe0..0748a3422d 100644
--- a/sysdeps/unix/sysv/linux/mips/xstat.c
+++ b/sysdeps/unix/sysv/linux/mips/xstat.c
@@ -21,9 +21,13 @@
 #include <kernel_stat.h>
 #include <sysdep.h>
 #include <xstatconv.h>
+#include <shlib-compat.h>
+
+#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
 
 /* Get information about the file NAME in BUF.  */
 int
+attribute_compat_text_section
 __xstat (int vers, const char *name, struct stat *buf)
 {
   switch (vers)
@@ -39,3 +43,7 @@ __xstat (int vers, const char *name, struct stat *buf)
       }
     }
 }
+
+compat_symbol (libc, __xstat, __xstat, GLIBC_2_0);
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/xstat.c b/sysdeps/unix/sysv/linux/xstat.c
index a971e8cf6a..51329831b0 100644
--- a/sysdeps/unix/sysv/linux/xstat.c
+++ b/sysdeps/unix/sysv/linux/xstat.c
@@ -20,13 +20,17 @@
 #include <fcntl.h>
 #include <kernel_stat.h>
 #include <sysdep.h>
+#include <shlib-compat.h>
 
 #if !XSTAT_IS_XSTAT64
 # include <xstatconv.h>
 # include <xstatover.h>
 
+# if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
+
 /* Get information about the file NAME in BUF.  */
 int
+attribute_compat_text_section
 __xstat (int vers, const char *name, struct stat *buf)
 {
   switch (vers)
@@ -57,4 +61,9 @@ __xstat (int vers, const char *name, struct stat *buf)
       }
     }
 }
+
+compat_symbol (libc, __xstat, __xstat, GLIBC_2_0);
+# endif /* SHLIB_COMPAT  */
+
 #endif /* XSTAT_IS_XSTAT64  */
+
diff --git a/sysdeps/unix/sysv/linux/xstat64.c b/sysdeps/unix/sysv/linux/xstat64.c
index e3a42966f5..4872d24694 100644
--- a/sysdeps/unix/sysv/linux/xstat64.c
+++ b/sysdeps/unix/sysv/linux/xstat64.c
@@ -24,10 +24,14 @@
 #include <sysdep.h>
 #include <xstatconv.h>
 #include <statx_cp.h>
+#include <shlib-compat.h>
+
+#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
 
 /* Get information about the file NAME in BUF.  */
 
 int
+attribute_compat_text_section
 ___xstat64 (int vers, const char *name, struct stat64 *buf)
 {
 #if XSTAT_IS_XSTAT64
@@ -68,16 +72,17 @@ ___xstat64 (int vers, const char *name, struct stat64 *buf)
 }
 
 #if XSTAT_IS_XSTAT64
-weak_alias (___xstat64, __xstat);
-weak_alias (___xstat64, __GI___xstat);
+strong_alias (___xstat64, __xstat_compat)
+compat_symbol (libc, __xstat_compat, __xstat, GLIBC_2_2);
 #endif
 
-#include <shlib-compat.h>
-
 #if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2)
-versioned_symbol (libc, ___xstat64, __xstat64, GLIBC_2_2);
+compat_symbol (libc, ___xstat64, __xstat64, GLIBC_2_2);
 strong_alias (___xstat64, __old__xstat64)
 compat_symbol (libc, __old__xstat64, __xstat64, GLIBC_2_1);
 #else
 strong_alias (___xstat64, __xstat64)
+compat_symbol (libc, ___xstat64, __xstat64, GLIBC_2_2);
 #endif
+
+#endif /* SHLIB_COMPAT  */
-- 
2.25.1


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

* [PATCH 15/16] linux: Add {f}stat{at} y2038 support
  2020-07-23 19:46 [PATCH 00/16] Add y2038 support for stat functions Adhemerval Zanella via Libc-alpha
                   ` (13 preceding siblings ...)
  2020-07-23 19:46 ` [PATCH 14/16] linux: Move {f}xstat{at} to compat symbols Adhemerval Zanella via Libc-alpha
@ 2020-07-23 19:46 ` Adhemerval Zanella via Libc-alpha
  2020-07-23 20:55   ` Joseph Myers
                     ` (2 more replies)
  2020-07-23 19:46 ` [PATCH 16/16] linux: Move xmknoda{at} to compat symbols Adhemerval Zanella via Libc-alpha
  15 siblings, 3 replies; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-07-23 19:46 UTC (permalink / raw)
  To: libc-alpha; +Cc: Alistair Francis

A new struct __stat{64}_t64 type is added with the required
__timespec64 time definition.  Both non-LFS and LFS support were
done with an extra __NR_statx call plus a conversion to the new
__stat{64}_t64 type.  The statx call is done only for architectures
with support for 32-bit time_t ABI.

Internally some extra routines to copy from/to struct stat{64}
to struct __stat{64} used on multiple implementations (stat, fstat,
lstat, and fstatat) are added on a extra file (stat_t64_cp.c).  Aslo
some extra routines to copy from statx to __stat{64} is added on
statx_cp.c.

Checked with a build for all affected ABIs. I also checked on x86_64,
i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and s390x.
---
 include/sys/stat.h                            |  32 +++++
 sysdeps/generic/struct_stat_time64.h          |   7 +
 sysdeps/unix/sysv/linux/Makefile              |   2 +-
 sysdeps/unix/sysv/linux/fstat.c               |  13 +-
 sysdeps/unix/sysv/linux/fstat64.c             |  20 ++-
 sysdeps/unix/sysv/linux/fstatat.c             |  64 +++++----
 sysdeps/unix/sysv/linux/fstatat64.c           |  88 ++++++++++---
 sysdeps/unix/sysv/linux/lstat.c               |  13 +-
 sysdeps/unix/sysv/linux/lstat64.c             |  19 ++-
 .../unix/sysv/linux/mips/mips64/kstat_cp.h    |  23 +---
 .../unix/sysv/linux/mips/mips64/statx_cp.c    |   3 -
 sysdeps/unix/sysv/linux/stat.c                |  13 +-
 sysdeps/unix/sysv/linux/stat64.c              |  20 ++-
 sysdeps/unix/sysv/linux/stat_t64_cp.c         |  92 +++++++++++++
 sysdeps/unix/sysv/linux/stat_t64_cp.h         |  28 ++++
 sysdeps/unix/sysv/linux/statx_cp.c            |  54 ++++++++
 sysdeps/unix/sysv/linux/statx_cp.h            |   6 +
 sysdeps/unix/sysv/linux/struct_stat_time64.h  | 122 ++++++++++++++++++
 18 files changed, 539 insertions(+), 80 deletions(-)
 create mode 100644 sysdeps/generic/struct_stat_time64.h
 delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/statx_cp.c
 create mode 100644 sysdeps/unix/sysv/linux/stat_t64_cp.c
 create mode 100644 sysdeps/unix/sysv/linux/stat_t64_cp.h
 create mode 100644 sysdeps/unix/sysv/linux/struct_stat_time64.h

diff --git a/include/sys/stat.h b/include/sys/stat.h
index 199173b007..87d4a5ec4f 100644
--- a/include/sys/stat.h
+++ b/include/sys/stat.h
@@ -3,6 +3,8 @@
 
 #ifndef _ISOMAC
 # include <xstatver.h>
+# include <struct___timespec64.h>
+# include <struct_stat_time64.h>
 # include <stdbool.h>
 
 static inline bool
@@ -44,6 +46,36 @@ hidden_proto (__lstat64)
 hidden_proto (__fstatat64)
 # endif
 
+# if __TIMESIZE == 64
+#  define __stat_time64  __stat
+#  define __stat64_time64  __stat64
+#  define __fstat_time64  __fstat
+#  define __fstat64_time64  __fstat64
+#  define __lstat_time64  __lstat
+#  define __lstat64_time64  __lstat64
+#  define __fstatat_time64  __fstatat
+#  define __fstatat64_time64 __fstatat64
+# else
+extern int __stat_time64 (const char *file, struct __stat_t64 *buf);
+libc_hidden_proto (__stat_time64);
+extern int __stat64_time64 (const char *file, struct __stat64_t64 *buf);
+hidden_proto (__stat64_time64);
+extern int __lstat_time64 (const char *file, struct __stat_t64 *buf);
+libc_hidden_proto (__lstat_time64);
+extern int __lstat64_time64 (const char *file, struct __stat64_t64 *buf);
+hidden_proto (__lstat64_time64);
+extern int __fstat_time64 (int fd, struct __stat_t64 *buf);
+libc_hidden_proto (__fstat_time64);
+extern int __fstat64_time64 (int fd, struct __stat64_t64 *buf);
+hidden_proto (__fstat64_time64);
+extern int __fstatat_time64 (int dirfd, const char *pathname,
+			     struct __stat_t64 *buf, int flags);
+libc_hidden_proto (__fstatat_time64);
+extern int __fstatat64_time64 (int dirfd, const char *pathname,
+			       struct __stat64_t64 *buf, int flags);
+hidden_proto (__fstatat64_time64);
+# endif
+
 extern int __chmod (const char *__file, __mode_t __mode);
 libc_hidden_proto (__chmod)
 extern int __fchmod (int __fd, __mode_t __mode);
diff --git a/sysdeps/generic/struct_stat_time64.h b/sysdeps/generic/struct_stat_time64.h
new file mode 100644
index 0000000000..24bb9f75cb
--- /dev/null
+++ b/sysdeps/generic/struct_stat_time64.h
@@ -0,0 +1,7 @@
+#ifndef _BITS_STRUCT_STAT_TIME64_H
+#define _BITS_STRUCT_STAT_TIME64_H 1
+
+#define __stat_t64   stat
+#define __stat64_t64 stat64
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index f189f65daf..95a51ee4f2 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -273,7 +273,7 @@ sysdep_routines += xstatconv internal_statvfs internal_statvfs64 \
 		   open_nocancel open64_nocancel \
 		   openat_nocancel openat64_nocancel \
 		   read_nocancel pread64_nocancel \
-		   write_nocancel statx_cp
+		   write_nocancel statx_cp stat_t64_cp
 
 sysdep_headers += bits/fcntl-linux.h
 
diff --git a/sysdeps/unix/sysv/linux/fstat.c b/sysdeps/unix/sysv/linux/fstat.c
index bdbeded956..0981dbaa95 100644
--- a/sysdeps/unix/sysv/linux/fstat.c
+++ b/sysdeps/unix/sysv/linux/fstat.c
@@ -19,13 +19,24 @@
 #include <sys/stat.h>
 #include <kernel_stat.h>
 #include <fcntl.h>
+#include <stat_t64_cp.h>
 
 #if !XSTAT_IS_XSTAT64
+int
+__fstat_time64 (int fd, struct __stat_t64 *buf)
+{
+  return __fstatat_time64 (fd, "", buf, AT_EMPTY_PATH);
+}
+# if __TIMESIZE != 64
+libc_hidden_def (__fstat_time64)
+
 int
 __fstat (int fd, struct stat *buf)
 {
-  return __fstatat (fd, "", buf, AT_EMPTY_PATH);
+  struct __stat_t64 st_t64;
+  return __fstat_time64 (fd, &st_t64) ?: __cp_stat_t64_stat (&st_t64, buf);
 }
+# endif
 
 weak_alias (__fstat, fstat)
 #endif
diff --git a/sysdeps/unix/sysv/linux/fstat64.c b/sysdeps/unix/sysv/linux/fstat64.c
index c2ff1ff577..67667e79d8 100644
--- a/sysdeps/unix/sysv/linux/fstat64.c
+++ b/sysdeps/unix/sysv/linux/fstat64.c
@@ -19,16 +19,30 @@
 #define __fstat __redirect___fstat
 #define fstat   __redirect_fstat
 #include <sys/stat.h>
-#undef __fstat
-#undef fstat
 #include <fcntl.h>
 #include <kernel_stat.h>
+#include <stat_t64_cp.h>
+
+int
+__fstat64_time64 (int fd, struct __stat64_t64 *buf)
+{
+  return __fstatat64_time64 (fd, "", buf, AT_EMPTY_PATH);
+}
+#if __TIMESIZE != 64
+hidden_def (__fstat64_time64)
 
 int
 __fstat64 (int fd, struct stat64 *buf)
 {
-  return __fstatat64 (fd, "", buf, AT_EMPTY_PATH);
+  struct __stat64_t64 st_t64;
+  return __fstat64_time64 (fd, &st_t64)
+	 ?: __cp_stat64_t64_stat64 (&st_t64, buf);
 }
+#endif
+
+#undef __fstat
+#undef fstat
+
 hidden_def (__fstat64)
 weak_alias (__fstat64, fstat64)
 
diff --git a/sysdeps/unix/sysv/linux/fstatat.c b/sysdeps/unix/sysv/linux/fstatat.c
index 03ddb3f493..f65d3b74a6 100644
--- a/sysdeps/unix/sysv/linux/fstatat.c
+++ b/sysdeps/unix/sysv/linux/fstatat.c
@@ -22,25 +22,28 @@
 
 #if !XSTAT_IS_XSTAT64
 # include <kstat_cp.h>
+# include <statx_cp.h>
+# include <stat_t64_cp.h>
 
 int
-__fstatat (int fd, const char *file, struct stat *st, int flag)
+__fstatat_time64 (int fd, const char *file, struct __stat_t64 *st, int flag)
 {
-# if STAT_IS_KERNEL_STAT
-  /* New kABIs which uses generic pre 64-bit time Linux ABI, e.g.
-     csky, nios2  */
-  int r = INLINE_SYSCALL_CALL (fstatat64, fd, file, st, flag);
-  if (r == 0 && (st->__st_ino_pad != 0
-		 || st->__st_size_pad != 0
-		 || st->__st_blocks_pad != 0))
-    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW);
-  return r;
-# else
-#  ifdef __NR_fstatat64
-  /* Old KABIs with old non-LFS support, e.g. arm, i386, hppa, m68k, mips32,
-     microblaze, s390, sh, powerpc, and sparc.  */
+  struct statx stx;
+  int r = INLINE_SYSCALL_CALL (statx, fd, file, flag, STATX_BASIC_STATS,
+			       &stx);
+  if (r == 0 || errno != ENOSYS)
+    {
+      if (r == 0)
+	__cp_stat_t64_statx (st, &stx);
+      return r;
+    }
+
+# ifdef __NR_fstatat64
+  /* Both new kABI which uses generic pre 64-bit time Linux ABI (e.g. csky
+     and nios) and old kABI with non-LFS support (e.g. arm, i386, hppa, m68k,
+     mips32, microblaze, s390, sh, powerpc, and sparc32).  */
   struct stat64 st64;
-  int r = INLINE_SYSCALL_CALL (fstatat64, fd, file, &st64, flag);
+  r = INLINE_SYSCALL_CALL (fstatat64, fd, file, &st64, flag);
   if (r == 0)
     {
       if (! in_ino_t_range (st64.st_ino)
@@ -48,7 +51,7 @@ __fstatat (int fd, const char *file, struct stat *st, int flag)
 	  || ! in_blkcnt_t_range (st64.st_blocks))
 	return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW);
 
-      /* Clear internal pad and reserved fields.  */
+      /* Clear both pad and reserved fields.  */
       memset (st, 0, sizeof (*st));
 
       st->st_dev = st64.st_dev,
@@ -61,22 +64,29 @@ __fstatat (int fd, const char *file, struct stat *st, int flag)
       st->st_size = st64.st_size;
       st->st_blksize = st64.st_blksize;
       st->st_blocks  = st64.st_blocks;
-      st->st_atim.tv_sec = st64.st_atim.tv_sec;
-      st->st_atim.tv_nsec = st64.st_atim.tv_nsec;
-      st->st_mtim.tv_sec = st64.st_mtim.tv_sec;
-      st->st_mtim.tv_nsec = st64.st_mtim.tv_nsec;
-      st->st_ctim.tv_sec = st64.st_ctim.tv_sec;
-      st->st_ctim.tv_nsec = st64.st_ctim.tv_nsec;
+      st->st_atim = valid_timespec_to_timespec64 (st64.st_atim);
+      st->st_mtim = valid_timespec_to_timespec64 (st64.st_mtim);
+      st->st_ctim = valid_timespec_to_timespec64 (st64.st_ctim);
     }
   return r;
-#  else
+# else
   /* 64-bit kabi outlier, e.g. mips64 and mips64-n32.  */
   struct kernel_stat kst;
-  int r = INTERNAL_SYSCALL_CALL (newfstatat, fd, file, &kst, flag);
-  return r ?: __cp_kstat_stat (&kst, st);
-#  endif /* __nr_fstatat64  */
-# endif /* STAT_IS_KERNEL_STAT  */
+  r = INTERNAL_SYSCALL_CALL (newfstatat, fd, file, &kst, flag);
+  return r ?: __cp_kstat_stat_t64 (&kst, st);
+# endif /* __NR_fstatat64  */
+}
+# if __TIMESIZE != 64
+libc_hidden_def (__fstatat_time64)
+
+int
+__fstatat (int fd, const char *file, struct stat *buf, int flags)
+{
+  struct __stat_t64 st_t64;
+  return __fstatat_time64 (fd, file, &st_t64, flags)
+	 ?: __cp_stat_t64_stat (&st_t64, buf);
 }
+# endif
 
 weak_alias (__fstatat, fstatat)
 #endif
diff --git a/sysdeps/unix/sysv/linux/fstatat64.c b/sysdeps/unix/sysv/linux/fstatat64.c
index 82fab107a5..b3940f0d20 100644
--- a/sysdeps/unix/sysv/linux/fstatat64.c
+++ b/sysdeps/unix/sysv/linux/fstatat64.c
@@ -19,56 +19,102 @@
 #define __fstatat __redirect___fstatat
 #define fstatat   __redirect_fstatat
 #include <sys/stat.h>
-#undef __fstatat
-#undef fstatat
 #include <fcntl.h>
-
+#include <string.h>
 #include <kernel_stat.h>
 #include <sysdep.h>
-
+#include <time.h>
 #include <statx_cp.h>
 #include <kstat_cp.h>
+#include <stat_t64_cp.h>
 
 int
-__fstatat64 (int fd, const char *file, struct stat64 *st, int flag)
+__fstatat64_time64 (int fd, const char *file, struct __stat64_t64 *st,
+		    int flag)
 {
+  int r;
+
+#if (__WORDSIZE == 32 \
+     && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE == 32))
+  struct statx tmp;
+  r = INLINE_SYSCALL_CALL (statx, fd, file, AT_NO_AUTOMOUNT | flag,
+			   STATX_BASIC_STATS, &tmp);
+  if (r == 0 || errno != ENOSYS)
+    {
+      if (r == 0)
+	__cp_stat64_t64_statx (st, &tmp);
+      return r;
+    }
+#endif
+
 #if XSTAT_IS_XSTAT64
 # ifdef __NR_newfstatat
   /* 64-bit kABI, e.g. aarch64, ia64, powerpc64*, s390x, riscv64, and
      x86_64.  */
-  return INLINE_SYSCALL_CALL (newfstatat, fd, file, st, flag);
+  r = INLINE_SYSCALL_CALL (newfstatat, fd, file, st, flag);
 # elif defined __NR_fstatat64
 #  if STAT64_IS_KERNEL_STAT64
-  /* 64-bit kABI outlier, e.g. alpha.  */
-  return INLINE_SYSCALL_CALL (fstatat64, fd, file, st, flag);
+  /* 64-bit kABI outlier, e.g. alpha  */
+  r = INLINE_SYSCALL_CALL (fstatat64, fd, file, st, flag);
 #  else
   /* 64-bit kABI outlier, e.g. sparc64.  */
   struct kernel_stat64 kst64;
-  int r = INLINE_SYSCALL_CALL (fstatat64, fd, file, &kst64, flag);
-  return r ?: __cp_stat64_kstat64 (st, &kst64);
-#  endif
-# else
-  /* 32-bit kABI with default 64-bit time_t, e.g. arc, riscv32.  */
-  struct statx tmp;
-  int r = INLINE_SYSCALL_CALL (statx, fd, file, AT_NO_AUTOMOUNT | flag,
-			       STATX_BASIC_STATS, &tmp);
+  r = INLINE_SYSCALL_CALL (fstatat64, fd, file, &kst64, flag);
   if (r == 0)
-    __cp_stat64_statx (st, &tmp);
-  return r;
+    r = __cp_stat64_kstat64 (st, &kst64);
+#  endif
 # endif
 #else
 # ifdef __NR_fstatat64
   /* All kABIs with non-LFS support, e.g. arm, csky, i386, hppa, m68k,
      microblaze, nios2, sh, powerpc32, and sparc32.  */
-  return INLINE_SYSCALL_CALL (fstatat64, fd, file, st, flag);
+  struct stat64 st64;
+  r = INLINE_SYSCALL_CALL (fstatat64, fd, file, &st64, flag);
+  if (r == 0)
+    {
+      /* Clear both pad and reserved fields.  */
+      memset (st, 0, sizeof (*st));
+
+      st->st_dev = st64.st_dev,
+      st->st_ino = st64.st_ino;
+      st->st_mode = st64.st_mode;
+      st->st_nlink = st64.st_nlink;
+      st->st_uid = st64.st_uid;
+      st->st_gid = st64.st_gid;
+      st->st_rdev = st64.st_rdev;
+      st->st_size = st64.st_size;
+      st->st_blksize = st64.st_blksize;
+      st->st_blocks  = st64.st_blocks;
+      st->st_atim = valid_timespec_to_timespec64 (st64.st_atim);
+      st->st_mtim = valid_timespec_to_timespec64 (st64.st_mtim);
+      st->st_ctim = valid_timespec_to_timespec64 (st64.st_ctim);
+    }
 # else
   /* 64-bit kabi outlier, e.g. mips64 and mips64-n32.  */
   struct kernel_stat kst;
-  int r = INTERNAL_SYSCALL_CALL (newfstatat, fd, file, &kst, flag);
-  return r ?: __cp_kstat_stat64 (&kst, st);
+  r = INTERNAL_SYSCALL_CALL (newfstatat, fd, file, &kst, flag);
+  if (r == 0)
+    r =  __cp_kstat_stat64_t64 (&kst, st);
 # endif
 #endif
+
+  return r;
 }
+#if __TIMESIZE != 64
+hidden_def (__fstatat64_time64)
+
+int
+__fstatat64 (int fd, const char *file, struct stat64 *st, int flags)
+{
+  struct __stat64_t64 st_t64;
+  return __fstatat64_time64 (fd, file, &st_t64, flags)
+	 ?: __cp_stat64_t64_stat64 (&st_t64, st);
+}
+#endif
+
+#undef __fstatat
+#undef fstatat
+
 hidden_def (__fstatat64)
 weak_alias (__fstatat64, fstatat64)
 
diff --git a/sysdeps/unix/sysv/linux/lstat.c b/sysdeps/unix/sysv/linux/lstat.c
index b0bdeee9e9..803ad78171 100644
--- a/sysdeps/unix/sysv/linux/lstat.c
+++ b/sysdeps/unix/sysv/linux/lstat.c
@@ -19,13 +19,24 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <kernel_stat.h>
+#include <stat_t64_cp.h>
 
 #if !XSTAT_IS_XSTAT64
+int
+__lstat_time64 (const char *file, struct __stat_t64 *buf)
+{
+  return __fstatat_time64 (AT_FDCWD, file, buf, AT_SYMLINK_NOFOLLOW);
+}
+# if __TIMESIZE != 64
+libc_hidden_def (__lstat_time64)
+
 int
 __lstat (const char *file, struct stat *buf)
 {
-  return __fstatat (AT_FDCWD, file, buf, AT_SYMLINK_NOFOLLOW);
+  struct __stat_t64 st_t64;
+  return __lstat_time64 (file, &st_t64) ?: __cp_stat_t64_stat (&st_t64, buf);
 }
+# endif
 
 weak_alias (__lstat, lstat)
 #endif
diff --git a/sysdeps/unix/sysv/linux/lstat64.c b/sysdeps/unix/sysv/linux/lstat64.c
index e5f02e9822..971ab8469d 100644
--- a/sysdeps/unix/sysv/linux/lstat64.c
+++ b/sysdeps/unix/sysv/linux/lstat64.c
@@ -19,19 +19,32 @@
 #define __lstat __redirect___lstat
 #define lstat   __redirect_lstat
 #include <sys/stat.h>
-#undef __lstat
-#undef lstat
 #include <fcntl.h>
 #include <kernel_stat.h>
+#include <stat_t64_cp.h>
+
+int
+__lstat64_time64 (const char *file, struct __stat64_t64 *buf)
+{
+  return __fstatat64_time64 (AT_FDCWD, file, buf, AT_SYMLINK_NOFOLLOW);
+}
+#if __TIMESIZE != 64
+hidden_def (__lstat64_time64)
 
 int
 __lstat64 (const char *file, struct stat64 *buf)
 {
-  return __fstatat64 (AT_FDCWD, file, buf, AT_SYMLINK_NOFOLLOW);
+  struct __stat64_t64 st_t64;
+  return __lstat64_time64 (file, &st_t64)
+	 ?: __cp_stat64_t64_stat64 (&st_t64, buf);
 }
+#endif
 hidden_def (__lstat64)
 weak_alias (__lstat64, lstat64)
 
+#undef __lstat
+#undef lstat
+
 #if XSTAT_IS_XSTAT64
 strong_alias (__lstat64, __lstat)
 weak_alias (__lstat64, lstat)
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/kstat_cp.h b/sysdeps/unix/sysv/linux/mips/mips64/kstat_cp.h
index 7f226416f9..553f4226bc 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/kstat_cp.h
+++ b/sysdeps/unix/sysv/linux/mips/mips64/kstat_cp.h
@@ -20,23 +20,21 @@
 #include <kernel_stat.h>
 
 static inline int
-__cp_kstat_stat (const struct kernel_stat *kst, struct stat *st)
+__cp_kstat_stat_t64 (const struct kernel_stat *kst, struct __stat_t64 *st)
 {
+  if (! in_ino_t_range (kst->st_ino)
+      || ! in_off_t_range (kst->st_size)
+      || ! in_blkcnt_t_range (kst->st_blocks))
+    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW);
+
   st->st_dev = kst->st_dev;
-  memset (&st->st_pad1, 0, sizeof (st->st_pad1));
   st->st_ino = kst->st_ino;
-  if (st->st_ino != kst->st_ino)
-    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW);
   st->st_mode = kst->st_mode;
   st->st_nlink = kst->st_nlink;
   st->st_uid = kst->st_uid;
   st->st_gid = kst->st_gid;
   st->st_rdev = kst->st_rdev;
-  memset (&st->st_pad2, 0, sizeof (st->st_pad2));
   st->st_size = kst->st_size;
-  if (st->st_size != kst->st_size)
-    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW);
-  st->st_pad3 = 0;
   st->st_atim.tv_sec = kst->st_atime_sec;
   st->st_atim.tv_nsec = kst->st_atime_nsec;
   st->st_mtim.tv_sec = kst->st_mtime_sec;
@@ -45,26 +43,20 @@ __cp_kstat_stat (const struct kernel_stat *kst, struct stat *st)
   st->st_ctim.tv_nsec = kst->st_ctime_nsec;
   st->st_blksize = kst->st_blksize;
   st->st_blocks = kst->st_blocks;
-  if (st->st_blocks != kst->st_blocks)
-    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW);
-  memset (&st->st_pad5, 0, sizeof (st->st_pad5));
 
   return 0;
 }
 
 static inline int
-__cp_kstat_stat64 (const struct kernel_stat *kst, struct stat64 *st)
+__cp_kstat_stat64_t64 (const struct kernel_stat *kst, struct __stat64_t64 *st)
 {
   st->st_dev = kst->st_dev;
-  memset (&st->st_pad1, 0, sizeof (st->st_pad1));
   st->st_ino = kst->st_ino;
   st->st_mode = kst->st_mode;
   st->st_nlink = kst->st_nlink;
   st->st_uid = kst->st_uid;
   st->st_gid = kst->st_gid;
   st->st_rdev = kst->st_rdev;
-  memset (&st->st_pad2, 0, sizeof (st->st_pad2));
-  st->st_pad3 = 0;
   st->st_size = kst->st_size;
   st->st_blksize = kst->st_blksize;
   st->st_blocks = kst->st_blocks;
@@ -74,7 +66,6 @@ __cp_kstat_stat64 (const struct kernel_stat *kst, struct stat64 *st)
   st->st_mtim.tv_nsec = kst->st_mtime_nsec;
   st->st_ctim.tv_sec = kst->st_ctime_sec;
   st->st_ctim.tv_nsec = kst->st_ctime_nsec;
-  memset (&st->st_pad4, 0, sizeof (st->st_pad4));
 
   return 0;
 }
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/statx_cp.c b/sysdeps/unix/sysv/linux/mips/mips64/statx_cp.c
deleted file mode 100644
index 260cda987e..0000000000
--- a/sysdeps/unix/sysv/linux/mips/mips64/statx_cp.c
+++ /dev/null
@@ -1,3 +0,0 @@
-/* Override the generic statx_cp.c which is only needed for new 32-bit arch
-   without stat64 family support.
- */
diff --git a/sysdeps/unix/sysv/linux/stat.c b/sysdeps/unix/sysv/linux/stat.c
index a77502eb95..dcbc22da29 100644
--- a/sysdeps/unix/sysv/linux/stat.c
+++ b/sysdeps/unix/sysv/linux/stat.c
@@ -19,13 +19,24 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <kernel_stat.h>
+#include <stat_t64_cp.h>
 
 #if !XSTAT_IS_XSTAT64
+int
+__stat_time64 (const char *file, struct __stat_t64 *buf)
+{
+  return __fstatat_time64 (AT_FDCWD, file, buf, 0);
+}
+# if __TIMESIZE != 64
+libc_hidden_def (__stat_time64);
+
 int
 __stat (const char *file, struct stat *buf)
 {
-  return __fstatat (AT_FDCWD, file, buf, 0);
+  struct __stat_t64 st_t64;
+  return __stat_time64 (file, &st_t64) ?: __cp_stat_t64_stat (&st_t64, buf);
 }
+# endif
 
 weak_alias (__stat, stat)
 #endif
diff --git a/sysdeps/unix/sysv/linux/stat64.c b/sysdeps/unix/sysv/linux/stat64.c
index 2f40037c2c..bd8b17ac49 100644
--- a/sysdeps/unix/sysv/linux/stat64.c
+++ b/sysdeps/unix/sysv/linux/stat64.c
@@ -19,16 +19,30 @@
 #define __stat __redirect___stat
 #define stat   __redirect_stat
 #include <sys/stat.h>
-#undef __stat
-#undef stat
 #include <fcntl.h>
 #include <kernel_stat.h>
+#include <stat_t64_cp.h>
+
+int
+__stat64_time64 (const char *file, struct __stat64_t64 *buf)
+{
+  return __fstatat64_time64 (AT_FDCWD, file, buf, 0);
+}
+#if __TIMESIZE != 64
+hidden_def (__stat64_time64)
 
 int
 __stat64 (const char *file, struct stat64 *buf)
 {
-  return __fstatat64 (AT_FDCWD, file, buf, 0);
+  struct __stat64_t64 st_t64;
+  return __stat64_time64 (file, &st_t64)
+	 ?: __cp_stat64_t64_stat64 (&st_t64, buf);
 }
+#endif
+
+#undef __stat
+#undef stat
+
 hidden_def (__stat64)
 weak_alias (__stat64, stat64)
 
diff --git a/sysdeps/unix/sysv/linux/stat_t64_cp.c b/sysdeps/unix/sysv/linux/stat_t64_cp.c
new file mode 100644
index 0000000000..56459b6266
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/stat_t64_cp.c
@@ -0,0 +1,92 @@
+/* Struct stat/stat64 to stat/stat64 conversion for Linux.
+   Copyright (C) 2020 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 <stat_t64_cp.h>
+#include <string.h>
+#include <errno.h>
+#include <time.h>
+
+#if __TIMESIZE != 64
+/* Convert the 64-bit time_t stat ST_T64 to the non-LFS ST stat and returns
+   EOVERFLOW if any of time (access, modification, status) is larger than
+   32-bit time_t.  It is used on non-LFS stat, fstat, lstat, and fstatat to
+   convert from the the 64-bit time_t call.  */
+int
+__cp_stat_t64_stat (const struct __stat_t64 *st_t64, struct stat *st)
+{
+  if (! in_time_t_range (st_t64->st_atim.tv_sec)
+      || ! in_time_t_range (st_t64->st_mtim.tv_sec)
+      || ! in_time_t_range (st_t64->st_ctim.tv_sec))
+    {
+      __set_errno (EOVERFLOW);
+      return -1;
+    }
+
+  /* Clear both pad and reserved fields.  */
+  memset (st, 0, sizeof (*st));
+
+  st->st_dev = st_t64->st_dev,
+  st->st_ino = st_t64->st_ino;
+  st->st_mode = st_t64->st_mode;
+  st->st_nlink = st_t64->st_nlink;
+  st->st_uid = st_t64->st_uid;
+  st->st_gid = st_t64->st_gid;
+  st->st_rdev = st_t64->st_rdev;
+  st->st_size = st_t64->st_size;
+  st->st_blksize = st_t64->st_blksize;
+  st->st_blocks  = st_t64->st_blocks;
+  st->st_atim = valid_timespec64_to_timespec (st_t64->st_atim);
+  st->st_mtim = valid_timespec64_to_timespec (st_t64->st_mtim);
+  st->st_ctim = valid_timespec64_to_timespec (st_t64->st_ctim);
+
+  return 0;
+}
+
+int
+__cp_stat64_t64_stat64 (const struct __stat64_t64 *st64_t64,
+			struct stat64 *st64)
+{
+  if (! in_time_t_range (st64_t64->st_atim.tv_sec)
+      || ! in_time_t_range (st64_t64->st_mtim.tv_sec)
+      || ! in_time_t_range (st64_t64->st_ctim.tv_sec))
+    {
+      __set_errno (EOVERFLOW);
+      return -1;
+    }
+
+  /* Clear both pad and reserved fields.  */
+  memset (st64, 0, sizeof (*st64));
+
+  st64->st_dev = st64_t64->st_dev,
+  st64->st_ino = st64_t64->st_ino;
+  st64->st_mode = st64_t64->st_mode;
+  st64->st_nlink = st64_t64->st_nlink;
+  st64->st_uid = st64_t64->st_uid;
+  st64->st_gid = st64_t64->st_gid;
+  st64->st_rdev = st64_t64->st_rdev;
+  st64->st_size = st64_t64->st_size;
+  st64->st_blksize = st64_t64->st_blksize;
+  st64->st_blocks  = st64_t64->st_blocks;
+  st64->st_atim = valid_timespec64_to_timespec (st64_t64->st_atim);
+  st64->st_mtim = valid_timespec64_to_timespec (st64_t64->st_mtim);
+  st64->st_ctim = valid_timespec64_to_timespec (st64_t64->st_ctim);
+
+  return 0;
+}
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/stat_t64_cp.h b/sysdeps/unix/sysv/linux/stat_t64_cp.h
new file mode 100644
index 0000000000..ad2bcc7a04
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/stat_t64_cp.h
@@ -0,0 +1,28 @@
+/* Copy to/from struct stat with and without 64-bit time_t support.
+   Copyright (C) 2020 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>
+
+#if __TIMESIZE != 64
+extern int __cp_stat_t64_stat (const struct __stat_t64 *st_t64,
+			       struct stat *st)
+  attribute_hidden;
+extern int __cp_stat64_t64_stat64 (const struct __stat64_t64 *st64_t64,
+				   struct stat64 *st64)
+  attribute_hidden;
+#endif
diff --git a/sysdeps/unix/sysv/linux/statx_cp.c b/sysdeps/unix/sysv/linux/statx_cp.c
index cc6e17929e..4b35e86f8d 100644
--- a/sysdeps/unix/sysv/linux/statx_cp.c
+++ b/sysdeps/unix/sysv/linux/statx_cp.c
@@ -47,3 +47,57 @@ __cp_stat64_statx (struct stat64 *to, struct statx *from)
   to->st_blksize = from->stx_blksize;
 }
 #endif
+
+void
+__cp_stat_t64_statx (struct __stat_t64 *to, const struct statx *from)
+{
+  /* Clear both pad and reserved fields.  */
+  memset (to, 0, sizeof (*to));
+
+  to->st_dev = ((from->stx_dev_minor & 0xff) | (from->stx_dev_major << 8)
+		| ((from->stx_dev_minor & ~0xff) << 12));
+  to->st_ino = from->stx_ino;
+  to->st_mode = from->stx_mode;
+  to->st_nlink = from->stx_nlink;
+  to->st_uid = from->stx_uid;
+  to->st_gid = from->stx_gid;
+  to->st_rdev = ((from->stx_rdev_minor & 0xff) | (from->stx_rdev_major << 8)
+		 | ((from->stx_rdev_minor & ~0xff) << 12));
+  to->st_size = from->stx_size;
+  to->st_blksize = from->stx_blksize;
+  to->st_blocks = from->stx_blocks;
+
+  to->st_atime = from->stx_atime.tv_sec;
+  to->st_atim.tv_nsec = from->stx_atime.tv_nsec;
+  to->st_mtime = from->stx_mtime.tv_sec;
+  to->st_mtim.tv_nsec = from->stx_mtime.tv_nsec;
+  to->st_ctime = from->stx_ctime.tv_sec;
+  to->st_ctim.tv_nsec = from->stx_ctime.tv_nsec;
+}
+
+void
+__cp_stat64_t64_statx (struct __stat64_t64 *to, const struct statx *from)
+{
+  /* Clear both pad and reserved fields.  */
+  memset (to, 0, sizeof (*to));
+
+  to->st_dev = ((from->stx_dev_minor & 0xff) | (from->stx_dev_major << 8)
+		| ((from->stx_dev_minor & ~0xff) << 12));
+  to->st_ino = from->stx_ino;
+  to->st_mode = from->stx_mode;
+  to->st_nlink = from->stx_nlink;
+  to->st_uid = from->stx_uid;
+  to->st_gid = from->stx_gid;
+  to->st_rdev = ((from->stx_rdev_minor & 0xff) | (from->stx_rdev_major << 8)
+		 | ((from->stx_rdev_minor & ~0xff) << 12));
+  to->st_size = from->stx_size;
+  to->st_blksize = from->stx_blksize;
+  to->st_blocks = from->stx_blocks;
+
+  to->st_atime = from->stx_atime.tv_sec;
+  to->st_atim.tv_nsec = from->stx_atime.tv_nsec;
+  to->st_mtime = from->stx_mtime.tv_sec;
+  to->st_mtim.tv_nsec = from->stx_mtime.tv_nsec;
+  to->st_ctime = from->stx_ctime.tv_sec;
+  to->st_ctim.tv_nsec = from->stx_ctime.tv_nsec;
+}
diff --git a/sysdeps/unix/sysv/linux/statx_cp.h b/sysdeps/unix/sysv/linux/statx_cp.h
index fdbb807a31..bf3186ffac 100644
--- a/sysdeps/unix/sysv/linux/statx_cp.h
+++ b/sysdeps/unix/sysv/linux/statx_cp.h
@@ -18,3 +18,9 @@
 
 extern void __cp_stat64_statx (struct stat64 *to, struct statx *from)
   attribute_hidden;
+extern void __cp_stat_t64_statx (struct __stat_t64 *to,
+				 const struct statx *from)
+  attribute_hidden;
+extern void __cp_stat64_t64_statx (struct __stat64_t64 *to,
+				   const struct statx *from)
+  attribute_hidden;
diff --git a/sysdeps/unix/sysv/linux/struct_stat_time64.h b/sysdeps/unix/sysv/linux/struct_stat_time64.h
new file mode 100644
index 0000000000..b2a51927d0
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/struct_stat_time64.h
@@ -0,0 +1,122 @@
+/* Struct stat with 64-bit time support.
+   Copyright (C) 2020 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 _BITS_STRUCT_STAT_TIME64_H
+#define _BITS_STRUCT_STAT_TIME64_H 1
+
+#if __TIMESIZE == 64
+# define __stat_t64   stat
+# define __stat64_t64 stat64
+#else
+# include <endian.h>
+
+# ifdef __USE_FILE_OFFSET64
+#  define __field64(type, type64, name) type64 name
+# else
+#  define __field64(type, type64, name) type name
+# endif
+
+/* The definition should be equal to the 'struct __timespec64' internal
+   layout.  */
+# if BYTE_ORDER == BIG_ENDIAN
+#  define __fieldts64(name) 					\
+   __time64_t name; __int32_t :32; __int32_t name ## nsec
+# else
+#  define __fieldts64(name)					\
+   __time64_t name; __int32_t name ## nsec; __int32_t :32
+# endif
+
+/* Workaround for the definition from struct_stat.h  */
+# undef st_atime
+# undef st_mtime
+# undef st_ctime
+
+struct __stat_t64
+  {
+    __dev_t st_dev;			/* Device.  */
+    __field64(__ino_t, __ino64_t, st_ino);  /* File serial number.  */
+    __mode_t st_mode;			/* File mode.  */
+    __nlink_t st_nlink;			/* Link count.  */
+    __uid_t st_uid;			/* User ID of the file's owner.	*/
+    __gid_t st_gid;			/* Group ID of the file's group.*/
+    __dev_t st_rdev;			/* Device number, if device.  */
+    __field64(__off_t, __off64_t, st_size);  /* Size of file, in bytes. */
+    __blksize_t st_blksize;		/* Optimal block size for I/O.  */
+    __field64(__blkcnt_t, __blkcnt64_t, st_blocks);  /* 512-byte blocks */
+# ifdef __USE_XOPEN2K8
+    /* Nanosecond resolution timestamps are stored in a format
+       equivalent to 'struct timespec'.  This is the type used
+       whenever possible but the Unix namespace rules do not allow the
+       identifier 'timespec' to appear in the <sys/stat.h> header.
+       Therefore we have to handle the use of this header in strictly
+       standard-compliant sources special.  */
+    struct __timespec64 st_atim;	/* Time of last access.  */
+    struct __timespec64 st_mtim;	/* Time of last modification.  */
+    struct __timespec64 st_ctim;	/* Time of last status change.  */
+#  define st_atime st_atim.tv_sec	/* Backward compatibility.  */
+#  define st_mtime st_mtim.tv_sec
+#  define st_ctime st_ctim.tv_sec
+# else
+    __fieldts64 (st_atime);
+    __fieldts64 (st_mtime);
+    __fieldts64 (st_ctime);
+# endif /* __USE_XOPEN2K8  */
+  };
+
+# undef __field64
+
+#ifdef __USE_LARGEFILE64
+struct __stat64_t64
+  {
+    __dev_t st_dev;			/* Device.  */
+    __ino64_t st_ino;			/* file serial number.	*/
+    __mode_t st_mode;			/* File mode.  */
+    __nlink_t st_nlink;			/* Link count.  */
+    __uid_t st_uid;			/* User ID of the file's owner.	*/
+    __gid_t st_gid;			/* Group ID of the file's group.*/
+    __dev_t st_rdev;			/* Device number, if device.  */
+    __off64_t st_size;			/* Size of file, in bytes.  */
+    __blksize_t st_blksize;		/* Optimal block size for I/O.  */
+    __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
+# ifdef __USE_XOPEN2K8
+    /* Nanosecond resolution timestamps are stored in a format
+       equivalent to 'struct timespec'.  This is the type used
+       whenever possible but the Unix namespace rules do not allow the
+       identifier 'timespec' to appear in the <sys/stat.h> header.
+       Therefore we have to handle the use of this header in strictly
+       standard-compliant sources special.  */
+    struct __timespec64 st_atim;	/* Time of last access.  */
+    struct __timespec64 st_mtim;	/* Time of last modification.  */
+    struct __timespec64 st_ctim;	/* Time of last status change.  */
+# else
+    __fieldts64 (st_atime);
+    __fieldts64 (st_mtime);
+    __fieldts64 (st_ctime);
+# endif /* __USE_XOPEN2K8  */
+  };
+# endif /* __USE_LARGEFILE64  */
+
+# undef __fieldts64
+
+# define _STATBUF_ST_BLKSIZE
+# define _STATBUF_ST_RDEV
+# define _STATBUF_ST_NSEC
+
+# endif /* __TIMESIZE == 64  */
+
+#endif /* _BITS_STRUCT_STAT_TIME64_H  */
-- 
2.25.1


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

* [PATCH 16/16] linux: Move xmknoda{at} to compat symbols
  2020-07-23 19:46 [PATCH 00/16] Add y2038 support for stat functions Adhemerval Zanella via Libc-alpha
                   ` (14 preceding siblings ...)
  2020-07-23 19:46 ` [PATCH 15/16] linux: Add {f}stat{at} y2038 support Adhemerval Zanella via Libc-alpha
@ 2020-07-23 19:46 ` Adhemerval Zanella via Libc-alpha
  2020-07-24 10:30   ` Florian Weimer via Libc-alpha
  2020-07-24 10:43   ` Lukasz Majewski
  15 siblings, 2 replies; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-07-23 19:46 UTC (permalink / raw)
  To: libc-alpha; +Cc: Alistair Francis

It also decouple mknod{at} from xmknod{at}.

Checked with a build for all affected Linux ABIs.  I checked also
on x86_64-linux-gnu and i686-linux-gnu.
---
 include/sys/stat.h                 |  6 +++--
 sysdeps/mach/hurd/xmknod.c         |  1 -
 sysdeps/mach/hurd/xmknodat.c       |  2 --
 sysdeps/unix/sysv/linux/mknod.c    | 28 ++++++++++++++++++++
 sysdeps/unix/sysv/linux/mknodat.c  | 41 ++++++++++++++++++++++++++++++
 sysdeps/unix/sysv/linux/xmknod.c   | 20 +++++----------
 sysdeps/unix/sysv/linux/xmknodat.c | 23 +++++------------
 7 files changed, 86 insertions(+), 35 deletions(-)
 create mode 100644 sysdeps/unix/sysv/linux/mknod.c
 create mode 100644 sysdeps/unix/sysv/linux/mknodat.c

diff --git a/include/sys/stat.h b/include/sys/stat.h
index 87d4a5ec4f..da8b14fee0 100644
--- a/include/sys/stat.h
+++ b/include/sys/stat.h
@@ -84,6 +84,8 @@ extern __mode_t __umask (__mode_t __mask);
 extern int __mkdir (const char *__path, __mode_t __mode);
 libc_hidden_proto (__mkdir)
 
+extern int __mknodat_common (int fd, const char *, __mode_t, __dev_t *)
+  attribute_hidden;
 extern int __mknodat (int fd, const char *path, mode_t mode, dev_t dev);
 libc_hidden_proto (__mknodat);
 extern int __mknod (const char *__path,
@@ -92,10 +94,8 @@ libc_hidden_proto (__mknod);
 
 extern int __xmknod (int __ver, const char *__path, __mode_t __mode,
 		     __dev_t *__dev);
-libc_hidden_proto (__xmknod)
 extern int __xmknodat (int __ver, int __fd, const char *__path,
 		       __mode_t __mode, __dev_t *__dev);
-libc_hidden_proto (__xmknodat)
 
 int __fxstat (int __ver, int __fildes, struct stat *__stat_buf);
 int __xstat (int __ver, const char *__filename,
@@ -121,6 +121,8 @@ hidden_proto (__xstat64);
 hidden_proto (__lxstat64);
 hidden_proto (__fxstatat64);
 #  endif
+libc_hidden_proto (__xmknod)
+libc_hidden_proto (__xmknodat)
 #  define stat(fname, buf) __xstat (_STAT_VER, fname, buf)
 #  define lstat(fname, buf)  __lxstat (_STAT_VER, fname, buf)
 #  define __lstat(fname, buf)  __lxstat (_STAT_VER, fname, buf)
diff --git a/sysdeps/mach/hurd/xmknod.c b/sysdeps/mach/hurd/xmknod.c
index 0ab4f1b719..67e32f518d 100644
--- a/sysdeps/mach/hurd/xmknod.c
+++ b/sysdeps/mach/hurd/xmknod.c
@@ -30,4 +30,3 @@ __xmknod (int vers, const char *file_name, mode_t mode, dev_t *dev)
 {
   return __xmknodat (vers, AT_FDCWD, file_name, mode, dev);
 }
-libc_hidden_def (__xmknod)
diff --git a/sysdeps/mach/hurd/xmknodat.c b/sysdeps/mach/hurd/xmknodat.c
index 4239d1ea91..0333765ebc 100644
--- a/sysdeps/mach/hurd/xmknodat.c
+++ b/sysdeps/mach/hurd/xmknodat.c
@@ -116,5 +116,3 @@ __xmknodat (int vers, int fd, const char *path, mode_t mode, dev_t *dev)
     return __hurd_fail (err);
   return 0;
 }
-
-libc_hidden_def (__xmknodat)
diff --git a/sysdeps/unix/sysv/linux/mknod.c b/sysdeps/unix/sysv/linux/mknod.c
new file mode 100644
index 0000000000..3185726f52
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/mknod.c
@@ -0,0 +1,28 @@
+/* Create a special or ordinary file.  Linux version.
+   Copyright (C) 2020 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 <fcntl.h>
+
+int
+__mknod (const char *path, mode_t mode, dev_t dev)
+{
+  return __mknodat_common (AT_FDCWD, path, mode, &dev);
+}
+libc_hidden_def (__mknod)
+weak_alias (__mknod, mknod)
diff --git a/sysdeps/unix/sysv/linux/mknodat.c b/sysdeps/unix/sysv/linux/mknodat.c
new file mode 100644
index 0000000000..d160fe520b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/mknodat.c
@@ -0,0 +1,41 @@
+/* Create a special or ordinary file.  Linux version.
+   Copyright (C) 2020 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/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+
+int
+__mknodat_common (int fd, const char *path, mode_t mode, dev_t *dev)
+{
+  /* We must convert the value to dev_t type used by the kernel.  */
+  unsigned long long int k_dev = (*dev) & ((1ULL << 32) - 1);
+  if (k_dev != *dev)
+    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+
+  return INLINE_SYSCALL_CALL (mknodat, fd, path, mode,
+			      (unsigned int) k_dev);
+}
+
+int
+__mknodat (int fd, const char *path, mode_t mode, dev_t dev)
+{
+  return __mknodat_common (fd, path, mode, &dev);
+}
+libc_hidden_def (__mknodat)
+weak_alias (__mknodat, mknodat)
diff --git a/sysdeps/unix/sysv/linux/xmknod.c b/sysdeps/unix/sysv/linux/xmknod.c
index 42809d4c57..2ae384a536 100644
--- a/sysdeps/unix/sysv/linux/xmknod.c
+++ b/sysdeps/unix/sysv/linux/xmknod.c
@@ -17,29 +17,23 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <sys/stat.h>
-#include <sys/sysmacros.h>
 #include <fcntl.h>
-#include <sysdep.h>
+#include <errno.h>
+#include <shlib-compat.h>
 
+#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
 /* Create a device file named PATH, with permission and special bits MODE
    and device number DEV (which can be constructed from major and minor
    device numbers with the `makedev' macro above).  */
 int
+attribute_compat_text_section
 __xmknod (int vers, const char *path, mode_t mode, dev_t *dev)
 {
-  unsigned long long int k_dev;
-
   if (vers != _MKNOD_VER)
     return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
 
-  /* We must convert the value to dev_t type used by the kernel.  */
-  k_dev =  (*dev) & ((1ULL << 32) - 1);
-  if (k_dev != *dev)
-    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
-
-  return INLINE_SYSCALL_CALL (mknodat, AT_FDCWD, path, mode,
-			      (unsigned int) k_dev);
+  return __mknodat_common (AT_FDCWD, path, mode, dev);
 }
 
-weak_alias (__xmknod, _xmknod)
-libc_hidden_def (__xmknod)
+compat_symbol (libc, __xmknod, __xmknod, GLIBC_2_0);
+#endif
diff --git a/sysdeps/unix/sysv/linux/xmknodat.c b/sysdeps/unix/sysv/linux/xmknodat.c
index 5640a499aa..11b52a29b2 100644
--- a/sysdeps/unix/sysv/linux/xmknodat.c
+++ b/sysdeps/unix/sysv/linux/xmknodat.c
@@ -15,18 +15,11 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/sysmacros.h>
-
-#include <sysdep.h>
-#include <sys/syscall.h>
-
+#include <errno.h>
+#include <shlib-compat.h>
 
+#if SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
 /* Create a device file named PATH relative to FD, with permission and
    special bits MODE and device number DEV (which can be constructed
    from major and minor device numbers with the `makedev' macro above).  */
@@ -36,12 +29,8 @@ __xmknodat (int vers, int fd, const char *file, mode_t mode, dev_t *dev)
   if (vers != _MKNOD_VER)
     return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
 
-  /* We must convert the value to dev_t type used by the kernel.  */
-  unsigned long long int k_dev =  (*dev) & ((1ULL << 32) - 1);
-  if (k_dev != *dev)
-    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
-
-  return INLINE_SYSCALL (mknodat, 4, fd, file, mode, (unsigned int) k_dev);
+  return __mknodat_common (fd, file, mode, dev);
 }
 
-libc_hidden_def (__xmknodat)
+compat_symbol (libc, __xmknodat, __xmknodat, GLIBC_2_4);
+#endif
-- 
2.25.1


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

* Re: [PATCH 03/16] linux: Consolidate xstat{64}
  2020-07-23 19:46 ` [PATCH 03/16] linux: Consolidate xstat{64} Adhemerval Zanella via Libc-alpha
@ 2020-07-23 20:51   ` Joseph Myers
  2020-07-24  8:34   ` Lukasz Majewski
  2020-09-09 14:46   ` Lukasz Majewski
  2 siblings, 0 replies; 80+ messages in thread
From: Joseph Myers @ 2020-07-23 20:51 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Alistair Francis, libc-alpha

On Thu, 23 Jul 2020, Adhemerval Zanella via Libc-alpha wrote:

> Also the  non-LFS mips is an outlier and it has its own implementation
> since _STAT_VER_LINUX requires a different conversion function (it uses
> the kernel_stat as the syscall argument since its exported ABI is
> different than the kernel one for both non-LFS and LFS implementation).

The other key MIPS peculiarity is that n64 has struct stat and struct 
stat64 with different layout even though off_t etc. are 64-bit by default.  
And thus n64 cannot use sysdeps/unix/sysv/linux/wordsize-64 (not sure if 
any other incompatibilities prevent use of that directory).

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH 10/16] Remove mknod wrapper functions, move them to symbols
  2020-07-23 19:46 ` [PATCH 10/16] Remove mknod wrapper functions, move them to symbols Adhemerval Zanella via Libc-alpha
@ 2020-07-23 20:53   ` Joseph Myers
  2020-07-23 20:58     ` Adhemerval Zanella via Libc-alpha
  2020-07-24  9:25   ` Lukasz Majewski
  2020-10-12 22:27   ` Joseph Myers
  2 siblings, 1 reply; 80+ messages in thread
From: Joseph Myers @ 2020-07-23 20:53 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Alistair Francis, libc-alpha

On Thu, 23 Jul 2020, Adhemerval Zanella via Libc-alpha wrote:

> Both the prototypes of the internal symbol linked by the static
> wrappers and the inline redirectors are also removed from the installed
> sys/stat.h header file.  The wrapper implementation license is also
> change from LGPL to GPL.

That's not an accurate description.  The license remains LGPL with the 
exception for objects that get statically linked in when dynamically 
linking with libc (*_nonshared.a and crt*.o) removed.  Likewise for other 
patches with a similar description.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH 15/16] linux: Add {f}stat{at} y2038 support
  2020-07-23 19:46 ` [PATCH 15/16] linux: Add {f}stat{at} y2038 support Adhemerval Zanella via Libc-alpha
@ 2020-07-23 20:55   ` Joseph Myers
  2020-07-23 21:00     ` Adhemerval Zanella via Libc-alpha
  2020-07-24 10:53   ` Lukasz Majewski
  2020-10-06  9:48   ` Lukasz Majewski
  2 siblings, 1 reply; 80+ messages in thread
From: Joseph Myers @ 2020-07-23 20:55 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Alistair Francis, libc-alpha

On Thu, 23 Jul 2020, Adhemerval Zanella via Libc-alpha wrote:

> A new struct __stat{64}_t64 type is added with the required
> __timespec64 time definition.  Both non-LFS and LFS support were
> done with an extra __NR_statx call plus a conversion to the new
> __stat{64}_t64 type.  The statx call is done only for architectures
> with support for 32-bit time_t ABI.

The combination of 64-bit times with 32-bit offsets is not supposed to be 
supported (no existing glibc configuration supports such a combination); 
_TIME_BITS=64 without _FILE_OFFSET_BITS=64 should be an error.  Thus, the 
__stat_t64 type and functions shouldn't be present.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH 10/16] Remove mknod wrapper functions, move them to symbols
  2020-07-23 20:53   ` Joseph Myers
@ 2020-07-23 20:58     ` Adhemerval Zanella via Libc-alpha
  2020-07-23 21:01       ` Joseph Myers
  0 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-07-23 20:58 UTC (permalink / raw)
  To: Joseph Myers; +Cc: Alistair Francis, libc-alpha



On 23/07/2020 17:53, Joseph Myers wrote:
> On Thu, 23 Jul 2020, Adhemerval Zanella via Libc-alpha wrote:
> 
>> Both the prototypes of the internal symbol linked by the static
>> wrappers and the inline redirectors are also removed from the installed
>> sys/stat.h header file.  The wrapper implementation license is also
>> change from LGPL to GPL.
> 
> That's not an accurate description.  The license remains LGPL with the 
> exception for objects that get statically linked in when dynamically 
> linking with libc (*_nonshared.a and crt*.o) removed.  Likewise for other 
> patches with a similar description.
> 

So should we revert the License change or just rewrite the description?

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

* Re: [PATCH 15/16] linux: Add {f}stat{at} y2038 support
  2020-07-23 20:55   ` Joseph Myers
@ 2020-07-23 21:00     ` Adhemerval Zanella via Libc-alpha
  0 siblings, 0 replies; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-07-23 21:00 UTC (permalink / raw)
  To: Joseph Myers; +Cc: Alistair Francis, libc-alpha



On 23/07/2020 17:55, Joseph Myers wrote:
> On Thu, 23 Jul 2020, Adhemerval Zanella via Libc-alpha wrote:
> 
>> A new struct __stat{64}_t64 type is added with the required
>> __timespec64 time definition.  Both non-LFS and LFS support were
>> done with an extra __NR_statx call plus a conversion to the new
>> __stat{64}_t64 type.  The statx call is done only for architectures
>> with support for 32-bit time_t ABI.
> 
> The combination of 64-bit times with 32-bit offsets is not supposed to be 
> supported (no existing glibc configuration supports such a combination); 
> _TIME_BITS=64 without _FILE_OFFSET_BITS=64 should be an error.  Thus, the 
> __stat_t64 type and functions shouldn't be present.
> 

Ok, I was not sure if the plan was to enforce it, but I agree that it
does make sense.  And this simplifies the require work as well.

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

* Re: [PATCH 10/16] Remove mknod wrapper functions, move them to symbols
  2020-07-23 20:58     ` Adhemerval Zanella via Libc-alpha
@ 2020-07-23 21:01       ` Joseph Myers
  0 siblings, 0 replies; 80+ messages in thread
From: Joseph Myers @ 2020-07-23 21:01 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha, Alistair Francis

On Thu, 23 Jul 2020, Adhemerval Zanella via Libc-alpha wrote:

> On 23/07/2020 17:53, Joseph Myers wrote:
> > On Thu, 23 Jul 2020, Adhemerval Zanella via Libc-alpha wrote:
> > 
> >> Both the prototypes of the internal symbol linked by the static
> >> wrappers and the inline redirectors are also removed from the installed
> >> sys/stat.h header file.  The wrapper implementation license is also
> >> change from LGPL to GPL.
> > 
> > That's not an accurate description.  The license remains LGPL with the 
> > exception for objects that get statically linked in when dynamically 
> > linking with libc (*_nonshared.a and crt*.o) removed.  Likewise for other 
> > patches with a similar description.
> > 
> 
> So should we revert the License change or just rewrite the description?

Rewrite the description.  Once an object is no longer in *_nonshared.a (or 
crt*.o, or sources shared with libgcc in the case of soft-fp), there is no 
need for the LGPL exception and the file should be plain LGPL with no 
exception.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH 01/16] linux: Always define STAT_IS_KERNEL_STAT
  2020-07-23 19:46 ` [PATCH 01/16] linux: Always define STAT_IS_KERNEL_STAT Adhemerval Zanella via Libc-alpha
@ 2020-07-24  8:17   ` Lukasz Majewski
  0 siblings, 0 replies; 80+ messages in thread
From: Lukasz Majewski @ 2020-07-24  8:17 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Alistair Francis, libc-alpha

[-- Attachment #1: Type: text/plain, Size: 8485 bytes --]

Hi Adhemerval,

> It allows to check for its value instead of its existence.
> 
> Checked with a build for all affected ABIS.

Reviewed-by: Lukasz Majewski <lukma@denx.de>

> ---
>  sysdeps/unix/sysv/linux/alpha/kernel_stat.h             | 1 +
>  sysdeps/unix/sysv/linux/fxstat.c                        | 2 +-
>  sysdeps/unix/sysv/linux/fxstatat.c                      | 4 ++--
>  sysdeps/unix/sysv/linux/hppa/kernel_stat.h              | 1 +
>  sysdeps/unix/sysv/linux/kernel_stat.h                   | 1 +
>  sysdeps/unix/sysv/linux/lxstat.c                        | 2 +-
>  sysdeps/unix/sysv/linux/microblaze/kernel_stat.h        | 1 +
>  sysdeps/unix/sysv/linux/mips/kernel_stat.h              | 1 +
>  sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h | 1 +
>  sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h     | 1 +
>  sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h     | 1 +
>  sysdeps/unix/sysv/linux/xstat.c                         | 2 +-
>  sysdeps/unix/sysv/linux/xstatconv.c                     | 2 +-
>  sysdeps/unix/sysv/linux/xstatconv.h                     | 2 +-
>  14 files changed, 15 insertions(+), 7 deletions(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/alpha/kernel_stat.h
> b/sysdeps/unix/sysv/linux/alpha/kernel_stat.h index
> d637e099cf..9bcc96c577 100644 ---
> a/sysdeps/unix/sysv/linux/alpha/kernel_stat.h +++
> b/sysdeps/unix/sysv/linux/alpha/kernel_stat.h @@ -85,5 +85,6 @@
> struct glibc21_stat long __glibc_reserved[4];
>    };
>  
> +#define STAT_IS_KERNEL_STAT 0
>  #define XSTAT_IS_XSTAT64 1
>  #define STATFS_IS_STATFS64 0
> diff --git a/sysdeps/unix/sysv/linux/fxstat.c
> b/sysdeps/unix/sysv/linux/fxstat.c index ce474dcd47..a88404b5c3 100644
> --- a/sysdeps/unix/sysv/linux/fxstat.c
> +++ b/sysdeps/unix/sysv/linux/fxstat.c
> @@ -38,7 +38,7 @@ __fxstat (int vers, int fd, struct stat *buf)
>    if (vers == _STAT_VER_KERNEL)
>      return INLINE_SYSCALL (fstat, 2, fd, buf);
>  
> -#ifdef STAT_IS_KERNEL_STAT
> +#if STAT_IS_KERNEL_STAT
>    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
>  #else
>    struct kernel_stat kbuf;
> diff --git a/sysdeps/unix/sysv/linux/fxstatat.c
> b/sysdeps/unix/sysv/linux/fxstatat.c index 3eb898e322..937fec45c2
> 100644 --- a/sysdeps/unix/sysv/linux/fxstatat.c
> +++ b/sysdeps/unix/sysv/linux/fxstatat.c
> @@ -37,7 +37,7 @@ int
>  __fxstatat (int vers, int fd, const char *file, struct stat *st, int
> flag) {
>    int result;
> -#ifdef STAT_IS_KERNEL_STAT
> +#if STAT_IS_KERNEL_STAT
>  # define kst (*st)
>  #else
>    struct kernel_stat kst;
> @@ -46,7 +46,7 @@ __fxstatat (int vers, int fd, const char *file,
> struct stat *st, int flag) result = INTERNAL_SYSCALL_CALL
> (newfstatat, fd, file, &kst, flag); if (!__glibc_likely
> (INTERNAL_SYSCALL_ERROR_P (result))) {
> -#ifdef STAT_IS_KERNEL_STAT
> +#if STAT_IS_KERNEL_STAT
>        return 0;
>  #else
>        return __xstat_conv (vers, &kst, st);
> diff --git a/sysdeps/unix/sysv/linux/hppa/kernel_stat.h
> b/sysdeps/unix/sysv/linux/hppa/kernel_stat.h index
> a3ac53a1ef..0cbd010fc3 100644 ---
> a/sysdeps/unix/sysv/linux/hppa/kernel_stat.h +++
> b/sysdeps/unix/sysv/linux/hppa/kernel_stat.h @@ -30,5 +30,6 @@ struct
> kernel_stat { #define _HAVE_STAT_NSEC
>  #define _HAVE_STAT64_NSEC
>  
> +#define STAT_IS_KERNEL_STAT 0
>  #define XSTAT_IS_XSTAT64 0
>  #define STATFS_IS_STATFS64 0
> diff --git a/sysdeps/unix/sysv/linux/kernel_stat.h
> b/sysdeps/unix/sysv/linux/kernel_stat.h index eecc962de3..ff54a4524c
> 100644 --- a/sysdeps/unix/sysv/linux/kernel_stat.h
> +++ b/sysdeps/unix/sysv/linux/kernel_stat.h
> @@ -34,5 +34,6 @@ struct kernel_stat
>  #define _HAVE_STAT64___ST_INO
>  #define _HAVE_STAT64_NSEC
>  
> +#define STAT_IS_KERNEL_STAT 0
>  #define XSTAT_IS_XSTAT64 0
>  #define STATFS_IS_STATFS64 0
> diff --git a/sysdeps/unix/sysv/linux/lxstat.c
> b/sysdeps/unix/sysv/linux/lxstat.c index e0cfc4f1fa..dcd685873d 100644
> --- a/sysdeps/unix/sysv/linux/lxstat.c
> +++ b/sysdeps/unix/sysv/linux/lxstat.c
> @@ -37,7 +37,7 @@ __lxstat (int vers, const char *name, struct stat
> *buf) if (vers == _STAT_VER_KERNEL)
>      return INLINE_SYSCALL (lstat, 2, name, buf);
>  
> -#ifdef STAT_IS_KERNEL_STAT
> +#if STAT_IS_KERNEL_STAT
>    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
>  #else
>    struct kernel_stat kbuf;
> diff --git a/sysdeps/unix/sysv/linux/microblaze/kernel_stat.h
> b/sysdeps/unix/sysv/linux/microblaze/kernel_stat.h index
> 765e0dca67..4daaedc4b6 100644 ---
> a/sysdeps/unix/sysv/linux/microblaze/kernel_stat.h +++
> b/sysdeps/unix/sysv/linux/microblaze/kernel_stat.h @@ -48,5 +48,6 @@
> struct kernel_stat #define _HAVE_STAT64___UNUSED5
>  };
>  
> +#define STAT_IS_KERNEL_STAT 0
>  #define XSTAT_IS_XSTAT64 0
>  #define STATFS_IS_STATFS64 0
> diff --git a/sysdeps/unix/sysv/linux/mips/kernel_stat.h
> b/sysdeps/unix/sysv/linux/mips/kernel_stat.h index
> 388df1bfff..e75f3e805b 100644 ---
> a/sysdeps/unix/sysv/linux/mips/kernel_stat.h +++
> b/sysdeps/unix/sysv/linux/mips/kernel_stat.h @@ -56,5 +56,6 @@ struct
> kernel_stat };
>  #endif
>  
> +#define STAT_IS_KERNEL_STAT 0
>  #define XSTAT_IS_XSTAT64 0
>  #define STATFS_IS_STATFS64 0
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h
> b/sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h index
> c5948a4d3c..75610b8df3 100644 ---
> a/sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h +++
> b/sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h @@ -47,5
> +47,6 @@ struct kernel_stat #define _HAVE_STAT64___PAD2
>  #define _HAVE_STAT64_NSEC
>  
> +#define STAT_IS_KERNEL_STAT 0
>  #define XSTAT_IS_XSTAT64 0
>  #define STATFS_IS_STATFS64 0
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h
> b/sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h index
> a4416009f1..5c8cacaf67 100644 ---
> a/sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h +++
> b/sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h @@ -31,5 +31,6
> @@ struct kernel_stat #define _HAVE_STAT_NSEC
>  #define _HAVE_STAT64_NSEC
>  
> +#define STAT_IS_KERNEL_STAT 0
>  #define XSTAT_IS_XSTAT64 0
>  #define STATFS_IS_STATFS64 0
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h
> b/sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h index
> 30afb553b9..d14b2487ac 100644 ---
> a/sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h +++
> b/sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h @@ -44,5 +44,6
> @@ struct kernel_stat64 long int __glibc_reserved[3];
>    };
>  
> +#define STAT_IS_KERNEL_STAT 0
>  #define XSTAT_IS_XSTAT64 1
>  #define STATFS_IS_STATFS64 0
> diff --git a/sysdeps/unix/sysv/linux/xstat.c
> b/sysdeps/unix/sysv/linux/xstat.c index a93d635611..76c90e20c7 100644
> --- a/sysdeps/unix/sysv/linux/xstat.c
> +++ b/sysdeps/unix/sysv/linux/xstat.c
> @@ -37,7 +37,7 @@ __xstat (int vers, const char *name, struct stat
> *buf) if (vers == _STAT_VER_KERNEL)
>      return INLINE_SYSCALL (stat, 2, name, buf);
>  
> -#ifdef STAT_IS_KERNEL_STAT
> +#if STAT_IS_KERNEL_STAT
>    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
>  #else
>    struct kernel_stat kbuf;
> diff --git a/sysdeps/unix/sysv/linux/xstatconv.c
> b/sysdeps/unix/sysv/linux/xstatconv.c index c01fb00a3a..3622a82cd0
> 100644 --- a/sysdeps/unix/sysv/linux/xstatconv.c
> +++ b/sysdeps/unix/sysv/linux/xstatconv.c
> @@ -20,7 +20,7 @@
>  #include <sys/stat.h>
>  #include <kernel_stat.h>
>  
> -#ifdef STAT_IS_KERNEL_STAT
> +#if STAT_IS_KERNEL_STAT
>  
>  /* Dummy.  */
>  struct kernel_stat;
> diff --git a/sysdeps/unix/sysv/linux/xstatconv.h
> b/sysdeps/unix/sysv/linux/xstatconv.h index 39102c9469..5319236cae
> 100644 --- a/sysdeps/unix/sysv/linux/xstatconv.h
> +++ b/sysdeps/unix/sysv/linux/xstatconv.h
> @@ -16,7 +16,7 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -#ifndef STAT_IS_KERNEL_STAT
> +#if !STAT_IS_KERNEL_STAT
>  extern int __xstat_conv (int vers, struct kernel_stat *kbuf, void
> *ubuf) attribute_hidden;
>  extern int __xstat64_conv (int vers, struct kernel_stat *kbuf, void
> *ubuf)




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 02/16] linux: Define STAT64_IS_KERNEL_STAT64
  2020-07-23 19:46 ` [PATCH 02/16] linux: Define STAT64_IS_KERNEL_STAT64 Adhemerval Zanella via Libc-alpha
@ 2020-07-24  8:20   ` Lukasz Majewski
  0 siblings, 0 replies; 80+ messages in thread
From: Lukasz Majewski @ 2020-07-24  8:20 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Alistair Francis, libc-alpha

[-- Attachment #1: Type: text/plain, Size: 8292 bytes --]

On Thu, 23 Jul 2020 16:46:27 -0300
Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> It indicates that the glibc export stat64 is similar in size and
> layout of the kernel stat64 used on the syscall.  It is not currently
> used on stat implementation, but the idea is to indicate whether
> to use the kernel_stat to issue on the syscall on the *stat*64
> variant (more specifically on mips which its exported ABI does not
> match the kernel).

Reviewed-by: Lukasz Majewski <lukma@denx.de>

> ---
>  sysdeps/unix/sysv/linux/alpha/kernel_stat.h             | 1 +
>  sysdeps/unix/sysv/linux/arc/kernel_stat.h               | 1 +
>  sysdeps/unix/sysv/linux/hppa/kernel_stat.h              | 1 +
>  sysdeps/unix/sysv/linux/ia64/kernel_stat.h              | 1 +
>  sysdeps/unix/sysv/linux/kernel_stat.h                   | 1 +
>  sysdeps/unix/sysv/linux/microblaze/kernel_stat.h        | 1 +
>  sysdeps/unix/sysv/linux/mips/kernel_stat.h              | 6 ++++++
>  sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h | 1 +
>  sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h | 1 +
>  sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h      | 1 +
>  sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h     | 1 +
>  sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h     | 6 ++++++
>  sysdeps/unix/sysv/linux/x86_64/kernel_stat.h            | 1 +
>  13 files changed, 23 insertions(+)
> 
> diff --git a/sysdeps/unix/sysv/linux/alpha/kernel_stat.h
> b/sysdeps/unix/sysv/linux/alpha/kernel_stat.h index
> 9bcc96c577..ff69045f8f 100644 ---
> a/sysdeps/unix/sysv/linux/alpha/kernel_stat.h +++
> b/sysdeps/unix/sysv/linux/alpha/kernel_stat.h @@ -86,5 +86,6 @@
> struct glibc21_stat };
>  
>  #define STAT_IS_KERNEL_STAT 0
> +#define STAT64_IS_KERNEL_STAT64 1
>  #define XSTAT_IS_XSTAT64 1
>  #define STATFS_IS_STATFS64 0
> diff --git a/sysdeps/unix/sysv/linux/arc/kernel_stat.h
> b/sysdeps/unix/sysv/linux/arc/kernel_stat.h index
> 8fdd86b9e8..fd9b113f45 100644 ---
> a/sysdeps/unix/sysv/linux/arc/kernel_stat.h +++
> b/sysdeps/unix/sysv/linux/arc/kernel_stat.h @@ -19,6 +19,7 @@
>  
>  /* 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
> diff --git a/sysdeps/unix/sysv/linux/hppa/kernel_stat.h
> b/sysdeps/unix/sysv/linux/hppa/kernel_stat.h index
> 0cbd010fc3..e8ad135e70 100644 ---
> a/sysdeps/unix/sysv/linux/hppa/kernel_stat.h +++
> b/sysdeps/unix/sysv/linux/hppa/kernel_stat.h @@ -31,5 +31,6 @@ struct
> kernel_stat { #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 index
> b38bf741d3..c96a0589dc 100644 ---
> a/sysdeps/unix/sysv/linux/ia64/kernel_stat.h +++
> b/sysdeps/unix/sysv/linux/ia64/kernel_stat.h @@ -17,5 +17,6 @@
>     <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 0
> diff --git a/sysdeps/unix/sysv/linux/kernel_stat.h
> b/sysdeps/unix/sysv/linux/kernel_stat.h index ff54a4524c..b1bc1459f0
> 100644 --- a/sysdeps/unix/sysv/linux/kernel_stat.h
> +++ b/sysdeps/unix/sysv/linux/kernel_stat.h
> @@ -35,5 +35,6 @@ struct kernel_stat
>  #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/microblaze/kernel_stat.h
> b/sysdeps/unix/sysv/linux/microblaze/kernel_stat.h index
> 4daaedc4b6..9ab1e50115 100644 ---
> a/sysdeps/unix/sysv/linux/microblaze/kernel_stat.h +++
> b/sysdeps/unix/sysv/linux/microblaze/kernel_stat.h @@ -49,5 +49,6 @@
> struct kernel_stat };
>  
>  #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/mips/kernel_stat.h
> b/sysdeps/unix/sysv/linux/mips/kernel_stat.h index
> e75f3e805b..21dba2de73 100644 ---
> a/sysdeps/unix/sysv/linux/mips/kernel_stat.h +++
> b/sysdeps/unix/sysv/linux/mips/kernel_stat.h @@ -1,3 +1,6 @@
> +#ifndef _KERNEL_STAT_H
> +#define _KERNEL_STAT_H
> +
>  #include <sgidefs.h>
>  /* As tempting as it is to define XSTAT_IS_XSTAT64 for n64, the
>     userland data structures are not identical, because of different
> @@ -57,5 +60,8 @@ struct kernel_stat
>  #endif
>  
>  #define STAT_IS_KERNEL_STAT 0
> +#define STAT64_IS_KERNEL_STAT64 0
>  #define XSTAT_IS_XSTAT64 0
>  #define STATFS_IS_STATFS64 0
> +
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h
> b/sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h index
> 75610b8df3..5757e65f8e 100644 ---
> a/sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h +++
> b/sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h @@ -48,5
> +48,6 @@ struct kernel_stat #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/powerpc/powerpc64/kernel_stat.h
> b/sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h index
> 5c10da3356..9f11b69e4f 100644 ---
> a/sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h +++
> b/sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h @@ -17,5
> +17,6 @@ <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 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 index
> b38bf741d3..c96a0589dc 100644 ---
> a/sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h +++
> b/sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h @@ -17,5 +17,6 @@
>     <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 0
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h
> b/sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h index
> 5c8cacaf67..4a2df42d37 100644 ---
> a/sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h +++
> b/sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h @@ -32,5 +32,6
> @@ struct kernel_stat #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/sparc/sparc64/kernel_stat.h
> b/sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h index
> d14b2487ac..0f3d405239 100644 ---
> a/sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h +++
> b/sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h @@ -1,3 +1,6 @@
> +#ifndef _KERNEL_STAT_H
> +#define _KERNEL_STAT_H
> +
>  /* Definition of `struct stat' used in the kernel */
>  struct kernel_stat
>    {
> @@ -45,5 +48,8 @@ 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
> +
> +#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
> b38bf741d3..c96a0589dc 100644 ---
> a/sysdeps/unix/sysv/linux/x86_64/kernel_stat.h +++
> b/sysdeps/unix/sysv/linux/x86_64/kernel_stat.h @@ -17,5 +17,6 @@
>     <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 0




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 03/16] linux: Consolidate xstat{64}
  2020-07-23 19:46 ` [PATCH 03/16] linux: Consolidate xstat{64} Adhemerval Zanella via Libc-alpha
  2020-07-23 20:51   ` Joseph Myers
@ 2020-07-24  8:34   ` Lukasz Majewski
  2020-09-09 14:46   ` Lukasz Majewski
  2 siblings, 0 replies; 80+ messages in thread
From: Lukasz Majewski @ 2020-07-24  8:34 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Alistair Francis, libc-alpha

[-- Attachment #1: Type: text/plain, Size: 30442 bytes --]

On Thu, 23 Jul 2020 16:46:28 -0300
Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> The LFS support is implemented on xstat64.c, instead of xstat.c for
> 64-bit architectures.  The xstat.c implements the non-LFS it is
> no-op for !XSTAT_IS_XSTAT64.
> 
> The generic non-LFS implementation handle two cases:
> 
>   1. New kABIs which uses generic pre 64-bit time Linux ABI (csky and
>      nios): it issues __NR_fstat64 plus handle the overflow on st_ino,
>      st_size, or st_blocks.  It only handles _STAT_VER_KERNEL.
> 
>   2. Old KABIs with old non-LFS support (arm, i386, hppa, m68k,
>      microblaze, s390, sh, powerpc, and sparc32).  For
> _STAT_VER_KERNEL it issues __NR_stat, otherwise it issues __NR_stat64
> and convert to non-LFS stat struct handling possible overflows on
> st_ino, st_size, or st_blocks.
> 
> Also the  non-LFS mips is an outlier and it has its own implementation
> since _STAT_VER_LINUX requires a different conversion function (it
> uses the kernel_stat as the syscall argument since its exported ABI is
> different than the kernel one for both non-LFS and LFS
> implementation).
> 
> The generic LFS implementation handles multiple cases:
> 
>   1. XSTAT_IS_XSTAT64 being 1:
> 
>     1.1. Old 64-bit kABI (ia64, powerpc64*, s390x, sparc64, x86_64):
> it issues __NR_stat for _STAT_VER_KERNEL or _STAT_VER_LINUX.
> 
>     1.2. New kABIs which uses generic 64-bit Linux ABI (aarch64 and
>          riscv64): it issues __NR_newfstatat and only for
>          _STAT_VER_KERNEL.
> 
>     1.3. New 32-bit kABIs with only 64-bit time_t support (arc and
> 	 riscv32): it issues __NR_statx and covert to struct stat64.
> 
>   2. Old ABIs with XSTAT_IS_XSTAT64 being 0:
> 
>     2.1. New kABIs which uses generic pre 64-bit time Linux ABI (csky
> 	 and nios2): it issues __NR_fstatat64 for _STAT_VER_KERNEL.
> 
>     2.2. Old kABIs with old non-LFS support (arm, i386, hppa, m68k,
> 	 microblaze, s390, sh, mips32, powerpc32, and sparc32): it
> 	 issues __NR_stat64.
> 
> Also, two special cases requires specific LFS implementations:
> 
>   1. alpha: it requires to handle _STAT_VER_KERNEL64 to call
> __NR_stat64 or use the kernel_stat with __NR_stat otherwise.
> 
>   2. mips64: as for non-LFS implementation its ABIs differ from glibc
>      exported one, which requires an specific conversion function to
>      handle the kernel_stat.
> 
> Checked with a build for all affected ABIs. I also checked on x86_64,
> i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and s390x.

Reviewed-by: Lukasz Majewski <lukma@denx.de>

> ---
>  sysdeps/unix/sysv/linux/alpha/xstat.c         | 57 ----------------
>  .../{generic/xstat.c => alpha/xstat64.c}      | 47 ++++++-------
>  sysdeps/unix/sysv/linux/arm/xstat.c           |  1 -
>  .../sysv/linux/generic/wordsize-32/xstat.c    | 54 ---------------
>  .../sysv/linux/generic/wordsize-32/xstat64.c  | 63 -----------------
>  sysdeps/unix/sysv/linux/hppa/xstat.c          |  1 -
>  sysdeps/unix/sysv/linux/i386/xstat.c          | 59 ----------------
>  sysdeps/unix/sysv/linux/m68k/xstat.c          |  1 -
>  sysdeps/unix/sysv/linux/microblaze/xstat.c    |  1 -
>  sysdeps/unix/sysv/linux/mips/mips64/xstat64.c | 16 +----
>  .../sysv/linux/{wordsize-64 => mips}/xstat.c  | 32 +++++----
>  .../unix/sysv/linux/powerpc/powerpc32/xstat.c |  1 -
>  sysdeps/unix/sysv/linux/s390/s390-32/xstat.c  |  1 -
>  sysdeps/unix/sysv/linux/sh/xstat.c            |  1 -
>  sysdeps/unix/sysv/linux/sparc/sparc32/xstat.c |  1 -
>  sysdeps/unix/sysv/linux/sparc/sparc64/xstat.c |  1 -
>  sysdeps/unix/sysv/linux/wordsize-64/xstat64.c |  1 -
>  sysdeps/unix/sysv/linux/xstat.c               | 60 +++++++++--------
>  sysdeps/unix/sysv/linux/xstat64.c             | 51 ++++++++++++--
>  sysdeps/unix/sysv/linux/xstatover.h           | 67
> +++++++++++++++++++ 20 files changed, 184 insertions(+), 332
> deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/alpha/xstat.c
>  rename sysdeps/unix/sysv/linux/{generic/xstat.c => alpha/xstat64.c}
> (57%) delete mode 100644 sysdeps/unix/sysv/linux/arm/xstat.c
>  delete mode 100644
> sysdeps/unix/sysv/linux/generic/wordsize-32/xstat.c delete mode
> 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/xstat64.c delete
> mode 100644 sysdeps/unix/sysv/linux/hppa/xstat.c delete mode 100644
> sysdeps/unix/sysv/linux/i386/xstat.c delete mode 100644
> sysdeps/unix/sysv/linux/m68k/xstat.c delete mode 100644
> sysdeps/unix/sysv/linux/microblaze/xstat.c rename
> sysdeps/unix/sysv/linux/{wordsize-64 => mips}/xstat.c (67%) delete
> mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/xstat.c delete
> mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/xstat.c delete mode
> 100644 sysdeps/unix/sysv/linux/sh/xstat.c delete mode 100644
> sysdeps/unix/sysv/linux/sparc/sparc32/xstat.c delete mode 100644
> sysdeps/unix/sysv/linux/sparc/sparc64/xstat.c delete mode 100644
> sysdeps/unix/sysv/linux/wordsize-64/xstat64.c create mode 100644
> sysdeps/unix/sysv/linux/xstatover.h
> 
> diff --git a/sysdeps/unix/sysv/linux/alpha/xstat.c
> b/sysdeps/unix/sysv/linux/alpha/xstat.c deleted file mode 100644
> index 3ba1ae1811..0000000000
> --- a/sysdeps/unix/sysv/linux/alpha/xstat.c
> +++ /dev/null
> @@ -1,57 +0,0 @@
> -/* xstat using old-style Unix stat system call.
> -   Copyright (C) 2004-2020 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 __xstat64 __xstat64_disable
> -
> -#include <errno.h>
> -#include <stddef.h>
> -#include <sys/stat.h>
> -#include <kernel_stat.h>
> -#include <sysdep.h>
> -#include <sys/syscall.h>
> -#include <xstatconv.h>
> -
> -#undef __xstat64
> -
> -
> -/* Get information about the file NAME in BUF.  */
> -int
> -__xstat (int vers, const char *name, struct stat *buf)
> -{
> -  int result;
> -  struct kernel_stat kbuf;
> -
> -  if (vers == _STAT_VER_KERNEL64)
> -    {
> -      result = INTERNAL_SYSCALL_CALL (stat64, name, buf);
> -      if (__glibc_likely (!INTERNAL_SYSCALL_ERROR_P (result)))
> -	return result;
> -      __set_errno (INTERNAL_SYSCALL_ERRNO (result));
> -      return -1;
> -    }
> -
> -  result = INTERNAL_SYSCALL_CALL (stat, name, &kbuf);
> -  if (__glibc_likely (!INTERNAL_SYSCALL_ERROR_P (result)))
> -    return __xstat_conv (vers, &kbuf, buf);
> -  __set_errno (INTERNAL_SYSCALL_ERRNO (result));
> -  return -1;
> -}
> -hidden_def (__xstat)
> -weak_alias (__xstat, _xstat);
> -strong_alias (__xstat, __xstat64);
> -hidden_ver (__xstat, __xstat64)
> diff --git a/sysdeps/unix/sysv/linux/generic/xstat.c
> b/sysdeps/unix/sysv/linux/alpha/xstat64.c similarity index 57%
> rename from sysdeps/unix/sysv/linux/generic/xstat.c
> rename to sysdeps/unix/sysv/linux/alpha/xstat64.c
> index 2eb27a6f91..ac1af53780 100644
> --- a/sysdeps/unix/sysv/linux/generic/xstat.c
> +++ b/sysdeps/unix/sysv/linux/alpha/xstat64.c
> @@ -1,6 +1,6 @@
> -/* Copyright (C) 2011-2020 Free Software Foundation, Inc.
> +/* xstat using old-style Unix stat system call.
> +   Copyright (C) 2004-2020 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,33 +16,34 @@
>     License along with the GNU C Library.  If not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -/* Ignore prototype to avoid error if we alias __xstat and
> __xstat64. */ -#define __xstat64 __xstat64_disable
> -
> -#include <errno.h>
> -#include <stddef.h>
> -#include <fcntl.h>
> +#define __xstat __redirect___xstat
>  #include <sys/stat.h>
> +#undef __xstat
> +#include <fcntl.h>
>  #include <kernel_stat.h>
> -
>  #include <sysdep.h>
> -#include <sys/syscall.h>
> +#include <xstatconv.h>
>  
>  /* Get information about the file NAME in BUF.  */
>  int
> -__xstat (int vers, const char *name, struct stat *buf)
> +__xstat64 (int vers, const char *name, struct stat64 *buf)
>  {
> -  if (vers == _STAT_VER_KERNEL)
> -    return INLINE_SYSCALL (newfstatat, 4, AT_FDCWD, name, buf, 0);
> -
> -  errno = EINVAL;
> -  return -1;
> +  switch (vers)
> +    {
> +    case _STAT_VER_KERNEL64:
> +      return INLINE_SYSCALL_CALL (stat64, name, buf);
> +
> +    default:
> +      {
> +        struct kernel_stat kbuf;
> +	int r = INTERNAL_SYSCALL_CALL (stat, name, &kbuf);
> +	if (r == 0)
> +	  return __xstat_conv (vers, &kbuf, buf);
> +	return INLINE_SYSCALL_ERROR_RETURN_VALUE (-r);
> +      }
> +    }
>  }
> +weak_alias (__xstat64, __xstat);
> +weak_alias (__xstat64, __GI___xstat);
>  
> -hidden_def (__xstat)
> -weak_alias (__xstat, _xstat);
> -#if XSTAT_IS_XSTAT64
> -#undef __xstat64
> -strong_alias (__xstat, __xstat64);
> -hidden_ver (__xstat, __xstat64)
> -#endif
> +hidden_def (__xstat64)
> diff --git a/sysdeps/unix/sysv/linux/arm/xstat.c
> b/sysdeps/unix/sysv/linux/arm/xstat.c deleted file mode 100644
> index e9869f5508..0000000000
> --- a/sysdeps/unix/sysv/linux/arm/xstat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/xstat.c>
> diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/xstat.c
> b/sysdeps/unix/sysv/linux/generic/wordsize-32/xstat.c deleted file
> mode 100644 index a4a921c1ea..0000000000
> --- a/sysdeps/unix/sysv/linux/generic/wordsize-32/xstat.c
> +++ /dev/null
> @@ -1,54 +0,0 @@
> -/* Copyright (C) 2011-2020 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 <errno.h>
> -#include <stddef.h>
> -#include <fcntl.h>
> -#include <sys/stat.h>
> -#include <kernel_stat.h>
> -
> -#include <sysdep.h>
> -#include <sys/syscall.h>
> -
> -#if !XSTAT_IS_XSTAT64
> -#include "overflow.h"
> -#include <statx_cp.h>
> -
> -/* Get information about the file NAME in BUF.  */
> -int
> -__xstat (int vers, const char *name, struct stat *buf)
> -{
> -  if (vers == _STAT_VER_KERNEL)
> -    {
> -# ifdef __NR_fstatat64
> -      int rc = INLINE_SYSCALL (fstatat64, 4, AT_FDCWD, name, buf, 0);
> -# else
> -      struct statx tmp;
> -      int rc = INLINE_SYSCALL (statx, 5, AT_FDCWD, name,
> AT_NO_AUTOMOUNT,
> -                               STATX_BASIC_STATS, &tmp);
> -      if (rc == 0)
> -        __cp_stat64_statx ((struct stat64 *)buf, &tmp);
> -# endif
> -      return rc ?: stat_overflow (buf);
> -    }
> -
> -  errno = EINVAL;
> -  return -1;
> -}
> -hidden_def (__xstat)
> -#endif
> diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/xstat64.c
> b/sysdeps/unix/sysv/linux/generic/wordsize-32/xstat64.c deleted file
> mode 100644 index 0848b5a4b4..0000000000
> --- a/sysdeps/unix/sysv/linux/generic/wordsize-32/xstat64.c
> +++ /dev/null
> @@ -1,63 +0,0 @@
> -/* Copyright (C) 2011-2020 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/>.  */
> -
> -/* Hide the prototype for __xstat so that GCC will not complain about
> -   the different function signature if it is aliased to  __xstat64.
> -   If XSTAT_IS_XSTAT64 is set to non-zero then the stat and stat64
> -   structures have an identical layout but different type names.  */
> -
> -#define __xstat __xstat_disable
> -
> -#include <errno.h>
> -#include <stddef.h>
> -#include <fcntl.h>
> -#include <sys/stat.h>
> -#include <kernel_stat.h>
> -
> -#include <sysdep.h>
> -#include <sys/syscall.h>
> -
> -#include <statx_cp.h>
> -
> -/* Get information about the file NAME in BUF.  */
> -int
> -__xstat64 (int vers, const char *name, struct stat64 *buf)
> -{
> -  if (vers == _STAT_VER_KERNEL)
> -    {
> -#ifdef __NR_fstatat64
> -      return INLINE_SYSCALL (fstatat64, 4, AT_FDCWD, name, buf, 0);
> -#else
> -      struct statx tmp;
> -      int rc = INLINE_SYSCALL (statx, 5, AT_FDCWD, name,
> AT_NO_AUTOMOUNT,
> -                               STATX_BASIC_STATS, &tmp);
> -      if (rc == 0)
> -        __cp_stat64_statx (buf, &tmp);
> -      return rc;
> -#endif
> -    }
> -  errno = EINVAL;
> -  return -1;
> -}
> -hidden_def (__xstat64)
> -
> -#undef __xstat
> -#if XSTAT_IS_XSTAT64
> -strong_alias (__xstat64, __xstat)
> -hidden_ver (__xstat64, __xstat)
> -#endif
> diff --git a/sysdeps/unix/sysv/linux/hppa/xstat.c
> b/sysdeps/unix/sysv/linux/hppa/xstat.c deleted file mode 100644
> index e9869f5508..0000000000
> --- a/sysdeps/unix/sysv/linux/hppa/xstat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/xstat.c>
> diff --git a/sysdeps/unix/sysv/linux/i386/xstat.c
> b/sysdeps/unix/sysv/linux/i386/xstat.c deleted file mode 100644
> index 96f67168ac..0000000000
> --- a/sysdeps/unix/sysv/linux/i386/xstat.c
> +++ /dev/null
> @@ -1,59 +0,0 @@
> -/* xstat using old-style Unix stat system call.
> -   Copyright (C) 1991-2020 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/>.  */
> -
> -/* Ho hum, if xstat == xstat64 we must get rid of the prototype or
> gcc
> -   will complain since they don't strictly match.  */
> -#define __xstat64 __xstat64_disable
> -
> -#include <errno.h>
> -#include <stddef.h>
> -#include <sys/stat.h>
> -#include <kernel_stat.h>
> -
> -#include <sysdep.h>
> -#include <sys/syscall.h>
> -
> -#include <xstatconv.h>
> -
> -
> -/* Get information about the file NAME in BUF.  */
> -int
> -__xstat (int vers, const char *name, struct stat *buf)
> -{
> -  int result;
> -
> -  if (vers == _STAT_VER_KERNEL)
> -    return INLINE_SYSCALL (stat, 2, name, buf);
> -
> -  {
> -    struct stat64 buf64;
> -
> -    result = INTERNAL_SYSCALL_CALL (stat64, name, &buf64);
> -    if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result)))
> -      return INLINE_SYSCALL_ERROR_RETURN_VALUE
> (INTERNAL_SYSCALL_ERRNO (result));
> -    else
> -      return __xstat32_conv (vers, &buf64, buf);
> -  }
> -}
> -hidden_def (__xstat)
> -weak_alias (__xstat, _xstat);
> -#if XSTAT_IS_XSTAT64
> -# undef __xstat64
> -strong_alias (__xstat, __xstat64);
> -hidden_ver (__xstat, __xstat64)
> -#endif
> diff --git a/sysdeps/unix/sysv/linux/m68k/xstat.c
> b/sysdeps/unix/sysv/linux/m68k/xstat.c deleted file mode 100644
> index e9869f5508..0000000000
> --- a/sysdeps/unix/sysv/linux/m68k/xstat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/xstat.c>
> diff --git a/sysdeps/unix/sysv/linux/microblaze/xstat.c
> b/sysdeps/unix/sysv/linux/microblaze/xstat.c deleted file mode 100644
> index e9869f5508..0000000000
> --- a/sysdeps/unix/sysv/linux/microblaze/xstat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/xstat.c>
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/xstat64.c
> b/sysdeps/unix/sysv/linux/mips/mips64/xstat64.c index
> 7eee9e67d4..99b03c7593 100644 ---
> a/sysdeps/unix/sysv/linux/mips/mips64/xstat64.c +++
> b/sysdeps/unix/sysv/linux/mips/mips64/xstat64.c @@ -1,4 +1,4 @@
> -/* xstat64 using 64-bit MIPS stat system call.
> +/* xstat64 using Linux stat64 system call.
>     Copyright (C) 1991-2020 Free Software Foundation, Inc.
>     This file is part of the GNU C Library.
>  
> @@ -16,14 +16,9 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -#include <errno.h>
> -#include <stddef.h>
>  #include <sys/stat.h>
>  #include <kernel_stat.h>
> -
>  #include <sysdep.h>
> -#include <sys/syscall.h>
> -
>  #include <xstatconv.h>
>  
>  /* Get information about the file NAME in BUF.  */
> @@ -31,14 +26,9 @@
>  int
>  __xstat64 (int vers, const char *name, struct stat64 *buf)
>  {
> -  int result;
>    struct kernel_stat kbuf;
> -
> -  result = INLINE_SYSCALL (stat, 2, name, &kbuf);
> -  if (result == 0)
> -    result = __xstat64_conv (vers, &kbuf, buf);
> -
> -  return result;
> +  int r = INLINE_SYSCALL_CALL (stat, name, &kbuf);
> +  return r ?: __xstat64_conv (vers, &kbuf, buf);
>  }
>  
>  hidden_def (__xstat64)
> diff --git a/sysdeps/unix/sysv/linux/wordsize-64/xstat.c
> b/sysdeps/unix/sysv/linux/mips/xstat.c similarity index 67%
> rename from sysdeps/unix/sysv/linux/wordsize-64/xstat.c
> rename to sysdeps/unix/sysv/linux/mips/xstat.c
> index 438d54d291..835691cf89 100644
> --- a/sysdeps/unix/sysv/linux/wordsize-64/xstat.c
> +++ b/sysdeps/unix/sysv/linux/mips/xstat.c
> @@ -16,29 +16,27 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -/* Ho hum, since xstat == xstat64 we must get rid of the prototype
> or gcc
> -   will complain since they don't strictly match.  */
> -#define __xstat64 __xstat64_disable
> -
> -#include <errno.h>
> -#include <stddef.h>
>  #include <sys/stat.h>
> -
> +#include <fcntl.h>
> +#include <kernel_stat.h>
>  #include <sysdep.h>
> -#include <sys/syscall.h>
> +#include <xstatconv.h>
>  
>  /* Get information about the file NAME in BUF.  */
>  int
>  __xstat (int vers, const char *name, struct stat *buf)
>  {
> -  if (vers == _STAT_VER_KERNEL || vers == _STAT_VER_LINUX)
> -    return INLINE_SYSCALL (stat, 2, name, buf);
> -
> -  __set_errno (EINVAL);
> -  return -1;
> +  switch (vers)
> +    {
> +    case _STAT_VER_KERNEL:
> +      return INLINE_SYSCALL_CALL (stat, name, buf);
> +
> +    default:
> +      {
> +	struct kernel_stat kbuf;
> +	int r = INTERNAL_SYSCALL_CALL (stat, name, &kbuf);
> +	return r ?: __xstat_conv (vers, &kbuf, buf);
> +      }
> +    }
>  }
>  hidden_def (__xstat)
> -weak_alias (__xstat, _xstat);
> -#undef __xstat64
> -strong_alias (__xstat, __xstat64);
> -hidden_ver (__xstat, __xstat64)
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/xstat.c
> b/sysdeps/unix/sysv/linux/powerpc/powerpc32/xstat.c deleted file mode
> 100644 index e9869f5508..0000000000
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/xstat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/xstat.c>
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/xstat.c
> b/sysdeps/unix/sysv/linux/s390/s390-32/xstat.c deleted file mode
> 100644 index e9869f5508..0000000000
> --- a/sysdeps/unix/sysv/linux/s390/s390-32/xstat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/xstat.c>
> diff --git a/sysdeps/unix/sysv/linux/sh/xstat.c
> b/sysdeps/unix/sysv/linux/sh/xstat.c deleted file mode 100644
> index e9869f5508..0000000000
> --- a/sysdeps/unix/sysv/linux/sh/xstat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/xstat.c>
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/xstat.c
> b/sysdeps/unix/sysv/linux/sparc/sparc32/xstat.c deleted file mode
> 100644 index e9869f5508..0000000000
> --- a/sysdeps/unix/sysv/linux/sparc/sparc32/xstat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/xstat.c>
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/xstat.c
> b/sysdeps/unix/sysv/linux/sparc/sparc64/xstat.c deleted file mode
> 100644 index c3b00cb1d4..0000000000
> --- a/sysdeps/unix/sysv/linux/sparc/sparc64/xstat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include "../../i386/xstat.c"
> diff --git a/sysdeps/unix/sysv/linux/wordsize-64/xstat64.c
> b/sysdeps/unix/sysv/linux/wordsize-64/xstat64.c deleted file mode
> 100644 index e7acd3b45e..0000000000
> --- a/sysdeps/unix/sysv/linux/wordsize-64/xstat64.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -/* xstat64 is in xstat.c */
> diff --git a/sysdeps/unix/sysv/linux/xstat.c
> b/sysdeps/unix/sysv/linux/xstat.c index 76c90e20c7..0ae52b1901 100644
> --- a/sysdeps/unix/sysv/linux/xstat.c
> +++ b/sysdeps/unix/sysv/linux/xstat.c
> @@ -16,44 +16,46 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -/* Ho hum, if xstat == xstat64 we must get rid of the prototype or
> gcc
> -   will complain since they don't strictly match.  */
> -#define __xstat64 __xstat64_disable
> -
> -#include <errno.h>
> -#include <stddef.h>
>  #include <sys/stat.h>
> +#include <fcntl.h>
>  #include <kernel_stat.h>
> -
>  #include <sysdep.h>
> -#include <sys/syscall.h>
>  
> -#include <xstatconv.h>
> +#if !XSTAT_IS_XSTAT64
> +# include <xstatconv.h>
> +# include <xstatover.h>
>  
>  /* Get information about the file NAME in BUF.  */
>  int
>  __xstat (int vers, const char *name, struct stat *buf)
>  {
> -  if (vers == _STAT_VER_KERNEL)
> -    return INLINE_SYSCALL (stat, 2, name, buf);
> -
> -#if STAT_IS_KERNEL_STAT
> -  return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
> -#else
> -  struct kernel_stat kbuf;
> -  int result;
> -
> -  result = INLINE_SYSCALL (stat, 2, name, &kbuf);
> -  if (result == 0)
> -    result = __xstat_conv (vers, &kbuf, buf);
> -
> -  return result;
> +  switch (vers)
> +    {
> +    case _STAT_VER_KERNEL:
> +      {
> +# if STAT_IS_KERNEL_STAT
> +	/* New kABIs which uses generic pre 64-bit time Linux ABI,
> +	   e.g. csky, nios2  */
> +	int r = INLINE_SYSCALL_CALL (fstatat64, AT_FDCWD, name, buf,
> 0);
> +	return r ?: stat_overflow (buf);
> +# else
> +	/* Old kABIs with old non-LFS support, e.g. arm, i386, hppa,
> m68k,
> +	   microblaze, s390, sh, powerpc, and sparc32.  */
> +	return INLINE_SYSCALL_CALL (stat, name, buf);
> +# endif
> +      }
> +
> +    default:
> +      {
> +# if STAT_IS_KERNEL_STAT
> +	return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
> +# else
> +	struct stat64 buf64;
> +	int r = INLINE_SYSCALL_CALL (stat64, name, &buf64);
> +	return r ?: __xstat32_conv (vers, &buf64, buf);
>  #endif
> +      }
> +    }
>  }
>  hidden_def (__xstat)
> -weak_alias (__xstat, _xstat);
> -#if XSTAT_IS_XSTAT64
> -#undef __xstat64
> -strong_alias (__xstat, __xstat64);
> -hidden_ver (__xstat, __xstat64)
> -#endif
> +#endif /* XSTAT_IS_XSTAT64  */
> diff --git a/sysdeps/unix/sysv/linux/xstat64.c
> b/sysdeps/unix/sysv/linux/xstat64.c index 16c6e69710..4feb55f429
> 100644 --- a/sysdeps/unix/sysv/linux/xstat64.c
> +++ b/sysdeps/unix/sysv/linux/xstat64.c
> @@ -16,24 +16,61 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -#include <errno.h>
> -#include <stddef.h>
> +#define __xstat __redirect___xstat
>  #include <sys/stat.h>
> +#undef __xstat
> +#include <fcntl.h>
>  #include <kernel_stat.h>
> -
>  #include <sysdep.h>
> -#include <sys/syscall.h>
> +#include <xstatconv.h>
> +#include <statx_cp.h>
>  
>  /* Get information about the file NAME in BUF.  */
>  
>  int
>  ___xstat64 (int vers, const char *name, struct stat64 *buf)
>  {
> -  int result;
> -  result = INLINE_SYSCALL (stat64, 2, name, buf);
> -  return result;
> +#if XSTAT_IS_XSTAT64
> +# if defined __NR_stat
> +  /* Old 64-bit kABI, e.g. ia64, powerpc64*, s390x, sparc64, x86_64.
>  */
> +  if (vers == _STAT_VER_KERNEL || vers == _STAT_VER_LINUX)
> +    return INLINE_SYSCALL_CALL (stat, name, buf);
> +# elif defined __NR_newfstatat
> +  /* New kABIs which uses generic 64-bit Linux ABI, e.g. aarch64,
> riscv64.  */
> +  if (vers == _STAT_VER_KERNEL)
> +    return INLINE_SYSCALL_CALL (newfstatat, AT_FDCWD, name, buf, 0);
> +# else
> +  /* New 32-bit kABIs with only 64-bit time_t support, e.g. arc,
> riscv32.  */
> +  if (vers == _STAT_VER_KERNEL)
> +    {
> +      struct statx tmp;
> +      int r = INLINE_SYSCALL_CALL (statx, AT_FDCWD, name,
> AT_NO_AUTOMOUNT,
> +				   STATX_BASIC_STATS, &tmp);
> +      if (r == 0)
> +	__cp_stat64_statx (buf, &tmp);
> +      return r;
> +     }
> +# endif
> +#else
> +# if STAT_IS_KERNEL_STAT
> +  /* New kABIs which uses generic pre 64-bit time Linux ABI,
> +     e.g. csky, nios2  */
> +  if (vers == _STAT_VER_KERNEL)
> +    return INLINE_SYSCALL_CALL (fstatat64, AT_FDCWD, name, buf, 0);
> +# else
> +  /* Old kABIs with old non-LFS support, e.g. arm, i386, hppa, m68k,
> +     microblaze, s390, sh, mips32, powerpc32, and sparc32.  */
> +  return INLINE_SYSCALL_CALL (stat64, name, buf);
> +# endif /* STAT_IS_KERNEL_STAT  */
> +#endif /* XSTAT_IS_XSTAT64  */
> +
> +  return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
>  }
>  
> +#if XSTAT_IS_XSTAT64
> +weak_alias (___xstat64, __xstat);
> +weak_alias (___xstat64, __GI___xstat);
> +#endif
>  
>  #include <shlib-compat.h>
>  
> diff --git a/sysdeps/unix/sysv/linux/xstatover.h
> b/sysdeps/unix/sysv/linux/xstatover.h new file mode 100644
> index 0000000000..20178114f9
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/xstatover.h
> @@ -0,0 +1,67 @@
> +/* Overflow tests for stat, statfs, and lseek functions.
> +   Copyright (C) 2020 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 <sys/statfs.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 || !STAT_IS_KERNEL_STAT
> +  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 || !STAT_IS_KERNEL_STAT
> +  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
> +}




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 04/16] linux: Consolidate lxstat{64}
  2020-07-23 19:46 ` [PATCH 04/16] linux: Consolidate lxstat{64} Adhemerval Zanella via Libc-alpha
@ 2020-07-24  8:43   ` Lukasz Majewski
  0 siblings, 0 replies; 80+ messages in thread
From: Lukasz Majewski @ 2020-07-24  8:43 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Alistair Francis, libc-alpha

[-- Attachment #1: Type: text/plain, Size: 29059 bytes --]

On Thu, 23 Jul 2020 16:46:29 -0300
Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> The LFS support is implemented on lxstat64.c, instead of lxstat.c for
> 64-bit architectures.  The xstat.c implements the non-LFS and it is
> a no-op for !XSTAT_IS_XSTAT64.
> 
> The generic non-LFS implementation handles two cases:
> 
>   1. New kABIs which uses generic pre 64-bit time Linux ABI (csky and
>      nios): it issues __NR_fstat64 with AT_SYMLINK_NOFOLLOW plus
> handles the possible overflow off st_ino, st_size, or st_blocks.  It
> only handles _STAT_VER_KERNEL.
> 
>   2. Old KABIs with old non-LFS support (arm, i386, hppa, m68k,
>      microblaze, s390, sh, powerpc, and sparc32).  For
> _STAT_VER_KERNEL it issues __NR_lstat, otherwise it isseus
> __NR_lstat64 and convert to non-LFS stat struct and handle possible
> overflows on st_ino, st_size, or st_blocks.
> 
> Also non-LFS mips is an outlier and it has its own implementation
> since _STAT_VER_LINUX requires a different conversion function (it
> uses the kernel_stat as the syscall argument since its exported ABI
> is different than the kernel one for both non-LFS and LFS
> implementation).
> 
> The generic LFS implementation handles multiple cases:
> 
>   1. XSTAT_IS_XSTAT64 being 1:
> 
>     1.1. Old 64-bit kABI (ia64, powerpc64*, s390x, sparc64, x86_64):
> it issues __NR_lstat for _STAT_VER_KERNEL or _STAT_VER_LINUX.
> 
>     1.2. New kABIs which uses generic 64-bit Linux ABI (aarch64 and
>          riscv64): it issues __NR_newfstatat with AT_SYMLINK_NOFOLLOW
> and only for _STAT_VER_KERNEL.
> 
>     1.3. New 32-bit kABIs with only 64-bit time_t support (arc and
>          riscv32): it issues __NR_statx and covert to struct stat64.
> 
>   2. Old ABIs with XSTAT_IS_XSTAT64 being 0:
> 
>     2.1. New kABIs which uses generic pre 64-bit time Linux ABI (csky
> 	 and nios2): it issues __NR_fstatat64 for _STAT_VER_KERNEL.
> 
>     2.2. Old kABIs with old non-LFS support (arm, i386, hppa, m68k,
> 	 microblaze, s390, sh, mips32, powerpc32, and sparc32): it
> 	 issues __NR_lstat64.
> 
> Also, two special cases requires specific LFS implementations:
> 
>   1. alpha: it requires to handle _STAT_VER_KERNEL64 to issue
>      __NR_lstat64 and use the kernel_stat with __NR_lstat otherwise.
> 
>   2. mips64: as for non-LFS implementation its ABIs differ from
>      glibc exported one, which requires a specific conversion
>      function to handle the kernel_stat.
> 
> Checked with a build for all affected ABIs. I also checked on x86_64,
> i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and s390x.

Reviewed-by: Lukasz Majewski <lukma@denx.de>

> ---
>  sysdeps/unix/sysv/linux/alpha/lxstat.c        | 57 ----------------
>  .../{generic/lxstat.c => alpha/lxstat64.c}    | 47 ++++++-------
>  sysdeps/unix/sysv/linux/arm/lxstat.c          |  1 -
>  .../sysv/linux/generic/wordsize-32/lxstat.c   | 55 ----------------
>  .../sysv/linux/generic/wordsize-32/lxstat64.c | 66
> ------------------- sysdeps/unix/sysv/linux/hppa/lxstat.c         |
> 1 - sysdeps/unix/sysv/linux/i386/lxstat.c         | 60
> ----------------- sysdeps/unix/sysv/linux/lxstat.c              | 64
> +++++++++--------- sysdeps/unix/sysv/linux/lxstat64.c            | 58
> +++++++++++++--- sysdeps/unix/sysv/linux/m68k/lxstat.c         |  1 -
>  sysdeps/unix/sysv/linux/microblaze/lxstat.c   |  1 -
>  .../sysv/linux/{wordsize-64 => mips}/lxstat.c | 37 +++++------
>  .../unix/sysv/linux/mips/mips64/lxstat64.c    | 14 +---
>  .../sysv/linux/powerpc/powerpc32/lxstat.c     |  2 -
>  sysdeps/unix/sysv/linux/s390/s390-32/lxstat.c |  1 -
>  sysdeps/unix/sysv/linux/sh/lxstat.c           |  2 -
>  .../unix/sysv/linux/sparc/sparc32/lxstat.c    |  2 -
>  .../unix/sysv/linux/sparc/sparc64/lxstat.c    |  1 -
>  .../unix/sysv/linux/wordsize-64/lxstat64.c    |  1 -
>  19 files changed, 126 insertions(+), 345 deletions(-)
>  delete mode 100644 sysdeps/unix/sysv/linux/alpha/lxstat.c
>  rename sysdeps/unix/sysv/linux/{generic/lxstat.c =>
> alpha/lxstat64.c} (55%) delete mode 100644
> sysdeps/unix/sysv/linux/arm/lxstat.c delete mode 100644
> sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat.c delete mode
> 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat64.c delete
> mode 100644 sysdeps/unix/sysv/linux/hppa/lxstat.c delete mode 100644
> sysdeps/unix/sysv/linux/i386/lxstat.c delete mode 100644
> sysdeps/unix/sysv/linux/m68k/lxstat.c delete mode 100644
> sysdeps/unix/sysv/linux/microblaze/lxstat.c rename
> sysdeps/unix/sysv/linux/{wordsize-64 => mips}/lxstat.c (60%) delete
> mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/lxstat.c delete
> mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/lxstat.c delete mode
> 100644 sysdeps/unix/sysv/linux/sh/lxstat.c delete mode 100644
> sysdeps/unix/sysv/linux/sparc/sparc32/lxstat.c delete mode 100644
> sysdeps/unix/sysv/linux/sparc/sparc64/lxstat.c delete mode 100644
> sysdeps/unix/sysv/linux/wordsize-64/lxstat64.c
> 
> diff --git a/sysdeps/unix/sysv/linux/alpha/lxstat.c
> b/sysdeps/unix/sysv/linux/alpha/lxstat.c deleted file mode 100644
> index eb03a5fbfe..0000000000
> --- a/sysdeps/unix/sysv/linux/alpha/lxstat.c
> +++ /dev/null
> @@ -1,57 +0,0 @@
> -/* lxstat using old-style Unix stat system call.
> -   Copyright (C) 2004-2020 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 __lxstat64 __lxstat64_disable
> -
> -#include <errno.h>
> -#include <stddef.h>
> -#include <sys/stat.h>
> -#include <kernel_stat.h>
> -#include <sysdep.h>
> -#include <sys/syscall.h>
> -#include <xstatconv.h>
> -
> -#undef __lxstat64
> -
> -
> -/* Get information about the file NAME in BUF.  */
> -int
> -__lxstat (int vers, const char *name, struct stat *buf)
> -{
> -  int result;
> -  struct kernel_stat kbuf;
> -
> -  if (vers == _STAT_VER_KERNEL64)
> -    {
> -      result = INTERNAL_SYSCALL_CALL (lstat64, name, buf);
> -      if (__glibc_likely (!INTERNAL_SYSCALL_ERROR_P (result)))
> -	return result;
> -      __set_errno (INTERNAL_SYSCALL_ERRNO (result));
> -      return -1;
> -    }
> -
> -  result = INTERNAL_SYSCALL_CALL (lstat, name, &kbuf);
> -  if (__glibc_likely (!INTERNAL_SYSCALL_ERROR_P (result)))
> -    return __xstat_conv (vers, &kbuf, buf);
> -  __set_errno (INTERNAL_SYSCALL_ERRNO (result));
> -  return -1;
> -}
> -hidden_def (__lxstat)
> -weak_alias (__lxstat, _lxstat);
> -strong_alias (__lxstat, __lxstat64);
> -hidden_ver (__lxstat, __lxstat64)
> diff --git a/sysdeps/unix/sysv/linux/generic/lxstat.c
> b/sysdeps/unix/sysv/linux/alpha/lxstat64.c similarity index 55%
> rename from sysdeps/unix/sysv/linux/generic/lxstat.c
> rename to sysdeps/unix/sysv/linux/alpha/lxstat64.c
> index 1cf082961a..90dc0c7ce7 100644
> --- a/sysdeps/unix/sysv/linux/generic/lxstat.c
> +++ b/sysdeps/unix/sysv/linux/alpha/lxstat64.c
> @@ -1,6 +1,6 @@
> -/* Copyright (C) 2011-2020 Free Software Foundation, Inc.
> +/* lxstat using old-style Unix stat system call.
> +   Copyright (C) 2004-2020 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,33 +16,34 @@
>     License along with the GNU C Library.  If not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -/* Ignore prototype to avoid error if we alias __lxstat and
> __lxstat64. */ -#define __lxstat64 __lxstat64_disable
> -
> -#include <errno.h>
> -#include <stddef.h>
> -#include <fcntl.h>
> +#define __lxstat __redirect___lxstat
>  #include <sys/stat.h>
> +#undef __lxstat
> +#include <fcntl.h>
>  #include <kernel_stat.h>
> -
>  #include <sysdep.h>
> -#include <sys/syscall.h>
> +#include <xstatconv.h>
>  
>  /* Get information about the file NAME in BUF.  */
>  int
> -__lxstat (int vers, const char *name, struct stat *buf)
> +__lxstat64 (int vers, const char *name, struct stat64 *buf)
>  {
> -  if (vers == _STAT_VER_KERNEL)
> -    return INLINE_SYSCALL (newfstatat, 4, AT_FDCWD, name, buf,
> -                           AT_SYMLINK_NOFOLLOW);
> -  errno = EINVAL;
> -  return -1;
> +  switch (vers)
> +    {
> +    case _STAT_VER_KERNEL64:
> +      return INLINE_SYSCALL_CALL (lstat64, name, buf);
> +
> +    default:
> +      {
> +        struct kernel_stat kbuf;
> +	int r = INTERNAL_SYSCALL_CALL (lstat, name, &kbuf);
> +	if (r == 0)
> +	  return __xstat_conv (vers, &kbuf, buf);
> +	return INLINE_SYSCALL_ERROR_RETURN_VALUE (-r);
> +      }
> +    }
>  }
> +weak_alias (__lxstat64, __lxstat);
> +weak_alias (__lxstat64, __GI___lxstat);
>  
> -hidden_def (__lxstat)
> -weak_alias (__lxstat, _lxstat);
> -#if XSTAT_IS_XSTAT64
> -#undef __lxstat64
> -strong_alias (__lxstat, __lxstat64);
> -hidden_ver (__lxstat, __lxstat64)
> -#endif
> +hidden_def (__lxstat64)
> diff --git a/sysdeps/unix/sysv/linux/arm/lxstat.c
> b/sysdeps/unix/sysv/linux/arm/lxstat.c deleted file mode 100644
> index 0efa0aea49..0000000000
> --- a/sysdeps/unix/sysv/linux/arm/lxstat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/lxstat.c>
> diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat.c
> b/sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat.c deleted file
> mode 100644 index bd02631d68..0000000000
> --- a/sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat.c
> +++ /dev/null
> @@ -1,55 +0,0 @@
> -/* Copyright (C) 2011-2020 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 <errno.h>
> -#include <stddef.h>
> -#include <fcntl.h>
> -#include <sys/stat.h>
> -#include <kernel_stat.h>
> -
> -#include <sysdep.h>
> -#include <sys/syscall.h>
> -
> -#if !XSTAT_IS_XSTAT64
> -#include "overflow.h"
> -#include <statx_cp.h>
> -
> -/* Get information about the file NAME in BUF.  */
> -int
> -__lxstat (int vers, const char *name, struct stat *buf)
> -{
> -  if (vers == _STAT_VER_KERNEL)
> -    {
> -#ifdef __NR_fstatat64
> -      int rc = INLINE_SYSCALL (fstatat64, 4, AT_FDCWD, name, buf,
> -                               AT_SYMLINK_NOFOLLOW);
> -#else
> -      struct statx tmp;
> -      int rc = INLINE_SYSCALL (statx, 5, AT_FDCWD, name,
> -                               AT_NO_AUTOMOUNT | AT_SYMLINK_NOFOLLOW,
> -                               STATX_BASIC_STATS, &tmp);
> -      if (rc == 0)
> -        __cp_stat64_statx ((struct stat64 *)buf, &tmp);
> -#endif
> -      return rc ?: stat_overflow (buf);
> -    }
> -  errno = EINVAL;
> -  return -1;
> -}
> -hidden_def (__lxstat)
> -#endif
> diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat64.c
> b/sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat64.c deleted file
> mode 100644 index 3eab0a1847..0000000000
> --- a/sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat64.c
> +++ /dev/null
> @@ -1,66 +0,0 @@
> -/* Copyright (C) 2011-2020 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/>.  */
> -
> -/* Hide the prototype for __lxstat so that GCC will not complain
> about
> -   the different function signature if it is aliased to  __lxstat64.
> -   If XSTAT_IS_XSTAT64 is set to non-zero then the stat and stat64
> -   structures have an identical layout but different type names.  */
> -
> -#define __lxstat __lxstat_disable
> -
> -#include <errno.h>
> -#include <stddef.h>
> -#include <fcntl.h>
> -#include <sys/stat.h>
> -#include <kernel_stat.h>
> -
> -#include <sysdep.h>
> -#include <sys/syscall.h>
> -
> -#include <statx_cp.h>
> -
> -/* Get information about the file NAME in BUF.  */
> -int
> -__lxstat64 (int vers, const char *name, struct stat64 *buf)
> -{
> -  if (vers == _STAT_VER_KERNEL)
> -    {
> -#ifdef __NR_fstatat64
> -      return INLINE_SYSCALL (fstatat64, 4, AT_FDCWD, name, buf,
> -                             AT_SYMLINK_NOFOLLOW);
> -#else
> -      struct statx tmp;
> -      int rc = INLINE_SYSCALL (statx, 5, AT_FDCWD, name,
> -                               AT_NO_AUTOMOUNT | AT_SYMLINK_NOFOLLOW,
> -                               STATX_BASIC_STATS, &tmp);
> -      if (rc == 0)
> -        __cp_stat64_statx (buf, &tmp);
> -      return rc;
> -#endif
> -    }
> -
> -  errno = EINVAL;
> -  return -1;
> -}
> -hidden_def (__lxstat64)
> -
> -#undef __lxstat
> -#if XSTAT_IS_XSTAT64
> -strong_alias (__lxstat64, __lxstat)
> -hidden_ver (__lxstat64, __lxstat)
> -#endif
> diff --git a/sysdeps/unix/sysv/linux/hppa/lxstat.c
> b/sysdeps/unix/sysv/linux/hppa/lxstat.c deleted file mode 100644
> index 0efa0aea49..0000000000
> --- a/sysdeps/unix/sysv/linux/hppa/lxstat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/lxstat.c>
> diff --git a/sysdeps/unix/sysv/linux/i386/lxstat.c
> b/sysdeps/unix/sysv/linux/i386/lxstat.c deleted file mode 100644
> index e960077893..0000000000
> --- a/sysdeps/unix/sysv/linux/i386/lxstat.c
> +++ /dev/null
> @@ -1,60 +0,0 @@
> -/* lxstat using old-style Unix lstat system call.
> -   Copyright (C) 1991-2020 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/>.  */
> -
> -/* Ho hum, if xstat == xstat64 we must get rid of the prototype or
> gcc
> -   will complain since they don't strictly match.  */
> -#define __lxstat64 __lxstat64_disable
> -
> -#include <errno.h>
> -#include <stddef.h>
> -#include <sys/stat.h>
> -#include <kernel_stat.h>
> -
> -#include <sysdep.h>
> -#include <sys/syscall.h>
> -
> -#include <xstatconv.h>
> -
> -
> -/* Get information about the file NAME in BUF.  */
> -int
> -__lxstat (int vers, const char *name, struct stat *buf)
> -{
> -  int result;
> -
> -  if (vers == _STAT_VER_KERNEL)
> -    return INLINE_SYSCALL (lstat, 2, name, buf);
> -
> -  {
> -    struct stat64 buf64;
> -
> -    result = INTERNAL_SYSCALL_CALL (lstat64, name, &buf64);
> -    if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result)))
> -      return INLINE_SYSCALL_ERROR_RETURN_VALUE
> (INTERNAL_SYSCALL_ERRNO (result));
> -    else
> -      return __xstat32_conv (vers, &buf64, buf);
> -  }
> -}
> -
> -hidden_def (__lxstat)
> -weak_alias (__lxstat, _lxstat);
> -#if XSTAT_IS_XSTAT64
> -#undef __lxstat64
> -strong_alias (__lxstat, __lxstat64);
> -hidden_ver (__lxstat, __lxstat64)
> -#endif
> diff --git a/sysdeps/unix/sysv/linux/lxstat.c
> b/sysdeps/unix/sysv/linux/lxstat.c index dcd685873d..dc63d20061 100644
> --- a/sysdeps/unix/sysv/linux/lxstat.c
> +++ b/sysdeps/unix/sysv/linux/lxstat.c
> @@ -1,4 +1,4 @@
> -/* lxstat using old-style Unix lstat system call.
> +/* lxstat using old-style Unix stat system call.
>     Copyright (C) 1991-2020 Free Software Foundation, Inc.
>     This file is part of the GNU C Library.
>  
> @@ -16,45 +16,47 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -/* Ho hum, if xstat == xstat64 we must get rid of the prototype or
> gcc
> -   will complain since they don't strictly match.  */
> -#define __lxstat64 __lxstat64_disable
> -
> -#include <errno.h>
> -#include <stddef.h>
>  #include <sys/stat.h>
> +#include <fcntl.h>
>  #include <kernel_stat.h>
> -
>  #include <sysdep.h>
> -#include <sys/syscall.h>
>  
> -#include <xstatconv.h>
> +#if !XSTAT_IS_XSTAT64
> +# include <xstatconv.h>
> +# include <xstatover.h>
>  
>  /* Get information about the file NAME in BUF.  */
>  int
>  __lxstat (int vers, const char *name, struct stat *buf)
>  {
> -  if (vers == _STAT_VER_KERNEL)
> -    return INLINE_SYSCALL (lstat, 2, name, buf);
> -
> -#if STAT_IS_KERNEL_STAT
> -  return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
> -#else
> -  struct kernel_stat kbuf;
> -  int result;
> -
> -  result = INLINE_SYSCALL (lstat, 2, name, &kbuf);
> -  if (result == 0)
> -    result = __xstat_conv (vers, &kbuf, buf);
> -
> -  return result;
> +  switch (vers)
> +    {
> +    case _STAT_VER_KERNEL:
> +      {
> +# if STAT_IS_KERNEL_STAT
> +	/* New kABIs which uses generic pre 64-bit time Linux ABI,
> +	   e.g. csky, nios2  */
> +	int r = INLINE_SYSCALL_CALL (fstatat64, AT_FDCWD, name, buf,
> +				     AT_SYMLINK_NOFOLLOW);
> +	return r ?: stat_overflow (buf);
> +# else
> +	/* Old kABIs with old non-LFS support, e.g. arm, i386, hppa,
> m68k,
> +	   microblaze, s390, sh, powerpc, and sparc.  */
> +	return INLINE_SYSCALL_CALL (lstat, name, buf);
> +# endif
> +      }
> +
> +    default:
> +      {
> +# if STAT_IS_KERNEL_STAT
> +	return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
> +# else
> +	struct stat64 buf64;
> +	int r = INTERNAL_SYSCALL_CALL (lstat64, name, &buf64);
> +	return r ?: __xstat32_conv (vers, &buf64, buf);
>  #endif
> +      }
> +    }
>  }
> -
>  hidden_def (__lxstat)
> -weak_alias (__lxstat, _lxstat);
> -#if XSTAT_IS_XSTAT64
> -#undef __lxstat64
> -strong_alias (__lxstat, __lxstat64);
> -hidden_ver (__lxstat, __lxstat64)
> -#endif
> +#endif /* XSTAT_IS_XSTAT64  */
> diff --git a/sysdeps/unix/sysv/linux/lxstat64.c
> b/sysdeps/unix/sysv/linux/lxstat64.c index 0ea8399d68..375013e9b1
> 100644 --- a/sysdeps/unix/sysv/linux/lxstat64.c
> +++ b/sysdeps/unix/sysv/linux/lxstat64.c
> @@ -1,5 +1,5 @@
>  /* lxstat64 using Linux lstat64 system call.
> -   Copyright (C) 1997-2020 Free Software Foundation, Inc.
> +   Copyright (C) 1991-2020 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
> @@ -16,23 +16,65 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -#include <errno.h>
> -#include <stddef.h>
> +#define __lxstat __redirect___lxstat
>  #include <sys/stat.h>
> +#undef __lxstat
> +#include <fcntl.h>
>  #include <kernel_stat.h>
> -
>  #include <sysdep.h>
> -#include <sys/syscall.h>
> +#include <xstatconv.h>
> +#include <statx_cp.h>
>  
>  /* Get information about the file NAME in BUF.  */
> +
>  int
>  ___lxstat64 (int vers, const char *name, struct stat64 *buf)
>  {
> -  int result;
> -  result = INLINE_SYSCALL (lstat64, 2, name, buf);
> -  return result;
> +#if XSTAT_IS_XSTAT64
> +# if defined __NR_lstat
> +  /* Old 64-bit kABI, e.g. ia64, powerpc64*, s390x, sparc64, x86_64.
>  */
> +  if (vers == _STAT_VER_KERNEL || vers == _STAT_VER_LINUX)
> +    return INLINE_SYSCALL_CALL (lstat, name, buf);
> +# elif defined __NR_newfstatat
> +  /* New kABIs which uses generic 64-bit Linux ABI, e.g. aarch64,
> riscv64.  */
> +  if (vers == _STAT_VER_KERNEL)
> +    return INLINE_SYSCALL_CALL (newfstatat, AT_FDCWD, name, buf,
> +				AT_SYMLINK_NOFOLLOW);
> +# else
> +  /* New 32-bit kABIs with only 64-bit time_t support, e.g. arc,
> riscv32.  */
> +  if (vers == _STAT_VER_KERNEL)
> +    {
> +      struct statx tmp;
> +      int r = INLINE_SYSCALL_CALL (statx, AT_FDCWD, name,
> +				   AT_NO_AUTOMOUNT |
> AT_SYMLINK_NOFOLLOW,
> +				   STATX_BASIC_STATS, &tmp);
> +      if (r == 0)
> +	__cp_stat64_statx (buf, &tmp);
> +      return r;
> +     }
> +# endif
> +#else
> +# if STAT_IS_KERNEL_STAT
> +  /* New kABIs which uses generic pre 64-bit time Linux ABI,
> +     e.g. csky, nios2  */
> +  if (vers == _STAT_VER_KERNEL)
> +    return INLINE_SYSCALL_CALL (fstatat64, AT_FDCWD, name, buf,
> +				AT_SYMLINK_NOFOLLOW);
> +# else
> +  /* Old kABIs with old non-LFS support, e.g. arm, i386, hppa, m68k,
> +     microblaze, s390, sh, mips32, powerpc32, and sparc32.  */
> +  return INLINE_SYSCALL_CALL (lstat64, name, buf);
> +# endif /* STAT_IS_KERNEL_STAT  */
> +#endif /* XSTAT_IS_XSTAT64  */
> +
> +  return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
>  }
>  
> +#if XSTAT_IS_XSTAT64
> +weak_alias (___lxstat64, __lxstat);
> +weak_alias (___lxstat64, __GI___lxstat);
> +#endif
> +
>  #include <shlib-compat.h>
>  
>  #if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2)
> diff --git a/sysdeps/unix/sysv/linux/m68k/lxstat.c
> b/sysdeps/unix/sysv/linux/m68k/lxstat.c deleted file mode 100644
> index 0efa0aea49..0000000000
> --- a/sysdeps/unix/sysv/linux/m68k/lxstat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/lxstat.c>
> diff --git a/sysdeps/unix/sysv/linux/microblaze/lxstat.c
> b/sysdeps/unix/sysv/linux/microblaze/lxstat.c deleted file mode 100644
> index 0efa0aea49..0000000000
> --- a/sysdeps/unix/sysv/linux/microblaze/lxstat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/lxstat.c>
> diff --git a/sysdeps/unix/sysv/linux/wordsize-64/lxstat.c
> b/sysdeps/unix/sysv/linux/mips/lxstat.c similarity index 60%
> rename from sysdeps/unix/sysv/linux/wordsize-64/lxstat.c
> rename to sysdeps/unix/sysv/linux/mips/lxstat.c
> index 156fbe7c64..eb07549adf 100644
> --- a/sysdeps/unix/sysv/linux/wordsize-64/lxstat.c
> +++ b/sysdeps/unix/sysv/linux/mips/lxstat.c
> @@ -1,4 +1,4 @@
> -/* lxstat using old-style Unix lstat system call.
> +/* lxstat using old-style Unix stat system call.
>     Copyright (C) 1991-2020 Free Software Foundation, Inc.
>     This file is part of the GNU C Library.
>  
> @@ -16,30 +16,27 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -/* Ho hum, since xstat == xstat64 we must get rid of the prototype
> or gcc
> -   will complain since they don't strictly match.  */
> -#define __lxstat64 __lxstat64_disable
> -
> -#include <errno.h>
> -#include <stddef.h>
>  #include <sys/stat.h>
> -
> +#include <fcntl.h>
> +#include <kernel_stat.h>
>  #include <sysdep.h>
> -#include <sys/syscall.h>
> +#include <xstatconv.h>
>  
> -/* Get information about the file FD in BUF.  */
> +/* Get information about the file NAME in BUF.  */
>  int
>  __lxstat (int vers, const char *name, struct stat *buf)
>  {
> -  if (vers == _STAT_VER_KERNEL || vers == _STAT_VER_LINUX)
> -    return INLINE_SYSCALL (lstat, 2, name, buf);
> -
> -  __set_errno (EINVAL);
> -  return -1;
> +  switch (vers)
> +    {
> +    case _STAT_VER_KERNEL:
> +      return INLINE_SYSCALL_CALL (lstat, name, buf);
> +
> +    default:
> +      {
> +	struct kernel_stat kbuf;
> +	int r = INTERNAL_SYSCALL_CALL (lstat, name, &kbuf);
> +	return r ?: __xstat_conv (vers, &kbuf, buf);
> +      }
> +    }
>  }
> -
>  hidden_def (__lxstat)
> -weak_alias (__lxstat, _lxstat);
> -#undef __lxstat64
> -strong_alias (__lxstat, __lxstat64);
> -hidden_ver (__lxstat, __lxstat64)
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/lxstat64.c
> b/sysdeps/unix/sysv/linux/mips/mips64/lxstat64.c index
> 62d4fe70eb..28bac57e58 100644 ---
> a/sysdeps/unix/sysv/linux/mips/mips64/lxstat64.c +++
> b/sysdeps/unix/sysv/linux/mips/mips64/lxstat64.c @@ -16,28 +16,18 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -#include <errno.h>
> -#include <stddef.h>
>  #include <sys/stat.h>
>  #include <kernel_stat.h>
> -
>  #include <sysdep.h>
> -#include <sys/syscall.h>
> -
>  #include <xstatconv.h>
>  
>  /* Get information about the file NAME in BUF.  */
>  int
>  __lxstat64 (int vers, const char *name, struct stat64 *buf)
>  {
> -  int result;
>    struct kernel_stat kbuf;
> -
> -  result = INLINE_SYSCALL (lstat, 2, name, &kbuf);
> -  if (result == 0)
> -    result = __xstat64_conv (vers, &kbuf, buf);
> -
> -  return result;
> +  int r = INLINE_SYSCALL_CALL (lstat, name, &kbuf);
> +  return r ?: __xstat64_conv (vers, &kbuf, buf);
>  }
>  
>  hidden_def (__lxstat64)
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/lxstat.c
> b/sysdeps/unix/sysv/linux/powerpc/powerpc32/lxstat.c deleted file
> mode 100644 index 2371cd9719..0000000000
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/lxstat.c
> +++ /dev/null
> @@ -1,2 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/lxstat.c>
> -
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/lxstat.c
> b/sysdeps/unix/sysv/linux/s390/s390-32/lxstat.c deleted file mode
> 100644 index 0efa0aea49..0000000000
> --- a/sysdeps/unix/sysv/linux/s390/s390-32/lxstat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/lxstat.c>
> diff --git a/sysdeps/unix/sysv/linux/sh/lxstat.c
> b/sysdeps/unix/sysv/linux/sh/lxstat.c deleted file mode 100644
> index 2371cd9719..0000000000
> --- a/sysdeps/unix/sysv/linux/sh/lxstat.c
> +++ /dev/null
> @@ -1,2 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/lxstat.c>
> -
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/lxstat.c
> b/sysdeps/unix/sysv/linux/sparc/sparc32/lxstat.c deleted file mode
> 100644 index 2371cd9719..0000000000
> --- a/sysdeps/unix/sysv/linux/sparc/sparc32/lxstat.c
> +++ /dev/null
> @@ -1,2 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/lxstat.c>
> -
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/lxstat.c
> b/sysdeps/unix/sysv/linux/sparc/sparc64/lxstat.c deleted file mode
> 100644 index 7f1e98e433..0000000000
> --- a/sysdeps/unix/sysv/linux/sparc/sparc64/lxstat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include "../../i386/lxstat.c"
> diff --git a/sysdeps/unix/sysv/linux/wordsize-64/lxstat64.c
> b/sysdeps/unix/sysv/linux/wordsize-64/lxstat64.c deleted file mode
> 100644 index bb5dbd0fff..0000000000
> --- a/sysdeps/unix/sysv/linux/wordsize-64/lxstat64.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -/* lxstat64 is in lxstat.c */




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 05/16] linux: Consolidate fxstat{64}
  2020-07-23 19:46 ` [PATCH 05/16] linux: Consolidate fxstat{64} Adhemerval Zanella via Libc-alpha
@ 2020-07-24  9:04   ` Lukasz Majewski
  0 siblings, 0 replies; 80+ messages in thread
From: Lukasz Majewski @ 2020-07-24  9:04 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Alistair Francis, libc-alpha

[-- Attachment #1: Type: text/plain, Size: 24354 bytes --]

On Thu, 23 Jul 2020 16:46:30 -0300
Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> The LFS support is implemented on fxstat64.c, instead of fxstat.c for
> 64-bit architectures.  The fxstat.c implements the non-LFS and it is
> a no-op for !XSTAT_IS_XSTAT64.
> 
> The generic non-LFS implementation handles two cases:
> 
>   1. New kABIs which uses generic pre 64-bit time Linux ABI (csky and
>      nios): it issuess __NR_fstat64 plus handle the overflow on
> st_ino, st_size, or st_blocks.  It only handles _STAT_VER_KERNEL.
> 
>   2. Old KABIs with old non-LFS support (arm, i386, hppa, m68k,
>      microblaze, s390, sh, powerpc, and sparc32).  For
> _STAT_VER_KERNEL it issues __NR_fstat, otherwise it calls
> __NR_fstat64 and convert to non-LFS stat struct and handle possible
> overflows on st_ino, st_size, or st_blocks.
> 
> Also non-LFS mips is an outlier and it has its own implementation
> since _STAT_VER_LINUX requires a different conversion function (it
> uses the kernel_stat as the sysissues argument since its exported ABI
> is different than the kernel one for both non-LFS and LFS
> implementation).
> 
> The generic LFS implementation handles multiple cases:
> 
>   1. XSTAT_IS_XSTAT64 being 1:
> 
>     1.1. 64-bit kABI (aarch64, ia64, powerpc64*, s390x, sparc64,
> 	 riscv64, and x86_64): it issuess __NR_fstat for
> 	 _STAT_VER_KERNEL or _STAT_VER_LINUX.
> 
>     1.2. New 32-bit kABIs with only 64-bit time_t support (arc and
> 	 riscv32): it issuess __NR_statx and covert to struct stat64.
> 
>   2. Old ABIs with XSTAT_IS_XSTAT64 being 0 (arm, csky, i386, hppa,
>      m68k, microblaze, mips32, nios2, sh, powerpc32, and sparc32): it
>      issues __NR_fstat64.
> 
> Also, two special cases requires specific implementations:
> 
>   1. alpha: it requires to handle _STAT_VER_KERNEL64 to issues
>      __NR_fstat64 and use the kernel_stat with __NR_fstat otherwise.
> 
>   2. mips64: as for non-LFS implementation its ABIs differ from
>      glibc exported one, which requires an specific conversion
>      function to handle the kernel_stat.
> 
> Checked with a build for all affected ABIs. I also checked on x86_64,
> i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and s390x.

Reviewed-by: Lukasz Majewski <lukma@denx.de>

> ---
>  .../sysv/linux/alpha/{fxstat.c => fxstat64.c} | 48 ++++++--------
>  sysdeps/unix/sysv/linux/arm/fxstat.c          |  1 -
>  sysdeps/unix/sysv/linux/fxstat.c              | 62
> +++++++++---------- sysdeps/unix/sysv/linux/fxstat64.c            |
> 43 ++++++++----- .../sysv/linux/generic/wordsize-32/fxstat.c   | 57
> ----------------- .../sysv/linux/generic/wordsize-32/fxstat64.c | 36
> ----------- sysdeps/unix/sysv/linux/hppa/fxstat.c         |  1 -
>  sysdeps/unix/sysv/linux/i386/fxstat.c         | 59 ------------------
>  sysdeps/unix/sysv/linux/m68k/fxstat.c         |  1 -
>  sysdeps/unix/sysv/linux/microblaze/fxstat.c   |  1 -
>  .../sysv/linux/{wordsize-64 => mips}/fxstat.c | 37 +++++------
>  .../unix/sysv/linux/mips/mips64/fxstat64.c    | 13 +---
>  .../sysv/linux/powerpc/powerpc32/fxstat.c     |  1 -
>  sysdeps/unix/sysv/linux/s390/s390-32/fxstat.c |  1 -
>  sysdeps/unix/sysv/linux/sh/fxstat.c           |  1 -
>  .../unix/sysv/linux/sparc/sparc32/fxstat.c    |  1 -
>  .../unix/sysv/linux/sparc/sparc64/fxstat.c    |  1 -
>  .../unix/sysv/linux/wordsize-64/fxstat64.c    |  1 -
>  18 files changed, 97 insertions(+), 268 deletions(-)
>  rename sysdeps/unix/sysv/linux/alpha/{fxstat.c => fxstat64.c} (53%)
>  delete mode 100644 sysdeps/unix/sysv/linux/arm/fxstat.c
>  delete mode 100644
> sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat.c delete mode
> 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat64.c delete
> mode 100644 sysdeps/unix/sysv/linux/hppa/fxstat.c delete mode 100644
> sysdeps/unix/sysv/linux/i386/fxstat.c delete mode 100644
> sysdeps/unix/sysv/linux/m68k/fxstat.c delete mode 100644
> sysdeps/unix/sysv/linux/microblaze/fxstat.c rename
> sysdeps/unix/sysv/linux/{wordsize-64 => mips}/fxstat.c (60%) delete
> mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/fxstat.c delete
> mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/fxstat.c delete mode
> 100644 sysdeps/unix/sysv/linux/sh/fxstat.c delete mode 100644
> sysdeps/unix/sysv/linux/sparc/sparc32/fxstat.c delete mode 100644
> sysdeps/unix/sysv/linux/sparc/sparc64/fxstat.c delete mode 100644
> sysdeps/unix/sysv/linux/wordsize-64/fxstat64.c
> 
> diff --git a/sysdeps/unix/sysv/linux/alpha/fxstat.c
> b/sysdeps/unix/sysv/linux/alpha/fxstat64.c similarity index 53%
> rename from sysdeps/unix/sysv/linux/alpha/fxstat.c
> rename to sysdeps/unix/sysv/linux/alpha/fxstat64.c
> index 0978610bf0..286a2f0a6c 100644
> --- a/sysdeps/unix/sysv/linux/alpha/fxstat.c
> +++ b/sysdeps/unix/sysv/linux/alpha/fxstat64.c
> @@ -1,4 +1,4 @@
> -/* fxstat using old-style Unix stat system call.
> +/* fxstat64 using old-style Unix stat system call.
>     Copyright (C) 2004-2020 Free Software Foundation, Inc.
>     This file is part of the GNU C Library.
>  
> @@ -16,42 +16,32 @@
>     License along with the GNU C Library.  If not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -#define __fxstat64 __fxstat64_disable
> -
> -#include <errno.h>
> -#include <stddef.h>
> +#define __fxstat __redirect___fxstat64
>  #include <sys/stat.h>
> +#undef __fxstat
>  #include <kernel_stat.h>
>  #include <sysdep.h>
> -#include <sys/syscall.h>
>  #include <xstatconv.h>
>  
> -#undef __fxstat64
> -
> -
>  /* Get information about the file NAME in BUF.  */
>  int
> -__fxstat (int vers, int fd, struct stat *buf)
> +__fxstat64 (int vers, int fd, struct stat64 *buf)
>  {
> -  int result;
> -  struct kernel_stat kbuf;
> -
> -  if (vers == _STAT_VER_KERNEL64)
> +  switch (vers)
>      {
> -      result = INTERNAL_SYSCALL_CALL (fstat64, fd, buf);
> -      if (__glibc_likely (!INTERNAL_SYSCALL_ERROR_P (result)))
> -	return result;
> -      __set_errno (INTERNAL_SYSCALL_ERRNO (result));
> -      return -1;
> +    case _STAT_VER_KERNEL64:
> +      return INLINE_SYSCALL_CALL (fstat64, fd, buf);
> +
> +    default:
> +      {
> +        struct kernel_stat kbuf;
> +	int r = INTERNAL_SYSCALL_CALL (fstat, fd, &kbuf);
> +	if (r == 0)
> +	  return __xstat_conv (vers, &kbuf, buf);
> +	return INLINE_SYSCALL_ERROR_RETURN_VALUE (-r);
> +      }
>      }
> -
> -  result = INTERNAL_SYSCALL_CALL (fstat, fd, &kbuf);
> -  if (__glibc_likely (!INTERNAL_SYSCALL_ERROR_P (result)))
> -    return __xstat_conv (vers, &kbuf, buf);
> -  __set_errno (INTERNAL_SYSCALL_ERRNO (result));
> -  return -1;
>  }
> -hidden_def (__fxstat)
> -weak_alias (__fxstat, _fxstat);
> -strong_alias (__fxstat, __fxstat64);
> -hidden_ver (__fxstat, __fxstat64)
> +hidden_def (__fxstat64)
> +strong_alias (__fxstat64, __fxstat);
> +hidden_ver (__fxstat64, __fxstat)
> diff --git a/sysdeps/unix/sysv/linux/arm/fxstat.c
> b/sysdeps/unix/sysv/linux/arm/fxstat.c deleted file mode 100644
> index 4f219f0b9d..0000000000
> --- a/sysdeps/unix/sysv/linux/arm/fxstat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/fxstat.c>
> diff --git a/sysdeps/unix/sysv/linux/fxstat.c
> b/sysdeps/unix/sysv/linux/fxstat.c index a88404b5c3..b46e344d0e 100644
> --- a/sysdeps/unix/sysv/linux/fxstat.c
> +++ b/sysdeps/unix/sysv/linux/fxstat.c
> @@ -16,46 +16,46 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -/* Ho hum, if xstat == xstat64 we must get rid of the prototype or
> gcc
> -   will complain since they don't strictly match.  */
> -#define __fxstat64 __fxstat64_disable
> -
> -#include <errno.h>
> -#include <stddef.h>
> -#include <sys/types.h>
>  #include <sys/stat.h>
> +#include <fcntl.h>
>  #include <kernel_stat.h>
> -
>  #include <sysdep.h>
> -#include <sys/syscall.h>
>  
> -#include <xstatconv.h>
> +#if !XSTAT_IS_XSTAT64
> +# include <xstatconv.h>
> +# include <xstatover.h>
>  
>  /* Get information about the file FD in BUF.  */
>  int
>  __fxstat (int vers, int fd, struct stat *buf)
>  {
> -  if (vers == _STAT_VER_KERNEL)
> -    return INLINE_SYSCALL (fstat, 2, fd, buf);
> -
> -#if STAT_IS_KERNEL_STAT
> -  return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
> -#else
> -  struct kernel_stat kbuf;
> -  int result;
> -
> -  result = INLINE_SYSCALL (fstat, 2, fd, &kbuf);
> -  if (result == 0)
> -    result = __xstat_conv (vers, &kbuf, buf);
> -
> -  return result;
> +  switch (vers)
> +    {
> +    case _STAT_VER_KERNEL:
> +      {
> +# if STAT_IS_KERNEL_STAT
> +	/* New kABIs which uses generic pre 64-bit time Linux ABI,
> +	   e.g. csky, nios2  */
> +	int r = INLINE_SYSCALL_CALL (fstat64, fd, buf);
> +	return r ?: stat_overflow (buf);
> +# else
> +	/* Old kABIs with old non-LFS support, e.g. arm, i386, hppa,
> m68k,
> +	   microblaze, s390, sh, powerpc, and sparc.  */
> +	return INLINE_SYSCALL_CALL (fstat, fd, buf);
> +# endif
> +      }
> +
> +    default:
> +      {
> +# if STAT_IS_KERNEL_STAT
> +	return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
> +# else
> +	struct stat64 buf64;
> +	int r = INLINE_SYSCALL_CALL (fstat64, fd, &buf64);
> +	return r ?: __xstat32_conv (vers, &buf64, buf);
>  #endif
> +      }
> +    }
>  }
> -
>  hidden_def (__fxstat)
> -weak_alias (__fxstat, _fxstat);
> -#if XSTAT_IS_XSTAT64
> -#undef __fxstat64
> -strong_alias (__fxstat, __fxstat64);
> -hidden_ver (__fxstat, __fxstat64)
> -#endif
> +#endif /* XSTAT_IS_XSTAT64  */
> diff --git a/sysdeps/unix/sysv/linux/fxstat64.c
> b/sysdeps/unix/sysv/linux/fxstat64.c index 9133a0a29b..d3834f1ce2
> 100644 --- a/sysdeps/unix/sysv/linux/fxstat64.c
> +++ b/sysdeps/unix/sysv/linux/fxstat64.c
> @@ -16,15 +16,13 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -#include <errno.h>
> -#include <stddef.h>
> -#include <fcntl.h>
> +#define __fxstat __redirect___fxstat
>  #include <sys/stat.h>
> +#undef __fxstat
> +#include <fcntl.h>
>  #include <kernel_stat.h>
> -
>  #include <sysdep.h>
> -#include <sys/syscall.h>
> -
> +#include <xstatconv.h>
>  #include <statx_cp.h>
>  
>  /* Get information about the file FD in BUF.  */
> @@ -32,17 +30,27 @@
>  int
>  ___fxstat64 (int vers, int fd, struct stat64 *buf)
>  {
> -  int result;
> -#ifdef __NR_fstat64
> -  result = INLINE_SYSCALL (fstat64, 2, fd, buf);
> -#else
> +#if XSTAT_IS_XSTAT64
> +# ifdef __NR_fstat
> +  /* 64-bit kABI, e.g. aarch64, ia64, powerpc64*, s390x, sparc64,
> riscv64,
> +     and x86_64.  */
> +  if (vers == _STAT_VER_KERNEL || vers == _STAT_VER_LINUX)
> +    return INLINE_SYSCALL_CALL (fstat, fd, buf);
> +  return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
> +# else
> +  /* New 32-bit kABIs with only 64-bit time_t support, e.g. arc,
> riscv32.  */ struct statx tmp;
> -  result = INLINE_SYSCALL (statx, 5, fd, "", AT_EMPTY_PATH,
> STATX_BASIC_STATS,
> -                           &tmp);
> -  if (result == 0)
> +  int r = INLINE_SYSCALL_CALL (statx, fd, "", AT_EMPTY_PATH,
> +			       STATX_BASIC_STATS, &tmp);
> +  if (r == 0)
>      __cp_stat64_statx (buf, &tmp);
> -#endif
> -  return result;
> +  return r;
> +# endif
> +#else
> +  /* All kABIs with non-LFS support, e.g. arm, csky, i386, hppa,
> m68k,
> +     microblaze, mips32, nios2, sh, powerpc32, and sparc32.  */
> +  return INLINE_SYSCALL_CALL (fstat64, fd, buf);
> +#endif /* XSTAT_IS_XSTAT64  */
>  }
>  
>  #include <shlib-compat.h>
> @@ -56,3 +64,8 @@ hidden_ver (___fxstat64, __fxstat64)
>  strong_alias (___fxstat64, __fxstat64)
>  hidden_def (__fxstat64)
>  #endif
> +
> +#if XSTAT_IS_XSTAT64
> +strong_alias (__fxstat64, __fxstat);
> +hidden_ver (__fxstat64, __fxstat)
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat.c
> b/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat.c deleted file
> mode 100644 index 850450e1e8..0000000000
> --- a/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat.c
> +++ /dev/null
> @@ -1,57 +0,0 @@
> -/* Copyright (C) 2011-2020 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 <errno.h>
> -#include <stddef.h>
> -#include <fcntl.h>
> -#include <sys/types.h>
> -#include <sys/stat.h>
> -#include <kernel_stat.h>
> -
> -#include <sysdep.h>
> -#include <sys/syscall.h>
> -
> -#if !XSTAT_IS_XSTAT64
> -#include "overflow.h"
> -#include <statx_cp.h>
> -
> -/* Get information about the file FD in BUF.  */
> -int
> -__fxstat (int vers, int fd, struct stat *buf)
> -{
> -  if (vers == _STAT_VER_KERNEL)
> -    {
> -# ifdef __NR_fstat64
> -      int rc = INLINE_SYSCALL (fstat64, 2, fd, buf);
> -# else
> -      struct statx tmp;
> -      int rc = INLINE_SYSCALL (statx, 5, fd, "", AT_EMPTY_PATH,
> -                               STATX_BASIC_STATS, &tmp);
> -      if (rc == 0)
> -        __cp_stat64_statx ((struct stat64 *)buf, &tmp);
> -# endif
> -      return rc ?: stat_overflow (buf);
> -    }
> -
> -  errno = EINVAL;
> -  return -1;
> -}
> -
> -hidden_def (__fxstat)
> -weak_alias (__fxstat, _fxstat);
> -#endif
> diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat64.c
> b/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat64.c deleted file
> mode 100644 index b4a2a5b417..0000000000
> --- a/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat64.c
> +++ /dev/null
> @@ -1,36 +0,0 @@
> -/* __fxstat64 () implementation.
> -   Copyright (C) 2016-2020 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/>.  */
> -
> -/* Hide the prototypes for __fxstat and _fxstat so that GCC will not
> -   complain about the different function signatures if they are
> aliased
> -   to  __fxstat64.  If XSTAT_IS_XSTAT64 is set to non-zero then the
> stat and
> -   stat64 structures have an identical layout but different type
> names.  */ -
> -#define __fxstat __fxstat_disable
> -#define _fxstat _fxstat_disable
> -
> -#include <sysdeps/unix/sysv/linux/fxstat64.c>
> -
> -#undef __fxstat
> -#undef _fxstat
> -#if XSTAT_IS_XSTAT64
> -weak_alias (__fxstat64, __fxstat)
> -weak_alias (__fxstat64, _fxstat)
> -hidden_ver (__fxstat64, __fxstat)
> -#endif
> diff --git a/sysdeps/unix/sysv/linux/hppa/fxstat.c
> b/sysdeps/unix/sysv/linux/hppa/fxstat.c deleted file mode 100644
> index 4f219f0b9d..0000000000
> --- a/sysdeps/unix/sysv/linux/hppa/fxstat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/fxstat.c>
> diff --git a/sysdeps/unix/sysv/linux/i386/fxstat.c
> b/sysdeps/unix/sysv/linux/i386/fxstat.c deleted file mode 100644
> index db59baa71b..0000000000
> --- a/sysdeps/unix/sysv/linux/i386/fxstat.c
> +++ /dev/null
> @@ -1,59 +0,0 @@
> -/* fxstat using old-style Unix fstat system call.
> -   Copyright (C) 1991-2020 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/>.  */
> -
> -/* Ho hum, if xstat == xstat64 we must get rid of the prototype or
> gcc
> -   will complain since they don't strictly match.  */
> -#define __fxstat64 __fxstat64_disable
> -
> -#include <errno.h>
> -#include <stddef.h>
> -#include <sys/stat.h>
> -#include <kernel_stat.h>
> -
> -#include <sysdep.h>
> -#include <sys/syscall.h>
> -
> -#include <xstatconv.h>
> -
> -/* Get information about the file FD in BUF.  */
> -int
> -__fxstat (int vers, int fd, struct stat *buf)
> -{
> -  int result;
> -
> -  if (vers == _STAT_VER_KERNEL)
> -    return INLINE_SYSCALL (fstat, 2, fd, buf);
> -
> -  {
> -    struct stat64 buf64;
> -
> -    result = INTERNAL_SYSCALL_CALL (fstat64, fd, &buf64);
> -    if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result)))
> -      return INLINE_SYSCALL_ERROR_RETURN_VALUE
> (INTERNAL_SYSCALL_ERRNO (result));
> -    else
> -      return __xstat32_conv (vers, &buf64, buf);
> -  }
> -}
> -
> -hidden_def (__fxstat)
> -weak_alias (__fxstat, _fxstat);
> -#if XSTAT_IS_XSTAT64
> -#undef __fxstat64
> -strong_alias (__fxstat, __fxstat64);
> -hidden_ver (__fxstat, __fxstat64)
> -#endif
> diff --git a/sysdeps/unix/sysv/linux/m68k/fxstat.c
> b/sysdeps/unix/sysv/linux/m68k/fxstat.c deleted file mode 100644
> index 4f219f0b9d..0000000000
> --- a/sysdeps/unix/sysv/linux/m68k/fxstat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/fxstat.c>
> diff --git a/sysdeps/unix/sysv/linux/microblaze/fxstat.c
> b/sysdeps/unix/sysv/linux/microblaze/fxstat.c deleted file mode 100644
> index 4f219f0b9d..0000000000
> --- a/sysdeps/unix/sysv/linux/microblaze/fxstat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/fxstat.c>
> diff --git a/sysdeps/unix/sysv/linux/wordsize-64/fxstat.c
> b/sysdeps/unix/sysv/linux/mips/fxstat.c similarity index 60%
> rename from sysdeps/unix/sysv/linux/wordsize-64/fxstat.c
> rename to sysdeps/unix/sysv/linux/mips/fxstat.c
> index 24bfe847d7..16c3cefee2 100644
> --- a/sysdeps/unix/sysv/linux/wordsize-64/fxstat.c
> +++ b/sysdeps/unix/sysv/linux/mips/fxstat.c
> @@ -1,4 +1,4 @@
> -/* fxstat using old-style Unix fstat system call.
> +/* fxstat using old-style Unix stat system call.
>     Copyright (C) 1991-2020 Free Software Foundation, Inc.
>     This file is part of the GNU C Library.
>  
> @@ -16,30 +16,27 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -/* Ho hum, since xstat == xstat64 we must get rid of the prototype
> or gcc
> -   will complain since they don't strictly match.  */
> -#define __fxstat64 __fxstat64_disable
> -
> -#include <errno.h>
> -#include <stddef.h>
>  #include <sys/stat.h>
> -
> +#include <fcntl.h>
> +#include <kernel_stat.h>
>  #include <sysdep.h>
> -#include <sys/syscall.h>
> +#include <xstatconv.h>
>  
> -/* Get information about the file FD in BUF.  */
> +/* Get information about the file NAME in BUF.  */
>  int
>  __fxstat (int vers, int fd, struct stat *buf)
>  {
> -  if (vers == _STAT_VER_KERNEL || vers == _STAT_VER_LINUX)
> -    return INLINE_SYSCALL (fstat, 2, fd, buf);
> -
> -  __set_errno (EINVAL);
> -  return -1;
> +  switch (vers)
> +    {
> +    case _STAT_VER_KERNEL:
> +      return INLINE_SYSCALL_CALL (fstat, fd, buf);
> +
> +    default:
> +      {
> +	struct kernel_stat kbuf;
> +	int r = INTERNAL_SYSCALL_CALL (fstat, fd, &kbuf);
> +	return r ?: __xstat_conv (vers, &kbuf, buf);
> +      }
> +    }
>  }
> -
>  hidden_def (__fxstat)
> -weak_alias (__fxstat, _fxstat);
> -#undef __fxstat64
> -strong_alias (__fxstat, __fxstat64);
> -hidden_ver (__fxstat, __fxstat64)
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/fxstat64.c
> b/sysdeps/unix/sysv/linux/mips/mips64/fxstat64.c index
> 8dd3d92eb1..3fcdd9f1ee 100644 ---
> a/sysdeps/unix/sysv/linux/mips/mips64/fxstat64.c +++
> b/sysdeps/unix/sysv/linux/mips/mips64/fxstat64.c @@ -16,14 +16,9 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -#include <errno.h>
> -#include <stddef.h>
>  #include <sys/stat.h>
>  #include <kernel_stat.h>
> -
>  #include <sysdep.h>
> -#include <sys/syscall.h>
> -
>  #include <xstatconv.h>
>  
>  /* Get information about the file FD in BUF.  */
> @@ -31,14 +26,10 @@
>  int
>  __fxstat64 (int vers, int fd, struct stat64 *buf)
>  {
> -  int result;
>    struct kernel_stat kbuf;
> +  int r = INLINE_SYSCALL_CALL (fstat, fd, &kbuf);
> +  return r ?: __xstat64_conv (vers, &kbuf, buf);
>  
> -  result = INLINE_SYSCALL (fstat, 2, fd, &kbuf);
> -  if (result == 0)
> -    result = __xstat64_conv (vers, &kbuf, buf);
> -
> -  return result;
>  }
>  
>  hidden_def (__fxstat64)
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fxstat.c
> b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fxstat.c deleted file
> mode 100644 index 4f219f0b9d..0000000000
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fxstat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/fxstat.c>
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/fxstat.c
> b/sysdeps/unix/sysv/linux/s390/s390-32/fxstat.c deleted file mode
> 100644 index 4f219f0b9d..0000000000
> --- a/sysdeps/unix/sysv/linux/s390/s390-32/fxstat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/fxstat.c>
> diff --git a/sysdeps/unix/sysv/linux/sh/fxstat.c
> b/sysdeps/unix/sysv/linux/sh/fxstat.c deleted file mode 100644
> index 4f219f0b9d..0000000000
> --- a/sysdeps/unix/sysv/linux/sh/fxstat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/fxstat.c>
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/fxstat.c
> b/sysdeps/unix/sysv/linux/sparc/sparc32/fxstat.c deleted file mode
> 100644 index 4f219f0b9d..0000000000
> --- a/sysdeps/unix/sysv/linux/sparc/sparc32/fxstat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/fxstat.c>
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/fxstat.c
> b/sysdeps/unix/sysv/linux/sparc/sparc64/fxstat.c deleted file mode
> 100644 index e328ccbab0..0000000000
> --- a/sysdeps/unix/sysv/linux/sparc/sparc64/fxstat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include "../../i386/fxstat.c"
> diff --git a/sysdeps/unix/sysv/linux/wordsize-64/fxstat64.c
> b/sysdeps/unix/sysv/linux/wordsize-64/fxstat64.c deleted file mode
> 100644 index 9eff9ebeb7..0000000000
> --- a/sysdeps/unix/sysv/linux/wordsize-64/fxstat64.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -/* fxstat64 is in fxstat.c */




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 06/16] linux: Consolidate fxstatat{64}
  2020-07-23 19:46 ` [PATCH 06/16] linux: Consolidate fxstatat{64} Adhemerval Zanella via Libc-alpha
@ 2020-07-24  9:14   ` Lukasz Majewski
  0 siblings, 0 replies; 80+ messages in thread
From: Lukasz Majewski @ 2020-07-24  9:14 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Alistair Francis, libc-alpha

[-- Attachment #1: Type: text/plain, Size: 29018 bytes --]

On Thu, 23 Jul 2020 16:46:31 -0300
Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> The LFS support is implemented on fxstat64.c, instead of fxstat.c for
> 64-bit architectures.  The fxstatat.c implements the non-LFS and it is
> a no-op for !XSTAT_IS_XSTAT64.
> 
> The generic non-LFS implementation handles two cases:
> 
>   1. New kABIs which uses generic pre 64-bit time Linux ABI (csky and
>      nios): it issues __NR_fstatat64 plus handle the overflow on
> st_ino, st_size, or st_blocks.  It only handles _STAT_VER_KERNEL.
> 
>   2. Old kABIs with old non-LFS support (arm, i386, hppa, m68k,
> mips32, microblaze, s390, sh, powerpc, and sparc32).  it issues
>      __NR_fstatat64 and convert to non-LFS stat struct based on the
>      version.
> 
> Also non-LFS mips64 is an outlier and it has its own implementation
> since _STAT_VER_LINUX requires a different conversion function (it
> uses the kernel_stat as the sysissues argument since its exported ABI
> is different than the kernel one for both non-LFS and LFS
> implementation).
> 
> The generic LFS implementation handles multiple cases:
> 
>   1. XSTAT_IS_XSTAT64 being 1:
> 
>     1.1. 64-bit kABI (aarch64, ia64, powerpc64*, s390x, riscv64, and
>          x86_64): it issues __NR_newfstatat for _STAT_VER_KERNEL or
>          _STAT_VER_LINUX.
> 
>     1.2. 64-bit kABI outlier (sparc64): it issuess fstatat64 with a
>          temporary stat64 and convert to output stat64 based on the
>          input version (and using a sparc64 specific __xstat32_conv).
> 
>     1.3. New 32-bit kABIs with only 64-bit time_t support (arc and
> 	 riscv32): it issues __NR_statx and covert to struct stat64.
> 
>   2. Old ABIs with XSTAT_IS_XSTAT64 being 0 (arm, csky, i386, hppa,
> m68k, microblaze, mips32, nios2, sh, powerpc32, and sparc32): it
> issues __NR_fstat64.
> 
> Also, two special cases requires specific implementations:
> 
>   1. alpha: it uses the __NR_fstatat64 syscall instead.
> 
>   2. mips64: as for non-LFS implementation its ABIs differ from
>      glibc exported one, which requires an specific conversion
>      function to handle the kernel_stat.
> 
> Checked with a build for all affected ABIs. I also checked on x86_64,
> i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and s390x.

Reviewed-by: Lukasz Majewski <lukma@denx.de>

> ---
>  sysdeps/unix/sysv/linux/Makefile              |  3 +-
>  sysdeps/unix/sysv/linux/alpha/dl-fxstatat64.c |  1 -
>  sysdeps/unix/sysv/linux/alpha/fxstatat.c      | 52 ---------------
>  .../wordsize-32 => alpha}/fxstatat64.c        | 35 +++++-----
>  sysdeps/unix/sysv/linux/arm/fxstatat.c        |  1 -
>  sysdeps/unix/sysv/linux/fxstatat.c            | 53 ++++++---------
>  sysdeps/unix/sysv/linux/fxstatat64.c          | 65
> +++++++++++-------- .../sysv/linux/generic/wordsize-32/fxstatat.c |
> 56 ---------------- sysdeps/unix/sysv/linux/hppa/fxstatat.c       |
> 1 - sysdeps/unix/sysv/linux/i386/fxstatat.c       | 54 ---------------
>  sysdeps/unix/sysv/linux/m68k/fxstatat.c       |  1 -
>  sysdeps/unix/sysv/linux/microblaze/fxstatat.c |  1 -
>  .../unix/sysv/linux/mips/mips32/fxstatat.c    |  1 -
>  .../{wordsize-64 => mips/mips64}/fxstatat.c   | 33 +++-------
>  .../unix/sysv/linux/mips/mips64/fxstatat64.c  | 28 ++------
>  .../sysv/linux/powerpc/powerpc32/fxstatat.c   |  1 -
>  .../unix/sysv/linux/s390/s390-32/fxstatat.c   |  1 -
>  sysdeps/unix/sysv/linux/sh/fxstatat.c         |  1 -
>  .../unix/sysv/linux/sparc/sparc32/fxstatat.c  |  1 -
>  .../sysv/linux/sparc/sparc64/dl-fxstatat64.c  |  1 -
>  .../unix/sysv/linux/sparc/sparc64/fxstatat.c  |  1 -
>  .../sysv/linux/wordsize-64/dl-fxstatat64.c    |  1 -
>  .../unix/sysv/linux/wordsize-64/fxstatat64.c  |  1 -
>  23 files changed, 92 insertions(+), 301 deletions(-)
>  delete mode 100644 sysdeps/unix/sysv/linux/alpha/dl-fxstatat64.c
>  delete mode 100644 sysdeps/unix/sysv/linux/alpha/fxstatat.c
>  rename sysdeps/unix/sysv/linux/{generic/wordsize-32 =>
> alpha}/fxstatat64.c (53%) delete mode 100644
> sysdeps/unix/sysv/linux/arm/fxstatat.c delete mode 100644
> sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat.c delete mode
> 100644 sysdeps/unix/sysv/linux/hppa/fxstatat.c delete mode 100644
> sysdeps/unix/sysv/linux/i386/fxstatat.c delete mode 100644
> sysdeps/unix/sysv/linux/m68k/fxstatat.c delete mode 100644
> sysdeps/unix/sysv/linux/microblaze/fxstatat.c delete mode 100644
> sysdeps/unix/sysv/linux/mips/mips32/fxstatat.c rename
> sysdeps/unix/sysv/linux/{wordsize-64 => mips/mips64}/fxstatat.c (56%)
> delete mode 100644
> sysdeps/unix/sysv/linux/powerpc/powerpc32/fxstatat.c delete mode
> 100644 sysdeps/unix/sysv/linux/s390/s390-32/fxstatat.c delete mode
> 100644 sysdeps/unix/sysv/linux/sh/fxstatat.c delete mode 100644
> sysdeps/unix/sysv/linux/sparc/sparc32/fxstatat.c delete mode 100644
> sysdeps/unix/sysv/linux/sparc/sparc64/dl-fxstatat64.c delete mode
> 100644 sysdeps/unix/sysv/linux/sparc/sparc64/fxstatat.c delete mode
> 100644 sysdeps/unix/sysv/linux/wordsize-64/dl-fxstatat64.c delete
> mode 100644 sysdeps/unix/sysv/linux/wordsize-64/fxstatat64.c
> 
> diff --git a/sysdeps/unix/sysv/linux/Makefile
> b/sysdeps/unix/sysv/linux/Makefile index 9b2a253032..3c28adae0d 100644
> --- a/sysdeps/unix/sysv/linux/Makefile
> +++ b/sysdeps/unix/sysv/linux/Makefile
> @@ -280,8 +280,7 @@ tests += tst-fallocate tst-fallocate64
> tst-o_path-locks endif
>  
>  ifeq ($(subdir),elf)
> -sysdep-rtld-routines += dl-brk dl-sbrk dl-getcwd dl-openat64
> dl-opendir \
> -			dl-fxstatat64
> +sysdep-rtld-routines += dl-brk dl-sbrk dl-getcwd dl-openat64
> dl-opendir 
>  libof-lddlibc4 = lddlibc4
>  
> diff --git a/sysdeps/unix/sysv/linux/alpha/dl-fxstatat64.c
> b/sysdeps/unix/sysv/linux/alpha/dl-fxstatat64.c deleted file mode
> 100644 index 330b33f7c7..0000000000
> --- a/sysdeps/unix/sysv/linux/alpha/dl-fxstatat64.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include "fxstatat.c"
> diff --git a/sysdeps/unix/sysv/linux/alpha/fxstatat.c
> b/sysdeps/unix/sysv/linux/alpha/fxstatat.c deleted file mode 100644
> index c5953d250a..0000000000
> --- a/sysdeps/unix/sysv/linux/alpha/fxstatat.c
> +++ /dev/null
> @@ -1,52 +0,0 @@
> -/* Copyright (C) 2005-2020 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 __fxstatat64 __fxstatat64_disable
> -
> -#include <errno.h>
> -#include <fcntl.h>
> -#include <stddef.h>
> -#include <stdio.h>
> -#include <sys/stat.h>
> -#include <kernel_stat.h>
> -#include <sysdep.h>
> -#include <sys/syscall.h>
> -#include <xstatconv.h>
> -
> -#undef __fxstatat64
> -
> -/* Get information about the file NAME in BUF.  */
> -int
> -__fxstatat (int vers, int fd, const char *file, struct stat *st, int
> flag) -{
> -  int result, errno_out;
> -
> -  /* ??? The __fxstatat entry point is new enough that it must be
> using
> -     vers == _STAT_VER_KERNEL64.  For the benefit of
> dl-fxstatat64.c, we
> -     cannot actually check this, lest the compiler not optimize the
> rest
> -     of the function away.  */
> -
> -  result = INTERNAL_SYSCALL_CALL (fstatat64, fd, file, st, flag);
> -  if (__glibc_likely (!INTERNAL_SYSCALL_ERROR_P (result)))
> -    return result;
> -  errno_out = INTERNAL_SYSCALL_ERRNO (result);
> -  __set_errno (errno_out);
> -  return -1;
> -}
> -libc_hidden_def (__fxstatat)
> -strong_alias (__fxstatat, __fxstatat64);
> -libc_hidden_ver(__fxstatat, __fxstatat64);
> diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat64.c
> b/sysdeps/unix/sysv/linux/alpha/fxstatat64.c similarity index 53%
> rename from sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat64.c
> rename to sysdeps/unix/sysv/linux/alpha/fxstatat64.c
> index 894f6dd396..f10c1d31e8 100644
> --- a/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat64.c
> +++ b/sysdeps/unix/sysv/linux/alpha/fxstatat64.c
> @@ -1,7 +1,6 @@
> -/* __fxstatat64 () implementation.
> -   Copyright (C) 2016-2020 Free Software Foundation, Inc.
> +/* fxstat using old-style Unix stat system call.
> +   Copyright (C) 2004-2020 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
> @@ -17,21 +16,21 @@
>     License along with the GNU C Library.  If not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -/* Hide the prototype for __fxstatat so that GCC will not complain
> about
> -   the different function signature if it is aliased to
> __fxstatat64.
> -   If XSTAT_IS_XSTAT64 is set to non-zero then the stat and stat64
> structures
> -   have an identical layout but different type names.  */
> -
> -#define __fxstatat __fxstatat_disable
> -
> +#define __fxstatat __redirect___fxstatat64
>  #include <sys/stat.h>
> -#undef _STAT_VER_LINUX
> -#define _STAT_VER_LINUX _STAT_VER_KERNEL
> -
> -#include <sysdeps/unix/sysv/linux/fxstatat64.c>
> -
>  #undef __fxstatat
> -#if XSTAT_IS_XSTAT64
> -weak_alias (__fxstatat64, __fxstatat)
> -libc_hidden_ver (__fxstatat64, __fxstatat)
> +#include <kernel_stat.h>
> +#include <sysdep.h>
> +#include <xstatconv.h>
> +
> +/* Get information about the file NAME in BUF.  */
> +int
> +__fxstatat64 (int vers, int fd, const char *file, struct stat64 *st,
> int flag) +{
> +  return INLINE_SYSCALL_CALL (fstatat64, fd, file, st, flag);
> +}
> +libc_hidden_def (__fxstatat64)
> +#if IS_IN(libc)
> +strong_alias (__fxstatat64, __fxstatat);
> +hidden_ver (__fxstatat64, __fxstatat)
>  #endif
> diff --git a/sysdeps/unix/sysv/linux/arm/fxstatat.c
> b/sysdeps/unix/sysv/linux/arm/fxstatat.c deleted file mode 100644
> index 0f8b3135d8..0000000000
> --- a/sysdeps/unix/sysv/linux/arm/fxstatat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/fxstatat.c>
> diff --git a/sysdeps/unix/sysv/linux/fxstatat.c
> b/sysdeps/unix/sysv/linux/fxstatat.c index 937fec45c2..0291a2c598
> 100644 --- a/sysdeps/unix/sysv/linux/fxstatat.c
> +++ b/sysdeps/unix/sysv/linux/fxstatat.c
> @@ -1,4 +1,5 @@
> -/* Copyright (C) 2005-2020 Free Software Foundation, Inc.
> +/* fxstatat used on fstatat, Linux implementation.
> +   Copyright (C) 2005-2020 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,48 +16,36 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -/* Ho hum, if fxstatat == fxstatat64 we must get rid of the
> prototype or gcc
> -   will complain since they don't strictly match.  */
> -#define __fxstatat64 __fxstatat64_disable
> -
> -#include <errno.h>
> -#include <fcntl.h>
> -#include <stddef.h>
> -#include <stdio.h>
> -#include <string.h>
>  #include <sys/stat.h>
> +#include <fcntl.h>
>  #include <kernel_stat.h>
> -
>  #include <sysdep.h>
> -#include <sys/syscall.h>
>  
> -#include <xstatconv.h>
> +#if !XSTAT_IS_XSTAT64
> +# include <xstatconv.h>
> +# include <xstatover.h>
>  
> -/* Get information about the file NAME in BUF.  */
> +/* Get information about the file FD in BUF.  */
>  int
>  __fxstatat (int vers, int fd, const char *file, struct stat *st, int
> flag) {
> -  int result;
>  #if STAT_IS_KERNEL_STAT
> -# define kst (*st)
> -#else
> -  struct kernel_stat kst;
> -#endif
> -
> -  result = INTERNAL_SYSCALL_CALL (newfstatat, fd, file, &kst, flag);
> -  if (!__glibc_likely (INTERNAL_SYSCALL_ERROR_P (result)))
> +  /* New kABIs which uses generic pre 64-bit time Linux ABI, e.g.
> +     csky, nios2  */
> +  if (vers == _STAT_VER_KERNEL)
>      {
> -#if STAT_IS_KERNEL_STAT
> -      return 0;
> +      int r = INLINE_SYSCALL_CALL (fstatat64, fd, file, st, flag);
> +      return r ?: stat_overflow (st);
> +    }
> +  return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
>  #else
> -      return __xstat_conv (vers, &kst, st);
> +  /* Old kABIs with old non-LFS support, e.g. arm, i386, hppa, m68k,
> mips32,
> +     microblaze, s390, sh, powerpc32, and sparc32.  */
> +  struct stat64 st64;
> +  int r = INLINE_SYSCALL_CALL (fstatat64, fd, file, &st64, flag);
> +  return r ?: __xstat32_conv (vers, &st64, st);
>  #endif
> -    }
> -  return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO
> (result)); }
>  libc_hidden_def (__fxstatat)
> -#if XSTAT_IS_XSTAT64
> -# undef __fxstatat64
> -strong_alias (__fxstatat, __fxstatat64);
> -libc_hidden_def (__fxstatat64)
> -#endif
> +
> +#endif /* XSTAT_IS_XSTAT64  */
> diff --git a/sysdeps/unix/sysv/linux/fxstatat64.c
> b/sysdeps/unix/sysv/linux/fxstatat64.c index e24b456604..ac33ab4fc9
> 100644 --- a/sysdeps/unix/sysv/linux/fxstatat64.c
> +++ b/sysdeps/unix/sysv/linux/fxstatat64.c
> @@ -1,4 +1,5 @@
> -/* Copyright (C) 2005-2020 Free Software Foundation, Inc.
> +/* fxstatat64 used on fstatat64, Linux implementation.
> +   Copyright (C) 2005-2020 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,41 +16,53 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -#include <errno.h>
> -#include <fcntl.h>
> -#include <stddef.h>
> -#include <stdio.h>
> -#include <string.h>
> +#define __fxstatat __redirect___fxstatat
>  #include <sys/stat.h>
> +#undef __fxstatat
> +#include <fcntl.h>
>  #include <kernel_stat.h>
> -
>  #include <sysdep.h>
> -#include <sys/syscall.h>
> -
> +#include <xstatconv.h>
>  #include <statx_cp.h>
>  
> -/* Get information about the file NAME in BUF.  */
> +/* Get information about the file FD in BUF.  */
>  
>  int
>  __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st,
> int flag) {
> -  if (__glibc_unlikely (vers != _STAT_VER_LINUX))
> -    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
> -
> -  int result;
> -
> -#ifdef __NR_fstatat64
> -  result = INTERNAL_SYSCALL_CALL (fstatat64, fd, file, st, flag);
> +#if XSTAT_IS_XSTAT64
> +# ifdef __NR_newfstatat
> +  /* 64-bit kABI, e.g. aarch64, ia64, powerpc64*, s390x, riscv64, and
> +     x86_64.  */
> +  if (vers == _STAT_VER_KERNEL || vers == _STAT_VER_LINUX)
> +    return INLINE_SYSCALL_CALL (newfstatat, fd, file, st, flag);
> +# elif defined __NR_fstatat64
> +  /* 64-bit kABI outlier, e.g. sparc64.  */
> +  struct stat64 st64;
> +  int r = INLINE_SYSCALL_CALL (fstatat64, fd, file, &st64, flag);
> +  return r ?: __xstat32_conv (vers, &st64, (struct stat *) st);
> +# else
> +  /* New 32-bit kABIs with only 64-bit time_t support, e.g. arc,
> riscv32.  */
> +  if (vers == _STAT_VER_KERNEL)
> +    {
> +      struct statx tmp;
> +      int r = INLINE_SYSCALL_CALL (statx, fd, file, AT_NO_AUTOMOUNT
> | flag,
> +				   STATX_BASIC_STATS, &tmp);
> +      if (r == 0)
> +	__cp_stat64_statx (st, &tmp);
> +      return r;
> +    }
> +# endif
>  #else
> -  struct statx tmp;
> -
> -  result = INTERNAL_SYSCALL_CALL (statx, fd, file, AT_NO_AUTOMOUNT |
> flag,
> -				  STATX_BASIC_STATS, &tmp);
> -  if (result == 0)
> -    __cp_stat64_statx (st, &tmp);
> +  /* All kABIs with non-LFS support, e.g. arm, csky, i386, hppa,
> m68k,
> +     microblaze, mips32, nios2, sh, powerpc32, and sparc32.  */
> +  if (vers == _STAT_VER_LINUX)
> +    return INLINE_SYSCALL_CALL (fstatat64, fd, file, st, flag);
>  #endif
> -  if (!__glibc_likely (INTERNAL_SYSCALL_ERROR_P (result)))
> -    return 0;
> -  return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO
> (result));
> +  return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
>  }
>  libc_hidden_def (__fxstatat64)
> +#if XSTAT_IS_XSTAT64 && IS_IN(libc)
> +strong_alias (__fxstatat64, __fxstatat);
> +hidden_ver (__fxstatat64, __fxstatat)
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat.c
> b/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat.c deleted file
> mode 100644 index 8df65ebea0..0000000000
> --- a/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat.c
> +++ /dev/null
> @@ -1,56 +0,0 @@
> -/* Copyright (C) 2011-2020 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 <errno.h>
> -#include <fcntl.h>
> -#include <stddef.h>
> -#include <stdio.h>
> -#include <sys/stat.h>
> -#include <kernel_stat.h>
> -
> -#include <sysdep.h>
> -#include <sys/syscall.h>
> -
> -#if !XSTAT_IS_XSTAT64
> -#include "overflow.h"
> -#include <statx_cp.h>
> -
> -/* Get information about the file NAME in BUF.  */
> -int
> -__fxstatat (int vers, int fd, const char *file, struct stat *buf,
> int flag) -{
> -  if (vers == _STAT_VER_KERNEL)
> -    {
> -# ifdef __NR_fstatat64
> -      int rc = INLINE_SYSCALL (fstatat64, 4, fd, file, buf, flag);
> -# else
> -      struct statx tmp;
> -      int rc = INLINE_SYSCALL (statx, 5, fd, file,
> -                               AT_NO_AUTOMOUNT | flag,
> -                               STATX_BASIC_STATS, &tmp);
> -      if (rc == 0)
> -        __cp_stat64_statx ((struct stat64 *)buf, &tmp);
> -# endif
> -      return rc ?: stat_overflow (buf);
> -    }
> -
> -  errno = EINVAL;
> -  return -1;
> -}
> -libc_hidden_def (__fxstatat)
> -#endif
> diff --git a/sysdeps/unix/sysv/linux/hppa/fxstatat.c
> b/sysdeps/unix/sysv/linux/hppa/fxstatat.c deleted file mode 100644
> index 0f8b3135d8..0000000000
> --- a/sysdeps/unix/sysv/linux/hppa/fxstatat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/fxstatat.c>
> diff --git a/sysdeps/unix/sysv/linux/i386/fxstatat.c
> b/sysdeps/unix/sysv/linux/i386/fxstatat.c deleted file mode 100644
> index f720f6e429..0000000000
> --- a/sysdeps/unix/sysv/linux/i386/fxstatat.c
> +++ /dev/null
> @@ -1,54 +0,0 @@
> -/* Copyright (C) 2005-2020 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/>.  */
> -
> -/* Ho hum, if fxstatat == fxstatat64 we must get rid of the
> prototype or gcc
> -   will complain since they don't strictly match.  */
> -#define __fxstatat64 __fxstatat64_disable
> -
> -#include <errno.h>
> -#include <fcntl.h>
> -#include <stddef.h>
> -#include <stdio.h>
> -#include <string.h>
> -#include <sys/stat.h>
> -#include <kernel_stat.h>
> -
> -#include <sysdep.h>
> -#include <sys/syscall.h>
> -
> -#include <xstatconv.h>
> -
> -
> -/* Get information about the file NAME relative to FD in ST.  */
> -int
> -__fxstatat (int vers, int fd, const char *file, struct stat *st, int
> flag) -{
> -  int result;
> -  struct stat64 st64;
> -
> -  result = INTERNAL_SYSCALL_CALL (fstatat64, fd, file, &st64, flag);
> -  if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result)))
> -    return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO
> (result));
> -  else
> -    return __xstat32_conv (vers, &st64, st);
> -}
> -libc_hidden_def (__fxstatat)
> -#if XSTAT_IS_XSTAT64
> -# undef __fxstatat64
> -strong_alias (__fxstatat, __fxstatat64);
> -libc_hidden_ver (__fxstatat, __fxstatat64)
> -#endif
> diff --git a/sysdeps/unix/sysv/linux/m68k/fxstatat.c
> b/sysdeps/unix/sysv/linux/m68k/fxstatat.c deleted file mode 100644
> index 0f8b3135d8..0000000000
> --- a/sysdeps/unix/sysv/linux/m68k/fxstatat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/fxstatat.c>
> diff --git a/sysdeps/unix/sysv/linux/microblaze/fxstatat.c
> b/sysdeps/unix/sysv/linux/microblaze/fxstatat.c deleted file mode
> 100644 index 0f8b3135d8..0000000000
> --- a/sysdeps/unix/sysv/linux/microblaze/fxstatat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/fxstatat.c>
> diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fxstatat.c
> b/sysdeps/unix/sysv/linux/mips/mips32/fxstatat.c deleted file mode
> 100644 index 0f8b3135d8..0000000000
> --- a/sysdeps/unix/sysv/linux/mips/mips32/fxstatat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/fxstatat.c>
> diff --git a/sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c
> b/sysdeps/unix/sysv/linux/mips/mips64/fxstatat.c similarity index 56%
> rename from sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c
> rename to sysdeps/unix/sysv/linux/mips/mips64/fxstatat.c
> index b8f5ab562e..58410a1441 100644
> --- a/sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c
> +++ b/sysdeps/unix/sysv/linux/mips/mips64/fxstatat.c
> @@ -1,4 +1,5 @@
> -/* Copyright (C) 2005-2020 Free Software Foundation, Inc.
> +/* fxstat using old-style Unix fstat system call.
> +   Copyright (C) 1991-2020 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,34 +16,18 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -/* Ho hum, since fxstatat == fxstatat64 we must get rid of the
> -   prototype or gcc will complain since they don't strictly match.
> */ -#define __fxstatat64 __fxstatat64_disable
> -
> -#include <errno.h>
> -#include <fcntl.h>
> -#include <stddef.h>
> -#include <stdio.h>
> -#include <string.h>
>  #include <sys/stat.h>
> -
> +#include <fcntl.h>
> +#include <kernel_stat.h>
>  #include <sysdep.h>
> -#include <sys/syscall.h>
> -
> +#include <xstatconv.h>
>  
> -/* Get information about the file NAME relative to FD in ST.  */
> +/* Get information about the file FD in BUF.  */
>  int
>  __fxstatat (int vers, int fd, const char *file, struct stat *st, int
> flag) {
> -  if (vers != _STAT_VER_KERNEL && vers != _STAT_VER_LINUX)
> -    {
> -      __set_errno (EINVAL);
> -      return -1;
> -    }
> -
> -  return INLINE_SYSCALL (newfstatat, 4, fd, file, st, flag);
> +  struct kernel_stat kst;
> +  int r = INLINE_SYSCALL_CALL (newfstatat, fd, file, &kst, flag);
> +  return r ?: __xstat_conv (vers, &kst, st);
>  }
>  libc_hidden_def (__fxstatat)
> -#undef __fxstatat64
> -strong_alias (__fxstatat, __fxstatat64);
> -strong_alias (__fxstatat64, __GI___fxstatat64)
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c
> b/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c index
> 62df5fb26c..e5416d8971 100644 ---
> a/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c +++
> b/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c @@ -15,17 +15,9 @@
>     License along with the GNU C Library.  If not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -#include <errno.h>
> -#include <fcntl.h>
> -#include <stddef.h>
> -#include <stdio.h>
> -#include <string.h>
>  #include <sys/stat.h>
>  #include <kernel_stat.h>
> -
>  #include <sysdep.h>
> -#include <sys/syscall.h>
> -
>  #include <xstatconv.h>
>  
>  /* Get information about the file NAME in BUF.  */
> @@ -33,22 +25,12 @@
>  int
>  __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st,
> int flag) {
> -  if (__builtin_expect (vers != _STAT_VER_LINUX, 0))
> -    {
> -      __set_errno (EINVAL);
> -      return -1;
> -    }
> -
> -  int result;
> -  struct kernel_stat kst;
> -
> -  result = INTERNAL_SYSCALL_CALL (newfstatat, fd, file, &kst, flag);
> -  if (!__glibc_likely (INTERNAL_SYSCALL_ERROR_P (result)))
> -    return __xstat64_conv (vers, &kst, st);
> -  else
> +  if (vers == _STAT_VER_LINUX)
>      {
> -      __set_errno (INTERNAL_SYSCALL_ERRNO (result));
> -      return -1;
> +      struct kernel_stat kst;
> +      int r = INLINE_SYSCALL_CALL (newfstatat, fd, file, &kst,
> flag);;
> +      return r ?: __xstat64_conv (vers, &kst, st);
>      }
> +  return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
>  }
>  libc_hidden_def (__fxstatat64)
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fxstatat.c
> b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fxstatat.c deleted file
> mode 100644 index 0f8b3135d8..0000000000
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fxstatat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/fxstatat.c>
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/fxstatat.c
> b/sysdeps/unix/sysv/linux/s390/s390-32/fxstatat.c deleted file mode
> 100644 index 0f8b3135d8..0000000000
> --- a/sysdeps/unix/sysv/linux/s390/s390-32/fxstatat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/fxstatat.c>
> diff --git a/sysdeps/unix/sysv/linux/sh/fxstatat.c
> b/sysdeps/unix/sysv/linux/sh/fxstatat.c deleted file mode 100644
> index 0f8b3135d8..0000000000
> --- a/sysdeps/unix/sysv/linux/sh/fxstatat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/fxstatat.c>
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/fxstatat.c
> b/sysdeps/unix/sysv/linux/sparc/sparc32/fxstatat.c deleted file mode
> 100644 index 0f8b3135d8..0000000000
> --- a/sysdeps/unix/sysv/linux/sparc/sparc32/fxstatat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/fxstatat.c>
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/dl-fxstatat64.c
> b/sysdeps/unix/sysv/linux/sparc/sparc64/dl-fxstatat64.c deleted file
> mode 100644 index 330b33f7c7..0000000000
> --- a/sysdeps/unix/sysv/linux/sparc/sparc64/dl-fxstatat64.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include "fxstatat.c"
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/fxstatat.c
> b/sysdeps/unix/sysv/linux/sparc/sparc64/fxstatat.c deleted file mode
> 100644 index db08af8e0f..0000000000
> --- a/sysdeps/unix/sysv/linux/sparc/sparc64/fxstatat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include "../../i386/fxstatat.c"
> diff --git a/sysdeps/unix/sysv/linux/wordsize-64/dl-fxstatat64.c
> b/sysdeps/unix/sysv/linux/wordsize-64/dl-fxstatat64.c deleted file
> mode 100644 index 330b33f7c7..0000000000
> --- a/sysdeps/unix/sysv/linux/wordsize-64/dl-fxstatat64.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include "fxstatat.c"
> diff --git a/sysdeps/unix/sysv/linux/wordsize-64/fxstatat64.c
> b/sysdeps/unix/sysv/linux/wordsize-64/fxstatat64.c deleted file mode
> 100644 index 05e7f413bb..0000000000
> --- a/sysdeps/unix/sysv/linux/wordsize-64/fxstatat64.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -/* fxstatat64 is in fxstatat.c */




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 07/16] Linux: Consolidate xmknod
  2020-07-23 19:46 ` [PATCH 07/16] Linux: Consolidate xmknod Adhemerval Zanella via Libc-alpha
@ 2020-07-24  9:14   ` Lukasz Majewski
  0 siblings, 0 replies; 80+ messages in thread
From: Lukasz Majewski @ 2020-07-24  9:14 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Alistair Francis, libc-alpha

[-- Attachment #1: Type: text/plain, Size: 4126 bytes --]

On Thu, 23 Jul 2020 16:46:32 -0300
Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> The __NR_mknodat syscall is supported on all kernels, so the generic
> implementation is used as default.
> 
> Checked on x86_64-linux-gnu and i686-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>

> ---
>  sysdeps/unix/sysv/linux/generic/xmknod.c | 54
> ------------------------ sysdeps/unix/sysv/linux/xmknod.c         |
> 8 ++-- 2 files changed, 3 insertions(+), 59 deletions(-)
>  delete mode 100644 sysdeps/unix/sysv/linux/generic/xmknod.c
> 
> diff --git a/sysdeps/unix/sysv/linux/generic/xmknod.c
> b/sysdeps/unix/sysv/linux/generic/xmknod.c deleted file mode 100644
> index a51fcbee22..0000000000
> --- a/sysdeps/unix/sysv/linux/generic/xmknod.c
> +++ /dev/null
> @@ -1,54 +0,0 @@
> -/* Copyright (C) 2011-2020 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 <errno.h>
> -#include <fcntl.h>
> -#include <sys/types.h>
> -#include <sys/stat.h>
> -#include <sys/sysmacros.h>
> -
> -#include <sysdep.h>
> -#include <sys/syscall.h>
> -
> -/* Create a device file named PATH, with permission and special bits
> MODE
> -   and device number DEV (which can be constructed from major and
> minor
> -   device numbers with the `makedev' macro above).  */
> -int
> -__xmknod (int vers, const char *path, mode_t mode, dev_t *dev)
> -{
> -  unsigned long long int k_dev;
> -
> -  if (vers != _MKNOD_VER)
> -    {
> -      __set_errno (EINVAL);
> -      return -1;
> -    }
> -
> -  /* We must convert the value to dev_t type used by the kernel.  */
> -  k_dev = (*dev) & ((1ULL << 32) - 1);
> -  if (k_dev != *dev)
> -    {
> -      __set_errno (EINVAL);
> -      return -1;
> -    }
> -
> -  return INLINE_SYSCALL (mknodat, 4, AT_FDCWD, path, mode,
> -                         (unsigned int) k_dev);
> -}
> -weak_alias (__xmknod, _xmknod)
> -libc_hidden_def (__xmknod)
> diff --git a/sysdeps/unix/sysv/linux/xmknod.c
> b/sysdeps/unix/sysv/linux/xmknod.c index 5d0ae97c34..42809d4c57 100644
> --- a/sysdeps/unix/sysv/linux/xmknod.c
> +++ b/sysdeps/unix/sysv/linux/xmknod.c
> @@ -16,13 +16,10 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -#include <errno.h>
> -#include <sys/types.h>
>  #include <sys/stat.h>
>  #include <sys/sysmacros.h>
> -
> +#include <fcntl.h>
>  #include <sysdep.h>
> -#include <sys/syscall.h>
>  
>  /* Create a device file named PATH, with permission and special bits
> MODE and device number DEV (which can be constructed from major and
> minor @@ -40,7 +37,8 @@ __xmknod (int vers, const char *path, mode_t
> mode, dev_t *dev) if (k_dev != *dev)
>      return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
>  
> -  return INLINE_SYSCALL (mknod, 3, path, mode, (unsigned int) k_dev);
> +  return INLINE_SYSCALL_CALL (mknodat, AT_FDCWD, path, mode,
> +			      (unsigned int) k_dev);
>  }
>  
>  weak_alias (__xmknod, _xmknod)




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 08/16] Remove internal usage of extensible stat functions
  2020-07-23 19:46 ` [PATCH 08/16] Remove internal usage of extensible stat functions Adhemerval Zanella via Libc-alpha
@ 2020-07-24  9:16   ` Lukasz Majewski
  0 siblings, 0 replies; 80+ messages in thread
From: Lukasz Majewski @ 2020-07-24  9:16 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Alistair Francis, libc-alpha

[-- Attachment #1: Type: text/plain, Size: 43749 bytes --]

On Thu, 23 Jul 2020 16:46:33 -0300
Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> It replaces the internal usage of __{f,l}xstat{at}{64} with the
> __{f,l}stat{at}{64}.  It should not change the generate code since
> sys/stat.h explicit defines redirections to internal calls back to
> xstat* symbols.
> 
> Checked with a build for all affected ABIs.  I also check on
> x86_64-linux-gnu and i686-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>

> ---
>  catgets/open_catalog.c              |  2 +-
>  csu/check_fds.c                     |  2 +-
>  elf/cache.c                         |  4 +--
>  elf/dl-load.c                       |  4 +--
>  elf/dl-misc.c                       |  2 +-
>  elf/dl-profile.c                    |  2 +-
>  iconv/gconv_cache.c                 |  2 +-
>  include/sys/stat.h                  |  1 +
>  inet/rcmd.c                         |  4 +--
>  inet/ruserpass.c                    |  2 +-
>  intl/loadmsgcat.c                   |  2 +-
>  io/file_change_detection.c          |  4 +--
>  io/fts.c                            | 15 +++++-----
>  io/fts64.c                          |  5 ++--
>  io/ftw.c                            | 46
> ++++++++++++++--------------- io/ftw64.c                          |
> 8 ++--- io/getdirname.c                     |  4 +--
>  io/mkdirat.c                        |  2 +-
>  io/mkfifoat.c                       |  2 +-
>  io/openat.c                         |  2 +-
>  io/openat64.c                       |  2 +-
>  io/xmknodat.c                       |  2 +-
>  libio/fileops.c                     |  2 +-
>  locale/loadarchive.c                |  4 +--
>  locale/loadlocale.c                 |  4 +--
>  misc/daemon.c                       |  2 +-
>  misc/getusershell.c                 |  2 +-
>  nptl/sem_open.c                     |  2 +-
>  nscd/nscd_helper.c                  |  2 +-
>  posix/glob.c                        |  7 -----
>  stdlib/canonicalize.c               |  2 +-
>  sysdeps/gnu/glob64-lstat-compat.c   |  2 +-
>  sysdeps/gnu/glob64.c                |  2 +-
>  sysdeps/mach/hurd/ptsname.c         |  2 +-
>  sysdeps/posix/dl-fileid.h           |  2 +-
>  sysdeps/posix/euidaccess.c          |  2 +-
>  sysdeps/posix/fdopendir.c           |  2 +-
>  sysdeps/posix/fpathconf.c           |  2 +-
>  sysdeps/posix/getaddrinfo.c         |  4 +--
>  sysdeps/posix/isfdtype.c            |  2 +-
>  sysdeps/posix/opendir.c             |  2 +-
>  sysdeps/posix/pathconf.c            |  2 +-
>  sysdeps/posix/posix_fallocate.c     |  2 +-
>  sysdeps/posix/posix_fallocate64.c   |  2 +-
>  sysdeps/posix/sysconf.c             |  2 +-
>  sysdeps/posix/tempname.c            |  5 ++--
>  sysdeps/unix/sysv/linux/faccessat.c |  2 +-
>  sysdeps/unix/sysv/linux/fexecve.c   |  4 +--
>  sysdeps/unix/sysv/linux/oldglob.c   |  2 +-
>  sysdeps/unix/sysv/linux/pathconf.c  |  4 +--
>  sysdeps/unix/sysv/linux/ptsname.c   |  4 +--
>  sysdeps/unix/sysv/linux/ttyname.c   |  8 ++---
>  sysdeps/unix/sysv/linux/ttyname_r.c |  8 ++---
>  sysvipc/ftok.c                      |  2 +-
>  time/getdate.c                      |  2 +-
>  time/tzfile.c                       |  4 +--
>  56 files changed, 108 insertions(+), 113 deletions(-)
> 
> diff --git a/catgets/open_catalog.c b/catgets/open_catalog.c
> index 6b14963d78..cf8d635ae7 100644
> --- a/catgets/open_catalog.c
> +++ b/catgets/open_catalog.c
> @@ -194,7 +194,7 @@ __open_catalog (const char *cat_name, const char
> *nlspath, const char *env_var, return -1;
>      }
>  
> -  if (__builtin_expect (__fxstat64 (_STAT_VER, fd, &st), 0) < 0)
> +  if (__builtin_expect (__fstat64 (fd, &st), 0) < 0)
>      goto close_unlock_return;
>  
>    if (__builtin_expect (!S_ISREG (st.st_mode), 0)
> diff --git a/csu/check_fds.c b/csu/check_fds.c
> index 30634b81a7..29d9d04acb 100644
> --- a/csu/check_fds.c
> +++ b/csu/check_fds.c
> @@ -71,7 +71,7 @@ check_one_fd (int fd, int mode)
>  	 decsriptor numbers, in this order.  */
>        struct stat64 st;
>        if (__builtin_expect (nullfd != fd, 0)
> -	  || __builtin_expect (__fxstat64 (_STAT_VER, fd, &st), 0)
> != 0
> +	  || __builtin_expect (__fstat64 (fd, &st), 0) != 0
>  	  || __builtin_expect (S_ISCHR (st.st_mode), 1) == 0
>  	  || st.st_rdev != dev)
>  	/* We cannot even give an error message here since it would
> diff --git a/elf/cache.c b/elf/cache.c
> index d92b4e59c1..1eb1455883 100644
> --- a/elf/cache.c
> +++ b/elf/cache.c
> @@ -163,7 +163,7 @@ print_cache (const char *cache_name)
>      error (EXIT_FAILURE, errno, _("Can't open cache file %s\n"),
> cache_name); 
>    struct stat64 st;
> -  if (fstat64 (fd, &st) < 0
> +  if (__fstat64 (fd, &st) < 0
>        /* No need to map the file if it is empty.  */
>        || st.st_size == 0)
>      {
> @@ -699,7 +699,7 @@ load_aux_cache (const char *aux_cache_name)
>      }
>  
>    struct stat64 st;
> -  if (fstat64 (fd, &st) < 0 || st.st_size < sizeof (struct
> aux_cache_file))
> +  if (__fstat64 (fd, &st) < 0 || st.st_size < sizeof (struct
> aux_cache_file)) {
>        close (fd);
>        init_aux_cache ();
> diff --git a/elf/dl-load.c b/elf/dl-load.c
> index e39980fb19..646c5dca40 100644
> --- a/elf/dl-load.c
> +++ b/elf/dl-load.c
> @@ -1914,7 +1914,7 @@ open_path (const char *name, size_t namelen,
> int mode, 
>  		  buf[buflen - namelen - 1] = '\0';
>  
> -		  if (__xstat64 (_STAT_VER, buf, &st) != 0
> +		  if (__stat64 (buf, &st) != 0
>  		      || ! S_ISDIR (st.st_mode))
>  		    /* The directory does not exist or it is no
> directory.  */ this_dir->status[cnt] = nonexisting;
> @@ -1934,7 +1934,7 @@ open_path (const char *name, size_t namelen,
> int mode, directories and so exploit the bugs.  */
>  	      struct stat64 st;
>  
> -	      if (__fxstat64 (_STAT_VER, fd, &st) != 0
> +	      if (__fstat64 (fd, &st) != 0
>  		  || (st.st_mode & S_ISUID) == 0)
>  		{
>  		  /* The shared object cannot be tested for being
> SUID diff --git a/elf/dl-misc.c b/elf/dl-misc.c
> index f9d1fd7993..aee62e1e60 100644
> --- a/elf/dl-misc.c
> +++ b/elf/dl-misc.c
> @@ -47,7 +47,7 @@ _dl_sysdep_read_whole_file (const char *file,
> size_t *sizep, int prot) int fd = __open64_nocancel (file, O_RDONLY |
> O_CLOEXEC); if (fd >= 0)
>      {
> -      if (__fxstat64 (_STAT_VER, fd, &st) >= 0)
> +      if (__fstat64 (fd, &st) >= 0)
>  	{
>  	  *sizep = st.st_size;
>  
> diff --git a/elf/dl-profile.c b/elf/dl-profile.c
> index c681f5415c..89dd70ba3b 100644
> --- a/elf/dl-profile.c
> +++ b/elf/dl-profile.c
> @@ -342,7 +342,7 @@ _dl_start_profile (void)
>        return;
>      }
>  
> -  if (__fxstat64 (_STAT_VER, fd, &st) < 0 || !S_ISREG (st.st_mode))
> +  if (__fstat64 (fd, &st) < 0 || !S_ISREG (st.st_mode))
>      {
>        /* Not stat'able or not a regular file => don't use it.  */
>        errstr = "%s: cannot stat file: %s\n";
> diff --git a/iconv/gconv_cache.c b/iconv/gconv_cache.c
> index 9fe371b4c0..b326cd19e2 100644
> --- a/iconv/gconv_cache.c
> +++ b/iconv/gconv_cache.c
> @@ -64,7 +64,7 @@ __gconv_load_cache (void)
>      return -1;
>  
>    /* Get information about the file.  */
> -  if (__builtin_expect (__fxstat64 (_STAT_VER, fd, &st), 0) < 0
> +  if (__builtin_expect (__fstat64 (fd, &st), 0) < 0
>        /* We do not have to start looking at the file if it cannot
> contain at least the cache header.  */
>        || (size_t) st.st_size < sizeof (struct gconvcache_header))
> diff --git a/include/sys/stat.h b/include/sys/stat.h
> index 92284ca48b..f8847cf73e 100644
> --- a/include/sys/stat.h
> +++ b/include/sys/stat.h
> @@ -53,6 +53,7 @@ extern __typeof (__fxstatat64) __fxstatat64
> attribute_hidden; #define lstat64(fname, buf)  __lxstat64 (_STAT_VER,
> fname, buf) #define __lstat64(fname, buf)  __lxstat64 (_STAT_VER,
> fname, buf) #define stat64(fname, buf) __xstat64 (_STAT_VER, fname,
> buf) +#define __stat64(fname, buf) __xstat64 (_STAT_VER, fname, buf)
>  #define fstat64(fd, buf) __fxstat64 (_STAT_VER, fd, buf)
>  #define __fstat64(fd, buf) __fxstat64 (_STAT_VER, fd, buf)
>  #define fstat(fd, buf) __fxstat (_STAT_VER, fd, buf)
> diff --git a/inet/rcmd.c b/inet/rcmd.c
> index 8a9616f847..452ff7d099 100644
> --- a/inet/rcmd.c
> +++ b/inet/rcmd.c
> @@ -474,7 +474,7 @@ iruserfopen (const char *file, uid_t okuser)
>    /* If not a regular file, if owned by someone other than user or
>       root, if writeable by anyone but the owner, or if hardlinked
>       anywhere, quit.  */
> -  if (__lxstat64 (_STAT_VER, file, &st))
> +  if (__lstat64 (file, &st))
>      cp = _("lstat failed");
>    else if (!S_ISREG (st.st_mode))
>      cp = _("not regular file");
> @@ -483,7 +483,7 @@ iruserfopen (const char *file, uid_t okuser)
>        res = fopen (file, "rce");
>        if (!res)
>  	cp = _("cannot open");
> -      else if (__fxstat64 (_STAT_VER, fileno (res), &st) < 0)
> +      else if (__fstat64 (fileno (res), &st) < 0)
>  	cp = _("fstat failed");
>        else if (st.st_uid && st.st_uid != okuser)
>  	cp = _("bad owner");
> diff --git a/inet/ruserpass.c b/inet/ruserpass.c
> index 4fa6520c1a..d61a72877d 100644
> --- a/inet/ruserpass.c
> +++ b/inet/ruserpass.c
> @@ -174,7 +174,7 @@ next:
>  			break;
>  		case PASSWD:
>  			if (strcmp(*aname, "anonymous") &&
> -			    fstat64(fileno(cfile), &stb) >= 0 &&
> +			    __fstat64(fileno(cfile), &stb) >= 0 &&
>  			    (stb.st_mode & 077) != 0) {
>  	warnx(_("Error: .netrc file is readable by others."));
>  	warnx(_("Remove 'password' line or make file unreadable by
> others.")); diff --git a/intl/loadmsgcat.c b/intl/loadmsgcat.c
> index 91c1ef156a..d44a4a0b14 100644
> --- a/intl/loadmsgcat.c
> +++ b/intl/loadmsgcat.c
> @@ -804,7 +804,7 @@ _nl_load_domain (struct loaded_l10nfile
> *domain_file, /* We must know about the size of the file.  */
>    if (
>  #ifdef _LIBC
> -      __builtin_expect (fstat64 (fd, &st) != 0, 0)
> +      __builtin_expect (__fstat64 (fd, &st) != 0, 0)
>  #else
>        __builtin_expect (fstat (fd, &st) != 0, 0)
>  #endif
> diff --git a/io/file_change_detection.c b/io/file_change_detection.c
> index c6d700ed05..f52d8fecfa 100644
> --- a/io/file_change_detection.c
> +++ b/io/file_change_detection.c
> @@ -67,7 +67,7 @@ __file_change_detection_for_path (struct
> file_change_detection *file, const char *path)
>  {
>    struct stat64 st;
> -  if (stat64 (path, &st) != 0)
> +  if (__stat64 (path, &st) != 0)
>      switch (errno)
>        {
>        case EACCES:
> @@ -105,7 +105,7 @@ __file_change_detection_for_fp (struct
> file_change_detection *file, else
>      {
>        struct stat64 st;
> -      if (fstat64 (__fileno (fp), &st) != 0)
> +      if (__fstat64 (__fileno (fp), &st) != 0)
>          /* If we already have a file descriptor, all errors are
> fatal.  */ return false;
>        else
> diff --git a/io/fts.c b/io/fts.c
> index ba83691859..9668a205c3 100644
> --- a/io/fts.c
> +++ b/io/fts.c
> @@ -81,8 +81,9 @@ static char sccsid[] = "@(#)fts.c	8.6
> (Berkeley) 8/14/94"; # define FTSOBJ FTS
>  # define FTSENTRY FTSENT
>  # define INO_T ino_t
> -# define STAT stat
> -# define LSTAT lstat
> +# define STRUCT_STAT stat
> +# define STAT __stat
> +# define LSTAT __lstat
>  #endif
>  
>  static FTSENTRY	*fts_alloc (FTSOBJ *, const char *, size_t);
> @@ -872,7 +873,7 @@ fts_stat (FTSOBJ *sp, FTSENTRY *p, int follow)
>  	FTSENTRY *t;
>  	dev_t dev;
>  	INO_T ino;
> -	struct STAT *sbp, sb;
> +	struct STRUCT_STAT *sbp, sb;
>  	int saved_errno;
>  
>  	/* If user needs stat info, stat buffer already allocated. */
> @@ -906,7 +907,7 @@ fts_stat (FTSOBJ *sp, FTSENTRY *p, int follow)
>  		}
>  	} else if (LSTAT(p->fts_accpath, sbp)) {
>  		p->fts_errno = errno;
> -err:		memset(sbp, 0, sizeof(struct STAT));
> +err:		memset(sbp, 0, sizeof(struct STRUCT_STAT));
>  		return (FTS_NS);
>  	}
>  
> @@ -996,7 +997,7 @@ fts_alloc (FTSOBJ *sp, const char *name, size_t
> namelen) */
>  	len = sizeof(FTSENTRY) + namelen;
>  	if (!ISSET(FTS_NOSTAT))
> -		len += sizeof(struct STAT) + ALIGNBYTES;
> +		len += sizeof(struct STRUCT_STAT) + ALIGNBYTES;
>  	if ((p = malloc(len)) == NULL)
>  		return (NULL);
>  
> @@ -1005,7 +1006,7 @@ fts_alloc (FTSOBJ *sp, const char *name, size_t
> namelen) p->fts_name[namelen] = '\0';
>  
>  	if (!ISSET(FTS_NOSTAT))
> -		p->fts_statp = (struct STAT *)ALIGN(p->fts_name +
> namelen + 2);
> +		p->fts_statp = (struct STRUCT_STAT
> *)ALIGN(p->fts_name + namelen + 2); p->fts_namelen = namelen;
>  	p->fts_path = sp->fts_path;
>  	p->fts_errno = 0;
> @@ -1116,7 +1117,7 @@ fts_safe_changedir (FTSOBJ *sp, FTSENTRY *p,
> int fd, const char *path) return (0);
>  	if (fd < 0 && (newfd = __open(path, O_RDONLY, 0)) < 0)
>  		return (-1);
> -	if (__fxstat64(_STAT_VER, newfd, &sb)) {
> +	if (__fstat64(newfd, &sb)) {
>  		ret = -1;
>  		goto bail;
>  	}
> diff --git a/io/fts64.c b/io/fts64.c
> index 3d9c779791..466703da37 100644
> --- a/io/fts64.c
> +++ b/io/fts64.c
> @@ -24,7 +24,8 @@
>  #define FTSOBJ FTS64
>  #define FTSENTRY FTSENT64
>  #define INO_T ino64_t
> -#define STAT stat64
> -#define LSTAT lstat64
> +#define STRUCT_STAT stat64
> +#define STAT __stat64
> +#define LSTAT __lstat64
>  
>  #include "fts.c"
> diff --git a/io/ftw.c b/io/ftw.c
> index 8c79d29a9e..7104816e85 100644
> --- a/io/ftw.c
> +++ b/io/ftw.c
> @@ -135,15 +135,15 @@ int rpl_lstat (const char *, struct stat *);
>  # define NFTW_OLD_NAME __old_nftw
>  # define NFTW_NEW_NAME __new_nftw
>  # define INO_T ino_t
> -# define STAT stat
> +# define STRUCT_STAT stat
>  # ifdef _LIBC
> -#  define LXSTAT __lxstat
> -#  define XSTAT __xstat
> -#  define FXSTATAT __fxstatat
> +#  define LSTAT __lstat
> +#  define STAT __stat
> +#  define FSTATAT __fstatat
>  # else
> -#  define LXSTAT(V,f,sb) lstat (f,sb)
> -#  define XSTAT(V,f,sb) stat (f,sb)
> -#  define FXSTATAT(V,d,f,sb,m) fstatat (d, f, sb, m)
> +#  define LSTAT lstat
> +#  define XTAT stat
> +#  define FSTATAT fstatat
>  # endif
>  # define FTW_FUNC_T __ftw_func_t
>  # define NFTW_FUNC_T __nftw_func_t
> @@ -219,7 +219,7 @@ static const int ftw_arr[] =
>  
>  
>  /* Forward declarations of local functions.  */
> -static int ftw_dir (struct ftw_data *data, struct STAT *st,
> +static int ftw_dir (struct ftw_data *data, struct STRUCT_STAT *st,
>  		    struct dir_data *old_dir);
>  
>  
> @@ -239,7 +239,7 @@ object_compare (const void *p1, const void *p2)
>  
>  
>  static int
> -add_object (struct ftw_data *data, struct STAT *st)
> +add_object (struct ftw_data *data, struct STRUCT_STAT *st)
>  {
>    struct known_object *newp = malloc (sizeof (struct known_object));
>    if (newp == NULL)
> @@ -251,7 +251,7 @@ add_object (struct ftw_data *data, struct STAT
> *st) 
>  
>  static inline int
> -find_object (struct ftw_data *data, struct STAT *st)
> +find_object (struct ftw_data *data, struct STRUCT_STAT *st)
>  {
>    struct known_object obj;
>    obj.dev = st->st_dev;
> @@ -378,7 +378,7 @@ static int
>  process_entry (struct ftw_data *data, struct dir_data *dir, const
> char *name, size_t namlen, int d_type)
>  {
> -  struct STAT st;
> +  struct STRUCT_STAT st;
>    int result = 0;
>    int flag = 0;
>    size_t new_buflen;
> @@ -405,16 +405,16 @@ process_entry (struct ftw_data *data, struct
> dir_data *dir, const char *name, 
>    int statres;
>    if (dir->streamfd != -1)
> -    statres = FXSTATAT (_STAT_VER, dir->streamfd, name, &st,
> -			(data->flags & FTW_PHYS) ?
> AT_SYMLINK_NOFOLLOW : 0);
> +    statres = FSTATAT (dir->streamfd, name, &st,
> +		       (data->flags & FTW_PHYS) ?
> AT_SYMLINK_NOFOLLOW : 0); else
>      {
>        if ((data->flags & FTW_CHDIR) == 0)
>  	name = data->dirbuf;
>  
>        statres = ((data->flags & FTW_PHYS)
> -		 ? LXSTAT (_STAT_VER, name, &st)
> -		 : XSTAT (_STAT_VER, name, &st));
> +		 ? LSTAT (name, &st)
> +		 : STAT (name, &st));
>      }
>  
>    if (statres < 0)
> @@ -430,10 +430,10 @@ process_entry (struct ftw_data *data, struct
> dir_data *dir, const char *name, it should contain information about
> the link (ala lstat). We do our best to fill in what data we can.  */
>  	  if (dir->streamfd != -1)
> -	    statres = FXSTATAT (_STAT_VER, dir->streamfd, name, &st,
> -				AT_SYMLINK_NOFOLLOW);
> +	    statres = FSTATAT (dir->streamfd, name, &st,
> +			       AT_SYMLINK_NOFOLLOW);
>  	  else
> -	    statres = LXSTAT (_STAT_VER, name, &st);
> +	    statres = LSTAT (name, &st);
>  	  if (statres == 0 && S_ISLNK (st.st_mode))
>  	    flag = FTW_SLN;
>  	  else
> @@ -476,7 +476,7 @@ process_entry (struct ftw_data *data, struct
> dir_data *dir, const char *name, 
>  static int
>  __attribute ((noinline))
> -ftw_dir (struct ftw_data *data, struct STAT *st, struct dir_data
> *old_dir) +ftw_dir (struct ftw_data *data, struct STRUCT_STAT *st,
> struct dir_data *old_dir) {
>    struct dir_data dir;
>    struct dirent64 *d;
> @@ -630,7 +630,7 @@ ftw_startup (const char *dir, int is_nftw, void
> *func, int descriptors, int flags)
>  {
>    struct ftw_data data;
> -  struct STAT st;
> +  struct STRUCT_STAT st;
>    int result = 0;
>    int save_err;
>    int cwdfd = -1;
> @@ -740,12 +740,12 @@ ftw_startup (const char *dir, int is_nftw, void
> *func, int descriptors, name = data.dirbuf;
>  
>        if (((flags & FTW_PHYS)
> -	   ? LXSTAT (_STAT_VER, name, &st)
> -	   : XSTAT (_STAT_VER, name, &st)) < 0)
> +	   ? LSTAT (name, &st)
> +	   : STAT (name, &st)) < 0)
>  	{
>  	  if (!(flags & FTW_PHYS)
>  	      && errno == ENOENT
> -	      && LXSTAT (_STAT_VER, name, &st) == 0
> +	      && LSTAT (name, &st) == 0
>  	      && S_ISLNK (st.st_mode))
>  	    result = (*data.func) (data.dirbuf, &st,
> data.cvt_arr[FTW_SLN], &data.ftw);
> diff --git a/io/ftw64.c b/io/ftw64.c
> index 20c43d9616..8daf8777cf 100644
> --- a/io/ftw64.c
> +++ b/io/ftw64.c
> @@ -22,10 +22,10 @@
>  #define NFTW_OLD_NAME __old_nftw64
>  #define NFTW_NEW_NAME __new_nftw64
>  #define INO_T ino64_t
> -#define STAT stat64
> -#define LXSTAT __lxstat64
> -#define XSTAT __xstat64
> -#define FXSTATAT __fxstatat64
> +#define STRUCT_STAT stat64
> +#define LSTAT __lstat64
> +#define STAT __stat64
> +#define FSTATAT __fstatat64
>  #define FTW_FUNC_T __ftw64_func_t
>  #define NFTW_FUNC_T __nftw64_func_t
>  
> diff --git a/io/getdirname.c b/io/getdirname.c
> index dd69e4e281..2465b62ad2 100644
> --- a/io/getdirname.c
> +++ b/io/getdirname.c
> @@ -32,8 +32,8 @@ get_current_dir_name (void)
>  
>    pwd = getenv ("PWD");
>    if (pwd != NULL
> -      && stat64 (".", &dotstat) == 0
> -      && stat64 (pwd, &pwdstat) == 0
> +      && __stat64 (".", &dotstat) == 0
> +      && __stat64 (pwd, &pwdstat) == 0
>        && pwdstat.st_dev == dotstat.st_dev
>        && pwdstat.st_ino == dotstat.st_ino)
>      /* The PWD value is correct.  Use it.  */
> diff --git a/io/mkdirat.c b/io/mkdirat.c
> index cfe01b5748..094f0d7e0e 100644
> --- a/io/mkdirat.c
> +++ b/io/mkdirat.c
> @@ -36,7 +36,7 @@ mkdirat (int fd, const char *path, mode_t mode)
>      {
>        /* Check FD is associated with a directory.  */
>        struct stat64 st;
> -      if (__fxstat64 (_STAT_VER, fd, &st) != 0)
> +      if (__fstat64 (fd, &st) != 0)
>  	return -1;
>  
>        if (!S_ISDIR (st.st_mode))
> diff --git a/io/mkfifoat.c b/io/mkfifoat.c
> index 409f55112c..f2af653399 100644
> --- a/io/mkfifoat.c
> +++ b/io/mkfifoat.c
> @@ -37,7 +37,7 @@ mkfifoat (int fd, const char *path, mode_t mode)
>      {
>        /* Check FD is associated with a directory.  */
>        struct stat64 st;
> -      if (__fxstat64 (_STAT_VER, fd, &st) != 0)
> +      if (__fstat64 (fd, &st) != 0)
>  	return -1;
>  
>        if (!S_ISDIR (st.st_mode))
> diff --git a/io/openat.c b/io/openat.c
> index a7ce65bee2..a2e86eddeb 100644
> --- a/io/openat.c
> +++ b/io/openat.c
> @@ -47,7 +47,7 @@ __openat (int fd, const char *file, int oflag, ...)
>      {
>        /* Check FD is associated with a directory.  */
>        struct stat64 st;
> -      if (__fxstat64 (_STAT_VER, fd, &st) != 0)
> +      if (__fstat64 (fd, &st) != 0)
>  	return -1;
>  
>        if (!S_ISDIR (st.st_mode))
> diff --git a/io/openat64.c b/io/openat64.c
> index b66979c035..a4bb188eb2 100644
> --- a/io/openat64.c
> +++ b/io/openat64.c
> @@ -40,7 +40,7 @@ __openat64 (int fd, const char *file, int oflag,
> ...) {
>        /* Check FD is associated with a directory.  */
>        struct stat64 st;
> -      if (__fxstat64 (_STAT_VER, fd, &st) != 0)
> +      if (__fstat64 (fd, &st) != 0)
>  	return -1;
>  
>        if (!S_ISDIR (st.st_mode))
> diff --git a/io/xmknodat.c b/io/xmknodat.c
> index 0e69db1940..b6c668170b 100644
> --- a/io/xmknodat.c
> +++ b/io/xmknodat.c
> @@ -44,7 +44,7 @@ __xmknodat (int vers, int fd, const char *path,
> mode_t mode, dev_t *dev) {
>        /* Check FD is associated with a directory.  */
>        struct stat64 st;
> -      if (__fxstat64 (_STAT_VER, fd, &st) != 0)
> +      if (__fstat64 (fd, &st) != 0)
>  	return -1;
>  
>        if (!S_ISDIR (st.st_mode))
> diff --git a/libio/fileops.c b/libio/fileops.c
> index bc76f3549f..99f06efc10 100644
> --- a/libio/fileops.c
> +++ b/libio/fileops.c
> @@ -1145,7 +1145,7 @@ libc_hidden_def (_IO_file_seek)
>  int
>  _IO_file_stat (FILE *fp, void *st)
>  {
> -  return __fxstat64 (_STAT_VER, fp->_fileno, (struct stat64 *) st);
> +  return __fstat64 (fp->_fileno, (struct stat64 *) st);
>  }
>  libc_hidden_def (_IO_file_stat)
>  
> diff --git a/locale/loadarchive.c b/locale/loadarchive.c
> index ba0fe45648..8de6a327a4 100644
> --- a/locale/loadarchive.c
> +++ b/locale/loadarchive.c
> @@ -207,7 +207,7 @@ _nl_load_locale_from_archive (int category, const
> char **namep) /* Cannot open the archive, for whatever reason.  */
>  	return NULL;
>  
> -      if (__fxstat64 (_STAT_VER, fd, &archive_stat) == -1)
> +      if (__fstat64 (fd, &archive_stat) == -1)
>  	{
>  	  /* stat failed, very strange.  */
>  	close_and_out:
> @@ -405,7 +405,7 @@ _nl_load_locale_from_archive (int category, const
> char **namep) /* Now verify we think this is really the same archive
> file we opened before.  If it has been changed we cannot trust
>  		 the header we read previously.  */
> -	      if (__fxstat64 (_STAT_VER, fd, &st) < 0
> +	      if (__fstat64 (fd, &st) < 0
>  		  || st.st_size != archive_stat.st_size
>  		  || st.st_mtime != archive_stat.st_mtime
>  		  || st.st_dev != archive_stat.st_dev
> diff --git a/locale/loadlocale.c b/locale/loadlocale.c
> index 2fcb348d1d..82c745d9a2 100644
> --- a/locale/loadlocale.c
> +++ b/locale/loadlocale.c
> @@ -180,7 +180,7 @@ _nl_load_locale (struct loaded_l10nfile *file,
> int category) /* Cannot open the file.  */
>      return;
>  
> -  if (__builtin_expect (__fxstat64 (_STAT_VER, fd, &st), 0) < 0)
> +  if (__builtin_expect (__fstat64 (fd, &st), 0) < 0)
>      {
>      puntfd:
>        __close_nocancel_nostatus (fd);
> @@ -206,7 +206,7 @@ _nl_load_locale (struct loaded_l10nfile *file,
> int category) if (__builtin_expect (fd, 0) < 0)
>  	return;
>  
> -      if (__builtin_expect (__fxstat64 (_STAT_VER, fd, &st), 0) < 0)
> +      if (__builtin_expect (__fstat64 (fd, &st), 0) < 0)
>  	goto puntfd;
>      }
>  
> diff --git a/misc/daemon.c b/misc/daemon.c
> index 21e785966a..0e688f4d74 100644
> --- a/misc/daemon.c
> +++ b/misc/daemon.c
> @@ -64,7 +64,7 @@ daemon (int nochdir, int noclose)
>  		struct stat64 st;
>  
>  		if ((fd = __open_nocancel(_PATH_DEVNULL, O_RDWR, 0))
> != -1
> -		    && (__builtin_expect (__fxstat64 (_STAT_VER, fd,
> &st), 0)
> +		    && (__builtin_expect (__fstat64 (fd, &st), 0)
>  			== 0)) {
>  			if (__builtin_expect (S_ISCHR (st.st_mode),
> 1) != 0 #if defined DEV_NULL_MAJOR && defined DEV_NULL_MINOR
> diff --git a/misc/getusershell.c b/misc/getusershell.c
> index fc2c43b771..11f5aa83f8 100644
> --- a/misc/getusershell.c
> +++ b/misc/getusershell.c
> @@ -106,7 +106,7 @@ initshells (void)
>  	strings = NULL;
>  	if ((fp = fopen(_PATH_SHELLS, "rce")) == NULL)
>  		goto init_okshells_noclose;
> -	if (fstat64(fileno(fp), &statb) == -1) {
> +	if (__fstat64(fileno(fp), &statb) == -1) {
>  	init_okshells:
>  		(void)fclose(fp);
>  	init_okshells_noclose:
> diff --git a/nptl/sem_open.c b/nptl/sem_open.c
> index b022cbfd9a..05e286002b 100644
> --- a/nptl/sem_open.c
> +++ b/nptl/sem_open.c
> @@ -68,7 +68,7 @@ check_add_mapping (const char *name, size_t
> namelen, int fd, sem_t *existing) 
>    /* Get the information about the file.  */
>    struct stat64 st;
> -  if (__fxstat64 (_STAT_VER, fd, &st) == 0)
> +  if (__fstat64 (fd, &st) == 0)
>      {
>        /* Get the lock.  */
>        lll_lock (__sem_mappings_lock, LLL_PRIVATE);
> diff --git a/nscd/nscd_helper.c b/nscd/nscd_helper.c
> index a4f3312f90..41c7937fcd 100644
> --- a/nscd/nscd_helper.c
> +++ b/nscd/nscd_helper.c
> @@ -325,7 +325,7 @@ __nscd_get_mapping (request_type type, const char
> *key, if (__glibc_unlikely (n == keylen))
>      {
>        struct stat64 st;
> -      if (__builtin_expect (fstat64 (mapfd, &st) != 0, 0)
> +      if (__builtin_expect (__fstat64 (mapfd, &st) != 0, 0)
>  	  || __builtin_expect (st.st_size < sizeof (struct
> database_pers_head), 0))
>  	goto out_close;
> diff --git a/posix/glob.c b/posix/glob.c
> index 4580cefb9f..b4b34945e2 100644
> --- a/posix/glob.c
> +++ b/posix/glob.c
> @@ -49,12 +49,6 @@
>  # define readdir(str) __readdir64 (str)
>  # define getpwnam_r(name, bufp, buf, len, res) \
>      __getpwnam_r (name, bufp, buf, len, res)
> -# ifndef __lstat64
> -#  define __lstat64(fname, buf) __lxstat64 (_STAT_VER, fname, buf)
> -# endif
> -# ifndef __stat64
> -#  define __stat64(fname, buf) __xstat64 (_STAT_VER, fname, buf)
> -# endif
>  # define struct_stat64		struct stat64
>  # define FLEXIBLE_ARRAY_MEMBER
>  # include <shlib-compat.h>
> @@ -63,7 +57,6 @@
>  # define __getlogin_r(buf, len) getlogin_r (buf, len)
>  # define __lstat64(fname, buf)  lstat (fname, buf)
>  # define __stat64(fname, buf)   stat (fname, buf)
> -# define __fxstatat64(_, d, f, st, flag) fstatat (d, f, st, flag)
>  # define struct_stat64          struct stat
>  # ifndef __MVS__
>  #  define __alloca              alloca
> diff --git a/stdlib/canonicalize.c b/stdlib/canonicalize.c
> index cbd885a3c5..3fcb399a5d 100644
> --- a/stdlib/canonicalize.c
> +++ b/stdlib/canonicalize.c
> @@ -158,7 +158,7 @@ __realpath (const char *name, char *resolved)
>  	  dest = __mempcpy (dest, start, end - start);
>  	  *dest = '\0';
>  
> -	  if (__lxstat64 (_STAT_VER, rpath, &st) < 0)
> +	  if (__lstat64 (rpath, &st) < 0)
>  	    goto error;
>  
>  	  if (S_ISLNK (st.st_mode))
> diff --git a/sysdeps/gnu/glob64-lstat-compat.c
> b/sysdeps/gnu/glob64-lstat-compat.c index 47b5e88498..ac1fe1496a
> 100644 --- a/sysdeps/gnu/glob64-lstat-compat.c
> +++ b/sysdeps/gnu/glob64-lstat-compat.c
> @@ -32,7 +32,7 @@
>  #undef stat
>  #define stat stat64
>  #undef __stat
> -#define __stat(file, buf) __xstat64 (_STAT_VER, file, buf)
> +#define __stat(file, buf) __stat64 (file, buf)
>  
>  #define COMPILE_GLOB64	1
>  
> diff --git a/sysdeps/gnu/glob64.c b/sysdeps/gnu/glob64.c
> index 42b5b225ca..32ac018fde 100644
> --- a/sysdeps/gnu/glob64.c
> +++ b/sysdeps/gnu/glob64.c
> @@ -12,7 +12,7 @@
>  #undef stat
>  #define stat stat64
>  #undef __stat
> -#define __stat(file, buf) __xstat64 (_STAT_VER, file, buf)
> +#define __stat(file, buf) __stat64 (file, buf)
>  
>  #define COMPILE_GLOB64	1
>  
> diff --git a/sysdeps/mach/hurd/ptsname.c b/sysdeps/mach/hurd/ptsname.c
> index 9627f970f9..065ba2a268 100644
> --- a/sysdeps/mach/hurd/ptsname.c
> +++ b/sysdeps/mach/hurd/ptsname.c
> @@ -63,7 +63,7 @@ __ptsname_internal (int fd, char *buf, size_t
> buflen, struct stat64 *stp) 
>    if (stp)
>      {
> -      if (__xstat64 (_STAT_VER, peername, stp) < 0)
> +      if (__stat64 (peername, stp) < 0)
>  	return errno;
>      }
>  
> diff --git a/sysdeps/posix/dl-fileid.h b/sysdeps/posix/dl-fileid.h
> index 7d1e9e4950..b3c8166701 100644
> --- a/sysdeps/posix/dl-fileid.h
> +++ b/sysdeps/posix/dl-fileid.h
> @@ -34,7 +34,7 @@ _dl_get_file_id (int fd, struct r_file_id *id)
>  {
>    struct stat64 st;
>  
> -  if (__glibc_unlikely (__fxstat64 (_STAT_VER, fd, &st) < 0))
> +  if (__glibc_unlikely (__fstat64 (fd, &st) < 0))
>      return false;
>  
>    id->dev = st.st_dev;
> diff --git a/sysdeps/posix/euidaccess.c b/sysdeps/posix/euidaccess.c
> index 8a2776d502..050d370f4c 100644
> --- a/sysdeps/posix/euidaccess.c
> +++ b/sysdeps/posix/euidaccess.c
> @@ -140,7 +140,7 @@ euidaccess (const char *path, int mode)
>      return access (path, mode);
>  #endif
>  
> -  if (stat64 (path, &stats))
> +  if (__stat64 (path, &stats))
>      return -1;
>  
>    mode &= (X_OK | W_OK | R_OK);	/* Clear any bogus bits. */
> diff --git a/sysdeps/posix/fdopendir.c b/sysdeps/posix/fdopendir.c
> index b690f7fc88..e424fbdaa2 100644
> --- a/sysdeps/posix/fdopendir.c
> +++ b/sysdeps/posix/fdopendir.c
> @@ -29,7 +29,7 @@ __fdopendir (int fd)
>  {
>    struct stat64 statbuf;
>  
> -  if (__builtin_expect (__fxstat64 (_STAT_VER, fd, &statbuf), 0) < 0)
> +  if (__builtin_expect (__fstat64 (fd, &statbuf), 0) < 0)
>      return NULL;
>    if (__glibc_unlikely (! S_ISDIR (statbuf.st_mode)))
>      {
> diff --git a/sysdeps/posix/fpathconf.c b/sysdeps/posix/fpathconf.c
> index 1863be64e0..3a9fb1513f 100644
> --- a/sysdeps/posix/fpathconf.c
> +++ b/sysdeps/posix/fpathconf.c
> @@ -133,7 +133,7 @@ __fpathconf (int fd, int name)
>  	/* AIO is only allowed on regular files and block devices.
> */ struct stat64 st;
>  
> -	if (__fxstat64 (_STAT_VER, fd, &st) < 0
> +	if (__fstat64 (fd, &st) < 0
>  	    || (! S_ISREG (st.st_mode) && ! S_ISBLK (st.st_mode)))
>  	  return -1;
>  	else
> diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
> index ed04e564f9..82c898fe35 100644
> --- a/sysdeps/posix/getaddrinfo.c
> +++ b/sysdeps/posix/getaddrinfo.c
> @@ -1785,7 +1785,7 @@ gaiconf_init (void)
>    if (fp != NULL)
>      {
>        struct stat64 st;
> -      if (__fxstat64 (_STAT_VER, fileno (fp), &st) != 0)
> +      if (__fstat64 (fileno (fp), &st) != 0)
>  	{
>  	  fclose (fp);
>  	  goto no_file;
> @@ -2138,7 +2138,7 @@ static void
>  gaiconf_reload (void)
>  {
>    struct stat64 st;
> -  if (__xstat64 (_STAT_VER, GAICONF_FNAME, &st) != 0
> +  if (stat64 (GAICONF_FNAME, &st) != 0
>        || !check_gaiconf_mtime (&st))
>      gaiconf_init ();
>  }
> diff --git a/sysdeps/posix/isfdtype.c b/sysdeps/posix/isfdtype.c
> index 20c6309220..3c63a33e88 100644
> --- a/sysdeps/posix/isfdtype.c
> +++ b/sysdeps/posix/isfdtype.c
> @@ -29,7 +29,7 @@ isfdtype (int fildes, int fdtype)
>  
>    {
>      int save_error = errno;
> -    result = fstat64 (fildes, &st);
> +    result = __fstat64 (fildes, &st);
>      __set_errno (save_error);
>    }
>  
> diff --git a/sysdeps/posix/opendir.c b/sysdeps/posix/opendir.c
> index c6ab79246c..e89e09bfc7 100644
> --- a/sysdeps/posix/opendir.c
> +++ b/sysdeps/posix/opendir.c
> @@ -56,7 +56,7 @@ opendir_tail (int fd)
>       `stat' call.  The S_ISDIR check is superfluous if O_DIRECTORY
> works, but it's cheap and we need the stat call for st_blksize
> anyway.  */ struct stat64 statbuf;
> -  if (__glibc_unlikely (__fxstat64 (_STAT_VER, fd, &statbuf) < 0))
> +  if (__glibc_unlikely (__fstat64 (fd, &statbuf) < 0))
>      goto lose;
>    if (__glibc_unlikely (! S_ISDIR (statbuf.st_mode)))
>      {
> diff --git a/sysdeps/posix/pathconf.c b/sysdeps/posix/pathconf.c
> index 5819f03aa7..084c5fab59 100644
> --- a/sysdeps/posix/pathconf.c
> +++ b/sysdeps/posix/pathconf.c
> @@ -131,7 +131,7 @@ __pathconf (const char *path, int name)
>  	/* AIO is only allowed on regular files and block devices.
> */ struct stat64 st;
>  
> -	if (__xstat64 (_STAT_VER, path, &st) < 0
> +	if (__stat64 (path, &st) < 0
>  	    || (! S_ISREG (st.st_mode) && ! S_ISBLK (st.st_mode)))
>  	  return -1;
>  	else
> diff --git a/sysdeps/posix/posix_fallocate.c
> b/sysdeps/posix/posix_fallocate.c index e7fccfc1c8..c9cf17bc7b 100644
> --- a/sysdeps/posix/posix_fallocate.c
> +++ b/sysdeps/posix/posix_fallocate.c
> @@ -48,7 +48,7 @@ posix_fallocate (int fd, __off_t offset, __off_t
> len) }
>  
>    /* We have to make sure that this is really a regular file.  */
> -  if (__fxstat64 (_STAT_VER, fd, &st) != 0)
> +  if (__fstat64 (fd, &st) != 0)
>      return EBADF;
>    if (S_ISFIFO (st.st_mode))
>      return ESPIPE;
> diff --git a/sysdeps/posix/posix_fallocate64.c
> b/sysdeps/posix/posix_fallocate64.c index f9d4fe5ca3..4f8fe47b18
> 100644 --- a/sysdeps/posix/posix_fallocate64.c
> +++ b/sysdeps/posix/posix_fallocate64.c
> @@ -48,7 +48,7 @@ __posix_fallocate64_l64 (int fd, __off64_t offset,
> __off64_t len) }
>  
>    /* We have to make sure that this is really a regular file.  */
> -  if (__fxstat64 (_STAT_VER, fd, &st) != 0)
> +  if (__fstat64 (fd, &st) != 0)
>      return EBADF;
>    if (S_ISFIFO (st.st_mode))
>      return ESPIPE;
> diff --git a/sysdeps/posix/sysconf.c b/sysdeps/posix/sysconf.c
> index 35ba7f8103..8f7c4708df 100644
> --- a/sysdeps/posix/sysconf.c
> +++ b/sysdeps/posix/sysconf.c
> @@ -1216,7 +1216,7 @@ __sysconf_check_spec (const char *spec)
>  	  spec, speclen + 1);
>  
>    struct stat64 st;
> -  long int ret = __xstat64 (_STAT_VER, name, &st) >= 0 ? 1 : -1;
> +  long int ret = __stat64 (name, &st) >= 0 ? 1 : -1;
>  
>    __set_errno (save_errno);
>    return ret;
> diff --git a/sysdeps/posix/tempname.c b/sysdeps/posix/tempname.c
> index cd48385a40..3dd8f1e1ef 100644
> --- a/sysdeps/posix/tempname.c
> +++ b/sysdeps/posix/tempname.c
> @@ -65,7 +65,6 @@
>  # define __getpid getpid
>  # define __mkdir mkdir
>  # define __open open
> -# define __lxstat64(version, file, buf) lstat (file, buf)
>  # define __secure_getenv secure_getenv
>  #endif
>  
> @@ -96,7 +95,7 @@ static int
>  direxists (const char *dir)
>  {
>    struct_stat64 buf;
> -  return __xstat64 (_STAT_VER, dir, &buf) == 0 && S_ISDIR
> (buf.st_mode);
> +  return __stat64 (dir, &buf) == 0 && S_ISDIR (buf.st_mode);
>  }
>  
>  /* Path search algorithm, for tmpnam, tmpfile, etc.  If DIR is
> @@ -254,7 +253,7 @@ __gen_tempname (char *tmpl, int suffixlen, int
> flags, int kind) succeeds if __xstat fails because the name does not
> exist. Note the continue to bypass the common logic at the bottom
>  	     of the loop.  */
> -	  if (__lxstat64 (_STAT_VER, tmpl, &st) < 0)
> +	  if (__lstat64 (tmpl, &st) < 0)
>  	    {
>  	      if (errno == ENOENT)
>  		{
> diff --git a/sysdeps/unix/sysv/linux/faccessat.c
> b/sysdeps/unix/sysv/linux/faccessat.c index e4f18ab2db..5a660f5201
> 100644 --- a/sysdeps/unix/sysv/linux/faccessat.c
> +++ b/sysdeps/unix/sysv/linux/faccessat.c
> @@ -37,7 +37,7 @@ faccessat (int fd, const char *file, int mode, int
> flag) return INLINE_SYSCALL (faccessat, 3, fd, file, mode);
>  
>    struct stat64 stats;
> -  if (__fxstatat64 (_STAT_VER, fd, file, &stats, flag &
> AT_SYMLINK_NOFOLLOW))
> +  if (__fstatat64 (fd, file, &stats, flag & AT_SYMLINK_NOFOLLOW))
>      return -1;
>  
>    mode &= (X_OK | W_OK | R_OK);	/* Clear any bogus bits. */
> diff --git a/sysdeps/unix/sysv/linux/fexecve.c
> b/sysdeps/unix/sysv/linux/fexecve.c index 23c9799f5d..1fe3a23333
> 100644 --- a/sysdeps/unix/sysv/linux/fexecve.c
> +++ b/sysdeps/unix/sysv/linux/fexecve.c
> @@ -60,8 +60,8 @@ fexecve (int fd, char *const argv[], char *const
> envp[]) 
>    /* We come here only if the 'execve' call fails.  Determine whether
>       /proc is mounted.  If not we return ENOSYS.  */
> -  struct stat st;
> -  if (stat ("/proc/self/fd", &st) != 0 && errno == ENOENT)
> +  struct stat64 st;
> +  if (__stat64 ("/proc/self/fd", &st) != 0 && errno == ENOENT)
>      save = ENOSYS;
>  
>    __set_errno (save);
> diff --git a/sysdeps/unix/sysv/linux/oldglob.c
> b/sysdeps/unix/sysv/linux/oldglob.c index a034c2d930..59bf89dc1d
> 100644 --- a/sysdeps/unix/sysv/linux/oldglob.c
> +++ b/sysdeps/unix/sysv/linux/oldglob.c
> @@ -31,7 +31,7 @@ libc_hidden_proto (__old_glob64);
>  #undef stat
>  #define stat stat64
>  #undef __stat
> -#define __stat(file, buf) __xstat64 (_STAT_VER, file, buf)
> +#define __stat(file, buf) __stat64 (file, buf)
>  
>  /* Avoid calling gl_lstat with GLOB_ALTDIRFUNC.  */
>  #define GLOB_NO_LSTAT
> diff --git a/sysdeps/unix/sysv/linux/pathconf.c
> b/sysdeps/unix/sysv/linux/pathconf.c index fec1a142e7..e59b8ab341
> 100644 --- a/sysdeps/unix/sysv/linux/pathconf.c
> +++ b/sysdeps/unix/sysv/linux/pathconf.c
> @@ -67,7 +67,7 @@ distinguish_extX (const struct statfs *fsbuf, const
> char *file, int fd) char path[PATH_MAX];
>    struct stat64 st;
>  
> -  if ((file == NULL ? fstat64 (fd, &st) : stat64 (file, &st)) != 0)
> +  if ((file == NULL ? __fstat64 (fd, &st) : __stat64 (file, &st)) !=
> 0) /* Strange.  The statfd call worked, but stat fails.  Default to
>         the more pessimistic value.  */
>      return EXT2_LINK_MAX;
> @@ -110,7 +110,7 @@ distinguish_extX (const struct statfs *fsbuf,
> const char *file, int fd) continue;
>  
>  	  struct stat64 fsst;
> -	  if (stat64 (mntbuf.mnt_dir, &fsst) >= 0
> +	  if (__stat64 (mntbuf.mnt_dir, &fsst) >= 0
>  	      && st.st_dev == fsst.st_dev)
>  	    {
>  	      if (strcmp (mntbuf.mnt_type, "ext4") == 0)
> diff --git a/sysdeps/unix/sysv/linux/ptsname.c
> b/sysdeps/unix/sysv/linux/ptsname.c index 81d9d26f1e..4c569bf264
> 100644 --- a/sysdeps/unix/sysv/linux/ptsname.c
> +++ b/sysdeps/unix/sysv/linux/ptsname.c
> @@ -114,7 +114,7 @@ __ptsname_internal (int fd, char *buf, size_t
> buflen, struct stat64 *stp) return ERANGE;
>  	}
>  
> -      if (__fxstat64 (_STAT_VER, fd, stp) < 0)
> +      if (__fstat64 (fd, stp) < 0)
>  	return errno;
>  
>        /* Check if FD really is a master pseudo terminal.  */
> @@ -138,7 +138,7 @@ __ptsname_internal (int fd, char *buf, size_t
> buflen, struct stat64 *stp) p[2] = '\0';
>      }
>  
> -  if (__xstat64 (_STAT_VER, buf, stp) < 0)
> +  if (__stat64 (buf, stp) < 0)
>      return errno;
>  
>    /* Check if the name we're about to return really corresponds to a
> diff --git a/sysdeps/unix/sysv/linux/ttyname.c
> b/sysdeps/unix/sysv/linux/ttyname.c index c05ca687f5..5fa6645353
> 100644 --- a/sysdeps/unix/sysv/linux/ttyname.c
> +++ b/sysdeps/unix/sysv/linux/ttyname.c
> @@ -84,7 +84,7 @@ getttyname (const char *dev, const struct stat64
> *mytty, int save, int *dostat) *((char *) __mempcpy (getttyname_name,
> dev, devlen - 1)) = '/'; }
>  	memcpy (&getttyname_name[devlen], d->d_name, dlen);
> -	if (__xstat64 (_STAT_VER, getttyname_name, &st) == 0
> +	if (__stat64 (getttyname_name, &st) == 0
>  	    && is_mytty (mytty, &st))
>  	  {
>  	    (void) __closedir (dirstream);
> @@ -125,7 +125,7 @@ ttyname (int fd)
>    if (__glibc_unlikely (__tcgetattr (fd, &term) < 0))
>      return NULL;
>  
> -  if (__fxstat64 (_STAT_VER, fd, &st) < 0)
> +  if (__fstat64 (fd, &st) < 0)
>      return NULL;
>  
>    /* We try using the /proc filesystem.  */
> @@ -162,14 +162,14 @@ ttyname (int fd)
>  
>        /* Verify readlink result, fall back on iterating through
> devices.  */ if (ttyname_buf[0] == '/'
> -	  && __xstat64 (_STAT_VER, ttyname_buf, &st1) == 0
> +	  && __stat64 (ttyname_buf, &st1) == 0
>  	  && is_mytty (&st, &st1))
>  	return ttyname_buf;
>  
>        doispty = 1;
>      }
>  
> -  if (__xstat64 (_STAT_VER, "/dev/pts", &st1) == 0 && S_ISDIR
> (st1.st_mode))
> +  if (__stat64 ("/dev/pts", &st1) == 0 && S_ISDIR (st1.st_mode))
>      {
>        name = getttyname ("/dev/pts", &st, save, &dostat);
>      }
> diff --git a/sysdeps/unix/sysv/linux/ttyname_r.c
> b/sysdeps/unix/sysv/linux/ttyname_r.c index 4a1ae40bb2..ad8cd28158
> 100644 --- a/sysdeps/unix/sysv/linux/ttyname_r.c
> +++ b/sysdeps/unix/sysv/linux/ttyname_r.c
> @@ -71,7 +71,7 @@ getttyname_r (char *buf, size_t buflen, const
> struct stat64 *mytty, cp = __stpncpy (buf + devlen, d->d_name,
> needed); cp[0] = '\0';
>  
> -	if (__xstat64 (_STAT_VER, buf, &st) == 0
> +	if (__stat64 (buf, &st) == 0
>  	    && is_mytty (mytty, &st))
>  	  {
>  	    (void) __closedir (dirstream);
> @@ -118,7 +118,7 @@ __ttyname_r (int fd, char *buf, size_t buflen)
>    if (__glibc_unlikely (__tcgetattr (fd, &term) < 0))
>      return errno;
>  
> -  if (__fxstat64 (_STAT_VER, fd, &st) < 0)
> +  if (__fstat64 (fd, &st) < 0)
>      return errno;
>  
>    /* We try using the /proc filesystem.  */
> @@ -146,7 +146,7 @@ __ttyname_r (int fd, char *buf, size_t buflen)
>  
>        /* Verify readlink result, fall back on iterating through
> devices.  */ if (buf[0] == '/'
> -	  && __xstat64 (_STAT_VER, buf, &st1) == 0
> +	  && __stat64 (buf, &st1) == 0
>  	  && is_mytty (&st, &st1))
>  	return 0;
>  
> @@ -157,7 +157,7 @@ __ttyname_r (int fd, char *buf, size_t buflen)
>    memcpy (buf, "/dev/pts/", sizeof ("/dev/pts/"));
>    buflen -= sizeof ("/dev/pts/") - 1;
>  
> -  if (__xstat64 (_STAT_VER, buf, &st1) == 0 && S_ISDIR (st1.st_mode))
> +  if (__stat64 (buf, &st1) == 0 && S_ISDIR (st1.st_mode))
>      {
>        ret = getttyname_r (buf, buflen, &st, save,
>  			  &dostat);
> diff --git a/sysvipc/ftok.c b/sysvipc/ftok.c
> index 0b6dab403f..a65dbd520a 100644
> --- a/sysvipc/ftok.c
> +++ b/sysvipc/ftok.c
> @@ -25,7 +25,7 @@ ftok (const char *pathname, int proj_id)
>    struct stat64 st;
>    key_t key;
>  
> -  if (__xstat64 (_STAT_VER, pathname, &st) < 0)
> +  if (__stat64 (pathname, &st) < 0)
>      return (key_t) -1;
>  
>    key = ((st.st_ino & 0xffff) | ((st.st_dev & 0xff) << 16)
> diff --git a/time/getdate.c b/time/getdate.c
> index d5c01b8446..ddd97ba277 100644
> --- a/time/getdate.c
> +++ b/time/getdate.c
> @@ -121,7 +121,7 @@ __getdate_r (const char *string, struct tm *tp)
>    if (datemsk == NULL || *datemsk == '\0')
>      return 1;
>  
> -  if (stat64 (datemsk, &st) < 0)
> +  if (__stat64 (datemsk, &st) < 0)
>      return 3;
>  
>    if (!S_ISREG (st.st_mode))
> diff --git a/time/tzfile.c b/time/tzfile.c
> index af6da1bf00..e8084a86e8 100644
> --- a/time/tzfile.c
> +++ b/time/tzfile.c
> @@ -152,7 +152,7 @@ __tzfile_read (const char *file, size_t extra,
> char **extrap) /* If we were already using tzfile, check whether the
> file changed.  */ struct stat64 st;
>    if (was_using_tzfile
> -      && stat64 (file, &st) == 0
> +      && __stat64 (file, &st) == 0
>        && tzfile_ino == st.st_ino && tzfile_dev == st.st_dev
>        && tzfile_mtime == st.st_mtime)
>      goto done;  /* Nothing to do.  */
> @@ -164,7 +164,7 @@ __tzfile_read (const char *file, size_t extra,
> char **extrap) goto ret_free_transitions;
>  
>    /* Get information about the file we are actually using.  */
> -  if (fstat64 (__fileno (f), &st) != 0)
> +  if (__fstat64 (__fileno (f), &st) != 0)
>      goto lose;
>  
>    free ((void *) transitions);




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 09/16] Remove stat wrapper functions, move them to exported symbols
  2020-07-23 19:46 ` [PATCH 09/16] Remove stat wrapper functions, move them to exported symbols Adhemerval Zanella via Libc-alpha
@ 2020-07-24  9:23   ` Lukasz Majewski
  0 siblings, 0 replies; 80+ messages in thread
From: Lukasz Majewski @ 2020-07-24  9:23 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Alistair Francis, libc-alpha

[-- Attachment #1: Type: text/plain, Size: 73744 bytes --]

On Thu, 23 Jul 2020 16:46:34 -0300
Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> This patch removes the stat, stat64, lstat, lstat64, fstat, fstat64,
> fstatat, and fstatat64 static wrapper and add the symbol on the libc
> with the expected names.
> 
> Both the prototypes of the internal symbol linked by the static
> wrappers and the inline redirectors are also removed from the
> installed sys/stat.h header file.  The wrapper implementation license
> is also change from LGPL to GPL.
> 
> Internally the _STAT_VER* definitions are moved to a arch-specific
> xstatver.h file.  The internal defines that redirects internals
> {f}stat{at} to their {f}xstat{at} counterparts are removed for Linux
> (!NO_RTLD_HIDDEN).  Hurd still requires them since {f}stat{at} pulls
> extra objects that makes the loader build fail otherwise (I haven't
> dig into why exactly).
> 
> Checked with a build for all affected Linux ABIs and Hurd.  I checked
> also on x86_64-linux-gnu and i686-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>

> ---
>  include/sys/stat.h                            |  94 ++++++++-----
>  io/Makefile                                   |   4 +-
>  io/Versions                                   |   4 +
>  io/fstat.c                                    |  33 +----
>  io/fstat64.c                                  |  36 +----
>  io/fstatat.c                                  |  36 +----
>  io/fstatat64.c                                |  36 +----
>  io/lstat.c                                    |  33 +----
>  io/lstat64.c                                  |  36 +----
>  io/stat.c                                     |  34 +----
>  io/stat64.c                                   |  36 +----
>  io/sys/stat.h                                 | 129
> ------------------ nscd/gai.c                                    |
> 5 + sysdeps/generic/xstatver.h                    |   3 +
>  sysdeps/mach/hurd/i386/libc.abilist           |   8 ++
>  sysdeps/posix/getaddrinfo.c                   |   2 +-
>  sysdeps/unix/sysv/linux/aarch64/libc.abilist  |   8 ++
>  sysdeps/unix/sysv/linux/alpha/bits/stat.h     |   9 --
>  sysdeps/unix/sysv/linux/alpha/libc.abilist    |   8 ++
>  sysdeps/unix/sysv/linux/alpha/xstatver.h      |   9 ++
>  sysdeps/unix/sysv/linux/arc/libc.abilist      |   8 ++
>  sysdeps/unix/sysv/linux/arm/le/libc.abilist   |   8 ++
>  sysdeps/unix/sysv/linux/bits/stat.h           |   6 -
>  sysdeps/unix/sysv/linux/csky/libc.abilist     |   8 ++
>  sysdeps/unix/sysv/linux/generic/bits/stat.h   |  11 --
>  sysdeps/unix/sysv/linux/generic/xstatver.h    |   5 +
>  sysdeps/unix/sysv/linux/hppa/libc.abilist     |   8 ++
>  sysdeps/unix/sysv/linux/i386/libc.abilist     |   8 ++
>  sysdeps/unix/sysv/linux/ia64/bits/stat.h      |   5 -
>  sysdeps/unix/sysv/linux/ia64/libc.abilist     |   8 ++
>  sysdeps/unix/sysv/linux/ia64/xstatver.h       |   5 +
>  sysdeps/unix/sysv/linux/m68k/bits/stat.h      |   7 -
>  .../unix/sysv/linux/m68k/m680x0/libc.abilist  |   8 ++
>  sysdeps/unix/sysv/linux/m68k/xstatver.h       |   7 +
>  .../sysv/linux/microblaze/be/libc.abilist     |   8 ++
>  .../unix/sysv/linux/microblaze/bits/stat.h    |   7 -
>  sysdeps/unix/sysv/linux/microblaze/xstatver.h |   7 +
>  sysdeps/unix/sysv/linux/mips/bits/stat.h      |   7 -
>  .../sysv/linux/mips/mips32/fpu/libc.abilist   |   8 ++
>  .../sysv/linux/mips/mips64/n32/libc.abilist   |   8 ++
>  .../sysv/linux/mips/mips64/n64/libc.abilist   |   8 ++
>  sysdeps/unix/sysv/linux/mips/xstatver.h       |   7 +
>  sysdeps/unix/sysv/linux/nios2/libc.abilist    |   8 ++
>  sysdeps/unix/sysv/linux/powerpc/bits/stat.h   |  11 --
>  .../linux/powerpc/powerpc32/fpu/libc.abilist  |   8 ++
>  .../linux/powerpc/powerpc64/be/libc.abilist   |   8 ++
>  .../linux/powerpc/powerpc64/le/libc.abilist   |   8 ++
>  sysdeps/unix/sysv/linux/powerpc/xstatver.h    |  11 ++
>  .../unix/sysv/linux/riscv/rv64/libc.abilist   |   8 ++
>  sysdeps/unix/sysv/linux/s390/bits/stat.h      |  12 --
>  .../unix/sysv/linux/s390/s390-32/libc.abilist |   8 ++
>  .../unix/sysv/linux/s390/s390-64/libc.abilist |   8 ++
>  sysdeps/unix/sysv/linux/s390/xstatver.h       |  16 +++
>  sysdeps/unix/sysv/linux/sh/le/libc.abilist    |   8 ++
>  sysdeps/unix/sysv/linux/sparc/bits/stat.h     |   7 -
>  .../sysv/linux/sparc/sparc32/libc.abilist     |   8 ++
>  .../sysv/linux/sparc/sparc64/libc.abilist     |   8 ++
>  sysdeps/unix/sysv/linux/sparc/xstatver.h      |   7 +
>  sysdeps/unix/sysv/linux/x86/bits/stat.h       |  10 --
>  sysdeps/unix/sysv/linux/x86/xstatver.h        |  13 ++
>  .../unix/sysv/linux/x86_64/64/libc.abilist    |   8 ++
>  .../unix/sysv/linux/x86_64/x32/libc.abilist   |   8 ++
>  sysdeps/unix/sysv/linux/xstatver.h            |   7 +
>  63 files changed, 414 insertions(+), 501 deletions(-)
>  create mode 100644 sysdeps/generic/xstatver.h
>  create mode 100644 sysdeps/unix/sysv/linux/alpha/xstatver.h
>  create mode 100644 sysdeps/unix/sysv/linux/generic/xstatver.h
>  create mode 100644 sysdeps/unix/sysv/linux/ia64/xstatver.h
>  create mode 100644 sysdeps/unix/sysv/linux/m68k/xstatver.h
>  create mode 100644 sysdeps/unix/sysv/linux/microblaze/xstatver.h
>  create mode 100644 sysdeps/unix/sysv/linux/mips/xstatver.h
>  create mode 100644 sysdeps/unix/sysv/linux/powerpc/xstatver.h
>  create mode 100644 sysdeps/unix/sysv/linux/s390/xstatver.h
>  create mode 100644 sysdeps/unix/sysv/linux/sparc/xstatver.h
>  create mode 100644 sysdeps/unix/sysv/linux/x86/xstatver.h
>  create mode 100644 sysdeps/unix/sysv/linux/xstatver.h
> 
> diff --git a/include/sys/stat.h b/include/sys/stat.h
> index f8847cf73e..0be918a7a7 100644
> --- a/include/sys/stat.h
> +++ b/include/sys/stat.h
> @@ -2,10 +2,26 @@
>  #include <io/sys/stat.h>
>  
>  #ifndef _ISOMAC
> +# include <xstatver.h>
> +
>  /* Now define the internal interfaces. */
>  extern int __stat (const char *__file, struct stat *__buf);
> +extern int __stat64 (const char *__file, struct stat64 *__buf);
>  extern int __fstat (int __fd, struct stat *__buf);
> +extern int __fstat64 (int __fd, struct stat64 *__buf);
>  extern int __lstat (const char *__file, struct stat *__buf);
> +extern int __lstat64 (const char *__file, struct stat64 *__buf);
> +extern int __fstatat (int dirfd, const char *pathname, struct stat
> *buf,
> +		      int flags);
> +extern int __fstatat64 (int dirfd, const char *pathname, struct
> stat64 *buf,
> +			int flags);
> +# if IS_IN (libc) || (IS_IN (rtld) && !defined NO_RTLD_HIDDEN)
> +hidden_proto (__stat64)
> +hidden_proto (__fstat64)
> +hidden_proto (__lstat64)
> +hidden_proto (__fstatat64)
> +# endif
> +
>  extern int __chmod (const char *__file, __mode_t __mode);
>  libc_hidden_proto (__chmod)
>  extern int __fchmod (int __fd, __mode_t __mode);
> @@ -13,20 +29,9 @@ libc_hidden_proto (fchmodat)
>  extern __mode_t __umask (__mode_t __mask);
>  extern int __mkdir (const char *__path, __mode_t __mode);
>  libc_hidden_proto (__mkdir)
> +
>  extern int __mknod (const char *__path,
>  		    __mode_t __mode, __dev_t __dev);
> -#if IS_IN (libc) || (IS_IN (rtld) && !defined NO_RTLD_HIDDEN)
> -hidden_proto (__fxstat)
> -hidden_proto (__fxstat64)
> -hidden_proto (__lxstat)
> -hidden_proto (__lxstat64)
> -hidden_proto (__xstat)
> -hidden_proto (__xstat64)
> -#endif
> -extern __inline__ int __stat (const char *__path, struct stat
> *__statbuf) -{
> -  return __xstat (_STAT_VER, __path, __statbuf);
> -}
>  libc_hidden_proto (__xmknod)
>  extern __inline__ int __mknod (const char *__path, __mode_t __mode,
>  			       __dev_t __dev)
> @@ -35,32 +40,47 @@ extern __inline__ int __mknod (const char
> *__path, __mode_t __mode, }
>  libc_hidden_proto (__xmknodat)
>  
> -libc_hidden_proto (__fxstatat)
> -libc_hidden_proto (__fxstatat64)
> -
> -# if IS_IN (rtld) && !defined NO_RTLD_HIDDEN
> -extern __typeof (__fxstatat64) __fxstatat64 attribute_hidden;
> +int __fxstat (int __ver, int __fildes, struct stat *__stat_buf);
> +int __xstat (int __ver, const char *__filename,
> +	     struct stat *__stat_buf);
> +int __lxstat (int __ver, const char *__filename, struct stat
> *__stat_buf); +int __fxstatat (int __ver, int __fildes, const char
> *__filename,
> +		struct stat *__stat_buf, int __flag);
> +int __fxstat64 (int ver, int __fildes, struct stat64 *__stat_buf);
> +int __xstat64 (int ver, const char *__filename, struct stat64
> *__stat_buf); +int __lxstat64 (int ver, const char *__filename,
> struct stat64 *__stat_buf); +int __fxstatat64 (int ver, int __fildes,
> const char *__filename,
> +		  struct stat64 *__stat_buf, int __flag);
> +libc_hidden_proto (__fxstat);
> +libc_hidden_proto (__xstat);
> +libc_hidden_proto (__lxstat);
> +libc_hidden_proto (__fxstatat);
> +# if IS_IN (libc) || (IS_IN (rtld) && !defined NO_RTLD_HIDDEN)
> +hidden_proto (__fxstat64);
> +hidden_proto (__xstat64);
> +hidden_proto (__lxstat64);
> +hidden_proto (__fxstatat64);
>  # endif
>  
> -/* The `stat', `fstat', `lstat' functions have to be handled special
> since
> -   even while not compiling the library with optimization calls to
> these
> -   functions in the shared library must reference the `xstat' etc
> functions.
> -   We have to use macros but we cannot define them in the normal
> headers
> -   since on user level we must use real functions.  */
> -#define stat(fname, buf) __xstat (_STAT_VER, fname, buf)
> -#define lstat(fname, buf)  __lxstat (_STAT_VER, fname, buf)
> -#define __lstat(fname, buf)  __lxstat (_STAT_VER, fname, buf)
> -#define lstat64(fname, buf)  __lxstat64 (_STAT_VER, fname, buf)
> -#define __lstat64(fname, buf)  __lxstat64 (_STAT_VER, fname, buf)
> -#define stat64(fname, buf) __xstat64 (_STAT_VER, fname, buf)
> -#define __stat64(fname, buf) __xstat64 (_STAT_VER, fname, buf)
> -#define fstat64(fd, buf) __fxstat64 (_STAT_VER, fd, buf)
> -#define __fstat64(fd, buf) __fxstat64 (_STAT_VER, fd, buf)
> -#define fstat(fd, buf) __fxstat (_STAT_VER, fd, buf)
> -#define __fstat(fd, buf) __fxstat (_STAT_VER, fd, buf)
> -#define __fstatat(dfd, fname, buf, flag) \
> -  __fxstatat (_STAT_VER, dfd, fname, buf, flag)
> -#define __fstatat64(dfd, fname, buf, flag) \
> -  __fxstatat64 (_STAT_VER, dfd, fname, buf, flag)
> +# ifdef NO_RTLD_HIDDEN
> +/* These are still required for Hurd.  */
> +#  define stat(fname, buf) __xstat (_STAT_VER, fname, buf)
> +#  define lstat(fname, buf)  __lxstat (_STAT_VER, fname, buf)
> +#  define __lstat(fname, buf)  __lxstat (_STAT_VER, fname, buf)
> +#  define lstat64(fname, buf)  __lxstat64 (_STAT_VER, fname, buf)
> +#  define __lstat64(fname, buf)  __lxstat64 (_STAT_VER, fname, buf)
> +#  define stat64(fname, buf) __xstat64 (_STAT_VER, fname, buf)
> +#  define __stat64(fname, buf) __xstat64 (_STAT_VER, fname, buf)
> +#  define fstat64(fd, buf) __fxstat64 (_STAT_VER, fd, buf)
> +#  define __fstat64(fd, buf) __fxstat64 (_STAT_VER, fd, buf)
> +#  define fstat(fd, buf) __fxstat (_STAT_VER, fd, buf)
> +#  define __fstat(fd, buf) __fxstat (_STAT_VER, fd, buf)
> +#  define __fstatat(dfd, fname, buf, flag) \
> +    __fxstatat (_STAT_VER, dfd, fname, buf, flag)
> +#  define __fstatat64(dfd, fname, buf, flag) \
> +    __fxstatat64 (_STAT_VER, dfd, fname, buf, flag)
> +# endif /* NO_RTLD_HIDDEN  */
> +
>  #endif
> +
>  #endif
> diff --git a/io/Makefile b/io/Makefile
> index cf380f3516..cee356b666 100644
> --- a/io/Makefile
> +++ b/io/Makefile
> @@ -60,8 +60,7 @@ routines :=
> 			\ # These routines will be omitted from the
> libc shared object. # Instead the static object files will be
> included in a special archive # linked against when the shared
> library will be used. -static-only-routines = stat fstat lstat stat64
> fstat64 lstat64	\
> -		       fstatat fstatat64 mknod mknodat
> +static-only-routines = mknod mknodat
>  
>  others		:= pwd
>  test-srcs	:= ftwtest
> @@ -78,6 +77,7 @@ tests		:= test-utime test-stat
> test-stat2 test-lfs tst-getcwd \ 
>  # Likewise for statx, but we do not need static linking here.
>  tests-internal += tst-statx
> +tests-static += tst-statx
>  
>  ifeq ($(run-built-tests),yes)
>  tests-special += $(objpfx)ftwtest.out
> diff --git a/io/Versions b/io/Versions
> index ee468055ff..f6db0e84ad 100644
> --- a/io/Versions
> +++ b/io/Versions
> @@ -132,6 +132,9 @@ libc {
>      fcntl64;
>      statx;
>    }
> +  GLIBC_2.33 {
> +    stat; stat64; fstat; fstat64; lstat; lstat64; fstatat; fstatat64;
> +  }
>    GLIBC_PRIVATE {
>      __libc_fcntl64;
>      __fcntl_nocancel;
> @@ -141,5 +144,6 @@ libc {
>      __file_change_detection_for_stat;
>      __file_change_detection_for_path;
>      __file_change_detection_for_fp;
> +    __fstat64;
>    }
>  }
> diff --git a/io/fstat.c b/io/fstat.c
> index 6ce077dc4a..faadd75e31 100644
> --- a/io/fstat.c
> +++ b/io/fstat.c
> @@ -1,4 +1,5 @@
> -/* Copyright (C) 1996-2020 Free Software Foundation, Inc.
> +/* Get file status.
> +   Copyright (C) 1996-2020 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
> @@ -6,23 +7,6 @@
>     License as published by the Free Software Foundation; either
>     version 2.1 of the License, or (at your option) any later version.
>  
> -   In addition to the permissions in the GNU Lesser General Public
> -   License, the Free Software Foundation gives you unlimited
> -   permission to link the compiled version of this file with other
> -   programs, and to distribute those programs without any restriction
> -   coming from the use of this file. (The GNU Lesser General Public
> -   License restrictions do apply in other respects; for example, they
> -   cover modification of the file, and distribution when not linked
> -   into another program.)
> -
> -   Note that people who make modified versions of this file are not
> -   obligated to grant this special exception for their modified
> -   versions; it is their choice whether to do so. The GNU Lesser
> -   General Public License gives permission to release a modified
> -   version without this exception; this exception also makes it
> -   possible to release a modified version which carries forward this
> -   exception.
> -
>     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
> @@ -34,22 +18,11 @@
>  
>  #include <sys/stat.h>
>  
> -/* This definition is only used if inlining fails for this function;
> see
> -   the last page of <sys/stat.h>.  The real work is done by the `x'
> -   function which is passed a version number argument.  We arrange
> in the
> -   makefile that when not inlined this function is always statically
> -   linked; that way a dynamically-linked executable always encodes
> the
> -   version number corresponding to the data structures it uses, so
> the `x'
> -   functions in the shared library can adapt without needing to
> recompile
> -   all callers.  */
> -
> -#undef fstat
>  #undef __fstat
>  int
> -attribute_hidden
>  __fstat (int fd, struct stat *buf)
>  {
>    return __fxstat (_STAT_VER, fd, buf);
>  }
>  
> -weak_hidden_alias (__fstat, fstat)
> +weak_alias (__fstat, fstat)
> diff --git a/io/fstat64.c b/io/fstat64.c
> index c4dd3acd60..b1fc17e5bf 100644
> --- a/io/fstat64.c
> +++ b/io/fstat64.c
> @@ -1,4 +1,5 @@
> -/* Copyright (C) 1996-2020 Free Software Foundation, Inc.
> +/* Get file status.
> +   Copyright (C) 1996-2020 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
> @@ -6,23 +7,6 @@
>     License as published by the Free Software Foundation; either
>     version 2.1 of the License, or (at your option) any later version.
>  
> -   In addition to the permissions in the GNU Lesser General Public
> -   License, the Free Software Foundation gives you unlimited
> -   permission to link the compiled version of this file with other
> -   programs, and to distribute those programs without any restriction
> -   coming from the use of this file. (The GNU Lesser General Public
> -   License restrictions do apply in other respects; for example, they
> -   cover modification of the file, and distribution when not linked
> -   into another program.)
> -
> -   Note that people who make modified versions of this file are not
> -   obligated to grant this special exception for their modified
> -   versions; it is their choice whether to do so. The GNU Lesser
> -   General Public License gives permission to release a modified
> -   version without this exception; this exception also makes it
> -   possible to release a modified version which carries forward this
> -   exception.
> -
>     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
> @@ -34,19 +18,11 @@
>  
>  #include <sys/stat.h>
>  
> -/* This definition is only used if inlining fails for this function;
> see
> -   the last page of <sys/stat.h>.  The real work is done by the `x'
> -   function which is passed a version number argument.  We arrange
> in the
> -   makefile that when not inlined this function is always statically
> -   linked; that way a dynamically-linked executable always encodes
> the
> -   version number corresponding to the data structures it uses, so
> the `x'
> -   functions in the shared library can adapt without needing to
> recompile
> -   all callers.  */
> -
> -#undef fstat64
> +#undef __fstat64
>  int
> -attribute_hidden
> -fstat64 (int fd, struct stat64 *buf)
> +__fstat64 (int fd, struct stat64 *buf)
>  {
>    return __fxstat64 (_STAT_VER, fd, buf);
>  }
> +hidden_def (__fstat64)
> +weak_alias (__fstat64, fstat64)
> diff --git a/io/fstatat.c b/io/fstatat.c
> index edc773487a..12443c2ff4 100644
> --- a/io/fstatat.c
> +++ b/io/fstatat.c
> @@ -1,4 +1,5 @@
> -/* Copyright (C) 2005-2020 Free Software Foundation, Inc.
> +/* Get file status.
> +   Copyright (C) 2005-2020 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
> @@ -6,23 +7,6 @@
>     License as published by the Free Software Foundation; either
>     version 2.1 of the License, or (at your option) any later version.
>  
> -   In addition to the permissions in the GNU Lesser General Public
> -   License, the Free Software Foundation gives you unlimited
> -   permission to link the compiled version of this file with other
> -   programs, and to distribute those programs without any restriction
> -   coming from the use of this file. (The GNU Lesser General Public
> -   License restrictions do apply in other respects; for example, they
> -   cover modification of the file, and distribution when not linked
> -   into another program.)
> -
> -   Note that people who make modified versions of this file are not
> -   obligated to grant this special exception for their modified
> -   versions; it is their choice whether to do so. The GNU Lesser
> -   General Public License gives permission to release a modified
> -   version without this exception; this exception also makes it
> -   possible to release a modified version which carries forward this
> -   exception.
> -
>     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
> @@ -34,19 +18,11 @@
>  
>  #include <sys/stat.h>
>  
> -/* This definition is only used if inlining fails for this function;
> see
> -   the last page of <sys/stat.h>.  The real work is done by the `x'
> -   function which is passed a version number argument.  We arrange
> in the
> -   makefile that when not inlined this function is always statically
> -   linked; that way a dynamically-linked executable always encodes
> the
> -   version number corresponding to the data structures it uses, so
> the `x'
> -   functions in the shared library can adapt without needing to
> recompile
> -   all callers.  */
> -
> -#undef fstatat
> +#undef __fstatat
>  int
> -attribute_hidden
> -fstatat (int fd, const char *file, struct stat *buf, int flag)
> +__fstatat (int fd, const char *file, struct stat *buf, int flag)
>  {
>    return __fxstatat (_STAT_VER, fd, file, buf, flag);
>  }
> +
> +weak_alias (__fstatat, fstatat)
> diff --git a/io/fstatat64.c b/io/fstatat64.c
> index b57133bd90..5ba4cdf68a 100644
> --- a/io/fstatat64.c
> +++ b/io/fstatat64.c
> @@ -1,4 +1,5 @@
> -/* Copyright (C) 2005-2020 Free Software Foundation, Inc.
> +/* Get file status.
> +   Copyright (C) 2005-2020 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
> @@ -6,23 +7,6 @@
>     License as published by the Free Software Foundation; either
>     version 2.1 of the License, or (at your option) any later version.
>  
> -   In addition to the permissions in the GNU Lesser General Public
> -   License, the Free Software Foundation gives you unlimited
> -   permission to link the compiled version of this file with other
> -   programs, and to distribute those programs without any restriction
> -   coming from the use of this file. (The GNU Lesser General Public
> -   License restrictions do apply in other respects; for example, they
> -   cover modification of the file, and distribution when not linked
> -   into another program.)
> -
> -   Note that people who make modified versions of this file are not
> -   obligated to grant this special exception for their modified
> -   versions; it is their choice whether to do so. The GNU Lesser
> -   General Public License gives permission to release a modified
> -   version without this exception; this exception also makes it
> -   possible to release a modified version which carries forward this
> -   exception.
> -
>     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
> @@ -34,19 +18,11 @@
>  
>  #include <sys/stat.h>
>  
> -/* This definition is only used if inlining fails for this function;
> see
> -   the last page of <sys/stat.h>.  The real work is done by the `x'
> -   function which is passed a version number argument.  We arrange
> in the
> -   makefile that when not inlined this function is always statically
> -   linked; that way a dynamically-linked executable always encodes
> the
> -   version number corresponding to the data structures it uses, so
> the `x'
> -   functions in the shared library can adapt without needing to
> recompile
> -   all callers.  */
> -
> -#undef fstatat64
> +#undef __fstatat64
>  int
> -attribute_hidden
> -fstatat64 (int fd, const char *file, struct stat64 *buf, int flag)
> +__fstatat64 (int fd, const char *file, struct stat64 *buf, int flag)
>  {
>    return __fxstatat64 (_STAT_VER, fd, file, buf, flag);
>  }
> +hidden_def (__fstatat64)
> +weak_alias (__fstatat64, fstatat64)
> diff --git a/io/lstat.c b/io/lstat.c
> index 7134741106..2a046c05e1 100644
> --- a/io/lstat.c
> +++ b/io/lstat.c
> @@ -1,4 +1,5 @@
> -/* Copyright (C) 1996-2020 Free Software Foundation, Inc.
> +/* Get file status.
> +   Copyright (C) 1996-2020 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
> @@ -6,23 +7,6 @@
>     License as published by the Free Software Foundation; either
>     version 2.1 of the License, or (at your option) any later version.
>  
> -   In addition to the permissions in the GNU Lesser General Public
> -   License, the Free Software Foundation gives you unlimited
> -   permission to link the compiled version of this file with other
> -   programs, and to distribute those programs without any restriction
> -   coming from the use of this file. (The GNU Lesser General Public
> -   License restrictions do apply in other respects; for example, they
> -   cover modification of the file, and distribution when not linked
> -   into another program.)
> -
> -   Note that people who make modified versions of this file are not
> -   obligated to grant this special exception for their modified
> -   versions; it is their choice whether to do so. The GNU Lesser
> -   General Public License gives permission to release a modified
> -   version without this exception; this exception also makes it
> -   possible to release a modified version which carries forward this
> -   exception.
> -
>     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
> @@ -34,22 +18,11 @@
>  
>  #include <sys/stat.h>
>  
> -/* This definition is only used if inlining fails for this function;
> see
> -   the last page of <sys/stat.h>.  The real work is done by the `x'
> -   function which is passed a version number argument.  We arrange
> in the
> -   makefile that when not inlined this function is always statically
> -   linked; that way a dynamically-linked executable always encodes
> the
> -   version number corresponding to the data structures it uses, so
> the `x'
> -   functions in the shared library can adapt without needing to
> recompile
> -   all callers.  */
> -
> -#undef lstat
>  #undef __lstat
>  int
> -attribute_hidden
>  __lstat (const char *file, struct stat *buf)
>  {
>    return __lxstat (_STAT_VER, file, buf);
>  }
>  
> -weak_hidden_alias (__lstat, lstat)
> +weak_alias (__lstat, lstat)
> diff --git a/io/lstat64.c b/io/lstat64.c
> index a890da71a8..a73c5a2541 100644
> --- a/io/lstat64.c
> +++ b/io/lstat64.c
> @@ -1,4 +1,5 @@
> -/* Copyright (C) 1996-2020 Free Software Foundation, Inc.
> +/* Get file status.
> +   Copyright (C) 1996-2020 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
> @@ -6,23 +7,6 @@
>     License as published by the Free Software Foundation; either
>     version 2.1 of the License, or (at your option) any later version.
>  
> -   In addition to the permissions in the GNU Lesser General Public
> -   License, the Free Software Foundation gives you unlimited
> -   permission to link the compiled version of this file with other
> -   programs, and to distribute those programs without any restriction
> -   coming from the use of this file. (The GNU Lesser General Public
> -   License restrictions do apply in other respects; for example, they
> -   cover modification of the file, and distribution when not linked
> -   into another program.)
> -
> -   Note that people who make modified versions of this file are not
> -   obligated to grant this special exception for their modified
> -   versions; it is their choice whether to do so. The GNU Lesser
> -   General Public License gives permission to release a modified
> -   version without this exception; this exception also makes it
> -   possible to release a modified version which carries forward this
> -   exception.
> -
>     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
> @@ -34,19 +18,11 @@
>  
>  #include <sys/stat.h>
>  
> -/* This definition is only used if inlining fails for this function;
> see
> -   the last page of <sys/stat.h>.  The real work is done by the `x'
> -   function which is passed a version number argument.  We arrange
> in the
> -   makefile that when not inlined this function is always statically
> -   linked; that way a dynamically-linked executable always encodes
> the
> -   version number corresponding to the data structures it uses, so
> the `x'
> -   functions in the shared library can adapt without needing to
> recompile
> -   all callers.  */
> -
> -#undef lstat64
> +#undef __lstat64
>  int
> -attribute_hidden
> -lstat64 (const char *file, struct stat64 *buf)
> +__lstat64 (const char *file, struct stat64 *buf)
>  {
>    return __lxstat64 (_STAT_VER, file, buf);
>  }
> +hidden_def (__lstat64)
> +weak_alias (__lstat64, lstat64)
> diff --git a/io/stat.c b/io/stat.c
> index 8c3cd877c8..b3d06107e3 100644
> --- a/io/stat.c
> +++ b/io/stat.c
> @@ -1,4 +1,5 @@
> -/* Copyright (C) 1996-2020 Free Software Foundation, Inc.
> +/* Get file status.
> +   Copyright (C) 1996-2020 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
> @@ -6,23 +7,6 @@
>     License as published by the Free Software Foundation; either
>     version 2.1 of the License, or (at your option) any later version.
>  
> -   In addition to the permissions in the GNU Lesser General Public
> -   License, the Free Software Foundation gives you unlimited
> -   permission to link the compiled version of this file with other
> -   programs, and to distribute those programs without any restriction
> -   coming from the use of this file. (The GNU Lesser General Public
> -   License restrictions do apply in other respects; for example, they
> -   cover modification of the file, and distribution when not linked
> -   into another program.)
> -
> -   Note that people who make modified versions of this file are not
> -   obligated to grant this special exception for their modified
> -   versions; it is their choice whether to do so. The GNU Lesser
> -   General Public License gives permission to release a modified
> -   version without this exception; this exception also makes it
> -   possible to release a modified version which carries forward this
> -   exception.
> -
>     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
> @@ -34,21 +18,11 @@
>  
>  #include <sys/stat.h>
>  
> -/* This definition is only used if inlining fails for this function;
> see
> -   the last page of <sys/stat.h>.  The real work is done by the `x'
> -   function which is passed a version number argument.  We arrange
> in the
> -   makefile that when not inlined this function is always statically
> -   linked; that way a dynamically-linked executable always encodes
> the
> -   version number corresponding to the data structures it uses, so
> the `x'
> -   functions in the shared library can adapt without needing to
> recompile
> -   all callers.  */
> -
> -#undef stat
> +#undef __stat
>  int
> -attribute_hidden
>  __stat (const char *file, struct stat *buf)
>  {
>    return __xstat (_STAT_VER, file, buf);
>  }
>  
> -weak_hidden_alias (__stat, stat)
> +weak_alias (__stat, stat)
> diff --git a/io/stat64.c b/io/stat64.c
> index 8b6b662f3a..41e8905c4e 100644
> --- a/io/stat64.c
> +++ b/io/stat64.c
> @@ -1,4 +1,5 @@
> -/* Copyright (C) 1996-2020 Free Software Foundation, Inc.
> +/* Get file status.
> +   Copyright (C) 1996-2020 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
> @@ -6,23 +7,6 @@
>     License as published by the Free Software Foundation; either
>     version 2.1 of the License, or (at your option) any later version.
>  
> -   In addition to the permissions in the GNU Lesser General Public
> -   License, the Free Software Foundation gives you unlimited
> -   permission to link the compiled version of this file with other
> -   programs, and to distribute those programs without any restriction
> -   coming from the use of this file. (The GNU Lesser General Public
> -   License restrictions do apply in other respects; for example, they
> -   cover modification of the file, and distribution when not linked
> -   into another program.)
> -
> -   Note that people who make modified versions of this file are not
> -   obligated to grant this special exception for their modified
> -   versions; it is their choice whether to do so. The GNU Lesser
> -   General Public License gives permission to release a modified
> -   version without this exception; this exception also makes it
> -   possible to release a modified version which carries forward this
> -   exception.
> -
>     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
> @@ -34,19 +18,11 @@
>  
>  #include <sys/stat.h>
>  
> -/* This definition is only used if inlining fails for this function;
> see
> -   the last page of <sys/stat.h>.  The real work is done by the `x'
> -   function which is passed a version number argument.  We arrange
> in the
> -   makefile that when not inlined this function is always statically
> -   linked; that way a dynamically-linked executable always encodes
> the
> -   version number corresponding to the data structures it uses, so
> the `x'
> -   functions in the shared library can adapt without needing to
> recompile
> -   all callers.  */
> -
> -#undef stat64
> +#undef __stat64
>  int
> -attribute_hidden
> -stat64 (const char *file, struct stat64 *buf)
> +__stat64 (const char *file, struct stat64 *buf)
>  {
>    return __xstat64 (_STAT_VER, file, buf);
>  }
> +hidden_def (__stat64)
> +weak_alias (__stat64, stat64)
> diff --git a/io/sys/stat.h b/io/sys/stat.h
> index ce014d03a5..83cf253c72 100644
> --- a/io/sys/stat.h
> +++ b/io/sys/stat.h
> @@ -368,73 +368,10 @@ extern int utimensat (int __fd, const char
> *__path, extern int futimens (int __fd, const struct timespec
> __times[2]) __THROW; #endif
>  \f
> -/* To allow the `struct stat' structure and the file type `mode_t'
> -   bits to vary without changing shared library major version number,
> -   the `stat' family of functions and `mknod' are in fact inline
> -   wrappers around calls to `xstat', `fxstat', `lxstat', and
> `xmknod',
> -   which all take a leading version-number argument designating the
> -   data structure and bits used.  <bits/stat.h> defines _STAT_VER
> with
> -   the version number corresponding to `struct stat' as defined in
> -   that file; and _MKNOD_VER with the version number corresponding to
> -   the S_IF* macros defined therein.  It is arranged that when not
> -   inlined these function are always statically linked; that way a
> -   dynamically-linked executable always encodes the version number
> -   corresponding to the data structures it uses, so the `x' functions
> -   in the shared library can adapt without needing to recompile all
> -   callers.  */
> -
> -#ifndef _STAT_VER
> -# define _STAT_VER	0
> -#endif
>  #ifndef _MKNOD_VER
>  # define _MKNOD_VER	0
>  #endif
>  
> -/* Wrappers for stat and mknod system calls.  */
> -#ifndef __USE_FILE_OFFSET64
> -extern int __fxstat (int __ver, int __fildes, struct stat
> *__stat_buf)
> -     __THROW __nonnull ((3));
> -extern int __xstat (int __ver, const char *__filename,
> -		    struct stat *__stat_buf) __THROW __nonnull ((2,
> 3)); -extern int __lxstat (int __ver, const char *__filename,
> -		     struct stat *__stat_buf) __THROW __nonnull ((2,
> 3)); -extern int __fxstatat (int __ver, int __fildes, const char
> *__filename,
> -		       struct stat *__stat_buf, int __flag)
> -     __THROW __nonnull ((3, 4));
> -#else
> -# ifdef __REDIRECT_NTH
> -extern int __REDIRECT_NTH (__fxstat, (int __ver, int __fildes,
> -				      struct stat *__stat_buf),
> __fxstat64)
> -     __nonnull ((3));
> -extern int __REDIRECT_NTH (__xstat, (int __ver, const char
> *__filename,
> -				     struct stat *__stat_buf),
> __xstat64)
> -     __nonnull ((2, 3));
> -extern int __REDIRECT_NTH (__lxstat, (int __ver, const char
> *__filename,
> -				      struct stat *__stat_buf),
> __lxstat64)
> -     __nonnull ((2, 3));
> -extern int __REDIRECT_NTH (__fxstatat, (int __ver, int __fildes,
> -					const char *__filename,
> -					struct stat *__stat_buf, int
> __flag),
> -			   __fxstatat64) __nonnull ((3, 4));
> -
> -# else
> -#  define __fxstat __fxstat64
> -#  define __xstat __xstat64
> -#  define __lxstat __lxstat64
> -# endif
> -#endif
> -
> -#ifdef __USE_LARGEFILE64
> -extern int __fxstat64 (int __ver, int __fildes, struct stat64
> *__stat_buf)
> -     __THROW __nonnull ((3));
> -extern int __xstat64 (int __ver, const char *__filename,
> -		      struct stat64 *__stat_buf) __THROW __nonnull
> ((2, 3)); -extern int __lxstat64 (int __ver, const char *__filename,
> -		       struct stat64 *__stat_buf) __THROW __nonnull
> ((2, 3)); -extern int __fxstatat64 (int __ver, int __fildes, const
> char *__filename,
> -			 struct stat64 *__stat_buf, int __flag)
> -     __THROW __nonnull ((3, 4));
> -#endif
>  extern int __xmknod (int __ver, const char *__path, __mode_t __mode,
>  		     __dev_t *__dev) __THROW __nonnull ((2, 4));
>  
> @@ -447,37 +384,6 @@ extern int __xmknodat (int __ver, int __fd,
> const char *__path, #endif
>  
>  #ifdef __USE_EXTERN_INLINES
> -/* Inlined versions of the real stat and mknod functions.  */
> -
> -__extern_inline int
> -__NTH (stat (const char *__path, struct stat *__statbuf))
> -{
> -  return __xstat (_STAT_VER, __path, __statbuf);
> -}
> -
> -# if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
> -__extern_inline int
> -__NTH (lstat (const char *__path, struct stat *__statbuf))
> -{
> -  return __lxstat (_STAT_VER, __path, __statbuf);
> -}
> -# endif
> -
> -__extern_inline int
> -__NTH (fstat (int __fd, struct stat *__statbuf))
> -{
> -  return __fxstat (_STAT_VER, __fd, __statbuf);
> -}
> -
> -# ifdef __USE_ATFILE
> -__extern_inline int
> -__NTH (fstatat (int __fd, const char *__filename, struct stat
> *__statbuf,
> -		int __flag))
> -{
> -  return __fxstatat (_STAT_VER, __fd, __filename, __statbuf, __flag);
> -}
> -# endif
> -
>  # ifdef __USE_MISC
>  __extern_inline int
>  __NTH (mknod (const char *__path, __mode_t __mode, __dev_t __dev))
> @@ -494,41 +400,6 @@ __NTH (mknodat (int __fd, const char *__path,
> __mode_t __mode, return __xmknodat (_MKNOD_VER, __fd, __path, __mode,
> &__dev); }
>  # endif
> -
> -# if defined __USE_LARGEFILE64 \
> -  && (! defined __USE_FILE_OFFSET64 \
> -      || (defined __REDIRECT_NTH && defined __OPTIMIZE__))
> -__extern_inline int
> -__NTH (stat64 (const char *__path, struct stat64 *__statbuf))
> -{
> -  return __xstat64 (_STAT_VER, __path, __statbuf);
> -}
> -
> -#  if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
> -__extern_inline int
> -__NTH (lstat64 (const char *__path, struct stat64 *__statbuf))
> -{
> -  return __lxstat64 (_STAT_VER, __path, __statbuf);
> -}
> -#  endif
> -
> -__extern_inline int
> -__NTH (fstat64 (int __fd, struct stat64 *__statbuf))
> -{
> -  return __fxstat64 (_STAT_VER, __fd, __statbuf);
> -}
> -
> -#  ifdef __USE_ATFILE
> -__extern_inline int
> -__NTH (fstatat64 (int __fd, const char *__filename, struct stat64
> *__statbuf,
> -		  int __flag))
> -{
> -  return __fxstatat64 (_STAT_VER, __fd, __filename, __statbuf,
> __flag); -}
> -#  endif
> -
> -# endif
> -
>  #endif
>  
>  __END_DECLS
> diff --git a/nscd/gai.c b/nscd/gai.c
> index 2e19530102..b0058bc873 100644
> --- a/nscd/gai.c
> +++ b/nscd/gai.c
> @@ -16,6 +16,7 @@
>     along with this program; if not, see
> <https://www.gnu.org/licenses/>.  */ 
>  #include <alloca.h>
> +#include <sys/stat.h>
>  
>  /* This file uses the getaddrinfo code but it compiles it without
> NSCD support.  We just need a few symbol renames.  */
> @@ -32,6 +33,10 @@
>  #define __libc_use_alloca(size) (size <= __MAX_ALLOCA_CUTOFF)
>  #define __getifaddrs getifaddrs
>  #define __freeifaddrs freeifaddrs
> +#undef __fstat64
> +#define __fstat64 fstat64
> +#undef __stat64
> +#define __stat64 stat64
>  
>  /* We are nscd, so we don't want to be talking to ourselves.  */
>  #undef  USE_NSCD
> diff --git a/sysdeps/generic/xstatver.h b/sysdeps/generic/xstatver.h
> new file mode 100644
> index 0000000000..d727c98a16
> --- /dev/null
> +++ b/sysdeps/generic/xstatver.h
> @@ -0,0 +1,3 @@
> +/* Versions of the 'struct stat' data structure used in
> compatibility xstat
> +   functions.  */
> +#define _STAT_VER 0
> diff --git a/sysdeps/mach/hurd/i386/libc.abilist
> b/sysdeps/mach/hurd/i386/libc.abilist index 5f6154d518..74a4ed5c1d
> 100644 --- a/sysdeps/mach/hurd/i386/libc.abilist
> +++ b/sysdeps/mach/hurd/i386/libc.abilist
> @@ -2192,6 +2192,14 @@ GLIBC_2.32 thrd_current F
>  GLIBC_2.32 thrd_equal F
>  GLIBC_2.32 thrd_sleep F
>  GLIBC_2.32 thrd_yield F
> +GLIBC_2.33 fstat F
> +GLIBC_2.33 fstat64 F
> +GLIBC_2.33 fstatat F
> +GLIBC_2.33 fstatat64 F
> +GLIBC_2.33 lstat F
> +GLIBC_2.33 lstat64 F
> +GLIBC_2.33 stat F
> +GLIBC_2.33 stat64 F
>  GLIBC_2.4 __confstr_chk F
>  GLIBC_2.4 __fgets_chk F
>  GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
> index 82c898fe35..ad4923ddbc 100644
> --- a/sysdeps/posix/getaddrinfo.c
> +++ b/sysdeps/posix/getaddrinfo.c
> @@ -2138,7 +2138,7 @@ static void
>  gaiconf_reload (void)
>  {
>    struct stat64 st;
> -  if (stat64 (GAICONF_FNAME, &st) != 0
> +  if (__stat64 (GAICONF_FNAME, &st) != 0
>        || !check_gaiconf_mtime (&st))
>      gaiconf_init ();
>  }
> diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist
> b/sysdeps/unix/sysv/linux/aarch64/libc.abilist index
> 6cd61988b4..03e4ae9296 100644 ---
> a/sysdeps/unix/sysv/linux/aarch64/libc.abilist +++
> b/sysdeps/unix/sysv/linux/aarch64/libc.abilist @@ -2160,3 +2160,11 @@
> GLIBC_2.32 sigabbrev_np F GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 fstat F
> +GLIBC_2.33 fstat64 F
> +GLIBC_2.33 fstatat F
> +GLIBC_2.33 fstatat64 F
> +GLIBC_2.33 lstat F
> +GLIBC_2.33 lstat64 F
> +GLIBC_2.33 stat F
> +GLIBC_2.33 stat64 F
> diff --git a/sysdeps/unix/sysv/linux/alpha/bits/stat.h
> b/sysdeps/unix/sysv/linux/alpha/bits/stat.h index
> 0064ca09ff..1fc27936b9 100644 ---
> a/sysdeps/unix/sysv/linux/alpha/bits/stat.h +++
> b/sysdeps/unix/sysv/linux/alpha/bits/stat.h @@ -22,15 +22,6 @@
>  #ifndef _BITS_STAT_H
>  #define _BITS_STAT_H	1
>  
> -/* Versions of the `struct stat' data structure.  */
> -#define _STAT_VER_KERNEL	0
> -#define _STAT_VER_GLIBC2	1
> -#define _STAT_VER_GLIBC2_1	2
> -#define _STAT_VER_KERNEL64	3
> -#define _STAT_VER_GLIBC2_3_4	3
> -#define _STAT_VER_LINUX		3
> -#define _STAT_VER		_STAT_VER_LINUX
> -
>  /* Versions of the `xmknod' interface.  */
>  #define _MKNOD_VER_LINUX	0
>  
> diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist
> b/sysdeps/unix/sysv/linux/alpha/libc.abilist index
> 8edb5deea1..5b752ef4a8 100644 ---
> a/sysdeps/unix/sysv/linux/alpha/libc.abilist +++
> b/sysdeps/unix/sysv/linux/alpha/libc.abilist @@ -2242,6 +2242,14 @@
> GLIBC_2.32 sigabbrev_np F GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 fstat F
> +GLIBC_2.33 fstat64 F
> +GLIBC_2.33 fstatat F
> +GLIBC_2.33 fstatat64 F
> +GLIBC_2.33 lstat F
> +GLIBC_2.33 lstat64 F
> +GLIBC_2.33 stat F
> +GLIBC_2.33 stat64 F
>  GLIBC_2.4 _IO_fprintf F
>  GLIBC_2.4 _IO_printf F
>  GLIBC_2.4 _IO_sprintf F
> diff --git a/sysdeps/unix/sysv/linux/alpha/xstatver.h
> b/sysdeps/unix/sysv/linux/alpha/xstatver.h new file mode 100644
> index 0000000000..bbb9469617
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/alpha/xstatver.h
> @@ -0,0 +1,9 @@
> +/* Versions of the 'struct stat' data structure used in
> compatibility xstat
> +   functions.  */
> +#define _STAT_VER_KERNEL	0
> +#define _STAT_VER_GLIBC2	1
> +#define _STAT_VER_GLIBC2_1	2
> +#define _STAT_VER_KERNEL64	3
> +#define _STAT_VER_GLIBC2_3_4	3
> +#define _STAT_VER_LINUX		3
> +#define _STAT_VER		_STAT_VER_LINUX
> diff --git a/sysdeps/unix/sysv/linux/arc/libc.abilist
> b/sysdeps/unix/sysv/linux/arc/libc.abilist index
> df13f49e15..925b532383 100644 ---
> a/sysdeps/unix/sysv/linux/arc/libc.abilist +++
> b/sysdeps/unix/sysv/linux/arc/libc.abilist @@ -1920,3 +1920,11 @@
> GLIBC_2.32 wprintf F GLIBC_2.32 write F
>  GLIBC_2.32 writev F
>  GLIBC_2.32 wscanf F
> +GLIBC_2.33 fstat F
> +GLIBC_2.33 fstat64 F
> +GLIBC_2.33 fstatat F
> +GLIBC_2.33 fstatat64 F
> +GLIBC_2.33 lstat F
> +GLIBC_2.33 lstat64 F
> +GLIBC_2.33 stat F
> +GLIBC_2.33 stat64 F
> diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist
> b/sysdeps/unix/sysv/linux/arm/le/libc.abilist index
> a83cc81958..a4c1a7c03c 100644 ---
> a/sysdeps/unix/sysv/linux/arm/le/libc.abilist +++
> b/sysdeps/unix/sysv/linux/arm/le/libc.abilist @@ -141,6 +141,14 @@
> GLIBC_2.32 sigabbrev_np F GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 fstat F
> +GLIBC_2.33 fstat64 F
> +GLIBC_2.33 fstatat F
> +GLIBC_2.33 fstatat64 F
> +GLIBC_2.33 lstat F
> +GLIBC_2.33 lstat64 F
> +GLIBC_2.33 stat F
> +GLIBC_2.33 stat64 F
>  GLIBC_2.4 _Exit F
>  GLIBC_2.4 _IO_2_1_stderr_ D 0xa0
>  GLIBC_2.4 _IO_2_1_stdin_ D 0xa0
> diff --git a/sysdeps/unix/sysv/linux/bits/stat.h
> b/sysdeps/unix/sysv/linux/bits/stat.h index 240628a6f4..b542623208
> 100644 --- a/sysdeps/unix/sysv/linux/bits/stat.h
> +++ b/sysdeps/unix/sysv/linux/bits/stat.h
> @@ -23,12 +23,6 @@
>  #define _BITS_STAT_H	1
>  
>  /* Versions of the `struct stat' data structure.  */
> -#define _STAT_VER_LINUX_OLD	1
> -#define _STAT_VER_KERNEL	1
> -#define _STAT_VER_SVR4		2
> -#define _STAT_VER_LINUX		3
> -#define _STAT_VER		_STAT_VER_LINUX	/* The one
> defined below.  */ -
>  /* Versions of the `xmknod' interface.  */
>  #define _MKNOD_VER_LINUX	1
>  #define _MKNOD_VER_SVR4		2
> diff --git a/sysdeps/unix/sysv/linux/csky/libc.abilist
> b/sysdeps/unix/sysv/linux/csky/libc.abilist index
> 32887b1c58..799873e189 100644 ---
> a/sysdeps/unix/sysv/linux/csky/libc.abilist +++
> b/sysdeps/unix/sysv/linux/csky/libc.abilist @@ -2104,3 +2104,11 @@
> GLIBC_2.32 sigabbrev_np F GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 fstat F
> +GLIBC_2.33 fstat64 F
> +GLIBC_2.33 fstatat F
> +GLIBC_2.33 fstatat64 F
> +GLIBC_2.33 lstat F
> +GLIBC_2.33 lstat64 F
> +GLIBC_2.33 stat F
> +GLIBC_2.33 stat64 F
> diff --git a/sysdeps/unix/sysv/linux/generic/bits/stat.h
> b/sysdeps/unix/sysv/linux/generic/bits/stat.h index
> 8d0980f0f5..35e14a47c6 100644 ---
> a/sysdeps/unix/sysv/linux/generic/bits/stat.h +++
> b/sysdeps/unix/sysv/linux/generic/bits/stat.h @@ -26,17 +26,6 @@
>  #include <bits/endian.h>
>  #include <bits/wordsize.h>
>  
> -/* 64-bit libc uses the kernel's 'struct stat', accessed via the
> -   stat() syscall; 32-bit libc uses the kernel's 'struct stat64'
> -   and accesses it via the stat64() syscall.  All the various
> -   APIs offered by libc use the kernel shape for their struct stat
> -   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 (specifically st_ino, st_size, and st_blocks).  */
> -#define _STAT_VER_KERNEL	0
> -#define _STAT_VER_LINUX		0
> -#define _STAT_VER		_STAT_VER_KERNEL
> -
>  /* Versions of the `xmknod' interface.  */
>  #define _MKNOD_VER_LINUX	0
>  
> diff --git a/sysdeps/unix/sysv/linux/generic/xstatver.h
> b/sysdeps/unix/sysv/linux/generic/xstatver.h new file mode 100644
> index 0000000000..8675db494c
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/generic/xstatver.h
> @@ -0,0 +1,5 @@
> +/* Versions of the 'struct stat' data structure used in
> compatibility xstat
> +   functions.  */
> +#define _STAT_VER_KERNEL	0
> +#define _STAT_VER_LINUX		0
> +#define _STAT_VER		_STAT_VER_KERNEL
> diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist
> b/sysdeps/unix/sysv/linux/hppa/libc.abilist index
> baf425072b..95c7bf4f06 100644 ---
> a/sysdeps/unix/sysv/linux/hppa/libc.abilist +++
> b/sysdeps/unix/sysv/linux/hppa/libc.abilist @@ -2063,6 +2063,14 @@
> GLIBC_2.32 sigabbrev_np F GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 fstat F
> +GLIBC_2.33 fstat64 F
> +GLIBC_2.33 fstatat F
> +GLIBC_2.33 fstatat64 F
> +GLIBC_2.33 lstat F
> +GLIBC_2.33 lstat64 F
> +GLIBC_2.33 stat F
> +GLIBC_2.33 stat64 F
>  GLIBC_2.4 __confstr_chk F
>  GLIBC_2.4 __fgets_chk F
>  GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist
> b/sysdeps/unix/sysv/linux/i386/libc.abilist index
> 8b0242a9b1..e7cf5cdb98 100644 ---
> a/sysdeps/unix/sysv/linux/i386/libc.abilist +++
> b/sysdeps/unix/sysv/linux/i386/libc.abilist @@ -2229,6 +2229,14 @@
> GLIBC_2.32 sigabbrev_np F GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 fstat F
> +GLIBC_2.33 fstat64 F
> +GLIBC_2.33 fstatat F
> +GLIBC_2.33 fstatat64 F
> +GLIBC_2.33 lstat F
> +GLIBC_2.33 lstat64 F
> +GLIBC_2.33 stat F
> +GLIBC_2.33 stat64 F
>  GLIBC_2.4 __confstr_chk F
>  GLIBC_2.4 __fgets_chk F
>  GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/ia64/bits/stat.h
> b/sysdeps/unix/sysv/linux/ia64/bits/stat.h index
> 608e988ae6..8ec2e4c81f 100644 ---
> a/sysdeps/unix/sysv/linux/ia64/bits/stat.h +++
> b/sysdeps/unix/sysv/linux/ia64/bits/stat.h @@ -22,11 +22,6 @@
>  #ifndef _BITS_STAT_H
>  #define _BITS_STAT_H	1
>  
> -/* Versions of the `struct stat' data structure.  */
> -#define _STAT_VER_KERNEL	0
> -#define _STAT_VER_LINUX		1
> -#define _STAT_VER		_STAT_VER_LINUX
> -
>  /* Versions of the `xmknod' interface.  */
>  #define _MKNOD_VER_LINUX	0
>  
> diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist
> b/sysdeps/unix/sysv/linux/ia64/libc.abilist index
> b6ba86dbe9..beeb905efd 100644 ---
> a/sysdeps/unix/sysv/linux/ia64/libc.abilist +++
> b/sysdeps/unix/sysv/linux/ia64/libc.abilist @@ -2095,6 +2095,14 @@
> GLIBC_2.32 sigabbrev_np F GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 fstat F
> +GLIBC_2.33 fstat64 F
> +GLIBC_2.33 fstatat F
> +GLIBC_2.33 fstatat64 F
> +GLIBC_2.33 lstat F
> +GLIBC_2.33 lstat64 F
> +GLIBC_2.33 stat F
> +GLIBC_2.33 stat64 F
>  GLIBC_2.4 __confstr_chk F
>  GLIBC_2.4 __fgets_chk F
>  GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/ia64/xstatver.h
> b/sysdeps/unix/sysv/linux/ia64/xstatver.h new file mode 100644
> index 0000000000..4f02f697ad
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/ia64/xstatver.h
> @@ -0,0 +1,5 @@
> +/* Versions of the 'struct stat' data structure used in
> compatibility xstat
> +   functions.  */
> +#define _STAT_VER_KERNEL	0
> +#define _STAT_VER_LINUX		1
> +#define _STAT_VER		_STAT_VER_LINUX
> diff --git a/sysdeps/unix/sysv/linux/m68k/bits/stat.h
> b/sysdeps/unix/sysv/linux/m68k/bits/stat.h index
> 453dcac709..bf41776e6c 100644 ---
> a/sysdeps/unix/sysv/linux/m68k/bits/stat.h +++
> b/sysdeps/unix/sysv/linux/m68k/bits/stat.h @@ -22,13 +22,6 @@
>  #ifndef _BITS_STAT_H
>  #define _BITS_STAT_H	1
>  
> -/* Versions of the `struct stat' data structure.  */
> -#define _STAT_VER_LINUX_OLD	1
> -#define _STAT_VER_KERNEL	1
> -#define _STAT_VER_SVR4		2
> -#define _STAT_VER_LINUX		3
> -#define _STAT_VER		_STAT_VER_LINUX	/* The one
> defined below.  */ -
>  /* Versions of the `xmknod' interface.  */
>  #define _MKNOD_VER_LINUX	1
>  #define _MKNOD_VER_SVR4		2
> diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
> b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist index
> 2d726097ca..ed34e1fc82 100644 ---
> a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist +++
> b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist @@ -2175,6
> +2175,14 @@ GLIBC_2.32 sigabbrev_np F GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 fstat F
> +GLIBC_2.33 fstat64 F
> +GLIBC_2.33 fstatat F
> +GLIBC_2.33 fstatat64 F
> +GLIBC_2.33 lstat F
> +GLIBC_2.33 lstat64 F
> +GLIBC_2.33 stat F
> +GLIBC_2.33 stat64 F
>  GLIBC_2.4 __confstr_chk F
>  GLIBC_2.4 __fgets_chk F
>  GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/m68k/xstatver.h
> b/sysdeps/unix/sysv/linux/m68k/xstatver.h new file mode 100644
> index 0000000000..59dba71dd1
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/m68k/xstatver.h
> @@ -0,0 +1,7 @@
> +/* Versions of the 'struct stat' data structure used in
> compatibility xstat
> +   functions.  */
> +#define _STAT_VER_LINUX_OLD	1
> +#define _STAT_VER_KERNEL	1
> +#define _STAT_VER_SVR4		2
> +#define _STAT_VER_LINUX		3
> +#define _STAT_VER		_STAT_VER_LINUX
> diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
> b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist index
> 7c78649e03..e00f5115b2 100644 ---
> a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist +++
> b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist @@ -2155,3
> +2155,11 @@ GLIBC_2.32 sigabbrev_np F GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 fstat F
> +GLIBC_2.33 fstat64 F
> +GLIBC_2.33 fstatat F
> +GLIBC_2.33 fstatat64 F
> +GLIBC_2.33 lstat F
> +GLIBC_2.33 lstat64 F
> +GLIBC_2.33 stat F
> +GLIBC_2.33 stat64 F
> diff --git a/sysdeps/unix/sysv/linux/microblaze/bits/stat.h
> b/sysdeps/unix/sysv/linux/microblaze/bits/stat.h index
> c5817e5b77..51316a8c1b 100644 ---
> a/sysdeps/unix/sysv/linux/microblaze/bits/stat.h +++
> b/sysdeps/unix/sysv/linux/microblaze/bits/stat.h @@ -23,13 +23,6 @@
>  #ifndef _BITS_STAT_H
>  #define _BITS_STAT_H	1
>  
> -/* Versions of the `struct stat' data structure.  */
> -#define _STAT_VER_LINUX_OLD    1
> -#define _STAT_VER_KERNEL       1
> -#define _STAT_VER_SVR4         2
> -#define _STAT_VER_LINUX        3
> -#define _STAT_VER              _STAT_VER_LINUX  /* The one defined
> below.  */ -
>  /* Versions of the `xmknod' interface.  */
>  #define _MKNOD_VER_LINUX       1
>  #define _MKNOD_VER_SVR4        2
> diff --git a/sysdeps/unix/sysv/linux/microblaze/xstatver.h
> b/sysdeps/unix/sysv/linux/microblaze/xstatver.h new file mode 100644
> index 0000000000..bddaa0d5ec
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/microblaze/xstatver.h
> @@ -0,0 +1,7 @@
> +/* Versions of the 'struct stat' data structure used in
> compatibility xstat
> +   functions.  */
> +#define _STAT_VER_LINUX_OLD    1
> +#define _STAT_VER_KERNEL       1
> +#define _STAT_VER_SVR4         2
> +#define _STAT_VER_LINUX        3
> +#define _STAT_VER              _STAT_VER_LINUX  /* The one defined
> below.  */ diff --git a/sysdeps/unix/sysv/linux/mips/bits/stat.h
> b/sysdeps/unix/sysv/linux/mips/bits/stat.h index
> b0e6726655..cfeb4ce6a4 100644 ---
> a/sysdeps/unix/sysv/linux/mips/bits/stat.h +++
> b/sysdeps/unix/sysv/linux/mips/bits/stat.h @@ -24,13 +24,6 @@
>  
>  #include <sgidefs.h>
>  
> -/* Versions of the `struct stat' data structure.  */
> -#define _STAT_VER_LINUX_OLD	1
> -#define _STAT_VER_KERNEL	1
> -#define _STAT_VER_SVR4		2
> -#define _STAT_VER_LINUX		3
> -#define _STAT_VER		_STAT_VER_LINUX /* The one defined
> below.  */ -
>  /* Versions of the `xmknod' interface.  */
>  #define _MKNOD_VER_LINUX	1
>  #define _MKNOD_VER_SVR4		2
> diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
> b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist index
> 9fa655b3a5..fe9ba4e982 100644 ---
> a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist +++
> b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist @@ -2146,6
> +2146,14 @@ GLIBC_2.32 sigabbrev_np F GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 fstat F
> +GLIBC_2.33 fstat64 F
> +GLIBC_2.33 fstatat F
> +GLIBC_2.33 fstatat64 F
> +GLIBC_2.33 lstat F
> +GLIBC_2.33 lstat64 F
> +GLIBC_2.33 stat F
> +GLIBC_2.33 stat64 F
>  GLIBC_2.4 __confstr_chk F
>  GLIBC_2.4 __fgets_chk F
>  GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
> b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist index
> de990933cf..e67591e710 100644 ---
> a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist +++
> b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist @@ -2152,6
> +2152,14 @@ GLIBC_2.32 sigabbrev_np F GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 fstat F
> +GLIBC_2.33 fstat64 F
> +GLIBC_2.33 fstatat F
> +GLIBC_2.33 fstatat64 F
> +GLIBC_2.33 lstat F
> +GLIBC_2.33 lstat64 F
> +GLIBC_2.33 stat F
> +GLIBC_2.33 stat64 F
>  GLIBC_2.4 __confstr_chk F
>  GLIBC_2.4 __fgets_chk F
>  GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
> b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist index
> 754491f209..e4eb9e6bbf 100644 ---
> a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist +++
> b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist @@ -2146,6
> +2146,14 @@ GLIBC_2.32 sigabbrev_np F GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 fstat F
> +GLIBC_2.33 fstat64 F
> +GLIBC_2.33 fstatat F
> +GLIBC_2.33 fstatat64 F
> +GLIBC_2.33 lstat F
> +GLIBC_2.33 lstat64 F
> +GLIBC_2.33 stat F
> +GLIBC_2.33 stat64 F
>  GLIBC_2.4 __confstr_chk F
>  GLIBC_2.4 __fgets_chk F
>  GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/mips/xstatver.h
> b/sysdeps/unix/sysv/linux/mips/xstatver.h new file mode 100644
> index 0000000000..59dba71dd1
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/mips/xstatver.h
> @@ -0,0 +1,7 @@
> +/* Versions of the 'struct stat' data structure used in
> compatibility xstat
> +   functions.  */
> +#define _STAT_VER_LINUX_OLD	1
> +#define _STAT_VER_KERNEL	1
> +#define _STAT_VER_SVR4		2
> +#define _STAT_VER_LINUX		3
> +#define _STAT_VER		_STAT_VER_LINUX
> diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist
> b/sysdeps/unix/sysv/linux/nios2/libc.abilist index
> 36a875115c..0878998441 100644 ---
> a/sysdeps/unix/sysv/linux/nios2/libc.abilist +++
> b/sysdeps/unix/sysv/linux/nios2/libc.abilist @@ -2193,3 +2193,11 @@
> GLIBC_2.32 sigabbrev_np F GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 fstat F
> +GLIBC_2.33 fstat64 F
> +GLIBC_2.33 fstatat F
> +GLIBC_2.33 fstatat64 F
> +GLIBC_2.33 lstat F
> +GLIBC_2.33 lstat64 F
> +GLIBC_2.33 stat F
> +GLIBC_2.33 stat64 F
> diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/stat.h
> b/sysdeps/unix/sysv/linux/powerpc/bits/stat.h index
> 61781bd902..40ea9a96d4 100644 ---
> a/sysdeps/unix/sysv/linux/powerpc/bits/stat.h +++
> b/sysdeps/unix/sysv/linux/powerpc/bits/stat.h @@ -24,17 +24,6 @@
>  
>  #include <bits/wordsize.h>
>  
> -/* Versions of the `struct stat' data structure.  */
> -#define _STAT_VER_LINUX_OLD	1
> -#define _STAT_VER_KERNEL	1
> -#define _STAT_VER_SVR4		2
> -#define _STAT_VER_LINUX	  3
> -#if __WORDSIZE == 32
> -# define _STAT_VER		_STAT_VER_LINUX
> -#else
> -# define _STAT_VER		_STAT_VER_KERNEL
> -#endif
> -
>  /* Versions of the `xmknod' interface.  */
>  #define _MKNOD_VER_LINUX	1
>  #define _MKNOD_VER_SVR4		2
> diff --git
> a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
> b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist index
> 6de9bed51d..993c957e8e 100644 ---
> a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist +++
> b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist @@
> -2202,6 +2202,14 @@ GLIBC_2.32 sigabbrev_np F GLIBC_2.32 sigdescr_np
> F GLIBC_2.32 strerrordesc_np F GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 fstat F
> +GLIBC_2.33 fstat64 F
> +GLIBC_2.33 fstatat F
> +GLIBC_2.33 fstatat64 F
> +GLIBC_2.33 lstat F
> +GLIBC_2.33 lstat64 F
> +GLIBC_2.33 stat F
> +GLIBC_2.33 stat64 F
>  GLIBC_2.4 _IO_fprintf F
>  GLIBC_2.4 _IO_printf F
>  GLIBC_2.4 _IO_sprintf F
> diff --git
> a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
> b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist index
> 92114806ac..25a8e828e9 100644 ---
> a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist +++
> b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist @@
> -2065,6 +2065,14 @@ GLIBC_2.32 sigabbrev_np F GLIBC_2.32 sigdescr_np
> F GLIBC_2.32 strerrordesc_np F GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 fstat F
> +GLIBC_2.33 fstat64 F
> +GLIBC_2.33 fstatat F
> +GLIBC_2.33 fstatat64 F
> +GLIBC_2.33 lstat F
> +GLIBC_2.33 lstat64 F
> +GLIBC_2.33 stat F
> +GLIBC_2.33 stat64 F
>  GLIBC_2.4 _IO_fprintf F
>  GLIBC_2.4 _IO_printf F
>  GLIBC_2.4 _IO_sprintf F
> diff --git
> a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
> b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist index
> b01fdcfae1..46ae28e552 100644 ---
> a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist +++
> b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist @@
> -2355,3 +2355,11 @@ GLIBC_2.32 sigabbrev_np F GLIBC_2.32 sigdescr_np
> F GLIBC_2.32 strerrordesc_np F GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 fstat F
> +GLIBC_2.33 fstat64 F
> +GLIBC_2.33 fstatat F
> +GLIBC_2.33 fstatat64 F
> +GLIBC_2.33 lstat F
> +GLIBC_2.33 lstat64 F
> +GLIBC_2.33 stat F
> +GLIBC_2.33 stat64 F
> diff --git a/sysdeps/unix/sysv/linux/powerpc/xstatver.h
> b/sysdeps/unix/sysv/linux/powerpc/xstatver.h new file mode 100644
> index 0000000000..1656e2f7e4
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/powerpc/xstatver.h
> @@ -0,0 +1,11 @@
> +/* Versions of the 'struct stat' data structure used in
> compatibility xstat
> +   functions.  */
> +#define _STAT_VER_LINUX_OLD	1
> +#define _STAT_VER_KERNEL	1
> +#define _STAT_VER_SVR4		2
> +#define _STAT_VER_LINUX	  3
> +#if __WORDSIZE == 32
> +# define _STAT_VER		_STAT_VER_LINUX
> +#else
> +# define _STAT_VER		_STAT_VER_KERNEL
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
> b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist index
> 45cbeb1d98..1044aa6be2 100644 ---
> a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist +++
> b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist @@ -2122,3 +2122,11
> @@ GLIBC_2.32 sigabbrev_np F GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 fstat F
> +GLIBC_2.33 fstat64 F
> +GLIBC_2.33 fstatat F
> +GLIBC_2.33 fstatat64 F
> +GLIBC_2.33 lstat F
> +GLIBC_2.33 lstat64 F
> +GLIBC_2.33 stat F
> +GLIBC_2.33 stat64 F
> diff --git a/sysdeps/unix/sysv/linux/s390/bits/stat.h
> b/sysdeps/unix/sysv/linux/s390/bits/stat.h index
> b383a98692..d12055529a 100644 ---
> a/sysdeps/unix/sysv/linux/s390/bits/stat.h +++
> b/sysdeps/unix/sysv/linux/s390/bits/stat.h @@ -25,21 +25,9 @@
>  #include <bits/wordsize.h>
>  
>  #if __WORDSIZE == 64
> -/* Versions of the `struct stat' data structure.  */
> -# define _STAT_VER_KERNEL	0
> -# define _STAT_VER_LINUX	1
> -# define _STAT_VER		_STAT_VER_LINUX
> -
>  /* Versions of the `xmknod' interface.	*/
>  #define _MKNOD_VER_LINUX	0
>  #else
> -/* Versions of the `struct stat' data structure.  */
> -# define _STAT_VER_LINUX_OLD	1
> -# define _STAT_VER_KERNEL	1
> -# define _STAT_VER_SVR4		2
> -# define _STAT_VER_LINUX	3
> -# define _STAT_VER		_STAT_VER_LINUX
> -
>  /* Versions of the `xmknod' interface.  */
>  # define _MKNOD_VER_LINUX	1
>  # define _MKNOD_VER_SVR4	2
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
> b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist index
> d0752dba6c..6b1fa7e67f 100644 ---
> a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist +++
> b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist @@ -2200,6
> +2200,14 @@ GLIBC_2.32 sigabbrev_np F GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 fstat F
> +GLIBC_2.33 fstat64 F
> +GLIBC_2.33 fstatat F
> +GLIBC_2.33 fstatat64 F
> +GLIBC_2.33 lstat F
> +GLIBC_2.33 lstat64 F
> +GLIBC_2.33 stat F
> +GLIBC_2.33 stat64 F
>  GLIBC_2.4 _IO_fprintf F
>  GLIBC_2.4 _IO_printf F
>  GLIBC_2.4 _IO_sprintf F
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
> b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist index
> af5f14d1c6..0aec094e7b 100644 ---
> a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist +++
> b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist @@ -2101,6
> +2101,14 @@ GLIBC_2.32 sigabbrev_np F GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 fstat F
> +GLIBC_2.33 fstat64 F
> +GLIBC_2.33 fstatat F
> +GLIBC_2.33 fstatat64 F
> +GLIBC_2.33 lstat F
> +GLIBC_2.33 lstat64 F
> +GLIBC_2.33 stat F
> +GLIBC_2.33 stat64 F
>  GLIBC_2.4 _IO_fprintf F
>  GLIBC_2.4 _IO_printf F
>  GLIBC_2.4 _IO_sprintf F
> diff --git a/sysdeps/unix/sysv/linux/s390/xstatver.h
> b/sysdeps/unix/sysv/linux/s390/xstatver.h new file mode 100644
> index 0000000000..5ad0db2797
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/s390/xstatver.h
> @@ -0,0 +1,16 @@
> +/* Versions of the 'struct stat' data structure used in
> compatibility xstat
> +   functions.  */
> +
> +#include <bits/wordsize.h>
> +
> +#if __WORDSIZE == 64
> +# define _STAT_VER_KERNEL	0
> +# define _STAT_VER_LINUX	1
> +# define _STAT_VER		_STAT_VER_LINUX
> +#else
> +# define _STAT_VER_LINUX_OLD	1
> +# define _STAT_VER_KERNEL	1
> +# define _STAT_VER_SVR4		2
> +# define _STAT_VER_LINUX	3
> +# define _STAT_VER		_STAT_VER_LINUX
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist
> b/sysdeps/unix/sysv/linux/sh/le/libc.abilist index
> 182970a708..e2ae13d4fa 100644 ---
> a/sysdeps/unix/sysv/linux/sh/le/libc.abilist +++
> b/sysdeps/unix/sysv/linux/sh/le/libc.abilist @@ -2067,6 +2067,14 @@
> GLIBC_2.32 sigabbrev_np F GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 fstat F
> +GLIBC_2.33 fstat64 F
> +GLIBC_2.33 fstatat F
> +GLIBC_2.33 fstatat64 F
> +GLIBC_2.33 lstat F
> +GLIBC_2.33 lstat64 F
> +GLIBC_2.33 stat F
> +GLIBC_2.33 stat64 F
>  GLIBC_2.4 __confstr_chk F
>  GLIBC_2.4 __fgets_chk F
>  GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/sparc/bits/stat.h
> b/sysdeps/unix/sysv/linux/sparc/bits/stat.h index
> 7379f2232d..7af17b5c40 100644 ---
> a/sysdeps/unix/sysv/linux/sparc/bits/stat.h +++
> b/sysdeps/unix/sysv/linux/sparc/bits/stat.h @@ -22,13 +22,6 @@
>  #ifndef _BITS_STAT_H
>  #define _BITS_STAT_H	1
>  
> -/* Versions of the `struct stat' data structure.  */
> -#define _STAT_VER_LINUX_OLD	1
> -#define _STAT_VER_KERNEL	1
> -#define _STAT_VER_SVR4		2
> -#define _STAT_VER_LINUX		3
> -#define _STAT_VER		_STAT_VER_LINUX	/* The one
> defined below.  */ -
>  /* Versions of the `xmknod' interface.  */
>  #define _MKNOD_VER_LINUX	1
>  #define _MKNOD_VER_SVR4		2
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
> b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist index
> a2521c3ee3..886e01960f 100644 ---
> a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist +++
> b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist @@ -2191,6
> +2191,14 @@ GLIBC_2.32 sigabbrev_np F GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 fstat F
> +GLIBC_2.33 fstat64 F
> +GLIBC_2.33 fstatat F
> +GLIBC_2.33 fstatat64 F
> +GLIBC_2.33 lstat F
> +GLIBC_2.33 lstat64 F
> +GLIBC_2.33 stat F
> +GLIBC_2.33 stat64 F
>  GLIBC_2.4 _IO_fprintf F
>  GLIBC_2.4 _IO_printf F
>  GLIBC_2.4 _IO_sprintf F
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
> b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist index
> d8188903f9..33b068201a 100644 ---
> a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist +++
> b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist @@ -2118,6
> +2118,14 @@ GLIBC_2.32 sigabbrev_np F GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 fstat F
> +GLIBC_2.33 fstat64 F
> +GLIBC_2.33 fstatat F
> +GLIBC_2.33 fstatat64 F
> +GLIBC_2.33 lstat F
> +GLIBC_2.33 lstat64 F
> +GLIBC_2.33 stat F
> +GLIBC_2.33 stat64 F
>  GLIBC_2.4 __confstr_chk F
>  GLIBC_2.4 __fgets_chk F
>  GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/sparc/xstatver.h
> b/sysdeps/unix/sysv/linux/sparc/xstatver.h new file mode 100644
> index 0000000000..ae92b530e7
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/sparc/xstatver.h
> @@ -0,0 +1,7 @@
> +/* Versions of the 'struct stat' data structure used in
> compatibility xstat
> +   functions.  */
> +#define _STAT_VER_LINUX_OLD	1
> +#define _STAT_VER_KERNEL	1
> +#define _STAT_VER_SVR4		2
> +#define _STAT_VER_LINUX		3
> +#define _STAT_VER		_STAT_VER_LINUX	/* The one
> defined below.  */ diff --git
> a/sysdeps/unix/sysv/linux/x86/bits/stat.h
> b/sysdeps/unix/sysv/linux/x86/bits/stat.h index
> 25dec69dda..f132569e9d 100644 ---
> a/sysdeps/unix/sysv/linux/x86/bits/stat.h +++
> b/sysdeps/unix/sysv/linux/x86/bits/stat.h @@ -24,25 +24,15 @@ 
>  /* Versions of the `struct stat' data structure.  */
>  #ifndef __x86_64__
> -# define _STAT_VER_LINUX_OLD	1
> -# define _STAT_VER_KERNEL	1
> -# define _STAT_VER_SVR4		2
> -# define _STAT_VER_LINUX	3
> -
>  /* i386 versions of the `xmknod' interface.  */
>  # define _MKNOD_VER_LINUX	1
>  # define _MKNOD_VER_SVR4	2
>  # define _MKNOD_VER		_MKNOD_VER_LINUX /* The bits
> defined below.  */ #else
> -# define _STAT_VER_KERNEL	0
> -# define _STAT_VER_LINUX	1
> -
>  /* x86-64 versions of the `xmknod' interface.  */
>  # define _MKNOD_VER_LINUX	0
>  #endif
>  
> -#define _STAT_VER		_STAT_VER_LINUX
> -
>  struct stat
>    {
>      __dev_t st_dev;		/* Device.  */
> diff --git a/sysdeps/unix/sysv/linux/x86/xstatver.h
> b/sysdeps/unix/sysv/linux/x86/xstatver.h new file mode 100644
> index 0000000000..6f047a346d
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/x86/xstatver.h
> @@ -0,0 +1,13 @@
> +/* Versions of the 'struct stat' data structure used in
> compatibility xstat
> +   functions.  */
> +#ifndef __x86_64__
> +# define _STAT_VER_LINUX_OLD	1
> +# define _STAT_VER_KERNEL	1
> +# define _STAT_VER_SVR4		2
> +# define _STAT_VER_LINUX	3
> +#else
> +# define _STAT_VER_KERNEL	0
> +# define _STAT_VER_LINUX	1
> +#endif
> +#define _STAT_VER		_STAT_VER_LINUX
> +
> diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
> b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist index
> 1a96103c68..f767bdde24 100644 ---
> a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist +++
> b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist @@ -2076,6 +2076,14
> @@ GLIBC_2.32 sigabbrev_np F GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 fstat F
> +GLIBC_2.33 fstat64 F
> +GLIBC_2.33 fstatat F
> +GLIBC_2.33 fstatat64 F
> +GLIBC_2.33 lstat F
> +GLIBC_2.33 lstat64 F
> +GLIBC_2.33 stat F
> +GLIBC_2.33 stat64 F
>  GLIBC_2.4 __confstr_chk F
>  GLIBC_2.4 __fgets_chk F
>  GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
> b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist index
> 35745a75b6..535862a51e 100644 ---
> a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist +++
> b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist @@ -2173,3 +2173,11
> @@ GLIBC_2.32 sigabbrev_np F GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 fstat F
> +GLIBC_2.33 fstat64 F
> +GLIBC_2.33 fstatat F
> +GLIBC_2.33 fstatat64 F
> +GLIBC_2.33 lstat F
> +GLIBC_2.33 lstat64 F
> +GLIBC_2.33 stat F
> +GLIBC_2.33 stat64 F
> diff --git a/sysdeps/unix/sysv/linux/xstatver.h
> b/sysdeps/unix/sysv/linux/xstatver.h new file mode 100644
> index 0000000000..59dba71dd1
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/xstatver.h
> @@ -0,0 +1,7 @@
> +/* Versions of the 'struct stat' data structure used in
> compatibility xstat
> +   functions.  */
> +#define _STAT_VER_LINUX_OLD	1
> +#define _STAT_VER_KERNEL	1
> +#define _STAT_VER_SVR4		2
> +#define _STAT_VER_LINUX		3
> +#define _STAT_VER		_STAT_VER_LINUX




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 10/16] Remove mknod wrapper functions, move them to symbols
  2020-07-23 19:46 ` [PATCH 10/16] Remove mknod wrapper functions, move them to symbols Adhemerval Zanella via Libc-alpha
  2020-07-23 20:53   ` Joseph Myers
@ 2020-07-24  9:25   ` Lukasz Majewski
  2020-10-12 22:27   ` Joseph Myers
  2 siblings, 0 replies; 80+ messages in thread
From: Lukasz Majewski @ 2020-07-24  9:25 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Alistair Francis, libc-alpha

[-- Attachment #1: Type: text/plain, Size: 40463 bytes --]

On Thu, 23 Jul 2020 16:46:35 -0300
Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> This patch removes the mknod and mknodat static wrapper and add the
> symbols on the libc with the expected names.
> 
> Both the prototypes of the internal symbol linked by the static
> wrappers and the inline redirectors are also removed from the
> installed sys/stat.h header file.  The wrapper implementation license
> is also change from LGPL to GPL.
> 
> Internally the _STAT_VER* definitions are moved to the arch-specific
> xstatver.h file.
> 
> Checked with a build for all affected Linux ABIs and Hurd.  I checked
> also on x86_64-linux-gnu and i686-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>

> ---
>  include/sys/stat.h                            | 13 ++++---
>  io/Makefile                                   |  5 ---
>  io/Versions                                   |  1 +
>  io/mknod.c                                    | 35
> +++---------------- io/mknodat.c                                  |
> 35 +++---------------- io/sys/stat.h
> | 30 ---------------- sysdeps/generic/xstatver.h                    |
>  1 + sysdeps/mach/hurd/i386/libc.abilist           |  2 ++
>  sysdeps/posix/mkfifo.c                        |  3 +-
>  sysdeps/posix/mkfifoat.c                      |  3 +-
>  sysdeps/unix/sysv/linux/aarch64/libc.abilist  |  2 ++
>  sysdeps/unix/sysv/linux/alpha/bits/stat.h     |  4 ---
>  sysdeps/unix/sysv/linux/alpha/libc.abilist    |  2 ++
>  sysdeps/unix/sysv/linux/alpha/xstatver.h      |  5 +++
>  sysdeps/unix/sysv/linux/arc/libc.abilist      |  2 ++
>  sysdeps/unix/sysv/linux/arm/le/libc.abilist   |  2 ++
>  sysdeps/unix/sysv/linux/bits/stat.h           |  7 ----
>  sysdeps/unix/sysv/linux/csky/libc.abilist     |  2 ++
>  sysdeps/unix/sysv/linux/generic/bits/stat.h   |  3 --
>  sysdeps/unix/sysv/linux/generic/xstatver.h    |  5 +++
>  sysdeps/unix/sysv/linux/hppa/libc.abilist     |  2 ++
>  sysdeps/unix/sysv/linux/i386/libc.abilist     |  2 ++
>  sysdeps/unix/sysv/linux/ia64/bits/stat.h      |  3 --
>  sysdeps/unix/sysv/linux/ia64/libc.abilist     |  2 ++
>  sysdeps/unix/sysv/linux/ia64/xstatver.h       |  5 +++
>  sysdeps/unix/sysv/linux/m68k/bits/stat.h      |  6 ----
>  .../unix/sysv/linux/m68k/m680x0/libc.abilist  |  2 ++
>  sysdeps/unix/sysv/linux/m68k/xstatver.h       |  6 ++++
>  .../sysv/linux/microblaze/be/libc.abilist     |  2 ++
>  .../unix/sysv/linux/microblaze/bits/stat.h    |  5 ---
>  sysdeps/unix/sysv/linux/microblaze/xstatver.h |  6 ++++
>  sysdeps/unix/sysv/linux/mips/bits/stat.h      |  5 ---
>  .../sysv/linux/mips/mips32/fpu/libc.abilist   |  2 ++
>  .../sysv/linux/mips/mips64/n32/libc.abilist   |  2 ++
>  .../sysv/linux/mips/mips64/n64/libc.abilist   |  2 ++
>  sysdeps/unix/sysv/linux/mips/xstatver.h       |  6 ++++
>  sysdeps/unix/sysv/linux/nios2/libc.abilist    |  2 ++
>  sysdeps/unix/sysv/linux/powerpc/bits/stat.h   |  5 ---
>  .../linux/powerpc/powerpc32/fpu/libc.abilist  |  2 ++
>  .../linux/powerpc/powerpc64/be/libc.abilist   |  2 ++
>  .../linux/powerpc/powerpc64/le/libc.abilist   |  2 ++
>  sysdeps/unix/sysv/linux/powerpc/xstatver.h    |  6 ++++
>  .../unix/sysv/linux/riscv/rv64/libc.abilist   |  2 ++
>  sysdeps/unix/sysv/linux/s390/bits/stat.h      | 10 ------
>  .../unix/sysv/linux/s390/s390-32/libc.abilist |  2 ++
>  .../unix/sysv/linux/s390/s390-64/libc.abilist |  2 ++
>  sysdeps/unix/sysv/linux/s390/xstatver.h       |  6 +++-
>  sysdeps/unix/sysv/linux/sh/le/libc.abilist    |  2 ++
>  sysdeps/unix/sysv/linux/sparc/bits/stat.h     |  6 ----
>  .../sysv/linux/sparc/sparc32/libc.abilist     |  2 ++
>  .../sysv/linux/sparc/sparc64/libc.abilist     |  2 ++
>  sysdeps/unix/sysv/linux/sparc/xstatver.h      |  6 ++++
>  sysdeps/unix/sysv/linux/x86/bits/stat.h       | 11 ------
>  sysdeps/unix/sysv/linux/x86/xstatver.h        |  5 ++-
>  .../unix/sysv/linux/x86_64/64/libc.abilist    |  2 ++
>  .../unix/sysv/linux/x86_64/x32/libc.abilist   |  2 ++
>  sysdeps/unix/sysv/linux/xstatver.h            |  6 ++++
>  57 files changed, 133 insertions(+), 172 deletions(-)
> 
> diff --git a/include/sys/stat.h b/include/sys/stat.h
> index 0be918a7a7..04b825df4a 100644
> --- a/include/sys/stat.h
> +++ b/include/sys/stat.h
> @@ -30,14 +30,17 @@ extern __mode_t __umask (__mode_t __mask);
>  extern int __mkdir (const char *__path, __mode_t __mode);
>  libc_hidden_proto (__mkdir)
>  
> +extern int __mknodat (int fd, const char *path, mode_t mode, dev_t
> dev); +libc_hidden_proto (__mknodat);
>  extern int __mknod (const char *__path,
>  		    __mode_t __mode, __dev_t __dev);
> +libc_hidden_proto (__mknod);
> +
> +extern int __xmknod (int __ver, const char *__path, __mode_t __mode,
> +		     __dev_t *__dev);
>  libc_hidden_proto (__xmknod)
> -extern __inline__ int __mknod (const char *__path, __mode_t __mode,
> -			       __dev_t __dev)
> -{
> -  return __xmknod (_MKNOD_VER, __path, __mode, &__dev);
> -}
> +extern int __xmknodat (int __ver, int __fd, const char *__path,
> +		       __mode_t __mode, __dev_t *__dev);
>  libc_hidden_proto (__xmknodat)
>  
>  int __fxstat (int __ver, int __fildes, struct stat *__stat_buf);
> diff --git a/io/Makefile b/io/Makefile
> index cee356b666..2ed86c530e 100644
> --- a/io/Makefile
> +++ b/io/Makefile
> @@ -57,11 +57,6 @@ routines :=
> 			\ sendfile sendfile64 copy_file_range
> 			\ utimensat futimens file_change_detection
>  
> -# These routines will be omitted from the libc shared object.
> -# Instead the static object files will be included in a special
> archive -# linked against when the shared library will be used.
> -static-only-routines = mknod mknodat
> -
>  others		:= pwd
>  test-srcs	:= ftwtest
>  tests		:= test-utime test-stat test-stat2 test-lfs
> tst-getcwd \ diff --git a/io/Versions b/io/Versions
> index f6db0e84ad..49c4d2d40a 100644
> --- a/io/Versions
> +++ b/io/Versions
> @@ -134,6 +134,7 @@ libc {
>    }
>    GLIBC_2.33 {
>      stat; stat64; fstat; fstat64; lstat; lstat64; fstatat; fstatat64;
> +    mknod; mknodat;
>    }
>    GLIBC_PRIVATE {
>      __libc_fcntl64;
> diff --git a/io/mknod.c b/io/mknod.c
> index ac96829230..7f88633198 100644
> --- a/io/mknod.c
> +++ b/io/mknod.c
> @@ -1,4 +1,5 @@
> -/* Copyright (C) 1995-2020 Free Software Foundation, Inc.
> +/* Create a special or ordinary file.
> +   Copyright (C) 1995-2020 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
> @@ -6,23 +7,6 @@
>     License as published by the Free Software Foundation; either
>     version 2.1 of the License, or (at your option) any later version.
>  
> -   In addition to the permissions in the GNU Lesser General Public
> -   License, the Free Software Foundation gives you unlimited
> -   permission to link the compiled version of this file with other
> -   programs, and to distribute those programs without any restriction
> -   coming from the use of this file. (The GNU Lesser General Public
> -   License restrictions do apply in other respects; for example, they
> -   cover modification of the file, and distribution when not linked
> -   into another program.)
> -
> -   Note that people who make modified versions of this file are not
> -   obligated to grant this special exception for their modified
> -   versions; it is their choice whether to do so. The GNU Lesser
> -   General Public License gives permission to release a modified
> -   version without this exception; this exception also makes it
> -   possible to release a modified version which carries forward this
> -   exception.
> -
>     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
> @@ -32,24 +16,13 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -
>  #include <sys/types.h>
>  #include <sys/stat.h>
>  
> -/* This definition is only used if inlining fails for this function;
> see
> -   the last page of <sys/stat.h>.  The real work is done by the `x'
> -   function which is passed a version number argument.  We arrange
> in the
> -   makefile that when not inlined this function is always statically
> -   linked; that way a dynamically-linked executable always encodes
> the
> -   version number corresponding to the data structures it uses, so
> the `x'
> -   functions in the shared library can adapt without needing to
> recompile
> -   all callers.  */
> -
>  int
> -attribute_hidden
>  __mknod (const char *path, mode_t mode, dev_t dev)
>  {
>    return __xmknod (_MKNOD_VER, path, mode, &dev);
>  }
> -
> -weak_hidden_alias (__mknod, mknod)
> +libc_hidden_def (__mknod)
> +weak_alias (__mknod, mknod)
> diff --git a/io/mknodat.c b/io/mknodat.c
> index 65c9f1aa9c..6ec1c1648c 100644
> --- a/io/mknodat.c
> +++ b/io/mknodat.c
> @@ -1,4 +1,5 @@
> -/* Copyright (C) 1995-2020 Free Software Foundation, Inc.
> +/* Create a special or ordinary file.
> +   Copyright (C) 1995-2020 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
> @@ -6,23 +7,6 @@
>     License as published by the Free Software Foundation; either
>     version 2.1 of the License, or (at your option) any later version.
>  
> -   In addition to the permissions in the GNU Lesser General Public
> -   License, the Free Software Foundation gives you unlimited
> -   permission to link the compiled version of this file with other
> -   programs, and to distribute those programs without any restriction
> -   coming from the use of this file. (The GNU Lesser General Public
> -   License restrictions do apply in other respects; for example, they
> -   cover modification of the file, and distribution when not linked
> -   into another program.)
> -
> -   Note that people who make modified versions of this file are not
> -   obligated to grant this special exception for their modified
> -   versions; it is their choice whether to do so. The GNU Lesser
> -   General Public License gives permission to release a modified
> -   version without this exception; this exception also makes it
> -   possible to release a modified version which carries forward this
> -   exception.
> -
>     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
> @@ -32,22 +16,13 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -
>  #include <sys/types.h>
>  #include <sys/stat.h>
>  
> -/* This definition is only used if inlining fails for this function;
> see
> -   the last page of <sys/stat.h>.  The real work is done by the `x'
> -   function which is passed a version number argument.  We arrange
> in the
> -   makefile that when not inlined this function is always statically
> -   linked; that way a dynamically-linked executable always encodes
> the
> -   version number corresponding to the data structures it uses, so
> the `x'
> -   functions in the shared library can adapt without needing to
> recompile
> -   all callers.  */
> -
>  int
> -attribute_hidden
> -mknodat (int fd, const char *path, mode_t mode, dev_t dev)
> +__mknodat (int fd, const char *path, mode_t mode, dev_t dev)
>  {
>    return __xmknodat (_MKNOD_VER, fd, path, mode, &dev);
>  }
> +libc_hidden_def (__mknodat)
> +weak_alias (__mknodat, mknodat)
> diff --git a/io/sys/stat.h b/io/sys/stat.h
> index 83cf253c72..58c3770622 100644
> --- a/io/sys/stat.h
> +++ b/io/sys/stat.h
> @@ -367,41 +367,11 @@ extern int utimensat (int __fd, const char
> *__path, /* Set file access and modification times of the file
> associated with FD.  */ extern int futimens (int __fd, const struct
> timespec __times[2]) __THROW; #endif
> -\f
> -#ifndef _MKNOD_VER
> -# define _MKNOD_VER	0
> -#endif
> -
> -extern int __xmknod (int __ver, const char *__path, __mode_t __mode,
> -		     __dev_t *__dev) __THROW __nonnull ((2, 4));
> -
> -extern int __xmknodat (int __ver, int __fd, const char *__path,
> -		       __mode_t __mode, __dev_t *__dev)
> -     __THROW __nonnull ((3, 5));
>  
>  #ifdef __USE_GNU
>  # include <bits/statx.h>
>  #endif
>  
> -#ifdef __USE_EXTERN_INLINES
> -# ifdef __USE_MISC
> -__extern_inline int
> -__NTH (mknod (const char *__path, __mode_t __mode, __dev_t __dev))
> -{
> -  return __xmknod (_MKNOD_VER, __path, __mode, &__dev);
> -}
> -# endif
> -
> -# ifdef __USE_ATFILE
> -__extern_inline int
> -__NTH (mknodat (int __fd, const char *__path, __mode_t __mode,
> -		__dev_t __dev))
> -{
> -  return __xmknodat (_MKNOD_VER, __fd, __path, __mode, &__dev);
> -}
> -# endif
> -#endif
> -
>  __END_DECLS
>  
>  
> diff --git a/sysdeps/generic/xstatver.h b/sysdeps/generic/xstatver.h
> index d727c98a16..281013b2f1 100644
> --- a/sysdeps/generic/xstatver.h
> +++ b/sysdeps/generic/xstatver.h
> @@ -1,3 +1,4 @@
>  /* Versions of the 'struct stat' data structure used in
> compatibility xstat functions.  */
>  #define _STAT_VER 0
> +#define _MKNOD_VER 0
> diff --git a/sysdeps/mach/hurd/i386/libc.abilist
> b/sysdeps/mach/hurd/i386/libc.abilist index 74a4ed5c1d..b4e39285d0
> 100644 --- a/sysdeps/mach/hurd/i386/libc.abilist
> +++ b/sysdeps/mach/hurd/i386/libc.abilist
> @@ -2198,6 +2198,8 @@ GLIBC_2.33 fstatat F
>  GLIBC_2.33 fstatat64 F
>  GLIBC_2.33 lstat F
>  GLIBC_2.33 lstat64 F
> +GLIBC_2.33 mknod F
> +GLIBC_2.33 mknodat F
>  GLIBC_2.33 stat F
>  GLIBC_2.33 stat64 F
>  GLIBC_2.4 __confstr_chk F
> diff --git a/sysdeps/posix/mkfifo.c b/sysdeps/posix/mkfifo.c
> index 61f62e2e96..0b89f6c291 100644
> --- a/sysdeps/posix/mkfifo.c
> +++ b/sysdeps/posix/mkfifo.c
> @@ -24,6 +24,5 @@
>  int
>  mkfifo (const char *path, mode_t mode)
>  {
> -  dev_t dev = 0;
> -  return __xmknod (_MKNOD_VER, path, mode | S_IFIFO, &dev);
> +  return __mknod (path, mode | S_IFIFO, 0);
>  }
> diff --git a/sysdeps/posix/mkfifoat.c b/sysdeps/posix/mkfifoat.c
> index 5287fe8782..d1e0977ba1 100644
> --- a/sysdeps/posix/mkfifoat.c
> +++ b/sysdeps/posix/mkfifoat.c
> @@ -23,6 +23,5 @@
>  int
>  mkfifoat (int fd, const char *file, mode_t mode)
>  {
> -  dev_t dev = 0;
> -  return __xmknodat (_MKNOD_VER, fd, file, mode | S_IFIFO, &dev);
> +  return __mknodat (fd, file, mode | S_IFIFO, 0);
>  }
> diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist
> b/sysdeps/unix/sysv/linux/aarch64/libc.abilist index
> 03e4ae9296..54b707b9cc 100644 ---
> a/sysdeps/unix/sysv/linux/aarch64/libc.abilist +++
> b/sysdeps/unix/sysv/linux/aarch64/libc.abilist @@ -2166,5 +2166,7 @@
> GLIBC_2.33 fstatat F GLIBC_2.33 fstatat64 F
>  GLIBC_2.33 lstat F
>  GLIBC_2.33 lstat64 F
> +GLIBC_2.33 mknod F
> +GLIBC_2.33 mknodat F
>  GLIBC_2.33 stat F
>  GLIBC_2.33 stat64 F
> diff --git a/sysdeps/unix/sysv/linux/alpha/bits/stat.h
> b/sysdeps/unix/sysv/linux/alpha/bits/stat.h index
> 1fc27936b9..d20fb5a4b0 100644 ---
> a/sysdeps/unix/sysv/linux/alpha/bits/stat.h +++
> b/sysdeps/unix/sysv/linux/alpha/bits/stat.h @@ -22,10 +22,6 @@
>  #ifndef _BITS_STAT_H
>  #define _BITS_STAT_H	1
>  
> -/* Versions of the `xmknod' interface.  */
> -#define _MKNOD_VER_LINUX	0
> -
> -
>  /* Nanosecond resolution timestamps are stored in a format
> equivalent to 'struct timespec'.  This is the type used whenever
> possible but the Unix namespace rules do not allow the identifier
> 'timespec' to appear diff --git
> a/sysdeps/unix/sysv/linux/alpha/libc.abilist
> b/sysdeps/unix/sysv/linux/alpha/libc.abilist index
> 5b752ef4a8..9b429fd28f 100644 ---
> a/sysdeps/unix/sysv/linux/alpha/libc.abilist +++
> b/sysdeps/unix/sysv/linux/alpha/libc.abilist @@ -2248,6 +2248,8 @@
> GLIBC_2.33 fstatat F GLIBC_2.33 fstatat64 F GLIBC_2.33 lstat F
>  GLIBC_2.33 lstat64 F
> +GLIBC_2.33 mknod F
> +GLIBC_2.33 mknodat F
>  GLIBC_2.33 stat F
>  GLIBC_2.33 stat64 F
>  GLIBC_2.4 _IO_fprintf F
> diff --git a/sysdeps/unix/sysv/linux/alpha/xstatver.h
> b/sysdeps/unix/sysv/linux/alpha/xstatver.h index
> bbb9469617..1cb5d26bb1 100644 ---
> a/sysdeps/unix/sysv/linux/alpha/xstatver.h +++
> b/sysdeps/unix/sysv/linux/alpha/xstatver.h @@ -7,3 +7,8 @@
>  #define _STAT_VER_GLIBC2_3_4	3
>  #define _STAT_VER_LINUX		3
>  #define _STAT_VER		_STAT_VER_LINUX
> +
> +/* Versions of the 'xmknod' interface used in compatibility xmknod
> +   functions.  */
> +#define _MKNOD_VER_LINUX	0
> +#define _MKNOD_VER		_MKNOD_VER_LINUX
> diff --git a/sysdeps/unix/sysv/linux/arc/libc.abilist
> b/sysdeps/unix/sysv/linux/arc/libc.abilist index
> 925b532383..7ed5340364 100644 ---
> a/sysdeps/unix/sysv/linux/arc/libc.abilist +++
> b/sysdeps/unix/sysv/linux/arc/libc.abilist @@ -1926,5 +1926,7 @@
> GLIBC_2.33 fstatat F GLIBC_2.33 fstatat64 F
>  GLIBC_2.33 lstat F
>  GLIBC_2.33 lstat64 F
> +GLIBC_2.33 mknod F
> +GLIBC_2.33 mknodat F
>  GLIBC_2.33 stat F
>  GLIBC_2.33 stat64 F
> diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist
> b/sysdeps/unix/sysv/linux/arm/le/libc.abilist index
> a4c1a7c03c..3ec1cbdfbc 100644 ---
> a/sysdeps/unix/sysv/linux/arm/le/libc.abilist +++
> b/sysdeps/unix/sysv/linux/arm/le/libc.abilist @@ -147,6 +147,8 @@
> GLIBC_2.33 fstatat F GLIBC_2.33 fstatat64 F
>  GLIBC_2.33 lstat F
>  GLIBC_2.33 lstat64 F
> +GLIBC_2.33 mknod F
> +GLIBC_2.33 mknodat F
>  GLIBC_2.33 stat F
>  GLIBC_2.33 stat64 F
>  GLIBC_2.4 _Exit F
> diff --git a/sysdeps/unix/sysv/linux/bits/stat.h
> b/sysdeps/unix/sysv/linux/bits/stat.h index b542623208..0669451f69
> 100644 --- a/sysdeps/unix/sysv/linux/bits/stat.h
> +++ b/sysdeps/unix/sysv/linux/bits/stat.h
> @@ -22,13 +22,6 @@
>  #ifndef _BITS_STAT_H
>  #define _BITS_STAT_H	1
>  
> -/* Versions of the `struct stat' data structure.  */
> -/* Versions of the `xmknod' interface.  */
> -#define _MKNOD_VER_LINUX	1
> -#define _MKNOD_VER_SVR4		2
> -#define _MKNOD_VER		_MKNOD_VER_LINUX /* The bits
> defined below.  */ -
> -
>  struct stat
>    {
>      __dev_t st_dev;			/* Device.  */
> diff --git a/sysdeps/unix/sysv/linux/csky/libc.abilist
> b/sysdeps/unix/sysv/linux/csky/libc.abilist index
> 799873e189..301fd728d7 100644 ---
> a/sysdeps/unix/sysv/linux/csky/libc.abilist +++
> b/sysdeps/unix/sysv/linux/csky/libc.abilist @@ -2110,5 +2110,7 @@
> GLIBC_2.33 fstatat F GLIBC_2.33 fstatat64 F
>  GLIBC_2.33 lstat F
>  GLIBC_2.33 lstat64 F
> +GLIBC_2.33 mknod F
> +GLIBC_2.33 mknodat F
>  GLIBC_2.33 stat F
>  GLIBC_2.33 stat64 F
> diff --git a/sysdeps/unix/sysv/linux/generic/bits/stat.h
> b/sysdeps/unix/sysv/linux/generic/bits/stat.h index
> 35e14a47c6..1b586d72fa 100644 ---
> a/sysdeps/unix/sysv/linux/generic/bits/stat.h +++
> b/sysdeps/unix/sysv/linux/generic/bits/stat.h @@ -26,9 +26,6 @@
>  #include <bits/endian.h>
>  #include <bits/wordsize.h>
>  
> -/* Versions of the `xmknod' interface.  */
> -#define _MKNOD_VER_LINUX	0
> -
>  #if defined __USE_FILE_OFFSET64
>  # define __field64(type, type64, name) type64 name
>  #elif __WORDSIZE == 64 || defined __INO_T_MATCHES_INO64_T
> diff --git a/sysdeps/unix/sysv/linux/generic/xstatver.h
> b/sysdeps/unix/sysv/linux/generic/xstatver.h index
> 8675db494c..d8fd35beb6 100644 ---
> a/sysdeps/unix/sysv/linux/generic/xstatver.h +++
> b/sysdeps/unix/sysv/linux/generic/xstatver.h @@ -3,3 +3,8 @@
>  #define _STAT_VER_KERNEL	0
>  #define _STAT_VER_LINUX		0
>  #define _STAT_VER		_STAT_VER_KERNEL
> +
> +/* Versions of the 'xmknod' interface used in compatibility xmknod
> +   functions.  */
> +#define _MKNOD_VER_LINUX	0
> +#define _MKNOD_VER		_MKNOD_VER_LINUX
> diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist
> b/sysdeps/unix/sysv/linux/hppa/libc.abilist index
> 95c7bf4f06..84834052e1 100644 ---
> a/sysdeps/unix/sysv/linux/hppa/libc.abilist +++
> b/sysdeps/unix/sysv/linux/hppa/libc.abilist @@ -2069,6 +2069,8 @@
> GLIBC_2.33 fstatat F GLIBC_2.33 fstatat64 F
>  GLIBC_2.33 lstat F
>  GLIBC_2.33 lstat64 F
> +GLIBC_2.33 mknod F
> +GLIBC_2.33 mknodat F
>  GLIBC_2.33 stat F
>  GLIBC_2.33 stat64 F
>  GLIBC_2.4 __confstr_chk F
> diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist
> b/sysdeps/unix/sysv/linux/i386/libc.abilist index
> e7cf5cdb98..b82debaba4 100644 ---
> a/sysdeps/unix/sysv/linux/i386/libc.abilist +++
> b/sysdeps/unix/sysv/linux/i386/libc.abilist @@ -2235,6 +2235,8 @@
> GLIBC_2.33 fstatat F GLIBC_2.33 fstatat64 F
>  GLIBC_2.33 lstat F
>  GLIBC_2.33 lstat64 F
> +GLIBC_2.33 mknod F
> +GLIBC_2.33 mknodat F
>  GLIBC_2.33 stat F
>  GLIBC_2.33 stat64 F
>  GLIBC_2.4 __confstr_chk F
> diff --git a/sysdeps/unix/sysv/linux/ia64/bits/stat.h
> b/sysdeps/unix/sysv/linux/ia64/bits/stat.h index
> 8ec2e4c81f..6937f3227a 100644 ---
> a/sysdeps/unix/sysv/linux/ia64/bits/stat.h +++
> b/sysdeps/unix/sysv/linux/ia64/bits/stat.h @@ -22,9 +22,6 @@
>  #ifndef _BITS_STAT_H
>  #define _BITS_STAT_H	1
>  
> -/* Versions of the `xmknod' interface.  */
> -#define _MKNOD_VER_LINUX	0
> -
>  struct stat
>    {
>      __dev_t st_dev;		/* Device.  */
> diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist
> b/sysdeps/unix/sysv/linux/ia64/libc.abilist index
> beeb905efd..475b7af1a5 100644 ---
> a/sysdeps/unix/sysv/linux/ia64/libc.abilist +++
> b/sysdeps/unix/sysv/linux/ia64/libc.abilist @@ -2101,6 +2101,8 @@
> GLIBC_2.33 fstatat F GLIBC_2.33 fstatat64 F
>  GLIBC_2.33 lstat F
>  GLIBC_2.33 lstat64 F
> +GLIBC_2.33 mknod F
> +GLIBC_2.33 mknodat F
>  GLIBC_2.33 stat F
>  GLIBC_2.33 stat64 F
>  GLIBC_2.4 __confstr_chk F
> diff --git a/sysdeps/unix/sysv/linux/ia64/xstatver.h
> b/sysdeps/unix/sysv/linux/ia64/xstatver.h index
> 4f02f697ad..f24ab4a9ee 100644 ---
> a/sysdeps/unix/sysv/linux/ia64/xstatver.h +++
> b/sysdeps/unix/sysv/linux/ia64/xstatver.h @@ -3,3 +3,8 @@
>  #define _STAT_VER_KERNEL	0
>  #define _STAT_VER_LINUX		1
>  #define _STAT_VER		_STAT_VER_LINUX
> +
> +/* Versions of the 'xmknod' interface used in compatibility xmknod
> +   functions.  */
> +#define _MKNOD_VER_LINUX	0
> +#define _MKNOD_VER		_MKNOD_VER_LINUX
> diff --git a/sysdeps/unix/sysv/linux/m68k/bits/stat.h
> b/sysdeps/unix/sysv/linux/m68k/bits/stat.h index
> bf41776e6c..c6f761fcc0 100644 ---
> a/sysdeps/unix/sysv/linux/m68k/bits/stat.h +++
> b/sysdeps/unix/sysv/linux/m68k/bits/stat.h @@ -22,12 +22,6 @@
>  #ifndef _BITS_STAT_H
>  #define _BITS_STAT_H	1
>  
> -/* Versions of the `xmknod' interface.  */
> -#define _MKNOD_VER_LINUX	1
> -#define _MKNOD_VER_SVR4		2
> -#define _MKNOD_VER		_MKNOD_VER_LINUX /* The bits
> defined below.  */ -
> -
>  struct stat
>    {
>      __dev_t st_dev;			/* Device.  */
> diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
> b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist index
> ed34e1fc82..29127e1341 100644 ---
> a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist +++
> b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist @@ -2181,6 +2181,8
> @@ GLIBC_2.33 fstatat F GLIBC_2.33 fstatat64 F
>  GLIBC_2.33 lstat F
>  GLIBC_2.33 lstat64 F
> +GLIBC_2.33 mknod F
> +GLIBC_2.33 mknodat F
>  GLIBC_2.33 stat F
>  GLIBC_2.33 stat64 F
>  GLIBC_2.4 __confstr_chk F
> diff --git a/sysdeps/unix/sysv/linux/m68k/xstatver.h
> b/sysdeps/unix/sysv/linux/m68k/xstatver.h index
> 59dba71dd1..8e1801b603 100644 ---
> a/sysdeps/unix/sysv/linux/m68k/xstatver.h +++
> b/sysdeps/unix/sysv/linux/m68k/xstatver.h @@ -5,3 +5,9 @@
>  #define _STAT_VER_SVR4		2
>  #define _STAT_VER_LINUX		3
>  #define _STAT_VER		_STAT_VER_LINUX
> +
> +/* Versions of the 'xmknod' interface used in compatibility xmknod
> +   functions.  */
> +#define _MKNOD_VER_LINUX	1
> +#define _MKNOD_VER_SVR4		2
> +#define _MKNOD_VER		_MKNOD_VER_LINUX
> diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
> b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist index
> e00f5115b2..e5b4cecacd 100644 ---
> a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist +++
> b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist @@ -2161,5
> +2161,7 @@ GLIBC_2.33 fstatat F GLIBC_2.33 fstatat64 F
>  GLIBC_2.33 lstat F
>  GLIBC_2.33 lstat64 F
> +GLIBC_2.33 mknod F
> +GLIBC_2.33 mknodat F
>  GLIBC_2.33 stat F
>  GLIBC_2.33 stat64 F
> diff --git a/sysdeps/unix/sysv/linux/microblaze/bits/stat.h
> b/sysdeps/unix/sysv/linux/microblaze/bits/stat.h index
> 51316a8c1b..b3068e5c98 100644 ---
> a/sysdeps/unix/sysv/linux/microblaze/bits/stat.h +++
> b/sysdeps/unix/sysv/linux/microblaze/bits/stat.h @@ -23,11 +23,6 @@
>  #ifndef _BITS_STAT_H
>  #define _BITS_STAT_H	1
>  
> -/* Versions of the `xmknod' interface.  */
> -#define _MKNOD_VER_LINUX       1
> -#define _MKNOD_VER_SVR4        2
> -#define _MKNOD_VER             _MKNOD_VER_LINUX  /* The bits defined
> below.  */ -
>  #ifndef __USE_FILE_OFFSET64
>  struct stat
>  {
> diff --git a/sysdeps/unix/sysv/linux/microblaze/xstatver.h
> b/sysdeps/unix/sysv/linux/microblaze/xstatver.h index
> bddaa0d5ec..790cc834d2 100644 ---
> a/sysdeps/unix/sysv/linux/microblaze/xstatver.h +++
> b/sysdeps/unix/sysv/linux/microblaze/xstatver.h @@ -5,3 +5,9 @@
>  #define _STAT_VER_SVR4         2
>  #define _STAT_VER_LINUX        3
>  #define _STAT_VER              _STAT_VER_LINUX  /* The one defined
> below.  */ +
> +/* Versions of the 'xmknod' interface used in compatibility xmknod
> +   functions.  */
> +#define _MKNOD_VER_LINUX       1
> +#define _MKNOD_VER_SVR4        2
> +#define _MKNOD_VER             _MKNOD_VER_LINUX
> diff --git a/sysdeps/unix/sysv/linux/mips/bits/stat.h
> b/sysdeps/unix/sysv/linux/mips/bits/stat.h index
> cfeb4ce6a4..f229c58013 100644 ---
> a/sysdeps/unix/sysv/linux/mips/bits/stat.h +++
> b/sysdeps/unix/sysv/linux/mips/bits/stat.h @@ -24,11 +24,6 @@
>  
>  #include <sgidefs.h>
>  
> -/* Versions of the `xmknod' interface.  */
> -#define _MKNOD_VER_LINUX	1
> -#define _MKNOD_VER_SVR4		2
> -#define _MKNOD_VER		_MKNOD_VER_LINUX /* The bits
> defined below.  */ -
>  
>  #if _MIPS_SIM == _ABIO32
>  /* Structure describing file characteristics.  */
> diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
> b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist index
> fe9ba4e982..b9f56007a2 100644 ---
> a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist +++
> b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist @@ -2152,6
> +2152,8 @@ GLIBC_2.33 fstatat F GLIBC_2.33 fstatat64 F
>  GLIBC_2.33 lstat F
>  GLIBC_2.33 lstat64 F
> +GLIBC_2.33 mknod F
> +GLIBC_2.33 mknodat F
>  GLIBC_2.33 stat F
>  GLIBC_2.33 stat64 F
>  GLIBC_2.4 __confstr_chk F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
> b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist index
> e67591e710..c161ef11b5 100644 ---
> a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist +++
> b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist @@ -2158,6
> +2158,8 @@ GLIBC_2.33 fstatat F GLIBC_2.33 fstatat64 F
>  GLIBC_2.33 lstat F
>  GLIBC_2.33 lstat64 F
> +GLIBC_2.33 mknod F
> +GLIBC_2.33 mknodat F
>  GLIBC_2.33 stat F
>  GLIBC_2.33 stat64 F
>  GLIBC_2.4 __confstr_chk F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
> b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist index
> e4eb9e6bbf..d4b1528e7a 100644 ---
> a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist +++
> b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist @@ -2152,6
> +2152,8 @@ GLIBC_2.33 fstatat F GLIBC_2.33 fstatat64 F
>  GLIBC_2.33 lstat F
>  GLIBC_2.33 lstat64 F
> +GLIBC_2.33 mknod F
> +GLIBC_2.33 mknodat F
>  GLIBC_2.33 stat F
>  GLIBC_2.33 stat64 F
>  GLIBC_2.4 __confstr_chk F
> diff --git a/sysdeps/unix/sysv/linux/mips/xstatver.h
> b/sysdeps/unix/sysv/linux/mips/xstatver.h index
> 59dba71dd1..8e1801b603 100644 ---
> a/sysdeps/unix/sysv/linux/mips/xstatver.h +++
> b/sysdeps/unix/sysv/linux/mips/xstatver.h @@ -5,3 +5,9 @@
>  #define _STAT_VER_SVR4		2
>  #define _STAT_VER_LINUX		3
>  #define _STAT_VER		_STAT_VER_LINUX
> +
> +/* Versions of the 'xmknod' interface used in compatibility xmknod
> +   functions.  */
> +#define _MKNOD_VER_LINUX	1
> +#define _MKNOD_VER_SVR4		2
> +#define _MKNOD_VER		_MKNOD_VER_LINUX
> diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist
> b/sysdeps/unix/sysv/linux/nios2/libc.abilist index
> 0878998441..68fca4e650 100644 ---
> a/sysdeps/unix/sysv/linux/nios2/libc.abilist +++
> b/sysdeps/unix/sysv/linux/nios2/libc.abilist @@ -2199,5 +2199,7 @@
> GLIBC_2.33 fstatat F GLIBC_2.33 fstatat64 F
>  GLIBC_2.33 lstat F
>  GLIBC_2.33 lstat64 F
> +GLIBC_2.33 mknod F
> +GLIBC_2.33 mknodat F
>  GLIBC_2.33 stat F
>  GLIBC_2.33 stat64 F
> diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/stat.h
> b/sysdeps/unix/sysv/linux/powerpc/bits/stat.h index
> 40ea9a96d4..80c9dc23ac 100644 ---
> a/sysdeps/unix/sysv/linux/powerpc/bits/stat.h +++
> b/sysdeps/unix/sysv/linux/powerpc/bits/stat.h @@ -24,11 +24,6 @@
>  
>  #include <bits/wordsize.h>
>  
> -/* Versions of the `xmknod' interface.  */
> -#define _MKNOD_VER_LINUX	1
> -#define _MKNOD_VER_SVR4		2
> -#define _MKNOD_VER		_MKNOD_VER_LINUX /* The bits
> defined below.  */ -
>  
>  #if __WORDSIZE == 32
>  
> diff --git
> a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
> b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist index
> 993c957e8e..bec34b2128 100644 ---
> a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist +++
> b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist @@
> -2208,6 +2208,8 @@ GLIBC_2.33 fstatat F GLIBC_2.33 fstatat64 F
> GLIBC_2.33 lstat F GLIBC_2.33 lstat64 F
> +GLIBC_2.33 mknod F
> +GLIBC_2.33 mknodat F
>  GLIBC_2.33 stat F
>  GLIBC_2.33 stat64 F
>  GLIBC_2.4 _IO_fprintf F
> diff --git
> a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
> b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist index
> 25a8e828e9..35bd161c79 100644 ---
> a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist +++
> b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist @@
> -2071,6 +2071,8 @@ GLIBC_2.33 fstatat F GLIBC_2.33 fstatat64 F
> GLIBC_2.33 lstat F GLIBC_2.33 lstat64 F
> +GLIBC_2.33 mknod F
> +GLIBC_2.33 mknodat F
>  GLIBC_2.33 stat F
>  GLIBC_2.33 stat64 F
>  GLIBC_2.4 _IO_fprintf F
> diff --git
> a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
> b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist index
> 46ae28e552..f1c8ad9cc5 100644 ---
> a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist +++
> b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist @@
> -2361,5 +2361,7 @@ GLIBC_2.33 fstatat F GLIBC_2.33 fstatat64 F
> GLIBC_2.33 lstat F GLIBC_2.33 lstat64 F
> +GLIBC_2.33 mknod F
> +GLIBC_2.33 mknodat F
>  GLIBC_2.33 stat F
>  GLIBC_2.33 stat64 F
> diff --git a/sysdeps/unix/sysv/linux/powerpc/xstatver.h
> b/sysdeps/unix/sysv/linux/powerpc/xstatver.h index
> 1656e2f7e4..aa61dfd678 100644 ---
> a/sysdeps/unix/sysv/linux/powerpc/xstatver.h +++
> b/sysdeps/unix/sysv/linux/powerpc/xstatver.h @@ -9,3 +9,9 @@
>  #else
>  # define _STAT_VER		_STAT_VER_KERNEL
>  #endif
> +
> +/* Versions of the 'xmknod' interface used in compatibility xmknod
> +   functions.  */
> +#define _MKNOD_VER_LINUX	1
> +#define _MKNOD_VER_SVR4		2
> +#define _MKNOD_VER		_MKNOD_VER_LINUX
> diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
> b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist index
> 1044aa6be2..fdfc373871 100644 ---
> a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist +++
> b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist @@ -2128,5 +2128,7
> @@ GLIBC_2.33 fstatat F GLIBC_2.33 fstatat64 F
>  GLIBC_2.33 lstat F
>  GLIBC_2.33 lstat64 F
> +GLIBC_2.33 mknod F
> +GLIBC_2.33 mknodat F
>  GLIBC_2.33 stat F
>  GLIBC_2.33 stat64 F
> diff --git a/sysdeps/unix/sysv/linux/s390/bits/stat.h
> b/sysdeps/unix/sysv/linux/s390/bits/stat.h index
> d12055529a..75fa871a1d 100644 ---
> a/sysdeps/unix/sysv/linux/s390/bits/stat.h +++
> b/sysdeps/unix/sysv/linux/s390/bits/stat.h @@ -24,16 +24,6 @@
>  
>  #include <bits/wordsize.h>
>  
> -#if __WORDSIZE == 64
> -/* Versions of the `xmknod' interface.	*/
> -#define _MKNOD_VER_LINUX	0
> -#else
> -/* Versions of the `xmknod' interface.  */
> -# define _MKNOD_VER_LINUX	1
> -# define _MKNOD_VER_SVR4	2
> -# define _MKNOD_VER		_MKNOD_VER_LINUX
> -#endif
> -
>  #if __WORDSIZE == 64
>  struct stat
>    {
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
> b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist index
> 6b1fa7e67f..47591dc5b5 100644 ---
> a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist +++
> b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist @@ -2206,6
> +2206,8 @@ GLIBC_2.33 fstatat F GLIBC_2.33 fstatat64 F
>  GLIBC_2.33 lstat F
>  GLIBC_2.33 lstat64 F
> +GLIBC_2.33 mknod F
> +GLIBC_2.33 mknodat F
>  GLIBC_2.33 stat F
>  GLIBC_2.33 stat64 F
>  GLIBC_2.4 _IO_fprintf F
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
> b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist index
> 0aec094e7b..bd96aeaff7 100644 ---
> a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist +++
> b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist @@ -2107,6
> +2107,8 @@ GLIBC_2.33 fstatat F GLIBC_2.33 fstatat64 F
>  GLIBC_2.33 lstat F
>  GLIBC_2.33 lstat64 F
> +GLIBC_2.33 mknod F
> +GLIBC_2.33 mknodat F
>  GLIBC_2.33 stat F
>  GLIBC_2.33 stat64 F
>  GLIBC_2.4 _IO_fprintf F
> diff --git a/sysdeps/unix/sysv/linux/s390/xstatver.h
> b/sysdeps/unix/sysv/linux/s390/xstatver.h index
> 5ad0db2797..aeaf852ee5 100644 ---
> a/sysdeps/unix/sysv/linux/s390/xstatver.h +++
> b/sysdeps/unix/sysv/linux/s390/xstatver.h @@ -7,10 +7,14 @@
>  # define _STAT_VER_KERNEL	0
>  # define _STAT_VER_LINUX	1
>  # define _STAT_VER		_STAT_VER_LINUX
> +# define _MKNOD_VER_LINUX	0
>  #else
>  # define _STAT_VER_LINUX_OLD	1
>  # define _STAT_VER_KERNEL	1
>  # define _STAT_VER_SVR4		2
>  # define _STAT_VER_LINUX	3
> -# define _STAT_VER		_STAT_VER_LINUX
> +# define _MKNOD_VER_LINUX	1
> +# define _MKNOD_VER_SVR4	2
>  #endif
> +#define _STAT_VER		_STAT_VER_LINUX
> +#define _MKNOD_VER		_MKNOD_VER_LINUX
> diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist
> b/sysdeps/unix/sysv/linux/sh/le/libc.abilist index
> e2ae13d4fa..b4cebb11dd 100644 ---
> a/sysdeps/unix/sysv/linux/sh/le/libc.abilist +++
> b/sysdeps/unix/sysv/linux/sh/le/libc.abilist @@ -2073,6 +2073,8 @@
> GLIBC_2.33 fstatat F GLIBC_2.33 fstatat64 F
>  GLIBC_2.33 lstat F
>  GLIBC_2.33 lstat64 F
> +GLIBC_2.33 mknod F
> +GLIBC_2.33 mknodat F
>  GLIBC_2.33 stat F
>  GLIBC_2.33 stat64 F
>  GLIBC_2.4 __confstr_chk F
> diff --git a/sysdeps/unix/sysv/linux/sparc/bits/stat.h
> b/sysdeps/unix/sysv/linux/sparc/bits/stat.h index
> 7af17b5c40..d10ebb1a9a 100644 ---
> a/sysdeps/unix/sysv/linux/sparc/bits/stat.h +++
> b/sysdeps/unix/sysv/linux/sparc/bits/stat.h @@ -22,12 +22,6 @@
>  #ifndef _BITS_STAT_H
>  #define _BITS_STAT_H	1
>  
> -/* Versions of the `xmknod' interface.  */
> -#define _MKNOD_VER_LINUX	1
> -#define _MKNOD_VER_SVR4		2
> -#define _MKNOD_VER		_MKNOD_VER_LINUX /* The bits
> defined below.  */ -
> -
>  struct stat
>    {
>      __dev_t st_dev;			/* Device.  */
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
> b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist index
> 886e01960f..f208405859 100644 ---
> a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist +++
> b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist @@ -2197,6
> +2197,8 @@ GLIBC_2.33 fstatat F GLIBC_2.33 fstatat64 F
>  GLIBC_2.33 lstat F
>  GLIBC_2.33 lstat64 F
> +GLIBC_2.33 mknod F
> +GLIBC_2.33 mknodat F
>  GLIBC_2.33 stat F
>  GLIBC_2.33 stat64 F
>  GLIBC_2.4 _IO_fprintf F
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
> b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist index
> 33b068201a..44e68aded2 100644 ---
> a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist +++
> b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist @@ -2124,6
> +2124,8 @@ GLIBC_2.33 fstatat F GLIBC_2.33 fstatat64 F
>  GLIBC_2.33 lstat F
>  GLIBC_2.33 lstat64 F
> +GLIBC_2.33 mknod F
> +GLIBC_2.33 mknodat F
>  GLIBC_2.33 stat F
>  GLIBC_2.33 stat64 F
>  GLIBC_2.4 __confstr_chk F
> diff --git a/sysdeps/unix/sysv/linux/sparc/xstatver.h
> b/sysdeps/unix/sysv/linux/sparc/xstatver.h index
> ae92b530e7..693b41c3ac 100644 ---
> a/sysdeps/unix/sysv/linux/sparc/xstatver.h +++
> b/sysdeps/unix/sysv/linux/sparc/xstatver.h @@ -5,3 +5,9 @@
>  #define _STAT_VER_SVR4		2
>  #define _STAT_VER_LINUX		3
>  #define _STAT_VER		_STAT_VER_LINUX	/* The one
> defined below.  */ +
> +/* Versions of the 'xmknod' interface used in compatibility xmknod
> +   functions.  */
> +#define _MKNOD_VER_LINUX	1
> +#define _MKNOD_VER_SVR4		2
> +#define _MKNOD_VER		_MKNOD_VER_LINUX
> diff --git a/sysdeps/unix/sysv/linux/x86/bits/stat.h
> b/sysdeps/unix/sysv/linux/x86/bits/stat.h index
> f132569e9d..2c0a3f120b 100644 ---
> a/sysdeps/unix/sysv/linux/x86/bits/stat.h +++
> b/sysdeps/unix/sysv/linux/x86/bits/stat.h @@ -22,17 +22,6 @@
>  #ifndef _BITS_STAT_H
>  #define _BITS_STAT_H	1
>  
> -/* Versions of the `struct stat' data structure.  */
> -#ifndef __x86_64__
> -/* i386 versions of the `xmknod' interface.  */
> -# define _MKNOD_VER_LINUX	1
> -# define _MKNOD_VER_SVR4	2
> -# define _MKNOD_VER		_MKNOD_VER_LINUX /* The bits
> defined below.  */ -#else
> -/* x86-64 versions of the `xmknod' interface.  */
> -# define _MKNOD_VER_LINUX	0
> -#endif
> -
>  struct stat
>    {
>      __dev_t st_dev;		/* Device.  */
> diff --git a/sysdeps/unix/sysv/linux/x86/xstatver.h
> b/sysdeps/unix/sysv/linux/x86/xstatver.h index 6f047a346d..678d5bc022
> 100644 --- a/sysdeps/unix/sysv/linux/x86/xstatver.h
> +++ b/sysdeps/unix/sysv/linux/x86/xstatver.h
> @@ -5,9 +5,12 @@
>  # define _STAT_VER_KERNEL	1
>  # define _STAT_VER_SVR4		2
>  # define _STAT_VER_LINUX	3
> +# define _MKNOD_VER_LINUX	1
> +# define _MKNOD_VER_SVR4	2
>  #else
>  # define _STAT_VER_KERNEL	0
>  # define _STAT_VER_LINUX	1
> +# define _MKNOD_VER_LINUX	0
>  #endif
>  #define _STAT_VER		_STAT_VER_LINUX
> -
> +#define _MKNOD_VER		_MKNOD_VER_LINUX
> diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
> b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist index
> f767bdde24..51e76861f6 100644 ---
> a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist +++
> b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist @@ -2082,6 +2082,8
> @@ GLIBC_2.33 fstatat F GLIBC_2.33 fstatat64 F
>  GLIBC_2.33 lstat F
>  GLIBC_2.33 lstat64 F
> +GLIBC_2.33 mknod F
> +GLIBC_2.33 mknodat F
>  GLIBC_2.33 stat F
>  GLIBC_2.33 stat64 F
>  GLIBC_2.4 __confstr_chk F
> diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
> b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist index
> 535862a51e..f83473c11f 100644 ---
> a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist +++
> b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist @@ -2179,5 +2179,7
> @@ GLIBC_2.33 fstatat F GLIBC_2.33 fstatat64 F
>  GLIBC_2.33 lstat F
>  GLIBC_2.33 lstat64 F
> +GLIBC_2.33 mknod F
> +GLIBC_2.33 mknodat F
>  GLIBC_2.33 stat F
>  GLIBC_2.33 stat64 F
> diff --git a/sysdeps/unix/sysv/linux/xstatver.h
> b/sysdeps/unix/sysv/linux/xstatver.h index 59dba71dd1..8e1801b603
> 100644 --- a/sysdeps/unix/sysv/linux/xstatver.h
> +++ b/sysdeps/unix/sysv/linux/xstatver.h
> @@ -5,3 +5,9 @@
>  #define _STAT_VER_SVR4		2
>  #define _STAT_VER_LINUX		3
>  #define _STAT_VER		_STAT_VER_LINUX
> +
> +/* Versions of the 'xmknod' interface used in compatibility xmknod
> +   functions.  */
> +#define _MKNOD_VER_LINUX	1
> +#define _MKNOD_VER_SVR4		2
> +#define _MKNOD_VER		_MKNOD_VER_LINUX




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 11/16] linux: Move the struct stat{64} to struct_stat.h
  2020-07-23 19:46 ` [PATCH 11/16] linux: Move the struct stat{64} to struct_stat.h Adhemerval Zanella via Libc-alpha
@ 2020-07-24  9:27   ` Lukasz Majewski
  0 siblings, 0 replies; 80+ messages in thread
From: Lukasz Majewski @ 2020-07-24  9:27 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Alistair Francis, libc-alpha

[-- Attachment #1: Type: text/plain, Size: 43717 bytes --]

On Thu, 23 Jul 2020 16:46:36 -0300
Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> The common definitions are moved to a Linux generic stat.h while
> the struct stat{64} definition are moved to a arch-specific
> struct_stat.h header.
> 
> Checked with a build for all affected Linux ABIs.  I checked also
> on x86_64-linux-gnu and i686-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>

> ---
>  sysdeps/unix/sysv/linux/Makefile              |   3 +-
>  .../alpha/bits/{stat.h => struct_stat.h}      |  43 +-----
>  sysdeps/unix/sysv/linux/bits/stat.h           | 101 +-------------
>  sysdeps/unix/sysv/linux/bits/struct_stat.h    | 131
> ++++++++++++++++++ .../generic/bits/{stat.h => struct_stat.h}    |
> 45 +----- .../linux/ia64/bits/{stat.h => struct_stat.h} |  45 +-----
>  .../linux/m68k/bits/{stat.h => struct_stat.h} |  44 +-----
>  .../microblaze/bits/{stat.h => struct_stat.h} |  53 ++-----
>  .../linux/mips/bits/{stat.h => struct_stat.h} |  45 +-----
>  .../powerpc/bits/{stat.h => struct_stat.h}    |  48 +------
>  .../linux/s390/bits/{stat.h => struct_stat.h} |  46 +-----
>  .../sparc/bits/{stat.h => struct_stat.h}      |  49 ++-----
>  .../linux/x86/bits/{stat.h => struct_stat.h}  |  46 +-----
>  13 files changed, 206 insertions(+), 493 deletions(-)
>  rename sysdeps/unix/sysv/linux/alpha/bits/{stat.h => struct_stat.h}
> (72%) create mode 100644 sysdeps/unix/sysv/linux/bits/struct_stat.h
>  rename sysdeps/unix/sysv/linux/generic/bits/{stat.h =>
> struct_stat.h} (77%) rename sysdeps/unix/sysv/linux/ia64/bits/{stat.h
> => struct_stat.h} (75%) rename
> sysdeps/unix/sysv/linux/m68k/bits/{stat.h => struct_stat.h} (77%)
> rename sysdeps/unix/sysv/linux/microblaze/bits/{stat.h =>
> struct_stat.h} (81%) rename sysdeps/unix/sysv/linux/mips/bits/{stat.h
> => struct_stat.h} (85%) rename
> sysdeps/unix/sysv/linux/powerpc/bits/{stat.h => struct_stat.h} (85%)
> rename sysdeps/unix/sysv/linux/s390/bits/{stat.h => struct_stat.h}
> (85%) rename sysdeps/unix/sysv/linux/sparc/bits/{stat.h =>
> struct_stat.h} (77%) rename sysdeps/unix/sysv/linux/x86/bits/{stat.h
> => struct_stat.h} (79%)
> 
> diff --git a/sysdeps/unix/sysv/linux/Makefile
> b/sysdeps/unix/sysv/linux/Makefile index 3c28adae0d..f189f65daf 100644
> --- a/sysdeps/unix/sysv/linux/Makefile
> +++ b/sysdeps/unix/sysv/linux/Makefile
> @@ -94,7 +94,8 @@ sysdep_headers += sys/mount.h sys/acct.h \
>  		  bits/types/struct_semid_ds.h \
>  		  bits/types/struct_msqid_ds.h \
>  		  bits/types/struct_shmid_ds.h \
> -		  bits/ipc-perm.h
> +		  bits/ipc-perm.h \
> +		  bits/struct_stat.h
>  
>  tests += tst-clone tst-clone2 tst-clone3 tst-fanotify
> tst-personality \ tst-quota tst-sync_file_range tst-sysconf-iov_max
> tst-ttyname \ diff --git a/sysdeps/unix/sysv/linux/alpha/bits/stat.h
> b/sysdeps/unix/sysv/linux/alpha/bits/struct_stat.h similarity index
> 72% rename from sysdeps/unix/sysv/linux/alpha/bits/stat.h
> rename to sysdeps/unix/sysv/linux/alpha/bits/struct_stat.h
> index d20fb5a4b0..1c9b4248b8 100644
> --- a/sysdeps/unix/sysv/linux/alpha/bits/stat.h
> +++ b/sysdeps/unix/sysv/linux/alpha/bits/struct_stat.h
> @@ -1,4 +1,5 @@
> -/* Copyright (C) 1996-2020 Free Software Foundation, Inc.
> +/* Definition for struct stat.
> +   Copyright (C) 2020 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
> @@ -16,11 +17,11 @@
>     <https://www.gnu.org/licenses/>.  */
>  
>  #if !defined _SYS_STAT_H && !defined _FCNTL_H
> -# error "Never include <bits/stat.h> directly; use <sys/stat.h>
> instead." +# error "Never include <bits/struct_stat.h> directly; use
> <sys/stat.h> instead." #endif
>  
> -#ifndef _BITS_STAT_H
> -#define _BITS_STAT_H	1
> +#ifndef _BITS_STRUCT_STAT_H
> +#define _BITS_STRUCT_STAT_H	1
>  
>  /* Nanosecond resolution timestamps are stored in a format
> equivalent to 'struct timespec'.  This is the type used whenever
> possible but the @@ -111,37 +112,5 @@ struct stat64
>  #define _STATBUF_ST_RDEV
>  #define _STATBUF_ST_NSEC
>  
> -/* Encoding of the file mode.  */
>  
> -#define	__S_IFMT	0170000	/* These bits
> determine file type.  */ -
> -/* File types.  */
> -#define	__S_IFDIR	0040000	/* Directory.  */
> -#define	__S_IFCHR	0020000	/* Character device.
> */ -#define	__S_IFBLK	0060000	/* Block device.
> */ -#define	__S_IFREG	0100000	/* Regular file.
> */ -#define	__S_IFIFO	0010000	/* FIFO.  */
> -#define	__S_IFLNK	0120000	/* Symbolic link.  */
> -#define	__S_IFSOCK	0140000	/* Socket.  */
> -
> -/* POSIX.1b objects.  Note that these macros always evaluate to
> zero.  But
> -   they do it by enforcing the correct use of the macros.  */
> -#define __S_TYPEISMQ(buf)  ((buf)->st_mode - (buf)->st_mode)
> -#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
> -#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
> -
> -/* Protection bits.  */
> -
> -#define	__S_ISUID	04000	/* Set user ID on
> execution.  */ -#define	__S_ISGID	02000	/* Set
> group ID on execution.  */ -#define	__S_ISVTX
> 01000	/* Save swapped text after use (sticky).  */
> -#define	__S_IREAD	0400	/* Read by owner.  */
> -#define	__S_IWRITE	0200	/* Write by owner.  */
> -#define	__S_IEXEC	0100	/* Execute by owner.  */
> - -#ifdef __USE_ATFILE
> -# define UTIME_NOW	((1l << 30) - 1l)
> -# define UTIME_OMIT	((1l << 30) - 2l)
> -#endif
> -
> -#endif /* bits/stat.h */
> +#endif /* _BITS_STRUCT_STAT_H  */
> diff --git a/sysdeps/unix/sysv/linux/bits/stat.h
> b/sysdeps/unix/sysv/linux/bits/stat.h index 0669451f69..85c4c7769e
> 100644 --- a/sysdeps/unix/sysv/linux/bits/stat.h
> +++ b/sysdeps/unix/sysv/linux/bits/stat.h
> @@ -22,106 +22,7 @@
>  #ifndef _BITS_STAT_H
>  #define _BITS_STAT_H	1
>  
> -struct stat
> -  {
> -    __dev_t st_dev;			/* Device.  */
> -    unsigned short int __pad1;
> -#ifndef __USE_FILE_OFFSET64
> -    __ino_t st_ino;			/* File serial
> number.	*/ -#else
> -    __ino_t __st_ino;			/* 32bit file serial
> number.	*/ -#endif
> -    __mode_t st_mode;			/* File mode.  */
> -    __nlink_t st_nlink;			/* Link count.  */
> -    __uid_t st_uid;			/* User ID of the file's
> owner.	*/
> -    __gid_t st_gid;			/* Group ID of the file's
> group.*/
> -    __dev_t st_rdev;			/* Device number, if
> device.  */
> -    unsigned short int __pad2;
> -#ifndef __USE_FILE_OFFSET64
> -    __off_t st_size;			/* Size of file, in
> bytes.  */ -#else
> -    __off64_t st_size;			/* Size of file, in
> bytes.  */ -#endif
> -    __blksize_t st_blksize;		/* Optimal block size for
> I/O.  */ -
> -#ifndef __USE_FILE_OFFSET64
> -    __blkcnt_t st_blocks;		/* Number 512-byte blocks
> allocated. */ -#else
> -    __blkcnt64_t st_blocks;		/* Number 512-byte blocks
> allocated. */ -#endif
> -#ifdef __USE_XOPEN2K8
> -    /* Nanosecond resolution timestamps are stored in a format
> -       equivalent to 'struct timespec'.  This is the type used
> -       whenever possible but the Unix namespace rules do not allow
> the
> -       identifier 'timespec' to appear in the <sys/stat.h> header.
> -       Therefore we have to handle the use of this header in strictly
> -       standard-compliant sources special.  */
> -    struct timespec st_atim;		/* Time of last access.
> */
> -    struct timespec st_mtim;		/* Time of last
> modification.  */
> -    struct timespec st_ctim;		/* Time of last status
> change.  */ -# define st_atime st_atim.tv_sec	/* Backward
> compatibility.  */ -# define st_mtime st_mtim.tv_sec
> -# define st_ctime st_ctim.tv_sec
> -#else
> -    __time_t st_atime;			/* Time of last
> access.  */
> -    unsigned long int st_atimensec;	/* Nscecs of last access.
>  */
> -    __time_t st_mtime;			/* Time of last
> modification.  */
> -    unsigned long int st_mtimensec;	/* Nsecs of last
> modification.  */
> -    __time_t st_ctime;			/* Time of last status
> change.  */
> -    unsigned long int st_ctimensec;	/* Nsecs of last status
> change.  */ -#endif
> -#ifndef __USE_FILE_OFFSET64
> -    unsigned long int __glibc_reserved4;
> -    unsigned long int __glibc_reserved5;
> -#else
> -    __ino64_t st_ino;			/* File serial
> number.	*/ -#endif
> -  };
> -
> -#ifdef __USE_LARGEFILE64
> -struct stat64
> -  {
> -    __dev_t st_dev;			/* Device.  */
> -    unsigned int __pad1;
> -
> -    __ino_t __st_ino;			/* 32bit file serial
> number.	*/
> -    __mode_t st_mode;			/* File mode.  */
> -    __nlink_t st_nlink;			/* Link count.  */
> -    __uid_t st_uid;			/* User ID of the file's
> owner.	*/
> -    __gid_t st_gid;			/* Group ID of the file's
> group.*/
> -    __dev_t st_rdev;			/* Device number, if
> device.  */
> -    unsigned int __pad2;
> -    __off64_t st_size;			/* Size of file, in
> bytes.  */
> -    __blksize_t st_blksize;		/* Optimal block size for
> I/O.  */ -
> -    __blkcnt64_t st_blocks;		/* Number 512-byte blocks
> allocated. */ -# ifdef __USE_XOPEN2K8
> -    /* Nanosecond resolution timestamps are stored in a format
> -       equivalent to 'struct timespec'.  This is the type used
> -       whenever possible but the Unix namespace rules do not allow
> the
> -       identifier 'timespec' to appear in the <sys/stat.h> header.
> -       Therefore we have to handle the use of this header in strictly
> -       standard-compliant sources special.  */
> -    struct timespec st_atim;		/* Time of last access.
> */
> -    struct timespec st_mtim;		/* Time of last
> modification.  */
> -    struct timespec st_ctim;		/* Time of last status
> change.  */ -# else
> -    __time_t st_atime;			/* Time of last
> access.  */
> -    unsigned long int st_atimensec;	/* Nscecs of last access.
>  */
> -    __time_t st_mtime;			/* Time of last
> modification.  */
> -    unsigned long int st_mtimensec;	/* Nsecs of last
> modification.  */
> -    __time_t st_ctime;			/* Time of last status
> change.  */
> -    unsigned long int st_ctimensec;	/* Nsecs of last status
> change.  */ -# endif
> -    __ino64_t st_ino;			/* File serial
> number.		*/
> -  };
> -#endif
> -
> -/* Tell code we have these members.  */
> -#define	_STATBUF_ST_BLKSIZE
> -#define _STATBUF_ST_RDEV
> -/* Nanosecond resolution time values are supported.  */
> -#define _STATBUF_ST_NSEC
> +#include <bits/struct_stat.h>
>  
>  /* Encoding of the file mode.  */
>  
> diff --git a/sysdeps/unix/sysv/linux/bits/struct_stat.h
> b/sysdeps/unix/sysv/linux/bits/struct_stat.h new file mode 100644
> index 0000000000..344bffece6
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/bits/struct_stat.h
> @@ -0,0 +1,131 @@
> +/* Definition for struct stat.
> +   Copyright (C) 2020 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/>.  */
> +
> +#if !defined _SYS_STAT_H && !defined _FCNTL_H
> +# error "Never include <bits/struct_stat.h> directly; use
> <sys/stat.h> instead." +#endif
> +
> +#ifndef _BITS_STRUCT_STAT_H
> +#define _BITS_STRUCT_STAT_H	1
> +
> +#include <bits/endian.h>
> +#include <bits/wordsize.h>
> +
> +struct stat
> +  {
> +    __dev_t st_dev;			/* Device.  */
> +    unsigned short int __pad1;
> +#ifndef __USE_FILE_OFFSET64
> +    __ino_t st_ino;			/* File serial
> number.	*/ +#else
> +    __ino_t __st_ino;			/* 32bit file serial
> number.	*/ +#endif
> +    __mode_t st_mode;			/* File mode.  */
> +    __nlink_t st_nlink;			/* Link count.  */
> +    __uid_t st_uid;			/* User ID of the file's
> owner.	*/
> +    __gid_t st_gid;			/* Group ID of the file's
> group.*/
> +    __dev_t st_rdev;			/* Device number, if
> device.  */
> +    unsigned short int __pad2;
> +#ifndef __USE_FILE_OFFSET64
> +    __off_t st_size;			/* Size of file, in
> bytes.  */ +#else
> +    __off64_t st_size;			/* Size of file, in
> bytes.  */ +#endif
> +    __blksize_t st_blksize;		/* Optimal block size for
> I/O.  */ +
> +#ifndef __USE_FILE_OFFSET64
> +    __blkcnt_t st_blocks;		/* Number 512-byte blocks
> allocated. */ +#else
> +    __blkcnt64_t st_blocks;		/* Number 512-byte blocks
> allocated. */ +#endif
> +#ifdef __USE_XOPEN2K8
> +    /* Nanosecond resolution timestamps are stored in a format
> +       equivalent to 'struct timespec'.  This is the type used
> +       whenever possible but the Unix namespace rules do not allow
> the
> +       identifier 'timespec' to appear in the <sys/stat.h> header.
> +       Therefore we have to handle the use of this header in strictly
> +       standard-compliant sources special.  */
> +    struct timespec st_atim;		/* Time of last access.
> */
> +    struct timespec st_mtim;		/* Time of last
> modification.  */
> +    struct timespec st_ctim;		/* Time of last status
> change.  */ +# define st_atime st_atim.tv_sec	/* Backward
> compatibility.  */ +# define st_mtime st_mtim.tv_sec
> +# define st_ctime st_ctim.tv_sec
> +#else
> +    __time_t st_atime;			/* Time of last
> access.  */
> +    unsigned long int st_atimensec;	/* Nscecs of last access.
>  */
> +    __time_t st_mtime;			/* Time of last
> modification.  */
> +    unsigned long int st_mtimensec;	/* Nsecs of last
> modification.  */
> +    __time_t st_ctime;			/* Time of last status
> change.  */
> +    unsigned long int st_ctimensec;	/* Nsecs of last status
> change.  */ +#endif
> +#ifndef __USE_FILE_OFFSET64
> +    unsigned long int __glibc_reserved4;
> +    unsigned long int __glibc_reserved5;
> +#else
> +    __ino64_t st_ino;			/* File serial
> number.	*/ +#endif
> +  };
> +
> +#ifdef __USE_LARGEFILE64
> +struct stat64
> +  {
> +    __dev_t st_dev;			/* Device.  */
> +    unsigned int __pad1;
> +
> +    __ino_t __st_ino;			/* 32bit file serial
> number.	*/
> +    __mode_t st_mode;			/* File mode.  */
> +    __nlink_t st_nlink;			/* Link count.  */
> +    __uid_t st_uid;			/* User ID of the file's
> owner.	*/
> +    __gid_t st_gid;			/* Group ID of the file's
> group.*/
> +    __dev_t st_rdev;			/* Device number, if
> device.  */
> +    unsigned int __pad2;
> +    __off64_t st_size;			/* Size of file, in
> bytes.  */
> +    __blksize_t st_blksize;		/* Optimal block size for
> I/O.  */ +
> +    __blkcnt64_t st_blocks;		/* Number 512-byte blocks
> allocated. */ +# ifdef __USE_XOPEN2K8
> +    /* Nanosecond resolution timestamps are stored in a format
> +       equivalent to 'struct timespec'.  This is the type used
> +       whenever possible but the Unix namespace rules do not allow
> the
> +       identifier 'timespec' to appear in the <sys/stat.h> header.
> +       Therefore we have to handle the use of this header in strictly
> +       standard-compliant sources special.  */
> +    struct timespec st_atim;		/* Time of last access.
> */
> +    struct timespec st_mtim;		/* Time of last
> modification.  */
> +    struct timespec st_ctim;		/* Time of last status
> change.  */ +# else
> +    __time_t st_atime;			/* Time of last
> access.  */
> +    unsigned long int st_atimensec;	/* Nscecs of last access.
>  */
> +    __time_t st_mtime;			/* Time of last
> modification.  */
> +    unsigned long int st_mtimensec;	/* Nsecs of last
> modification.  */
> +    __time_t st_ctime;			/* Time of last status
> change.  */
> +    unsigned long int st_ctimensec;	/* Nsecs of last status
> change.  */ +# endif
> +    __ino64_t st_ino;			/* File serial
> number.		*/
> +  };
> +#endif
> +
> +/* Tell code we have these members.  */
> +#define	_STATBUF_ST_BLKSIZE
> +#define _STATBUF_ST_RDEV
> +/* Nanosecond resolution time values are supported.  */
> +#define _STATBUF_ST_NSEC
> +
> +
> +#endif /* _BITS_STRUCT_STAT_H  */
> diff --git a/sysdeps/unix/sysv/linux/generic/bits/stat.h
> b/sysdeps/unix/sysv/linux/generic/bits/struct_stat.h similarity index
> 77% rename from sysdeps/unix/sysv/linux/generic/bits/stat.h
> rename to sysdeps/unix/sysv/linux/generic/bits/struct_stat.h
> index 1b586d72fa..5049956030 100644
> --- a/sysdeps/unix/sysv/linux/generic/bits/stat.h
> +++ b/sysdeps/unix/sysv/linux/generic/bits/struct_stat.h
> @@ -1,6 +1,6 @@
> -/* Copyright (C) 2011-2020 Free Software Foundation, Inc.
> +/* Definition for struct stat.
> +   Copyright (C) 2020 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
> @@ -17,11 +17,11 @@
>     <https://www.gnu.org/licenses/>.  */
>  
>  #if !defined _SYS_STAT_H && !defined _FCNTL_H
> -# error "Never include <bits/stat.h> directly; use <sys/stat.h>
> instead." +# error "Never include <bits/struct_stat.h> directly; use
> <sys/stat.h> instead." #endif
>  
> -#ifndef _BITS_STAT_H
> -#define _BITS_STAT_H	1
> +#ifndef _BITS_STRUCT_STAT_H
> +#define _BITS_STRUCT_STAT_H	1
>  
>  #include <bits/endian.h>
>  #include <bits/wordsize.h>
> @@ -124,37 +124,4 @@ struct stat64
>  /* Nanosecond resolution time values are supported.  */
>  #define _STATBUF_ST_NSEC
>  
> -/* Encoding of the file mode.  */
> -
> -#define	__S_IFMT	0170000	/* These bits
> determine file type.  */ -
> -/* File types.  */
> -#define	__S_IFDIR	0040000	/* Directory.  */
> -#define	__S_IFCHR	0020000	/* Character device.
> */ -#define	__S_IFBLK	0060000	/* Block device.
> */ -#define	__S_IFREG	0100000	/* Regular file.
> */ -#define	__S_IFIFO	0010000	/* FIFO.  */
> -#define	__S_IFLNK	0120000	/* Symbolic link.  */
> -#define	__S_IFSOCK	0140000	/* Socket.  */
> -
> -/* POSIX.1b objects.  Note that these macros always evaluate to
> zero.  But
> -   they do it by enforcing the correct use of the macros.  */
> -#define __S_TYPEISMQ(buf)  ((buf)->st_mode - (buf)->st_mode)
> -#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
> -#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
> -
> -/* Protection bits.  */
> -
> -#define	__S_ISUID	04000	/* Set user ID on
> execution.  */ -#define	__S_ISGID	02000	/* Set
> group ID on execution.  */ -#define	__S_ISVTX
> 01000	/* Save swapped text after use (sticky).  */
> -#define	__S_IREAD	0400	/* Read by owner.  */
> -#define	__S_IWRITE	0200	/* Write by owner.  */
> -#define	__S_IEXEC	0100	/* Execute by owner.  */
> - -#ifdef __USE_ATFILE
> -# define UTIME_NOW	((1l << 30) - 1l)
> -# define UTIME_OMIT	((1l << 30) - 2l)
> -#endif
> -
> -#endif /* bits/stat.h */
> +#endif /* _BITS_STRUCT_STAT_H  */
> diff --git a/sysdeps/unix/sysv/linux/ia64/bits/stat.h
> b/sysdeps/unix/sysv/linux/ia64/bits/struct_stat.h similarity index 75%
> rename from sysdeps/unix/sysv/linux/ia64/bits/stat.h
> rename to sysdeps/unix/sysv/linux/ia64/bits/struct_stat.h
> index 6937f3227a..b2272a55b1 100644
> --- a/sysdeps/unix/sysv/linux/ia64/bits/stat.h
> +++ b/sysdeps/unix/sysv/linux/ia64/bits/struct_stat.h
> @@ -1,4 +1,5 @@
> -/* Copyright (C) 1999-2020 Free Software Foundation, Inc.
> +/* Definition for struct stat.
> +   Copyright (C) 2020 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
> @@ -12,15 +13,15 @@
>     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/>.  */
>  
>  #if !defined _SYS_STAT_H && !defined _FCNTL_H
> -# error "Never include <bits/stat.h> directly; use <sys/stat.h>
> instead." +# error "Never include <bits/struct_stat.h> directly; use
> <sys/stat.h> instead." #endif
>  
> -#ifndef _BITS_STAT_H
> -#define _BITS_STAT_H	1
> +#ifndef _BITS_STRUCT_STAT_H
> +#define _BITS_STRUCT_STAT_H	1
>  
>  struct stat
>    {
> @@ -105,37 +106,5 @@ struct stat64
>  /* Nanosecond resolution time values are supported.  */
>  #define _STATBUF_ST_NSEC
>  
> -/* Encoding of the file mode.  */
>  
> -#define	__S_IFMT	0170000	/* These bits
> determine file type.  */ -
> -/* File types.  */
> -#define	__S_IFDIR	0040000	/* Directory.  */
> -#define	__S_IFCHR	0020000	/* Character device.
> */ -#define	__S_IFBLK	0060000	/* Block device.
> */ -#define	__S_IFREG	0100000	/* Regular file.
> */ -#define	__S_IFIFO	0010000	/* FIFO.  */
> -#define	__S_IFLNK	0120000	/* Symbolic link.  */
> -#define	__S_IFSOCK	0140000	/* Socket.  */
> -
> -/* POSIX.1b objects.  Note that these macros always evaluate to
> zero.  But
> -   they do it by enforcing the correct use of the macros.  */
> -#define __S_TYPEISMQ(buf)  ((buf)->st_mode - (buf)->st_mode)
> -#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
> -#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
> -
> -/* Protection bits.  */
> -
> -#define	__S_ISUID	04000	/* Set user ID on
> execution.  */ -#define	__S_ISGID	02000	/* Set
> group ID on execution.  */ -#define	__S_ISVTX
> 01000	/* Save swapped text after use (sticky).  */
> -#define	__S_IREAD	0400	/* Read by owner.  */
> -#define	__S_IWRITE	0200	/* Write by owner.  */
> -#define	__S_IEXEC	0100	/* Execute by owner.  */
> - -#ifdef __USE_ATFILE
> -# define UTIME_NOW	((1l << 30) - 1l)
> -# define UTIME_OMIT	((1l << 30) - 2l)
> -#endif
> -
> -#endif	/* bits//stat.h */
> +#endif /* _BITS_STRUCT_STAT_H  */
> diff --git a/sysdeps/unix/sysv/linux/m68k/bits/stat.h
> b/sysdeps/unix/sysv/linux/m68k/bits/struct_stat.h similarity index 77%
> rename from sysdeps/unix/sysv/linux/m68k/bits/stat.h
> rename to sysdeps/unix/sysv/linux/m68k/bits/struct_stat.h
> index c6f761fcc0..bf457a0db7 100644
> --- a/sysdeps/unix/sysv/linux/m68k/bits/stat.h
> +++ b/sysdeps/unix/sysv/linux/m68k/bits/struct_stat.h
> @@ -1,4 +1,5 @@
> -/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
> +/* Definition for struct stat.
> +   Copyright (C) 2020 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
> @@ -16,11 +17,11 @@
>     <https://www.gnu.org/licenses/>.  */
>  
>  #if !defined _SYS_STAT_H && !defined _FCNTL_H
> -# error "Never include <bits/stat.h> directly; use <sys/stat.h>
> instead." +# error "Never include <bits/struct_stat.h> directly; use
> <sys/stat.h> instead." #endif
>  
> -#ifndef _BITS_STAT_H
> -#define _BITS_STAT_H	1
> +#ifndef _BITS_STRUCT_STAT_H
> +#define _BITS_STRUCT_STAT_H	1
>  
>  struct stat
>    {
> @@ -123,37 +124,4 @@ struct stat64
>  /* Nanosecond resolution time values are supported.  */
>  #define _STATBUF_ST_NSEC
>  
> -/* Encoding of the file mode.  */
> -
> -#define	__S_IFMT	0170000	/* These bits
> determine file type.  */ -
> -/* File types.  */
> -#define	__S_IFDIR	0040000	/* Directory.  */
> -#define	__S_IFCHR	0020000	/* Character device.
> */ -#define	__S_IFBLK	0060000	/* Block device.
> */ -#define	__S_IFREG	0100000	/* Regular file.
> */ -#define	__S_IFIFO	0010000	/* FIFO.  */
> -#define	__S_IFLNK	0120000	/* Symbolic link.  */
> -#define	__S_IFSOCK	0140000	/* Socket.  */
> -
> -/* POSIX.1b objects.  Note that these macros always evaluate to
> zero.  But
> -   they do it by enforcing the correct use of the macros.  */
> -#define __S_TYPEISMQ(buf)  ((buf)->st_mode - (buf)->st_mode)
> -#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
> -#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
> -
> -/* Protection bits.  */
> -
> -#define	__S_ISUID	04000	/* Set user ID on
> execution.  */ -#define	__S_ISGID	02000	/* Set
> group ID on execution.  */ -#define	__S_ISVTX
> 01000	/* Save swapped text after use (sticky).  */
> -#define	__S_IREAD	0400	/* Read by owner.  */
> -#define	__S_IWRITE	0200	/* Write by owner.  */
> -#define	__S_IEXEC	0100	/* Execute by owner.  */
> - -#ifdef __USE_ATFILE
> -# define UTIME_NOW	((1l << 30) - 1l)
> -# define UTIME_OMIT	((1l << 30) - 2l)
> -#endif
> -
> -#endif	/* bits/stat.h */
> +#endif /* _BITS_STRUCT_STAT_H  */
> diff --git a/sysdeps/unix/sysv/linux/microblaze/bits/stat.h
> b/sysdeps/unix/sysv/linux/microblaze/bits/struct_stat.h similarity
> index 81% rename from sysdeps/unix/sysv/linux/microblaze/bits/stat.h
> rename to sysdeps/unix/sysv/linux/microblaze/bits/struct_stat.h
> index b3068e5c98..db81543b23 100644
> --- a/sysdeps/unix/sysv/linux/microblaze/bits/stat.h
> +++ b/sysdeps/unix/sysv/linux/microblaze/bits/struct_stat.h
> @@ -1,11 +1,11 @@
> -/* Copyright (C) 1997-2020 Free Software Foundation, Inc.
> -
> +/* Definition for struct stat.
> +   Copyright (C) 2020 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.
> +   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
> @@ -13,15 +13,15 @@
>     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/>.  */
>  
>  #if !defined _SYS_STAT_H && !defined _FCNTL_H
> -# error "Never include <bits/stat.h> directly; use <sys/stat.h>
> instead." +# error "Never include <bits/struct_stat.h> directly; use
> <sys/stat.h> instead." #endif
>  
> -#ifndef _BITS_STAT_H
> -#define _BITS_STAT_H	1
> +#ifndef _BITS_STRUCT_STAT_H
> +#define _BITS_STRUCT_STAT_H	1
>  
>  #ifndef __USE_FILE_OFFSET64
>  struct stat
> @@ -155,37 +155,4 @@ struct stat64
>  /* Nanosecond resolution time values are supported.  */
>  #define _STATBUF_ST_NSEC
>  
> -/* Encoding of the file mode.  */
> -
> -#define __S_IFMT        0170000 /* These bits determine file type.
> */ -
> -/* File types.  */
> -#define __S_IFDIR       0040000 /* Directory.  */
> -#define __S_IFCHR       0020000 /* Character device.  */
> -#define __S_IFBLK       0060000 /* Block device.  */
> -#define __S_IFREG       0100000 /* Regular file.  */
> -#define __S_IFIFO       0010000 /* FIFO.  */
> -#define __S_IFLNK       0120000 /* Symbolic link.  */
> -#define __S_IFSOCK      0140000 /* Socket.  */
> -
> -/* POSIX.1b objects.  Note that these macros always evaluate to
> zero.  But
> -   they do it by enforcing the correct use of the macros.  */
> -#define __S_TYPEISMQ(buf)  ((buf)->st_mode - (buf)->st_mode)
> -#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
> -#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
> -
> -/* Protection bits.  */
> -
> -#define __S_ISUID       04000   /* Set user ID on execution.  */
> -#define __S_ISGID       02000   /* Set group ID on execution.  */
> -#define __S_ISVTX       01000   /* Save swapped text after use
> (sticky).  */ -#define __S_IREAD       0400    /* Read by owner.  */
> -#define __S_IWRITE      0200    /* Write by owner.  */
> -#define __S_IEXEC       0100    /* Execute by owner.  */
> -
> -#ifdef __USE_ATFILE
> -# define UTIME_NOW	((1l << 30) - 1l)
> -# define UTIME_OMIT	((1l << 30) - 2l)
> -#endif
> -
> -#endif	/* bits/stat.h.  */
> +#endif /* _BITS_STRUCT_STAT_H  */
> diff --git a/sysdeps/unix/sysv/linux/mips/bits/stat.h
> b/sysdeps/unix/sysv/linux/mips/bits/struct_stat.h similarity index 85%
> rename from sysdeps/unix/sysv/linux/mips/bits/stat.h
> rename to sysdeps/unix/sysv/linux/mips/bits/struct_stat.h
> index f229c58013..5abd71fc23 100644
> --- a/sysdeps/unix/sysv/linux/mips/bits/stat.h
> +++ b/sysdeps/unix/sysv/linux/mips/bits/struct_stat.h
> @@ -1,4 +1,5 @@
> -/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
> +/* Definition for struct stat.
> +   Copyright (C) 2020 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
> @@ -16,15 +17,14 @@
>     <https://www.gnu.org/licenses/>.  */
>  
>  #if !defined _SYS_STAT_H && !defined _FCNTL_H
> -# error "Never include <bits/stat.h> directly; use <sys/stat.h>
> instead." +# error "Never include <bits/struct_stat.h> directly; use
> <sys/stat.h> instead." #endif
>  
> -#ifndef _BITS_STAT_H
> -#define _BITS_STAT_H	1
> +#ifndef _BITS_STRUCT_STAT_H
> +#define _BITS_STRUCT_STAT_H	1
>  
>  #include <sgidefs.h>
>  
> -
>  #if _MIPS_SIM == _ABIO32
>  /* Structure describing file characteristics.  */
>  struct stat
> @@ -215,37 +215,4 @@ struct stat64
>  #define	_STATBUF_ST_BLKSIZE
>  #define	_STATBUF_ST_RDEV
>  
> -/* Encoding of the file mode.  */
> -
> -#define	__S_IFMT	0170000	/* These bits
> determine file type.  */ -
> -/* File types.  */
> -#define	__S_IFDIR	0040000	/* Directory.  */
> -#define	__S_IFCHR	0020000	/* Character device.
> */ -#define	__S_IFBLK	0060000	/* Block device.
> */ -#define	__S_IFREG	0100000	/* Regular file.
> */ -#define	__S_IFIFO	0010000	/* FIFO.  */
> -#define	__S_IFLNK	0120000	/* Symbolic link.  */
> -#define	__S_IFSOCK	0140000	/* Socket.  */
> -
> -/* POSIX.1b objects.  Note that these macros always evaluate to
> zero.  But
> -   they do it by enforcing the correct use of the macros.  */
> -#define __S_TYPEISMQ(buf)  ((buf)->st_mode - (buf)->st_mode)
> -#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
> -#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
> -
> -/* Protection bits.  */
> -
> -#define	__S_ISUID	04000	/* Set user ID on
> execution.  */ -#define	__S_ISGID	02000	/* Set
> group ID on execution.  */ -#define	__S_ISVTX
> 01000	/* Save swapped text after use (sticky).  */
> -#define	__S_IREAD	0400	/* Read by owner.  */
> -#define	__S_IWRITE	0200	/* Write by owner.  */
> -#define	__S_IEXEC	0100	/* Execute by owner.  */
> - -#ifdef __USE_ATFILE
> -# define UTIME_NOW	((1l << 30) - 1l)
> -# define UTIME_OMIT	((1l << 30) - 2l)
> -#endif
> -
> -#endif	/* bits/stat.h */
> +#endif /* _BITS_STRUCT_STAT_H  */
> diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/stat.h
> b/sysdeps/unix/sysv/linux/powerpc/bits/struct_stat.h similarity index
> 85% rename from sysdeps/unix/sysv/linux/powerpc/bits/stat.h
> rename to sysdeps/unix/sysv/linux/powerpc/bits/struct_stat.h
> index 80c9dc23ac..cb41adc7c0 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/bits/stat.h
> +++ b/sysdeps/unix/sysv/linux/powerpc/bits/struct_stat.h
> @@ -1,4 +1,5 @@
> -/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
> +/* Definition for struct stat.
> +   Copyright (C) 2020 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
> @@ -12,19 +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/>.  */
>  
>  #if !defined _SYS_STAT_H && !defined _FCNTL_H
> -# error "Never include <bits/stat.h> directly; use <sys/stat.h>
> instead." +# error "Never include <bits/struct_stat.h> directly; use
> <sys/stat.h> instead." #endif
>  
> -#ifndef _BITS_STAT_H
> -#define _BITS_STAT_H	1
> +#ifndef _BITS_STRUCT_STAT_H
> +#define _BITS_STRUCT_STAT_H	1
>  
>  #include <bits/wordsize.h>
>  
> -
>  #if __WORDSIZE == 32
>  
>  struct stat
> @@ -216,44 +216,10 @@ struct stat64
>  # endif /* __USE_LARGEFILE64 */
>  #endif
>  
> -
>  /* Tell code we have these members.  */
>  #define	_STATBUF_ST_BLKSIZE
>  #define _STATBUF_ST_RDEV
>  /* Nanosecond resolution time values are supported.  */
>  #define _STATBUF_ST_NSEC
>  
> -/* Encoding of the file mode.  */
> -
> -#define	__S_IFMT	0170000	/* These bits
> determine file type.  */ -
> -/* File types.  */
> -#define	__S_IFDIR	0040000	/* Directory.  */
> -#define	__S_IFCHR	0020000	/* Character device.
> */ -#define	__S_IFBLK	0060000	/* Block device.
> */ -#define	__S_IFREG	0100000	/* Regular file.
> */ -#define	__S_IFIFO	0010000	/* FIFO.  */
> -#define	__S_IFLNK	0120000	/* Symbolic link.  */
> -#define	__S_IFSOCK	0140000	/* Socket.  */
> -
> -/* POSIX.1b objects.  Note that these macros always evaluate to
> zero.  But
> -   they do it by enforcing the correct use of the macros.  */
> -#define __S_TYPEISMQ(buf)  ((buf)->st_mode - (buf)->st_mode)
> -#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
> -#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
> -
> -/* Protection bits.  */
> -
> -#define	__S_ISUID	04000	/* Set user ID on
> execution.  */ -#define	__S_ISGID	02000	/* Set
> group ID on execution.  */ -#define	__S_ISVTX
> 01000	/* Save swapped text after use (sticky).  */
> -#define	__S_IREAD	0400	/* Read by owner.  */
> -#define	__S_IWRITE	0200	/* Write by owner.  */
> -#define	__S_IEXEC	0100	/* Execute by owner.  */
> - -#ifdef __USE_ATFILE
> -# define UTIME_NOW	((1l << 30) - 1l)
> -# define UTIME_OMIT	((1l << 30) - 2l)
> -#endif
> -
> -#endif	/* bits/stat.h */
> +#endif /* _BITS_STRUCT_STAT_H  */
> diff --git a/sysdeps/unix/sysv/linux/s390/bits/stat.h
> b/sysdeps/unix/sysv/linux/s390/bits/struct_stat.h similarity index 85%
> rename from sysdeps/unix/sysv/linux/s390/bits/stat.h
> rename to sysdeps/unix/sysv/linux/s390/bits/struct_stat.h
> index 75fa871a1d..10e7eb0221 100644
> --- a/sysdeps/unix/sysv/linux/s390/bits/stat.h
> +++ b/sysdeps/unix/sysv/linux/s390/bits/struct_stat.h
> @@ -1,4 +1,5 @@
> -/* Copyright (C) 2000-2020 Free Software Foundation, Inc.
> +/* Definition for struct stat.
> +   Copyright (C) 2020 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
> @@ -12,15 +13,15 @@
>     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/>.  */
>  
>  #if !defined _SYS_STAT_H && !defined _FCNTL_H
> -# error "Never include <bits/stat.h> directly; use <sys/stat.h>
> instead." +# error "Never include <bits/struct_stat.h> directly; use
> <sys/stat.h> instead." #endif
>  
> -#ifndef _BITS_STAT_H
> -#define _BITS_STAT_H	1
> +#ifndef _BITS_STRUCT_STAT_H
> +#define _BITS_STRUCT_STAT_H	1
>  
>  #include <bits/wordsize.h>
>  
> @@ -207,37 +208,4 @@ struct stat64
>  /* Nanosecond resolution time values are supported.  */
>  #define _STATBUF_ST_NSEC
>  
> -/* Encoding of the file mode.  */
> -
> -#define	__S_IFMT	0170000	/* These bits
> determine file type.  */ -
> -/* File types.  */
> -#define	__S_IFDIR	0040000	/* Directory.  */
> -#define	__S_IFCHR	0020000	/* Character device.
> */ -#define	__S_IFBLK	0060000	/* Block device.
> */ -#define	__S_IFREG	0100000	/* Regular file.
> */ -#define	__S_IFIFO	0010000	/* FIFO.  */
> -#define	__S_IFLNK	0120000	/* Symbolic link.  */
> -#define	__S_IFSOCK	0140000	/* Socket.  */
> -
> -/* POSIX.1b objects.  Note that these macros always evaluate to
> zero.  But
> -   they do it by enforcing the correct use of the macros.  */
> -#define __S_TYPEISMQ(buf)  ((buf)->st_mode - (buf)->st_mode)
> -#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
> -#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
> -
> -/* Protection bits.  */
> -
> -#define	__S_ISUID	04000	/* Set user ID on
> execution.  */ -#define	__S_ISGID	02000	/* Set
> group ID on execution.  */ -#define	__S_ISVTX
> 01000	/* Save swapped text after use (sticky).  */
> -#define	__S_IREAD	0400	/* Read by owner.  */
> -#define	__S_IWRITE	0200	/* Write by owner.  */
> -#define	__S_IEXEC	0100	/* Execute by owner.  */
> - -#ifdef __USE_ATFILE
> -# define UTIME_NOW	((1l << 30) - 1l)
> -# define UTIME_OMIT	((1l << 30) - 2l)
> -#endif
> -
> -#endif	/* bits/stat.h */
> +#endif /* _BITS_STRUCT_STAT_H  */
> diff --git a/sysdeps/unix/sysv/linux/sparc/bits/stat.h
> b/sysdeps/unix/sysv/linux/sparc/bits/struct_stat.h similarity index
> 77% rename from sysdeps/unix/sysv/linux/sparc/bits/stat.h
> rename to sysdeps/unix/sysv/linux/sparc/bits/struct_stat.h
> index d10ebb1a9a..546811539a 100644
> --- a/sysdeps/unix/sysv/linux/sparc/bits/stat.h
> +++ b/sysdeps/unix/sysv/linux/sparc/bits/struct_stat.h
> @@ -1,4 +1,5 @@
> -/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
> +/* Definition for struct stat.
> +   Copyright (C) 2020 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
> @@ -12,15 +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/>.  */
>  
>  #if !defined _SYS_STAT_H && !defined _FCNTL_H
> -# error "Never include <bits/stat.h> directly; use <sys/stat.h>
> instead." +# error "Never include <bits/struct_stat.h> directly; use
> <sys/stat.h> instead." #endif
>  
> -#ifndef _BITS_STAT_H
> -#define _BITS_STAT_H	1
> +#ifndef _BITS_STRUCT_STAT_H
> +#define _BITS_STRUCT_STAT_H	1
> +
> +#include <bits/endian.h>
> +#include <bits/wordsize.h>
>  
>  struct stat
>    {
> @@ -124,37 +128,4 @@ struct stat64
>  /* Nanosecond resolution time values are supported.  */
>  #define _STATBUF_ST_NSEC
>  
> -/* Encoding of the file mode.  */
> -
> -#define	__S_IFMT	0170000	/* These bits
> determine file type.  */ -
> -/* File types.  */
> -#define	__S_IFDIR	0040000	/* Directory.  */
> -#define	__S_IFCHR	0020000	/* Character device.
> */ -#define	__S_IFBLK	0060000	/* Block device.
> */ -#define	__S_IFREG	0100000	/* Regular file.
> */ -#define	__S_IFIFO	0010000	/* FIFO.  */
> -#define	__S_IFLNK	0120000	/* Symbolic link.  */
> -#define	__S_IFSOCK	0140000	/* Socket.  */
> -
> -/* POSIX.1b objects.  Note that these macros always evaluate to
> zero.  But
> -   they do it by enforcing the correct use of the macros.  */
> -#define __S_TYPEISMQ(buf)  ((buf)->st_mode - (buf)->st_mode)
> -#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
> -#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
> -
> -/* Protection bits.  */
> -
> -#define	__S_ISUID	04000	/* Set user ID on
> execution.  */ -#define	__S_ISGID	02000	/* Set
> group ID on execution.  */ -#define	__S_ISVTX
> 01000	/* Save swapped text after use (sticky).  */
> -#define	__S_IREAD	0400	/* Read by owner.  */
> -#define	__S_IWRITE	0200	/* Write by owner.  */
> -#define	__S_IEXEC	0100	/* Execute by owner.  */
> - -#ifdef __USE_ATFILE
> -# define UTIME_NOW	((1l << 30) - 1l)
> -# define UTIME_OMIT	((1l << 30) - 2l)
> -#endif
> -
> -#endif	/* bits/stat.h */
> +#endif /* _BITS_STRUCT_STAT_H  */
> diff --git a/sysdeps/unix/sysv/linux/x86/bits/stat.h
> b/sysdeps/unix/sysv/linux/x86/bits/struct_stat.h similarity index 79%
> rename from sysdeps/unix/sysv/linux/x86/bits/stat.h
> rename to sysdeps/unix/sysv/linux/x86/bits/struct_stat.h
> index 2c0a3f120b..dae7aa46b3 100644
> --- a/sysdeps/unix/sysv/linux/x86/bits/stat.h
> +++ b/sysdeps/unix/sysv/linux/x86/bits/struct_stat.h
> @@ -1,4 +1,5 @@
> -/* Copyright (C) 1999-2020 Free Software Foundation, Inc.
> +/* Definition for struct stat.
> +   Copyright (C) 2020 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
> @@ -12,15 +13,15 @@
>     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/>.  */
>  
>  #if !defined _SYS_STAT_H && !defined _FCNTL_H
> -# error "Never include <bits/stat.h> directly; use <sys/stat.h>
> instead." +# error "Never include <bits/struct_stat.h> directly; use
> <sys/stat.h> instead." #endif
>  
> -#ifndef _BITS_STAT_H
> -#define _BITS_STAT_H	1
> +#ifndef _BITS_STRUCT_STAT_H
> +#define _BITS_STRUCT_STAT_H	1
>  
>  struct stat
>    {
> @@ -153,37 +154,4 @@ struct stat64
>  /* Nanosecond resolution time values are supported.  */
>  #define _STATBUF_ST_NSEC
>  
> -/* Encoding of the file mode.  */
> -
> -#define	__S_IFMT	0170000	/* These bits
> determine file type.  */ -
> -/* File types.  */
> -#define	__S_IFDIR	0040000	/* Directory.  */
> -#define	__S_IFCHR	0020000	/* Character device.
> */ -#define	__S_IFBLK	0060000	/* Block device.
> */ -#define	__S_IFREG	0100000	/* Regular file.
> */ -#define	__S_IFIFO	0010000	/* FIFO.  */
> -#define	__S_IFLNK	0120000	/* Symbolic link.  */
> -#define	__S_IFSOCK	0140000	/* Socket.  */
> -
> -/* POSIX.1b objects.  Note that these macros always evaluate to
> zero.  But
> -   they do it by enforcing the correct use of the macros.  */
> -#define __S_TYPEISMQ(buf)  ((buf)->st_mode - (buf)->st_mode)
> -#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
> -#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
> -
> -/* Protection bits.  */
> -
> -#define	__S_ISUID	04000	/* Set user ID on
> execution.  */ -#define	__S_ISGID	02000	/* Set
> group ID on execution.  */ -#define	__S_ISVTX
> 01000	/* Save swapped text after use (sticky).  */
> -#define	__S_IREAD	0400	/* Read by owner.  */
> -#define	__S_IWRITE	0200	/* Write by owner.  */
> -#define	__S_IEXEC	0100	/* Execute by owner.  */
> - -#ifdef __USE_ATFILE
> -# define UTIME_NOW	((1l << 30) - 1l)
> -# define UTIME_OMIT	((1l << 30) - 2l)
> -#endif
> -
> -#endif	/* bits/stat.h */
> +#endif /* _BITS_STRUCT_STAT_H  */




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 12/16] linux: Implement {l}fstat{at} in terms of fstatat
  2020-07-23 19:46 ` [PATCH 12/16] linux: Implement {l}fstat{at} in terms of fstatat Adhemerval Zanella via Libc-alpha
@ 2020-07-24  9:29   ` Lukasz Majewski
  0 siblings, 0 replies; 80+ messages in thread
From: Lukasz Majewski @ 2020-07-24  9:29 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Alistair Francis, libc-alpha

[-- Attachment #1: Type: text/plain, Size: 13783 bytes --]

On Thu, 23 Jul 2020 16:46:37 -0300
Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> Both fstatat and fstata64 calls the old fxstatat and fxstatat64
> repectivelly with _STAT_VER, the one currently exported as default
> for all ABIs.
> 
> Checked on x86_64-linux-gnu and i686-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>

> ---
>  sysdeps/unix/sysv/linux/fstat.c     | 31 +++++++++++++++++++++++
>  sysdeps/unix/sysv/linux/fstat64.c   | 38
> +++++++++++++++++++++++++++++ sysdeps/unix/sysv/linux/fstatat.c   |
> 30 +++++++++++++++++++++++ sysdeps/unix/sysv/linux/fstatat64.c | 38
> +++++++++++++++++++++++++++++ sysdeps/unix/sysv/linux/lstat.c     |
> 31 +++++++++++++++++++++++ sysdeps/unix/sysv/linux/lstat64.c   | 38
> +++++++++++++++++++++++++++++ sysdeps/unix/sysv/linux/stat.c      |
> 31 +++++++++++++++++++++++ sysdeps/unix/sysv/linux/stat64.c    | 38
> +++++++++++++++++++++++++++++ 8 files changed, 275 insertions(+)
>  create mode 100644 sysdeps/unix/sysv/linux/fstat.c
>  create mode 100644 sysdeps/unix/sysv/linux/fstat64.c
>  create mode 100644 sysdeps/unix/sysv/linux/fstatat.c
>  create mode 100644 sysdeps/unix/sysv/linux/fstatat64.c
>  create mode 100644 sysdeps/unix/sysv/linux/lstat.c
>  create mode 100644 sysdeps/unix/sysv/linux/lstat64.c
>  create mode 100644 sysdeps/unix/sysv/linux/stat.c
>  create mode 100644 sysdeps/unix/sysv/linux/stat64.c
> 
> diff --git a/sysdeps/unix/sysv/linux/fstat.c
> b/sysdeps/unix/sysv/linux/fstat.c new file mode 100644
> index 0000000000..bdbeded956
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/fstat.c
> @@ -0,0 +1,31 @@
> +/* Get file status.  Linux version.
> +   Copyright (C) 2020 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 <kernel_stat.h>
> +#include <fcntl.h>
> +
> +#if !XSTAT_IS_XSTAT64
> +int
> +__fstat (int fd, struct stat *buf)
> +{
> +  return __fstatat (fd, "", buf, AT_EMPTY_PATH);
> +}
> +
> +weak_alias (__fstat, fstat)
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/fstat64.c
> b/sysdeps/unix/sysv/linux/fstat64.c new file mode 100644
> index 0000000000..c2ff1ff577
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/fstat64.c
> @@ -0,0 +1,38 @@
> +/* Get file status.  Linux version.
> +   Copyright (C) 2020 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 __fstat __redirect___fstat
> +#define fstat   __redirect_fstat
> +#include <sys/stat.h>
> +#undef __fstat
> +#undef fstat
> +#include <fcntl.h>
> +#include <kernel_stat.h>
> +
> +int
> +__fstat64 (int fd, struct stat64 *buf)
> +{
> +  return __fstatat64 (fd, "", buf, AT_EMPTY_PATH);
> +}
> +hidden_def (__fstat64)
> +weak_alias (__fstat64, fstat64)
> +
> +#if XSTAT_IS_XSTAT64
> +strong_alias (__fstat64, __fstat)
> +weak_alias (__fstat64, fstat)
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/fstatat.c
> b/sysdeps/unix/sysv/linux/fstatat.c new file mode 100644
> index 0000000000..457496605c
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/fstatat.c
> @@ -0,0 +1,30 @@
> +/* Get file status.  Linux version.
> +   Copyright (C) 2020 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 <kernel_stat.h>
> +
> +#if !XSTAT_IS_XSTAT64
> +int
> +__fstatat (int fd, const char *file, struct stat *buf, int flag)
> +{
> +  return __fxstatat (_STAT_VER, fd, file, buf, flag);
> +}
> +
> +weak_alias (__fstatat, fstatat)
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/fstatat64.c
> b/sysdeps/unix/sysv/linux/fstatat64.c new file mode 100644
> index 0000000000..46487919e6
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/fstatat64.c
> @@ -0,0 +1,38 @@
> +/* Get file status.  Linux version.
> +   Copyright (C) 2020 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 __fstatat __redirect___fstatat
> +#define fstatat   __redirect_fstatat
> +#include <sys/stat.h>
> +#undef __fstatat
> +#undef fstatat
> +#include <kernel_stat.h>
> +
> +int
> +__fstatat64 (int fd, const char *file, struct stat64 *buf, int flag)
> +{
> +  return __fxstatat64 (_STAT_VER, fd, file, buf, flag);
> +}
> +hidden_def (__fstatat64)
> +weak_alias (__fstatat64, fstatat64)
> +
> +#if XSTAT_IS_XSTAT64
> +strong_alias (__fstatat64, __fstatat)
> +weak_alias (__fstatat64, fstatat)
> +strong_alias (__fstatat64, __GI___fstatat);
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/lstat.c
> b/sysdeps/unix/sysv/linux/lstat.c new file mode 100644
> index 0000000000..b0bdeee9e9
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/lstat.c
> @@ -0,0 +1,31 @@
> +/* Get file status.  Linux version.
> +   Copyright (C) 2020 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 <fcntl.h>
> +#include <kernel_stat.h>
> +
> +#if !XSTAT_IS_XSTAT64
> +int
> +__lstat (const char *file, struct stat *buf)
> +{
> +  return __fstatat (AT_FDCWD, file, buf, AT_SYMLINK_NOFOLLOW);
> +}
> +
> +weak_alias (__lstat, lstat)
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/lstat64.c
> b/sysdeps/unix/sysv/linux/lstat64.c new file mode 100644
> index 0000000000..e5f02e9822
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/lstat64.c
> @@ -0,0 +1,38 @@
> +/* Get file status.
> +   Copyright (C) 1996-2020 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 __lstat __redirect___lstat
> +#define lstat   __redirect_lstat
> +#include <sys/stat.h>
> +#undef __lstat
> +#undef lstat
> +#include <fcntl.h>
> +#include <kernel_stat.h>
> +
> +int
> +__lstat64 (const char *file, struct stat64 *buf)
> +{
> +  return __fstatat64 (AT_FDCWD, file, buf, AT_SYMLINK_NOFOLLOW);
> +}
> +hidden_def (__lstat64)
> +weak_alias (__lstat64, lstat64)
> +
> +#if XSTAT_IS_XSTAT64
> +strong_alias (__lstat64, __lstat)
> +weak_alias (__lstat64, lstat)
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/stat.c
> b/sysdeps/unix/sysv/linux/stat.c new file mode 100644
> index 0000000000..a77502eb95
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/stat.c
> @@ -0,0 +1,31 @@
> +/* Get file status.  Linux version.
> +   Copyright (C) 2020 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 <fcntl.h>
> +#include <kernel_stat.h>
> +
> +#if !XSTAT_IS_XSTAT64
> +int
> +__stat (const char *file, struct stat *buf)
> +{
> +  return __fstatat (AT_FDCWD, file, buf, 0);
> +}
> +
> +weak_alias (__stat, stat)
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/stat64.c
> b/sysdeps/unix/sysv/linux/stat64.c new file mode 100644
> index 0000000000..2f40037c2c
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/stat64.c
> @@ -0,0 +1,38 @@
> +/* Get file status.  Linux version.
> +   Copyright (C) 2020 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 __redirect___stat
> +#define stat   __redirect_stat
> +#include <sys/stat.h>
> +#undef __stat
> +#undef stat
> +#include <fcntl.h>
> +#include <kernel_stat.h>
> +
> +int
> +__stat64 (const char *file, struct stat64 *buf)
> +{
> +  return __fstatat64 (AT_FDCWD, file, buf, 0);
> +}
> +hidden_def (__stat64)
> +weak_alias (__stat64, stat64)
> +
> +#if XSTAT_IS_XSTAT64
> +strong_alias (__stat64, __stat)
> +weak_alias (__stat64, stat)
> +#endif




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 13/16] linux: Disentangle fstatat from fxstatat
  2020-07-23 19:46 ` [PATCH 13/16] linux: Disentangle fstatat from fxstatat Adhemerval Zanella via Libc-alpha
@ 2020-07-24  9:39   ` Lukasz Majewski
  2020-07-24 10:25   ` Florian Weimer via Libc-alpha
  1 sibling, 0 replies; 80+ messages in thread
From: Lukasz Majewski @ 2020-07-24  9:39 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Alistair Francis, libc-alpha

[-- Attachment #1: Type: text/plain, Size: 26002 bytes --]

On Thu, 23 Jul 2020 16:46:38 -0300
Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> It implements all the requires syscall for the all Linux kABIS on
> fstatat{64} itself instead of calling fxstatat{64}.
> 
> On non-LFS implementation, it handles 3 cases:
> 
>   1. New kABIs which uses generic pre 64-bit time Linux ABI (csky and
>      nios): it issues __NR_fstat64 plus handle the overflow on st_ino,
>      st_size, or st_blocks.
> 
>   2. Old KABIs with old non-LFS support (arm, i386, hppa, m68k,
>      microblaze, mips32, s390, sh, powerpc, and sparc32): it issues
>      __NR_fstatat64 and convert the result to struct stat.
> 
>   3. 64-bit kABI outliers (mips64 and mips64-n32): it issues
>      __NR_newfstatat and convert the result to struct stat.
> 
> The generic LFS implementation handles multiple cases:
> 
>   1. XSTAT_IS_XSTAT64 being 1:
> 
>     1.1. 64-bit kABI (aarch64, ia64, powerpc64*, s390x, riscv64, and
>          x86_64): it issues __NR_newfstatat.
> 
>     1.2. 64-bit kABI outlier (alpha): it issues __NR_fstatat64.
> 
>     1.3. 64-bit kABI outlier where struct stat64 does not match kernel
>          one (sparc64): it issues __NR_fstatat64 and convert the
> result to struct stat64.
> 
>     1.4. 32-bit kABI with default 64-bit time_t (arc, riscv32): it
>          issues __NR_statx and convert the result to struct stat64.
> 
>   2. Old ABIs with XSTAT_IS_XSTAT64 being 0:
> 
>     2.1. All kABIs with non-LFS support (arm, csky, i386, hppa, m68k,
>          microblaze, nios2, sh, powerpc32, and sparc32): it issues
>          __NR_fstatat64.
> 
>     2.2. 64-bit kABI outliers (mips64 and mips64-n32): it issues
>          __NR_newfstatat and convert the result to struct stat64.
> 
> It allows to remove all the hidden definitions from the {f,l}xstat{64}
> (some are still kept because Hurd requires it).
> 
> Checked with a build for all affected ABIs. I also checked on x86_64,
> i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and s390x.

Reviewed-by: Lukasz Majewski <lukma@denx.de>

> ---
>  include/sys/stat.h                            | 32 ++++++--
>  sysdeps/unix/sysv/linux/alpha/fxstat64.c      |  2 -
>  sysdeps/unix/sysv/linux/alpha/fxstatat64.c    |  4 -
>  sysdeps/unix/sysv/linux/alpha/lxstat64.c      |  3 -
>  sysdeps/unix/sysv/linux/alpha/xstat64.c       |  3 -
>  sysdeps/unix/sysv/linux/fstatat.c             | 56 ++++++++++++-
>  sysdeps/unix/sysv/linux/fstatat64.c           | 45 ++++++++++-
>  sysdeps/unix/sysv/linux/fxstat.c              |  1 -
>  sysdeps/unix/sysv/linux/fxstat64.c            |  3 -
>  sysdeps/unix/sysv/linux/fxstatat.c            |  2 -
>  sysdeps/unix/sysv/linux/fxstatat64.c          |  4 +-
>  sysdeps/unix/sysv/linux/kstat_cp.h            |  2 +
>  sysdeps/unix/sysv/linux/lxstat.c              |  1 -
>  sysdeps/unix/sysv/linux/lxstat64.c            |  2 -
>  sysdeps/unix/sysv/linux/mips/fxstat.c         |  1 -
>  sysdeps/unix/sysv/linux/mips/lxstat.c         |  1 -
>  .../unix/sysv/linux/mips/mips64/fxstat64.c    |  2 -
>  .../unix/sysv/linux/mips/mips64/fxstatat.c    |  1 -
>  .../unix/sysv/linux/mips/mips64/fxstatat64.c  |  1 -
>  .../unix/sysv/linux/mips/mips64/kstat_cp.h    | 80
> +++++++++++++++++++ .../unix/sysv/linux/mips/mips64/lxstat64.c    |
> 2 - sysdeps/unix/sysv/linux/mips/mips64/xstat64.c |  2 -
>  sysdeps/unix/sysv/linux/mips/xstat.c          |  1 -
>  .../unix/sysv/linux/sparc/sparc64/kstat_cp.h  | 46 +++++++++++
>  sysdeps/unix/sysv/linux/xstat.c               |  1 -
>  sysdeps/unix/sysv/linux/xstat64.c             |  2 -
>  26 files changed, 253 insertions(+), 47 deletions(-)
>  create mode 100644 sysdeps/unix/sysv/linux/kstat_cp.h
>  create mode 100644 sysdeps/unix/sysv/linux/mips/mips64/kstat_cp.h
>  create mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/kstat_cp.h
> 
> diff --git a/include/sys/stat.h b/include/sys/stat.h
> index 04b825df4a..199173b007 100644
> --- a/include/sys/stat.h
> +++ b/include/sys/stat.h
> @@ -3,6 +3,28 @@
>  
>  #ifndef _ISOMAC
>  # include <xstatver.h>
> +# include <stdbool.h>
> +
> +static inline bool
> +in_ino_t_range (__ino64_t v)
> +{
> +  __ino_t s = v;
> +  return s == v;
> +}
> +
> +static inline bool
> +in_off_t_range (__off64_t v)
> +{
> +  __off_t s = v;
> +  return s == v;
> +}
> +
> +static inline bool
> +in_blkcnt_t_range (__blkcnt64_t v)
> +{
> +  __blkcnt_t s = v;
> +  return s == v;
> +}
>  
>  /* Now define the internal interfaces. */
>  extern int __stat (const char *__file, struct stat *__buf);
> @@ -54,19 +76,19 @@ int __xstat64 (int ver, const char *__filename,
> struct stat64 *__stat_buf); int __lxstat64 (int ver, const char
> *__filename, struct stat64 *__stat_buf); int __fxstatat64 (int ver,
> int __fildes, const char *__filename, struct stat64 *__stat_buf, int
> __flag); +
> +# ifdef NO_RTLD_HIDDEN
> +/* These are still required for Hurd.  */
>  libc_hidden_proto (__fxstat);
>  libc_hidden_proto (__xstat);
>  libc_hidden_proto (__lxstat);
>  libc_hidden_proto (__fxstatat);
> -# if IS_IN (libc) || (IS_IN (rtld) && !defined NO_RTLD_HIDDEN)
> +#  if IS_IN (libc)
>  hidden_proto (__fxstat64);
>  hidden_proto (__xstat64);
>  hidden_proto (__lxstat64);
>  hidden_proto (__fxstatat64);
> -# endif
> -
> -# ifdef NO_RTLD_HIDDEN
> -/* These are still required for Hurd.  */
> +#  endif
>  #  define stat(fname, buf) __xstat (_STAT_VER, fname, buf)
>  #  define lstat(fname, buf)  __lxstat (_STAT_VER, fname, buf)
>  #  define __lstat(fname, buf)  __lxstat (_STAT_VER, fname, buf)
> diff --git a/sysdeps/unix/sysv/linux/alpha/fxstat64.c
> b/sysdeps/unix/sysv/linux/alpha/fxstat64.c index
> 286a2f0a6c..9d6b8eca32 100644 ---
> a/sysdeps/unix/sysv/linux/alpha/fxstat64.c +++
> b/sysdeps/unix/sysv/linux/alpha/fxstat64.c @@ -42,6 +42,4 @@
> __fxstat64 (int vers, int fd, struct stat64 *buf) }
>      }
>  }
> -hidden_def (__fxstat64)
>  strong_alias (__fxstat64, __fxstat);
> -hidden_ver (__fxstat64, __fxstat)
> diff --git a/sysdeps/unix/sysv/linux/alpha/fxstatat64.c
> b/sysdeps/unix/sysv/linux/alpha/fxstatat64.c index
> f10c1d31e8..997fb87ac6 100644 ---
> a/sysdeps/unix/sysv/linux/alpha/fxstatat64.c +++
> b/sysdeps/unix/sysv/linux/alpha/fxstatat64.c @@ -29,8 +29,4 @@
> __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st,
> int flag) { return INLINE_SYSCALL_CALL (fstatat64, fd, file, st,
> flag); }
> -libc_hidden_def (__fxstatat64)
> -#if IS_IN(libc)
>  strong_alias (__fxstatat64, __fxstatat);
> -hidden_ver (__fxstatat64, __fxstatat)
> -#endif
> diff --git a/sysdeps/unix/sysv/linux/alpha/lxstat64.c
> b/sysdeps/unix/sysv/linux/alpha/lxstat64.c index
> 90dc0c7ce7..38f132f15e 100644 ---
> a/sysdeps/unix/sysv/linux/alpha/lxstat64.c +++
> b/sysdeps/unix/sysv/linux/alpha/lxstat64.c @@ -44,6 +44,3 @@
> __lxstat64 (int vers, const char *name, struct stat64 *buf) }
>  }
>  weak_alias (__lxstat64, __lxstat);
> -weak_alias (__lxstat64, __GI___lxstat);
> -
> -hidden_def (__lxstat64)
> diff --git a/sysdeps/unix/sysv/linux/alpha/xstat64.c
> b/sysdeps/unix/sysv/linux/alpha/xstat64.c index
> ac1af53780..c856c95dc5 100644 ---
> a/sysdeps/unix/sysv/linux/alpha/xstat64.c +++
> b/sysdeps/unix/sysv/linux/alpha/xstat64.c @@ -44,6 +44,3 @@ __xstat64
> (int vers, const char *name, struct stat64 *buf) }
>  }
>  weak_alias (__xstat64, __xstat);
> -weak_alias (__xstat64, __GI___xstat);
> -
> -hidden_def (__xstat64)
> diff --git a/sysdeps/unix/sysv/linux/fstatat.c
> b/sysdeps/unix/sysv/linux/fstatat.c index 457496605c..03ddb3f493
> 100644 --- a/sysdeps/unix/sysv/linux/fstatat.c
> +++ b/sysdeps/unix/sysv/linux/fstatat.c
> @@ -18,12 +18,64 @@
>  
>  #include <sys/stat.h>
>  #include <kernel_stat.h>
> +#include <sysdep.h>
>  
>  #if !XSTAT_IS_XSTAT64
> +# include <kstat_cp.h>
> +
>  int
> -__fstatat (int fd, const char *file, struct stat *buf, int flag)
> +__fstatat (int fd, const char *file, struct stat *st, int flag)
>  {
> -  return __fxstatat (_STAT_VER, fd, file, buf, flag);
> +# if STAT_IS_KERNEL_STAT
> +  /* New kABIs which uses generic pre 64-bit time Linux ABI, e.g.
> +     csky, nios2  */
> +  int r = INLINE_SYSCALL_CALL (fstatat64, fd, file, st, flag);
> +  if (r == 0 && (st->__st_ino_pad != 0
> +		 || st->__st_size_pad != 0
> +		 || st->__st_blocks_pad != 0))
> +    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW);
> +  return r;
> +# else
> +#  ifdef __NR_fstatat64
> +  /* Old KABIs with old non-LFS support, e.g. arm, i386, hppa, m68k,
> mips32,
> +     microblaze, s390, sh, powerpc, and sparc.  */
> +  struct stat64 st64;
> +  int r = INLINE_SYSCALL_CALL (fstatat64, fd, file, &st64, flag);
> +  if (r == 0)
> +    {
> +      if (! in_ino_t_range (st64.st_ino)
> +	  || ! in_off_t_range (st64.st_size)
> +	  || ! in_blkcnt_t_range (st64.st_blocks))
> +	return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW);
> +
> +      /* Clear internal pad and reserved fields.  */
> +      memset (st, 0, sizeof (*st));
> +
> +      st->st_dev = st64.st_dev,
> +      st->st_ino = st64.st_ino;
> +      st->st_mode = st64.st_mode;
> +      st->st_nlink = st64.st_nlink;
> +      st->st_uid = st64.st_uid;
> +      st->st_gid = st64.st_gid;
> +      st->st_rdev = st64.st_rdev;
> +      st->st_size = st64.st_size;
> +      st->st_blksize = st64.st_blksize;
> +      st->st_blocks  = st64.st_blocks;
> +      st->st_atim.tv_sec = st64.st_atim.tv_sec;
> +      st->st_atim.tv_nsec = st64.st_atim.tv_nsec;
> +      st->st_mtim.tv_sec = st64.st_mtim.tv_sec;
> +      st->st_mtim.tv_nsec = st64.st_mtim.tv_nsec;
> +      st->st_ctim.tv_sec = st64.st_ctim.tv_sec;
> +      st->st_ctim.tv_nsec = st64.st_ctim.tv_nsec;
> +    }
> +  return r;
> +#  else
> +  /* 64-bit kabi outlier, e.g. mips64 and mips64-n32.  */
> +  struct kernel_stat kst;
> +  int r = INTERNAL_SYSCALL_CALL (newfstatat, fd, file, &kst, flag);
> +  return r ?: __cp_kstat_stat (&kst, st);
> +#  endif /* __nr_fstatat64  */
> +# endif /* STAT_IS_KERNEL_STAT  */
>  }
>  
>  weak_alias (__fstatat, fstatat)
> diff --git a/sysdeps/unix/sysv/linux/fstatat64.c
> b/sysdeps/unix/sysv/linux/fstatat64.c index 46487919e6..82fab107a5
> 100644 --- a/sysdeps/unix/sysv/linux/fstatat64.c
> +++ b/sysdeps/unix/sysv/linux/fstatat64.c
> @@ -21,12 +21,53 @@
>  #include <sys/stat.h>
>  #undef __fstatat
>  #undef fstatat
> +#include <fcntl.h>
> +
>  #include <kernel_stat.h>
> +#include <sysdep.h>
> +
> +#include <statx_cp.h>
> +#include <kstat_cp.h>
>  
>  int
> -__fstatat64 (int fd, const char *file, struct stat64 *buf, int flag)
> +__fstatat64 (int fd, const char *file, struct stat64 *st, int flag)
>  {
> -  return __fxstatat64 (_STAT_VER, fd, file, buf, flag);
> +#if XSTAT_IS_XSTAT64
> +# ifdef __NR_newfstatat
> +  /* 64-bit kABI, e.g. aarch64, ia64, powerpc64*, s390x, riscv64, and
> +     x86_64.  */
> +  return INLINE_SYSCALL_CALL (newfstatat, fd, file, st, flag);
> +# elif defined __NR_fstatat64
> +#  if STAT64_IS_KERNEL_STAT64
> +  /* 64-bit kABI outlier, e.g. alpha.  */
> +  return INLINE_SYSCALL_CALL (fstatat64, fd, file, st, flag);
> +#  else
> +  /* 64-bit kABI outlier, e.g. sparc64.  */
> +  struct kernel_stat64 kst64;
> +  int r = INLINE_SYSCALL_CALL (fstatat64, fd, file, &kst64, flag);
> +  return r ?: __cp_stat64_kstat64 (st, &kst64);
> +#  endif
> +# else
> +  /* 32-bit kABI with default 64-bit time_t, e.g. arc, riscv32.  */
> +  struct statx tmp;
> +  int r = INLINE_SYSCALL_CALL (statx, fd, file, AT_NO_AUTOMOUNT |
> flag,
> +			       STATX_BASIC_STATS, &tmp);
> +  if (r == 0)
> +    __cp_stat64_statx (st, &tmp);
> +  return r;
> +# endif
> +#else
> +# ifdef __NR_fstatat64
> +  /* All kABIs with non-LFS support, e.g. arm, csky, i386, hppa,
> m68k,
> +     microblaze, nios2, sh, powerpc32, and sparc32.  */
> +  return INLINE_SYSCALL_CALL (fstatat64, fd, file, st, flag);
> +# else
> +  /* 64-bit kabi outlier, e.g. mips64 and mips64-n32.  */
> +  struct kernel_stat kst;
> +  int r = INTERNAL_SYSCALL_CALL (newfstatat, fd, file, &kst, flag);
> +  return r ?: __cp_kstat_stat64 (&kst, st);
> +# endif
> +#endif
>  }
>  hidden_def (__fstatat64)
>  weak_alias (__fstatat64, fstatat64)
> diff --git a/sysdeps/unix/sysv/linux/fxstat.c
> b/sysdeps/unix/sysv/linux/fxstat.c index b46e344d0e..f78497ea92 100644
> --- a/sysdeps/unix/sysv/linux/fxstat.c
> +++ b/sysdeps/unix/sysv/linux/fxstat.c
> @@ -57,5 +57,4 @@ __fxstat (int vers, int fd, struct stat *buf)
>        }
>      }
>  }
> -hidden_def (__fxstat)
>  #endif /* XSTAT_IS_XSTAT64  */
> diff --git a/sysdeps/unix/sysv/linux/fxstat64.c
> b/sysdeps/unix/sysv/linux/fxstat64.c index d3834f1ce2..6ae7babccc
> 100644 --- a/sysdeps/unix/sysv/linux/fxstat64.c
> +++ b/sysdeps/unix/sysv/linux/fxstat64.c
> @@ -59,13 +59,10 @@ ___fxstat64 (int vers, int fd, struct stat64 *buf)
>  versioned_symbol (libc, ___fxstat64, __fxstat64, GLIBC_2_2);
>  strong_alias (___fxstat64, __old__fxstat64)
>  compat_symbol (libc, __old__fxstat64, __fxstat64, GLIBC_2_1);
> -hidden_ver (___fxstat64, __fxstat64)
>  #else
>  strong_alias (___fxstat64, __fxstat64)
> -hidden_def (__fxstat64)
>  #endif
>  
>  #if XSTAT_IS_XSTAT64
>  strong_alias (__fxstat64, __fxstat);
> -hidden_ver (__fxstat64, __fxstat)
>  #endif
> diff --git a/sysdeps/unix/sysv/linux/fxstatat.c
> b/sysdeps/unix/sysv/linux/fxstatat.c index 0291a2c598..1a60fc10e3
> 100644 --- a/sysdeps/unix/sysv/linux/fxstatat.c
> +++ b/sysdeps/unix/sysv/linux/fxstatat.c
> @@ -46,6 +46,4 @@ __fxstatat (int vers, int fd, const char *file,
> struct stat *st, int flag) return r ?: __xstat32_conv (vers, &st64,
> st); #endif
>  }
> -libc_hidden_def (__fxstatat)
> -
>  #endif /* XSTAT_IS_XSTAT64  */
> diff --git a/sysdeps/unix/sysv/linux/fxstatat64.c
> b/sysdeps/unix/sysv/linux/fxstatat64.c index ac33ab4fc9..7fe034809c
> 100644 --- a/sysdeps/unix/sysv/linux/fxstatat64.c
> +++ b/sysdeps/unix/sysv/linux/fxstatat64.c
> @@ -61,8 +61,6 @@ __fxstatat64 (int vers, int fd, const char *file,
> struct stat64 *st, int flag) #endif
>    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
>  }
> -libc_hidden_def (__fxstatat64)
> -#if XSTAT_IS_XSTAT64 && IS_IN(libc)
> +#if XSTAT_IS_XSTAT64
>  strong_alias (__fxstatat64, __fxstatat);
> -hidden_ver (__fxstatat64, __fxstatat)
>  #endif
> diff --git a/sysdeps/unix/sysv/linux/kstat_cp.h
> b/sysdeps/unix/sysv/linux/kstat_cp.h new file mode 100644
> index 0000000000..8fa43ed2e1
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/kstat_cp.h
> @@ -0,0 +1,2 @@
> +/* Empty, it is overridden by an architecture which might require
> copy to ro
> +   from a kernel_stat stat struct to glibc export stat{64}.  */
> diff --git a/sysdeps/unix/sysv/linux/lxstat.c
> b/sysdeps/unix/sysv/linux/lxstat.c index dc63d20061..156173a4e1 100644
> --- a/sysdeps/unix/sysv/linux/lxstat.c
> +++ b/sysdeps/unix/sysv/linux/lxstat.c
> @@ -58,5 +58,4 @@ __lxstat (int vers, const char *name, struct stat
> *buf) }
>      }
>  }
> -hidden_def (__lxstat)
>  #endif /* XSTAT_IS_XSTAT64  */
> diff --git a/sysdeps/unix/sysv/linux/lxstat64.c
> b/sysdeps/unix/sysv/linux/lxstat64.c index 375013e9b1..29bd1cdf72
> 100644 --- a/sysdeps/unix/sysv/linux/lxstat64.c
> +++ b/sysdeps/unix/sysv/linux/lxstat64.c
> @@ -81,8 +81,6 @@ weak_alias (___lxstat64, __GI___lxstat);
>  versioned_symbol (libc, ___lxstat64, __lxstat64, GLIBC_2_2);
>  strong_alias (___lxstat64, __old__lxstat64)
>  compat_symbol (libc, __old__lxstat64, __lxstat64, GLIBC_2_1);
> -hidden_ver (___lxstat64, __lxstat64)
>  #else
>  strong_alias (___lxstat64, __lxstat64);
> -hidden_def (__lxstat64)
>  #endif
> diff --git a/sysdeps/unix/sysv/linux/mips/fxstat.c
> b/sysdeps/unix/sysv/linux/mips/fxstat.c index 16c3cefee2..4585c2362b
> 100644 --- a/sysdeps/unix/sysv/linux/mips/fxstat.c
> +++ b/sysdeps/unix/sysv/linux/mips/fxstat.c
> @@ -39,4 +39,3 @@ __fxstat (int vers, int fd, struct stat *buf)
>        }
>      }
>  }
> -hidden_def (__fxstat)
> diff --git a/sysdeps/unix/sysv/linux/mips/lxstat.c
> b/sysdeps/unix/sysv/linux/mips/lxstat.c index eb07549adf..62a3b15b32
> 100644 --- a/sysdeps/unix/sysv/linux/mips/lxstat.c
> +++ b/sysdeps/unix/sysv/linux/mips/lxstat.c
> @@ -39,4 +39,3 @@ __lxstat (int vers, const char *name, struct stat
> *buf) }
>      }
>  }
> -hidden_def (__lxstat)
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/fxstat64.c
> b/sysdeps/unix/sysv/linux/mips/mips64/fxstat64.c index
> 3fcdd9f1ee..e6c1cacd4b 100644 ---
> a/sysdeps/unix/sysv/linux/mips/mips64/fxstat64.c +++
> b/sysdeps/unix/sysv/linux/mips/mips64/fxstat64.c @@ -31,5 +31,3 @@
> __fxstat64 (int vers, int fd, struct stat64 *buf) return r ?:
> __xstat64_conv (vers, &kbuf, buf); 
>  }
> -
> -hidden_def (__fxstat64)
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/fxstatat.c
> b/sysdeps/unix/sysv/linux/mips/mips64/fxstatat.c index
> 58410a1441..e384dbab8b 100644 ---
> a/sysdeps/unix/sysv/linux/mips/mips64/fxstatat.c +++
> b/sysdeps/unix/sysv/linux/mips/mips64/fxstatat.c @@ -30,4 +30,3 @@
> __fxstatat (int vers, int fd, const char *file, struct stat *st, int
> flag) int r = INLINE_SYSCALL_CALL (newfstatat, fd, file, &kst, flag);
> return r ?: __xstat_conv (vers, &kst, st); }
> -libc_hidden_def (__fxstatat)
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c
> b/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c index
> e5416d8971..cfd172d301 100644 ---
> a/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c +++
> b/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c @@ -33,4 +33,3 @@
> __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st,
> int flag) } return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
>  }
> -libc_hidden_def (__fxstatat64)
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/kstat_cp.h
> b/sysdeps/unix/sysv/linux/mips/mips64/kstat_cp.h new file mode 100644
> index 0000000000..7f226416f9
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/mips/mips64/kstat_cp.h
> @@ -0,0 +1,80 @@
> +/* Struct stat/stat64 to stat/stat64 conversion for Linux.
> +   Copyright (C) 2020 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 <kernel_stat.h>
> +
> +static inline int
> +__cp_kstat_stat (const struct kernel_stat *kst, struct stat *st)
> +{
> +  st->st_dev = kst->st_dev;
> +  memset (&st->st_pad1, 0, sizeof (st->st_pad1));
> +  st->st_ino = kst->st_ino;
> +  if (st->st_ino != kst->st_ino)
> +    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW);
> +  st->st_mode = kst->st_mode;
> +  st->st_nlink = kst->st_nlink;
> +  st->st_uid = kst->st_uid;
> +  st->st_gid = kst->st_gid;
> +  st->st_rdev = kst->st_rdev;
> +  memset (&st->st_pad2, 0, sizeof (st->st_pad2));
> +  st->st_size = kst->st_size;
> +  if (st->st_size != kst->st_size)
> +    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW);
> +  st->st_pad3 = 0;
> +  st->st_atim.tv_sec = kst->st_atime_sec;
> +  st->st_atim.tv_nsec = kst->st_atime_nsec;
> +  st->st_mtim.tv_sec = kst->st_mtime_sec;
> +  st->st_mtim.tv_nsec = kst->st_mtime_nsec;
> +  st->st_ctim.tv_sec = kst->st_ctime_sec;
> +  st->st_ctim.tv_nsec = kst->st_ctime_nsec;
> +  st->st_blksize = kst->st_blksize;
> +  st->st_blocks = kst->st_blocks;
> +  if (st->st_blocks != kst->st_blocks)
> +    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW);
> +  memset (&st->st_pad5, 0, sizeof (st->st_pad5));
> +
> +  return 0;
> +}
> +
> +static inline int
> +__cp_kstat_stat64 (const struct kernel_stat *kst, struct stat64 *st)
> +{
> +  st->st_dev = kst->st_dev;
> +  memset (&st->st_pad1, 0, sizeof (st->st_pad1));
> +  st->st_ino = kst->st_ino;
> +  st->st_mode = kst->st_mode;
> +  st->st_nlink = kst->st_nlink;
> +  st->st_uid = kst->st_uid;
> +  st->st_gid = kst->st_gid;
> +  st->st_rdev = kst->st_rdev;
> +  memset (&st->st_pad2, 0, sizeof (st->st_pad2));
> +  st->st_pad3 = 0;
> +  st->st_size = kst->st_size;
> +  st->st_blksize = kst->st_blksize;
> +  st->st_blocks = kst->st_blocks;
> +  st->st_atim.tv_sec = kst->st_atime_sec;
> +  st->st_atim.tv_nsec = kst->st_atime_nsec;
> +  st->st_mtim.tv_sec = kst->st_mtime_sec;
> +  st->st_mtim.tv_nsec = kst->st_mtime_nsec;
> +  st->st_ctim.tv_sec = kst->st_ctime_sec;
> +  st->st_ctim.tv_nsec = kst->st_ctime_nsec;
> +  memset (&st->st_pad4, 0, sizeof (st->st_pad4));
> +
> +  return 0;
> +}
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/lxstat64.c
> b/sysdeps/unix/sysv/linux/mips/mips64/lxstat64.c index
> 28bac57e58..0f3934f8c8 100644 ---
> a/sysdeps/unix/sysv/linux/mips/mips64/lxstat64.c +++
> b/sysdeps/unix/sysv/linux/mips/mips64/lxstat64.c @@ -29,5 +29,3 @@
> __lxstat64 (int vers, const char *name, struct stat64 *buf) int r =
> INLINE_SYSCALL_CALL (lstat, name, &kbuf); return r ?: __xstat64_conv
> (vers, &kbuf, buf); }
> -
> -hidden_def (__lxstat64)
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/xstat64.c
> b/sysdeps/unix/sysv/linux/mips/mips64/xstat64.c index
> 99b03c7593..64d2952276 100644 ---
> a/sysdeps/unix/sysv/linux/mips/mips64/xstat64.c +++
> b/sysdeps/unix/sysv/linux/mips/mips64/xstat64.c @@ -30,5 +30,3 @@
> __xstat64 (int vers, const char *name, struct stat64 *buf) int r =
> INLINE_SYSCALL_CALL (stat, name, &kbuf); return r ?: __xstat64_conv
> (vers, &kbuf, buf); }
> -
> -hidden_def (__xstat64)
> diff --git a/sysdeps/unix/sysv/linux/mips/xstat.c
> b/sysdeps/unix/sysv/linux/mips/xstat.c index 835691cf89..d6ff5ccbe0
> 100644 --- a/sysdeps/unix/sysv/linux/mips/xstat.c
> +++ b/sysdeps/unix/sysv/linux/mips/xstat.c
> @@ -39,4 +39,3 @@ __xstat (int vers, const char *name, struct stat
> *buf) }
>      }
>  }
> -hidden_def (__xstat)
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/kstat_cp.h
> b/sysdeps/unix/sysv/linux/sparc/sparc64/kstat_cp.h new file mode
> 100644 index 0000000000..0599b6a49e
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/kstat_cp.h
> @@ -0,0 +1,46 @@
> +/* Struct kernel_stat64 to stat64.  Linux/SPARC version.
> +   Copyright (C) 2020 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 <errno.h>
> +
> +static inline int
> +__cp_stat64_kstat64 (struct stat64 *st64, const struct kernel_stat64
> *kst64) +{
> +  st64->st_dev = kst64->st_dev;
> +  st64->__pad1 = 0;
> +  st64->st_ino = kst64->st_ino;
> +  st64->st_mode = kst64->st_mode;
> +  st64->st_nlink = kst64->st_nlink;
> +  st64->st_uid = kst64->st_uid;
> +  st64->st_gid = kst64->st_gid;
> +  st64->st_rdev = kst64->st_rdev;
> +  st64->__pad2 = 0;
> +  st64->st_size = kst64->st_size;
> +  st64->st_blksize = kst64->st_blksize;
> +  st64->st_blocks = kst64->st_blocks;
> +  st64->st_atim.tv_sec = kst64->st_atime_sec;
> +  st64->st_atim.tv_nsec = kst64->st_atime_nsec;
> +  st64->st_mtim.tv_sec = kst64->st_mtime_sec;
> +  st64->st_mtim.tv_nsec = kst64->st_mtime_nsec;
> +  st64->st_ctim.tv_sec = kst64->st_ctime_sec;
> +  st64->st_ctim.tv_nsec = kst64->st_ctime_nsec;
> +  st64->__glibc_reserved4 = 0;
> +  st64->__glibc_reserved5 = 0;
> +
> +  return 0;
> +}
> diff --git a/sysdeps/unix/sysv/linux/xstat.c
> b/sysdeps/unix/sysv/linux/xstat.c index 0ae52b1901..a971e8cf6a 100644
> --- a/sysdeps/unix/sysv/linux/xstat.c
> +++ b/sysdeps/unix/sysv/linux/xstat.c
> @@ -57,5 +57,4 @@ __xstat (int vers, const char *name, struct stat
> *buf) }
>      }
>  }
> -hidden_def (__xstat)
>  #endif /* XSTAT_IS_XSTAT64  */
> diff --git a/sysdeps/unix/sysv/linux/xstat64.c
> b/sysdeps/unix/sysv/linux/xstat64.c index 4feb55f429..e3a42966f5
> 100644 --- a/sysdeps/unix/sysv/linux/xstat64.c
> +++ b/sysdeps/unix/sysv/linux/xstat64.c
> @@ -78,8 +78,6 @@ weak_alias (___xstat64, __GI___xstat);
>  versioned_symbol (libc, ___xstat64, __xstat64, GLIBC_2_2);
>  strong_alias (___xstat64, __old__xstat64)
>  compat_symbol (libc, __old__xstat64, __xstat64, GLIBC_2_1);
> -hidden_ver (___xstat64, __xstat64)
>  #else
>  strong_alias (___xstat64, __xstat64)
> -hidden_def (__xstat64)
>  #endif




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 14/16] linux: Move {f}xstat{at} to compat symbols
  2020-07-23 19:46 ` [PATCH 14/16] linux: Move {f}xstat{at} to compat symbols Adhemerval Zanella via Libc-alpha
@ 2020-07-24  9:40   ` Lukasz Majewski
  2020-10-21  5:21   ` __xstat et al. as compat symbols (was: Re: [PATCH 14/16] linux: Move {f}xstat{at} to compat symbols) Florian Weimer via Libc-alpha
  1 sibling, 0 replies; 80+ messages in thread
From: Lukasz Majewski @ 2020-07-24  9:40 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Alistair Francis, libc-alpha

[-- Attachment #1: Type: text/plain, Size: 21579 bytes --]

On Thu, 23 Jul 2020 16:46:39 -0300
Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> They are not used internally anymore.
> 
> Checked with a build for all affected Linux ABIs.  I checked also
> on x86_64-linux-gnu and i686-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>

> ---
>  sysdeps/unix/sysv/linux/alpha/fxstat64.c      | 12 ++++++++++-
>  sysdeps/unix/sysv/linux/alpha/fxstatat64.c    |  9 +++++++-
>  sysdeps/unix/sysv/linux/alpha/lxstat64.c      | 12 ++++++++++-
>  sysdeps/unix/sysv/linux/alpha/xstat64.c       | 12 ++++++++++-
>  sysdeps/unix/sysv/linux/fxstat.c              |  8 +++++++
>  sysdeps/unix/sysv/linux/fxstat64.c            | 14 +++++++++----
>  sysdeps/unix/sysv/linux/fxstatat.c            |  8 +++++++
>  sysdeps/unix/sysv/linux/fxstatat64.c          | 12 ++++++++++-
>  sysdeps/unix/sysv/linux/lxstat.c              |  8 +++++++
>  sysdeps/unix/sysv/linux/lxstat64.c            | 21
> ++++++++++++------- sysdeps/unix/sysv/linux/mips/fxstat.c         |
> 8 +++++++ sysdeps/unix/sysv/linux/mips/lxstat.c         |  8 +++++++
>  .../unix/sysv/linux/mips/mips64/fxstat64.c    |  8 +++++++
>  .../unix/sysv/linux/mips/mips64/fxstatat.c    |  8 +++++++
>  .../unix/sysv/linux/mips/mips64/fxstatat64.c  |  8 +++++++
>  .../unix/sysv/linux/mips/mips64/lxstat64.c    |  8 +++++++
>  sysdeps/unix/sysv/linux/mips/mips64/xstat64.c |  9 +++++++-
>  sysdeps/unix/sysv/linux/mips/xstat.c          |  8 +++++++
>  sysdeps/unix/sysv/linux/xstat.c               |  9 ++++++++
>  sysdeps/unix/sysv/linux/xstat64.c             | 15 ++++++++-----
>  20 files changed, 182 insertions(+), 23 deletions(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/alpha/fxstat64.c
> b/sysdeps/unix/sysv/linux/alpha/fxstat64.c index
> 9d6b8eca32..bcfb55050c 100644 ---
> a/sysdeps/unix/sysv/linux/alpha/fxstat64.c +++
> b/sysdeps/unix/sysv/linux/alpha/fxstat64.c @@ -22,9 +22,11 @@
>  #include <kernel_stat.h>
>  #include <sysdep.h>
>  #include <xstatconv.h>
> +#include <shlib-compat.h>
>  
>  /* Get information about the file NAME in BUF.  */
>  int
> +attribute_compat_text_section
>  __fxstat64 (int vers, int fd, struct stat64 *buf)
>  {
>    switch (vers)
> @@ -42,4 +44,12 @@ __fxstat64 (int vers, int fd, struct stat64 *buf)
>        }
>      }
>  }
> -strong_alias (__fxstat64, __fxstat);
> +
> +#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
> +strong_alias (__fxstat64, __fxstat_compat)
> +compat_symbol (libc, __fxstat_compat, __fxstat, GLIBC_2_0);
> +#endif
> +
> +#if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_33)
> +compat_symbol (libc, __fxstat64, __fxstat64, GLIBC_2_1);
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/alpha/fxstatat64.c
> b/sysdeps/unix/sysv/linux/alpha/fxstatat64.c index
> 997fb87ac6..fa3074eeca 100644 ---
> a/sysdeps/unix/sysv/linux/alpha/fxstatat64.c +++
> b/sysdeps/unix/sysv/linux/alpha/fxstatat64.c @@ -22,11 +22,18 @@
>  #include <kernel_stat.h>
>  #include <sysdep.h>
>  #include <xstatconv.h>
> +#include <shlib-compat.h>
>  
> +#if SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
>  /* Get information about the file NAME in BUF.  */
>  int
> +attribute_compat_text_section
>  __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st,
> int flag) {
>    return INLINE_SYSCALL_CALL (fstatat64, fd, file, st, flag);
>  }
> -strong_alias (__fxstatat64, __fxstatat);
> +strong_alias (__fxstatat64, __fxstatat_compat)
> +compat_symbol (libc, __fxstatat_compat, __fxstatat, GLIBC_2_4);
> +
> +compat_symbol (libc, __fxstatat64, __fxstatat64, GLIBC_2_4);
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/alpha/lxstat64.c
> b/sysdeps/unix/sysv/linux/alpha/lxstat64.c index
> 38f132f15e..7424b2f621 100644 ---
> a/sysdeps/unix/sysv/linux/alpha/lxstat64.c +++
> b/sysdeps/unix/sysv/linux/alpha/lxstat64.c @@ -23,9 +23,11 @@
>  #include <kernel_stat.h>
>  #include <sysdep.h>
>  #include <xstatconv.h>
> +#include <shlib-compat.h>
>  
>  /* Get information about the file NAME in BUF.  */
>  int
> +attribute_compat_text_section
>  __lxstat64 (int vers, const char *name, struct stat64 *buf)
>  {
>    switch (vers)
> @@ -43,4 +45,12 @@ __lxstat64 (int vers, const char *name, struct
> stat64 *buf) }
>      }
>  }
> -weak_alias (__lxstat64, __lxstat);
> +
> +#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
> +strong_alias (__lxstat64, __lxstat_compat)
> +compat_symbol (libc, __lxstat_compat, __lxstat, GLIBC_2_0);
> +#endif
> +
> +#if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_33)
> +compat_symbol (libc, __lxstat64, __lxstat64, GLIBC_2_1);
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/alpha/xstat64.c
> b/sysdeps/unix/sysv/linux/alpha/xstat64.c index
> c856c95dc5..59f7ddae7f 100644 ---
> a/sysdeps/unix/sysv/linux/alpha/xstat64.c +++
> b/sysdeps/unix/sysv/linux/alpha/xstat64.c @@ -23,9 +23,11 @@
>  #include <kernel_stat.h>
>  #include <sysdep.h>
>  #include <xstatconv.h>
> +#include <shlib-compat.h>
>  
>  /* Get information about the file NAME in BUF.  */
>  int
> +attribute_compat_text_section
>  __xstat64 (int vers, const char *name, struct stat64 *buf)
>  {
>    switch (vers)
> @@ -43,4 +45,12 @@ __xstat64 (int vers, const char *name, struct
> stat64 *buf) }
>      }
>  }
> -weak_alias (__xstat64, __xstat);
> +
> +#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
> +strong_alias (__xstat64, __xstat_compat)
> +compat_symbol (libc, __xstat_compat, __xstat, GLIBC_2_0);
> +#endif
> +
> +#if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_33)
> +compat_symbol (libc, __xstat64, __xstat64, GLIBC_2_1);
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/fxstat.c
> b/sysdeps/unix/sysv/linux/fxstat.c index f78497ea92..649bb95252 100644
> --- a/sysdeps/unix/sysv/linux/fxstat.c
> +++ b/sysdeps/unix/sysv/linux/fxstat.c
> @@ -24,9 +24,13 @@
>  #if !XSTAT_IS_XSTAT64
>  # include <xstatconv.h>
>  # include <xstatover.h>
> +# include <shlib-compat.h>
> +
> +# if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
>  
>  /* Get information about the file FD in BUF.  */
>  int
> +attribute_compat_text_section
>  __fxstat (int vers, int fd, struct stat *buf)
>  {
>    switch (vers)
> @@ -57,4 +61,8 @@ __fxstat (int vers, int fd, struct stat *buf)
>        }
>      }
>  }
> +
> +compat_symbol (libc, __fxstat, __fxstat, GLIBC_2_0);
> +# endif /* SHLIB_COMPAT  */
> +
>  #endif /* XSTAT_IS_XSTAT64  */
> diff --git a/sysdeps/unix/sysv/linux/fxstat64.c
> b/sysdeps/unix/sysv/linux/fxstat64.c index 6ae7babccc..726dfd0ad6
> 100644 --- a/sysdeps/unix/sysv/linux/fxstat64.c
> +++ b/sysdeps/unix/sysv/linux/fxstat64.c
> @@ -24,10 +24,14 @@
>  #include <sysdep.h>
>  #include <xstatconv.h>
>  #include <statx_cp.h>
> +#include <shlib-compat.h>
> +
> +#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
>  
>  /* Get information about the file FD in BUF.  */
>  
>  int
> +attribute_compat_text_section
>  ___fxstat64 (int vers, int fd, struct stat64 *buf)
>  {
>  #if XSTAT_IS_XSTAT64
> @@ -53,16 +57,18 @@ ___fxstat64 (int vers, int fd, struct stat64 *buf)
>  #endif /* XSTAT_IS_XSTAT64  */
>  }
>  
> -#include <shlib-compat.h>
> -
>  #if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2)
> -versioned_symbol (libc, ___fxstat64, __fxstat64, GLIBC_2_2);
> +compat_symbol (libc, ___fxstat64, __fxstat64, GLIBC_2_2);
>  strong_alias (___fxstat64, __old__fxstat64)
>  compat_symbol (libc, __old__fxstat64, __fxstat64, GLIBC_2_1);
>  #else
>  strong_alias (___fxstat64, __fxstat64)
> +compat_symbol (libc, ___fxstat64, __fxstat64, GLIBC_2_2);
>  #endif
>  
>  #if XSTAT_IS_XSTAT64
> -strong_alias (__fxstat64, __fxstat);
> +strong_alias (___fxstat64, __fxstat_compat)
> +compat_symbol (libc, __fxstat_compat, __fxstat, GLIBC_2_2);
>  #endif
> +
> +#endif /* SHLIB_COMPAT  */
> diff --git a/sysdeps/unix/sysv/linux/fxstatat.c
> b/sysdeps/unix/sysv/linux/fxstatat.c index 1a60fc10e3..2083e18eac
> 100644 --- a/sysdeps/unix/sysv/linux/fxstatat.c
> +++ b/sysdeps/unix/sysv/linux/fxstatat.c
> @@ -24,9 +24,13 @@
>  #if !XSTAT_IS_XSTAT64
>  # include <xstatconv.h>
>  # include <xstatover.h>
> +# include <shlib-compat.h>
> +
> +# if SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
>  
>  /* Get information about the file FD in BUF.  */
>  int
> +attribute_compat_text_section
>  __fxstatat (int vers, int fd, const char *file, struct stat *st, int
> flag) {
>  #if STAT_IS_KERNEL_STAT
> @@ -46,4 +50,8 @@ __fxstatat (int vers, int fd, const char *file,
> struct stat *st, int flag) return r ?: __xstat32_conv (vers, &st64,
> st); #endif
>  }
> +
> +compat_symbol (libc, __fxstatat, __fxstatat, GLIBC_2_4);
> +# endif /* SHLIB_COMPAT  */
> +
>  #endif /* XSTAT_IS_XSTAT64  */
> diff --git a/sysdeps/unix/sysv/linux/fxstatat64.c
> b/sysdeps/unix/sysv/linux/fxstatat64.c index 7fe034809c..8a505451d9
> 100644 --- a/sysdeps/unix/sysv/linux/fxstatat64.c
> +++ b/sysdeps/unix/sysv/linux/fxstatat64.c
> @@ -24,10 +24,14 @@
>  #include <sysdep.h>
>  #include <xstatconv.h>
>  #include <statx_cp.h>
> +#include <shlib-compat.h>
> +
> +#if SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
>  
>  /* Get information about the file FD in BUF.  */
>  
>  int
> +attribute_compat_text_section
>  __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st,
> int flag) {
>  #if XSTAT_IS_XSTAT64
> @@ -61,6 +65,12 @@ __fxstatat64 (int vers, int fd, const char *file,
> struct stat64 *st, int flag) #endif
>    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
>  }
> +
> +compat_symbol (libc, __fxstatat64, __fxstatat64, GLIBC_2_4);
> +
>  #if XSTAT_IS_XSTAT64
> -strong_alias (__fxstatat64, __fxstatat);
> +strong_alias (__fxstatat64, __fxstatat_compat)
> +compat_symbol (libc, __fxstatat_compat, __fxstatat, GLIBC_2_4);
>  #endif
> +
> +#endif /* SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)  */
> diff --git a/sysdeps/unix/sysv/linux/lxstat.c
> b/sysdeps/unix/sysv/linux/lxstat.c index 156173a4e1..f307aa4942 100644
> --- a/sysdeps/unix/sysv/linux/lxstat.c
> +++ b/sysdeps/unix/sysv/linux/lxstat.c
> @@ -20,13 +20,17 @@
>  #include <fcntl.h>
>  #include <kernel_stat.h>
>  #include <sysdep.h>
> +#include <shlib-compat.h>
>  
>  #if !XSTAT_IS_XSTAT64
>  # include <xstatconv.h>
>  # include <xstatover.h>
>  
> +# if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
> +
>  /* Get information about the file NAME in BUF.  */
>  int
> +attribute_compat_text_section
>  __lxstat (int vers, const char *name, struct stat *buf)
>  {
>    switch (vers)
> @@ -58,4 +62,8 @@ __lxstat (int vers, const char *name, struct stat
> *buf) }
>      }
>  }
> +
> +compat_symbol (libc, __lxstat, __lxstat, GLIBC_2_0);
> +# endif /* SHLIB_COMPAT  */
> +
>  #endif /* XSTAT_IS_XSTAT64  */
> diff --git a/sysdeps/unix/sysv/linux/lxstat64.c
> b/sysdeps/unix/sysv/linux/lxstat64.c index 29bd1cdf72..660d59aea3
> 100644 --- a/sysdeps/unix/sysv/linux/lxstat64.c
> +++ b/sysdeps/unix/sysv/linux/lxstat64.c
> @@ -24,10 +24,14 @@
>  #include <sysdep.h>
>  #include <xstatconv.h>
>  #include <statx_cp.h>
> +#include <shlib-compat.h>
> +
> +#if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_33)
>  
>  /* Get information about the file NAME in BUF.  */
>  
>  int
> +attribute_compat_text_section
>  ___lxstat64 (int vers, const char *name, struct stat64 *buf)
>  {
>  #if XSTAT_IS_XSTAT64
> @@ -70,17 +74,18 @@ ___lxstat64 (int vers, const char *name, struct
> stat64 *buf) return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
>  }
>  
> -#if XSTAT_IS_XSTAT64
> -weak_alias (___lxstat64, __lxstat);
> -weak_alias (___lxstat64, __GI___lxstat);
> -#endif
> -
> -#include <shlib-compat.h>
> -
>  #if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2)
> -versioned_symbol (libc, ___lxstat64, __lxstat64, GLIBC_2_2);
> +compat_symbol (libc, ___lxstat64, __lxstat64, GLIBC_2_2);
>  strong_alias (___lxstat64, __old__lxstat64)
>  compat_symbol (libc, __old__lxstat64, __lxstat64, GLIBC_2_1);
>  #else
>  strong_alias (___lxstat64, __lxstat64);
> +compat_symbol (libc, ___lxstat64, __lxstat64, GLIBC_2_2);
>  #endif
> +
> +#if XSTAT_IS_XSTAT64
> +strong_alias (___lxstat64,__lxstat_compat)
> +compat_symbol (libc, __lxstat_compat, __lxstat, GLIBC_2_2);
> +#endif
> +
> +#endif /* SHLIB_COMPAT  */
> diff --git a/sysdeps/unix/sysv/linux/mips/fxstat.c
> b/sysdeps/unix/sysv/linux/mips/fxstat.c index 4585c2362b..cb9f656628
> 100644 --- a/sysdeps/unix/sysv/linux/mips/fxstat.c
> +++ b/sysdeps/unix/sysv/linux/mips/fxstat.c
> @@ -21,9 +21,13 @@
>  #include <kernel_stat.h>
>  #include <sysdep.h>
>  #include <xstatconv.h>
> +#include <shlib-compat.h>
> +
> +#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
>  
>  /* Get information about the file NAME in BUF.  */
>  int
> +attribute_compat_text_section
>  __fxstat (int vers, int fd, struct stat *buf)
>  {
>    switch (vers)
> @@ -39,3 +43,7 @@ __fxstat (int vers, int fd, struct stat *buf)
>        }
>      }
>  }
> +
> +compat_symbol (libc, __fxstat, __fxstat, GLIBC_2_0);
> +
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/mips/lxstat.c
> b/sysdeps/unix/sysv/linux/mips/lxstat.c index 62a3b15b32..ebd05cca50
> 100644 --- a/sysdeps/unix/sysv/linux/mips/lxstat.c
> +++ b/sysdeps/unix/sysv/linux/mips/lxstat.c
> @@ -21,9 +21,13 @@
>  #include <kernel_stat.h>
>  #include <sysdep.h>
>  #include <xstatconv.h>
> +#include <shlib-compat.h>
> +
> +#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
>  
>  /* Get information about the file NAME in BUF.  */
>  int
> +attribute_compat_text_section
>  __lxstat (int vers, const char *name, struct stat *buf)
>  {
>    switch (vers)
> @@ -39,3 +43,7 @@ __lxstat (int vers, const char *name, struct stat
> *buf) }
>      }
>  }
> +
> +compat_symbol (libc, __lxstat, __lxstat, GLIBC_2_0);
> +
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/fxstat64.c
> b/sysdeps/unix/sysv/linux/mips/mips64/fxstat64.c index
> e6c1cacd4b..855c650814 100644 ---
> a/sysdeps/unix/sysv/linux/mips/mips64/fxstat64.c +++
> b/sysdeps/unix/sysv/linux/mips/mips64/fxstat64.c @@ -20,10 +20,14 @@
>  #include <kernel_stat.h>
>  #include <sysdep.h>
>  #include <xstatconv.h>
> +#include <shlib-compat.h>
> +
> +#if SHLIB_COMPAT(libc, GLIBC_2_2, GLIBC_2_33)
>  
>  /* Get information about the file FD in BUF.  */
>  
>  int
> +attribute_compat_text_section
>  __fxstat64 (int vers, int fd, struct stat64 *buf)
>  {
>    struct kernel_stat kbuf;
> @@ -31,3 +35,7 @@ __fxstat64 (int vers, int fd, struct stat64 *buf)
>    return r ?: __xstat64_conv (vers, &kbuf, buf);
>  
>  }
> +
> +compat_symbol (libc, __fxstat64, __fxstat64, GLIBC_2_2);
> +
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/fxstatat.c
> b/sysdeps/unix/sysv/linux/mips/mips64/fxstatat.c index
> e384dbab8b..1c1fbb02c2 100644 ---
> a/sysdeps/unix/sysv/linux/mips/mips64/fxstatat.c +++
> b/sysdeps/unix/sysv/linux/mips/mips64/fxstatat.c @@ -21,12 +21,20 @@
>  #include <kernel_stat.h>
>  #include <sysdep.h>
>  #include <xstatconv.h>
> +#include <shlib-compat.h>
> +
> +#if SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
>  
>  /* Get information about the file FD in BUF.  */
>  int
> +attribute_compat_text_section
>  __fxstatat (int vers, int fd, const char *file, struct stat *st, int
> flag) {
>    struct kernel_stat kst;
>    int r = INLINE_SYSCALL_CALL (newfstatat, fd, file, &kst, flag);
>    return r ?: __xstat_conv (vers, &kst, st);
>  }
> +
> +compat_symbol (libc, __fxstatat, __fxstatat, GLIBC_2_4);
> +
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c
> b/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c index
> cfd172d301..f40a2c5aa8 100644 ---
> a/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c +++
> b/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c @@ -19,10 +19,14 @@
>  #include <kernel_stat.h>
>  #include <sysdep.h>
>  #include <xstatconv.h>
> +#include <shlib-compat.h>
> +
> +#if SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
>  
>  /* Get information about the file NAME in BUF.  */
>  
>  int
> +attribute_compat_text_section
>  __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st,
> int flag) {
>    if (vers == _STAT_VER_LINUX)
> @@ -33,3 +37,7 @@ __fxstatat64 (int vers, int fd, const char *file,
> struct stat64 *st, int flag) }
>    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
>  }
> +
> +compat_symbol (libc, __fxstatat64, __fxstatat64, GLIBC_2_4);
> +
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/lxstat64.c
> b/sysdeps/unix/sysv/linux/mips/mips64/lxstat64.c index
> 0f3934f8c8..752c5284a7 100644 ---
> a/sysdeps/unix/sysv/linux/mips/mips64/lxstat64.c +++
> b/sysdeps/unix/sysv/linux/mips/mips64/lxstat64.c @@ -20,12 +20,20 @@
>  #include <kernel_stat.h>
>  #include <sysdep.h>
>  #include <xstatconv.h>
> +#include <shlib-compat.h>
> +
> +#if SHLIB_COMPAT(libc, GLIBC_2_2, GLIBC_2_33)
>  
>  /* Get information about the file NAME in BUF.  */
>  int
> +attribute_compat_text_section
>  __lxstat64 (int vers, const char *name, struct stat64 *buf)
>  {
>    struct kernel_stat kbuf;
>    int r = INLINE_SYSCALL_CALL (lstat, name, &kbuf);
>    return r ?: __xstat64_conv (vers, &kbuf, buf);
>  }
> +
> +compat_symbol (libc, __lxstat64, __lxstat64, GLIBC_2_2);
> +
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/xstat64.c
> b/sysdeps/unix/sysv/linux/mips/mips64/xstat64.c index
> 64d2952276..a620ba2f1f 100644 ---
> a/sysdeps/unix/sysv/linux/mips/mips64/xstat64.c +++
> b/sysdeps/unix/sysv/linux/mips/mips64/xstat64.c @@ -20,13 +20,20 @@
>  #include <kernel_stat.h>
>  #include <sysdep.h>
>  #include <xstatconv.h>
> +#include <shlib-compat.h>
>  
> -/* Get information about the file NAME in BUF.  */
> +#if SHLIB_COMPAT(libc, GLIBC_2_2, GLIBC_2_33)
>  
> +/* Get information about the file NAME in BUF.  */
>  int
> +attribute_compat_text_section
>  __xstat64 (int vers, const char *name, struct stat64 *buf)
>  {
>    struct kernel_stat kbuf;
>    int r = INLINE_SYSCALL_CALL (stat, name, &kbuf);
>    return r ?: __xstat64_conv (vers, &kbuf, buf);
>  }
> +
> +compat_symbol (libc, __xstat64, __xstat64, GLIBC_2_2);
> +
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/mips/xstat.c
> b/sysdeps/unix/sysv/linux/mips/xstat.c index d6ff5ccbe0..0748a3422d
> 100644 --- a/sysdeps/unix/sysv/linux/mips/xstat.c
> +++ b/sysdeps/unix/sysv/linux/mips/xstat.c
> @@ -21,9 +21,13 @@
>  #include <kernel_stat.h>
>  #include <sysdep.h>
>  #include <xstatconv.h>
> +#include <shlib-compat.h>
> +
> +#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
>  
>  /* Get information about the file NAME in BUF.  */
>  int
> +attribute_compat_text_section
>  __xstat (int vers, const char *name, struct stat *buf)
>  {
>    switch (vers)
> @@ -39,3 +43,7 @@ __xstat (int vers, const char *name, struct stat
> *buf) }
>      }
>  }
> +
> +compat_symbol (libc, __xstat, __xstat, GLIBC_2_0);
> +
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/xstat.c
> b/sysdeps/unix/sysv/linux/xstat.c index a971e8cf6a..51329831b0 100644
> --- a/sysdeps/unix/sysv/linux/xstat.c
> +++ b/sysdeps/unix/sysv/linux/xstat.c
> @@ -20,13 +20,17 @@
>  #include <fcntl.h>
>  #include <kernel_stat.h>
>  #include <sysdep.h>
> +#include <shlib-compat.h>
>  
>  #if !XSTAT_IS_XSTAT64
>  # include <xstatconv.h>
>  # include <xstatover.h>
>  
> +# if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
> +
>  /* Get information about the file NAME in BUF.  */
>  int
> +attribute_compat_text_section
>  __xstat (int vers, const char *name, struct stat *buf)
>  {
>    switch (vers)
> @@ -57,4 +61,9 @@ __xstat (int vers, const char *name, struct stat
> *buf) }
>      }
>  }
> +
> +compat_symbol (libc, __xstat, __xstat, GLIBC_2_0);
> +# endif /* SHLIB_COMPAT  */
> +
>  #endif /* XSTAT_IS_XSTAT64  */
> +
> diff --git a/sysdeps/unix/sysv/linux/xstat64.c
> b/sysdeps/unix/sysv/linux/xstat64.c index e3a42966f5..4872d24694
> 100644 --- a/sysdeps/unix/sysv/linux/xstat64.c
> +++ b/sysdeps/unix/sysv/linux/xstat64.c
> @@ -24,10 +24,14 @@
>  #include <sysdep.h>
>  #include <xstatconv.h>
>  #include <statx_cp.h>
> +#include <shlib-compat.h>
> +
> +#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
>  
>  /* Get information about the file NAME in BUF.  */
>  
>  int
> +attribute_compat_text_section
>  ___xstat64 (int vers, const char *name, struct stat64 *buf)
>  {
>  #if XSTAT_IS_XSTAT64
> @@ -68,16 +72,17 @@ ___xstat64 (int vers, const char *name, struct
> stat64 *buf) }
>  
>  #if XSTAT_IS_XSTAT64
> -weak_alias (___xstat64, __xstat);
> -weak_alias (___xstat64, __GI___xstat);
> +strong_alias (___xstat64, __xstat_compat)
> +compat_symbol (libc, __xstat_compat, __xstat, GLIBC_2_2);
>  #endif
>  
> -#include <shlib-compat.h>
> -
>  #if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2)
> -versioned_symbol (libc, ___xstat64, __xstat64, GLIBC_2_2);
> +compat_symbol (libc, ___xstat64, __xstat64, GLIBC_2_2);
>  strong_alias (___xstat64, __old__xstat64)
>  compat_symbol (libc, __old__xstat64, __xstat64, GLIBC_2_1);
>  #else
>  strong_alias (___xstat64, __xstat64)
> +compat_symbol (libc, ___xstat64, __xstat64, GLIBC_2_2);
>  #endif
> +
> +#endif /* SHLIB_COMPAT  */




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 13/16] linux: Disentangle fstatat from fxstatat
  2020-07-23 19:46 ` [PATCH 13/16] linux: Disentangle fstatat from fxstatat Adhemerval Zanella via Libc-alpha
  2020-07-24  9:39   ` Lukasz Majewski
@ 2020-07-24 10:25   ` Florian Weimer via Libc-alpha
  2020-07-24 14:39     ` Adhemerval Zanella via Libc-alpha
  1 sibling, 1 reply; 80+ messages in thread
From: Florian Weimer via Libc-alpha @ 2020-07-24 10:25 UTC (permalink / raw)
  To: Adhemerval Zanella via Libc-alpha; +Cc: Alistair Francis

* Adhemerval Zanella via Libc-alpha:

> diff --git a/sysdeps/unix/sysv/linux/kstat_cp.h b/sysdeps/unix/sysv/linux/kstat_cp.h
> new file mode 100644
> index 0000000000..8fa43ed2e1
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/kstat_cp.h
> @@ -0,0 +1,2 @@
> +/* Empty, it is overridden by an architecture which might require copy to ro
> +   from a kernel_stat stat struct to glibc export stat{64}.  */

Typo: or

Thanks,
Florian


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

* Re: [PATCH 16/16] linux: Move xmknoda{at} to compat symbols
  2020-07-23 19:46 ` [PATCH 16/16] linux: Move xmknoda{at} to compat symbols Adhemerval Zanella via Libc-alpha
@ 2020-07-24 10:30   ` Florian Weimer via Libc-alpha
  2020-07-24 12:34     ` Adhemerval Zanella via Libc-alpha
  2020-07-24 10:43   ` Lukasz Majewski
  1 sibling, 1 reply; 80+ messages in thread
From: Florian Weimer via Libc-alpha @ 2020-07-24 10:30 UTC (permalink / raw)
  To: Adhemerval Zanella via Libc-alpha; +Cc: Alistair Francis

* Adhemerval Zanella via Libc-alpha:

> diff --git a/sysdeps/unix/sysv/linux/mknodat.c b/sysdeps/unix/sysv/linux/mknodat.c
> new file mode 100644
> index 0000000000..d160fe520b
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/mknodat.c
> @@ -0,0 +1,41 @@

> +int
> +__mknodat_common (int fd, const char *path, mode_t mode, dev_t *dev)
> +{
> +  /* We must convert the value to dev_t type used by the kernel.  */
> +  unsigned long long int k_dev = (*dev) & ((1ULL << 32) - 1);
> +  if (k_dev != *dev)
> +    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
> +
> +  return INLINE_SYSCALL_CALL (mknodat, fd, path, mode,
> +			      (unsigned int) k_dev);
> +}

This looks suspicious yo me.  Why use a dev_t * argument?  Why check
against the unsigned long long int value, when the kernel receives an
unsigned int value in the system call?

What's the intended difference between __mknodat_common and __mknodat?

Thanks,
Florian


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

* Re: [PATCH 16/16] linux: Move xmknoda{at} to compat symbols
  2020-07-23 19:46 ` [PATCH 16/16] linux: Move xmknoda{at} to compat symbols Adhemerval Zanella via Libc-alpha
  2020-07-24 10:30   ` Florian Weimer via Libc-alpha
@ 2020-07-24 10:43   ` Lukasz Majewski
  1 sibling, 0 replies; 80+ messages in thread
From: Lukasz Majewski @ 2020-07-24 10:43 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Alistair Francis, libc-alpha

[-- Attachment #1: Type: text/plain, Size: 9605 bytes --]

On Thu, 23 Jul 2020 16:46:41 -0300
Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> It also decouple mknod{at} from xmknod{at}.
> 
> Checked with a build for all affected Linux ABIs.  I checked also
> on x86_64-linux-gnu and i686-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>

> ---
>  include/sys/stat.h                 |  6 +++--
>  sysdeps/mach/hurd/xmknod.c         |  1 -
>  sysdeps/mach/hurd/xmknodat.c       |  2 --
>  sysdeps/unix/sysv/linux/mknod.c    | 28 ++++++++++++++++++++
>  sysdeps/unix/sysv/linux/mknodat.c  | 41
> ++++++++++++++++++++++++++++++ sysdeps/unix/sysv/linux/xmknod.c   |
> 20 +++++---------- sysdeps/unix/sysv/linux/xmknodat.c | 23
> +++++------------ 7 files changed, 86 insertions(+), 35 deletions(-)
>  create mode 100644 sysdeps/unix/sysv/linux/mknod.c
>  create mode 100644 sysdeps/unix/sysv/linux/mknodat.c
> 
> diff --git a/include/sys/stat.h b/include/sys/stat.h
> index 87d4a5ec4f..da8b14fee0 100644
> --- a/include/sys/stat.h
> +++ b/include/sys/stat.h
> @@ -84,6 +84,8 @@ extern __mode_t __umask (__mode_t __mask);
>  extern int __mkdir (const char *__path, __mode_t __mode);
>  libc_hidden_proto (__mkdir)
>  
> +extern int __mknodat_common (int fd, const char *, __mode_t, __dev_t
> *)
> +  attribute_hidden;
>  extern int __mknodat (int fd, const char *path, mode_t mode, dev_t
> dev); libc_hidden_proto (__mknodat);
>  extern int __mknod (const char *__path,
> @@ -92,10 +94,8 @@ libc_hidden_proto (__mknod);
>  
>  extern int __xmknod (int __ver, const char *__path, __mode_t __mode,
>  		     __dev_t *__dev);
> -libc_hidden_proto (__xmknod)
>  extern int __xmknodat (int __ver, int __fd, const char *__path,
>  		       __mode_t __mode, __dev_t *__dev);
> -libc_hidden_proto (__xmknodat)
>  
>  int __fxstat (int __ver, int __fildes, struct stat *__stat_buf);
>  int __xstat (int __ver, const char *__filename,
> @@ -121,6 +121,8 @@ hidden_proto (__xstat64);
>  hidden_proto (__lxstat64);
>  hidden_proto (__fxstatat64);
>  #  endif
> +libc_hidden_proto (__xmknod)
> +libc_hidden_proto (__xmknodat)
>  #  define stat(fname, buf) __xstat (_STAT_VER, fname, buf)
>  #  define lstat(fname, buf)  __lxstat (_STAT_VER, fname, buf)
>  #  define __lstat(fname, buf)  __lxstat (_STAT_VER, fname, buf)
> diff --git a/sysdeps/mach/hurd/xmknod.c b/sysdeps/mach/hurd/xmknod.c
> index 0ab4f1b719..67e32f518d 100644
> --- a/sysdeps/mach/hurd/xmknod.c
> +++ b/sysdeps/mach/hurd/xmknod.c
> @@ -30,4 +30,3 @@ __xmknod (int vers, const char *file_name, mode_t
> mode, dev_t *dev) {
>    return __xmknodat (vers, AT_FDCWD, file_name, mode, dev);
>  }
> -libc_hidden_def (__xmknod)
> diff --git a/sysdeps/mach/hurd/xmknodat.c
> b/sysdeps/mach/hurd/xmknodat.c index 4239d1ea91..0333765ebc 100644
> --- a/sysdeps/mach/hurd/xmknodat.c
> +++ b/sysdeps/mach/hurd/xmknodat.c
> @@ -116,5 +116,3 @@ __xmknodat (int vers, int fd, const char *path,
> mode_t mode, dev_t *dev) return __hurd_fail (err);
>    return 0;
>  }
> -
> -libc_hidden_def (__xmknodat)
> diff --git a/sysdeps/unix/sysv/linux/mknod.c
> b/sysdeps/unix/sysv/linux/mknod.c new file mode 100644
> index 0000000000..3185726f52
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/mknod.c
> @@ -0,0 +1,28 @@
> +/* Create a special or ordinary file.  Linux version.
> +   Copyright (C) 2020 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 <fcntl.h>
> +
> +int
> +__mknod (const char *path, mode_t mode, dev_t dev)
> +{
> +  return __mknodat_common (AT_FDCWD, path, mode, &dev);
> +}
> +libc_hidden_def (__mknod)
> +weak_alias (__mknod, mknod)
> diff --git a/sysdeps/unix/sysv/linux/mknodat.c
> b/sysdeps/unix/sysv/linux/mknodat.c new file mode 100644
> index 0000000000..d160fe520b
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/mknodat.c
> @@ -0,0 +1,41 @@
> +/* Create a special or ordinary file.  Linux version.
> +   Copyright (C) 2020 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/types.h>
> +#include <sys/stat.h>
> +#include <errno.h>
> +
> +int
> +__mknodat_common (int fd, const char *path, mode_t mode, dev_t *dev)
> +{
> +  /* We must convert the value to dev_t type used by the kernel.  */
> +  unsigned long long int k_dev = (*dev) & ((1ULL << 32) - 1);
> +  if (k_dev != *dev)
> +    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
> +
> +  return INLINE_SYSCALL_CALL (mknodat, fd, path, mode,
> +			      (unsigned int) k_dev);
> +}
> +
> +int
> +__mknodat (int fd, const char *path, mode_t mode, dev_t dev)
> +{
> +  return __mknodat_common (fd, path, mode, &dev);
> +}
> +libc_hidden_def (__mknodat)
> +weak_alias (__mknodat, mknodat)
> diff --git a/sysdeps/unix/sysv/linux/xmknod.c
> b/sysdeps/unix/sysv/linux/xmknod.c index 42809d4c57..2ae384a536 100644
> --- a/sysdeps/unix/sysv/linux/xmknod.c
> +++ b/sysdeps/unix/sysv/linux/xmknod.c
> @@ -17,29 +17,23 @@
>     <https://www.gnu.org/licenses/>.  */
>  
>  #include <sys/stat.h>
> -#include <sys/sysmacros.h>
>  #include <fcntl.h>
> -#include <sysdep.h>
> +#include <errno.h>
> +#include <shlib-compat.h>
>  
> +#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
>  /* Create a device file named PATH, with permission and special bits
> MODE and device number DEV (which can be constructed from major and
> minor device numbers with the `makedev' macro above).  */
>  int
> +attribute_compat_text_section
>  __xmknod (int vers, const char *path, mode_t mode, dev_t *dev)
>  {
> -  unsigned long long int k_dev;
> -
>    if (vers != _MKNOD_VER)
>      return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
>  
> -  /* We must convert the value to dev_t type used by the kernel.  */
> -  k_dev =  (*dev) & ((1ULL << 32) - 1);
> -  if (k_dev != *dev)
> -    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
> -
> -  return INLINE_SYSCALL_CALL (mknodat, AT_FDCWD, path, mode,
> -			      (unsigned int) k_dev);
> +  return __mknodat_common (AT_FDCWD, path, mode, dev);
>  }
>  
> -weak_alias (__xmknod, _xmknod)
> -libc_hidden_def (__xmknod)
> +compat_symbol (libc, __xmknod, __xmknod, GLIBC_2_0);
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/xmknodat.c
> b/sysdeps/unix/sysv/linux/xmknodat.c index 5640a499aa..11b52a29b2
> 100644 --- a/sysdeps/unix/sysv/linux/xmknodat.c
> +++ b/sysdeps/unix/sysv/linux/xmknodat.c
> @@ -15,18 +15,11 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -#include <errno.h>
> -#include <fcntl.h>
> -#include <stdio.h>
> -#include <string.h>
> -#include <sys/types.h>
>  #include <sys/stat.h>
> -#include <sys/sysmacros.h>
> -
> -#include <sysdep.h>
> -#include <sys/syscall.h>
> -
> +#include <errno.h>
> +#include <shlib-compat.h>
>  
> +#if SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
>  /* Create a device file named PATH relative to FD, with permission
> and special bits MODE and device number DEV (which can be constructed
>     from major and minor device numbers with the `makedev' macro
> above).  */ @@ -36,12 +29,8 @@ __xmknodat (int vers, int fd, const
> char *file, mode_t mode, dev_t *dev) if (vers != _MKNOD_VER)
>      return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
>  
> -  /* We must convert the value to dev_t type used by the kernel.  */
> -  unsigned long long int k_dev =  (*dev) & ((1ULL << 32) - 1);
> -  if (k_dev != *dev)
> -    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
> -
> -  return INLINE_SYSCALL (mknodat, 4, fd, file, mode, (unsigned int)
> k_dev);
> +  return __mknodat_common (fd, file, mode, dev);
>  }
>  
> -libc_hidden_def (__xmknodat)
> +compat_symbol (libc, __xmknodat, __xmknodat, GLIBC_2_4);
> +#endif




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 15/16] linux: Add {f}stat{at} y2038 support
  2020-07-23 19:46 ` [PATCH 15/16] linux: Add {f}stat{at} y2038 support Adhemerval Zanella via Libc-alpha
  2020-07-23 20:55   ` Joseph Myers
@ 2020-07-24 10:53   ` Lukasz Majewski
  2020-07-30 12:42     ` Adhemerval Zanella via Libc-alpha
  2020-10-06  9:48   ` Lukasz Majewski
  2 siblings, 1 reply; 80+ messages in thread
From: Lukasz Majewski @ 2020-07-24 10:53 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Alistair Francis, libc-alpha

[-- Attachment #1: Type: text/plain, Size: 36876 bytes --]

Hi Adhemerval,

> A new struct __stat{64}_t64 type is added with the required
> __timespec64 time definition.  Both non-LFS and LFS support were
> done with an extra __NR_statx call plus a conversion to the new
> __stat{64}_t64 type.  The statx call is done only for architectures
> with support for 32-bit time_t ABI.
> 
> Internally some extra routines to copy from/to struct stat{64}
> to struct __stat{64} used on multiple implementations (stat, fstat,
> lstat, and fstatat) are added on a extra file (stat_t64_cp.c).  Aslo
> some extra routines to copy from statx to __stat{64} is added on
> statx_cp.c.
> 
> Checked with a build for all affected ABIs. I also checked on x86_64,
> i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and s390x.

This patch set is a huge step forward for the *stat* conversion to
support 64 bit time.

In fact we will only need redirections when -D__USE_TIME_BITS64 support
is added.

> ---
>  include/sys/stat.h                            |  32 +++++
>  sysdeps/generic/struct_stat_time64.h          |   7 +
>  sysdeps/unix/sysv/linux/Makefile              |   2 +-
>  sysdeps/unix/sysv/linux/fstat.c               |  13 +-
>  sysdeps/unix/sysv/linux/fstat64.c             |  20 ++-
>  sysdeps/unix/sysv/linux/fstatat.c             |  64 +++++----
>  sysdeps/unix/sysv/linux/fstatat64.c           |  88 ++++++++++---
>  sysdeps/unix/sysv/linux/lstat.c               |  13 +-
>  sysdeps/unix/sysv/linux/lstat64.c             |  19 ++-
>  .../unix/sysv/linux/mips/mips64/kstat_cp.h    |  23 +---
>  .../unix/sysv/linux/mips/mips64/statx_cp.c    |   3 -
>  sysdeps/unix/sysv/linux/stat.c                |  13 +-
>  sysdeps/unix/sysv/linux/stat64.c              |  20 ++-
>  sysdeps/unix/sysv/linux/stat_t64_cp.c         |  92 +++++++++++++
>  sysdeps/unix/sysv/linux/stat_t64_cp.h         |  28 ++++
>  sysdeps/unix/sysv/linux/statx_cp.c            |  54 ++++++++
>  sysdeps/unix/sysv/linux/statx_cp.h            |   6 +
>  sysdeps/unix/sysv/linux/struct_stat_time64.h  | 122
> ++++++++++++++++++ 18 files changed, 539 insertions(+), 80
> deletions(-) create mode 100644 sysdeps/generic/struct_stat_time64.h
>  delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/statx_cp.c
>  create mode 100644 sysdeps/unix/sysv/linux/stat_t64_cp.c
>  create mode 100644 sysdeps/unix/sysv/linux/stat_t64_cp.h
>  create mode 100644 sysdeps/unix/sysv/linux/struct_stat_time64.h
> 
> diff --git a/include/sys/stat.h b/include/sys/stat.h
> index 199173b007..87d4a5ec4f 100644
> --- a/include/sys/stat.h
> +++ b/include/sys/stat.h
> @@ -3,6 +3,8 @@
>  
>  #ifndef _ISOMAC
>  # include <xstatver.h>
> +# include <struct___timespec64.h>
> +# include <struct_stat_time64.h>
>  # include <stdbool.h>
>  
>  static inline bool
> @@ -44,6 +46,36 @@ hidden_proto (__lstat64)
>  hidden_proto (__fstatat64)
>  # endif
>  
> +# if __TIMESIZE == 64
> +#  define __stat_time64  __stat
> +#  define __stat64_time64  __stat64
> +#  define __fstat_time64  __fstat
> +#  define __fstat64_time64  __fstat64
> +#  define __lstat_time64  __lstat
> +#  define __lstat64_time64  __lstat64
> +#  define __fstatat_time64  __fstatat
> +#  define __fstatat64_time64 __fstatat64
> +# else
> +extern int __stat_time64 (const char *file, struct __stat_t64 *buf);
> +libc_hidden_proto (__stat_time64);
> +extern int __stat64_time64 (const char *file, struct __stat64_t64
> *buf); +hidden_proto (__stat64_time64);
> +extern int __lstat_time64 (const char *file, struct __stat_t64 *buf);
> +libc_hidden_proto (__lstat_time64);
> +extern int __lstat64_time64 (const char *file, struct __stat64_t64
> *buf); +hidden_proto (__lstat64_time64);
> +extern int __fstat_time64 (int fd, struct __stat_t64 *buf);
> +libc_hidden_proto (__fstat_time64);
> +extern int __fstat64_time64 (int fd, struct __stat64_t64 *buf);
> +hidden_proto (__fstat64_time64);
> +extern int __fstatat_time64 (int dirfd, const char *pathname,
> +			     struct __stat_t64 *buf, int flags);
> +libc_hidden_proto (__fstatat_time64);
> +extern int __fstatat64_time64 (int dirfd, const char *pathname,
> +			       struct __stat64_t64 *buf, int flags);
> +hidden_proto (__fstatat64_time64);
> +# endif
> +
>  extern int __chmod (const char *__file, __mode_t __mode);
>  libc_hidden_proto (__chmod)
>  extern int __fchmod (int __fd, __mode_t __mode);
> diff --git a/sysdeps/generic/struct_stat_time64.h
> b/sysdeps/generic/struct_stat_time64.h new file mode 100644
> index 0000000000..24bb9f75cb
> --- /dev/null
> +++ b/sysdeps/generic/struct_stat_time64.h
> @@ -0,0 +1,7 @@
> +#ifndef _BITS_STRUCT_STAT_TIME64_H
> +#define _BITS_STRUCT_STAT_TIME64_H 1
> +
> +#define __stat_t64   stat
> +#define __stat64_t64 stat64
> +
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/Makefile
> b/sysdeps/unix/sysv/linux/Makefile index f189f65daf..95a51ee4f2 100644
> --- a/sysdeps/unix/sysv/linux/Makefile
> +++ b/sysdeps/unix/sysv/linux/Makefile
> @@ -273,7 +273,7 @@ sysdep_routines += xstatconv internal_statvfs
> internal_statvfs64 \ open_nocancel open64_nocancel \
>  		   openat_nocancel openat64_nocancel \
>  		   read_nocancel pread64_nocancel \
> -		   write_nocancel statx_cp
> +		   write_nocancel statx_cp stat_t64_cp
>  
>  sysdep_headers += bits/fcntl-linux.h
>  
> diff --git a/sysdeps/unix/sysv/linux/fstat.c
> b/sysdeps/unix/sysv/linux/fstat.c index bdbeded956..0981dbaa95 100644
> --- a/sysdeps/unix/sysv/linux/fstat.c
> +++ b/sysdeps/unix/sysv/linux/fstat.c
> @@ -19,13 +19,24 @@
>  #include <sys/stat.h>
>  #include <kernel_stat.h>
>  #include <fcntl.h>
> +#include <stat_t64_cp.h>
>  
>  #if !XSTAT_IS_XSTAT64
> +int
> +__fstat_time64 (int fd, struct __stat_t64 *buf)
> +{
> +  return __fstatat_time64 (fd, "", buf, AT_EMPTY_PATH);
> +}
> +# if __TIMESIZE != 64
> +libc_hidden_def (__fstat_time64)
> +
>  int
>  __fstat (int fd, struct stat *buf)
>  {
> -  return __fstatat (fd, "", buf, AT_EMPTY_PATH);
> +  struct __stat_t64 st_t64;
> +  return __fstat_time64 (fd, &st_t64) ?: __cp_stat_t64_stat
> (&st_t64, buf); }
> +# endif
>  
>  weak_alias (__fstat, fstat)
>  #endif
> diff --git a/sysdeps/unix/sysv/linux/fstat64.c
> b/sysdeps/unix/sysv/linux/fstat64.c index c2ff1ff577..67667e79d8
> 100644 --- a/sysdeps/unix/sysv/linux/fstat64.c
> +++ b/sysdeps/unix/sysv/linux/fstat64.c
> @@ -19,16 +19,30 @@
>  #define __fstat __redirect___fstat
>  #define fstat   __redirect_fstat
>  #include <sys/stat.h>
> -#undef __fstat
> -#undef fstat
>  #include <fcntl.h>
>  #include <kernel_stat.h>
> +#include <stat_t64_cp.h>
> +
> +int
> +__fstat64_time64 (int fd, struct __stat64_t64 *buf)
> +{
> +  return __fstatat64_time64 (fd, "", buf, AT_EMPTY_PATH);
> +}
> +#if __TIMESIZE != 64
> +hidden_def (__fstat64_time64)
>  
>  int
>  __fstat64 (int fd, struct stat64 *buf)
>  {
> -  return __fstatat64 (fd, "", buf, AT_EMPTY_PATH);
> +  struct __stat64_t64 st_t64;
> +  return __fstat64_time64 (fd, &st_t64)
> +	 ?: __cp_stat64_t64_stat64 (&st_t64, buf);
>  }
> +#endif
> +
> +#undef __fstat
> +#undef fstat
> +
>  hidden_def (__fstat64)
>  weak_alias (__fstat64, fstat64)
>  
> diff --git a/sysdeps/unix/sysv/linux/fstatat.c
> b/sysdeps/unix/sysv/linux/fstatat.c index 03ddb3f493..f65d3b74a6
> 100644 --- a/sysdeps/unix/sysv/linux/fstatat.c
> +++ b/sysdeps/unix/sysv/linux/fstatat.c
> @@ -22,25 +22,28 @@
>  
>  #if !XSTAT_IS_XSTAT64
>  # include <kstat_cp.h>
> +# include <statx_cp.h>
> +# include <stat_t64_cp.h>
>  
>  int
> -__fstatat (int fd, const char *file, struct stat *st, int flag)
> +__fstatat_time64 (int fd, const char *file, struct __stat_t64 *st,
> int flag) {
> -# if STAT_IS_KERNEL_STAT
> -  /* New kABIs which uses generic pre 64-bit time Linux ABI, e.g.
> -     csky, nios2  */
> -  int r = INLINE_SYSCALL_CALL (fstatat64, fd, file, st, flag);
> -  if (r == 0 && (st->__st_ino_pad != 0
> -		 || st->__st_size_pad != 0
> -		 || st->__st_blocks_pad != 0))
> -    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW);
> -  return r;
> -# else
> -#  ifdef __NR_fstatat64
> -  /* Old KABIs with old non-LFS support, e.g. arm, i386, hppa, m68k,
> mips32,
> -     microblaze, s390, sh, powerpc, and sparc.  */
> +  struct statx stx;
> +  int r = INLINE_SYSCALL_CALL (statx, fd, file, flag,
> STATX_BASIC_STATS,
> +			       &stx);

I'm wondering about the indentation here - I do see 3*TAB and some
spaces. Shouldn't we only use spaces?

And one more question what is the correct alignment:
		(statx, fd, file, flag
		 &stx);

or
		(statx, fd, file, flag
		&stx);

> +  if (r == 0 || errno != ENOSYS)
> +    {
> +      if (r == 0)
> +	__cp_stat_t64_statx (st, &stx);
> +      return r;
> +    }

Great that the statx is used here.

> +
> +# ifdef __NR_fstatat64
> +  /* Both new kABI which uses generic pre 64-bit time Linux ABI
> (e.g. csky
> +     and nios) and old kABI with non-LFS support (e.g. arm, i386,
> hppa, m68k,
> +     mips32, microblaze, s390, sh, powerpc, and sparc32).  */
>    struct stat64 st64;
> -  int r = INLINE_SYSCALL_CALL (fstatat64, fd, file, &st64, flag);
> +  r = INLINE_SYSCALL_CALL (fstatat64, fd, file, &st64, flag);
>    if (r == 0)
>      {
>        if (! in_ino_t_range (st64.st_ino)
> @@ -48,7 +51,7 @@ __fstatat (int fd, const char *file, struct stat
> *st, int flag) || ! in_blkcnt_t_range (st64.st_blocks))
>  	return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW);
>  
> -      /* Clear internal pad and reserved fields.  */
> +      /* Clear both pad and reserved fields.  */
>        memset (st, 0, sizeof (*st));
>  
>        st->st_dev = st64.st_dev,
> @@ -61,22 +64,29 @@ __fstatat (int fd, const char *file, struct stat
> *st, int flag) st->st_size = st64.st_size;
>        st->st_blksize = st64.st_blksize;
>        st->st_blocks  = st64.st_blocks;
> -      st->st_atim.tv_sec = st64.st_atim.tv_sec;
> -      st->st_atim.tv_nsec = st64.st_atim.tv_nsec;
> -      st->st_mtim.tv_sec = st64.st_mtim.tv_sec;
> -      st->st_mtim.tv_nsec = st64.st_mtim.tv_nsec;
> -      st->st_ctim.tv_sec = st64.st_ctim.tv_sec;
> -      st->st_ctim.tv_nsec = st64.st_ctim.tv_nsec;
> +      st->st_atim = valid_timespec_to_timespec64 (st64.st_atim);
> +      st->st_mtim = valid_timespec_to_timespec64 (st64.st_mtim);
> +      st->st_ctim = valid_timespec_to_timespec64 (st64.st_ctim);
>      }
>    return r;
> -#  else
> +# else
>    /* 64-bit kabi outlier, e.g. mips64 and mips64-n32.  */
>    struct kernel_stat kst;
> -  int r = INTERNAL_SYSCALL_CALL (newfstatat, fd, file, &kst, flag);
> -  return r ?: __cp_kstat_stat (&kst, st);
> -#  endif /* __nr_fstatat64  */
> -# endif /* STAT_IS_KERNEL_STAT  */
> +  r = INTERNAL_SYSCALL_CALL (newfstatat, fd, file, &kst, flag);
> +  return r ?: __cp_kstat_stat_t64 (&kst, st);
> +# endif /* __NR_fstatat64  */
> +}
> +# if __TIMESIZE != 64
> +libc_hidden_def (__fstatat_time64)
> +
> +int
> +__fstatat (int fd, const char *file, struct stat *buf, int flags)
> +{
> +  struct __stat_t64 st_t64;
> +  return __fstatat_time64 (fd, file, &st_t64, flags)
> +	 ?: __cp_stat_t64_stat (&st_t64, buf);
>  }
> +# endif
>  
>  weak_alias (__fstatat, fstatat)
>  #endif
> diff --git a/sysdeps/unix/sysv/linux/fstatat64.c
> b/sysdeps/unix/sysv/linux/fstatat64.c index 82fab107a5..b3940f0d20
> 100644 --- a/sysdeps/unix/sysv/linux/fstatat64.c
> +++ b/sysdeps/unix/sysv/linux/fstatat64.c
> @@ -19,56 +19,102 @@
>  #define __fstatat __redirect___fstatat
>  #define fstatat   __redirect_fstatat
>  #include <sys/stat.h>
> -#undef __fstatat
> -#undef fstatat
>  #include <fcntl.h>
> -
> +#include <string.h>
>  #include <kernel_stat.h>
>  #include <sysdep.h>
> -
> +#include <time.h>
>  #include <statx_cp.h>
>  #include <kstat_cp.h>
> +#include <stat_t64_cp.h>
>  
>  int
> -__fstatat64 (int fd, const char *file, struct stat64 *st, int flag)
> +__fstatat64_time64 (int fd, const char *file, struct __stat64_t64
> *st,
> +		    int flag)
>  {
> +  int r;
> +
> +#if (__WORDSIZE == 32 \
> +     && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE == 32))

I do guess that the above condition is to ensure that 32 bit archs
(excluding x86_64-x32 - e.g. arm, riscv, etc) use statx?

> +  struct statx tmp;
> +  r = INLINE_SYSCALL_CALL (statx, fd, file, AT_NO_AUTOMOUNT | flag,
> +			   STATX_BASIC_STATS, &tmp);
> +  if (r == 0 || errno != ENOSYS)
> +    {
> +      if (r == 0)
> +	__cp_stat64_t64_statx (st, &tmp);
> +      return r;
> +    }
> +#endif
> +
>  #if XSTAT_IS_XSTAT64
>  # ifdef __NR_newfstatat
>    /* 64-bit kABI, e.g. aarch64, ia64, powerpc64*, s390x, riscv64, and
>       x86_64.  */
> -  return INLINE_SYSCALL_CALL (newfstatat, fd, file, st, flag);
> +  r = INLINE_SYSCALL_CALL (newfstatat, fd, file, st, flag);
>  # elif defined __NR_fstatat64
>  #  if STAT64_IS_KERNEL_STAT64
> -  /* 64-bit kABI outlier, e.g. alpha.  */
> -  return INLINE_SYSCALL_CALL (fstatat64, fd, file, st, flag);
> +  /* 64-bit kABI outlier, e.g. alpha  */
> +  r = INLINE_SYSCALL_CALL (fstatat64, fd, file, st, flag);
>  #  else
>    /* 64-bit kABI outlier, e.g. sparc64.  */
>    struct kernel_stat64 kst64;
> -  int r = INLINE_SYSCALL_CALL (fstatat64, fd, file, &kst64, flag);
> -  return r ?: __cp_stat64_kstat64 (st, &kst64);
> -#  endif
> -# else
> -  /* 32-bit kABI with default 64-bit time_t, e.g. arc, riscv32.  */
> -  struct statx tmp;
> -  int r = INLINE_SYSCALL_CALL (statx, fd, file, AT_NO_AUTOMOUNT |
> flag,
> -			       STATX_BASIC_STATS, &tmp);
> +  r = INLINE_SYSCALL_CALL (fstatat64, fd, file, &kst64, flag);
>    if (r == 0)
> -    __cp_stat64_statx (st, &tmp);
> -  return r;
> +    r = __cp_stat64_kstat64 (st, &kst64);
> +#  endif
>  # endif
>  #else
>  # ifdef __NR_fstatat64
>    /* All kABIs with non-LFS support, e.g. arm, csky, i386, hppa,
> m68k, microblaze, nios2, sh, powerpc32, and sparc32.  */
> -  return INLINE_SYSCALL_CALL (fstatat64, fd, file, st, flag);
> +  struct stat64 st64;
> +  r = INLINE_SYSCALL_CALL (fstatat64, fd, file, &st64, flag);
> +  if (r == 0)
> +    {
> +      /* Clear both pad and reserved fields.  */
> +      memset (st, 0, sizeof (*st));
> +
> +      st->st_dev = st64.st_dev,
> +      st->st_ino = st64.st_ino;
> +      st->st_mode = st64.st_mode;
> +      st->st_nlink = st64.st_nlink;
> +      st->st_uid = st64.st_uid;
> +      st->st_gid = st64.st_gid;
> +      st->st_rdev = st64.st_rdev;
> +      st->st_size = st64.st_size;
> +      st->st_blksize = st64.st_blksize;
> +      st->st_blocks  = st64.st_blocks;
> +      st->st_atim = valid_timespec_to_timespec64 (st64.st_atim);
> +      st->st_mtim = valid_timespec_to_timespec64 (st64.st_mtim);
> +      st->st_ctim = valid_timespec_to_timespec64 (st64.st_ctim);
> +    }
>  # else
>    /* 64-bit kabi outlier, e.g. mips64 and mips64-n32.  */
>    struct kernel_stat kst;
> -  int r = INTERNAL_SYSCALL_CALL (newfstatat, fd, file, &kst, flag);
> -  return r ?: __cp_kstat_stat64 (&kst, st);
> +  r = INTERNAL_SYSCALL_CALL (newfstatat, fd, file, &kst, flag);
> +  if (r == 0)
> +    r =  __cp_kstat_stat64_t64 (&kst, st);
>  # endif
>  #endif
> +
> +  return r;
>  }
> +#if __TIMESIZE != 64
> +hidden_def (__fstatat64_time64)
> +
> +int
> +__fstatat64 (int fd, const char *file, struct stat64 *st, int flags)
> +{
> +  struct __stat64_t64 st_t64;
> +  return __fstatat64_time64 (fd, file, &st_t64, flags)
> +	 ?: __cp_stat64_t64_stat64 (&st_t64, st);
> +}
> +#endif
> +
> +#undef __fstatat
> +#undef fstatat
> +
>  hidden_def (__fstatat64)
>  weak_alias (__fstatat64, fstatat64)
>  
> diff --git a/sysdeps/unix/sysv/linux/lstat.c
> b/sysdeps/unix/sysv/linux/lstat.c index b0bdeee9e9..803ad78171 100644
> --- a/sysdeps/unix/sysv/linux/lstat.c
> +++ b/sysdeps/unix/sysv/linux/lstat.c
> @@ -19,13 +19,24 @@
>  #include <sys/stat.h>
>  #include <fcntl.h>
>  #include <kernel_stat.h>
> +#include <stat_t64_cp.h>
>  
>  #if !XSTAT_IS_XSTAT64
> +int
> +__lstat_time64 (const char *file, struct __stat_t64 *buf)
> +{
> +  return __fstatat_time64 (AT_FDCWD, file, buf, AT_SYMLINK_NOFOLLOW);
> +}
> +# if __TIMESIZE != 64
> +libc_hidden_def (__lstat_time64)
> +
>  int
>  __lstat (const char *file, struct stat *buf)
>  {
> -  return __fstatat (AT_FDCWD, file, buf, AT_SYMLINK_NOFOLLOW);
> +  struct __stat_t64 st_t64;
> +  return __lstat_time64 (file, &st_t64) ?: __cp_stat_t64_stat
> (&st_t64, buf); }
> +# endif
>  
>  weak_alias (__lstat, lstat)
>  #endif
> diff --git a/sysdeps/unix/sysv/linux/lstat64.c
> b/sysdeps/unix/sysv/linux/lstat64.c index e5f02e9822..971ab8469d
> 100644 --- a/sysdeps/unix/sysv/linux/lstat64.c
> +++ b/sysdeps/unix/sysv/linux/lstat64.c
> @@ -19,19 +19,32 @@
>  #define __lstat __redirect___lstat
>  #define lstat   __redirect_lstat
>  #include <sys/stat.h>
> -#undef __lstat
> -#undef lstat
>  #include <fcntl.h>
>  #include <kernel_stat.h>
> +#include <stat_t64_cp.h>
> +
> +int
> +__lstat64_time64 (const char *file, struct __stat64_t64 *buf)
> +{
> +  return __fstatat64_time64 (AT_FDCWD, file, buf,
> AT_SYMLINK_NOFOLLOW); +}
> +#if __TIMESIZE != 64
> +hidden_def (__lstat64_time64)
>  
>  int
>  __lstat64 (const char *file, struct stat64 *buf)
>  {
> -  return __fstatat64 (AT_FDCWD, file, buf, AT_SYMLINK_NOFOLLOW);
> +  struct __stat64_t64 st_t64;
> +  return __lstat64_time64 (file, &st_t64)
> +	 ?: __cp_stat64_t64_stat64 (&st_t64, buf);
>  }
> +#endif
>  hidden_def (__lstat64)
>  weak_alias (__lstat64, lstat64)
>  
> +#undef __lstat
> +#undef lstat
> +
>  #if XSTAT_IS_XSTAT64
>  strong_alias (__lstat64, __lstat)
>  weak_alias (__lstat64, lstat)
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/kstat_cp.h
> b/sysdeps/unix/sysv/linux/mips/mips64/kstat_cp.h index
> 7f226416f9..553f4226bc 100644 ---
> a/sysdeps/unix/sysv/linux/mips/mips64/kstat_cp.h +++
> b/sysdeps/unix/sysv/linux/mips/mips64/kstat_cp.h @@ -20,23 +20,21 @@
>  #include <kernel_stat.h>
>  
>  static inline int
> -__cp_kstat_stat (const struct kernel_stat *kst, struct stat *st)
> +__cp_kstat_stat_t64 (const struct kernel_stat *kst, struct
> __stat_t64 *st) {
> +  if (! in_ino_t_range (kst->st_ino)
> +      || ! in_off_t_range (kst->st_size)
> +      || ! in_blkcnt_t_range (kst->st_blocks))
> +    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW);
> +
>    st->st_dev = kst->st_dev;
> -  memset (&st->st_pad1, 0, sizeof (st->st_pad1));
>    st->st_ino = kst->st_ino;
> -  if (st->st_ino != kst->st_ino)
> -    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW);
>    st->st_mode = kst->st_mode;
>    st->st_nlink = kst->st_nlink;
>    st->st_uid = kst->st_uid;
>    st->st_gid = kst->st_gid;
>    st->st_rdev = kst->st_rdev;
> -  memset (&st->st_pad2, 0, sizeof (st->st_pad2));
>    st->st_size = kst->st_size;
> -  if (st->st_size != kst->st_size)
> -    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW);
> -  st->st_pad3 = 0;
>    st->st_atim.tv_sec = kst->st_atime_sec;
>    st->st_atim.tv_nsec = kst->st_atime_nsec;
>    st->st_mtim.tv_sec = kst->st_mtime_sec;
> @@ -45,26 +43,20 @@ __cp_kstat_stat (const struct kernel_stat *kst,
> struct stat *st) st->st_ctim.tv_nsec = kst->st_ctime_nsec;
>    st->st_blksize = kst->st_blksize;
>    st->st_blocks = kst->st_blocks;
> -  if (st->st_blocks != kst->st_blocks)
> -    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW);
> -  memset (&st->st_pad5, 0, sizeof (st->st_pad5));
>  
>    return 0;
>  }
>  
>  static inline int
> -__cp_kstat_stat64 (const struct kernel_stat *kst, struct stat64 *st)
> +__cp_kstat_stat64_t64 (const struct kernel_stat *kst, struct
> __stat64_t64 *st) {
>    st->st_dev = kst->st_dev;
> -  memset (&st->st_pad1, 0, sizeof (st->st_pad1));
>    st->st_ino = kst->st_ino;
>    st->st_mode = kst->st_mode;
>    st->st_nlink = kst->st_nlink;
>    st->st_uid = kst->st_uid;
>    st->st_gid = kst->st_gid;
>    st->st_rdev = kst->st_rdev;
> -  memset (&st->st_pad2, 0, sizeof (st->st_pad2));
> -  st->st_pad3 = 0;
>    st->st_size = kst->st_size;
>    st->st_blksize = kst->st_blksize;
>    st->st_blocks = kst->st_blocks;
> @@ -74,7 +66,6 @@ __cp_kstat_stat64 (const struct kernel_stat *kst,
> struct stat64 *st) st->st_mtim.tv_nsec = kst->st_mtime_nsec;
>    st->st_ctim.tv_sec = kst->st_ctime_sec;
>    st->st_ctim.tv_nsec = kst->st_ctime_nsec;
> -  memset (&st->st_pad4, 0, sizeof (st->st_pad4));
>  
>    return 0;
>  }
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/statx_cp.c
> b/sysdeps/unix/sysv/linux/mips/mips64/statx_cp.c deleted file mode
> 100644 index 260cda987e..0000000000
> --- a/sysdeps/unix/sysv/linux/mips/mips64/statx_cp.c
> +++ /dev/null
> @@ -1,3 +0,0 @@
> -/* Override the generic statx_cp.c which is only needed for new
> 32-bit arch
> -   without stat64 family support.
> - */
> diff --git a/sysdeps/unix/sysv/linux/stat.c
> b/sysdeps/unix/sysv/linux/stat.c index a77502eb95..dcbc22da29 100644
> --- a/sysdeps/unix/sysv/linux/stat.c
> +++ b/sysdeps/unix/sysv/linux/stat.c
> @@ -19,13 +19,24 @@
>  #include <sys/stat.h>
>  #include <fcntl.h>
>  #include <kernel_stat.h>
> +#include <stat_t64_cp.h>
>  
>  #if !XSTAT_IS_XSTAT64
> +int
> +__stat_time64 (const char *file, struct __stat_t64 *buf)
> +{
> +  return __fstatat_time64 (AT_FDCWD, file, buf, 0);
> +}
> +# if __TIMESIZE != 64
> +libc_hidden_def (__stat_time64);
> +
>  int
>  __stat (const char *file, struct stat *buf)
>  {
> -  return __fstatat (AT_FDCWD, file, buf, 0);
> +  struct __stat_t64 st_t64;
> +  return __stat_time64 (file, &st_t64) ?: __cp_stat_t64_stat
> (&st_t64, buf); }
> +# endif
>  
>  weak_alias (__stat, stat)
>  #endif
> diff --git a/sysdeps/unix/sysv/linux/stat64.c
> b/sysdeps/unix/sysv/linux/stat64.c index 2f40037c2c..bd8b17ac49 100644
> --- a/sysdeps/unix/sysv/linux/stat64.c
> +++ b/sysdeps/unix/sysv/linux/stat64.c
> @@ -19,16 +19,30 @@
>  #define __stat __redirect___stat
>  #define stat   __redirect_stat
>  #include <sys/stat.h>
> -#undef __stat
> -#undef stat
>  #include <fcntl.h>
>  #include <kernel_stat.h>
> +#include <stat_t64_cp.h>
> +
> +int
> +__stat64_time64 (const char *file, struct __stat64_t64 *buf)
> +{
> +  return __fstatat64_time64 (AT_FDCWD, file, buf, 0);
> +}
> +#if __TIMESIZE != 64
> +hidden_def (__stat64_time64)
>  
>  int
>  __stat64 (const char *file, struct stat64 *buf)
>  {
> -  return __fstatat64 (AT_FDCWD, file, buf, 0);
> +  struct __stat64_t64 st_t64;
> +  return __stat64_time64 (file, &st_t64)
> +	 ?: __cp_stat64_t64_stat64 (&st_t64, buf);
>  }
> +#endif
> +
> +#undef __stat
> +#undef stat
> +
>  hidden_def (__stat64)
>  weak_alias (__stat64, stat64)
>  
> diff --git a/sysdeps/unix/sysv/linux/stat_t64_cp.c
> b/sysdeps/unix/sysv/linux/stat_t64_cp.c new file mode 100644
> index 0000000000..56459b6266
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/stat_t64_cp.c
> @@ -0,0 +1,92 @@
> +/* Struct stat/stat64 to stat/stat64 conversion for Linux.
> +   Copyright (C) 2020 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 <stat_t64_cp.h>
> +#include <string.h>
> +#include <errno.h>
> +#include <time.h>
> +
> +#if __TIMESIZE != 64
> +/* Convert the 64-bit time_t stat ST_T64 to the non-LFS ST stat and
> returns
> +   EOVERFLOW if any of time (access, modification, status) is larger
> than
> +   32-bit time_t.  It is used on non-LFS stat, fstat, lstat, and
> fstatat to
> +   convert from the the 64-bit time_t call.  */
> +int
> +__cp_stat_t64_stat (const struct __stat_t64 *st_t64, struct stat *st)
> +{
> +  if (! in_time_t_range (st_t64->st_atim.tv_sec)
> +      || ! in_time_t_range (st_t64->st_mtim.tv_sec)
> +      || ! in_time_t_range (st_t64->st_ctim.tv_sec))
> +    {
> +      __set_errno (EOVERFLOW);
> +      return -1;
> +    }
> +
> +  /* Clear both pad and reserved fields.  */
> +  memset (st, 0, sizeof (*st));
> +
> +  st->st_dev = st_t64->st_dev,
> +  st->st_ino = st_t64->st_ino;
> +  st->st_mode = st_t64->st_mode;
> +  st->st_nlink = st_t64->st_nlink;
> +  st->st_uid = st_t64->st_uid;
> +  st->st_gid = st_t64->st_gid;
> +  st->st_rdev = st_t64->st_rdev;
> +  st->st_size = st_t64->st_size;
> +  st->st_blksize = st_t64->st_blksize;
> +  st->st_blocks  = st_t64->st_blocks;
> +  st->st_atim = valid_timespec64_to_timespec (st_t64->st_atim);
> +  st->st_mtim = valid_timespec64_to_timespec (st_t64->st_mtim);
> +  st->st_ctim = valid_timespec64_to_timespec (st_t64->st_ctim);
> +
> +  return 0;
> +}
> +
> +int
> +__cp_stat64_t64_stat64 (const struct __stat64_t64 *st64_t64,
> +			struct stat64 *st64)
> +{
> +  if (! in_time_t_range (st64_t64->st_atim.tv_sec)
> +      || ! in_time_t_range (st64_t64->st_mtim.tv_sec)
> +      || ! in_time_t_range (st64_t64->st_ctim.tv_sec))
> +    {
> +      __set_errno (EOVERFLOW);
> +      return -1;
> +    }
> +
> +  /* Clear both pad and reserved fields.  */
> +  memset (st64, 0, sizeof (*st64));
> +
> +  st64->st_dev = st64_t64->st_dev,
> +  st64->st_ino = st64_t64->st_ino;
> +  st64->st_mode = st64_t64->st_mode;
> +  st64->st_nlink = st64_t64->st_nlink;
> +  st64->st_uid = st64_t64->st_uid;
> +  st64->st_gid = st64_t64->st_gid;
> +  st64->st_rdev = st64_t64->st_rdev;
> +  st64->st_size = st64_t64->st_size;
> +  st64->st_blksize = st64_t64->st_blksize;
> +  st64->st_blocks  = st64_t64->st_blocks;
> +  st64->st_atim = valid_timespec64_to_timespec (st64_t64->st_atim);
> +  st64->st_mtim = valid_timespec64_to_timespec (st64_t64->st_mtim);
> +  st64->st_ctim = valid_timespec64_to_timespec (st64_t64->st_ctim);
> +
> +  return 0;
> +}
> +
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/stat_t64_cp.h
> b/sysdeps/unix/sysv/linux/stat_t64_cp.h new file mode 100644
> index 0000000000..ad2bcc7a04
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/stat_t64_cp.h
> @@ -0,0 +1,28 @@
> +/* Copy to/from struct stat with and without 64-bit time_t support.
> +   Copyright (C) 2020 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>
> +
> +#if __TIMESIZE != 64
> +extern int __cp_stat_t64_stat (const struct __stat_t64 *st_t64,
> +			       struct stat *st)
> +  attribute_hidden;
> +extern int __cp_stat64_t64_stat64 (const struct __stat64_t64
> *st64_t64,
> +				   struct stat64 *st64)
> +  attribute_hidden;
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/statx_cp.c
> b/sysdeps/unix/sysv/linux/statx_cp.c index cc6e17929e..4b35e86f8d
> 100644 --- a/sysdeps/unix/sysv/linux/statx_cp.c
> +++ b/sysdeps/unix/sysv/linux/statx_cp.c
> @@ -47,3 +47,57 @@ __cp_stat64_statx (struct stat64 *to, struct statx
> *from) to->st_blksize = from->stx_blksize;
>  }
>  #endif
> +
> +void
> +__cp_stat_t64_statx (struct __stat_t64 *to, const struct statx *from)
> +{
> +  /* Clear both pad and reserved fields.  */
> +  memset (to, 0, sizeof (*to));
> +
> +  to->st_dev = ((from->stx_dev_minor & 0xff) | (from->stx_dev_major
> << 8)
> +		| ((from->stx_dev_minor & ~0xff) << 12));
> +  to->st_ino = from->stx_ino;
> +  to->st_mode = from->stx_mode;
> +  to->st_nlink = from->stx_nlink;
> +  to->st_uid = from->stx_uid;
> +  to->st_gid = from->stx_gid;
> +  to->st_rdev = ((from->stx_rdev_minor & 0xff) |
> (from->stx_rdev_major << 8)
> +		 | ((from->stx_rdev_minor & ~0xff) << 12));
> +  to->st_size = from->stx_size;
> +  to->st_blksize = from->stx_blksize;
> +  to->st_blocks = from->stx_blocks;
> +
> +  to->st_atime = from->stx_atime.tv_sec;
> +  to->st_atim.tv_nsec = from->stx_atime.tv_nsec;
> +  to->st_mtime = from->stx_mtime.tv_sec;
> +  to->st_mtim.tv_nsec = from->stx_mtime.tv_nsec;
> +  to->st_ctime = from->stx_ctime.tv_sec;
> +  to->st_ctim.tv_nsec = from->stx_ctime.tv_nsec;
> +}
> +
> +void
> +__cp_stat64_t64_statx (struct __stat64_t64 *to, const struct statx
> *from) +{
> +  /* Clear both pad and reserved fields.  */
> +  memset (to, 0, sizeof (*to));
> +
> +  to->st_dev = ((from->stx_dev_minor & 0xff) | (from->stx_dev_major
> << 8)
> +		| ((from->stx_dev_minor & ~0xff) << 12));
> +  to->st_ino = from->stx_ino;
> +  to->st_mode = from->stx_mode;
> +  to->st_nlink = from->stx_nlink;
> +  to->st_uid = from->stx_uid;
> +  to->st_gid = from->stx_gid;
> +  to->st_rdev = ((from->stx_rdev_minor & 0xff) |
> (from->stx_rdev_major << 8)
> +		 | ((from->stx_rdev_minor & ~0xff) << 12));
> +  to->st_size = from->stx_size;
> +  to->st_blksize = from->stx_blksize;
> +  to->st_blocks = from->stx_blocks;
> +
> +  to->st_atime = from->stx_atime.tv_sec;
> +  to->st_atim.tv_nsec = from->stx_atime.tv_nsec;
> +  to->st_mtime = from->stx_mtime.tv_sec;
> +  to->st_mtim.tv_nsec = from->stx_mtime.tv_nsec;
> +  to->st_ctime = from->stx_ctime.tv_sec;
> +  to->st_ctim.tv_nsec = from->stx_ctime.tv_nsec;
> +}
> diff --git a/sysdeps/unix/sysv/linux/statx_cp.h
> b/sysdeps/unix/sysv/linux/statx_cp.h index fdbb807a31..bf3186ffac
> 100644 --- a/sysdeps/unix/sysv/linux/statx_cp.h
> +++ b/sysdeps/unix/sysv/linux/statx_cp.h
> @@ -18,3 +18,9 @@
>  
>  extern void __cp_stat64_statx (struct stat64 *to, struct statx *from)
>    attribute_hidden;
> +extern void __cp_stat_t64_statx (struct __stat_t64 *to,
> +				 const struct statx *from)
> +  attribute_hidden;
> +extern void __cp_stat64_t64_statx (struct __stat64_t64 *to,
> +				   const struct statx *from)
> +  attribute_hidden;
> diff --git a/sysdeps/unix/sysv/linux/struct_stat_time64.h
> b/sysdeps/unix/sysv/linux/struct_stat_time64.h new file mode 100644
> index 0000000000..b2a51927d0
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/struct_stat_time64.h
> @@ -0,0 +1,122 @@
> +/* Struct stat with 64-bit time support.
> +   Copyright (C) 2020 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 _BITS_STRUCT_STAT_TIME64_H
> +#define _BITS_STRUCT_STAT_TIME64_H 1
> +
> +#if __TIMESIZE == 64
> +# define __stat_t64   stat
> +# define __stat64_t64 stat64
> +#else
> +# include <endian.h>
> +
> +# ifdef __USE_FILE_OFFSET64
> +#  define __field64(type, type64, name) type64 name
> +# else
> +#  define __field64(type, type64, name) type name
> +# endif
> +
> +/* The definition should be equal to the 'struct __timespec64'
> internal
> +   layout.  */
> +# if BYTE_ORDER == BIG_ENDIAN
> +#  define __fieldts64(name) 					\
> +   __time64_t name; __int32_t :32; __int32_t name ## nsec
> +# else
> +#  define __fieldts64(name)					\
> +   __time64_t name; __int32_t name ## nsec; __int32_t :32
> +# endif
> +
> +/* Workaround for the definition from struct_stat.h  */
> +# undef st_atime
> +# undef st_mtime
> +# undef st_ctime
> +
> +struct __stat_t64
> +  {
> +    __dev_t st_dev;			/* Device.  */
> +    __field64(__ino_t, __ino64_t, st_ino);  /* File serial number.
> */
> +    __mode_t st_mode;			/* File mode.  */
> +    __nlink_t st_nlink;			/* Link count.  */
> +    __uid_t st_uid;			/* User ID of the file's
> owner.	*/
> +    __gid_t st_gid;			/* Group ID of the file's
> group.*/
> +    __dev_t st_rdev;			/* Device number, if
> device.  */
> +    __field64(__off_t, __off64_t, st_size);  /* Size of file, in
> bytes. */
> +    __blksize_t st_blksize;		/* Optimal block size for
> I/O.  */
> +    __field64(__blkcnt_t, __blkcnt64_t, st_blocks);  /* 512-byte
> blocks */ +# ifdef __USE_XOPEN2K8
> +    /* Nanosecond resolution timestamps are stored in a format
> +       equivalent to 'struct timespec'.  This is the type used
> +       whenever possible but the Unix namespace rules do not allow
> the
> +       identifier 'timespec' to appear in the <sys/stat.h> header.
> +       Therefore we have to handle the use of this header in strictly
> +       standard-compliant sources special.  */
> +    struct __timespec64 st_atim;	/* Time of last access.  */
> +    struct __timespec64 st_mtim;	/* Time of last
> modification.  */
> +    struct __timespec64 st_ctim;	/* Time of last status
> change.  */ +#  define st_atime st_atim.tv_sec	/* Backward
> compatibility.  */ +#  define st_mtime st_mtim.tv_sec
> +#  define st_ctime st_ctim.tv_sec
> +# else
> +    __fieldts64 (st_atime);
> +    __fieldts64 (st_mtime);
> +    __fieldts64 (st_ctime);
> +# endif /* __USE_XOPEN2K8  */
> +  };
> +
> +# undef __field64
> +
> +#ifdef __USE_LARGEFILE64
> +struct __stat64_t64
> +  {
> +    __dev_t st_dev;			/* Device.  */
> +    __ino64_t st_ino;			/* file serial
> number.	*/
> +    __mode_t st_mode;			/* File mode.  */
> +    __nlink_t st_nlink;			/* Link count.  */
> +    __uid_t st_uid;			/* User ID of the file's
> owner.	*/
> +    __gid_t st_gid;			/* Group ID of the file's
> group.*/
> +    __dev_t st_rdev;			/* Device number, if
> device.  */
> +    __off64_t st_size;			/* Size of file, in
> bytes.  */
> +    __blksize_t st_blksize;		/* Optimal block size for
> I/O.  */
> +    __blkcnt64_t st_blocks;		/* Number 512-byte blocks
> allocated. */ +# ifdef __USE_XOPEN2K8
> +    /* Nanosecond resolution timestamps are stored in a format
> +       equivalent to 'struct timespec'.  This is the type used
> +       whenever possible but the Unix namespace rules do not allow
> the
> +       identifier 'timespec' to appear in the <sys/stat.h> header.
> +       Therefore we have to handle the use of this header in strictly
> +       standard-compliant sources special.  */
> +    struct __timespec64 st_atim;	/* Time of last access.  */
> +    struct __timespec64 st_mtim;	/* Time of last
> modification.  */
> +    struct __timespec64 st_ctim;	/* Time of last status
> change.  */ +# else
> +    __fieldts64 (st_atime);
> +    __fieldts64 (st_mtime);
> +    __fieldts64 (st_ctime);
> +# endif /* __USE_XOPEN2K8  */
> +  };
> +# endif /* __USE_LARGEFILE64  */
> +
> +# undef __fieldts64
> +
> +# define _STATBUF_ST_BLKSIZE
> +# define _STATBUF_ST_RDEV
> +# define _STATBUF_ST_NSEC
> +
> +# endif /* __TIMESIZE == 64  */
> +
> +#endif /* _BITS_STRUCT_STAT_TIME64_H  */

Despite some very minor comments,

Acked-by: Lukasz Majewski <lukma@denx.de>


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 16/16] linux: Move xmknoda{at} to compat symbols
  2020-07-24 10:30   ` Florian Weimer via Libc-alpha
@ 2020-07-24 12:34     ` Adhemerval Zanella via Libc-alpha
  2020-07-24 12:43       ` Florian Weimer via Libc-alpha
  0 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-07-24 12:34 UTC (permalink / raw)
  To: Florian Weimer, Adhemerval Zanella via Libc-alpha; +Cc: Alistair Francis



On 24/07/2020 07:30, Florian Weimer wrote:
> * Adhemerval Zanella via Libc-alpha:
> 
>> diff --git a/sysdeps/unix/sysv/linux/mknodat.c b/sysdeps/unix/sysv/linux/mknodat.c
>> new file mode 100644
>> index 0000000000..d160fe520b
>> --- /dev/null
>> +++ b/sysdeps/unix/sysv/linux/mknodat.c
>> @@ -0,0 +1,41 @@
> 
>> +int
>> +__mknodat_common (int fd, const char *path, mode_t mode, dev_t *dev)
>> +{
>> +  /* We must convert the value to dev_t type used by the kernel.  */
>> +  unsigned long long int k_dev = (*dev) & ((1ULL << 32) - 1);
>> +  if (k_dev != *dev)
>> +    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
>> +
>> +  return INLINE_SYSCALL_CALL (mknodat, fd, path, mode,
>> +			      (unsigned int) k_dev);
>> +}
> 
> This looks suspicious yo me.  Why use a dev_t * argument?  Why check
> against the unsigned long long int value, when the kernel receives an
> unsigned int value in the system call?

Because glibc exports dev_t is 64-bit on all architectures (__DEV_T_TYPE),
while kernel current only accepts 32-bits.  But I used the dev_t *
argument to make it more straightforward to implement xmknod{at}.  I 
can change to use a dev_t as well

> 
> What's the intended difference between __mknodat_common and __mknodat
None, in fact I think it would be better to implement xmknod{at} in terms
of mknod{at}.

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

* Re: [PATCH 16/16] linux: Move xmknoda{at} to compat symbols
  2020-07-24 12:34     ` Adhemerval Zanella via Libc-alpha
@ 2020-07-24 12:43       ` Florian Weimer via Libc-alpha
  2020-07-24 12:49         ` Adhemerval Zanella via Libc-alpha
  0 siblings, 1 reply; 80+ messages in thread
From: Florian Weimer via Libc-alpha @ 2020-07-24 12:43 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Alistair Francis, Adhemerval Zanella via Libc-alpha

* Adhemerval Zanella:

> On 24/07/2020 07:30, Florian Weimer wrote:
>> * Adhemerval Zanella via Libc-alpha:
>> 
>>> diff --git a/sysdeps/unix/sysv/linux/mknodat.c b/sysdeps/unix/sysv/linux/mknodat.c
>>> new file mode 100644
>>> index 0000000000..d160fe520b
>>> --- /dev/null
>>> +++ b/sysdeps/unix/sysv/linux/mknodat.c
>>> @@ -0,0 +1,41 @@
>> 
>>> +int
>>> +__mknodat_common (int fd, const char *path, mode_t mode, dev_t *dev)
>>> +{
>>> +  /* We must convert the value to dev_t type used by the kernel.  */
>>> +  unsigned long long int k_dev = (*dev) & ((1ULL << 32) - 1);
>>> +  if (k_dev != *dev)
>>> +    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
>>> +
>>> +  return INLINE_SYSCALL_CALL (mknodat, fd, path, mode,
>>> +			      (unsigned int) k_dev);
>>> +}
>> 
>> This looks suspicious yo me.  Why use a dev_t * argument?  Why check
>> against the unsigned long long int value, when the kernel receives an
>> unsigned int value in the system call?
>
> Because glibc exports dev_t is 64-bit on all architectures (__DEV_T_TYPE),
> while kernel current only accepts 32-bits.

But then the type of k_dev should be unsigned int, I think.

> But I used the dev_t * argument to make it more straightforward to
> implement xmknod{at}.  I can change to use a dev_t as well

Yes please.

Thanks,
Florian


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

* Re: [PATCH 16/16] linux: Move xmknoda{at} to compat symbols
  2020-07-24 12:43       ` Florian Weimer via Libc-alpha
@ 2020-07-24 12:49         ` Adhemerval Zanella via Libc-alpha
  0 siblings, 0 replies; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-07-24 12:49 UTC (permalink / raw)
  To: Florian Weimer; +Cc: Alistair Francis, Adhemerval Zanella via Libc-alpha



On 24/07/2020 09:43, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> On 24/07/2020 07:30, Florian Weimer wrote:
>>> * Adhemerval Zanella via Libc-alpha:
>>>
>>>> diff --git a/sysdeps/unix/sysv/linux/mknodat.c b/sysdeps/unix/sysv/linux/mknodat.c
>>>> new file mode 100644
>>>> index 0000000000..d160fe520b
>>>> --- /dev/null
>>>> +++ b/sysdeps/unix/sysv/linux/mknodat.c
>>>> @@ -0,0 +1,41 @@
>>>
>>>> +int
>>>> +__mknodat_common (int fd, const char *path, mode_t mode, dev_t *dev)
>>>> +{
>>>> +  /* We must convert the value to dev_t type used by the kernel.  */
>>>> +  unsigned long long int k_dev = (*dev) & ((1ULL << 32) - 1);
>>>> +  if (k_dev != *dev)
>>>> +    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
>>>> +
>>>> +  return INLINE_SYSCALL_CALL (mknodat, fd, path, mode,
>>>> +			      (unsigned int) k_dev);
>>>> +}
>>>
>>> This looks suspicious yo me.  Why use a dev_t * argument?  Why check
>>> against the unsigned long long int value, when the kernel receives an
>>> unsigned int value in the system call?
>>
>> Because glibc exports dev_t is 64-bit on all architectures (__DEV_T_TYPE),
>> while kernel current only accepts 32-bits.
> 
> But then the type of k_dev should be unsigned int, I think.

Indeed, the code at least does it on the INLINE_SYSCALL_CALL. I copied the 
code as is from current linux xmknodat, but I agree with you that it is
not the most clear one.

> 
>> But I used the dev_t * argument to make it more straightforward to
>> implement xmknod{at}.  I can change to use a dev_t as well
> 
> Yes please.

Ack.
 

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

* Re: [PATCH 13/16] linux: Disentangle fstatat from fxstatat
  2020-07-24 10:25   ` Florian Weimer via Libc-alpha
@ 2020-07-24 14:39     ` Adhemerval Zanella via Libc-alpha
  0 siblings, 0 replies; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-07-24 14:39 UTC (permalink / raw)
  To: Florian Weimer, Adhemerval Zanella via Libc-alpha; +Cc: Alistair Francis



On 24/07/2020 07:25, Florian Weimer wrote:
> * Adhemerval Zanella via Libc-alpha:
> 
>> diff --git a/sysdeps/unix/sysv/linux/kstat_cp.h b/sysdeps/unix/sysv/linux/kstat_cp.h
>> new file mode 100644
>> index 0000000000..8fa43ed2e1
>> --- /dev/null
>> +++ b/sysdeps/unix/sysv/linux/kstat_cp.h
>> @@ -0,0 +1,2 @@
>> +/* Empty, it is overridden by an architecture which might require copy to ro
>> +   from a kernel_stat stat struct to glibc export stat{64}.  */
> 
> Typo: or

Ack.

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

* Re: [PATCH 15/16] linux: Add {f}stat{at} y2038 support
  2020-07-24 10:53   ` Lukasz Majewski
@ 2020-07-30 12:42     ` Adhemerval Zanella via Libc-alpha
  2020-08-02 19:46       ` Maciej W. Rozycki via Libc-alpha
  0 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-07-30 12:42 UTC (permalink / raw)
  To: Lukasz Majewski; +Cc: Alistair Francis, libc-alpha


[-- Attachment #1.1: Type: text/plain, Size: 4830 bytes --]



On 24/07/2020 07:53, Lukasz Majewski wrote:
>>  
>> diff --git a/sysdeps/unix/sysv/linux/fstatat.c
>> b/sysdeps/unix/sysv/linux/fstatat.c index 03ddb3f493..f65d3b74a6
>> 100644 --- a/sysdeps/unix/sysv/linux/fstatat.c
>> +++ b/sysdeps/unix/sysv/linux/fstatat.c
>> -#  ifdef __NR_fstatat64
>> -  /* Old KABIs with old non-LFS support, e.g. arm, i386, hppa, m68k,
>> mips32,
>> -     microblaze, s390, sh, powerpc, and sparc.  */
>> +  struct statx stx;
>> +  int r = INLINE_SYSCALL_CALL (statx, fd, file, flag,
>> STATX_BASIC_STATS,
>> +			       &stx);
> 
> I'm wondering about the indentation here - I do see 3*TAB and some
> spaces. Shouldn't we only use spaces?

Afaik the GNU code guidelines requires to use TAB indentations instead
of space in this case.  


> 
> And one more question what is the correct alignment:
> 		(statx, fd, file, flag
> 		 &stx);
> 
> or
> 		(statx, fd, file, flag
> 		&stx);

My understanding the latter.

> 
>> +  if (r == 0 || errno != ENOSYS)
>> +    {
>> +      if (r == 0)
>> +	__cp_stat_t64_statx (st, &stx);
>> +      return r;
>> +    }
> 
> Great that the statx is used here.
> 
>> +
>> +# ifdef __NR_fstatat64
>> +  /* Both new kABI which uses generic pre 64-bit time Linux ABI
>> (e.g. csky
>> +     and nios) and old kABI with non-LFS support (e.g. arm, i386,
>> hppa, m68k,
>> +     mips32, microblaze, s390, sh, powerpc, and sparc32).  */
>>    struct stat64 st64;
>> -  int r = INLINE_SYSCALL_CALL (fstatat64, fd, file, &st64, flag);
>> +  r = INLINE_SYSCALL_CALL (fstatat64, fd, file, &st64, flag);
>>    if (r == 0)
>>      {
>>        if (! in_ino_t_range (st64.st_ino)
>> @@ -48,7 +51,7 @@ __fstatat (int fd, const char *file, struct stat
>> *st, int flag) || ! in_blkcnt_t_range (st64.st_blocks))
>>  	return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW);
>>  
>> -      /* Clear internal pad and reserved fields.  */
>> +      /* Clear both pad and reserved fields.  */
>>        memset (st, 0, sizeof (*st));
>>  
>>        st->st_dev = st64.st_dev,
>> @@ -61,22 +64,29 @@ __fstatat (int fd, const char *file, struct stat
>> *st, int flag) st->st_size = st64.st_size;
>>        st->st_blksize = st64.st_blksize;
>>        st->st_blocks  = st64.st_blocks;
>> -      st->st_atim.tv_sec = st64.st_atim.tv_sec;
>> -      st->st_atim.tv_nsec = st64.st_atim.tv_nsec;
>> -      st->st_mtim.tv_sec = st64.st_mtim.tv_sec;
>> -      st->st_mtim.tv_nsec = st64.st_mtim.tv_nsec;
>> -      st->st_ctim.tv_sec = st64.st_ctim.tv_sec;
>> -      st->st_ctim.tv_nsec = st64.st_ctim.tv_nsec;
>> +      st->st_atim = valid_timespec_to_timespec64 (st64.st_atim);
>> +      st->st_mtim = valid_timespec_to_timespec64 (st64.st_mtim);
>> +      st->st_ctim = valid_timespec_to_timespec64 (st64.st_ctim);
>>      }
>>    return r;
>> -#  else
>> +# else
>>    /* 64-bit kabi outlier, e.g. mips64 and mips64-n32.  */
>>    struct kernel_stat kst;
>> -  int r = INTERNAL_SYSCALL_CALL (newfstatat, fd, file, &kst, flag);
>> -  return r ?: __cp_kstat_stat (&kst, st);
>> -#  endif /* __nr_fstatat64  */
>> -# endif /* STAT_IS_KERNEL_STAT  */
>> +  r = INTERNAL_SYSCALL_CALL (newfstatat, fd, file, &kst, flag);
>> +  return r ?: __cp_kstat_stat_t64 (&kst, st);
>> +# endif /* __NR_fstatat64  */
>> +}
>> +# if __TIMESIZE != 64
>> +libc_hidden_def (__fstatat_time64)
>> +
>> +int
>> +__fstatat (int fd, const char *file, struct stat *buf, int flags)
>> +{
>> +  struct __stat_t64 st_t64;
>> +  return __fstatat_time64 (fd, file, &st_t64, flags)
>> +	 ?: __cp_stat_t64_stat (&st_t64, buf);
>>  }
>> +# endif
>>  
>>  weak_alias (__fstatat, fstatat)
>>  #endif
>> diff --git a/sysdeps/unix/sysv/linux/fstatat64.c
>> b/sysdeps/unix/sysv/linux/fstatat64.c index 82fab107a5..b3940f0d20
>> 100644 --- a/sysdeps/unix/sysv/linux/fstatat64.c
>> +++ b/sysdeps/unix/sysv/linux/fstatat64.c
>> @@ -19,56 +19,102 @@
>>  #define __fstatat __redirect___fstatat
>>  #define fstatat   __redirect_fstatat
>>  #include <sys/stat.h>
>> -#undef __fstatat
>> -#undef fstatat
>>  #include <fcntl.h>
>> -
>> +#include <string.h>
>>  #include <kernel_stat.h>
>>  #include <sysdep.h>
>> -
>> +#include <time.h>
>>  #include <statx_cp.h>
>>  #include <kstat_cp.h>
>> +#include <stat_t64_cp.h>
>>  
>>  int
>> -__fstatat64 (int fd, const char *file, struct stat64 *st, int flag)
>> +__fstatat64_time64 (int fd, const char *file, struct __stat64_t64
>> *st,
>> +		    int flag)
>>  {
>> +  int r;
>> +
>> +#if (__WORDSIZE == 32 \
>> +     && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE == 32))
> 
> I do guess that the above condition is to ensure that 32 bit archs
> (excluding x86_64-x32 - e.g. arm, riscv, etc) use statx?

Yes, this is similar for what is done by SysVIPC fixes. 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 15/16] linux: Add {f}stat{at} y2038 support
  2020-07-30 12:42     ` Adhemerval Zanella via Libc-alpha
@ 2020-08-02 19:46       ` Maciej W. Rozycki via Libc-alpha
  0 siblings, 0 replies; 80+ messages in thread
From: Maciej W. Rozycki via Libc-alpha @ 2020-08-02 19:46 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha, Alistair Francis

On Thu, 30 Jul 2020, Adhemerval Zanella via Libc-alpha wrote:

> > And one more question what is the correct alignment:
> > 		(statx, fd, file, flag
> > 		 &stx);
> > 
> > or
> > 		(statx, fd, file, flag
> > 		&stx);
> 
> My understanding the latter.

 The opposite AFAIK, and you can always use `indent -gnu' to get the stuff 
right as far as "The GNU Coding Standards" are concerned, except perhaps 
for some really obscure code such as I believe some multi-line macros, and 
also some newer constructs such as ISO C99 compound literals may not work 
out well and have to be fixed up by hand (at least with older versions of 
GNU indent; I haven't checked what the most recent behaves like).

 Of course GNU indent will not handle project-specific extra rules such as 
ours: <https://sourceware.org/glibc/wiki/Style_and_Conventions>.

  Maciej

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

* Re: [PATCH 03/16] linux: Consolidate xstat{64}
  2020-07-23 19:46 ` [PATCH 03/16] linux: Consolidate xstat{64} Adhemerval Zanella via Libc-alpha
  2020-07-23 20:51   ` Joseph Myers
  2020-07-24  8:34   ` Lukasz Majewski
@ 2020-09-09 14:46   ` Lukasz Majewski
  2020-09-09 18:05     ` Adhemerval Zanella via Libc-alpha
  2 siblings, 1 reply; 80+ messages in thread
From: Lukasz Majewski @ 2020-09-09 14:46 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Alistair Francis, libc-alpha

[-- Attachment #1: Type: text/plain, Size: 30422 bytes --]

Hi Adhemerval,

> The LFS support is implemented on xstat64.c, instead of xstat.c for
> 64-bit architectures.  The xstat.c implements the non-LFS it is
> no-op for !XSTAT_IS_XSTAT64.
> 

Do we have any more input for this patch series? In other words - when
it can find its way to -master?

> The generic non-LFS implementation handle two cases:
> 
>   1. New kABIs which uses generic pre 64-bit time Linux ABI (csky and
>      nios): it issues __NR_fstat64 plus handle the overflow on st_ino,
>      st_size, or st_blocks.  It only handles _STAT_VER_KERNEL.
> 
>   2. Old KABIs with old non-LFS support (arm, i386, hppa, m68k,
>      microblaze, s390, sh, powerpc, and sparc32).  For
> _STAT_VER_KERNEL it issues __NR_stat, otherwise it issues __NR_stat64
> and convert to non-LFS stat struct handling possible overflows on
> st_ino, st_size, or st_blocks.
> 
> Also the  non-LFS mips is an outlier and it has its own implementation
> since _STAT_VER_LINUX requires a different conversion function (it
> uses the kernel_stat as the syscall argument since its exported ABI is
> different than the kernel one for both non-LFS and LFS
> implementation).
> 
> The generic LFS implementation handles multiple cases:
> 
>   1. XSTAT_IS_XSTAT64 being 1:
> 
>     1.1. Old 64-bit kABI (ia64, powerpc64*, s390x, sparc64, x86_64):
> it issues __NR_stat for _STAT_VER_KERNEL or _STAT_VER_LINUX.
> 
>     1.2. New kABIs which uses generic 64-bit Linux ABI (aarch64 and
>          riscv64): it issues __NR_newfstatat and only for
>          _STAT_VER_KERNEL.
> 
>     1.3. New 32-bit kABIs with only 64-bit time_t support (arc and
> 	 riscv32): it issues __NR_statx and covert to struct stat64.
> 
>   2. Old ABIs with XSTAT_IS_XSTAT64 being 0:
> 
>     2.1. New kABIs which uses generic pre 64-bit time Linux ABI (csky
> 	 and nios2): it issues __NR_fstatat64 for _STAT_VER_KERNEL.
> 
>     2.2. Old kABIs with old non-LFS support (arm, i386, hppa, m68k,
> 	 microblaze, s390, sh, mips32, powerpc32, and sparc32): it
> 	 issues __NR_stat64.
> 
> Also, two special cases requires specific LFS implementations:
> 
>   1. alpha: it requires to handle _STAT_VER_KERNEL64 to call
> __NR_stat64 or use the kernel_stat with __NR_stat otherwise.
> 
>   2. mips64: as for non-LFS implementation its ABIs differ from glibc
>      exported one, which requires an specific conversion function to
>      handle the kernel_stat.
> 
> Checked with a build for all affected ABIs. I also checked on x86_64,
> i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and s390x.
> ---
>  sysdeps/unix/sysv/linux/alpha/xstat.c         | 57 ----------------
>  .../{generic/xstat.c => alpha/xstat64.c}      | 47 ++++++-------
>  sysdeps/unix/sysv/linux/arm/xstat.c           |  1 -
>  .../sysv/linux/generic/wordsize-32/xstat.c    | 54 ---------------
>  .../sysv/linux/generic/wordsize-32/xstat64.c  | 63 -----------------
>  sysdeps/unix/sysv/linux/hppa/xstat.c          |  1 -
>  sysdeps/unix/sysv/linux/i386/xstat.c          | 59 ----------------
>  sysdeps/unix/sysv/linux/m68k/xstat.c          |  1 -
>  sysdeps/unix/sysv/linux/microblaze/xstat.c    |  1 -
>  sysdeps/unix/sysv/linux/mips/mips64/xstat64.c | 16 +----
>  .../sysv/linux/{wordsize-64 => mips}/xstat.c  | 32 +++++----
>  .../unix/sysv/linux/powerpc/powerpc32/xstat.c |  1 -
>  sysdeps/unix/sysv/linux/s390/s390-32/xstat.c  |  1 -
>  sysdeps/unix/sysv/linux/sh/xstat.c            |  1 -
>  sysdeps/unix/sysv/linux/sparc/sparc32/xstat.c |  1 -
>  sysdeps/unix/sysv/linux/sparc/sparc64/xstat.c |  1 -
>  sysdeps/unix/sysv/linux/wordsize-64/xstat64.c |  1 -
>  sysdeps/unix/sysv/linux/xstat.c               | 60 +++++++++--------
>  sysdeps/unix/sysv/linux/xstat64.c             | 51 ++++++++++++--
>  sysdeps/unix/sysv/linux/xstatover.h           | 67
> +++++++++++++++++++ 20 files changed, 184 insertions(+), 332
> deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/alpha/xstat.c
>  rename sysdeps/unix/sysv/linux/{generic/xstat.c => alpha/xstat64.c}
> (57%) delete mode 100644 sysdeps/unix/sysv/linux/arm/xstat.c
>  delete mode 100644
> sysdeps/unix/sysv/linux/generic/wordsize-32/xstat.c delete mode
> 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/xstat64.c delete
> mode 100644 sysdeps/unix/sysv/linux/hppa/xstat.c delete mode 100644
> sysdeps/unix/sysv/linux/i386/xstat.c delete mode 100644
> sysdeps/unix/sysv/linux/m68k/xstat.c delete mode 100644
> sysdeps/unix/sysv/linux/microblaze/xstat.c rename
> sysdeps/unix/sysv/linux/{wordsize-64 => mips}/xstat.c (67%) delete
> mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/xstat.c delete
> mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/xstat.c delete mode
> 100644 sysdeps/unix/sysv/linux/sh/xstat.c delete mode 100644
> sysdeps/unix/sysv/linux/sparc/sparc32/xstat.c delete mode 100644
> sysdeps/unix/sysv/linux/sparc/sparc64/xstat.c delete mode 100644
> sysdeps/unix/sysv/linux/wordsize-64/xstat64.c create mode 100644
> sysdeps/unix/sysv/linux/xstatover.h
> 
> diff --git a/sysdeps/unix/sysv/linux/alpha/xstat.c
> b/sysdeps/unix/sysv/linux/alpha/xstat.c deleted file mode 100644
> index 3ba1ae1811..0000000000
> --- a/sysdeps/unix/sysv/linux/alpha/xstat.c
> +++ /dev/null
> @@ -1,57 +0,0 @@
> -/* xstat using old-style Unix stat system call.
> -   Copyright (C) 2004-2020 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 __xstat64 __xstat64_disable
> -
> -#include <errno.h>
> -#include <stddef.h>
> -#include <sys/stat.h>
> -#include <kernel_stat.h>
> -#include <sysdep.h>
> -#include <sys/syscall.h>
> -#include <xstatconv.h>
> -
> -#undef __xstat64
> -
> -
> -/* Get information about the file NAME in BUF.  */
> -int
> -__xstat (int vers, const char *name, struct stat *buf)
> -{
> -  int result;
> -  struct kernel_stat kbuf;
> -
> -  if (vers == _STAT_VER_KERNEL64)
> -    {
> -      result = INTERNAL_SYSCALL_CALL (stat64, name, buf);
> -      if (__glibc_likely (!INTERNAL_SYSCALL_ERROR_P (result)))
> -	return result;
> -      __set_errno (INTERNAL_SYSCALL_ERRNO (result));
> -      return -1;
> -    }
> -
> -  result = INTERNAL_SYSCALL_CALL (stat, name, &kbuf);
> -  if (__glibc_likely (!INTERNAL_SYSCALL_ERROR_P (result)))
> -    return __xstat_conv (vers, &kbuf, buf);
> -  __set_errno (INTERNAL_SYSCALL_ERRNO (result));
> -  return -1;
> -}
> -hidden_def (__xstat)
> -weak_alias (__xstat, _xstat);
> -strong_alias (__xstat, __xstat64);
> -hidden_ver (__xstat, __xstat64)
> diff --git a/sysdeps/unix/sysv/linux/generic/xstat.c
> b/sysdeps/unix/sysv/linux/alpha/xstat64.c similarity index 57%
> rename from sysdeps/unix/sysv/linux/generic/xstat.c
> rename to sysdeps/unix/sysv/linux/alpha/xstat64.c
> index 2eb27a6f91..ac1af53780 100644
> --- a/sysdeps/unix/sysv/linux/generic/xstat.c
> +++ b/sysdeps/unix/sysv/linux/alpha/xstat64.c
> @@ -1,6 +1,6 @@
> -/* Copyright (C) 2011-2020 Free Software Foundation, Inc.
> +/* xstat using old-style Unix stat system call.
> +   Copyright (C) 2004-2020 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,33 +16,34 @@
>     License along with the GNU C Library.  If not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -/* Ignore prototype to avoid error if we alias __xstat and
> __xstat64. */ -#define __xstat64 __xstat64_disable
> -
> -#include <errno.h>
> -#include <stddef.h>
> -#include <fcntl.h>
> +#define __xstat __redirect___xstat
>  #include <sys/stat.h>
> +#undef __xstat
> +#include <fcntl.h>
>  #include <kernel_stat.h>
> -
>  #include <sysdep.h>
> -#include <sys/syscall.h>
> +#include <xstatconv.h>
>  
>  /* Get information about the file NAME in BUF.  */
>  int
> -__xstat (int vers, const char *name, struct stat *buf)
> +__xstat64 (int vers, const char *name, struct stat64 *buf)
>  {
> -  if (vers == _STAT_VER_KERNEL)
> -    return INLINE_SYSCALL (newfstatat, 4, AT_FDCWD, name, buf, 0);
> -
> -  errno = EINVAL;
> -  return -1;
> +  switch (vers)
> +    {
> +    case _STAT_VER_KERNEL64:
> +      return INLINE_SYSCALL_CALL (stat64, name, buf);
> +
> +    default:
> +      {
> +        struct kernel_stat kbuf;
> +	int r = INTERNAL_SYSCALL_CALL (stat, name, &kbuf);
> +	if (r == 0)
> +	  return __xstat_conv (vers, &kbuf, buf);
> +	return INLINE_SYSCALL_ERROR_RETURN_VALUE (-r);
> +      }
> +    }
>  }
> +weak_alias (__xstat64, __xstat);
> +weak_alias (__xstat64, __GI___xstat);
>  
> -hidden_def (__xstat)
> -weak_alias (__xstat, _xstat);
> -#if XSTAT_IS_XSTAT64
> -#undef __xstat64
> -strong_alias (__xstat, __xstat64);
> -hidden_ver (__xstat, __xstat64)
> -#endif
> +hidden_def (__xstat64)
> diff --git a/sysdeps/unix/sysv/linux/arm/xstat.c
> b/sysdeps/unix/sysv/linux/arm/xstat.c deleted file mode 100644
> index e9869f5508..0000000000
> --- a/sysdeps/unix/sysv/linux/arm/xstat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/xstat.c>
> diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/xstat.c
> b/sysdeps/unix/sysv/linux/generic/wordsize-32/xstat.c deleted file
> mode 100644 index a4a921c1ea..0000000000
> --- a/sysdeps/unix/sysv/linux/generic/wordsize-32/xstat.c
> +++ /dev/null
> @@ -1,54 +0,0 @@
> -/* Copyright (C) 2011-2020 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 <errno.h>
> -#include <stddef.h>
> -#include <fcntl.h>
> -#include <sys/stat.h>
> -#include <kernel_stat.h>
> -
> -#include <sysdep.h>
> -#include <sys/syscall.h>
> -
> -#if !XSTAT_IS_XSTAT64
> -#include "overflow.h"
> -#include <statx_cp.h>
> -
> -/* Get information about the file NAME in BUF.  */
> -int
> -__xstat (int vers, const char *name, struct stat *buf)
> -{
> -  if (vers == _STAT_VER_KERNEL)
> -    {
> -# ifdef __NR_fstatat64
> -      int rc = INLINE_SYSCALL (fstatat64, 4, AT_FDCWD, name, buf, 0);
> -# else
> -      struct statx tmp;
> -      int rc = INLINE_SYSCALL (statx, 5, AT_FDCWD, name,
> AT_NO_AUTOMOUNT,
> -                               STATX_BASIC_STATS, &tmp);
> -      if (rc == 0)
> -        __cp_stat64_statx ((struct stat64 *)buf, &tmp);
> -# endif
> -      return rc ?: stat_overflow (buf);
> -    }
> -
> -  errno = EINVAL;
> -  return -1;
> -}
> -hidden_def (__xstat)
> -#endif
> diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/xstat64.c
> b/sysdeps/unix/sysv/linux/generic/wordsize-32/xstat64.c deleted file
> mode 100644 index 0848b5a4b4..0000000000
> --- a/sysdeps/unix/sysv/linux/generic/wordsize-32/xstat64.c
> +++ /dev/null
> @@ -1,63 +0,0 @@
> -/* Copyright (C) 2011-2020 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/>.  */
> -
> -/* Hide the prototype for __xstat so that GCC will not complain about
> -   the different function signature if it is aliased to  __xstat64.
> -   If XSTAT_IS_XSTAT64 is set to non-zero then the stat and stat64
> -   structures have an identical layout but different type names.  */
> -
> -#define __xstat __xstat_disable
> -
> -#include <errno.h>
> -#include <stddef.h>
> -#include <fcntl.h>
> -#include <sys/stat.h>
> -#include <kernel_stat.h>
> -
> -#include <sysdep.h>
> -#include <sys/syscall.h>
> -
> -#include <statx_cp.h>
> -
> -/* Get information about the file NAME in BUF.  */
> -int
> -__xstat64 (int vers, const char *name, struct stat64 *buf)
> -{
> -  if (vers == _STAT_VER_KERNEL)
> -    {
> -#ifdef __NR_fstatat64
> -      return INLINE_SYSCALL (fstatat64, 4, AT_FDCWD, name, buf, 0);
> -#else
> -      struct statx tmp;
> -      int rc = INLINE_SYSCALL (statx, 5, AT_FDCWD, name,
> AT_NO_AUTOMOUNT,
> -                               STATX_BASIC_STATS, &tmp);
> -      if (rc == 0)
> -        __cp_stat64_statx (buf, &tmp);
> -      return rc;
> -#endif
> -    }
> -  errno = EINVAL;
> -  return -1;
> -}
> -hidden_def (__xstat64)
> -
> -#undef __xstat
> -#if XSTAT_IS_XSTAT64
> -strong_alias (__xstat64, __xstat)
> -hidden_ver (__xstat64, __xstat)
> -#endif
> diff --git a/sysdeps/unix/sysv/linux/hppa/xstat.c
> b/sysdeps/unix/sysv/linux/hppa/xstat.c deleted file mode 100644
> index e9869f5508..0000000000
> --- a/sysdeps/unix/sysv/linux/hppa/xstat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/xstat.c>
> diff --git a/sysdeps/unix/sysv/linux/i386/xstat.c
> b/sysdeps/unix/sysv/linux/i386/xstat.c deleted file mode 100644
> index 96f67168ac..0000000000
> --- a/sysdeps/unix/sysv/linux/i386/xstat.c
> +++ /dev/null
> @@ -1,59 +0,0 @@
> -/* xstat using old-style Unix stat system call.
> -   Copyright (C) 1991-2020 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/>.  */
> -
> -/* Ho hum, if xstat == xstat64 we must get rid of the prototype or
> gcc
> -   will complain since they don't strictly match.  */
> -#define __xstat64 __xstat64_disable
> -
> -#include <errno.h>
> -#include <stddef.h>
> -#include <sys/stat.h>
> -#include <kernel_stat.h>
> -
> -#include <sysdep.h>
> -#include <sys/syscall.h>
> -
> -#include <xstatconv.h>
> -
> -
> -/* Get information about the file NAME in BUF.  */
> -int
> -__xstat (int vers, const char *name, struct stat *buf)
> -{
> -  int result;
> -
> -  if (vers == _STAT_VER_KERNEL)
> -    return INLINE_SYSCALL (stat, 2, name, buf);
> -
> -  {
> -    struct stat64 buf64;
> -
> -    result = INTERNAL_SYSCALL_CALL (stat64, name, &buf64);
> -    if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result)))
> -      return INLINE_SYSCALL_ERROR_RETURN_VALUE
> (INTERNAL_SYSCALL_ERRNO (result));
> -    else
> -      return __xstat32_conv (vers, &buf64, buf);
> -  }
> -}
> -hidden_def (__xstat)
> -weak_alias (__xstat, _xstat);
> -#if XSTAT_IS_XSTAT64
> -# undef __xstat64
> -strong_alias (__xstat, __xstat64);
> -hidden_ver (__xstat, __xstat64)
> -#endif
> diff --git a/sysdeps/unix/sysv/linux/m68k/xstat.c
> b/sysdeps/unix/sysv/linux/m68k/xstat.c deleted file mode 100644
> index e9869f5508..0000000000
> --- a/sysdeps/unix/sysv/linux/m68k/xstat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/xstat.c>
> diff --git a/sysdeps/unix/sysv/linux/microblaze/xstat.c
> b/sysdeps/unix/sysv/linux/microblaze/xstat.c deleted file mode 100644
> index e9869f5508..0000000000
> --- a/sysdeps/unix/sysv/linux/microblaze/xstat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/xstat.c>
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/xstat64.c
> b/sysdeps/unix/sysv/linux/mips/mips64/xstat64.c index
> 7eee9e67d4..99b03c7593 100644 ---
> a/sysdeps/unix/sysv/linux/mips/mips64/xstat64.c +++
> b/sysdeps/unix/sysv/linux/mips/mips64/xstat64.c @@ -1,4 +1,4 @@
> -/* xstat64 using 64-bit MIPS stat system call.
> +/* xstat64 using Linux stat64 system call.
>     Copyright (C) 1991-2020 Free Software Foundation, Inc.
>     This file is part of the GNU C Library.
>  
> @@ -16,14 +16,9 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -#include <errno.h>
> -#include <stddef.h>
>  #include <sys/stat.h>
>  #include <kernel_stat.h>
> -
>  #include <sysdep.h>
> -#include <sys/syscall.h>
> -
>  #include <xstatconv.h>
>  
>  /* Get information about the file NAME in BUF.  */
> @@ -31,14 +26,9 @@
>  int
>  __xstat64 (int vers, const char *name, struct stat64 *buf)
>  {
> -  int result;
>    struct kernel_stat kbuf;
> -
> -  result = INLINE_SYSCALL (stat, 2, name, &kbuf);
> -  if (result == 0)
> -    result = __xstat64_conv (vers, &kbuf, buf);
> -
> -  return result;
> +  int r = INLINE_SYSCALL_CALL (stat, name, &kbuf);
> +  return r ?: __xstat64_conv (vers, &kbuf, buf);
>  }
>  
>  hidden_def (__xstat64)
> diff --git a/sysdeps/unix/sysv/linux/wordsize-64/xstat.c
> b/sysdeps/unix/sysv/linux/mips/xstat.c similarity index 67%
> rename from sysdeps/unix/sysv/linux/wordsize-64/xstat.c
> rename to sysdeps/unix/sysv/linux/mips/xstat.c
> index 438d54d291..835691cf89 100644
> --- a/sysdeps/unix/sysv/linux/wordsize-64/xstat.c
> +++ b/sysdeps/unix/sysv/linux/mips/xstat.c
> @@ -16,29 +16,27 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -/* Ho hum, since xstat == xstat64 we must get rid of the prototype
> or gcc
> -   will complain since they don't strictly match.  */
> -#define __xstat64 __xstat64_disable
> -
> -#include <errno.h>
> -#include <stddef.h>
>  #include <sys/stat.h>
> -
> +#include <fcntl.h>
> +#include <kernel_stat.h>
>  #include <sysdep.h>
> -#include <sys/syscall.h>
> +#include <xstatconv.h>
>  
>  /* Get information about the file NAME in BUF.  */
>  int
>  __xstat (int vers, const char *name, struct stat *buf)
>  {
> -  if (vers == _STAT_VER_KERNEL || vers == _STAT_VER_LINUX)
> -    return INLINE_SYSCALL (stat, 2, name, buf);
> -
> -  __set_errno (EINVAL);
> -  return -1;
> +  switch (vers)
> +    {
> +    case _STAT_VER_KERNEL:
> +      return INLINE_SYSCALL_CALL (stat, name, buf);
> +
> +    default:
> +      {
> +	struct kernel_stat kbuf;
> +	int r = INTERNAL_SYSCALL_CALL (stat, name, &kbuf);
> +	return r ?: __xstat_conv (vers, &kbuf, buf);
> +      }
> +    }
>  }
>  hidden_def (__xstat)
> -weak_alias (__xstat, _xstat);
> -#undef __xstat64
> -strong_alias (__xstat, __xstat64);
> -hidden_ver (__xstat, __xstat64)
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/xstat.c
> b/sysdeps/unix/sysv/linux/powerpc/powerpc32/xstat.c deleted file mode
> 100644 index e9869f5508..0000000000
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/xstat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/xstat.c>
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/xstat.c
> b/sysdeps/unix/sysv/linux/s390/s390-32/xstat.c deleted file mode
> 100644 index e9869f5508..0000000000
> --- a/sysdeps/unix/sysv/linux/s390/s390-32/xstat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/xstat.c>
> diff --git a/sysdeps/unix/sysv/linux/sh/xstat.c
> b/sysdeps/unix/sysv/linux/sh/xstat.c deleted file mode 100644
> index e9869f5508..0000000000
> --- a/sysdeps/unix/sysv/linux/sh/xstat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/xstat.c>
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/xstat.c
> b/sysdeps/unix/sysv/linux/sparc/sparc32/xstat.c deleted file mode
> 100644 index e9869f5508..0000000000
> --- a/sysdeps/unix/sysv/linux/sparc/sparc32/xstat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/xstat.c>
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/xstat.c
> b/sysdeps/unix/sysv/linux/sparc/sparc64/xstat.c deleted file mode
> 100644 index c3b00cb1d4..0000000000
> --- a/sysdeps/unix/sysv/linux/sparc/sparc64/xstat.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include "../../i386/xstat.c"
> diff --git a/sysdeps/unix/sysv/linux/wordsize-64/xstat64.c
> b/sysdeps/unix/sysv/linux/wordsize-64/xstat64.c deleted file mode
> 100644 index e7acd3b45e..0000000000
> --- a/sysdeps/unix/sysv/linux/wordsize-64/xstat64.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -/* xstat64 is in xstat.c */
> diff --git a/sysdeps/unix/sysv/linux/xstat.c
> b/sysdeps/unix/sysv/linux/xstat.c index 76c90e20c7..0ae52b1901 100644
> --- a/sysdeps/unix/sysv/linux/xstat.c
> +++ b/sysdeps/unix/sysv/linux/xstat.c
> @@ -16,44 +16,46 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -/* Ho hum, if xstat == xstat64 we must get rid of the prototype or
> gcc
> -   will complain since they don't strictly match.  */
> -#define __xstat64 __xstat64_disable
> -
> -#include <errno.h>
> -#include <stddef.h>
>  #include <sys/stat.h>
> +#include <fcntl.h>
>  #include <kernel_stat.h>
> -
>  #include <sysdep.h>
> -#include <sys/syscall.h>
>  
> -#include <xstatconv.h>
> +#if !XSTAT_IS_XSTAT64
> +# include <xstatconv.h>
> +# include <xstatover.h>
>  
>  /* Get information about the file NAME in BUF.  */
>  int
>  __xstat (int vers, const char *name, struct stat *buf)
>  {
> -  if (vers == _STAT_VER_KERNEL)
> -    return INLINE_SYSCALL (stat, 2, name, buf);
> -
> -#if STAT_IS_KERNEL_STAT
> -  return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
> -#else
> -  struct kernel_stat kbuf;
> -  int result;
> -
> -  result = INLINE_SYSCALL (stat, 2, name, &kbuf);
> -  if (result == 0)
> -    result = __xstat_conv (vers, &kbuf, buf);
> -
> -  return result;
> +  switch (vers)
> +    {
> +    case _STAT_VER_KERNEL:
> +      {
> +# if STAT_IS_KERNEL_STAT
> +	/* New kABIs which uses generic pre 64-bit time Linux ABI,
> +	   e.g. csky, nios2  */
> +	int r = INLINE_SYSCALL_CALL (fstatat64, AT_FDCWD, name, buf,
> 0);
> +	return r ?: stat_overflow (buf);
> +# else
> +	/* Old kABIs with old non-LFS support, e.g. arm, i386, hppa,
> m68k,
> +	   microblaze, s390, sh, powerpc, and sparc32.  */
> +	return INLINE_SYSCALL_CALL (stat, name, buf);
> +# endif
> +      }
> +
> +    default:
> +      {
> +# if STAT_IS_KERNEL_STAT
> +	return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
> +# else
> +	struct stat64 buf64;
> +	int r = INLINE_SYSCALL_CALL (stat64, name, &buf64);
> +	return r ?: __xstat32_conv (vers, &buf64, buf);
>  #endif
> +      }
> +    }
>  }
>  hidden_def (__xstat)
> -weak_alias (__xstat, _xstat);
> -#if XSTAT_IS_XSTAT64
> -#undef __xstat64
> -strong_alias (__xstat, __xstat64);
> -hidden_ver (__xstat, __xstat64)
> -#endif
> +#endif /* XSTAT_IS_XSTAT64  */
> diff --git a/sysdeps/unix/sysv/linux/xstat64.c
> b/sysdeps/unix/sysv/linux/xstat64.c index 16c6e69710..4feb55f429
> 100644 --- a/sysdeps/unix/sysv/linux/xstat64.c
> +++ b/sysdeps/unix/sysv/linux/xstat64.c
> @@ -16,24 +16,61 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -#include <errno.h>
> -#include <stddef.h>
> +#define __xstat __redirect___xstat
>  #include <sys/stat.h>
> +#undef __xstat
> +#include <fcntl.h>
>  #include <kernel_stat.h>
> -
>  #include <sysdep.h>
> -#include <sys/syscall.h>
> +#include <xstatconv.h>
> +#include <statx_cp.h>
>  
>  /* Get information about the file NAME in BUF.  */
>  
>  int
>  ___xstat64 (int vers, const char *name, struct stat64 *buf)
>  {
> -  int result;
> -  result = INLINE_SYSCALL (stat64, 2, name, buf);
> -  return result;
> +#if XSTAT_IS_XSTAT64
> +# if defined __NR_stat
> +  /* Old 64-bit kABI, e.g. ia64, powerpc64*, s390x, sparc64, x86_64.
>  */
> +  if (vers == _STAT_VER_KERNEL || vers == _STAT_VER_LINUX)
> +    return INLINE_SYSCALL_CALL (stat, name, buf);
> +# elif defined __NR_newfstatat
> +  /* New kABIs which uses generic 64-bit Linux ABI, e.g. aarch64,
> riscv64.  */
> +  if (vers == _STAT_VER_KERNEL)
> +    return INLINE_SYSCALL_CALL (newfstatat, AT_FDCWD, name, buf, 0);
> +# else
> +  /* New 32-bit kABIs with only 64-bit time_t support, e.g. arc,
> riscv32.  */
> +  if (vers == _STAT_VER_KERNEL)
> +    {
> +      struct statx tmp;
> +      int r = INLINE_SYSCALL_CALL (statx, AT_FDCWD, name,
> AT_NO_AUTOMOUNT,
> +				   STATX_BASIC_STATS, &tmp);
> +      if (r == 0)
> +	__cp_stat64_statx (buf, &tmp);
> +      return r;
> +     }
> +# endif
> +#else
> +# if STAT_IS_KERNEL_STAT
> +  /* New kABIs which uses generic pre 64-bit time Linux ABI,
> +     e.g. csky, nios2  */
> +  if (vers == _STAT_VER_KERNEL)
> +    return INLINE_SYSCALL_CALL (fstatat64, AT_FDCWD, name, buf, 0);
> +# else
> +  /* Old kABIs with old non-LFS support, e.g. arm, i386, hppa, m68k,
> +     microblaze, s390, sh, mips32, powerpc32, and sparc32.  */
> +  return INLINE_SYSCALL_CALL (stat64, name, buf);
> +# endif /* STAT_IS_KERNEL_STAT  */
> +#endif /* XSTAT_IS_XSTAT64  */
> +
> +  return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
>  }
>  
> +#if XSTAT_IS_XSTAT64
> +weak_alias (___xstat64, __xstat);
> +weak_alias (___xstat64, __GI___xstat);
> +#endif
>  
>  #include <shlib-compat.h>
>  
> diff --git a/sysdeps/unix/sysv/linux/xstatover.h
> b/sysdeps/unix/sysv/linux/xstatover.h new file mode 100644
> index 0000000000..20178114f9
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/xstatover.h
> @@ -0,0 +1,67 @@
> +/* Overflow tests for stat, statfs, and lseek functions.
> +   Copyright (C) 2020 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 <sys/statfs.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 || !STAT_IS_KERNEL_STAT
> +  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 || !STAT_IS_KERNEL_STAT
> +  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
> +}




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 03/16] linux: Consolidate xstat{64}
  2020-09-09 14:46   ` Lukasz Majewski
@ 2020-09-09 18:05     ` Adhemerval Zanella via Libc-alpha
  2020-09-10  7:10       ` Lukasz Majewski
  0 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-09-09 18:05 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Florian Weimer, Alistair Francis, libc-alpha, Joseph Myers


[-- Attachment #1.1: Type: text/plain, Size: 1073 bytes --]



On 09/09/2020 11:46, Lukasz Majewski wrote:
> Hi Adhemerval,
> 
>> The LFS support is implemented on xstat64.c, instead of xstat.c for
>> 64-bit architectures.  The xstat.c implements the non-LFS it is
>> no-op for !XSTAT_IS_XSTAT64.
>>
> 
> Do we have any more input for this patch series? In other words - when
> it can find its way to -master?

I will rebase this patchset and do some re-testing on different platforms
to check for regressions.  I have addressed the remarks done by Joseph
and Florian, but I am not sure if they are planning to do more reviews.

I think patches from 01 to 08 should be ok to go, they are mostly
refactoring. I will double check if any syscall is changed over all the
support architectures and commit them. 

I will resend the 08 to 16 with the changes I added, mainly the rewrite of
some descriptor and the removal of the combination of 64-bit times with 
32-bit offsets (it is not supposed to be supported).

I do like to get this done on 2.33, as well with all other remaining work
for y2038 support.



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 03/16] linux: Consolidate xstat{64}
  2020-09-09 18:05     ` Adhemerval Zanella via Libc-alpha
@ 2020-09-10  7:10       ` Lukasz Majewski
  0 siblings, 0 replies; 80+ messages in thread
From: Lukasz Majewski @ 2020-09-10  7:10 UTC (permalink / raw)
  To: Adhemerval Zanella
  Cc: Florian Weimer, Alistair Francis, libc-alpha, Joseph Myers

[-- Attachment #1: Type: text/plain, Size: 1649 bytes --]

Hi Adhemerval,

> On 09/09/2020 11:46, Lukasz Majewski wrote:
> > Hi Adhemerval,
> >   
> >> The LFS support is implemented on xstat64.c, instead of xstat.c for
> >> 64-bit architectures.  The xstat.c implements the non-LFS it is
> >> no-op for !XSTAT_IS_XSTAT64.
> >>  
> > 
> > Do we have any more input for this patch series? In other words -
> > when it can find its way to -master?  
> 
> I will rebase this patchset and do some re-testing on different
> platforms to check for regressions.  I have addressed the remarks
> done by Joseph and Florian, but I am not sure if they are planning to
> do more reviews.

Thanks for the status update.

> 
> I think patches from 01 to 08 should be ok to go, they are mostly
> refactoring. I will double check if any syscall is changed over all
> the support architectures and commit them. 

Great, thanks.

> 
> I will resend the 08 to 16 with the changes I added, mainly the
> rewrite of some descriptor and the removal of the combination of
> 64-bit times with 32-bit offsets (it is not supposed to be supported).

Ok.

> 
> I do like to get this done on 2.33, as well with all other remaining
> work for y2038 support.
> 
> 

I do have pthread_rwlock_{clock|timed}{rd|wr}lock 64 bit support on my
queue as well (despite sem_{clock|timed}wait, for which I will wait a
few days and then commit it).

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 15/16] linux: Add {f}stat{at} y2038 support
  2020-07-23 19:46 ` [PATCH 15/16] linux: Add {f}stat{at} y2038 support Adhemerval Zanella via Libc-alpha
  2020-07-23 20:55   ` Joseph Myers
  2020-07-24 10:53   ` Lukasz Majewski
@ 2020-10-06  9:48   ` Lukasz Majewski
  2020-10-07 12:52     ` Adhemerval Zanella via Libc-alpha
  2 siblings, 1 reply; 80+ messages in thread
From: Lukasz Majewski @ 2020-10-06  9:48 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Alistair Francis, libc-alpha

[-- Attachment #1: Type: text/plain, Size: 1177 bytes --]

Hi Adhemerval,

> A new struct __stat{64}_t64 type is added with the required
> __timespec64 time definition.  Both non-LFS and LFS support were
> done with an extra __NR_statx call plus a conversion to the new
> __stat{64}_t64 type.  The statx call is done only for architectures
> with support for 32-bit time_t ABI.
> 
> Internally some extra routines to copy from/to struct stat{64}
> to struct __stat{64} used on multiple implementations (stat, fstat,
> lstat, and fstatat) are added on a extra file (stat_t64_cp.c).  Aslo
> some extra routines to copy from statx to __stat{64} is added on
> statx_cp.c.
> 
> Checked with a build for all affected ABIs. I also checked on x86_64,
> i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and s390x.

When do you plan to pull this patch set to -master?
Those patches have been available for review on the mailing list for
more than two months now.

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 15/16] linux: Add {f}stat{at} y2038 support
  2020-10-06  9:48   ` Lukasz Majewski
@ 2020-10-07 12:52     ` Adhemerval Zanella via Libc-alpha
  2020-10-07 14:25       ` Adhemerval Zanella via Libc-alpha
  0 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-10-07 12:52 UTC (permalink / raw)
  To: Lukasz Majewski; +Cc: Alistair Francis, libc-alpha


[-- Attachment #1.1: Type: text/plain, Size: 1124 bytes --]



On 06/10/2020 06:48, Lukasz Majewski wrote:
> Hi Adhemerval,
> 
>> A new struct __stat{64}_t64 type is added with the required
>> __timespec64 time definition.  Both non-LFS and LFS support were
>> done with an extra __NR_statx call plus a conversion to the new
>> __stat{64}_t64 type.  The statx call is done only for architectures
>> with support for 32-bit time_t ABI.
>>
>> Internally some extra routines to copy from/to struct stat{64}
>> to struct __stat{64} used on multiple implementations (stat, fstat,
>> lstat, and fstatat) are added on a extra file (stat_t64_cp.c).  Aslo
>> some extra routines to copy from statx to __stat{64} is added on
>> statx_cp.c.
>>
>> Checked with a build for all affected ABIs. I also checked on x86_64,
>> i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and s390x.
> 
> When do you plan to pull this patch set to -master?
> Those patches have been available for review on the mailing list for
> more than two months now.

Hi Lukasz, thanks to remind me. I will rebase against master and run
some regressions tests against some platforms and push it.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 15/16] linux: Add {f}stat{at} y2038 support
  2020-10-07 12:52     ` Adhemerval Zanella via Libc-alpha
@ 2020-10-07 14:25       ` Adhemerval Zanella via Libc-alpha
  2020-10-07 20:20         ` Lukasz Majewski
                           ` (2 more replies)
  0 siblings, 3 replies; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-10-07 14:25 UTC (permalink / raw)
  To: Lukasz Majewski; +Cc: Alistair Francis, libc-alpha


[-- Attachment #1.1: Type: text/plain, Size: 1602 bytes --]



On 07/10/2020 09:52, Adhemerval Zanella wrote:
> 
> 
> On 06/10/2020 06:48, Lukasz Majewski wrote:
>> Hi Adhemerval,
>>
>>> A new struct __stat{64}_t64 type is added with the required
>>> __timespec64 time definition.  Both non-LFS and LFS support were
>>> done with an extra __NR_statx call plus a conversion to the new
>>> __stat{64}_t64 type.  The statx call is done only for architectures
>>> with support for 32-bit time_t ABI.
>>>
>>> Internally some extra routines to copy from/to struct stat{64}
>>> to struct __stat{64} used on multiple implementations (stat, fstat,
>>> lstat, and fstatat) are added on a extra file (stat_t64_cp.c).  Aslo
>>> some extra routines to copy from statx to __stat{64} is added on
>>> statx_cp.c.
>>>
>>> Checked with a build for all affected ABIs. I also checked on x86_64,
>>> i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and s390x.
>>
>> When do you plan to pull this patch set to -master?
>> Those patches have been available for review on the mailing list for
>> more than two months now.
> 
> Hi Lukasz, thanks to remind me. I will rebase against master and run
> some regressions tests against some platforms and push it.
> 

One required change with the rebase is adapt the riscv32 ABI to exclude 
the __{f,l}xstat{at} symbol and replace with proper {f,l}stat ones. 
It is possible because the new ABI was added on current development
branch, however one minor inconvenient is the toolchain need to be
rebuild with a updated glibc branch to avoid linking failures with
libstd++ (which uses __{f,l}xstat{at}).


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 15/16] linux: Add {f}stat{at} y2038 support
  2020-10-07 14:25       ` Adhemerval Zanella via Libc-alpha
@ 2020-10-07 20:20         ` Lukasz Majewski
  2020-10-07 21:01           ` Adhemerval Zanella via Libc-alpha
  2020-10-07 21:07         ` Adhemerval Zanella via Libc-alpha
  2020-10-13 13:58         ` Lukasz Majewski
  2 siblings, 1 reply; 80+ messages in thread
From: Lukasz Majewski @ 2020-10-07 20:20 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Alistair Francis, libc-alpha

[-- Attachment #1: Type: text/plain, Size: 2161 bytes --]

Hi Adhemerval,

> On 07/10/2020 09:52, Adhemerval Zanella wrote:
> > 
> > 
> > On 06/10/2020 06:48, Lukasz Majewski wrote:  
> >> Hi Adhemerval,
> >>  
> >>> A new struct __stat{64}_t64 type is added with the required
> >>> __timespec64 time definition.  Both non-LFS and LFS support were
> >>> done with an extra __NR_statx call plus a conversion to the new
> >>> __stat{64}_t64 type.  The statx call is done only for
> >>> architectures with support for 32-bit time_t ABI.
> >>>
> >>> Internally some extra routines to copy from/to struct stat{64}
> >>> to struct __stat{64} used on multiple implementations (stat,
> >>> fstat, lstat, and fstatat) are added on a extra file
> >>> (stat_t64_cp.c).  Aslo some extra routines to copy from statx to
> >>> __stat{64} is added on statx_cp.c.
> >>>
> >>> Checked with a build for all affected ABIs. I also checked on
> >>> x86_64, i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and
> >>> s390x.  
> >>
> >> When do you plan to pull this patch set to -master?
> >> Those patches have been available for review on the mailing list
> >> for more than two months now.  
> > 
> > Hi Lukasz, thanks to remind me. I will rebase against master and run
> > some regressions tests against some platforms and push it.
> >   
> 
> One required change with the rebase is adapt the riscv32 ABI to
> exclude the __{f,l}xstat{at} symbol and replace with proper {f,l}stat
> ones. It is possible because the new ABI was added on current
> development branch, however one minor inconvenient is the toolchain
> need to be rebuild with a updated glibc branch to avoid linking
> failures with libstd++ (which uses __{f,l}xstat{at}).
> 

Does it mean that we would need to run glibc-many-builds with
{checkout,host-libraries,compilers} after we update the branch?

We would need to rebuild the toolchain anyway for rv32 anyway?


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 15/16] linux: Add {f}stat{at} y2038 support
  2020-10-07 20:20         ` Lukasz Majewski
@ 2020-10-07 21:01           ` Adhemerval Zanella via Libc-alpha
  0 siblings, 0 replies; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-10-07 21:01 UTC (permalink / raw)
  To: Lukasz Majewski; +Cc: Alistair Francis, libc-alpha


[-- Attachment #1.1: Type: text/plain, Size: 2100 bytes --]



On 07/10/2020 17:20, Lukasz Majewski wrote:
> Hi Adhemerval,
> 
>> On 07/10/2020 09:52, Adhemerval Zanella wrote:
>>>
>>>
>>> On 06/10/2020 06:48, Lukasz Majewski wrote:  
>>>> Hi Adhemerval,
>>>>  
>>>>> A new struct __stat{64}_t64 type is added with the required
>>>>> __timespec64 time definition.  Both non-LFS and LFS support were
>>>>> done with an extra __NR_statx call plus a conversion to the new
>>>>> __stat{64}_t64 type.  The statx call is done only for
>>>>> architectures with support for 32-bit time_t ABI.
>>>>>
>>>>> Internally some extra routines to copy from/to struct stat{64}
>>>>> to struct __stat{64} used on multiple implementations (stat,
>>>>> fstat, lstat, and fstatat) are added on a extra file
>>>>> (stat_t64_cp.c).  Aslo some extra routines to copy from statx to
>>>>> __stat{64} is added on statx_cp.c.
>>>>>
>>>>> Checked with a build for all affected ABIs. I also checked on
>>>>> x86_64, i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and
>>>>> s390x.  
>>>>
>>>> When do you plan to pull this patch set to -master?
>>>> Those patches have been available for review on the mailing list
>>>> for more than two months now.  
>>>
>>> Hi Lukasz, thanks to remind me. I will rebase against master and run
>>> some regressions tests against some platforms and push it.
>>>   
>>
>> One required change with the rebase is adapt the riscv32 ABI to
>> exclude the __{f,l}xstat{at} symbol and replace with proper {f,l}stat
>> ones. It is possible because the new ABI was added on current
>> development branch, however one minor inconvenient is the toolchain
>> need to be rebuild with a updated glibc branch to avoid linking
>> failures with libstd++ (which uses __{f,l}xstat{at}).
>>
> 
> Does it mean that we would need to run glibc-many-builds with
> {checkout,host-libraries,compilers} after we update the branch?
> 
> We would need to rebuild the toolchain anyway for rv32 anyway?

Yes, at least 'checkout' to get the most recent glibc and 'compilers'
to build a proper toolchain with the expect baseline ABI.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 15/16] linux: Add {f}stat{at} y2038 support
  2020-10-07 14:25       ` Adhemerval Zanella via Libc-alpha
  2020-10-07 20:20         ` Lukasz Majewski
@ 2020-10-07 21:07         ` Adhemerval Zanella via Libc-alpha
  2020-10-08  7:57           ` Lukasz Majewski
  2020-10-13 13:58         ` Lukasz Majewski
  2 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-10-07 21:07 UTC (permalink / raw)
  To: Lukasz Majewski; +Cc: Alistair Francis, libc-alpha


[-- Attachment #1.1: Type: text/plain, Size: 1969 bytes --]



On 07/10/2020 11:25, Adhemerval Zanella wrote:
> 
> 
> On 07/10/2020 09:52, Adhemerval Zanella wrote:
>>
>>
>> On 06/10/2020 06:48, Lukasz Majewski wrote:
>>> Hi Adhemerval,
>>>
>>>> A new struct __stat{64}_t64 type is added with the required
>>>> __timespec64 time definition.  Both non-LFS and LFS support were
>>>> done with an extra __NR_statx call plus a conversion to the new
>>>> __stat{64}_t64 type.  The statx call is done only for architectures
>>>> with support for 32-bit time_t ABI.
>>>>
>>>> Internally some extra routines to copy from/to struct stat{64}
>>>> to struct __stat{64} used on multiple implementations (stat, fstat,
>>>> lstat, and fstatat) are added on a extra file (stat_t64_cp.c).  Aslo
>>>> some extra routines to copy from statx to __stat{64} is added on
>>>> statx_cp.c.
>>>>
>>>> Checked with a build for all affected ABIs. I also checked on x86_64,
>>>> i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and s390x.
>>>
>>> When do you plan to pull this patch set to -master?
>>> Those patches have been available for review on the mailing list for
>>> more than two months now.
>>
>> Hi Lukasz, thanks to remind me. I will rebase against master and run
>> some regressions tests against some platforms and push it.
>>
> 
> One required change with the rebase is adapt the riscv32 ABI to exclude 
> the __{f,l}xstat{at} symbol and replace with proper {f,l}stat ones. 
> It is possible because the new ABI was added on current development
> branch, however one minor inconvenient is the toolchain need to be
> rebuild with a updated glibc branch to avoid linking failures with
> libstd++ (which uses __{f,l}xstat{at}).
> 

Ok, I have ran the testsuite on x86_64, x32, i686, aarch64, armhf,
powerpc, powerpc64, powerpc64le, sparc64, sparcv9, s390x, and s390
without regression. I will just finish the testing on mips, mips64,
and alpha since they require some specific implementations.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 15/16] linux: Add {f}stat{at} y2038 support
  2020-10-07 21:07         ` Adhemerval Zanella via Libc-alpha
@ 2020-10-08  7:57           ` Lukasz Majewski
  2020-10-09 14:05             ` Adhemerval Zanella via Libc-alpha
  0 siblings, 1 reply; 80+ messages in thread
From: Lukasz Majewski @ 2020-10-08  7:57 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Alistair Francis, libc-alpha

[-- Attachment #1: Type: text/plain, Size: 2627 bytes --]

Hi Adhemerval,

> On 07/10/2020 11:25, Adhemerval Zanella wrote:
> > 
> > 
> > On 07/10/2020 09:52, Adhemerval Zanella wrote:  
> >>
> >>
> >> On 06/10/2020 06:48, Lukasz Majewski wrote:  
> >>> Hi Adhemerval,
> >>>  
> >>>> A new struct __stat{64}_t64 type is added with the required
> >>>> __timespec64 time definition.  Both non-LFS and LFS support were
> >>>> done with an extra __NR_statx call plus a conversion to the new
> >>>> __stat{64}_t64 type.  The statx call is done only for
> >>>> architectures with support for 32-bit time_t ABI.
> >>>>
> >>>> Internally some extra routines to copy from/to struct stat{64}
> >>>> to struct __stat{64} used on multiple implementations (stat,
> >>>> fstat, lstat, and fstatat) are added on a extra file
> >>>> (stat_t64_cp.c).  Aslo some extra routines to copy from statx to
> >>>> __stat{64} is added on statx_cp.c.
> >>>>
> >>>> Checked with a build for all affected ABIs. I also checked on
> >>>> x86_64, i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and
> >>>> s390x.  
> >>>
> >>> When do you plan to pull this patch set to -master?
> >>> Those patches have been available for review on the mailing list
> >>> for more than two months now.  
> >>
> >> Hi Lukasz, thanks to remind me. I will rebase against master and
> >> run some regressions tests against some platforms and push it.
> >>  
> > 
> > One required change with the rebase is adapt the riscv32 ABI to
> > exclude the __{f,l}xstat{at} symbol and replace with proper
> > {f,l}stat ones. It is possible because the new ABI was added on
> > current development branch, however one minor inconvenient is the
> > toolchain need to be rebuild with a updated glibc branch to avoid
> > linking failures with libstd++ (which uses __{f,l}xstat{at}).
> >   
> 
> Ok, I have ran the testsuite on x86_64, x32, i686, aarch64, armhf,
> powerpc, powerpc64, powerpc64le, sparc64, sparcv9, s390x, and s390
> without regression. I will just finish the testing on mips, mips64,
> and alpha since they require some specific implementations.
> 

That would be a huge step forward.

According to list in the following commit message:
https://github.com/lmajewski/y2038_glibc/commit/73215359e184d96b415e87b585a4396b5bd0936c

Then I will send an RFC for enabling support for 64 bit time on
eligible architectures.

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 15/16] linux: Add {f}stat{at} y2038 support
  2020-10-08  7:57           ` Lukasz Majewski
@ 2020-10-09 14:05             ` Adhemerval Zanella via Libc-alpha
  2020-10-09 15:39               ` Lukasz Majewski
  0 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-10-09 14:05 UTC (permalink / raw)
  To: Lukasz Majewski; +Cc: Alistair Francis, libc-alpha


[-- Attachment #1.1: Type: text/plain, Size: 3903 bytes --]



On 08/10/2020 04:57, Lukasz Majewski wrote:
> Hi Adhemerval,
> 
>> On 07/10/2020 11:25, Adhemerval Zanella wrote:
>>>
>>>
>>> On 07/10/2020 09:52, Adhemerval Zanella wrote:  
>>>>
>>>>
>>>> On 06/10/2020 06:48, Lukasz Majewski wrote:  
>>>>> Hi Adhemerval,
>>>>>  
>>>>>> A new struct __stat{64}_t64 type is added with the required
>>>>>> __timespec64 time definition.  Both non-LFS and LFS support were
>>>>>> done with an extra __NR_statx call plus a conversion to the new
>>>>>> __stat{64}_t64 type.  The statx call is done only for
>>>>>> architectures with support for 32-bit time_t ABI.
>>>>>>
>>>>>> Internally some extra routines to copy from/to struct stat{64}
>>>>>> to struct __stat{64} used on multiple implementations (stat,
>>>>>> fstat, lstat, and fstatat) are added on a extra file
>>>>>> (stat_t64_cp.c).  Aslo some extra routines to copy from statx to
>>>>>> __stat{64} is added on statx_cp.c.
>>>>>>
>>>>>> Checked with a build for all affected ABIs. I also checked on
>>>>>> x86_64, i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and
>>>>>> s390x.  
>>>>>
>>>>> When do you plan to pull this patch set to -master?
>>>>> Those patches have been available for review on the mailing list
>>>>> for more than two months now.  
>>>>
>>>> Hi Lukasz, thanks to remind me. I will rebase against master and
>>>> run some regressions tests against some platforms and push it.
>>>>  
>>>
>>> One required change with the rebase is adapt the riscv32 ABI to
>>> exclude the __{f,l}xstat{at} symbol and replace with proper
>>> {f,l}stat ones. It is possible because the new ABI was added on
>>> current development branch, however one minor inconvenient is the
>>> toolchain need to be rebuild with a updated glibc branch to avoid
>>> linking failures with libstd++ (which uses __{f,l}xstat{at}).
>>>   
>>
>> Ok, I have ran the testsuite on x86_64, x32, i686, aarch64, armhf,
>> powerpc, powerpc64, powerpc64le, sparc64, sparcv9, s390x, and s390
>> without regression. I will just finish the testing on mips, mips64,
>> and alpha since they require some specific implementations.
>>
> 
> That would be a huge step forward.
> 
> According to list in the following commit message:
> https://github.com/lmajewski/y2038_glibc/commit/73215359e184d96b415e87b585a4396b5bd0936c

The mips testing caught an issue on where the "linux: Disentangle 
fstatat from fxstatat" patch uses INTERNAL_SYSCALL_CALL where
it should use INLINE_SYSCALL_CALL (which sets the errno).  I have
fixed and this only affects mips, so my testing should cover all
the affects architectures (I got access to a ia64 machine again
and I will run a regression test once I commit this to master).

> 
> Then I will send an RFC for enabling support for 64 bit time on
> eligible architectures.

There still some missing implementations I have on my local tree:

 1. wait3: it is a straightforward fix since it just calls __wait4_time64.
 2. ftime: we need to move it to a compatibility symbol, so there will
    be no need to add a time64 variant to support the deprecated symbol.
 3. futimesat: we need to remove the implementation on generic folder
    and handle UTIME_NOW and UTIME_OMIT correctly.
 4. recvvmsg/recvmsg: we need to handle ancillary data. I recently send
    patch that tries to handle it [1] [2] [3]. It is more in a RFC and
    I don't think it is strictly necessary.
 5. utmp/utmpx/lastlog: I also sent a fix to handle the 64-bit support
    on this [4]

I will send 1. 2. 3., since they are the easiest one to review.

[1] https://sourceware.org/pipermail/libc-alpha/2020-September/117484.html
[2] https://sourceware.org/pipermail/libc-alpha/2020-September/117485.html
[3] https://sourceware.org/pipermail/libc-alpha/2020-September/117486.html
[4] https://sourceware.org/pipermail/libc-alpha/2020-August/116850.html


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 15/16] linux: Add {f}stat{at} y2038 support
  2020-10-09 14:05             ` Adhemerval Zanella via Libc-alpha
@ 2020-10-09 15:39               ` Lukasz Majewski
  2020-10-09 20:06                 ` Adhemerval Zanella via Libc-alpha
  0 siblings, 1 reply; 80+ messages in thread
From: Lukasz Majewski @ 2020-10-09 15:39 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Alistair Francis, libc-alpha

[-- Attachment #1: Type: text/plain, Size: 4903 bytes --]

Hi Adhemerval,

> On 08/10/2020 04:57, Lukasz Majewski wrote:
> > Hi Adhemerval,
> >   
> >> On 07/10/2020 11:25, Adhemerval Zanella wrote:  
> >>>
> >>>
> >>> On 07/10/2020 09:52, Adhemerval Zanella wrote:    
> >>>>
> >>>>
> >>>> On 06/10/2020 06:48, Lukasz Majewski wrote:    
> >>>>> Hi Adhemerval,
> >>>>>    
> >>>>>> A new struct __stat{64}_t64 type is added with the required
> >>>>>> __timespec64 time definition.  Both non-LFS and LFS support
> >>>>>> were done with an extra __NR_statx call plus a conversion to
> >>>>>> the new __stat{64}_t64 type.  The statx call is done only for
> >>>>>> architectures with support for 32-bit time_t ABI.
> >>>>>>
> >>>>>> Internally some extra routines to copy from/to struct stat{64}
> >>>>>> to struct __stat{64} used on multiple implementations (stat,
> >>>>>> fstat, lstat, and fstatat) are added on a extra file
> >>>>>> (stat_t64_cp.c).  Aslo some extra routines to copy from statx
> >>>>>> to __stat{64} is added on statx_cp.c.
> >>>>>>
> >>>>>> Checked with a build for all affected ABIs. I also checked on
> >>>>>> x86_64, i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and
> >>>>>> s390x.    
> >>>>>
> >>>>> When do you plan to pull this patch set to -master?
> >>>>> Those patches have been available for review on the mailing list
> >>>>> for more than two months now.    
> >>>>
> >>>> Hi Lukasz, thanks to remind me. I will rebase against master and
> >>>> run some regressions tests against some platforms and push it.
> >>>>    
> >>>
> >>> One required change with the rebase is adapt the riscv32 ABI to
> >>> exclude the __{f,l}xstat{at} symbol and replace with proper
> >>> {f,l}stat ones. It is possible because the new ABI was added on
> >>> current development branch, however one minor inconvenient is the
> >>> toolchain need to be rebuild with a updated glibc branch to avoid
> >>> linking failures with libstd++ (which uses __{f,l}xstat{at}).
> >>>     
> >>
> >> Ok, I have ran the testsuite on x86_64, x32, i686, aarch64, armhf,
> >> powerpc, powerpc64, powerpc64le, sparc64, sparcv9, s390x, and s390
> >> without regression. I will just finish the testing on mips, mips64,
> >> and alpha since they require some specific implementations.
> >>  
> > 
> > That would be a huge step forward.
> > 
> > According to list in the following commit message:
> > https://github.com/lmajewski/y2038_glibc/commit/73215359e184d96b415e87b585a4396b5bd0936c
> >  
> 
> The mips testing caught an issue on where the "linux: Disentangle 
> fstatat from fxstatat" patch uses INTERNAL_SYSCALL_CALL where
> it should use INLINE_SYSCALL_CALL (which sets the errno).  I have
> fixed and this only affects mips, so my testing should cover all
> the affects architectures (I got access to a ia64 machine again
> and I will run a regression test once I commit this to master).

Ok. Does it mean that we can expect those patches being pull to -master
soon?

> 
> > 
> > Then I will send an RFC for enabling support for 64 bit time on
> > eligible architectures.  
> 
> There still some missing implementations I have on my local tree:
> 
>  1. wait3: it is a straightforward fix since it just calls
> __wait4_time64. 

Ok.

>2. ftime: we need to move it to a compatibility
> symbol, so there will be no need to add a time64 variant to support
> the deprecated symbol.

IIRC, such deprecation patch for ftime was already pulled to master:

SHA1: 2b5fea833bcd0f651579afd16ed7842770ecbae1
"Consolidate and deprecate ftime"

From the commit description - it shall be removed by Y2038 :-)

> 3. futimesat: we need to remove the
> implementation on generic folder and handle UTIME_NOW and UTIME_OMIT
> correctly.

Ok.

> 4. recvvmsg/recvmsg: we need to handle ancillary data. I
> recently send patch that tries to handle it [1] [2] [3]. It is more
> in a RFC and I don't think it is strictly necessary.

Ok.

>  5. utmp/utmpx/lastlog: I also sent a fix to handle the 64-bit support
>     on this [4]

I saw conversion patches in your y2038 tree (sourceware/azanella/y2038)
on top of the stat conversion work, so I guess that it will be next in
the queue.

> 
> I will send 1. 2. 3., since they are the easiest one to review.

Ok. Thanks :-)

> 
> [1]
> https://sourceware.org/pipermail/libc-alpha/2020-September/117484.html
> [2]
> https://sourceware.org/pipermail/libc-alpha/2020-September/117485.html
> [3]
> https://sourceware.org/pipermail/libc-alpha/2020-September/117486.html
> [4]
> https://sourceware.org/pipermail/libc-alpha/2020-August/116850.html
> 




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 15/16] linux: Add {f}stat{at} y2038 support
  2020-10-09 15:39               ` Lukasz Majewski
@ 2020-10-09 20:06                 ` Adhemerval Zanella via Libc-alpha
  0 siblings, 0 replies; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-10-09 20:06 UTC (permalink / raw)
  To: Lukasz Majewski; +Cc: Alistair Francis, libc-alpha


[-- Attachment #1.1: Type: text/plain, Size: 1864 bytes --]



On 09/10/2020 12:39, Lukasz Majewski wrote:
> 
> Ok. Does it mean that we can expect those patches being pull to -master
> soon?
> 

Yes, I just push it upstream.

>>
>>>
>>> Then I will send an RFC for enabling support for 64 bit time on
>>> eligible architectures.  
>>
>> There still some missing implementations I have on my local tree:
>>
>>  1. wait3: it is a straightforward fix since it just calls
>> __wait4_time64. 
> 
> Ok.
> 
>> 2. ftime: we need to move it to a compatibility
>> symbol, so there will be no need to add a time64 variant to support
>> the deprecated symbol.
> 
> IIRC, such deprecation patch for ftime was already pulled to master:
> 
> SHA1: 2b5fea833bcd0f651579afd16ed7842770ecbae1
> "Consolidate and deprecate ftime"
> 
> From the commit description - it shall be removed by Y2038 :-)

This patch just make the prototype deprecated, it is still exported on
all architecture and built for newer ABIs (riscv32 for instance).
The idea of my patch is move it to a compat symbol only, meaning that
it won't be available to binaries build against glibc 2.33 and new
ABIs won't provide it (which will be the case for riscv32). 

> 
>> 3. futimesat: we need to remove the
>> implementation on generic folder and handle UTIME_NOW and UTIME_OMIT
>> correctly.
> 
> Ok.
> 
>> 4. recvvmsg/recvmsg: we need to handle ancillary data. I
>> recently send patch that tries to handle it [1] [2] [3]. It is more
>> in a RFC and I don't think it is strictly necessary.
> 
> Ok.
> 
>>  5. utmp/utmpx/lastlog: I also sent a fix to handle the 64-bit support
>>     on this [4]
> 
> I saw conversion patches in your y2038 tree (sourceware/azanella/y2038)
> on top of the stat conversion work, so I guess that it will be next in
> the queue.

I will rebase my y2038 changes and update my tree.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 10/16] Remove mknod wrapper functions, move them to symbols
  2020-07-23 19:46 ` [PATCH 10/16] Remove mknod wrapper functions, move them to symbols Adhemerval Zanella via Libc-alpha
  2020-07-23 20:53   ` Joseph Myers
  2020-07-24  9:25   ` Lukasz Majewski
@ 2020-10-12 22:27   ` Joseph Myers
  2020-10-13  0:58     ` Adhemerval Zanella via Libc-alpha
  2 siblings, 1 reply; 80+ messages in thread
From: Joseph Myers @ 2020-10-12 22:27 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Alistair Francis, libc-alpha

It appears this and related changes have recently been committed and 
introduced ABI test regressions.

FAIL: glibcs-armeb-linux-gnueabi check
FAIL: glibcs-armeb-linux-gnueabi-be8 check
FAIL: glibcs-armeb-linux-gnueabihf check
FAIL: glibcs-armeb-linux-gnueabihf-be8 check
FAIL: glibcs-m68k-linux-gnu-coldfire check
FAIL: glibcs-m68k-linux-gnu-coldfire-soft check
FAIL: glibcs-microblazeel-linux-gnu check
FAIL: glibcs-mips-linux-gnu-nan2008-soft check
FAIL: glibcs-mips-linux-gnu-soft check
FAIL: glibcs-mipsel-linux-gnu-nan2008-soft check
FAIL: glibcs-mipsel-linux-gnu-soft check
FAIL: glibcs-powerpc-linux-gnu-soft check
FAIL: glibcs-sh3eb-linux-gnu check
FAIL: glibcs-sh4eb-linux-gnu check
FAIL: glibcs-sh4eb-linux-gnu-soft check

https://sourceware.org/pipermail/libc-testresults/2020q4/006880.html

Sample test output (check-abi-libc fails, for armeb-linux-gnueabi):

@@ -146,0 +147,6 @@ GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 fstat F
+GLIBC_2.33 fstat64 F
+GLIBC_2.33 fstatat F
+GLIBC_2.33 fstatat64 F
+GLIBC_2.33 lstat F
+GLIBC_2.33 lstat64 F
@@ -147,0 +154,4 @@ GLIBC_2.33 mallinfo2 F
+GLIBC_2.33 mknod F
+GLIBC_2.33 mknodat F
+GLIBC_2.33 stat F
+GLIBC_2.33 stat64 F

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH 10/16] Remove mknod wrapper functions, move them to symbols
  2020-10-12 22:27   ` Joseph Myers
@ 2020-10-13  0:58     ` Adhemerval Zanella via Libc-alpha
  0 siblings, 0 replies; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-10-13  0:58 UTC (permalink / raw)
  To: Joseph Myers; +Cc: Alistair Francis, libc-alpha



On 12/10/2020 19:27, Joseph Myers wrote:
> It appears this and related changes have recently been committed and 
> introduced ABI test regressions.
> 
> FAIL: glibcs-armeb-linux-gnueabi check
> FAIL: glibcs-armeb-linux-gnueabi-be8 check
> FAIL: glibcs-armeb-linux-gnueabihf check
> FAIL: glibcs-armeb-linux-gnueabihf-be8 check
> FAIL: glibcs-m68k-linux-gnu-coldfire check
> FAIL: glibcs-m68k-linux-gnu-coldfire-soft check
> FAIL: glibcs-microblazeel-linux-gnu check
> FAIL: glibcs-mips-linux-gnu-nan2008-soft check
> FAIL: glibcs-mips-linux-gnu-soft check
> FAIL: glibcs-mipsel-linux-gnu-nan2008-soft check
> FAIL: glibcs-mipsel-linux-gnu-soft check
> FAIL: glibcs-powerpc-linux-gnu-soft check
> FAIL: glibcs-sh3eb-linux-gnu check
> FAIL: glibcs-sh4eb-linux-gnu check
> FAIL: glibcs-sh4eb-linux-gnu-soft check
> 
> https://sourceware.org/pipermail/libc-testresults/2020q4/006880.html
> 
> Sample test output (check-abi-libc fails, for armeb-linux-gnueabi):
> 
> @@ -146,0 +147,6 @@ GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 fstat F
> +GLIBC_2.33 fstat64 F
> +GLIBC_2.33 fstatat F
> +GLIBC_2.33 fstatat64 F
> +GLIBC_2.33 lstat F
> +GLIBC_2.33 lstat64 F
> @@ -147,0 +154,4 @@ GLIBC_2.33 mallinfo2 F
> +GLIBC_2.33 mknod F
> +GLIBC_2.33 mknodat F
> +GLIBC_2.33 stat F
> +GLIBC_2.33 stat64 F
> 

I will sort this out, thanks (I need to update my own script to
handle these abi variants as well).

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

* Re: [PATCH 15/16] linux: Add {f}stat{at} y2038 support
  2020-10-07 14:25       ` Adhemerval Zanella via Libc-alpha
  2020-10-07 20:20         ` Lukasz Majewski
  2020-10-07 21:07         ` Adhemerval Zanella via Libc-alpha
@ 2020-10-13 13:58         ` Lukasz Majewski
  2020-10-13 14:18           ` Adhemerval Zanella via Libc-alpha
  2 siblings, 1 reply; 80+ messages in thread
From: Lukasz Majewski @ 2020-10-13 13:58 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Alistair Francis, libc-alpha

[-- Attachment #1: Type: text/plain, Size: 2541 bytes --]

Hi Adhemerval,

> On 07/10/2020 09:52, Adhemerval Zanella wrote:
> > 
> > 
> > On 06/10/2020 06:48, Lukasz Majewski wrote:  
> >> Hi Adhemerval,
> >>  
> >>> A new struct __stat{64}_t64 type is added with the required
> >>> __timespec64 time definition.  Both non-LFS and LFS support were
> >>> done with an extra __NR_statx call plus a conversion to the new
> >>> __stat{64}_t64 type.  The statx call is done only for
> >>> architectures with support for 32-bit time_t ABI.
> >>>
> >>> Internally some extra routines to copy from/to struct stat{64}
> >>> to struct __stat{64} used on multiple implementations (stat,
> >>> fstat, lstat, and fstatat) are added on a extra file
> >>> (stat_t64_cp.c).  Aslo some extra routines to copy from statx to
> >>> __stat{64} is added on statx_cp.c.
> >>>
> >>> Checked with a build for all affected ABIs. I also checked on
> >>> x86_64, i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and
> >>> s390x.  
> >>
> >> When do you plan to pull this patch set to -master?
> >> Those patches have been available for review on the mailing list
> >> for more than two months now.  
> > 
> > Hi Lukasz, thanks to remind me. I will rebase against master and run
> > some regressions tests against some platforms and push it.
> >   
> 
> One required change with the rebase is adapt the riscv32 ABI to
> exclude the __{f,l}xstat{at} symbol and replace with proper {f,l}stat
> ones. It is possible because the new ABI was added on current
> development branch, however one minor inconvenient is the toolchain
> need to be rebuild with a updated glibc branch to avoid linking
> failures with libstd++ (which uses __{f,l}xstat{at}).
> 

I'm not sure if this is related, but on my ARMv7 (32 bit) sandbox there
is an issue with fstat accesses to files.

When I try to run a program build against newest glibc (installed in
/opt/lib) I do see issues with {f}stat on other libraries (e.g.
/opt/lib/librt.so). To be more specific I do experience the EOVERFLOW
error:

error while loading shared libraries: librt.so.1: cannot stat shared
object: Error 75

The "base" glibc is 2.28 (installed in /lib). The glibc under test is
the newest master installed in /opt/lib.

I'm now investigating this issue.


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 15/16] linux: Add {f}stat{at} y2038 support
  2020-10-13 13:58         ` Lukasz Majewski
@ 2020-10-13 14:18           ` Adhemerval Zanella via Libc-alpha
  2020-10-13 14:23             ` H.J. Lu via Libc-alpha
                               ` (2 more replies)
  0 siblings, 3 replies; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-10-13 14:18 UTC (permalink / raw)
  To: Lukasz Majewski; +Cc: Alistair Francis, libc-alpha


[-- Attachment #1.1: Type: text/plain, Size: 2739 bytes --]



On 13/10/2020 10:58, Lukasz Majewski wrote:
> Hi Adhemerval,
> 
>> On 07/10/2020 09:52, Adhemerval Zanella wrote:
>>>
>>>
>>> On 06/10/2020 06:48, Lukasz Majewski wrote:  
>>>> Hi Adhemerval,
>>>>  
>>>>> A new struct __stat{64}_t64 type is added with the required
>>>>> __timespec64 time definition.  Both non-LFS and LFS support were
>>>>> done with an extra __NR_statx call plus a conversion to the new
>>>>> __stat{64}_t64 type.  The statx call is done only for
>>>>> architectures with support for 32-bit time_t ABI.
>>>>>
>>>>> Internally some extra routines to copy from/to struct stat{64}
>>>>> to struct __stat{64} used on multiple implementations (stat,
>>>>> fstat, lstat, and fstatat) are added on a extra file
>>>>> (stat_t64_cp.c).  Aslo some extra routines to copy from statx to
>>>>> __stat{64} is added on statx_cp.c.
>>>>>
>>>>> Checked with a build for all affected ABIs. I also checked on
>>>>> x86_64, i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and
>>>>> s390x.  
>>>>
>>>> When do you plan to pull this patch set to -master?
>>>> Those patches have been available for review on the mailing list
>>>> for more than two months now.  
>>>
>>> Hi Lukasz, thanks to remind me. I will rebase against master and run
>>> some regressions tests against some platforms and push it.
>>>   
>>
>> One required change with the rebase is adapt the riscv32 ABI to
>> exclude the __{f,l}xstat{at} symbol and replace with proper {f,l}stat
>> ones. It is possible because the new ABI was added on current
>> development branch, however one minor inconvenient is the toolchain
>> need to be rebuild with a updated glibc branch to avoid linking
>> failures with libstd++ (which uses __{f,l}xstat{at}).
>>
> 
> I'm not sure if this is related, but on my ARMv7 (32 bit) sandbox there
> is an issue with fstat accesses to files.
> 
> When I try to run a program build against newest glibc (installed in
> /opt/lib) I do see issues with {f}stat on other libraries (e.g.
> /opt/lib/librt.so). To be more specific I do experience the EOVERFLOW
> error:
> 
> error while loading shared libraries: librt.so.1: cannot stat shared
> object: Error 75
> 
> The "base" glibc is 2.28 (installed in /lib). The glibc under test is
> the newest master installed in /opt/lib.
> 
> I'm now investigating this issue.

I am not sure what it might be based on these information, could you
provide a strace so we can pinpoint what might the issue?  

The arm-linux-gnueabihf testing I did was on a aarch64 kernel (4.12.13).
Besides the make check without regression, I could run system binaries 
with ./testrun.sh.

I will check on a different kernel/system with a 32-bit kernel.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 15/16] linux: Add {f}stat{at} y2038 support
  2020-10-13 14:18           ` Adhemerval Zanella via Libc-alpha
@ 2020-10-13 14:23             ` H.J. Lu via Libc-alpha
  2020-10-13 14:27               ` Adhemerval Zanella via Libc-alpha
  2020-10-13 18:14             ` Adhemerval Zanella via Libc-alpha
  2020-10-13 21:40             ` Lukasz Majewski
  2 siblings, 1 reply; 80+ messages in thread
From: H.J. Lu via Libc-alpha @ 2020-10-13 14:23 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: GNU C Library, Alistair Francis

On Tue, Oct 13, 2020 at 7:18 AM Adhemerval Zanella via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
>
>
> On 13/10/2020 10:58, Lukasz Majewski wrote:
> > Hi Adhemerval,
> >
> >> On 07/10/2020 09:52, Adhemerval Zanella wrote:
> >>>
> >>>
> >>> On 06/10/2020 06:48, Lukasz Majewski wrote:
> >>>> Hi Adhemerval,
> >>>>
> >>>>> A new struct __stat{64}_t64 type is added with the required
> >>>>> __timespec64 time definition.  Both non-LFS and LFS support were
> >>>>> done with an extra __NR_statx call plus a conversion to the new
> >>>>> __stat{64}_t64 type.  The statx call is done only for
> >>>>> architectures with support for 32-bit time_t ABI.
> >>>>>
> >>>>> Internally some extra routines to copy from/to struct stat{64}
> >>>>> to struct __stat{64} used on multiple implementations (stat,
> >>>>> fstat, lstat, and fstatat) are added on a extra file
> >>>>> (stat_t64_cp.c).  Aslo some extra routines to copy from statx to
> >>>>> __stat{64} is added on statx_cp.c.
> >>>>>
> >>>>> Checked with a build for all affected ABIs. I also checked on
> >>>>> x86_64, i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and
> >>>>> s390x.
> >>>>
> >>>> When do you plan to pull this patch set to -master?
> >>>> Those patches have been available for review on the mailing list
> >>>> for more than two months now.
> >>>
> >>> Hi Lukasz, thanks to remind me. I will rebase against master and run
> >>> some regressions tests against some platforms and push it.
> >>>
> >>
> >> One required change with the rebase is adapt the riscv32 ABI to
> >> exclude the __{f,l}xstat{at} symbol and replace with proper {f,l}stat
> >> ones. It is possible because the new ABI was added on current
> >> development branch, however one minor inconvenient is the toolchain
> >> need to be rebuild with a updated glibc branch to avoid linking
> >> failures with libstd++ (which uses __{f,l}xstat{at}).
> >>
> >
> > I'm not sure if this is related, but on my ARMv7 (32 bit) sandbox there
> > is an issue with fstat accesses to files.
> >
> > When I try to run a program build against newest glibc (installed in
> > /opt/lib) I do see issues with {f}stat on other libraries (e.g.
> > /opt/lib/librt.so). To be more specific I do experience the EOVERFLOW
> > error:
> >
> > error while loading shared libraries: librt.so.1: cannot stat shared
> > object: Error 75
> >
> > The "base" glibc is 2.28 (installed in /lib). The glibc under test is
> > the newest master installed in /opt/lib.
> >
> > I'm now investigating this issue.
>
> I am not sure what it might be based on these information, could you
> provide a strace so we can pinpoint what might the issue?
>
> The arm-linux-gnueabihf testing I did was on a aarch64 kernel (4.12.13).
> Besides the make check without regression, I could run system binaries
> with ./testrun.sh.
>
> I will check on a different kernel/system with a 32-bit kernel.

FWIW, I got

FAIL: glibcs-armeb-linux-gnueabi-be8 check
FAIL: glibcs-armeb-linux-gnueabi check
FAIL: glibcs-armeb-linux-gnueabihf-be8 check
FAIL: glibcs-armeb-linux-gnueabihf check
FAIL: glibcs-m68k-linux-gnu-coldfire check
FAIL: glibcs-m68k-linux-gnu-coldfire-soft check
FAIL: glibcs-microblazeel-linux-gnu check
FAIL: glibcs-mipsel-linux-gnu-nan2008-soft check
FAIL: glibcs-mipsel-linux-gnu-soft check
FAIL: glibcs-mips-linux-gnu-nan2008-soft check
FAIL: glibcs-mips-linux-gnu-soft check
FAIL: glibcs-powerpc-linux-gnu-soft check
FAIL: glibcs-riscv32-linux-gnu-rv32imac-ilp32 build
FAIL: glibcs-riscv32-linux-gnu-rv32imafdc-ilp32 build
FAIL: glibcs-riscv32-linux-gnu-rv32imafdc-ilp32d build
FAIL: glibcs-sh3eb-linux-gnu check
FAIL: glibcs-sh4eb-linux-gnu check
FAIL: glibcs-sh4eb-linux-gnu-soft check
UNRESOLVED: glibcs-riscv32-linux-gnu-rv32imac-ilp32 check
UNRESOLVED: glibcs-riscv32-linux-gnu-rv32imac-ilp32 install
UNRESOLVED: glibcs-riscv32-linux-gnu-rv32imac-ilp32 mkdir-lib
UNRESOLVED: glibcs-riscv32-linux-gnu-rv32imafdc-ilp32 check
UNRESOLVED: glibcs-riscv32-linux-gnu-rv32imafdc-ilp32d check
UNRESOLVED: glibcs-riscv32-linux-gnu-rv32imafdc-ilp32d install
UNRESOLVED: glibcs-riscv32-linux-gnu-rv32imafdc-ilp32d mkdir-lib
UNRESOLVED: glibcs-riscv32-linux-gnu-rv32imafdc-ilp32 install
UNRESOLVED: glibcs-riscv32-linux-gnu-rv32imafdc-ilp32 mkdir-lib

-- 
H.J.

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

* Re: [PATCH 15/16] linux: Add {f}stat{at} y2038 support
  2020-10-13 14:23             ` H.J. Lu via Libc-alpha
@ 2020-10-13 14:27               ` Adhemerval Zanella via Libc-alpha
  0 siblings, 0 replies; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-10-13 14:27 UTC (permalink / raw)
  To: H.J. Lu; +Cc: GNU C Library, Alistair Francis



On 13/10/2020 11:23, H.J. Lu wrote:
> On Tue, Oct 13, 2020 at 7:18 AM Adhemerval Zanella via Libc-alpha
> <libc-alpha@sourceware.org> wrote:
>>
>>
>>
>> On 13/10/2020 10:58, Lukasz Majewski wrote:
>>> Hi Adhemerval,
>>>
>>>> On 07/10/2020 09:52, Adhemerval Zanella wrote:
>>>>>
>>>>>
>>>>> On 06/10/2020 06:48, Lukasz Majewski wrote:
>>>>>> Hi Adhemerval,
>>>>>>
>>>>>>> A new struct __stat{64}_t64 type is added with the required
>>>>>>> __timespec64 time definition.  Both non-LFS and LFS support were
>>>>>>> done with an extra __NR_statx call plus a conversion to the new
>>>>>>> __stat{64}_t64 type.  The statx call is done only for
>>>>>>> architectures with support for 32-bit time_t ABI.
>>>>>>>
>>>>>>> Internally some extra routines to copy from/to struct stat{64}
>>>>>>> to struct __stat{64} used on multiple implementations (stat,
>>>>>>> fstat, lstat, and fstatat) are added on a extra file
>>>>>>> (stat_t64_cp.c).  Aslo some extra routines to copy from statx to
>>>>>>> __stat{64} is added on statx_cp.c.
>>>>>>>
>>>>>>> Checked with a build for all affected ABIs. I also checked on
>>>>>>> x86_64, i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and
>>>>>>> s390x.
>>>>>>
>>>>>> When do you plan to pull this patch set to -master?
>>>>>> Those patches have been available for review on the mailing list
>>>>>> for more than two months now.
>>>>>
>>>>> Hi Lukasz, thanks to remind me. I will rebase against master and run
>>>>> some regressions tests against some platforms and push it.
>>>>>
>>>>
>>>> One required change with the rebase is adapt the riscv32 ABI to
>>>> exclude the __{f,l}xstat{at} symbol and replace with proper {f,l}stat
>>>> ones. It is possible because the new ABI was added on current
>>>> development branch, however one minor inconvenient is the toolchain
>>>> need to be rebuild with a updated glibc branch to avoid linking
>>>> failures with libstd++ (which uses __{f,l}xstat{at}).
>>>>
>>>
>>> I'm not sure if this is related, but on my ARMv7 (32 bit) sandbox there
>>> is an issue with fstat accesses to files.
>>>
>>> When I try to run a program build against newest glibc (installed in
>>> /opt/lib) I do see issues with {f}stat on other libraries (e.g.
>>> /opt/lib/librt.so). To be more specific I do experience the EOVERFLOW
>>> error:
>>>
>>> error while loading shared libraries: librt.so.1: cannot stat shared
>>> object: Error 75
>>>
>>> The "base" glibc is 2.28 (installed in /lib). The glibc under test is
>>> the newest master installed in /opt/lib.
>>>
>>> I'm now investigating this issue.
>>
>> I am not sure what it might be based on these information, could you
>> provide a strace so we can pinpoint what might the issue?
>>
>> The arm-linux-gnueabihf testing I did was on a aarch64 kernel (4.12.13).
>> Besides the make check without regression, I could run system binaries
>> with ./testrun.sh.
>>
>> I will check on a different kernel/system with a 32-bit kernel.
> 
> FWIW, I got
> 
> FAIL: glibcs-armeb-linux-gnueabi-be8 check
> FAIL: glibcs-armeb-linux-gnueabi check
> FAIL: glibcs-armeb-linux-gnueabihf-be8 check
> FAIL: glibcs-armeb-linux-gnueabihf check
> FAIL: glibcs-m68k-linux-gnu-coldfire check
> FAIL: glibcs-m68k-linux-gnu-coldfire-soft check
> FAIL: glibcs-microblazeel-linux-gnu check
> FAIL: glibcs-mipsel-linux-gnu-nan2008-soft check
> FAIL: glibcs-mipsel-linux-gnu-soft check
> FAIL: glibcs-mips-linux-gnu-nan2008-soft check
> FAIL: glibcs-mips-linux-gnu-soft check
> FAIL: glibcs-powerpc-linux-gnu-soft check
> FAIL: glibcs-riscv32-linux-gnu-rv32imac-ilp32 build
> FAIL: glibcs-riscv32-linux-gnu-rv32imafdc-ilp32 build
> FAIL: glibcs-riscv32-linux-gnu-rv32imafdc-ilp32d build
> FAIL: glibcs-sh3eb-linux-gnu check
> FAIL: glibcs-sh4eb-linux-gnu check
> FAIL: glibcs-sh4eb-linux-gnu-soft check

Joseph has raised this earlier, I just pushed a fix to update
the libc.abilist (880a12e96df8b330350f565d93677bccf4237e1d).

> UNRESOLVED: glibcs-riscv32-linux-gnu-rv32imac-ilp32 check
> UNRESOLVED: glibcs-riscv32-linux-gnu-rv32imac-ilp32 install
> UNRESOLVED: glibcs-riscv32-linux-gnu-rv32imac-ilp32 mkdir-lib
> UNRESOLVED: glibcs-riscv32-linux-gnu-rv32imafdc-ilp32 check
> UNRESOLVED: glibcs-riscv32-linux-gnu-rv32imafdc-ilp32d check
> UNRESOLVED: glibcs-riscv32-linux-gnu-rv32imafdc-ilp32d install
> UNRESOLVED: glibcs-riscv32-linux-gnu-rv32imafdc-ilp32d mkdir-lib
> UNRESOLVED: glibcs-riscv32-linux-gnu-rv32imafdc-ilp32 install
> UNRESOLVED: glibcs-riscv32-linux-gnu-rv32imafdc-ilp32 mkdir-lib

Since this moved the __{f,l}xstat{at}{64} symbols to compatibility
ones and made it the {f,l}stat{at}{64} the ones exported by libc,
it requires to rebuild the riscv32 toolchain (since libstdc++.so
is linked against the __xstat symbols).

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

* Re: [PATCH 15/16] linux: Add {f}stat{at} y2038 support
  2020-10-13 14:18           ` Adhemerval Zanella via Libc-alpha
  2020-10-13 14:23             ` H.J. Lu via Libc-alpha
@ 2020-10-13 18:14             ` Adhemerval Zanella via Libc-alpha
  2020-10-13 21:20               ` Lukasz Majewski
  2020-10-13 21:40             ` Lukasz Majewski
  2 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-10-13 18:14 UTC (permalink / raw)
  To: Lukasz Majewski; +Cc: Alistair Francis, libc-alpha


[-- Attachment #1.1: Type: text/plain, Size: 5074 bytes --]



On 13/10/2020 11:18, Adhemerval Zanella wrote:
> 
> 
> On 13/10/2020 10:58, Lukasz Majewski wrote:
>> Hi Adhemerval,
>>
>>> On 07/10/2020 09:52, Adhemerval Zanella wrote:
>>>>
>>>>
>>>> On 06/10/2020 06:48, Lukasz Majewski wrote:  
>>>>> Hi Adhemerval,
>>>>>  
>>>>>> A new struct __stat{64}_t64 type is added with the required
>>>>>> __timespec64 time definition.  Both non-LFS and LFS support were
>>>>>> done with an extra __NR_statx call plus a conversion to the new
>>>>>> __stat{64}_t64 type.  The statx call is done only for
>>>>>> architectures with support for 32-bit time_t ABI.
>>>>>>
>>>>>> Internally some extra routines to copy from/to struct stat{64}
>>>>>> to struct __stat{64} used on multiple implementations (stat,
>>>>>> fstat, lstat, and fstatat) are added on a extra file
>>>>>> (stat_t64_cp.c).  Aslo some extra routines to copy from statx to
>>>>>> __stat{64} is added on statx_cp.c.
>>>>>>
>>>>>> Checked with a build for all affected ABIs. I also checked on
>>>>>> x86_64, i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and
>>>>>> s390x.  
>>>>>
>>>>> When do you plan to pull this patch set to -master?
>>>>> Those patches have been available for review on the mailing list
>>>>> for more than two months now.  
>>>>
>>>> Hi Lukasz, thanks to remind me. I will rebase against master and run
>>>> some regressions tests against some platforms and push it.
>>>>   
>>>
>>> One required change with the rebase is adapt the riscv32 ABI to
>>> exclude the __{f,l}xstat{at} symbol and replace with proper {f,l}stat
>>> ones. It is possible because the new ABI was added on current
>>> development branch, however one minor inconvenient is the toolchain
>>> need to be rebuild with a updated glibc branch to avoid linking
>>> failures with libstd++ (which uses __{f,l}xstat{at}).
>>>
>>
>> I'm not sure if this is related, but on my ARMv7 (32 bit) sandbox there
>> is an issue with fstat accesses to files.
>>
>> When I try to run a program build against newest glibc (installed in
>> /opt/lib) I do see issues with {f}stat on other libraries (e.g.
>> /opt/lib/librt.so). To be more specific I do experience the EOVERFLOW
>> error:
>>
>> error while loading shared libraries: librt.so.1: cannot stat shared
>> object: Error 75
>>
>> The "base" glibc is 2.28 (installed in /lib). The glibc under test is
>> the newest master installed in /opt/lib.
>>
>> I'm now investigating this issue.
> 
> I am not sure what it might be based on these information, could you
> provide a strace so we can pinpoint what might the issue?  
> 
> The arm-linux-gnueabihf testing I did was on a aarch64 kernel (4.12.13).
> Besides the make check without regression, I could run system binaries 
> with ./testrun.sh.
> 
> I will check on a different kernel/system with a 32-bit kernel.

Ok, this change in fact triggered a very subtle issue at dl-load.c that
I saw in both arm-linux-gnueabihf system with a 32-bit kernel and on
mips-linux-gnu.

The issue is at:

elf/dl-load.c

1982       if (here_any && (err = errno) != ENOENT && err != EACCES)
1983         /* The file exists and is readable, but something went wrong.  */
1984         return -1;

And it is just triggered on system where {f,l}stat{at}{64} issues
__NR_statx and it fails with ENOSYS but later success with the system
stat* syscall.

This code here checks the errno value without checking whether the
previous function call that might change err actually has failed
(in this specific case the stat64 at line 1931). And this due how we 
currently implement the y2038 support with INLINE_SYSCALL_CALL 
(a function that succeeds is allowed to change errno and it simplifies 
the resulting y2038 support a bit).

In fact this check does not really make sense, since either 'fd' will
be different than '0' (meaning it has being opened) or the 'stat64'
at line 1931 failed and 'here_any' won't be set (the stat64 at line
1951 already explicit sets errno in failure case).  

Also, git history does not give much information on why it was added
at fist place.  So I think we just need to remove this extra check,
you can check if the following patch helps (I am running some
regression tests before sensing it upstream):

diff --git a/elf/dl-load.c b/elf/dl-load.c
index f3201e7c14..39ae43c6ce 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -1878,7 +1878,6 @@ open_path (const char *name, size_t namelen, int mode,
       size_t cnt;
       char *edp;
       int here_any = 0;
-      int err;
 
       /* If we are debugging the search for libraries print the path
         now if it hasn't happened now.  */
@@ -1979,9 +1978,6 @@ open_path (const char *name, size_t namelen, int mode,
              return -1;
            }
        }
-      if (here_any && (err = errno) != ENOENT && err != EACCES)
-       /* The file exists and is readable, but something went wrong.  */
-       return -1;
 
       /* Remember whether we found anything.  */
       any |= here_any;





[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 15/16] linux: Add {f}stat{at} y2038 support
  2020-10-13 18:14             ` Adhemerval Zanella via Libc-alpha
@ 2020-10-13 21:20               ` Lukasz Majewski
  0 siblings, 0 replies; 80+ messages in thread
From: Lukasz Majewski @ 2020-10-13 21:20 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Alistair Francis, libc-alpha

[-- Attachment #1: Type: text/plain, Size: 5669 bytes --]

Hi Adhemerval,

> On 13/10/2020 11:18, Adhemerval Zanella wrote:
> > 
> > 
> > On 13/10/2020 10:58, Lukasz Majewski wrote:  
> >> Hi Adhemerval,
> >>  
> >>> On 07/10/2020 09:52, Adhemerval Zanella wrote:  
> >>>>
> >>>>
> >>>> On 06/10/2020 06:48, Lukasz Majewski wrote:    
> >>>>> Hi Adhemerval,
> >>>>>    
> >>>>>> A new struct __stat{64}_t64 type is added with the required
> >>>>>> __timespec64 time definition.  Both non-LFS and LFS support
> >>>>>> were done with an extra __NR_statx call plus a conversion to
> >>>>>> the new __stat{64}_t64 type.  The statx call is done only for
> >>>>>> architectures with support for 32-bit time_t ABI.
> >>>>>>
> >>>>>> Internally some extra routines to copy from/to struct stat{64}
> >>>>>> to struct __stat{64} used on multiple implementations (stat,
> >>>>>> fstat, lstat, and fstatat) are added on a extra file
> >>>>>> (stat_t64_cp.c).  Aslo some extra routines to copy from statx
> >>>>>> to __stat{64} is added on statx_cp.c.
> >>>>>>
> >>>>>> Checked with a build for all affected ABIs. I also checked on
> >>>>>> x86_64, i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and
> >>>>>> s390x.    
> >>>>>
> >>>>> When do you plan to pull this patch set to -master?
> >>>>> Those patches have been available for review on the mailing list
> >>>>> for more than two months now.    
> >>>>
> >>>> Hi Lukasz, thanks to remind me. I will rebase against master and
> >>>> run some regressions tests against some platforms and push it.
> >>>>     
> >>>
> >>> One required change with the rebase is adapt the riscv32 ABI to
> >>> exclude the __{f,l}xstat{at} symbol and replace with proper
> >>> {f,l}stat ones. It is possible because the new ABI was added on
> >>> current development branch, however one minor inconvenient is the
> >>> toolchain need to be rebuild with a updated glibc branch to avoid
> >>> linking failures with libstd++ (which uses __{f,l}xstat{at}).
> >>>  
> >>
> >> I'm not sure if this is related, but on my ARMv7 (32 bit) sandbox
> >> there is an issue with fstat accesses to files.
> >>
> >> When I try to run a program build against newest glibc (installed
> >> in /opt/lib) I do see issues with {f}stat on other libraries (e.g.
> >> /opt/lib/librt.so). To be more specific I do experience the
> >> EOVERFLOW error:
> >>
> >> error while loading shared libraries: librt.so.1: cannot stat
> >> shared object: Error 75
> >>
> >> The "base" glibc is 2.28 (installed in /lib). The glibc under test
> >> is the newest master installed in /opt/lib.
> >>
> >> I'm now investigating this issue.  
> > 
> > I am not sure what it might be based on these information, could you
> > provide a strace so we can pinpoint what might the issue?  
> > 
> > The arm-linux-gnueabihf testing I did was on a aarch64 kernel
> > (4.12.13). Besides the make check without regression, I could run
> > system binaries with ./testrun.sh.
> > 
> > I will check on a different kernel/system with a 32-bit kernel.  
> 
> Ok, this change in fact triggered a very subtle issue at dl-load.c
> that I saw in both arm-linux-gnueabihf system with a 32-bit kernel
> and on mips-linux-gnu.
> 
> The issue is at:
> 
> elf/dl-load.c
> 
> 1982       if (here_any && (err = errno) != ENOENT && err != EACCES)
> 1983         /* The file exists and is readable, but something went
> wrong.  */ 1984         return -1;
> 
> And it is just triggered on system where {f,l}stat{at}{64} issues
> __NR_statx and it fails with ENOSYS but later success with the system
> stat* syscall.
> 
> This code here checks the errno value without checking whether the
> previous function call that might change err actually has failed
> (in this specific case the stat64 at line 1931). And this due how we 
> currently implement the y2038 support with INLINE_SYSCALL_CALL 
> (a function that succeeds is allowed to change errno and it
> simplifies the resulting y2038 support a bit).
> 
> In fact this check does not really make sense, since either 'fd' will
> be different than '0' (meaning it has being opened) or the 'stat64'
> at line 1931 failed and 'here_any' won't be set (the stat64 at line
> 1951 already explicit sets errno in failure case).  
> 
> Also, git history does not give much information on why it was added
> at fist place.  So I think we just need to remove this extra check,
> you can check if the following patch helps (I am running some
> regression tests before sensing it upstream):
> 
> diff --git a/elf/dl-load.c b/elf/dl-load.c
> index f3201e7c14..39ae43c6ce 100644
> --- a/elf/dl-load.c
> +++ b/elf/dl-load.c
> @@ -1878,7 +1878,6 @@ open_path (const char *name, size_t namelen,
> int mode, size_t cnt;
>        char *edp;
>        int here_any = 0;
> -      int err;
>  
>        /* If we are debugging the search for libraries print the path
>          now if it hasn't happened now.  */
> @@ -1979,9 +1978,6 @@ open_path (const char *name, size_t namelen,
> int mode, return -1;
>             }
>         }
> -      if (here_any && (err = errno) != ENOENT && err != EACCES)
> -       /* The file exists and is readable, but something went wrong.
>  */
> -       return -1;
>  
>        /* Remember whether we found anything.  */
>        any |= here_any;
> 
> 

I've tested this patch and it doesn't fix my issue.

> 
> 




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 15/16] linux: Add {f}stat{at} y2038 support
  2020-10-13 14:18           ` Adhemerval Zanella via Libc-alpha
  2020-10-13 14:23             ` H.J. Lu via Libc-alpha
  2020-10-13 18:14             ` Adhemerval Zanella via Libc-alpha
@ 2020-10-13 21:40             ` Lukasz Majewski
  2020-10-14 13:15               ` Lukasz Majewski
  2 siblings, 1 reply; 80+ messages in thread
From: Lukasz Majewski @ 2020-10-13 21:40 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Alistair Francis, libc-alpha

[-- Attachment #1: Type: text/plain, Size: 5828 bytes --]

Hi Adhemerval,

> On 13/10/2020 10:58, Lukasz Majewski wrote:
> > Hi Adhemerval,
> >   
> >> On 07/10/2020 09:52, Adhemerval Zanella wrote:  
> >>>
> >>>
> >>> On 06/10/2020 06:48, Lukasz Majewski wrote:    
> >>>> Hi Adhemerval,
> >>>>    
> >>>>> A new struct __stat{64}_t64 type is added with the required
> >>>>> __timespec64 time definition.  Both non-LFS and LFS support were
> >>>>> done with an extra __NR_statx call plus a conversion to the new
> >>>>> __stat{64}_t64 type.  The statx call is done only for
> >>>>> architectures with support for 32-bit time_t ABI.
> >>>>>
> >>>>> Internally some extra routines to copy from/to struct stat{64}
> >>>>> to struct __stat{64} used on multiple implementations (stat,
> >>>>> fstat, lstat, and fstatat) are added on a extra file
> >>>>> (stat_t64_cp.c).  Aslo some extra routines to copy from statx to
> >>>>> __stat{64} is added on statx_cp.c.
> >>>>>
> >>>>> Checked with a build for all affected ABIs. I also checked on
> >>>>> x86_64, i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and
> >>>>> s390x.    
> >>>>
> >>>> When do you plan to pull this patch set to -master?
> >>>> Those patches have been available for review on the mailing list
> >>>> for more than two months now.    
> >>>
> >>> Hi Lukasz, thanks to remind me. I will rebase against master and
> >>> run some regressions tests against some platforms and push it.
> >>>     
> >>
> >> One required change with the rebase is adapt the riscv32 ABI to
> >> exclude the __{f,l}xstat{at} symbol and replace with proper
> >> {f,l}stat ones. It is possible because the new ABI was added on
> >> current development branch, however one minor inconvenient is the
> >> toolchain need to be rebuild with a updated glibc branch to avoid
> >> linking failures with libstd++ (which uses __{f,l}xstat{at}).
> >>  
> > 
> > I'm not sure if this is related, but on my ARMv7 (32 bit) sandbox
> > there is an issue with fstat accesses to files.
> > 
> > When I try to run a program build against newest glibc (installed in
> > /opt/lib) I do see issues with {f}stat on other libraries (e.g.
> > /opt/lib/librt.so). To be more specific I do experience the
> > EOVERFLOW error:
> > 
> > error while loading shared libraries: librt.so.1: cannot stat shared
> > object: Error 75
> > 
> > The "base" glibc is 2.28 (installed in /lib). The glibc under test
> > is the newest master installed in /opt/lib.
> > 
> > I'm now investigating this issue.  
> 
> I am not sure what it might be based on these information, could you
> provide a strace so we can pinpoint what might the issue?  

Things are getting more and more interesting.

Let's consider the /opt/lib/librt.so.1

After qemu boot:

root@y2038arm:~# stat /opt/lib/librt.so.1
  File: /opt/lib/librt.so.1 -> librt-2.32.9000.so
  Size: 18              Blocks: 0          IO Block: 4096   symbolic
link Device: b300h/45824d    Inode: 17490       Links: 1
Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2020-10-13 23:14:56.800000000 +0000      ----> OK
Modify: 2020-10-13 23:14:52.770000000 +0000
Change: 2020-10-13 23:14:52.770000000 +0000

Then I do run gdb (which was build with 2.28 glibc as a base and gcc
8.1, which uses the same library):

gdb test_y2038:
...
(gdb) run
Starting program: /usr/bin/test_y2038
/usr/bin/test_y2038: error while loading shared libraries: librt.so.1:
cannot stat shared object: Error 75 [Inferior 1 (process 1045) exited
with code 0177]

So I've accessed the librt.so.1 with some old - i.e. 2.28 ABI - now:

root@y2038arm:~# stat /opt/lib/librt.so.1
  File: /opt/lib/librt.so.1 -> librt-2.32.9000.so
  Size: 18              Blocks: 0          IO Block: 4096   symbolic
link Device: b300h/45824d    Inode: 17490       Links: 1
Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 1901-12-13 20:46:33.625721000 +0000  ----> Overflow
Modify: 2020-10-13 23:14:52.770000000 +0000
Change: 2020-10-13 23:14:52.770000000 +0000

root@y2038arm:~# strace -v -Tf -e trace=file test_y2038

openat(AT_FDCWD, "/opt/lib/librt.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC)
= 3 <0.000409> statx(3, "",
AT_STATX_SYNC_AS_STAT|AT_NO_AUTOMOUNT|AT_EMPTY_PATH, STATX_BASIC_STATS,
{stx_mask=STATX_ALL, stx_blksize=4096, stx_attributes=0, stx_nlink=1,
stx_uid=0, stx_gid=0, stx_mode=S_IFREG|0755, stx_ino=17487,
stx_size=425008, stx_blocks=832,
stx_attributes_mask=STATX_ATTR_COMPRESSED|STATX_ATTR_IMMUTABLE|STATX_ATTR_APPEND|STATX_ATTR_NODUMP|STATX_ATTR_ENCRYPTED,
stx_atime={tv_sec=1602625090, tv_nsec=600000000} /*
2020-10-13T21:38:10.600000000+0000 */, stx_btime={tv_sec=1602622592,
tv_nsec=0} /* 2020-10-13T20:56:32+0000 */,
stx_ctime={tv_sec=2147484284, tv_nsec=335721000},
stx_mtime={tv_sec=2147484263, tv_nsec=545721000}, stx_rdev_major=0,
stx_rdev_minor=0, stx_dev_major=179, stx_dev_minor=0}) = 0 <0.000494>
test_y2038: error while loading shared libraries: librt.so.1: cannot
stat shared object: Error 75 +++ exited with 127 +++


Here the ctime and mtime are wrong - i.e. overflowed.

The system date is not changed:
root@y2038arm:~# date
Tue Oct 13 21:40:02 UTC 2020
root@y2038arm:~# date +%s
1602625224

I will continue investigation tomorrow...

> 
> The arm-linux-gnueabihf testing I did was on a aarch64 kernel
> (4.12.13). Besides the make check without regression, I could run
> system binaries with ./testrun.sh.
> 
> I will check on a different kernel/system with a 32-bit kernel.
> 




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 15/16] linux: Add {f}stat{at} y2038 support
  2020-10-13 21:40             ` Lukasz Majewski
@ 2020-10-14 13:15               ` Lukasz Majewski
  2020-10-14 13:39                 ` Adhemerval Zanella via Libc-alpha
  0 siblings, 1 reply; 80+ messages in thread
From: Lukasz Majewski @ 2020-10-14 13:15 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha, Alistair Francis

[-- Attachment #1: Type: text/plain, Size: 7359 bytes --]

Dear Community,

> Hi Adhemerval,
> 
> > On 13/10/2020 10:58, Lukasz Majewski wrote:  
> > > Hi Adhemerval,
> > >     
> > >> On 07/10/2020 09:52, Adhemerval Zanella wrote:    
> > >>>
> > >>>
> > >>> On 06/10/2020 06:48, Lukasz Majewski wrote:      
> > >>>> Hi Adhemerval,
> > >>>>      
> > >>>>> A new struct __stat{64}_t64 type is added with the required
> > >>>>> __timespec64 time definition.  Both non-LFS and LFS support
> > >>>>> were done with an extra __NR_statx call plus a conversion to
> > >>>>> the new __stat{64}_t64 type.  The statx call is done only for
> > >>>>> architectures with support for 32-bit time_t ABI.
> > >>>>>
> > >>>>> Internally some extra routines to copy from/to struct stat{64}
> > >>>>> to struct __stat{64} used on multiple implementations (stat,
> > >>>>> fstat, lstat, and fstatat) are added on a extra file
> > >>>>> (stat_t64_cp.c).  Aslo some extra routines to copy from statx
> > >>>>> to __stat{64} is added on statx_cp.c.
> > >>>>>
> > >>>>> Checked with a build for all affected ABIs. I also checked on
> > >>>>> x86_64, i686, powerpc, powerpc64le, sparcv9, sparc64, s390,
> > >>>>> and s390x.      
> > >>>>
> > >>>> When do you plan to pull this patch set to -master?
> > >>>> Those patches have been available for review on the mailing
> > >>>> list for more than two months now.      
> > >>>
> > >>> Hi Lukasz, thanks to remind me. I will rebase against master and
> > >>> run some regressions tests against some platforms and push it.
> > >>>       
> > >>
> > >> One required change with the rebase is adapt the riscv32 ABI to
> > >> exclude the __{f,l}xstat{at} symbol and replace with proper
> > >> {f,l}stat ones. It is possible because the new ABI was added on
> > >> current development branch, however one minor inconvenient is the
> > >> toolchain need to be rebuild with a updated glibc branch to avoid
> > >> linking failures with libstd++ (which uses __{f,l}xstat{at}).
> > >>    
> > > 
> > > I'm not sure if this is related, but on my ARMv7 (32 bit) sandbox
> > > there is an issue with fstat accesses to files.
> > > 
> > > When I try to run a program build against newest glibc (installed
> > > in /opt/lib) I do see issues with {f}stat on other libraries (e.g.
> > > /opt/lib/librt.so). To be more specific I do experience the
> > > EOVERFLOW error:
> > > 
> > > error while loading shared libraries: librt.so.1: cannot stat
> > > shared object: Error 75
> > > 
> > > The "base" glibc is 2.28 (installed in /lib). The glibc under test
> > > is the newest master installed in /opt/lib.
> > > 
> > > I'm now investigating this issue.    
> > 
> > I am not sure what it might be based on these information, could you
> > provide a strace so we can pinpoint what might the issue?    
> 
> Things are getting more and more interesting.
> 
> Let's consider the /opt/lib/librt.so.1
> 
> After qemu boot:
> 
> root@y2038arm:~# stat /opt/lib/librt.so.1
>   File: /opt/lib/librt.so.1 -> librt-2.32.9000.so
>   Size: 18              Blocks: 0          IO Block: 4096   symbolic
> link Device: b300h/45824d    Inode: 17490       Links: 1
> Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/
> root) Access: 2020-10-13 23:14:56.800000000 +0000      ----> OK
> Modify: 2020-10-13 23:14:52.770000000 +0000
> Change: 2020-10-13 23:14:52.770000000 +0000
> 
> Then I do run gdb (which was build with 2.28 glibc as a base and gcc
> 8.1, which uses the same library):
> 
> gdb test_y2038:
> ...
> (gdb) run
> Starting program: /usr/bin/test_y2038
> /usr/bin/test_y2038: error while loading shared libraries: librt.so.1:
> cannot stat shared object: Error 75 [Inferior 1 (process 1045) exited
> with code 0177]
> 
> So I've accessed the librt.so.1 with some old - i.e. 2.28 ABI - now:
> 
> root@y2038arm:~# stat /opt/lib/librt.so.1
>   File: /opt/lib/librt.so.1 -> librt-2.32.9000.so
>   Size: 18              Blocks: 0          IO Block: 4096   symbolic
> link Device: b300h/45824d    Inode: 17490       Links: 1
> Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/
> root) Access: 1901-12-13 20:46:33.625721000 +0000  ----> Overflow
> Modify: 2020-10-13 23:14:52.770000000 +0000
> Change: 2020-10-13 23:14:52.770000000 +0000
> 
> root@y2038arm:~# strace -v -Tf -e trace=file test_y2038
> 
> openat(AT_FDCWD, "/opt/lib/librt.so.1",
> O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3 <0.000409> statx(3, "",
> AT_STATX_SYNC_AS_STAT|AT_NO_AUTOMOUNT|AT_EMPTY_PATH,
> STATX_BASIC_STATS, {stx_mask=STATX_ALL, stx_blksize=4096,
> stx_attributes=0, stx_nlink=1, stx_uid=0, stx_gid=0,
> stx_mode=S_IFREG|0755, stx_ino=17487, stx_size=425008, stx_blocks=832,
> stx_attributes_mask=STATX_ATTR_COMPRESSED|STATX_ATTR_IMMUTABLE|STATX_ATTR_APPEND|STATX_ATTR_NODUMP|STATX_ATTR_ENCRYPTED,
> stx_atime={tv_sec=1602625090, tv_nsec=600000000} /*
> 2020-10-13T21:38:10.600000000+0000 */, stx_btime={tv_sec=1602622592,
> tv_nsec=0} /* 2020-10-13T20:56:32+0000 */,
> stx_ctime={tv_sec=2147484284, tv_nsec=335721000},
> stx_mtime={tv_sec=2147484263, tv_nsec=545721000}, stx_rdev_major=0,
> stx_rdev_minor=0, stx_dev_major=179, stx_dev_minor=0}) = 0 <0.000494>
> test_y2038: error while loading shared libraries: librt.so.1: cannot
> stat shared object: Error 75 +++ exited with 127 +++
> 
> 
> Here the ctime and mtime are wrong - i.e. overflowed.
> 
> The system date is not changed:
> root@y2038arm:~# date
> Tue Oct 13 21:40:02 UTC 2020
> root@y2038arm:~# date +%s
> 1602625224
> 
> I will continue investigation tomorrow...

And now the penny has dropped...

The issue was that:

1. Adhemerval has added extra checks for overflowing the time in
{f}stat{at} patches - this is obviously good :-)

2. In my test system - I've been using "time" syscall (glibc function)
to get the seconds after epoch. This was not yet [*] converted to
support 64 bit time.

3. Some tests (like clock_gettime / clock_settime) require time
modifications after Y2038. Broken time() caused wrong data after
casting from __time_t to __time64_t and the proper time couldn't be
restored.

4. As a result - the date was wrong during the following tests
execution and {mac}time for external files (like librt.so.1,
libgcc_s.so) was set to wrong value.

5. Each subsequent call of {fl}stat{64} returned error due to date
overflow check.

Fix:

Convert time to support 64 bit time.

[*] I will send patches after build-many-glibcs.py and xcheck finish.

> 
> > 
> > The arm-linux-gnueabihf testing I did was on a aarch64 kernel
> > (4.12.13). Besides the make check without regression, I could run
> > system binaries with ./testrun.sh.
> > 
> > I will check on a different kernel/system with a 32-bit kernel.
> >   
> 
> 
> 
> 
> Best regards,
> 
> Lukasz Majewski
> 
> --
> 
> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email:
> lukma@denx.de




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 15/16] linux: Add {f}stat{at} y2038 support
  2020-10-14 13:15               ` Lukasz Majewski
@ 2020-10-14 13:39                 ` Adhemerval Zanella via Libc-alpha
  0 siblings, 0 replies; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-10-14 13:39 UTC (permalink / raw)
  To: Lukasz Majewski; +Cc: libc-alpha, Alistair Francis


[-- Attachment #1.1: Type: text/plain, Size: 6832 bytes --]



On 14/10/2020 10:15, Lukasz Majewski wrote:
> Dear Community,
> 
>> Hi Adhemerval,
>>
>>> On 13/10/2020 10:58, Lukasz Majewski wrote:  
>>>> Hi Adhemerval,
>>>>     
>>>>> On 07/10/2020 09:52, Adhemerval Zanella wrote:    
>>>>>>
>>>>>>
>>>>>> On 06/10/2020 06:48, Lukasz Majewski wrote:      
>>>>>>> Hi Adhemerval,
>>>>>>>      
>>>>>>>> A new struct __stat{64}_t64 type is added with the required
>>>>>>>> __timespec64 time definition.  Both non-LFS and LFS support
>>>>>>>> were done with an extra __NR_statx call plus a conversion to
>>>>>>>> the new __stat{64}_t64 type.  The statx call is done only for
>>>>>>>> architectures with support for 32-bit time_t ABI.
>>>>>>>>
>>>>>>>> Internally some extra routines to copy from/to struct stat{64}
>>>>>>>> to struct __stat{64} used on multiple implementations (stat,
>>>>>>>> fstat, lstat, and fstatat) are added on a extra file
>>>>>>>> (stat_t64_cp.c).  Aslo some extra routines to copy from statx
>>>>>>>> to __stat{64} is added on statx_cp.c.
>>>>>>>>
>>>>>>>> Checked with a build for all affected ABIs. I also checked on
>>>>>>>> x86_64, i686, powerpc, powerpc64le, sparcv9, sparc64, s390,
>>>>>>>> and s390x.      
>>>>>>>
>>>>>>> When do you plan to pull this patch set to -master?
>>>>>>> Those patches have been available for review on the mailing
>>>>>>> list for more than two months now.      
>>>>>>
>>>>>> Hi Lukasz, thanks to remind me. I will rebase against master and
>>>>>> run some regressions tests against some platforms and push it.
>>>>>>       
>>>>>
>>>>> One required change with the rebase is adapt the riscv32 ABI to
>>>>> exclude the __{f,l}xstat{at} symbol and replace with proper
>>>>> {f,l}stat ones. It is possible because the new ABI was added on
>>>>> current development branch, however one minor inconvenient is the
>>>>> toolchain need to be rebuild with a updated glibc branch to avoid
>>>>> linking failures with libstd++ (which uses __{f,l}xstat{at}).
>>>>>    
>>>>
>>>> I'm not sure if this is related, but on my ARMv7 (32 bit) sandbox
>>>> there is an issue with fstat accesses to files.
>>>>
>>>> When I try to run a program build against newest glibc (installed
>>>> in /opt/lib) I do see issues with {f}stat on other libraries (e.g.
>>>> /opt/lib/librt.so). To be more specific I do experience the
>>>> EOVERFLOW error:
>>>>
>>>> error while loading shared libraries: librt.so.1: cannot stat
>>>> shared object: Error 75
>>>>
>>>> The "base" glibc is 2.28 (installed in /lib). The glibc under test
>>>> is the newest master installed in /opt/lib.
>>>>
>>>> I'm now investigating this issue.    
>>>
>>> I am not sure what it might be based on these information, could you
>>> provide a strace so we can pinpoint what might the issue?    
>>
>> Things are getting more and more interesting.
>>
>> Let's consider the /opt/lib/librt.so.1
>>
>> After qemu boot:
>>
>> root@y2038arm:~# stat /opt/lib/librt.so.1
>>   File: /opt/lib/librt.so.1 -> librt-2.32.9000.so
>>   Size: 18              Blocks: 0          IO Block: 4096   symbolic
>> link Device: b300h/45824d    Inode: 17490       Links: 1
>> Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/
>> root) Access: 2020-10-13 23:14:56.800000000 +0000      ----> OK
>> Modify: 2020-10-13 23:14:52.770000000 +0000
>> Change: 2020-10-13 23:14:52.770000000 +0000
>>
>> Then I do run gdb (which was build with 2.28 glibc as a base and gcc
>> 8.1, which uses the same library):
>>
>> gdb test_y2038:
>> ...
>> (gdb) run
>> Starting program: /usr/bin/test_y2038
>> /usr/bin/test_y2038: error while loading shared libraries: librt.so.1:
>> cannot stat shared object: Error 75 [Inferior 1 (process 1045) exited
>> with code 0177]
>>
>> So I've accessed the librt.so.1 with some old - i.e. 2.28 ABI - now:
>>
>> root@y2038arm:~# stat /opt/lib/librt.so.1
>>   File: /opt/lib/librt.so.1 -> librt-2.32.9000.so
>>   Size: 18              Blocks: 0          IO Block: 4096   symbolic
>> link Device: b300h/45824d    Inode: 17490       Links: 1
>> Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/
>> root) Access: 1901-12-13 20:46:33.625721000 +0000  ----> Overflow
>> Modify: 2020-10-13 23:14:52.770000000 +0000
>> Change: 2020-10-13 23:14:52.770000000 +0000
>>
>> root@y2038arm:~# strace -v -Tf -e trace=file test_y2038
>>
>> openat(AT_FDCWD, "/opt/lib/librt.so.1",
>> O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3 <0.000409> statx(3, "",
>> AT_STATX_SYNC_AS_STAT|AT_NO_AUTOMOUNT|AT_EMPTY_PATH,
>> STATX_BASIC_STATS, {stx_mask=STATX_ALL, stx_blksize=4096,
>> stx_attributes=0, stx_nlink=1, stx_uid=0, stx_gid=0,
>> stx_mode=S_IFREG|0755, stx_ino=17487, stx_size=425008, stx_blocks=832,
>> stx_attributes_mask=STATX_ATTR_COMPRESSED|STATX_ATTR_IMMUTABLE|STATX_ATTR_APPEND|STATX_ATTR_NODUMP|STATX_ATTR_ENCRYPTED,
>> stx_atime={tv_sec=1602625090, tv_nsec=600000000} /*
>> 2020-10-13T21:38:10.600000000+0000 */, stx_btime={tv_sec=1602622592,
>> tv_nsec=0} /* 2020-10-13T20:56:32+0000 */,
>> stx_ctime={tv_sec=2147484284, tv_nsec=335721000},
>> stx_mtime={tv_sec=2147484263, tv_nsec=545721000}, stx_rdev_major=0,
>> stx_rdev_minor=0, stx_dev_major=179, stx_dev_minor=0}) = 0 <0.000494>
>> test_y2038: error while loading shared libraries: librt.so.1: cannot
>> stat shared object: Error 75 +++ exited with 127 +++
>>
>>
>> Here the ctime and mtime are wrong - i.e. overflowed.
>>
>> The system date is not changed:
>> root@y2038arm:~# date
>> Tue Oct 13 21:40:02 UTC 2020
>> root@y2038arm:~# date +%s
>> 1602625224
>>
>> I will continue investigation tomorrow...
> 
> And now the penny has dropped...
> 
> The issue was that:
> 
> 1. Adhemerval has added extra checks for overflowing the time in
> {f}stat{at} patches - this is obviously good :-)
> 
> 2. In my test system - I've been using "time" syscall (glibc function)
> to get the seconds after epoch. This was not yet [*] converted to
> support 64 bit time.
> 
> 3. Some tests (like clock_gettime / clock_settime) require time
> modifications after Y2038. Broken time() caused wrong data after
> casting from __time_t to __time64_t and the proper time couldn't be
> restored.
> 
> 4. As a result - the date was wrong during the following tests
> execution and {mac}time for external files (like librt.so.1,
> libgcc_s.so) was set to wrong value.
> 
> 5. Each subsequent call of {fl}stat{64} returned error due to date
> overflow check.
> 
> Fix:
> 
> Convert time to support 64 bit time.
> 
> [*] I will send patches after build-many-glibcs.py and xcheck finish.

Good to know this is an issue not related to the stat patches itself.
I was confused because you initially didn't describe the test you
are doing in details, so it was hard to pinpoint the issue. 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* __xstat et al. as compat symbols (was: Re: [PATCH 14/16] linux: Move {f}xstat{at} to compat symbols)
  2020-07-23 19:46 ` [PATCH 14/16] linux: Move {f}xstat{at} to compat symbols Adhemerval Zanella via Libc-alpha
  2020-07-24  9:40   ` Lukasz Majewski
@ 2020-10-21  5:21   ` Florian Weimer via Libc-alpha
  2020-10-21 11:59     ` Adhemerval Zanella via Libc-alpha
  1 sibling, 1 reply; 80+ messages in thread
From: Florian Weimer via Libc-alpha @ 2020-10-21  5:21 UTC (permalink / raw)
  To: Adhemerval Zanella via Libc-alpha; +Cc: Alistair Francis

* Adhemerval Zanella via Libc-alpha:

> diff --git a/sysdeps/unix/sysv/linux/alpha/fxstat64.c b/sysdeps/unix/sysv/linux/alpha/fxstat64.c
> index 9d6b8eca32..bcfb55050c 100644
> --- a/sysdeps/unix/sysv/linux/alpha/fxstat64.c
> +++ b/sysdeps/unix/sysv/linux/alpha/fxstat64.c
> @@ -22,9 +22,11 @@
>  #include <kernel_stat.h>
>  #include <sysdep.h>
>  #include <xstatconv.h>
> +#include <shlib-compat.h>
>  
>  /* Get information about the file NAME in BUF.  */
>  int
> +attribute_compat_text_section
>  __fxstat64 (int vers, int fd, struct stat64 *buf)
>  {
>    switch (vers)
> @@ -42,4 +44,12 @@ __fxstat64 (int vers, int fd, struct stat64 *buf)
>        }
>      }
>  }
> -strong_alias (__fxstat64, __fxstat);
> +
> +#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
> +strong_alias (__fxstat64, __fxstat_compat)
> +compat_symbol (libc, __fxstat_compat, __fxstat, GLIBC_2_0);
> +#endif
> +
> +#if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_33)
> +compat_symbol (libc, __fxstat64, __fxstat64, GLIBC_2_1);
> +#endif

This change breaks a lot of static libraries out there.  Do we really
want to do this immediately, or should we just stop using these symbols
from libc_nonshared.a, and defer the compat symbol treatment to a future
glibc version?

Thanks,
Florian
-- 
Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill


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

* Re: __xstat et al. as compat symbols (was: Re: [PATCH 14/16] linux: Move {f}xstat{at} to compat symbols)
  2020-10-21  5:21   ` __xstat et al. as compat symbols (was: Re: [PATCH 14/16] linux: Move {f}xstat{at} to compat symbols) Florian Weimer via Libc-alpha
@ 2020-10-21 11:59     ` Adhemerval Zanella via Libc-alpha
  2020-10-21 12:57       ` __xstat et al. as compat symbols Florian Weimer via Libc-alpha
  0 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-10-21 11:59 UTC (permalink / raw)
  To: Florian Weimer, Adhemerval Zanella via Libc-alpha; +Cc: Alistair Francis



On 21/10/2020 02:21, Florian Weimer wrote:
> * Adhemerval Zanella via Libc-alpha:
> 
>> diff --git a/sysdeps/unix/sysv/linux/alpha/fxstat64.c b/sysdeps/unix/sysv/linux/alpha/fxstat64.c
>> index 9d6b8eca32..bcfb55050c 100644
>> --- a/sysdeps/unix/sysv/linux/alpha/fxstat64.c
>> +++ b/sysdeps/unix/sysv/linux/alpha/fxstat64.c
>> @@ -22,9 +22,11 @@
>>  #include <kernel_stat.h>
>>  #include <sysdep.h>
>>  #include <xstatconv.h>
>> +#include <shlib-compat.h>
>>  
>>  /* Get information about the file NAME in BUF.  */
>>  int
>> +attribute_compat_text_section
>>  __fxstat64 (int vers, int fd, struct stat64 *buf)
>>  {
>>    switch (vers)
>> @@ -42,4 +44,12 @@ __fxstat64 (int vers, int fd, struct stat64 *buf)
>>        }
>>      }
>>  }
>> -strong_alias (__fxstat64, __fxstat);
>> +
>> +#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
>> +strong_alias (__fxstat64, __fxstat_compat)
>> +compat_symbol (libc, __fxstat_compat, __fxstat, GLIBC_2_0);
>> +#endif
>> +
>> +#if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_33)
>> +compat_symbol (libc, __fxstat64, __fxstat64, GLIBC_2_1);
>> +#endif
> 
> This change breaks a lot of static libraries out there.  Do we really
> want to do this immediately, or should we just stop using these symbols
> from libc_nonshared.a, and defer the compat symbol treatment to a future
> glibc version?

This is the similar the libm finite symbols where my understanding was user
was supposed to rebuild the library.

The issue is only for static linking, by stopping using libc_nonshared.a we
need to provide the versioned stat symbols anyway.  And we still need to handle
new ABIs where adding the old xstat symbols does not make sense (such as
riscv32 or any new 32-bit architecture).

It would required a new compat_symbol directive to export the symbols *just*
for static linking and some building tinkering to just build the xstat symbol
for dynamic object and static linking depending of support ABI version.

If we just defer the compat move, it would add the needless symbols on
newer ABIs that we will need to keep supporting indefinitely (even though they
won't be used anywhere unless user explicily links against a protected symbol)
and we would eventually need to handle the y2038 support on old ABIs (with the
_TIME_SIZE selection) by either adding proper 64-bit time support for by 
removing the xstat for good.

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

* Re: __xstat et al. as compat symbols
  2020-10-21 11:59     ` Adhemerval Zanella via Libc-alpha
@ 2020-10-21 12:57       ` Florian Weimer via Libc-alpha
  2020-10-21 13:09         ` Adhemerval Zanella via Libc-alpha
  0 siblings, 1 reply; 80+ messages in thread
From: Florian Weimer via Libc-alpha @ 2020-10-21 12:57 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Alistair Francis, Adhemerval Zanella via Libc-alpha

* Adhemerval Zanella:

> On 21/10/2020 02:21, Florian Weimer wrote:
>> * Adhemerval Zanella via Libc-alpha:
>> 
>>> diff --git a/sysdeps/unix/sysv/linux/alpha/fxstat64.c b/sysdeps/unix/sysv/linux/alpha/fxstat64.c
>>> index 9d6b8eca32..bcfb55050c 100644
>>> --- a/sysdeps/unix/sysv/linux/alpha/fxstat64.c
>>> +++ b/sysdeps/unix/sysv/linux/alpha/fxstat64.c
>>> @@ -22,9 +22,11 @@
>>>  #include <kernel_stat.h>
>>>  #include <sysdep.h>
>>>  #include <xstatconv.h>
>>> +#include <shlib-compat.h>
>>>  
>>>  /* Get information about the file NAME in BUF.  */
>>>  int
>>> +attribute_compat_text_section
>>>  __fxstat64 (int vers, int fd, struct stat64 *buf)
>>>  {
>>>    switch (vers)
>>> @@ -42,4 +44,12 @@ __fxstat64 (int vers, int fd, struct stat64 *buf)
>>>        }
>>>      }
>>>  }
>>> -strong_alias (__fxstat64, __fxstat);
>>> +
>>> +#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
>>> +strong_alias (__fxstat64, __fxstat_compat)
>>> +compat_symbol (libc, __fxstat_compat, __fxstat, GLIBC_2_0);
>>> +#endif
>>> +
>>> +#if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_33)
>>> +compat_symbol (libc, __fxstat64, __fxstat64, GLIBC_2_1);
>>> +#endif
>> 
>> This change breaks a lot of static libraries out there.  Do we really
>> want to do this immediately, or should we just stop using these symbols
>> from libc_nonshared.a, and defer the compat symbol treatment to a future
>> glibc version?
>
> This is the similar the libm finite symbols where my understanding was
> user was supposed to rebuild the library.

I think the impact of that is a bit narrower because it requires special
compiler flags.  But I suspect I will ask for reverting that in a year
as well. 8-/

> The issue is only for static linking, by stopping using
> libc_nonshared.a we need to provide the versioned stat symbols anyway.
> And we still need to handle new ABIs where adding the old xstat
> symbols does not make sense (such as riscv32 or any new 32-bit
> architecture).

You could use a SHLIB_COMPAT conditional without compat_symbol, the two
are separate.

> It would required a new compat_symbol directive to export the symbols
> *just* for static linking and some building tinkering to just build
> the xstat symbol for dynamic object and static linking depending of
> support ABI version.

The problem is not relying on the contents of libc_nonshared.a, that is
working still.  It's code that calls __xstat et al. directly via the old
inline functions in the headers.

> If we just defer the compat move, it would add the needless symbols on
> newer ABIs that we will need to keep supporting indefinitely (even
> though they won't be used anywhere unless user explicily links against
> a protected symbol) and we would eventually need to handle the y2038
> support on old ABIs (with the _TIME_SIZE selection) by either adding
> proper 64-bit time support for by removing the xstat for good.

See above, we can (and should) remove it on newer ABIs only.

Thanks,
Florian
-- 
Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill


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

* Re: __xstat et al. as compat symbols
  2020-10-21 12:57       ` __xstat et al. as compat symbols Florian Weimer via Libc-alpha
@ 2020-10-21 13:09         ` Adhemerval Zanella via Libc-alpha
  2020-10-22 10:08           ` Florian Weimer via Libc-alpha
  0 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-10-21 13:09 UTC (permalink / raw)
  To: Florian Weimer; +Cc: Alistair Francis, Adhemerval Zanella via Libc-alpha



On 21/10/2020 09:57, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> On 21/10/2020 02:21, Florian Weimer wrote:
>>> * Adhemerval Zanella via Libc-alpha:
>>>
>>>> diff --git a/sysdeps/unix/sysv/linux/alpha/fxstat64.c b/sysdeps/unix/sysv/linux/alpha/fxstat64.c
>>>> index 9d6b8eca32..bcfb55050c 100644
>>>> --- a/sysdeps/unix/sysv/linux/alpha/fxstat64.c
>>>> +++ b/sysdeps/unix/sysv/linux/alpha/fxstat64.c
>>>> @@ -22,9 +22,11 @@
>>>>  #include <kernel_stat.h>
>>>>  #include <sysdep.h>
>>>>  #include <xstatconv.h>
>>>> +#include <shlib-compat.h>
>>>>  
>>>>  /* Get information about the file NAME in BUF.  */
>>>>  int
>>>> +attribute_compat_text_section
>>>>  __fxstat64 (int vers, int fd, struct stat64 *buf)
>>>>  {
>>>>    switch (vers)
>>>> @@ -42,4 +44,12 @@ __fxstat64 (int vers, int fd, struct stat64 *buf)
>>>>        }
>>>>      }
>>>>  }
>>>> -strong_alias (__fxstat64, __fxstat);
>>>> +
>>>> +#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
>>>> +strong_alias (__fxstat64, __fxstat_compat)
>>>> +compat_symbol (libc, __fxstat_compat, __fxstat, GLIBC_2_0);
>>>> +#endif
>>>> +
>>>> +#if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_33)
>>>> +compat_symbol (libc, __fxstat64, __fxstat64, GLIBC_2_1);
>>>> +#endif
>>>
>>> This change breaks a lot of static libraries out there.  Do we really
>>> want to do this immediately, or should we just stop using these symbols
>>> from libc_nonshared.a, and defer the compat symbol treatment to a future
>>> glibc version?
>>
>> This is the similar the libm finite symbols where my understanding was
>> user was supposed to rebuild the library.
> 
> I think the impact of that is a bit narrower because it requires special
> compiler flags.  But I suspect I will ask for reverting that in a year
> as well. 8-/

It is sad that we can't get rid of clunky and not well thought interface,
which kind of issues are you seeing that is making you thinking about
reverting the libm finite symbols?

> 
>> The issue is only for static linking, by stopping using
>> libc_nonshared.a we need to provide the versioned stat symbols anyway.
>> And we still need to handle new ABIs where adding the old xstat
>> symbols does not make sense (such as riscv32 or any new 32-bit
>> architecture).
> 
> You could use a SHLIB_COMPAT conditional without compat_symbol, the two
> are separate.

The problem is with:

  #if SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
  int
  __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
  {
  }
  #endif

It won't be built for static and without using SHLIB_COMPAT in this 
case will build the interfaces for ABIs that doe not require it.

> 
>> It would required a new compat_symbol directive to export the symbols
>> *just* for static linking and some building tinkering to just build
>> the xstat symbol for dynamic object and static linking depending of
>> support ABI version.
> 
> The problem is not relying on the contents of libc_nonshared.a, that is
> working still.  It's code that calls __xstat et al. directly via the old
> inline functions in the headers.

Yes, I am aware. I am outlining is I think we would need some thikering
to build for static case that is not easily support with the current
shlib-compat macros we have.

> 
>> If we just defer the compat move, it would add the needless symbols on
>> newer ABIs that we will need to keep supporting indefinitely (even
>> though they won't be used anywhere unless user explicily links against
>> a protected symbol) and we would eventually need to handle the y2038
>> support on old ABIs (with the _TIME_SIZE selection) by either adding
>> proper 64-bit time support for by removing the xstat for good.
> 
> See above, we can (and should) remove it on newer ABIs only.

So now is we are moving in providing what is supposed to be compat symbols 
in the static library case as well. Do we really want to start supporting 
such scenario?

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

* Re: __xstat et al. as compat symbols
  2020-10-21 13:09         ` Adhemerval Zanella via Libc-alpha
@ 2020-10-22 10:08           ` Florian Weimer via Libc-alpha
  2020-10-22 12:43             ` Adhemerval Zanella via Libc-alpha
  0 siblings, 1 reply; 80+ messages in thread
From: Florian Weimer via Libc-alpha @ 2020-10-22 10:08 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Alistair Francis, Adhemerval Zanella via Libc-alpha

* Adhemerval Zanella:

>> I think the impact of that is a bit narrower because it requires special
>> compiler flags.  But I suspect I will ask for reverting that in a year
>> as well. 8-/
>
> It is sad that we can't get rid of clunky and not well thought interface,
> which kind of issues are you seeing that is making you thinking about
> reverting the libm finite symbols?

Based on the failures I've seen so far, Ocaml would have to start
distributing binaries for glibc 2.32 and earlier (probably built on
something like glibc 2.17) and glibc 2.33 and later (built on glibc
2.33).  Other native code compilers are likely affected in the same way.

>>> The issue is only for static linking, by stopping using
>>> libc_nonshared.a we need to provide the versioned stat symbols anyway.
>>> And we still need to handle new ABIs where adding the old xstat
>>> symbols does not make sense (such as riscv32 or any new 32-bit
>>> architecture).
>> 
>> You could use a SHLIB_COMPAT conditional without compat_symbol, the two
>> are separate.
>
> The problem is with:
>
>   #if SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
>   int
>   __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
>   {
>   }
>   #endif
>
> It won't be built for static and without using SHLIB_COMPAT in this 
> case will build the interfaces for ABIs that doe not require it.

We could rename TEST_COMPAT and use that, I think it already has the
right semantics.  Or you could use “ifdef have-GLIBC_2.32” at the
makefile level.

>>> If we just defer the compat move, it would add the needless symbols on
>>> newer ABIs that we will need to keep supporting indefinitely (even
>>> though they won't be used anywhere unless user explicily links against
>>> a protected symbol) and we would eventually need to handle the y2038
>>> support on old ABIs (with the _TIME_SIZE selection) by either adding
>>> proper 64-bit time support for by removing the xstat for good.
>> 
>> See above, we can (and should) remove it on newer ABIs only.
>
> So now is we are moving in providing what is supposed to be compat
> symbols in the static library case as well. Do we really want to start
> supporting such scenario?

Downstream, we do not need these symbols for fully static linking, so
SHLIB_COMPAT would actually be okay for our needs, I think.

I guess if upstream rejects this, we can provide a stub library that can
be used to link against the __xstat et al. symbols as a workaround.  But
if we need it, Debian (with its lack of per-release mass rebuilds) will
likely need it too, and some other distributions probably as well.  So
at that point, I think we need to ask ourselves as upstream developers
whether we are really serving the needs of our users.

Maybe this is coming across a bit strongly, I just want to put it out
there.  If Fedora rawhide breaks after we make a change that is
technically correct because it affects officially unsupported
configurations only, it makes sense to pause and think if what we are
doing is really correct.

Thanks,
Florian
-- 
Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill


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

* Re: __xstat et al. as compat symbols
  2020-10-22 10:08           ` Florian Weimer via Libc-alpha
@ 2020-10-22 12:43             ` Adhemerval Zanella via Libc-alpha
  2020-10-22 15:37               ` Florian Weimer via Libc-alpha
  0 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-10-22 12:43 UTC (permalink / raw)
  To: Florian Weimer; +Cc: Alistair Francis, Adhemerval Zanella via Libc-alpha



On 22/10/2020 07:08, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>>> I think the impact of that is a bit narrower because it requires special
>>> compiler flags.  But I suspect I will ask for reverting that in a year
>>> as well. 8-/
>>
>> It is sad that we can't get rid of clunky and not well thought interface,
>> which kind of issues are you seeing that is making you thinking about
>> reverting the libm finite symbols?
> 
> Based on the failures I've seen so far, Ocaml would have to start
> distributing binaries for glibc 2.32 and earlier (probably built on
> something like glibc 2.17) and glibc 2.33 and later (built on glibc
> 2.33).  Other native code compilers are likely affected in the same way.

Indeed it seems that Ocaml distributes static libraries with reference
xstat symbols.  And I agree that this is only one example, I would
expect more libraries would use the xstat symbos.

> 
>>>> The issue is only for static linking, by stopping using
>>>> libc_nonshared.a we need to provide the versioned stat symbols anyway.
>>>> And we still need to handle new ABIs where adding the old xstat
>>>> symbols does not make sense (such as riscv32 or any new 32-bit
>>>> architecture).
>>>
>>> You could use a SHLIB_COMPAT conditional without compat_symbol, the two
>>> are separate.
>>
>> The problem is with:
>>
>>   #if SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
>>   int
>>   __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
>>   {
>>   }
>>   #endif
>>
>> It won't be built for static and without using SHLIB_COMPAT in this 
>> case will build the interfaces for ABIs that doe not require it.
> 
> We could rename TEST_COMPAT and use that, I think it already has the
> right semantics.  Or you could use “ifdef have-GLIBC_2.32” at the
> makefile level.

I think TEST_COMPAT would be a better alternative since, it would give all
the information how the symbol should be handled ABI wise on the C file
instead of spreading over multiple files.

> 
>>>> If we just defer the compat move, it would add the needless symbols on
>>>> newer ABIs that we will need to keep supporting indefinitely (even
>>>> though they won't be used anywhere unless user explicily links against
>>>> a protected symbol) and we would eventually need to handle the y2038
>>>> support on old ABIs (with the _TIME_SIZE selection) by either adding
>>>> proper 64-bit time support for by removing the xstat for good.
>>>
>>> See above, we can (and should) remove it on newer ABIs only.
>>
>> So now is we are moving in providing what is supposed to be compat
>> symbols in the static library case as well. Do we really want to start
>> supporting such scenario?
> 
> Downstream, we do not need these symbols for fully static linking, so
> SHLIB_COMPAT would actually be okay for our needs, I think.
> 
> I guess if upstream rejects this, we can provide a stub library that can
> be used to link against the __xstat et al. symbols as a workaround.  But
> if we need it, Debian (with its lack of per-release mass rebuilds) will
> likely need it too, and some other distributions probably as well.  So
> at that point, I think we need to ask ourselves as upstream developers
> whether we are really serving the needs of our users.

I really not sure how is the best way to handle this transitions, since
they tend to require a lot of time and affecting different releases.
And it does not make sense to provide this specific stub libraries as
different project, since it is a implementation detail from glibc itself.

> 
> Maybe this is coming across a bit strongly, I just want to put it out
> there.  If Fedora rawhide breaks after we make a change that is
> technically correct because it affects officially unsupported
> configurations only, it makes sense to pause and think if what we are
> doing is really correct.

Thanks for bring this up, and I agree with you that this breakage might
incur in more headaches than solutions.  I will send a fix to export
the xstat symbols in static objects as well, while preserving the compat
symbols on shared objects.

It is unfortunate that we need to add such workarounds, but it seems 
a better strategy. 

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

* Re: __xstat et al. as compat symbols
  2020-10-22 12:43             ` Adhemerval Zanella via Libc-alpha
@ 2020-10-22 15:37               ` Florian Weimer via Libc-alpha
  2020-10-22 16:40                 ` Adhemerval Zanella via Libc-alpha
  0 siblings, 1 reply; 80+ messages in thread
From: Florian Weimer via Libc-alpha @ 2020-10-22 15:37 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Alistair Francis, Adhemerval Zanella via Libc-alpha

* Adhemerval Zanella:

> Thanks for bring this up, and I agree with you that this breakage might
> incur in more headaches than solutions.  I will send a fix to export
> the xstat symbols in static objects as well, while preserving the compat
> symbols on shared objects.

Sorry, I do not see how the compat symbols work for the Ocaml use case?
The compat symbol is what creates the Ocaml link failure.  It has to be
a non-compat symbol.  We have to rely on lack of use in the installed
headers (which does not seem to be a real problem in this particular
case).

By the way, I verified that glibc 2.0 binaries without symbol versioning
can bind to the __xstat compat symbol.  Apparently binaries can do that
as long as they do not contain any version information at all:

    165100:	binding file /home/fweimer/src/my/glibc-test-binaries/gcc-2.7.2.3/i386/root/usr/bin/gcc [0] to ./libc.so.6 [0]: normal symbol `__xstat'

Thanks,
Florian
-- 
Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill


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

* Re: __xstat et al. as compat symbols
  2020-10-22 15:37               ` Florian Weimer via Libc-alpha
@ 2020-10-22 16:40                 ` Adhemerval Zanella via Libc-alpha
  2020-10-22 18:04                   ` Adhemerval Zanella via Libc-alpha
  0 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-10-22 16:40 UTC (permalink / raw)
  To: Florian Weimer; +Cc: Alistair Francis, Adhemerval Zanella via Libc-alpha



On 22/10/2020 12:37, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> Thanks for bring this up, and I agree with you that this breakage might
>> incur in more headaches than solutions.  I will send a fix to export
>> the xstat symbols in static objects as well, while preserving the compat
>> symbols on shared objects.
> 
> Sorry, I do not see how the compat symbols work for the Ocaml use case?
> The compat symbol is what creates the Ocaml link failure.  It has to be
> a non-compat symbol.  We have to rely on lack of use in the installed
> headers (which does not seem to be a real problem in this particular
> case).

So the issue is Ocaml is providing static libraries that are meant to 
generate dynamic linked binaries? Does it provide the same facility to
build static binaries and if it were the case, how this is done?

In the end, do still need to keep providing the xstat symbols in the
static library as well or just remove the compat symbol directive would
be suffice?

> 
> By the way, I verified that glibc 2.0 binaries without symbol versioning
> can bind to the __xstat compat symbol.  Apparently binaries can do that
> as long as they do not contain any version information at all:
> 
>     165100:	binding file /home/fweimer/src/my/glibc-test-binaries/gcc-2.7.2.3/i386/root/usr/bin/gcc [0] to ./libc.so.6 [0]: normal symbol `__xstat'
> 
> Thanks,
> Florian
> 

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

* Re: __xstat et al. as compat symbols
  2020-10-22 16:40                 ` Adhemerval Zanella via Libc-alpha
@ 2020-10-22 18:04                   ` Adhemerval Zanella via Libc-alpha
  0 siblings, 0 replies; 80+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2020-10-22 18:04 UTC (permalink / raw)
  To: Florian Weimer; +Cc: Alistair Francis, Adhemerval Zanella via Libc-alpha



On 22/10/2020 13:40, Adhemerval Zanella wrote:
> 
> 
> On 22/10/2020 12:37, Florian Weimer wrote:
>> * Adhemerval Zanella:
>>
>>> Thanks for bring this up, and I agree with you that this breakage might
>>> incur in more headaches than solutions.  I will send a fix to export
>>> the xstat symbols in static objects as well, while preserving the compat
>>> symbols on shared objects.
>>
>> Sorry, I do not see how the compat symbols work for the Ocaml use case?
>> The compat symbol is what creates the Ocaml link failure.  It has to be
>> a non-compat symbol.  We have to rely on lack of use in the installed
>> headers (which does not seem to be a real problem in this particular
>> case).
> 
> So the issue is Ocaml is providing static libraries that are meant to 
> generate dynamic linked binaries? Does it provide the same facility to
> build static binaries and if it were the case, how this is done?
> 
> In the end, do still need to keep providing the xstat symbols in the
> static library as well or just remove the compat symbol directive would
> be suffice?
> 
>>
>> By the way, I verified that glibc 2.0 binaries without symbol versioning
>> can bind to the __xstat compat symbol.  Apparently binaries can do that
>> as long as they do not contain any version information at all:
>>
>>     165100:	binding file /home/fweimer/src/my/glibc-test-binaries/gcc-2.7.2.3/i386/root/usr/bin/gcc [0] to ./libc.so.6 [0]: normal symbol `__xstat'

Ok, I understood better the scenario Ocaml might be doing and this is
another fallback of using the libc_noshared wrapper. I will send patch
to revert and fix the fix the build for newer ABIS.

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

end of thread, other threads:[~2020-10-22 18:04 UTC | newest]

Thread overview: 80+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-23 19:46 [PATCH 00/16] Add y2038 support for stat functions Adhemerval Zanella via Libc-alpha
2020-07-23 19:46 ` [PATCH 01/16] linux: Always define STAT_IS_KERNEL_STAT Adhemerval Zanella via Libc-alpha
2020-07-24  8:17   ` Lukasz Majewski
2020-07-23 19:46 ` [PATCH 02/16] linux: Define STAT64_IS_KERNEL_STAT64 Adhemerval Zanella via Libc-alpha
2020-07-24  8:20   ` Lukasz Majewski
2020-07-23 19:46 ` [PATCH 03/16] linux: Consolidate xstat{64} Adhemerval Zanella via Libc-alpha
2020-07-23 20:51   ` Joseph Myers
2020-07-24  8:34   ` Lukasz Majewski
2020-09-09 14:46   ` Lukasz Majewski
2020-09-09 18:05     ` Adhemerval Zanella via Libc-alpha
2020-09-10  7:10       ` Lukasz Majewski
2020-07-23 19:46 ` [PATCH 04/16] linux: Consolidate lxstat{64} Adhemerval Zanella via Libc-alpha
2020-07-24  8:43   ` Lukasz Majewski
2020-07-23 19:46 ` [PATCH 05/16] linux: Consolidate fxstat{64} Adhemerval Zanella via Libc-alpha
2020-07-24  9:04   ` Lukasz Majewski
2020-07-23 19:46 ` [PATCH 06/16] linux: Consolidate fxstatat{64} Adhemerval Zanella via Libc-alpha
2020-07-24  9:14   ` Lukasz Majewski
2020-07-23 19:46 ` [PATCH 07/16] Linux: Consolidate xmknod Adhemerval Zanella via Libc-alpha
2020-07-24  9:14   ` Lukasz Majewski
2020-07-23 19:46 ` [PATCH 08/16] Remove internal usage of extensible stat functions Adhemerval Zanella via Libc-alpha
2020-07-24  9:16   ` Lukasz Majewski
2020-07-23 19:46 ` [PATCH 09/16] Remove stat wrapper functions, move them to exported symbols Adhemerval Zanella via Libc-alpha
2020-07-24  9:23   ` Lukasz Majewski
2020-07-23 19:46 ` [PATCH 10/16] Remove mknod wrapper functions, move them to symbols Adhemerval Zanella via Libc-alpha
2020-07-23 20:53   ` Joseph Myers
2020-07-23 20:58     ` Adhemerval Zanella via Libc-alpha
2020-07-23 21:01       ` Joseph Myers
2020-07-24  9:25   ` Lukasz Majewski
2020-10-12 22:27   ` Joseph Myers
2020-10-13  0:58     ` Adhemerval Zanella via Libc-alpha
2020-07-23 19:46 ` [PATCH 11/16] linux: Move the struct stat{64} to struct_stat.h Adhemerval Zanella via Libc-alpha
2020-07-24  9:27   ` Lukasz Majewski
2020-07-23 19:46 ` [PATCH 12/16] linux: Implement {l}fstat{at} in terms of fstatat Adhemerval Zanella via Libc-alpha
2020-07-24  9:29   ` Lukasz Majewski
2020-07-23 19:46 ` [PATCH 13/16] linux: Disentangle fstatat from fxstatat Adhemerval Zanella via Libc-alpha
2020-07-24  9:39   ` Lukasz Majewski
2020-07-24 10:25   ` Florian Weimer via Libc-alpha
2020-07-24 14:39     ` Adhemerval Zanella via Libc-alpha
2020-07-23 19:46 ` [PATCH 14/16] linux: Move {f}xstat{at} to compat symbols Adhemerval Zanella via Libc-alpha
2020-07-24  9:40   ` Lukasz Majewski
2020-10-21  5:21   ` __xstat et al. as compat symbols (was: Re: [PATCH 14/16] linux: Move {f}xstat{at} to compat symbols) Florian Weimer via Libc-alpha
2020-10-21 11:59     ` Adhemerval Zanella via Libc-alpha
2020-10-21 12:57       ` __xstat et al. as compat symbols Florian Weimer via Libc-alpha
2020-10-21 13:09         ` Adhemerval Zanella via Libc-alpha
2020-10-22 10:08           ` Florian Weimer via Libc-alpha
2020-10-22 12:43             ` Adhemerval Zanella via Libc-alpha
2020-10-22 15:37               ` Florian Weimer via Libc-alpha
2020-10-22 16:40                 ` Adhemerval Zanella via Libc-alpha
2020-10-22 18:04                   ` Adhemerval Zanella via Libc-alpha
2020-07-23 19:46 ` [PATCH 15/16] linux: Add {f}stat{at} y2038 support Adhemerval Zanella via Libc-alpha
2020-07-23 20:55   ` Joseph Myers
2020-07-23 21:00     ` Adhemerval Zanella via Libc-alpha
2020-07-24 10:53   ` Lukasz Majewski
2020-07-30 12:42     ` Adhemerval Zanella via Libc-alpha
2020-08-02 19:46       ` Maciej W. Rozycki via Libc-alpha
2020-10-06  9:48   ` Lukasz Majewski
2020-10-07 12:52     ` Adhemerval Zanella via Libc-alpha
2020-10-07 14:25       ` Adhemerval Zanella via Libc-alpha
2020-10-07 20:20         ` Lukasz Majewski
2020-10-07 21:01           ` Adhemerval Zanella via Libc-alpha
2020-10-07 21:07         ` Adhemerval Zanella via Libc-alpha
2020-10-08  7:57           ` Lukasz Majewski
2020-10-09 14:05             ` Adhemerval Zanella via Libc-alpha
2020-10-09 15:39               ` Lukasz Majewski
2020-10-09 20:06                 ` Adhemerval Zanella via Libc-alpha
2020-10-13 13:58         ` Lukasz Majewski
2020-10-13 14:18           ` Adhemerval Zanella via Libc-alpha
2020-10-13 14:23             ` H.J. Lu via Libc-alpha
2020-10-13 14:27               ` Adhemerval Zanella via Libc-alpha
2020-10-13 18:14             ` Adhemerval Zanella via Libc-alpha
2020-10-13 21:20               ` Lukasz Majewski
2020-10-13 21:40             ` Lukasz Majewski
2020-10-14 13:15               ` Lukasz Majewski
2020-10-14 13:39                 ` Adhemerval Zanella via Libc-alpha
2020-07-23 19:46 ` [PATCH 16/16] linux: Move xmknoda{at} to compat symbols Adhemerval Zanella via Libc-alpha
2020-07-24 10:30   ` Florian Weimer via Libc-alpha
2020-07-24 12:34     ` Adhemerval Zanella via Libc-alpha
2020-07-24 12:43       ` Florian Weimer via Libc-alpha
2020-07-24 12:49         ` Adhemerval Zanella via Libc-alpha
2020-07-24 10:43   ` Lukasz Majewski

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).