public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: YunQiang Su <yunqiang.su@cipunited.com>, libc-alpha@sourceware.org
Cc: aurelien@aurel32.net, jiaxun.yang@flygoat.com, macro@orcam.me.uk,
	syq@debian.org
Subject: Re: [PATCH v2 1/2] fstatat64: use statx on kernel using uint32 for time
Date: Fri, 19 Mar 2021 15:38:37 -0300	[thread overview]
Message-ID: <d38085ef-b906-d700-b566-d26d00d6e7d1@linaro.org> (raw)
In-Reply-To: <20210319011837.3883510-1-yunqiang.su@cipunited.com>



On 18/03/2021 22:18, YunQiang Su wrote:
> diff --git a/sysdeps/unix/sysv/linux/fstatat.c b/sysdeps/unix/sysv/linux/fstatat.c
> index 59efff615f..ccb6027b64 100644
> --- a/sysdeps/unix/sysv/linux/fstatat.c
> +++ b/sysdeps/unix/sysv/linux/fstatat.c
> @@ -37,7 +37,12 @@ __fstatat (int fd, const char *file, struct stat *buf, int flag)
>  		 || buf->__st_blocks_pad != 0))
>      return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW);
>  # else
> -#  ifdef __NR_fstatat64
> +#  if defined(STAT_KERNEL64_TIME32_T)
> +   /* Some architecture, like MIPS N64, is 64bit, while its kernel_stat has 32bit timespec.
> +      Since they are 64bit, and time_t is also 64bit, it is safe for this cast */
> +  return __fstatat64_time64(fd, file, (struct __stat64_t64 *)buf, flag);
> +#  endif

I am not very found of this aliasing violation, specially because my
refactor tried exactly to avoid it on the newer implementations
(only the old xstat does require them because of the way the compat
is implemented).

> diff --git a/sysdeps/unix/sysv/linux/statx_cp.h b/sysdeps/unix/sysv/linux/statx_cp.h
> index 634330aaa6..cc1ae4698d 100644
> --- a/sysdeps/unix/sysv/linux/statx_cp.h
> +++ b/sysdeps/unix/sysv/linux/statx_cp.h
> @@ -18,6 +18,10 @@
>  
>  extern void __cp_stat64_statx (struct stat64 *to, struct statx *from)
>    attribute_hidden;
> +#if defined(STAT_KERNEL64_TIME32_T)
> +# define __cp_stat64_t64_statx __cp_stat64_statx
> +#else
>  extern void __cp_stat64_t64_statx (struct __stat64_t64 *to,
>  				   const struct statx *from)
>    attribute_hidden;
> +#endif

Instead of adding this hack, it is better to just open code the
__cp_stat64_t64_statx (it is used solely on fstatat64).

> diff --git a/sysdeps/unix/sysv/linux/tst-futimens.c b/sysdeps/unix/sysv/linux/tst-futimens.c
> index 785cd87557..67a411db74 100644
> --- a/sysdeps/unix/sysv/linux/tst-futimens.c
> +++ b/sysdeps/unix/sysv/linux/tst-futimens.c
> @@ -37,6 +37,9 @@ const struct timespec t2[2] = { { 0x80000001ULL, 0 },  { 0x80000002ULL, 0 } };
>  /* struct timespec array around Y2038 threshold.  */
>  const struct timespec t3[2] = { { 0x7FFFFFFE, 0 },  { 0x80000002ULL, 0 } };
>  
> +/* struct timespec array around -1: may trigger Y2106 problem */
> +const struct timespec t4[2] = { { -1, 0 },  { -2, 0 } };
> +
>  #define PREPARE do_prepare
>  static void
>  do_prepare (int argc, char *argv[])
> @@ -83,6 +86,7 @@ do_test (void)
>    test_futimens_helper (&t1[0]);
>    test_futimens_helper (&t2[0]);
>    test_futimens_helper (&t3[0]);
> +  test_futimens_helper (&t4[0]);
>  
>    return 0;
>  }

This test will fail on MIPSn64 kernels older than 4.11.

I have sent a more complete fix, that also fixes the s390 issue regarding
missing nanoseconds and improves the tests to handle the y2106 issue as
well [1].

[1] https://patchwork.sourceware.org/project/glibc/list/?series=1878

      parent reply	other threads:[~2021-03-19 18:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-19  1:18 YunQiang Su
2021-03-19  1:18 ` [PATCH v2 2/2] MIPS: N64, make xstat as wrapper of generic fstatat YunQiang Su
2021-03-19 10:07   ` Andreas Schwab
2021-03-19 18:42   ` Adhemerval Zanella
2021-03-22  2:23     ` 回复: " yunqiang.su
2021-03-19 18:38 ` Adhemerval Zanella [this message]

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=d38085ef-b906-d700-b566-d26d00d6e7d1@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=aurelien@aurel32.net \
    --cc=jiaxun.yang@flygoat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=macro@orcam.me.uk \
    --cc=syq@debian.org \
    --cc=yunqiang.su@cipunited.com \
    /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).