From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-x82c.google.com (mail-qt1-x82c.google.com [IPv6:2607:f8b0:4864:20::82c]) by sourceware.org (Postfix) with ESMTPS id E724D3858002 for ; Mon, 29 Mar 2021 12:48:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E724D3858002 Received: by mail-qt1-x82c.google.com with SMTP id u8so9125099qtq.12 for ; Mon, 29 Mar 2021 05:48:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=nPoEUTlnFRWcLMdE/Y+9y0k6qNOjsUrrAp1eOXr6Iac=; b=HrnRUiV/p0KTdJUYoMCaMtJwfFxL/gyr0JdBz9ExVp7ODyUNEKEUQ/FUGhd55rCPvr XcJe70+jVqOYzrFz41EgKUv5g9xwfflsfXl4536OgyCeGNALjAiAfmKRFw0u49wfMarj pfk19AWRRE8m/jBN4zV5oHfsdE+HKijD1nanZxdBm26Cctj7Mu17IsZwbMCS4P8f8Qox k9r/yZYscuEEwdbeNmJhB4mXPli0tT4NPn7ZYQ6MPibkPKnf7aQpQn8NNUcHiEs9kmTt JbmiYiznQ1YDzShsF7Gwo8N4meC+S/U0I1rY5D+pEQHlFp56WIAgqU0I8J4rQylFV8gY WiBw== X-Gm-Message-State: AOAM532WGu233U1952x2PgVQWvd2V7FCVPfhNlSwZ5z3C7yluaEwpJOK +EoPmjS42Oy3YH++7ArFmCWIunFQTWZuCyeI X-Google-Smtp-Source: ABdhPJwUijETuSvrqlVqD5R9YkjyC8/k8hHjaeeCWVq3EfjbSb/h8S3ktdz1CKh9iQTrO7cvx2YYLQ== X-Received: by 2002:a05:622a:493:: with SMTP id p19mr23085163qtx.131.1617022112243; Mon, 29 Mar 2021 05:48:32 -0700 (PDT) Received: from [192.168.1.132] ([177.194.41.149]) by smtp.gmail.com with ESMTPSA id b198sm13145717qkg.10.2021.03.29.05.48.31 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 29 Mar 2021 05:48:31 -0700 (PDT) Subject: Re: [PATCH 3/5] linux: Use statx for MIPSn64 From: Adhemerval Zanella To: libc-alpha@sourceware.org References: <20210319183121.2252064-1-adhemerval.zanella@linaro.org> <20210319183121.2252064-4-adhemerval.zanella@linaro.org> Message-ID: <14b433ef-d609-ebbb-3312-4f625cc3c7a0@linaro.org> Date: Mon, 29 Mar 2021 09:48:29 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210319183121.2252064-4-adhemerval.zanella@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, NICE_REPLY_A, 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-List-Received-Date: Mon, 29 Mar 2021 12:48:34 -0000 Since other patches have been reviewed, I will commit this shortly. I ran the tst-futimens, tst-utime, and tst-utimes on a mips64-le with both a 4.1.4 and 5.10 kernel and got the expected results. On 19/03/2021 15:31, Adhemerval Zanella wrote: > 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) > This is not required. > 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 >