From patchwork Sat Jun 30 22:41:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 937489 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-93884-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="fC9HaW0Q"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41J7ly3Bw1z9s1b for ; Sun, 1 Jul 2018 08:41:18 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:to:subject:mime-version:content-type :content-transfer-encoding:message-id:from; q=dns; s=default; b= f40dbIZnnFPnvy2B4RC9jnxykxigXEuARSq5HDiJxJZUXnWGtTkI7cFgw3AKyywT PoWSu/+FhQZVJAwb+AGgtUokSDRZirtYCo+rEhw676KlUaw8FS5Mk+nF1IpKyKnU 74V1nR5VRol/09KDXEw4ptp+7JCGUkcknn26B+dQX1Y= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:to:subject:mime-version:content-type :content-transfer-encoding:message-id:from; s=default; bh=5rZwLh PxvDJsuAnt1PlWMkSBC80=; b=fC9HaW0Qc6/6IQuvok9m6Cl6SgEatRYWerkr6m UHE4oWdjgagYRWP2ogoRyqL3tdcB8ypNFcUyp9VZ4KZqRnvcZGHUKMbnvztzXiWf s3IIDNG4qSRoZlWLU70OK9dL8555VCtwLfdLFZtljpaRUfYECk/HLBAObr3w7kSg mQdw0= Received: (qmail 8651 invoked by alias); 30 Jun 2018 22:41:11 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 8638 invoked by uid 89); 30 Jun 2018 22:41:10 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Date: Sun, 01 Jul 2018 00:41:03 +0200 To: libc-alpha@sourceware.org Subject: [PATCH] Add the statx function User-Agent: Heirloom mailx 12.5 7/5/10 MIME-Version: 1.0 Message-Id: <20180630224103.4501543994575@oldenburg.str.redhat.com> From: fweimer@redhat.com (Florian Weimer) The STATX_ALL and STATX__RESERVED are deliberately not exposed because they could change with future kernel versions. 2018-06-30 Florian Weimer * 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. diff --git a/NEWS b/NEWS index a27dd371a3..af454020f6 100644 --- a/NEWS +++ b/NEWS @@ -35,6 +35,8 @@ Major new features: * Building and running on GNU/Hurd systems now works without out-of-tree patches. +* The statx function has been added. + * 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 index 0000000000..8ec78a4f37 --- /dev/null +++ b/include/bits/statx.h @@ -0,0 +1 @@ +#include diff --git a/io/Makefile b/io/Makefile index 4a0d8fea09..f5b1b61d4e 100644 --- a/io/Makefile +++ b/io/Makefile @@ -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 diff --git a/io/Versions b/io/Versions index 98037fbbfc..f7e5dbe49e 100644 --- a/io/Versions +++ b/io/Versions @@ -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 index 0000000000..49f6a574b1 --- /dev/null +++ b/io/bits/statx.h @@ -0,0 +1,90 @@ +/* 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 + . */ + +/* This interface is based on in Linux. */ + +#ifndef _SYS_STAT_H +# error Never include directly, include 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_BTIME 0x0800U + +#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 *__path, int __flags, + unsigned int __mask, struct statx *__buf) + __THROW __nonnull ((2, 5)); + +__END_DECLS diff --git a/io/fcntl.h b/io/fcntl.h index 3afc62011a..6b0e9fa1fa 100644 --- a/io/fcntl.h +++ b/io/fcntl.h @@ -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 index 0000000000..0b90cd00d1 --- /dev/null +++ b/io/statx.c @@ -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 + . */ + +#include +#include + +#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 index 0000000000..252862fc26 --- /dev/null +++ b/io/statx_generic.c @@ -0,0 +1,80 @@ +/* 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 + . */ + +#include +#include +#include +#include + +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; + + *buf = (struct statx) + { + /* We copy everything from fstat64, which corresponds the basic + fstat64. */ + .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 = __gnu_dev_major (st.st_rdev), + .stx_rdev_minor = __gnu_dev_minor (st.st_rdev), + .stx_dev_major = __gnu_dev_minor (st.st_dev), + .stx_dev_minor = __gnu_dev_minor (st.st_dev), + }; + + return 0; +} diff --git a/io/sys/stat.h b/io/sys/stat.h index 90c403cfd6..762c8538ba 100644 --- a/io/sys/stat.h +++ b/io/sys/stat.h @@ -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 +#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 index 0000000000..444f3f930f --- /dev/null +++ b/io/tst-statx.c @@ -0,0 +1,135 @@ +/* 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 + . */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* 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); + } +} + +/* 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 diff --git a/manual/filesys.texi b/manual/filesys.texi index cc70a6b7ee..25fc2beedc 100644 --- a/manual/filesys.texi +++ b/manual/filesys.texi @@ -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 diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist index 3d46de795d..0617498d84 100644 --- a/sysdeps/mach/hurd/i386/libc.abilist +++ b/sysdeps/mach/hurd/i386/libc.abilist @@ -2035,6 +2035,7 @@ GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F GLIBC_2.28 fcntl F GLIBC_2.28 fcntl64 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/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist index 884d0dfa95..312b02d2f2 100644 --- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist +++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist @@ -2132,3 +2132,4 @@ GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F GLIBC_2.28 fcntl64 F +GLIBC_2.28 statx F diff --git a/sysdeps/unix/sysv/linux/alpha/kernel-features.h b/sysdeps/unix/sysv/linux/alpha/kernel-features.h index c2d4a9f55b..689b32dabe 100644 --- a/sysdeps/unix/sysv/linux/alpha/kernel-features.h +++ b/sysdeps/unix/sysv/linux/alpha/kernel-features.h @@ -40,4 +40,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 */ diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist index 28d54b9794..530f74d587 100644 --- a/sysdeps/unix/sysv/linux/alpha/libc.abilist +++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist @@ -2027,6 +2027,7 @@ GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F GLIBC_2.28 fcntl64 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/arm/libc.abilist b/sysdeps/unix/sysv/linux/arm/libc.abilist index dfde3bd725..6cd40afb9d 100644 --- a/sysdeps/unix/sysv/linux/arm/libc.abilist +++ b/sysdeps/unix/sysv/linux/arm/libc.abilist @@ -117,6 +117,7 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.28 fcntl F GLIBC_2.28 fcntl64 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 diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist index 06b00f730a..90079eade1 100644 --- a/sysdeps/unix/sysv/linux/hppa/libc.abilist +++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist @@ -1874,6 +1874,7 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.28 fcntl F GLIBC_2.28 fcntl64 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/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist index 1c1cc00d40..b23cfa1636 100644 --- a/sysdeps/unix/sysv/linux/i386/libc.abilist +++ b/sysdeps/unix/sysv/linux/i386/libc.abilist @@ -2039,6 +2039,7 @@ GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F GLIBC_2.28 fcntl F GLIBC_2.28 fcntl64 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/ia64/kernel-features.h b/sysdeps/unix/sysv/linux/ia64/kernel-features.h index 04cdf43511..4fde73fba1 100644 --- a/sysdeps/unix/sysv/linux/ia64/kernel-features.h +++ b/sysdeps/unix/sysv/linux/ia64/kernel-features.h @@ -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 diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist index f6e17a005f..35e3cce160 100644 --- a/sysdeps/unix/sysv/linux/ia64/libc.abilist +++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist @@ -1908,6 +1908,7 @@ GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F GLIBC_2.28 fcntl64 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/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h index b90ea30195..1f96955260 100644 --- a/sysdeps/unix/sysv/linux/kernel-features.h +++ b/sysdeps/unix/sysv/linux/kernel-features.h @@ -110,6 +110,11 @@ # 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: diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist index ee054a618d..e9cc8a8a26 100644 --- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist @@ -118,6 +118,7 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.28 fcntl F GLIBC_2.28 fcntl64 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 diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist index 227a0581cb..35141aed15 100644 --- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist @@ -1983,6 +1983,7 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.28 fcntl F GLIBC_2.28 fcntl64 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/microblaze/kernel-features.h b/sysdeps/unix/sysv/linux/microblaze/kernel-features.h index b13b863f06..31c0db66e9 100644 --- a/sysdeps/unix/sysv/linux/microblaze/kernel-features.h +++ b/sysdeps/unix/sysv/linux/microblaze/kernel-features.h @@ -58,5 +58,10 @@ # 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 diff --git a/sysdeps/unix/sysv/linux/microblaze/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/libc.abilist index 18781b3017..4c9b68760e 100644 --- a/sysdeps/unix/sysv/linux/microblaze/libc.abilist +++ b/sysdeps/unix/sysv/linux/microblaze/libc.abilist @@ -2124,3 +2124,4 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.28 fcntl F GLIBC_2.28 fcntl64 F +GLIBC_2.28 statx F diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist index 2d86989cf2..90e71bb460 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist @@ -1961,6 +1961,7 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.28 fcntl F GLIBC_2.28 fcntl64 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/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist index b8b113e1a5..76ef5d1555 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist @@ -1959,6 +1959,7 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.28 fcntl F GLIBC_2.28 fcntl64 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/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist index 6a3cd13e2d..08e25a617d 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist @@ -1967,6 +1967,7 @@ GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F GLIBC_2.28 fcntl F GLIBC_2.28 fcntl64 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/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist index 596ec05379..72ade0f12c 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist @@ -1962,6 +1962,7 @@ GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F GLIBC_2.28 fcntl64 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/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist index 8da18eed57..565196f2d3 100644 --- a/sysdeps/unix/sysv/linux/nios2/libc.abilist +++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist @@ -2165,3 +2165,4 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.28 fcntl F GLIBC_2.28 fcntl64 F +GLIBC_2.28 statx F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist index 555751eb12..cef7d905da 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist @@ -1987,6 +1987,7 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.28 fcntl F GLIBC_2.28 fcntl64 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/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist index 80324e41aa..dfc1110154 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist @@ -1991,6 +1991,7 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.28 fcntl F GLIBC_2.28 fcntl64 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/powerpc/powerpc64/libc-le.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist index 97b1d354af..5a0c414649 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist @@ -2222,3 +2222,4 @@ GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F GLIBC_2.28 fcntl64 F +GLIBC_2.28 statx F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist index 15be314921..613edb1585 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist @@ -117,6 +117,7 @@ GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.28 fcntl64 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 diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist index 436b992251..2f52095f81 100644 --- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist +++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist @@ -2094,3 +2094,4 @@ GLIBC_2.27 xencrypt F GLIBC_2.27 xprt_register F GLIBC_2.27 xprt_unregister F GLIBC_2.28 fcntl64 F +GLIBC_2.28 statx F diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist index f66715f0c9..be692a002e 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist @@ -1996,6 +1996,7 @@ GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F GLIBC_2.28 fcntl F GLIBC_2.28 fcntl64 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/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist index bd6242861b..51c42ee68f 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist @@ -1901,6 +1901,7 @@ GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F GLIBC_2.28 fcntl64 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/sh/libc.abilist b/sysdeps/unix/sysv/linux/sh/libc.abilist index f2f070fbce..ad597429cd 100644 --- a/sysdeps/unix/sysv/linux/sh/libc.abilist +++ b/sysdeps/unix/sysv/linux/sh/libc.abilist @@ -1878,6 +1878,7 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.28 fcntl F GLIBC_2.28 fcntl64 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/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist index 265087f6a8..f04e3c3f75 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist @@ -1990,6 +1990,7 @@ GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F GLIBC_2.28 fcntl F GLIBC_2.28 fcntl64 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/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist index 16a69812cb..006d7b4f01 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist @@ -1931,6 +1931,7 @@ GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F GLIBC_2.28 fcntl64 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 index 0000000000..76761d6ef2 --- /dev/null +++ b/sysdeps/unix/sysv/linux/statx.c @@ -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 + . */ + +#include +#include + +#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 +} diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist index fa8c198d13..a3e21ec14d 100644 --- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist +++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist @@ -1889,6 +1889,7 @@ GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F GLIBC_2.28 fcntl64 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/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist index 2536971682..a0280783c2 100644 --- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist +++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist @@ -2140,3 +2140,4 @@ GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F GLIBC_2.28 fcntl64 F +GLIBC_2.28 statx F