From patchwork Mon Jul 13 17:10:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40087 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D01603938C37; Mon, 13 Jul 2020 17:11:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D01603938C37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594660266; bh=LjOs+r7ahGq6YbOu7ikQSozkpBxBC7ntObxSYtFQ+EQ=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=LFSysstVMuw18XsXlpVuSUCy7+2/QYoaII6INP3E3gyB0SDmSDfGyz6RMWDWh+NmW /zRvpnvunKtjKFCLHwSPiEvz7GtIjUPSzekQRtq7NFjb/OibJtaNz6Q18lTHF1j8WR lMKGxq+nBVFdHYWYFlm0tauenDEUibfJafKvw8Kc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by sourceware.org (Postfix) with ESMTPS id 34A083890439 for ; Mon, 13 Jul 2020 17:11:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 34A083890439 Received: by mail-qt1-x841.google.com with SMTP id e12so10497345qtr.9 for ; Mon, 13 Jul 2020 10:11:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LjOs+r7ahGq6YbOu7ikQSozkpBxBC7ntObxSYtFQ+EQ=; b=fcHJO7stzuwiC+F8LpWIrMSQlhcva/YxxksehPD7tZPtCuCnBEKZ/8BHl8Nlf+2+JH 2kqonkHEWoMZRA/Dhy15S+QeMJDOfxB27KL9QXeCKbIW5lPoCLoBoCgw0N9a36kD6Son OOFKQrB61iU1gmbNlu9EaSHAtrmBYiZ+PJOxFLt713RngMZ3138Za4IaLApuOGwtxE2D nACjQNMKYnlISM4lOtRiCEulIXBtzwQ/kEplSdNO5kOE7EkAJBBBP2EDwMAzcC/e11g2 LOVasaj7ihml7v4yFPOyhF6vjSsBhryhafuLUmm9vNQGeLNybCYeiEzVq/iw0cIZowgH Visg== X-Gm-Message-State: AOAM532bpr9ameMekycDn2yfVbfCKrN03sVH9PkmYHpytSanrhgCdq7d 31eSb/au2cOfz+ndhcmQGIyR8tfWtZg= X-Google-Smtp-Source: ABdhPJw+XnDTdqUMDwtZVts0sypVAzjR18y9VMHTGkwPQ7j3cOABpBw7Yqs9dbUopqsE7Q6QKzFxaQ== X-Received: by 2002:ac8:2928:: with SMTP id y37mr299610qty.245.1594660263095; Mon, 13 Jul 2020 10:11:03 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id v10sm19767919qtk.14.2020.07.13.10.11.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 10:11:02 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 22/23] linux: Fix time64 support for futimesat Date: Mon, 13 Jul 2020 14:10:24 -0300 Message-Id: <20200713171025.3661832-22-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> References: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The generic implementation does not support time64 and the default one return overflow for invalid tv_sec with UTIME_NOW / UTIME_OMIT (which is valid since tv_sec in such cases is ignored by the kernel). Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). --- sysdeps/unix/sysv/linux/generic/futimesat.c | 52 --------------------- sysdeps/unix/sysv/linux/utimensat.c | 8 +++- 2 files changed, 6 insertions(+), 54 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/generic/futimesat.c diff --git a/sysdeps/unix/sysv/linux/generic/futimesat.c b/sysdeps/unix/sysv/linux/generic/futimesat.c deleted file mode 100644 index 7be1fbc252..0000000000 --- a/sysdeps/unix/sysv/linux/generic/futimesat.c +++ /dev/null @@ -1,52 +0,0 @@ -/* futimesat -- Change access and modification times of file. Linux version. - Copyright (C) 2005-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Chris Metcalf , 2011. - - 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 - - -/* Change the access time of FILE relative to FD to TVP[0] and - the modification time of FILE to TVP[1]. */ -int -futimesat (int fd, const char *file, const struct timeval tvp[2]) -{ - struct timespec tsp[2]; - int result; - - if (tvp) - { - if (tvp[0].tv_usec >= 1000000 || tvp[0].tv_usec < 0 - || tvp[1].tv_usec >= 1000000 || tvp[1].tv_usec < 0) - { - __set_errno (EINVAL); - return -1; - } - TIMEVAL_TO_TIMESPEC (&tvp[0], &tsp[0]); - TIMEVAL_TO_TIMESPEC (&tvp[1], &tsp[1]); - } - - result = INLINE_SYSCALL (utimensat, 4, fd, file, tvp ? tsp : NULL, 0); - return result; -} diff --git a/sysdeps/unix/sysv/linux/utimensat.c b/sysdeps/unix/sysv/linux/utimensat.c index ea23c2f051..72784d824a 100644 --- a/sysdeps/unix/sysv/linux/utimensat.c +++ b/sysdeps/unix/sysv/linux/utimensat.c @@ -36,9 +36,13 @@ __utimensat64_helper (int fd, const char *file, if (ret == 0 || errno != ENOSYS) return ret; + /* For UTIME_NOW and UTIME_OMIT the value of tv_sec field is ignored. */ +# define NS_VALID(ns) \ + ((((ns).tv_nsec == UTIME_NOW || (ns).tv_nsec == UTIME_OMIT) \ + || in_time_t_range ((ns).tv_sec))) + if (tsp64 != NULL - && (! in_time_t_range (tsp64[0].tv_sec) - || ! in_time_t_range (tsp64[1].tv_sec))) + && (!NS_VALID (tsp64[0]) || !NS_VALID (tsp64[1]))) { __set_errno (EOVERFLOW); return -1;