From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 85729 invoked by alias); 7 Sep 2017 22:44:23 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 85630 invoked by uid 89); 7 Sep 2017 22:44:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.6 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy= X-HELO: smtp6-g21.free.fr From: "Albert ARIBAUD (3ADEV)" To: libc-alpha@sourceware.org Cc: "Albert ARIBAUD (3ADEV)" Subject: [RFC PATCH 27/52] Y2038: add function __fstatat64_t64 (and __fxstatat_t64) Date: Thu, 07 Sep 2017 22:44:00 -0000 Message-Id: <20170907224219.12483-28-albert.aribaud@3adev.fr> In-Reply-To: <20170907224219.12483-27-albert.aribaud@3adev.fr> References: <20170907224219.12483-1-albert.aribaud@3adev.fr> <20170907224219.12483-2-albert.aribaud@3adev.fr> <20170907224219.12483-3-albert.aribaud@3adev.fr> <20170907224219.12483-4-albert.aribaud@3adev.fr> <20170907224219.12483-5-albert.aribaud@3adev.fr> <20170907224219.12483-6-albert.aribaud@3adev.fr> <20170907224219.12483-7-albert.aribaud@3adev.fr> <20170907224219.12483-8-albert.aribaud@3adev.fr> <20170907224219.12483-9-albert.aribaud@3adev.fr> <20170907224219.12483-10-albert.aribaud@3adev.fr> <20170907224219.12483-11-albert.aribaud@3adev.fr> <20170907224219.12483-12-albert.aribaud@3adev.fr> <20170907224219.12483-13-albert.aribaud@3adev.fr> <20170907224219.12483-14-albert.aribaud@3adev.fr> <20170907224219.12483-15-albert.aribaud@3adev.fr> <20170907224219.12483-16-albert.aribaud@3adev.fr> <20170907224219.12483-17-albert.aribaud@3adev.fr> <20170907224219.12483-18-albert.aribaud@3adev.fr> <20170907224219.12483-19-albert.aribaud@3adev.fr> <20170907224219.12483-20-albert.aribaud@3adev.fr> <20170907224219.12483-21-albert.aribaud@3adev.fr> <20170907224219.12483-22-albert.aribaud@3adev.fr> <20170907224219.12483-23-albert.aribaud@3adev.fr> <20170907224219.12483-24-albert.aribaud@3adev.fr> <20170907224219.12483-25-albert.aribaud@3adev.fr> <20170907224219.12483-26-albert.aribaud@3adev.fr> <20170907224219.12483-27-albert.aribaud@3adev.fr> X-SW-Source: 2017-09/txt/msg00343.txt.bz2 There is no Y2038-proof linux struct stat for now, so these implementations just use the existing syscalls and convert from kernel 32-bit-time struct stat64 to GLIBC Y2038-ready struct __stat64_t64. Signed-off-by: Albert ARIBAUD (3ADEV) --- include/sys/stat.h | 4 +++ io/Versions | 1 + io/fstatat64.c | 7 +++++ sysdeps/unix/sysv/linux/fxstatat64.c | 54 ++++++++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+) diff --git a/include/sys/stat.h b/include/sys/stat.h index 9b0782a9a4..71f6d63e3e 100644 --- a/include/sys/stat.h +++ b/include/sys/stat.h @@ -43,6 +43,10 @@ extern int __xstat64_t64 (int __ver, const char *__filename, struct __stat64_t64 *__stat_buf); extern int __lxstat64_t64 (int __ver, const char *__filename, struct __stat64_t64 *__stat_buf); +extern int __fxstatat64_t64 (int __ver, int __fildes, + const char *__filename, + struct __stat64_t64 *__stat_buf, + int __flag); #if IS_IN (libc) || IS_IN (rtld) hidden_proto (__fxstat) hidden_proto (__fxstat64) diff --git a/io/Versions b/io/Versions index fcd1b71f80..33629a0d4e 100644 --- a/io/Versions +++ b/io/Versions @@ -133,5 +133,6 @@ libc { __fxstat64_t64; __xstat64_t64; __lxstat64_t64; + __fxstatat64_t64; } } diff --git a/io/fstatat64.c b/io/fstatat64.c index 13a9ebc870..4e13f072ff 100644 --- a/io/fstatat64.c +++ b/io/fstatat64.c @@ -50,3 +50,10 @@ fstatat64 (int fd, const char *file, struct stat64 *buf, int flag) { return __fxstatat64 (_STAT_VER, fd, file, buf, flag); } + +int +attribute_hidden +__fstatat64_t64 (int fd, const char *file, struct __stat64_t64 *buf, int flag) +{ + return __fxstatat64_t64 (_STAT_VER, fd, file, buf, flag); +} diff --git a/sysdeps/unix/sysv/linux/fxstatat64.c b/sysdeps/unix/sysv/linux/fxstatat64.c index ef1e132c11..070ed78861 100644 --- a/sysdeps/unix/sysv/linux/fxstatat64.c +++ b/sysdeps/unix/sysv/linux/fxstatat64.c @@ -26,6 +26,8 @@ #include #include +#include + /* Get information about the file NAME in BUF. */ int @@ -45,3 +47,55 @@ __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag) err)); } libc_hidden_def (__fxstatat64) + +/* 64-bit time version */ + +extern int __y2038_linux_support; + +int +__fxstatat64_t64 (int vers, int fd, const char *file, struct __stat64_t64 *buf, int flag) +{ + if (__glibc_unlikely (vers != _STAT_VER_LINUX)) + return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); + + int result; + struct stat64 st64; + INTERNAL_SYSCALL_DECL (err); + + if (__y2038_linux_support) + { + // TODO: use 64-bit syscalls when they become available + } + + result = INTERNAL_SYSCALL (fstatat64, err, 4, fd, file, &st64, flag); + if (!__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 1)) + { + buf->st_dev = st64.st_dev; + buf->__pad1 = st64.__pad1; + + 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->__pad2 = st64.__pad2; + 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; + + buf->st_ino = st64.st_ino; + + return 0; + } + else + return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (result, + err)); +} -- 2.11.0