aboutsummaryrefslogtreecommitdiff
path: root/include/sys
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 /include/sys
parent30f1c7439489bf756a45e349d69be1826e0c9bd8 (diff)
downloadglibc-6073bae64ccf27d6ebf5e49592a715801e14a5ba.zip
glibc-6073bae64ccf27d6ebf5e49592a715801e14a5ba.tar.gz
glibc-6073bae64ccf27d6ebf5e49592a715801e14a5ba.tar.bz2
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 'include/sys')
-rw-r--r--include/sys/stat.h32
1 files changed, 27 insertions, 5 deletions
diff --git a/include/sys/stat.h b/include/sys/stat.h
index 1f832f6..3d4ea7f 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)