From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: libc-alpha@sourceware.org
Subject: Re: [PATCH 3/5] linux: Use statx for MIPSn64
Date: Mon, 29 Mar 2021 09:48:29 -0300 [thread overview]
Message-ID: <14b433ef-d609-ebbb-3312-4f625cc3c7a0@linaro.org> (raw)
In-Reply-To: <20210319183121.2252064-4-adhemerval.zanella@linaro.org>
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 <kernel_stat.h>
> #include <sysdep.h>
> #include <time.h>
> -#include <statx_cp.h>
> #include <kstat_cp.h>
> #include <stat_t64_cp.h>
> +#include <sys/sysmacros.h>
>
> #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 <xstatconv.h>
> #include <statx_cp.h>
> #include <shlib-compat.h>
> +#include <sys/sysmacros.h>
>
> #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
>
next prev parent reply other threads:[~2021-03-29 12:48 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-19 18:31 [PATCH 0/5] More stat fixes Adhemerval Zanella
2021-03-19 18:31 ` [PATCH 1/5] linux: Implement fstatat with __fstatat64_time64 Adhemerval Zanella
2021-03-23 16:13 ` Stefan Liebler
2021-03-26 9:24 ` Stefan Liebler
2021-03-26 19:32 ` Adhemerval Zanella
2021-03-19 18:31 ` [PATCH 2/5] linux: Disable fstatat64 fallback if __ASSUME_STATX is defined Adhemerval Zanella
2021-03-26 9:24 ` Stefan Liebler
2021-03-26 19:38 ` Adhemerval Zanella
2021-03-19 18:31 ` [PATCH 3/5] linux: Use statx for MIPSn64 Adhemerval Zanella
2021-03-29 12:48 ` Adhemerval Zanella [this message]
2021-04-01 0:07 ` Maciej W. Rozycki
2021-04-01 12:45 ` Adhemerval Zanella
2021-04-01 18:00 ` Maciej W. Rozycki
2021-03-19 18:31 ` [PATCH 4/5] support: Add support_path_support_time64_value Adhemerval Zanella
2021-03-26 9:24 ` Stefan Liebler
2021-03-19 18:31 ` [PATCH 5/5] linux: Add y2106 support on utimensat tests Adhemerval Zanella
2021-03-26 9:24 ` Stefan Liebler
2021-03-26 19:40 ` Adhemerval Zanella
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=14b433ef-d609-ebbb-3312-4f625cc3c7a0@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).