]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
linux: Disentangle fstatat from fxstatat
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Sat, 18 Jul 2020 11:20:46 +0000 (08:20 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Fri, 9 Oct 2020 20:02:06 +0000 (17:02 -0300)
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>
26 files changed:
include/sys/stat.h
sysdeps/unix/sysv/linux/alpha/fxstat64.c
sysdeps/unix/sysv/linux/alpha/fxstatat64.c
sysdeps/unix/sysv/linux/alpha/lxstat64.c
sysdeps/unix/sysv/linux/alpha/xstat64.c
sysdeps/unix/sysv/linux/fstatat.c
sysdeps/unix/sysv/linux/fstatat64.c
sysdeps/unix/sysv/linux/fxstat.c
sysdeps/unix/sysv/linux/fxstat64.c
sysdeps/unix/sysv/linux/fxstatat.c
sysdeps/unix/sysv/linux/fxstatat64.c
sysdeps/unix/sysv/linux/kstat_cp.h [new file with mode: 0644]
sysdeps/unix/sysv/linux/lxstat.c
sysdeps/unix/sysv/linux/lxstat64.c
sysdeps/unix/sysv/linux/mips/fxstat.c
sysdeps/unix/sysv/linux/mips/lxstat.c
sysdeps/unix/sysv/linux/mips/mips64/fxstat64.c
sysdeps/unix/sysv/linux/mips/mips64/fxstatat.c
sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c
sysdeps/unix/sysv/linux/mips/mips64/kstat_cp.h [new file with mode: 0644]
sysdeps/unix/sysv/linux/mips/mips64/lxstat64.c
sysdeps/unix/sysv/linux/mips/mips64/xstat64.c
sysdeps/unix/sysv/linux/mips/xstat.c
sysdeps/unix/sysv/linux/sparc/sparc64/kstat_cp.h [new file with mode: 0644]
sysdeps/unix/sysv/linux/xstat.c
sysdeps/unix/sysv/linux/xstat64.c

index 1f832f6ce8cf06c3586fa883e3ce118f434cc8d5..3d4ea7f0c702fc4a695ae1416837591576a431dc 100644 (file)
@@ -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)
index 286a2f0a6c2301aca4caae81a99eb5927c321b02..9d6b8eca32a404612070f32de0bbc0fa24e494b8 100644 (file)
@@ -42,6 +42,4 @@ __fxstat64 (int vers, int fd, struct stat64 *buf)
       }
     }
 }
-hidden_def (__fxstat64)
 strong_alias (__fxstat64, __fxstat);
-hidden_ver (__fxstat64, __fxstat)
index f10c1d31e8829115c0549199fff0aac18f70029f..997fb87ac66019a57a8fca50cff93f3830fcb0ab 100644 (file)
@@ -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
index 90dc0c7ce7f3dfa9ba69566a4d4813f27bfe9e57..38f132f15ecab852bc59ed08bb267245164aa51f 100644 (file)
@@ -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)
index ac1af537802c8f9d83d96d589713681173721506..c856c95dc5bdbf85377f1f7d9699e78d1a2fccaa 100644 (file)
@@ -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)
index 457496605c9464e719aed40d313e56f9c83a89d8..c7fcfaf2772ddddd3895f2110fea99c1b3b5f116 100644 (file)
 
 #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)
 {
-  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, buf, flag);
+  if (r == 0 && (buf->__st_ino_pad != 0
+                || buf->__st_size_pad != 0
+                || buf->__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 (buf, 0, sizeof (*buf));
+
+      buf->st_dev = st64.st_dev,
+      buf->st_ino = st64.st_ino;
+      buf->st_mode = st64.st_mode;
+      buf->st_nlink = st64.st_nlink;
+      buf->st_uid = st64.st_uid;
+      buf->st_gid = st64.st_gid;
+      buf->st_rdev = st64.st_rdev;
+      buf->st_size = st64.st_size;
+      buf->st_blksize = st64.st_blksize;
+      buf->st_blocks  = st64.st_blocks;
+      buf->st_atim.tv_sec = st64.st_atim.tv_sec;
+      buf->st_atim.tv_nsec = st64.st_atim.tv_nsec;
+      buf->st_mtim.tv_sec = st64.st_mtim.tv_sec;
+      buf->st_mtim.tv_nsec = st64.st_mtim.tv_nsec;
+      buf->st_ctim.tv_sec = st64.st_ctim.tv_sec;
+      buf->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 = INLINE_SYSCALL_CALL (newfstatat, fd, file, &kst, flag);
+  return r ?: __cp_kstat_stat (&kst, buf);
+#  endif /* __nr_fstatat64  */
+# endif /* STAT_IS_KERNEL_STAT  */
 }
 
 weak_alias (__fstatat, fstatat)
index 46487919e686dbe8d1e87eb6436bb10a67708ca8..d9d3ea5e64f29ff995ec7ce365868410cf45dd21 100644 (file)
 #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)
 {
-  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, buf, flag);
+# elif defined __NR_fstatat64
+#  if STAT64_IS_KERNEL_STAT64
+  /* 64-bit kABI outlier, e.g. alpha.  */
+  return INLINE_SYSCALL_CALL (fstatat64, fd, file, buf, 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 (buf, &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 (buf, &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, buf, flag);
+# else
+  /* 64-bit kabi outlier, e.g. mips64 and mips64-n32.  */
+  struct kernel_stat kst;
+  int r = INLINE_SYSCALL_CALL (newfstatat, fd, file, &kst, flag);
+  return r ?: __cp_kstat_stat64 (&kst, buf);
+# endif
+#endif
 }
 hidden_def (__fstatat64)
 weak_alias (__fstatat64, fstatat64)
index b46e344d0e08505044da4c70d835ff612bdf3e2e..f78497ea929bffccd23f24db7d961f3273a67ab2 100644 (file)
@@ -57,5 +57,4 @@ __fxstat (int vers, int fd, struct stat *buf)
       }
     }
 }
