From patchwork Thu Oct 15 13:06:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 40729 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 9F0623948AB3; Thu, 15 Oct 2020 13:06:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9F0623948AB3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1602767202; bh=LjOs+r7ahGq6YbOu7ikQSozkpBxBC7ntObxSYtFQ+EQ=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=jgd/I8oj9rKEW+xUR5swwGd2kG4z6pjg0M6IzfwzJTX+0V437cVcUnYTPgGjiAOkx duicBd4FHlEoBf9h4aORnN68A3GUVbXZu2KPSFi0KodnFXx98RzIiQT7fH6S3G2zlX w91RZ00CU4FZLgvDOBBeS7EqLnZqrs6AvZfuksNk= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by sourceware.org (Postfix) with ESMTPS id 85E5A386F009 for ; Thu, 15 Oct 2020 13:06:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 85E5A386F009 Received: by mail-qk1-x743.google.com with SMTP id 188so2219568qkk.12 for ; Thu, 15 Oct 2020 06:06:39 -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:mime-version :content-transfer-encoding; bh=LjOs+r7ahGq6YbOu7ikQSozkpBxBC7ntObxSYtFQ+EQ=; b=ZZedjAegFs/ecUJG6ZnU7YB7CJrucM7q7OLSVsc61voDCBZ/eUqYwTEH3HC/kLXSXF wU2yeOupl640XIPnxAaJ14w2f0gigbKw6/0Ds8l1j79umClyGcexuDacTc+opfAbeQAP qiWO677Xv6vEjJnNFZp3/uTy0lGgv7nSiYtSGVng+YQvv32UiZTEQd8vu8mRBUwtOR/s DSi3LWdmiRQA/Ugm8mLGNIAlCygc7swDbnX4O+q7R1zH/ntXhGty5jPitpsXSHrBD4Sf 9cKBMDL0eg6bBwOuz5BDe7Lexx/8r+lBRe7Kh5zGC4Nz4FL8aek0mrRLKHdR47fyC2NV NVQw== X-Gm-Message-State: AOAM530/TO4L0C5jCcRUWjTF2z5NPASaaEMpA0PqSyl7ftc3EEfOk5eV bvxmmMyx7rHgDVYZjDyop23+BANYWK682Q== X-Google-Smtp-Source: ABdhPJzIJS5ME01i4GZx99HNjGldPEcpNPB/k580uSrF9OIio+U0Z9bWTbsrWZ0URWNJNou5ZgUqjg== X-Received: by 2002:ae9:ed02:: with SMTP id c2mr3890567qkg.410.1602767197885; Thu, 15 Oct 2020 06:06:37 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id 6sm1093648qtz.31.2020.10.15.06.06.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Oct 2020 06:06:37 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 1/3] linux: Fix time64 support for futimesat Date: Thu, 15 Oct 2020 10:06:30 -0300 Message-Id: <20201015130632.90961-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 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 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). Reviewed-by: Lukasz Majewski --- 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;