From patchwork Fri Mar 19 18:31:19 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: 42702 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 751703842427; Fri, 19 Mar 2021 18:31:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 751703842427 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1616178693; bh=7PmVmilm354rQQzOGmios62WXSzVAwqBLj/dnMbTHyw=; 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=t2OymayIcg/glmfrb+9FWX8rTms7wN+zfxwQ2LFmSL61G8mO37YQaXuxhRVHg82wb eyB3Fd4lAMNuoDZoWu2C8jm77uf49mlBciQu6xX0aMsBhm4FN61sCctDNEg3/WDYIe O1d8/kAQiwSoya0nikaIQOW3puMzI6S8YD4PNgV8= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qv1-xf34.google.com (mail-qv1-xf34.google.com [IPv6:2607:f8b0:4864:20::f34]) by sourceware.org (Postfix) with ESMTPS id 9D5613842412 for ; Fri, 19 Mar 2021 18:31:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9D5613842412 Received: by mail-qv1-xf34.google.com with SMTP id cx5so5502561qvb.10 for ; Fri, 19 Mar 2021 11:31:30 -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=7PmVmilm354rQQzOGmios62WXSzVAwqBLj/dnMbTHyw=; b=nh1ok0tp96M95+TM7HUfXGlpcTELzerzfPHctbXMJv06HKCk34TFvMQdbU4tKQiXVC qNuoV/hp9EGoBPitC41Et2deLDeFoUQ8afifCLbciWG3JYkxFIBRRFK2b+GeI4uNlJYl DWHMqFyaTlEPuwF6F80eFq5VqIR8LksPd+Bgx8v01N8nYsLN2irC25TpQeJ36m0kALMB 2CvrvK86vxz1LbUcFXH3IROYBZtvTuvghOgQSn6TQt6RKDRnhuTlu6f37CAHHqrRM4BV ZnsTPyK/NQ77c5EfAtflZR4Z22GQzZRE0Jrx2mxO+7BS0wz84sY2WmRSO64a8ueIG8tI dLLQ== X-Gm-Message-State: AOAM533Czq5vzGqPma5jaBKCuAhkDO8q7d5SIy2xJF0dd0HQurQowmr8 hW7XcGsea0oSW5SUQG56uMMJNGsgQoF0wATA X-Google-Smtp-Source: ABdhPJykwh6Ta/mJK43+Hbd570sRcBgyingfxIQ1YUpoVZQb3gyMhmUl7b2TjB9Illk15uO5/MbgRQ== X-Received: by 2002:a0c:9ad7:: with SMTP id k23mr10643228qvf.52.1616178689956; Fri, 19 Mar 2021 11:31:29 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id z11sm5205747qkg.52.2021.03.19.11.31.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 11:31:29 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 3/5] linux: Use statx for MIPSn64 Date: Fri, 19 Mar 2021 15:31:19 -0300 Message-Id: <20210319183121.2252064-4-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.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, 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" MIPSn64 kernel ABI for legacy stat uses unsigned 32 bit for second timestamp, which limits the maximum value to y2106. This patch make mips64 use statx as for 32-bit architectures. Thie __cp_stat64_t64_statx is open coded, its usage is solely on fstatat64 and it avoid the need to redefine the name for mips64 (which will call __cp_stat64_statx since its does not use __stat64_t64 internally). --- sysdeps/unix/sysv/linux/fstatat64.c | 29 +++++++++++++++++++--- sysdeps/unix/sysv/linux/fxstat64.c | 1 + sysdeps/unix/sysv/linux/mips/kernel_stat.h | 4 +++ sysdeps/unix/sysv/linux/statx_cp.c | 29 ---------------------- 4 files changed, 30 insertions(+), 33 deletions(-) diff --git a/sysdeps/unix/sysv/linux/fstatat64.c b/sysdeps/unix/sysv/linux/fstatat64.c index c3a030af58..b9b8cd994b 100644 --- a/sysdeps/unix/sysv/linux/fstatat64.c +++ b/sysdeps/unix/sysv/linux/fstatat64.c @@ -24,9 +24,9 @@ #include #include #include -#include #include #include +#include #if __TIMESIZE == 64 \ && (__WORDSIZE == 32 \ @@ -50,8 +50,28 @@ fstatat64_time64_statx (int fd, const char *file, struct __stat64_t64 *buf, struct statx tmp; int r = INTERNAL_SYSCALL_CALL (statx, fd, file, AT_NO_AUTOMOUNT | flag, STATX_BASIC_STATS, &tmp); - if (r == 0) - __cp_stat64_t64_statx (buf, &tmp); + if (r != 0) + return r; + + *buf = (struct __stat64_t64) { + .st_dev = makedev (tmp.stx_dev_major, tmp.stx_dev_minor), + .st_rdev = makedev (tmp.stx_rdev_major, tmp.stx_rdev_minor), + .st_ino = tmp.stx_ino, + .st_mode = tmp.stx_mode, + .st_nlink = tmp.stx_nlink, + .st_uid = tmp.stx_uid, + .st_gid = tmp.stx_gid, + .st_atime = tmp.stx_atime.tv_sec, + .st_atim.tv_nsec = tmp.stx_atime.tv_nsec, + .st_mtime = tmp.stx_mtime.tv_sec, + .st_mtim.tv_nsec = tmp.stx_mtime.tv_nsec, + .st_ctime = tmp.stx_ctime.tv_sec, + .st_ctim.tv_nsec = tmp.stx_ctime.tv_nsec, + .st_size = tmp.stx_size, + .st_blocks = tmp.stx_blocks, + .st_blksize = tmp.stx_blksize, + }; + return r; } @@ -117,7 +137,8 @@ fstatat64_time64_stat (int fd, const char *file, struct __stat64_t64 *buf, } #if (__WORDSIZE == 32 \ - && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE == 32)) + && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE == 32)) \ + || defined STAT_HAS_TIME32 # define FSTATAT_USE_STATX 1 #else # define FSTATAT_USE_STATX 0 diff --git a/sysdeps/unix/sysv/linux/fxstat64.c b/sysdeps/unix/sysv/linux/fxstat64.c index be12798273..23d9d92b00 100644 --- a/sysdeps/unix/sysv/linux/fxstat64.c +++ b/sysdeps/unix/sysv/linux/fxstat64.c @@ -25,6 +25,7 @@ #include #include #include +#include #if LIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33) diff --git a/sysdeps/unix/sysv/linux/mips/kernel_stat.h b/sysdeps/unix/sysv/linux/mips/kernel_stat.h index e4b0f211ca..19524f7ea4 100644 --- a/sysdeps/unix/sysv/linux/mips/kernel_stat.h +++ b/sysdeps/unix/sysv/linux/mips/kernel_stat.h @@ -67,5 +67,9 @@ struct kernel_stat #else # define STATFS_IS_STATFS64 0 #endif +/* MIPS64 has unsigned 32 bit timestamps fields, so use statx as well. */ +#if _MIPS_SIM == _ABI64 +# define STAT_HAS_TIME32 +#endif #endif diff --git a/sysdeps/unix/sysv/linux/statx_cp.c b/sysdeps/unix/sysv/linux/statx_cp.c index 53068704c6..73405a9612 100644 --- a/sysdeps/unix/sysv/linux/statx_cp.c +++ b/sysdeps/unix/sysv/linux/statx_cp.c @@ -48,32 +48,3 @@ __cp_stat64_statx (struct stat64 *to, struct statx *from) } #endif -#if (__WORDSIZE == 32 \ - && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE == 32)) -void -__cp_stat64_t64_statx (struct __stat64_t64 *to, const struct statx *from) -{ - /* Clear both pad and reserved fields. */ - memset (to, 0, sizeof (*to)); - - to->st_dev = ((from->stx_dev_minor & 0xff) | (from->stx_dev_major << 8) - | ((from->stx_dev_minor & ~0xff) << 12)); - to->st_ino = from->stx_ino; - to->st_mode = from->stx_mode; - to->st_nlink = from->stx_nlink; - to->st_uid = from->stx_uid; - to->st_gid = from->stx_gid; - to->st_rdev = ((from->stx_rdev_minor & 0xff) | (from->stx_rdev_major << 8) - | ((from->stx_rdev_minor & ~0xff) << 12)); - to->st_size = from->stx_size; - to->st_blksize = from->stx_blksize; - to->st_blocks = from->stx_blocks; - - to->st_atime = from->stx_atime.tv_sec; - to->st_atim.tv_nsec = from->stx_atime.tv_nsec; - to->st_mtime = from->stx_mtime.tv_sec; - to->st_mtim.tv_nsec = from->stx_mtime.tv_nsec; - to->st_ctime = from->stx_ctime.tv_sec; - to->st_ctim.tv_nsec = from->stx_ctime.tv_nsec; -} -#endif