about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux/sparc/sparc64
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2020-07-18 08:20:46 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2020-10-09 17:02:06 -0300
commit6073bae64ccf27d6ebf5e49592a715801e14a5ba (patch)
treedfcd07c7eb2ac8f058ba303b87347c848c7b747d /sysdeps/unix/sysv/linux/sparc/sparc64
parent30f1c7439489bf756a45e349d69be1826e0c9bd8 (diff)
downloadglibc-6073bae64ccf27d6ebf5e49592a715801e14a5ba.tar.gz
glibc-6073bae64ccf27d6ebf5e49592a715801e14a5ba.tar.xz
glibc-6073bae64ccf27d6ebf5e49592a715801e14a5ba.zip
linux: Disentangle fstatat from fxstatat
It implements all the required syscall for the all Linux kABIS on
fstatat{64} 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>
Diffstat (limited to 'sysdeps/unix/sysv/linux/sparc/sparc64')
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc64/kstat_cp.h46
1 files changed, 46 insertions, 0 deletions
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;
+}