linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Zhangjin Wu <falcon@tinylab.org>
To: thomas@t-8ch.de, arnd@arndb.de, w@1wt.eu
Cc: falcon@tinylab.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org
Subject: Re: [PATCH v2 04/13] tools/nolibc: add missing nanoseconds support for __NR_statx
Date: Tue, 30 May 2023 13:21:32 +0800	[thread overview]
Message-ID: <20230530052132.364685-1-falcon@tinylab.org> (raw)
In-Reply-To: <3a3edd48-1ace-4c89-89e8-9c594dd1b3c9@t-8ch.de>

Thomas, Arnd, Willy

> On 2023-05-30 03:50:34+0800, Zhangjin Wu wrote:
> > Commit a89c937d781a ("tools/nolibc: support nanoseconds in stat()")
> > added nanoseconds for stat() but missed the statx case, this adds it.
> 
> Welp, I should have thought of that.
> At least the testcase seems to have been useful.
>

yeah, your testcase telled me this issue.

> Thanks for the fix!
> 
> > The stx_atime, stx_mtime, stx_ctime are in type of 'struct
> > statx_timestamp', which is incompatible with 'struct timespec', should
> > convert explicitly.
> > 
> >     /* include/uapi/linux/stat.h */
> > 
> >     struct statx_timestamp {
> >     	__s64	tv_sec;
> >     	__u32	tv_nsec;
> >     	__s32	__reserved;
> >     };
> > 
> >     /* include/uapi/linux/time_types.h */
> >     struct __kernel_timespec {
> >     	__kernel_time64_t       tv_sec;                 /* seconds */
> >     	long long               tv_nsec;                /* nanoseconds */
> >     };
> > 
> >     /* tools/include/nolibc/types.h */
> >     #define timespec __kernel_timespec
> > 
> > Without this patch, the stat_timestamps test case would fail on rv32.
> > 
> > Fixes: a89c937d781a ("tools/nolibc: support nanoseconds in stat()")
> > Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
> > ---
> >  tools/include/nolibc/sys.h | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h
> > index 154194056962..98cfa2f6d021 100644
> > --- a/tools/include/nolibc/sys.h
> > +++ b/tools/include/nolibc/sys.h
> > @@ -1175,9 +1175,9 @@ int sys_stat(const char *path, struct stat *buf)
> >  	buf->st_size    = statx.stx_size;
> >  	buf->st_blksize = statx.stx_blksize;
> >  	buf->st_blocks  = statx.stx_blocks;
> > -	buf->st_atime   = statx.stx_atime.tv_sec;
> > -	buf->st_mtime   = statx.stx_mtime.tv_sec;
> > -	buf->st_ctime   = statx.stx_ctime.tv_sec;
> > +	buf->st_atim    = (struct timespec){ .tv_sec = statx.stx_atime.tv_sec, .tv_nsec = statx.stx_atime.tv_nsec };
> > +	buf->st_mtim    = (struct timespec){ .tv_sec = statx.stx_mtime.tv_sec, .tv_nsec = statx.stx_mtime.tv_nsec };
> > +	buf->st_ctim    = (struct timespec){ .tv_sec = statx.stx_ctime.tv_sec, .tv_nsec = statx.stx_ctime.tv_nsec };
> 
> I would prefer to split the compound assignment into two single
> assignments, though.
> 
> buf->st_ctim.tv_sec = statx.stx_ctime.tv_sec;
> buf->st_ctim.tv_nsec = statx.stx_ctime.tv_nsec;
>

Ok, will update it in the v3 revision.

And further, what about removing the other !statx parts
(__NR_newfstatat, __NR_stat)? just like we are doing for the other 64bit
syscalls (llseek and time65).

Best regards,
Zhangjin

> >  	return ret;
> >  }
> >  #else

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  reply	other threads:[~2023-05-30  5:22 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-29 19:45 [PATCH v2 00/13] nolibc: add part2 of support for rv32 Zhangjin Wu
2023-05-29 19:46 ` [PATCH v2 01/13] selftests/nolibc: remove gettimeofday_bad1/2 completely Zhangjin Wu
2023-05-29 19:47 ` [PATCH v2 02/13] selftests/nolibc: support two errnos with EXPECT_SYSER2() Zhangjin Wu
2023-05-29 19:49 ` [PATCH v2 03/13] selftests/nolibc: waitpid_min: add waitid syscall support Zhangjin Wu
2023-05-29 19:50 ` [PATCH v2 04/13] tools/nolibc: add missing nanoseconds support for __NR_statx Zhangjin Wu
2023-05-29 21:39   ` Thomas Weißschuh
2023-05-30  5:21     ` Zhangjin Wu [this message]
2023-05-29 19:51 ` [PATCH v2 05/13] tools/nolibc: add more wait status related types Zhangjin Wu
2023-05-29 19:53 ` [PATCH v2 06/13] tools/nolibc: add pure 64bit off_t, time_t and blkcnt_t Zhangjin Wu
2023-05-29 19:54 ` [PATCH v2 07/13] tools/nolibc: sys_lseek: add pure 64bit lseek Zhangjin Wu
2023-05-30  8:10   ` Arnd Bergmann
2023-05-30 13:54     ` Zhangjin Wu
2023-07-02 16:28       ` Willy Tarreau
2023-05-29 19:56 ` [PATCH v2 08/13] tools/nolibc: add pure 64bit time structs Zhangjin Wu
2023-05-29 19:57 ` [PATCH v2 09/13] tools/nolibc: sys_select: add pure 64bit select Zhangjin Wu
2023-05-29 19:58 ` [PATCH v2 10/13] tools/nolibc: sys_poll: add pure 64bit poll Zhangjin Wu
2023-05-29 19:59 ` [PATCH v2 11/13] tools/nolibc: sys_gettimeofday: add pure 64bit gettimeofday Zhangjin Wu
2023-05-29 20:01 ` [PATCH v2 12/13] tools/nolibc: sys_wait4: add waitid syscall support Zhangjin Wu
2023-05-29 20:03 ` [PATCH v2 13/13] selftests/nolibc: riscv: customize makefile for rv32 Zhangjin Wu
2023-06-02  4:06   ` Zhangjin Wu
2023-06-02 10:33     ` Thomas Weißschuh
2023-06-02 11:56       ` Zhangjin Wu
2023-05-30  6:33 ` [PATCH v2 0/2] nolibc: add part3 of support " Zhangjin Wu
2023-05-30  6:37   ` [PATCH 1/2] selftests/nolibc: add new gettimeofday test cases Zhangjin Wu
2023-05-30 10:59     ` Thomas Weißschuh
2023-05-30 11:28       ` Zhangjin Wu
2023-05-30 11:54         ` Thomas Weißschuh
2023-05-30 12:05       ` Willy Tarreau
2023-05-30 12:31         ` Andreas Schwab
2023-05-30 12:35         ` Thomas Weißschuh
2023-05-30  6:42   ` [PATCH 2/2] selftests/nolibc: add sizeof test for the new 64bit data types Zhangjin Wu
2023-05-30  9:18     ` Thomas Weißschuh
2023-05-30 11:17       ` Zhangjin Wu
2023-06-02 19:44 ` [PATCH v2 00/13] nolibc: add part2 of support for rv32 Willy Tarreau

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=20230530052132.364685-1-falcon@tinylab.org \
    --to=falcon@tinylab.org \
    --cc=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=thomas@t-8ch.de \
    --cc=w@1wt.eu \
    /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 NNTP newsgroup(s).