]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Add the statx function
authorFlorian Weimer <fweimer@redhat.com>
Tue, 10 Jul 2018 14:14:45 +0000 (16:14 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Tue, 10 Jul 2018 14:14:45 +0000 (16:14 +0200)
44 files changed:
ChangeLog
NEWS
include/bits/statx.h [new file with mode: 0644]
io/Makefile
io/Versions
io/bits/statx.h [new file with mode: 0644]
io/fcntl.h
io/statx.c [new file with mode: 0644]
io/statx_generic.c [new file with mode: 0644]
io/sys/stat.h
io/tst-statx.c [new file with mode: 0644]
manual/filesys.texi
sysdeps/mach/hurd/i386/libc.abilist
sysdeps/unix/sysv/linux/aarch64/libc.abilist
sysdeps/unix/sysv/linux/alpha/kernel-features.h
sysdeps/unix/sysv/linux/alpha/libc.abilist
sysdeps/unix/sysv/linux/arm/libc.abilist
sysdeps/unix/sysv/linux/hppa/libc.abilist
sysdeps/unix/sysv/linux/i386/libc.abilist
sysdeps/unix/sysv/linux/ia64/kernel-features.h
sysdeps/unix/sysv/linux/ia64/libc.abilist
sysdeps/unix/sysv/linux/kernel-features.h
sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
sysdeps/unix/sysv/linux/microblaze/kernel-features.h
sysdeps/unix/sysv/linux/microblaze/libc.abilist
sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
sysdeps/unix/sysv/linux/nios2/libc.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
sysdeps/unix/sysv/linux/sh/libc.abilist
sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
sysdeps/unix/sysv/linux/statx.c [new file with mode: 0644]
sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist

index f21b5ad6ffd83ddd5a31aa4cc0afa656668da889..8a4f85efec4539e74574f03e34a779c57ae72621 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2018-07-10  Florian Weimer  <fweimer@redhat.com>
+
+       * io/Makefile (routines): Add statx.
+       (tests-internal): Add tst-statx.
+       * io/Versions (GLIBC_2.28): Export statx.
+       * io/bits/statx.h: New file.
+       * io/sys/stat.h [__USE_GNU]: Include it.
+       * io/fcntl.h [__USE_GNU] (AT_STATX_SYNC_TYPE)
+       (AT_STATX_SYNC_AS_STAT, AT_STATX_FORCE_SYNC, AT_STATX_DONT_SYNC):
+       Define.
+       * io/statx.c: New file.
+       * io/statx_generic.: Likewise.
+       * io/tst-statx.: Likewise.
+       * include/bits/statx.h: Likewise.
+       * sysdeps/unix/sysv/linux/kernel-features.h
+       [__LINUX_KERNEL_VERSION >= 0x040B00] (__ASSUME_STATX): Define.
+       * sysdeps/unix/sysv/linux/alpha/kernel-features.h
+       [__LINUX_KERNEL_VERSION < 0x040D00] (__ASSUME_STATX): Undefine.
+       * sysdeps/unix/sysv/linux/ia64/kernel-features.h (__ASSUME_STATX):
+       Undefine.
+       * sysdeps/unix/sysv/linux/microblaze/kernel-features.h
+       [__LINUX_KERNEL_VERSION < 0x040C00] (__ASSUME_STATX): Undefine.
+       * sysdeps/unix/sysv/linux/statx.c: New file.
+       * manual/filesys.texi: Note that statx is undocumented.
+       * sysdeps/**/libc*.abilist: Update.
+
 2018-07-10  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
 
        * sysdeps/unix/sysv/linux/tst-ofdlocks-compat.c: Add a comment about
diff --git a/NEWS b/NEWS
index 716d11cda12e90cd71e2d546885edd89473856b3..5de2c2816fbca4bd1836412c7830c403b1a080be 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -55,6 +55,11 @@ Major new features:
   flags and a non-existing destination (and therefore has a race condition
   that can clobber the destination inadvertently).
 
+* The statx function has been added, a variant of the fstatat64
+  function with an additional flags argument.  If there is no direct
+  kernel support for statx, glibc provides basic stat support based on
+  the fstatat64 function.
+
 * IDN domain names in getaddrinfo and getnameinfo now use the system libidn2
   library if installed.  libidn2 version 2.0.5 or later is recommended.  If
   libidn2 is not available, internationalized domain names are not encoded
diff --git a/include/bits/statx.h b/include/bits/statx.h
new file mode 100644 (file)
index 0000000..8ec78a4
--- /dev/null
@@ -0,0 +1 @@
+#include <io/bits/statx.h>
index 4a0d8fea09299023e2b9bef184e8df35acbfb280..f5b1b61d4e1cb3946c4da3941a27281529e82e3e 100644 (file)
@@ -31,7 +31,7 @@ routines :=                                                           \
        utime                                                           \
        mkfifo mkfifoat                                                 \
        stat fstat lstat stat64 fstat64 lstat64 fstatat fstatat64       \
-       xstat fxstat lxstat xstat64 fxstat64 lxstat64                   \
+       xstat fxstat lxstat xstat64 fxstat64 lxstat64 statx             \
        mknod mknodat xmknod xmknodat                                   \
        fxstatat fxstatat64                                             \
        statfs fstatfs statfs64 fstatfs64                               \
@@ -78,6 +78,9 @@ tests         := test-utime test-stat test-stat2 test-lfs tst-getcwd \
 tests-static += tst-copy_file_range-compat
 tests-internal += tst-copy_file_range-compat
 
+# Likewise for statx, but we do not need static linking here.
+tests-internal += tst-statx
+
 ifeq ($(run-built-tests),yes)
 tests-special += $(objpfx)ftwtest.out
 endif
index 98037fbbfcc32f8cf3b5e6e66ac4303d4307b9f1..f7e5dbe49e00063ee35a4fe7777a33a202686d66 100644 (file)
@@ -130,6 +130,7 @@ libc {
   }
   GLIBC_2.28 {
     fcntl64;
+    statx;
   }
   GLIBC_PRIVATE {
     __libc_fcntl64;
diff --git a/io/bits/statx.h b/io/bits/statx.h
new file mode 100644 (file)
index 0000000..e31254e
--- /dev/null
@@ -0,0 +1,91 @@
+/* statx-related definitions and declarations.
+   Copyright (C) 2018 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
+   <http://www.gnu.org/licenses/>.  */
+
+/* This interface is based on <linux/stat.h> in Linux.  */
+
+#ifndef _SYS_STAT_H
+# error Never include <bits/stat.x.h> directly, include <sys/stat.h> instead.
+#endif
+
+struct statx_timestamp
+{
+  __int64_t tv_sec;
+  __uint32_t tv_nsec;
+  __int32_t __statx_timestamp_pad1[1];
+};
+
+/* Warning: The kernel may add additional fields to this struct in the
+   future.  Only use this struct for calling the statx function, not
+   for storing data.  (Expansion will be controlled by the mask
+   argument of the statx function.)  */
+struct statx
+{
+  __uint32_t stx_mask;
+  __uint32_t stx_blksize;
+  __uint64_t stx_attributes;
+  __uint32_t stx_nlink;
+  __uint32_t stx_uid;
+  __uint32_t stx_gid;
+  __uint16_t stx_mode;
+  __uint16_t __statx_pad1[1];
+  __uint64_t stx_ino;
+  __uint64_t stx_size;
+  __uint64_t stx_blocks;
+  __uint64_t stx_attributes_mask;
+  struct statx_timestamp stx_atime;
+  struct statx_timestamp stx_btime;
+  struct statx_timestamp stx_ctime;
+  struct statx_timestamp stx_mtime;
+  __uint32_t stx_rdev_major;
+  __uint32_t stx_rdev_minor;
+  __uint32_t stx_dev_major;
+  __uint32_t stx_dev_minor;
+  __uint64_t __statx_pad2[14];
+};
+
+#define STATX_TYPE 0x0001U
+#define STATX_MODE 0x0002U
+#define STATX_NLINK 0x0004U
+#define STATX_UID 0x0008U
+#define STATX_GID 0x0010U
+#define STATX_ATIME 0x0020U
+#define STATX_MTIME 0x0040U
+#define STATX_CTIME 0x0080U
+#define STATX_INO 0x0100U
+#define STATX_SIZE 0x0200U
+#define STATX_BLOCKS 0x0400U
+#define STATX_BASIC_STATS 0x07ffU
+#define STATX_ALL 0x0fffU
+#define STATX_BTIME 0x0800U
+#define STATX__RESERVED 0x80000000U
+
+#define STATX_ATTR_COMPRESSED 0x0004
+#define STATX_ATTR_IMMUTABLE 0x0010
+#define STATX_ATTR_APPEND 0x0020
+#define STATX_ATTR_NODUMP 0x0040
+#define STATX_ATTR_ENCRYPTED 0x0800
+#define STATX_ATTR_AUTOMOUNT 0x1000
+
+__BEGIN_DECLS
+
+/* Fill *BUF with information about PATH in DIRFD.  */
+int statx (int __dirfd, const char *__restrict __path, int __flags,
+           unsigned int __mask, struct statx *__restrict __buf)
+  __THROW __nonnull ((2, 5));
+
+__END_DECLS
index 3afc62011a2249dc4d1afcf77a2824fbdd4e6b3f..6b0e9fa1fa2a2d8872b1adb5c0861410756a9e52 100644 (file)
@@ -157,6 +157,10 @@ typedef __pid_t pid_t;
 #  define AT_NO_AUTOMOUNT      0x800   /* Suppress terminal automount
                                           traversal.  */
 #  define AT_EMPTY_PATH                0x1000  /* Allow empty relative pathname.  */
+#  define AT_STATX_SYNC_TYPE   0x6000
+#  define AT_STATX_SYNC_AS_STAT        0x0000
+#  define AT_STATX_FORCE_SYNC  0x2000
+#  define AT_STATX_DONT_SYNC   0x4000
 # endif
 # define AT_EACCESS            0x200   /* Test access permitted for
                                           effective IDs, not real IDs.  */
diff --git a/io/statx.c b/io/statx.c
new file mode 100644 (file)
index 0000000..0b90cd0
--- /dev/null
@@ -0,0 +1,29 @@
+/* Generic statx implementation.
+   Copyright (C) 2018 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <sys/stat.h>
+
+#include "statx_generic.c"
+
+int
+statx (int fd, const char *path, int flags,
+       unsigned int mask, struct statx *buf)
+{
+  return statx_generic (fd, path, flags, mask, buf);
+}
diff --git a/io/statx_generic.c b/io/statx_generic.c
new file mode 100644 (file)
index 0000000..df327f8
--- /dev/null
@@ -0,0 +1,81 @@
+/* Generic implementation of statx based on fstatat64.
+   Copyright (C) 2018 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/sysmacros.h>
+
+static inline struct statx_timestamp
+statx_convert_timestamp (struct timespec tv)
+{
+  return (struct statx_timestamp) { tv.tv_sec, tv.tv_nsec };
+}
+
+/* Approximate emulation of statx.  This will always fill in
+   POSIX-mandated attributes even if the underlying file system does
+   not actually support it (for example, GID and UID on file systems
+   without UNIX-style permissions).  */
+static __attribute__ ((unused)) int
+statx_generic (int fd, const char *path, int flags,
+               unsigned int mask, struct statx *buf)
+{
+  /* Flags which need to be cleared before passing them to
+     fstatat64.  */
+  static const int clear_flags = AT_STATX_SYNC_AS_STAT;
+
+    /* Flags supported by our emulation.  */
+  static const int supported_flags
+    = AT_EMPTY_PATH | AT_NO_AUTOMOUNT | AT_SYMLINK_NOFOLLOW | clear_flags;
+
+  if (__glibc_unlikely ((flags & ~supported_flags) != 0))
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  struct stat64 st;
+  int ret = __fstatat64 (fd, path, &st, flags & ~clear_flags);
+  if (ret != 0)
+    return ret;
+
+  /* The interface is defined in such a way that unused (padding)
+     fields have to be cleared.  STATX_BASIC_STATS corresponds to the
+     data which is available via fstatat64.  */
+  *buf = (struct statx)
+    {
+      .stx_mask = STATX_BASIC_STATS,
+      .stx_blksize = st.st_blksize,
+      .stx_nlink = st.st_nlink,
+      .stx_uid = st.st_uid,
+      .stx_gid = st.st_gid,
+      .stx_mode = st.st_mode,
+      .stx_ino = st.st_ino,
+      .stx_size = st.st_size,
+      .stx_blocks = st.st_blocks,
+      .stx_atime = statx_convert_timestamp (st.st_atim),
+      .stx_ctime = statx_convert_timestamp (st.st_ctim),
+      .stx_mtime = statx_convert_timestamp (st.st_mtim),
+      .stx_rdev_major = major (st.st_rdev),
+      .stx_rdev_minor = minor (st.st_rdev),
+      .stx_dev_major = major (st.st_dev),
+      .stx_dev_minor = minor (st.st_dev),
+    };
+
+  return 0;
+}
index 90c403cfd65119a46a8f3be556effdf45f78babd..762c8538baad367c5e1917d98173166d2d8ed251 100644 (file)
@@ -442,6 +442,10 @@ 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
 /* Inlined versions of the real stat and mknod functions.  */
 
diff --git a/io/tst-statx.c b/io/tst-statx.c
new file mode 100644 (file)
index 0000000..61bf31d
--- /dev/null
@@ -0,0 +1,157 @@
+/* Basic test of statx system call.
+   Copyright (C) 2018 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <support/check.h>
+#include <support/support.h>
+#include <support/temp_file.h>
+#include <support/xunistd.h>
+#include <sys/stat.h>
+#include <sys/syscall.h>
+#include <sys/sysmacros.h>
+#include <unistd.h>
+
+/* Ensure that the types have the kernel-expected layout.  */
+_Static_assert (sizeof (struct statx_timestamp) == 16, "statx_timestamp size");
+_Static_assert (sizeof (struct statx) == 256, "statx size");
+_Static_assert (offsetof (struct statx, stx_nlink) == 16, "statx nlink");
+_Static_assert (offsetof (struct statx, stx_ino) == 32, "statx ino");
+_Static_assert (offsetof (struct statx, stx_atime) == 64, "statx atime");
+_Static_assert (offsetof (struct statx, stx_rdev_major) == 128, "statx rdev");
+_Static_assert (offsetof (struct statx, __statx_pad2) == 144, "statx pad2");
+
+#include "statx_generic.c"
+
+typedef int (*statx_function) (int, const char *, int, unsigned int,
+                               struct statx *);
+
+/* Return true if we have a real implementation of statx.  */
+static bool
+kernel_supports_statx (void)
+{
+#ifdef __NR_statx
+  struct statx buf;
+  return syscall (__NR_statx, 0, "", AT_EMPTY_PATH, 0, &buf) == 0
+    || errno != ENOSYS;
+#else
+  return false;
+#endif
+}
+
+/* Tests which apply to both implementations.  */
+static void
+both_implementations_tests (statx_function impl, const char *path, int fd)
+{
+  uint64_t ino;
+  {
+    struct statx buf = { 0, };
+    TEST_COMPARE (statx (fd, "", AT_EMPTY_PATH, STATX_BASIC_STATS, &buf), 0);
+    TEST_COMPARE (buf.stx_size, 3);
+    ino = buf.stx_ino;
+  }
+  {
+    struct statx buf = { 0, };
+    TEST_COMPARE (statx (AT_FDCWD, path, 0, STATX_BASIC_STATS, &buf), 0);
+    TEST_COMPARE (buf.stx_size, 3);
+    TEST_COMPARE (buf.stx_ino, ino);
+  }
+  {
+    struct statx stx = { 0, };
+    TEST_COMPARE (statx (fd, "", AT_EMPTY_PATH, STATX_BASIC_STATS, &stx), 0);
+    struct stat64 st;
+    xfstat (fd, &st);
+    TEST_COMPARE (stx.stx_mode, st.st_mode);
+    TEST_COMPARE (stx.stx_dev_major, major (st.st_dev));
+    TEST_COMPARE (stx.stx_dev_minor, minor (st.st_dev));
+  }
+  {
+    struct statx stx = { 0, };
+    TEST_COMPARE (statx (AT_FDCWD, "/dev/null", 0, STATX_BASIC_STATS, &stx),
+                  0);
+    struct stat64 st;
+    xstat ("/dev/null", &st);
+    TEST_COMPARE (stx.stx_mode, st.st_mode);
+    TEST_COMPARE (stx.stx_dev_major, major (st.st_dev));
+    TEST_COMPARE (stx.stx_dev_minor, minor (st.st_dev));
+    TEST_COMPARE (stx.stx_rdev_major, major (st.st_rdev));
+    TEST_COMPARE (stx.stx_rdev_minor, minor (st.st_rdev));
+  }
+}
+
+/* Tests which apply only to the non-kernel (generic)
+   implementation.  */
+static void
+non_kernel_tests (statx_function impl, int fd)
+{
+  /* The non-kernel implementation must always fail for explicit sync
+     flags.  */
+  struct statx buf;
+  errno = 0;
+  TEST_COMPARE (impl (fd, "", AT_EMPTY_PATH | AT_STATX_FORCE_SYNC,
+                      STATX_BASIC_STATS, &buf), -1);
+  TEST_COMPARE (errno, EINVAL);
+  errno = 0;
+  TEST_COMPARE (impl (fd, "", AT_EMPTY_PATH | AT_STATX_DONT_SYNC,
+                      STATX_BASIC_STATS, &buf), -1);
+  TEST_COMPARE (errno, EINVAL);
+}
+
+static int
+do_test (void)
+{
+  char *path;
+  int fd = create_temp_file ("tst-statx-", &path);
+  TEST_VERIFY_EXIT (fd >= 0);
+  support_write_file_string (path, "abc");
+
+  both_implementations_tests (&statx, path, fd);
+  both_implementations_tests (&statx_generic, path, fd);
+
+  if (kernel_supports_statx ())
+    {
+      puts ("info: kernel supports statx");
+      struct statx buf;
+      buf.stx_size = 0;
+      TEST_COMPARE (statx (fd, "", AT_EMPTY_PATH | AT_STATX_FORCE_SYNC,
+                           STATX_BASIC_STATS, &buf),
+                    0);
+      TEST_COMPARE (buf.stx_size, 3);
+      buf.stx_size = 0;
+      TEST_COMPARE (statx (fd, "", AT_EMPTY_PATH | AT_STATX_DONT_SYNC,
+                           STATX_BASIC_STATS, &buf),
+                    0);
+      TEST_COMPARE (buf.stx_size, 3);
+    }
+  else
+    {
+      puts ("info: kernel does not support statx");
+      non_kernel_tests (&statx, fd);
+    }
+  non_kernel_tests (&statx_generic, fd);
+
+  xclose (fd);
+  free (path);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
index db2f1041de077a1d325c570c993ed2fb75228775..ccda36cf84339ed728803cc4154259a40490108c 100644 (file)
@@ -3545,6 +3545,7 @@ The @code{mkdtemp} function comes from OpenBSD.
 @c fchownat
 @c futimesat
 @c fstatat (there's a commented-out safety assessment for this one)
+@c statx
 @c mkdirat
 @c mkfifoat
 @c name_to_handle_at
index a9089d90646f165b661c73e438502a61f0f48ea4..9a3aac7a92f77ec90f65cb1d5f19c4325b635541 100644 (file)
@@ -2035,6 +2035,7 @@ GLIBC_2.27 wcstof64x F
 GLIBC_2.27 wcstof64x_l F
 GLIBC_2.28 fcntl64 F
 GLIBC_2.28 renameat2 F
+GLIBC_2.28 statx F
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
 GLIBC_2.3 __ctype_toupper_loc F
index 7a272a19bb5d819554d937fc4436e2d31555e313..e92cd0ab9e1c33a6aa1114d441b3f3b82d8e83c9 100644 (file)
@@ -2133,3 +2133,4 @@ GLIBC_2.27 wcstof64x F
 GLIBC_2.27 wcstof64x_l F
 GLIBC_2.28 fcntl64 F
 GLIBC_2.28 renameat2 F
+GLIBC_2.28 statx F
index 5781cffd5ac4d782082f6696b2ba715f9e71a37a..f63be39d1bb6de4886a0403e08c98ebfba766d9d 100644 (file)
@@ -45,4 +45,9 @@
 # undef __ASSUME_EXECVEAT
 #endif
 
+/* Support for statx was added in kernel 4.13.  */
+#if __LINUX_KERNEL_VERSION < 0x040D00
+# undef __ASSUME_STATX
+#endif
+
 #endif /* _KERNEL_FEATURES_H */
index 23fec55d977dd4bd5e12dcfba58a1b5c415b5a75..ba9473940a1279667bbb1f329850296a2f5e0a99 100644 (file)
@@ -2028,6 +2028,7 @@ GLIBC_2.27 wcstof64x F
 GLIBC_2.27 wcstof64x_l F
 GLIBC_2.28 fcntl64 F
 GLIBC_2.28 renameat2 F
+GLIBC_2.28 statx F
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
 GLIBC_2.3 __ctype_toupper_loc F
index b2031608896297cb90ded5ad6a11160b7f3b591c..dc71f1bb7f6f409976a2ae65b3ed14a6188be0bb 100644 (file)
@@ -118,6 +118,7 @@ GLIBC_2.27 wcstof64_l F
 GLIBC_2.28 fcntl F
 GLIBC_2.28 fcntl64 F
 GLIBC_2.28 renameat2 F
+GLIBC_2.28 statx F
 GLIBC_2.4 _Exit F
 GLIBC_2.4 _IO_2_1_stderr_ D 0xa0
 GLIBC_2.4 _IO_2_1_stdin_ D 0xa0
index 64809ca4032b1eabc768095f091bb1a046262127..6a340907334046d23fb28ba7359f6fd8ea8d6b2d 100644 (file)
@@ -1875,6 +1875,7 @@ GLIBC_2.27 wcstof64_l F
 GLIBC_2.28 fcntl F
 GLIBC_2.28 fcntl64 F
 GLIBC_2.28 renameat2 F
+GLIBC_2.28 statx F
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
 GLIBC_2.3 __ctype_toupper_loc F
index 4a87f62ad97e6f1e3564e139cd6fd8adfe9d96ba..30f8ddc682a5d4ad3dfa89728452b7c44fac122a 100644 (file)
@@ -2040,6 +2040,7 @@ GLIBC_2.27 wcstof64x_l F
 GLIBC_2.28 fcntl F
 GLIBC_2.28 fcntl64 F
 GLIBC_2.28 renameat2 F
+GLIBC_2.28 statx F
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
 GLIBC_2.3 __ctype_toupper_loc F
index 04cdf43511b5c4b6cdc22249e8d747be4ad84563..4fde73fba1fd964a6304e98d9c82c29f55a2b862 100644 (file)
@@ -26,6 +26,9 @@
 #define __ASSUME_SEND_SYSCALL          1
 #define __ASSUME_ACCEPT4_SYSCALL       1
 
+/* No statx system call on ia64 yet.  */
+#undef __ASSUME_STATX
+
 #undef __ASSUME_CLONE_DEFAULT
 #define __ASSUME_CLONE2
 
index 6bdd0d0443b86ea1766dba5f9604a37ff08ad112..8f7aaff3884642e5a7ec0f3d260cb517635979f1 100644 (file)
@@ -1909,6 +1909,7 @@ GLIBC_2.27 wcstof64x F
 GLIBC_2.27 wcstof64x_l F
 GLIBC_2.28 fcntl64 F
 GLIBC_2.28 renameat2 F
+GLIBC_2.28 statx F
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
 GLIBC_2.3 __ctype_toupper_loc F
index 86fc66574b6851d398708973bae5b9472a9d8de0..5543d92d7e32e501c929b15ea53299c765a4b9e0 100644 (file)
 # define __ASSUME_COPY_FILE_RANGE 1
 #endif
 
+/* Support for statx was added in kernel 4.11.  */
+#if __LINUX_KERNEL_VERSION >= 0x040B00
+# define __ASSUME_STATX 1
+#endif
+
 /* Support for clone call used on fork.  The signature varies across the
    architectures with current 4 different variants:
 
index 3226f916eb99e9f00dd7f095926a3310af0155a2..1b057ec6a6317545f75a8d5cfb6973a05accbf3b 100644 (file)
@@ -119,6 +119,7 @@ GLIBC_2.27 wcstof64_l F
 GLIBC_2.28 fcntl F
 GLIBC_2.28 fcntl64 F
 GLIBC_2.28 renameat2 F
+GLIBC_2.28 statx F
 GLIBC_2.4 _Exit F
 GLIBC_2.4 _IO_2_1_stderr_ D 0x98
 GLIBC_2.4 _IO_2_1_stdin_ D 0x98
index b1074eeed133deb0385edb5c8e96bd4dc7109b5b..70232f2d16f69c425c224d2ba27e82aa7ee01eaa 100644 (file)
@@ -1984,6 +1984,7 @@ GLIBC_2.27 wcstof64_l F
 GLIBC_2.28 fcntl F
 GLIBC_2.28 fcntl64 F
 GLIBC_2.28 renameat2 F
+GLIBC_2.28 statx F
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
 GLIBC_2.3 __ctype_toupper_loc F
index 7db3d05636f3c1c4d63ed8c8c9d603bf996fb1b1..e8e2ac6a873126ac7bac1fe77db69e6edf37bc7c 100644 (file)
 # undef __ASSUME_COPY_FILE_RANGE
 #endif
 
+/* Support for statx was added in kernel 4.12.  */
+#if __LINUX_KERNEL_VERSION < 0X040C00
+# undef __ASSUME_STATX
+#endif
+
 #undef __ASSUME_CLONE_DEFAULT
 #define __ASSUME_CLONE_BACKWARDS3
index b52fc7d6f796111bc7acb7a44406deab222577bb..6f295789c6adbf71c9299848a6a5e599ceae8c52 100644 (file)
@@ -2125,3 +2125,4 @@ GLIBC_2.27 wcstof64_l F
 GLIBC_2.28 fcntl F
 GLIBC_2.28 fcntl64 F
 GLIBC_2.28 renameat2 F
+GLIBC_2.28 statx F
index 718c74262ad1883e3263ccaed0857bf8620369d4..88f79b7d9d3149eea9d1969c2652fa0b93bb1039 100644 (file)
@@ -1962,6 +1962,7 @@ GLIBC_2.27 wcstof64_l F
 GLIBC_2.28 fcntl F
 GLIBC_2.28 fcntl64 F
 GLIBC_2.28 renameat2 F
+GLIBC_2.28 statx F
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
 GLIBC_2.3 __ctype_toupper_loc F
index 9b218a9435449d435d22b414dbcd220efeed85e5..563b3101b7beca383214b469f317bd58190b0917 100644 (file)
@@ -1960,6 +1960,7 @@ GLIBC_2.27 wcstof64_l F
 GLIBC_2.28 fcntl F
 GLIBC_2.28 fcntl64 F
 GLIBC_2.28 renameat2 F
+GLIBC_2.28 statx F
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
 GLIBC_2.3 __ctype_toupper_loc F
index 5a90ab83e7b449a6355794265a0010565c02964b..5cdf8c2232e34c59436f01efe0dff896999d1607 100644 (file)
@@ -1968,6 +1968,7 @@ GLIBC_2.27 wcstof64x_l F
 GLIBC_2.28 fcntl F
 GLIBC_2.28 fcntl64 F
 GLIBC_2.28 renameat2 F
+GLIBC_2.28 statx F
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
 GLIBC_2.3 __ctype_toupper_loc F
index 3005fc9500f8c7c661a6b4bab5edf363f17ef91d..ce27832705f00a9c7da2b0b4e58a9cc36e4e9d5d 100644 (file)
@@ -1963,6 +1963,7 @@ GLIBC_2.27 wcstof64x F
 GLIBC_2.27 wcstof64x_l F
 GLIBC_2.28 fcntl64 F
 GLIBC_2.28 renameat2 F
+GLIBC_2.28 statx F
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
 GLIBC_2.3 __ctype_toupper_loc F
index a87fbbeb6be02f7772c549ac019857ab87d45054..78cc9cfff3b160de52989718c81557d2180115ae 100644 (file)
@@ -2166,3 +2166,4 @@ GLIBC_2.27 wcstof64_l F
 GLIBC_2.28 fcntl F
 GLIBC_2.28 fcntl64 F
 GLIBC_2.28 renameat2 F
+GLIBC_2.28 statx F
index d56f776a52bce613c2632defe475288d99b11b7e..9ae40a9470c6fd1fe2f7cd60e2ae587e787bc42b 100644 (file)
@@ -1988,6 +1988,7 @@ GLIBC_2.27 wcstof64_l F
 GLIBC_2.28 fcntl F
 GLIBC_2.28 fcntl64 F
 GLIBC_2.28 renameat2 F
+GLIBC_2.28 statx F
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
 GLIBC_2.3 __ctype_toupper_loc F
index 2b5337aab631166688c7f79be78d6059790b69d0..863f85b430157accfdcfe225d417b12e3186f8fc 100644 (file)
@@ -1992,6 +1992,7 @@ GLIBC_2.27 wcstof64_l F
 GLIBC_2.28 fcntl F
 GLIBC_2.28 fcntl64 F
 GLIBC_2.28 renameat2 F
+GLIBC_2.28 statx F
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
 GLIBC_2.3 __ctype_toupper_loc F
index d0dfde389718e2e386b43d7829a081b2e6f2e6ae..4cc5a4473bdb59f142ae253435f5160f1ed8bbd9 100644 (file)
@@ -2223,3 +2223,4 @@ GLIBC_2.27 wcstof64x F
 GLIBC_2.27 wcstof64x_l F
 GLIBC_2.28 fcntl64 F
 GLIBC_2.28 renameat2 F
+GLIBC_2.28 statx F
index d505ae0e7dd48f11744de682e31f97858138e47d..a3cd3229c96cb1a70f486821fad0149d3b5bddeb 100644 (file)
@@ -118,6 +118,7 @@ GLIBC_2.27 wcstof64 F
 GLIBC_2.27 wcstof64_l F
 GLIBC_2.28 fcntl64 F
 GLIBC_2.28 renameat2 F
+GLIBC_2.28 statx F
 GLIBC_2.3 _Exit F
 GLIBC_2.3 _IO_2_1_stderr_ D 0xe0
 GLIBC_2.3 _IO_2_1_stdin_ D 0xe0
index 33f751abc0bbd7ab15bd210bf741e7071ae1b8d6..f094b0f3cd6ce8efd8bdc7efab6e8cad4064c96d 100644 (file)
@@ -2095,3 +2095,4 @@ GLIBC_2.27 xprt_register F
 GLIBC_2.27 xprt_unregister F
 GLIBC_2.28 fcntl64 F
 GLIBC_2.28 renameat2 F
+GLIBC_2.28 statx F
index c4ec93ff43fc5948ff9f19422c3010e31189c343..26a95e6fda73e5d6f2c0aa83afbfa885a0c20ad2 100644 (file)
@@ -1997,6 +1997,7 @@ GLIBC_2.27 wcstof64x_l F
 GLIBC_2.28 fcntl F
 GLIBC_2.28 fcntl64 F
 GLIBC_2.28 renameat2 F
+GLIBC_2.28 statx F
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
 GLIBC_2.3 __ctype_toupper_loc F
index 2a6a0abde85c5e422165768d9cde1ce80f187f87..650385b607823f063c2f16b16cd907a88f727366 100644 (file)
@@ -1902,6 +1902,7 @@ GLIBC_2.27 wcstof64x F
 GLIBC_2.27 wcstof64x_l F
 GLIBC_2.28 fcntl64 F
 GLIBC_2.28 renameat2 F
+GLIBC_2.28 statx F
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
 GLIBC_2.3 __ctype_toupper_loc F
index 8de0d1711a30c1756f572819d92ff912415c4057..cd349ccec1f26ecb24bb9085fca270a516156fe8 100644 (file)
@@ -1879,6 +1879,7 @@ GLIBC_2.27 wcstof64_l F
 GLIBC_2.28 fcntl F
 GLIBC_2.28 fcntl64 F
 GLIBC_2.28 renameat2 F
+GLIBC_2.28 statx F
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
 GLIBC_2.3 __ctype_toupper_loc F
index 9858460c9fffd2a94c7deaf2b3219d2f298d07ac..e0438402b3e3d1b8f68317c540de4aa87ead1c64 100644 (file)
@@ -1991,6 +1991,7 @@ GLIBC_2.27 wcstof64x_l F
 GLIBC_2.28 fcntl F
 GLIBC_2.28 fcntl64 F
 GLIBC_2.28 renameat2 F
+GLIBC_2.28 statx F
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
 GLIBC_2.3 __ctype_toupper_loc F
index a22b8fb7cafcb1a0f1cf963fd9af51768d8e6928..9f036ddf4b7079905d9e279964bd8cc841eada34 100644 (file)
@@ -1932,6 +1932,7 @@ GLIBC_2.27 wcstof64x F
 GLIBC_2.27 wcstof64x_l F
 GLIBC_2.28 fcntl64 F
 GLIBC_2.28 renameat2 F
+GLIBC_2.28 statx F
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
 GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/statx.c b/sysdeps/unix/sysv/linux/statx.c
new file mode 100644 (file)
index 0000000..76761d6
--- /dev/null
@@ -0,0 +1,41 @@
+/* Linux statx implementation.
+   Copyright (C) 2018 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <sys/stat.h>
+
+#include "statx_generic.c"
+
+int
+statx (int fd, const char *path, int flags,
+       unsigned int mask, struct statx *buf)
+{
+#ifdef __NR_statx
+  int ret = INLINE_SYSCALL_CALL (statx, fd, path, flags, mask, buf);
+# ifdef __ASSUME_STATX
+  return ret;
+# else
+  if (ret == 0 || errno != ENOSYS)
+    /* Preserve non-error/non-ENOSYS return values.  */
+    return ret;
+# endif
+#endif
+#ifndef __ASSUME_STATX
+  return statx_generic (fd, path, flags, mask, buf);
+#endif
+}
index d5d71cccbac87e2db95eb790347ac69e3dc99321..2df20ebafd01c9348072a447fc584828df2c1b81 100644 (file)
@@ -1890,6 +1890,7 @@ GLIBC_2.27 wcstof64x F
 GLIBC_2.27 wcstof64x_l F
 GLIBC_2.28 fcntl64 F
 GLIBC_2.28 renameat2 F
+GLIBC_2.28 statx F
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
 GLIBC_2.3 __ctype_toupper_loc F
index e6ad42440e1ed2d7e3ce2734577c899afd9502e0..83e15f84fc29ac1668efeef7a49b653ab351345e 100644 (file)
@@ -2141,3 +2141,4 @@ GLIBC_2.27 wcstof64x F
 GLIBC_2.27 wcstof64x_l F
 GLIBC_2.28 fcntl64 F
 GLIBC_2.28 renameat2 F
+GLIBC_2.28 statx F