From patchwork Wed Apr 18 20:18:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Albert ARIBAUD X-Patchwork-Id: 26826 Received: (qmail 124443 invoked by alias); 18 Apr 2018 20:22:06 -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 124320 invoked by uid 89); 18 Apr 2018 20:22:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KAM_NUMSUBJECT, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_RP_RNBL autolearn=ham version=3.3.2 spammy= X-HELO: smtp3-g21.free.fr From: "Albert ARIBAUD (3ADEV)" To: libc-alpha@sourceware.org Cc: "Albert ARIBAUD (3ADEV)" Subject: [[PATCH RFC 2] 47/63] Y2038: add function __utime64 Date: Wed, 18 Apr 2018 22:18:03 +0200 Message-Id: <20180418201819.15952-48-albert.aribaud@3adev.fr> In-Reply-To: <20180418201819.15952-47-albert.aribaud@3adev.fr> References: <20180418201819.15952-1-albert.aribaud@3adev.fr> <20180418201819.15952-2-albert.aribaud@3adev.fr> <20180418201819.15952-3-albert.aribaud@3adev.fr> <20180418201819.15952-4-albert.aribaud@3adev.fr> <20180418201819.15952-5-albert.aribaud@3adev.fr> <20180418201819.15952-6-albert.aribaud@3adev.fr> <20180418201819.15952-7-albert.aribaud@3adev.fr> <20180418201819.15952-8-albert.aribaud@3adev.fr> <20180418201819.15952-9-albert.aribaud@3adev.fr> <20180418201819.15952-10-albert.aribaud@3adev.fr> <20180418201819.15952-11-albert.aribaud@3adev.fr> <20180418201819.15952-12-albert.aribaud@3adev.fr> <20180418201819.15952-13-albert.aribaud@3adev.fr> <20180418201819.15952-14-albert.aribaud@3adev.fr> <20180418201819.15952-15-albert.aribaud@3adev.fr> <20180418201819.15952-16-albert.aribaud@3adev.fr> <20180418201819.15952-17-albert.aribaud@3adev.fr> <20180418201819.15952-18-albert.aribaud@3adev.fr> <20180418201819.15952-19-albert.aribaud@3adev.fr> <20180418201819.15952-20-albert.aribaud@3adev.fr> <20180418201819.15952-21-albert.aribaud@3adev.fr> <20180418201819.15952-22-albert.aribaud@3adev.fr> <20180418201819.15952-23-albert.aribaud@3adev.fr> <20180418201819.15952-24-albert.aribaud@3adev.fr> <20180418201819.15952-25-albert.aribaud@3adev.fr> <20180418201819.15952-26-albert.aribaud@3adev.fr> <20180418201819.15952-27-albert.aribaud@3adev.fr> <20180418201819.15952-28-albert.aribaud@3adev.fr> <20180418201819.15952-29-albert.aribaud@3adev.fr> <20180418201819.15952-30-albert.aribaud@3adev.fr> <20180418201819.15952-31-albert.aribaud@3adev.fr> <20180418201819.15952-32-albert.aribaud@3adev.fr> <20180418201819.15952-33-albert.aribaud@3adev.fr> <20180418201819.15952-34-albert.aribaud@3adev.fr> <20180418201819.15952-35-albert.aribaud@3adev.fr> <20180418201819.15952-36-albert.aribaud@3adev.fr> <20180418201819.15952-37-albert.aribaud@3adev.fr> <20180418201819.15952-38-albert.aribaud@3adev.fr> <20180418201819.15952-39-albert.aribaud@3adev.fr> <20180418201819.15952-40-albert.aribaud@3adev.fr> <20180418201819.15952-41-albert.aribaud@3adev.fr> <20180418201819.15952-42-albert.aribaud@3adev.fr> <20180418201819.15952-43-albert.aribaud@3adev.fr> <20180418201819.15952-44-albert.aribaud@3adev.fr> <20180418201819.15952-45-albert.aribaud@3adev.fr> <20180418201819.15952-46-albert.aribaud@3adev.fr> <20180418201819.15952-47-albert.aribaud@3adev.fr> --- include/utime.h | 7 +++++++ io/Makefile | 2 +- io/Versions | 1 + io/utime.c | 16 ++++++++++++++++ sysdeps/posix/utime64.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 sysdeps/posix/utime64.c diff --git a/include/utime.h b/include/utime.h index 5049251311..eb907f7472 100644 --- a/include/utime.h +++ b/include/utime.h @@ -6,4 +6,11 @@ libc_hidden_proto (utime) #endif +/* Structure describing file times, 64-bit time version. */ +struct __utimbuf64 + { + __time64_t actime; /* Access time. */ + __time64_t modtime; /* Modification time. */ + }; + #endif /* utime.h */ diff --git a/io/Makefile b/io/Makefile index 2117cb6b62..85dafd3429 100644 --- a/io/Makefile +++ b/io/Makefile @@ -28,7 +28,7 @@ headers := sys/stat.h bits/stat.h sys/statfs.h bits/statfs.h sys/vfs.h \ utime.h ftw.h fts.h sys/sendfile.h routines := \ - utime \ + utime utime64 \ mkfifo mkfifoat \ stat fstat lstat stat64 fstat64 lstat64 fstatat fstatat64 \ xstat fxstat lxstat xstat64 fxstat64 lxstat64 \ diff --git a/io/Versions b/io/Versions index 13334f07fb..73eca4d065 100644 --- a/io/Versions +++ b/io/Versions @@ -131,5 +131,6 @@ libc { __xstat64_t64; __lxstat64_t64; __fxstatat64_t64; + __utime64; } } diff --git a/io/utime.c b/io/utime.c index 3f3c03c92d..b33296b7ee 100644 --- a/io/utime.c +++ b/io/utime.c @@ -38,3 +38,19 @@ utime (const char *file, const struct utimbuf *times) libc_hidden_def (utime) stub_warning (utime) + +/* 64-bit time version */ + +int +__utime64 (const char *file, const struct __utimbuf64 *times) +{ + if (file == NULL) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +stub_warning (__utime64) diff --git a/sysdeps/posix/utime64.c b/sysdeps/posix/utime64.c new file mode 100644 index 0000000000..1f043da0ce --- /dev/null +++ b/sysdeps/posix/utime64.c @@ -0,0 +1,46 @@ +/* Copyright (C) 1991-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 + + +/* Set the access and modification times of FILE to those given in TIMES. + If TIMES is NULL, set them to the current time. */ +int +__utime64 (const char *file, const struct __utimbuf64 *times) +{ + struct __timeval64 timevals[2]; + struct __timeval64 *tvp; + + if (times != NULL) + { + timevals[0].tv_sec = (time_t) times->actime; + timevals[0].tv_usec = 0L; + timevals[1].tv_sec = (time_t) times->modtime; + timevals[1].tv_usec = 0L; + tvp = timevals; + } + else + tvp = NULL; + + return __utimes64 (file, tvp); +}