From patchwork Fri Mar 19 18:31:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 42703 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 0692F384242C; Fri, 19 Mar 2021 18:31:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0692F384242C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1616178694; bh=oUn20d6fyqsYvQif8F6rO1yliwNe/i97tM8owFw4YIY=; 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=NMnvGxEzMISm3teCUHP5enW8DbaJT06lslOrJoA7T6m1QgHO+RTkChnkCDugwa/V9 ZCPcsRjHExIzQ0kNOO3wI5fVD85qvKqSmoge+b01B1t5NtsDwjHGf0BQhIdFbSh+Ro sOYEeGlbSlJKqniQsHo4j0kqyWlk4+wg8xDNvdHI= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [IPv6:2607:f8b0:4864:20::72a]) by sourceware.org (Postfix) with ESMTPS id B6E24386F446 for ; Fri, 19 Mar 2021 18:31:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B6E24386F446 Received: by mail-qk1-x72a.google.com with SMTP id v70so3945755qkb.8 for ; Fri, 19 Mar 2021 11:31:31 -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:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oUn20d6fyqsYvQif8F6rO1yliwNe/i97tM8owFw4YIY=; b=jRcfJDF8XfRJeLxwPkbQxDCFeSMDGEfu27q5JnPCMOcgAA6NHiCJEoeiiiTyvWUTd8 YDwizwWC8LVX7mJcumLP3oO6Ci34LllauHqpitRD8rA6gZJ381/bIZeyWGLpyLC0Swbu agFGZmIKsHUWp/73EbEUbh6xQgADrwjcUbxj+h8eGkAEa/bpO3ssUdVS7K4oUUDKopDZ E9wuByVKd3ghwZVaXpZrQIAojFKgLY3k9TxQ0yQP7fGX3TLcOw5HsatTEgrrz1aRhpqG m6vD2zwbAfQKrCn4D7p8i3Q6WMdQ0Q3xGvDsc8iSAf/QifKspUqxxcr14cVQlFQ6K3kd 6j/w== X-Gm-Message-State: AOAM532Ivo6nT7CeT2YskEvFHKwXrECi5HvIGIcYCzgpK/+QMZS0c9MB ZpVWBH4Nb0N35Tvw+6HvYuh2jnXsMDv6XNGt X-Google-Smtp-Source: ABdhPJz3zYeLsfUBaxzk6AQ18GKrK4lS8POrz/d+MLCWdd3M/+qTa4xDxQ3XTnNlrgAzBqSmr7OtvQ== X-Received: by 2002:a37:a38e:: with SMTP id m136mr10743990qke.250.1616178691149; Fri, 19 Mar 2021 11:31:31 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id z11sm5205747qkg.52.2021.03.19.11.31.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 11:31:30 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 4/5] support: Add support_path_support_time64_value Date: Fri, 19 Mar 2021 15:31:20 -0300 Message-Id: <20210319183121.2252064-5-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210319183121.2252064-1-adhemerval.zanella@linaro.org> References: <20210319183121.2252064-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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" It allows to check for support on arbitrary timestamp values. --- support/support.h | 11 +++++++++-- support/support_path_support_time64.c | 10 +++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/support/support.h b/support/support.h index 2e477c9e7c..5757c40833 100644 --- a/support/support.h +++ b/support/support.h @@ -130,9 +130,16 @@ extern void support_copy_file (const char *from, const char *to); extern ssize_t support_copy_file_range (int, off64_t *, int, off64_t *, size_t, unsigned int); -/* Return true is PATH supports 64-bit time_t interfaces for file +/* Return true if PATH supports 64-bit time_t interfaces for file operations (such as fstatat or utimensat). */ -extern bool support_path_support_time64 (const char *path); +extern bool support_path_support_time64_value (const char *path, int64_t at, + int64_t mt); +static __inline bool support_path_support_time64 (const char *path) +{ + /* 1s and 2s after y2038 limit. */ + return support_path_support_time64_value (path, 0x80000001ULL, + 0x80000002ULL); +} __END_DECLS diff --git a/support/support_path_support_time64.c b/support/support_path_support_time64.c index 452fedcde5..33b2bdff66 100644 --- a/support/support_path_support_time64.c +++ b/support/support_path_support_time64.c @@ -36,19 +36,15 @@ utimesat_call (const char *path, const struct __timespec64 tsp[2]) #endif bool -support_path_support_time64 (const char *path) +support_path_support_time64_value (const char *path, int64_t at, int64_t mt) { #ifdef __linux__ /* Obtain the original timestamps to restore at the end. */ struct statx ostx; TEST_VERIFY_EXIT (statx (AT_FDCWD, path, 0, STATX_BASIC_STATS, &ostx) == 0); - const struct __timespec64 tsp[] = - { - /* 1s and 2s after y2038 limit. */ - { 0x80000001ULL, 0 }, - { 0x80000002ULL, 0 } - }; + const struct __timespec64 tsp[] = { { at, 0 }, { mt, 0 } }; + /* Return is kernel does not support __NR_utimensat_time64. */ if (utimesat_call (path, tsp) == -1) return false;