From patchwork Thu Sep 7 22:41:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Albert ARIBAUD (3ADEV)" X-Patchwork-Id: 811222 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-84342-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="O1V4zlZo"; 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 3xpFvD2H9Fz9sDB for ; Fri, 8 Sep 2017 08:47:04 +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:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=jgXtzKWAYJj0THLNEhyPM6h5Qy+YU/B BsPhCW8cT/7EAmajOpQC2QLZV1u0/69AaAxXeXWVkerxpu6p1MpSXGXKNpy9Ra8O lH1jOa7GVf5FEw40ZzZe8AtHUM7mPi98TBnBfsI4xNZMVVWK6ie41/nqU8rNShJ2 YJ8MW5QnoNqo= 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:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=PYiOzzIpzhEhr/ioDKZgblze1nA=; b=O1V4z lZoQXAIw6d6vaH35pqCfv95nHoNin/h/CkBTe5JxGhgZ108gygvKtDNN1Ji/UD5a 9I+eRLMlpU60Nmeu7EIKdbiFlWchPZlXjXgVZTdcrZbRImLy8NS5YVA9XAWAFHAt 3RQkIxj5UfXOy2H8jGz5HsN+hBXGIOdrxvvi7M= Received: (qmail 82811 invoked by alias); 7 Sep 2017 22:44: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 82676 invoked by uid 89); 7 Sep 2017 22:44:10 -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=vers X-HELO: smtp6-g21.free.fr From: "Albert ARIBAUD (3ADEV)" To: libc-alpha@sourceware.org Cc: "Albert ARIBAUD (3ADEV)" Subject: [RFC PATCH 24/52] Y2038: add function __fstat64_t64 (and __fxstat64_t64) Date: Fri, 8 Sep 2017 00:41:51 +0200 Message-Id: <20170907224219.12483-25-albert.aribaud@3adev.fr> In-Reply-To: <20170907224219.12483-24-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> 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 | 2 ++ io/Versions | 7 ++++++ io/fstat64.c | 7 ++++++ sysdeps/unix/sysv/linux/fxstat64.c | 50 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+) diff --git a/include/sys/stat.h b/include/sys/stat.h index 300cf8bbc4..2961849e35 100644 --- a/include/sys/stat.h +++ b/include/sys/stat.h @@ -37,6 +37,8 @@ extern __mode_t __umask (__mode_t __mask); extern int __mkdir (const char *__path, __mode_t __mode); extern int __mknod (const char *__path, __mode_t __mode, __dev_t __dev); +extern int __fxstat64_t64 (int __ver, int __fildes, + struct __stat64_t64 *__stat_buf); #if IS_IN (libc) || IS_IN (rtld) hidden_proto (__fxstat) hidden_proto (__fxstat64) diff --git a/io/Versions b/io/Versions index 64316cd025..747ae5d9d6 100644 --- a/io/Versions +++ b/io/Versions @@ -125,4 +125,11 @@ libc { GLIBC_2.23 { fts64_children; fts64_close; fts64_open; fts64_read; fts64_set; } + + # Y2038 symbols are given their own version until they can be put in + # the right place + + GLIBC_Y2038 { + __fxstat64_t64; + } } diff --git a/io/fstat64.c b/io/fstat64.c index 69c80e5e45..a972304c0a 100644 --- a/io/fstat64.c +++ b/io/fstat64.c @@ -50,3 +50,10 @@ fstat64 (int fd, struct stat64 *buf) { return __fxstat64 (_STAT_VER, fd, buf); } + +int +attribute_hidden +__fstat64_t64 (int fd, struct __stat64_t64 *buf) +{ + return __fxstat64_t64 (_STAT_VER, fd, buf); +} diff --git a/sysdeps/unix/sysv/linux/fxstat64.c b/sysdeps/unix/sysv/linux/fxstat64.c index 8a59d86d31..6097257b2a 100644 --- a/sysdeps/unix/sysv/linux/fxstat64.c +++ b/sysdeps/unix/sysv/linux/fxstat64.c @@ -24,6 +24,8 @@ #include #include +#include + #include /* Get information about the file FD in BUF. */ @@ -51,3 +53,51 @@ hidden_ver (___fxstat64, __fxstat64) strong_alias (___fxstat64, __fxstat64) hidden_def (__fxstat64) #endif + +/* 64-bit time version */ + +extern int __y2038_linux_support; + +int +__fxstat64_t64 (int vers, int fd, struct __stat64_t64 *buf) +{ + int result; + struct stat64 st64; + + if (__y2038_linux_support) + { + // TODO: use 64-bit syscalls when they become available + } + + result = INLINE_SYSCALL (fstat64, 2, fd, &st64); +#if defined _HAVE_STAT64___ST_INO && !__ASSUME_ST_INO_64_BIT + if (__builtin_expect (!result, 1) && st64.__st_ino != (__ino_t) st64.st_ino) + st64.st_ino = st64.__st_ino; +#endif + if (!result) + { + 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 result; +}