-hidden_def (__fxstat)
 #endif /* XSTAT_IS_XSTAT64  */
index 330af75f118222c1400e95eabefe40b1663666e2..dd7b7528737ddb26a7b4f3153f9ec9c1cbf7b8f5 100644 (file)
@@ -69,13 +69,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
index 0291a2c5983051762e914f5df6ed90ac294b8283..1a60fc10e37668870f1d36b965ce00eeb4be40b1 100644 (file)
@@ -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  */
index ac33ab4fc959bb3a0e61ec90ba7a8d41e79dd066..7fe034809c84cc87340d961900ff944a54895e0a 100644 (file)
@@ -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 (file)
index 0000000..69397db
--- /dev/null
@@ -0,0 +1,2 @@
+/* Empty, it is overridden by an architecture which might require copy to or
+   from a kernel_stat stat struct to glibc export stat{64}.  */
index 2c7a0b3f6de822f58eb2ad2cec0403e8478c409e..9e7e02d298db48abead68c42f5993dfbe19e0371 100644 (file)
@@ -58,5 +58,4 @@ __lxstat (int vers, const char *name, struct stat *buf)
       }
     }
 }
-hidden_def (__lxstat)
 #endif /* XSTAT_IS_XSTAT64  */
index d0d8b5fb18557c333292d1722a9422f19491573c..2b06133bf33658396e66b3758927e214c2e98c6c 100644 (file)
@@ -91,8 +91,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
index 16c3cefee2dcb673954824e49ae2061bc3de8250..4585c2362bb382a92ee5874cfed634139ea13598 100644 (file)
@@ -39,4 +39,3 @@ __fxstat (int vers, int fd, struct stat *buf)
       }
     }
 }
-hidden_def (__fxstat)
index eb07549adfac353a4455c5c1b493e4e67ea9d25f..62a3b15b32ee9f25c6ababf813fea7b57225d937 100644 (file)
@@ -39,4 +39,3 @@ __lxstat (int vers, const char *name, struct stat *buf)
       }
     }
 }
-hidden_def (__lxstat)
index 3fcdd9f1ee0ffd9e2634abea013f5dd3ca953fca..e6c1cacd4b7c7769ee3ef43c8c34802d8ca68701 100644 (file)
@@ -31,5 +31,3 @@ __fxstat64 (int vers, int fd, struct stat64 *buf)
   return r ?: __xstat64_conv (vers, &kbuf, buf);
 
 }
-
-hidden_def (__fxstat64)
index 58410a144176c62ee1f04bedddaee6680f8e8ab1..e384dbab8b6eed636292acfa985eec9f5d8a0ef0 100644 (file)
@@ -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)
index e5416d8971a31176053e39796da7158d3a6fa4e7..cfd172d3018c37407be02d0fe1d2a42f417010dd 100644 (file)
@@ -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 (file)
index 0000000..7f22641
--- /dev/null
@@ -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;
+}
index 28bac57e58608bd73c9025ead4fa185cf9fa05be..0f3934f8c8b37aa34a11f5dfb678cd1de736894c 100644 (file)
@@ -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)
index 99b03c75937ead71cf8d0b811274a6b99f374c95..64d29522763a80f0a7e8267fd52f8c998fb18535 100644 (file)
@@ -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)
index 835691cf8924ca64b77c4ce62cabbffe154f3950..d6ff5ccbe06412ea55fd915679df2e8340b48846 100644 (file)
@@ -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 (file)
index 0000000..0599b6a
--- /dev/null
@@ -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;
+}
index 0ae52b19019a82be2052655ed54070d20fe7d0be..a971e8cf6a7da3f14789c7357120443032dc8017 100644 (file)
@@ -57,5 +57,4 @@ __xstat (int vers, const char *name, struct stat *buf)
       }
     }
 }
-hidden_def (__xstat)
 #endif /* XSTAT_IS_XSTAT64  */
index 919d98cb4eee0d920a3b285c5c55f144aa0b2a80..9d368d5841b181e0db17320db30c4f16ebdd6498 100644 (file)
@@ -88,8 +88,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