From: Zorro Lang <zlang@kernel.org>
To: ChenXiaoSong <chenxiaosong@chenxiaosong.com>
Cc: smfrench@gmail.com, linkinjeon@kernel.org, pc@manguebit.org,
ronniesahlberg@gmail.com, sprasad@microsoft.com, tom@talpey.com,
bharathsm@microsoft.com, senozhatsky@chromium.org,
dhowells@redhat.com, metze@samba.org, linux-cifs@vger.kernel.org,
ChenXiaoSong <chenxiaosong@kylinos.cn>,
fstests@vger.kernel.org
Subject: Re: [PATCH v2 xfstests 0/3] add generic/795
Date: Wed, 22 Jul 2026 05:21:22 +0800 [thread overview]
Message-ID: <al_e-tLidEugZyY2@zlang-mailbox> (raw)
In-Reply-To: <4021e03f-6d80-4a26-9112-1dc20abeed12@chenxiaosong.com>
On Tue, Jul 21, 2026 at 04:31:59PM +0800, ChenXiaoSong wrote:
> Hi Zorro,
>
> The stat command uses the statx() syscall rather than fstat(), so we have to
> use a C program to call fstat().
I'm not sure how you got at that conclusion.
>
> On 7/21/26 16:25, Zorro Lang wrote:
> > I might not have explained clearly during the review. I wasn't asking you to
> > rewrite g/002 and lstat64.c. I was suggesting checking whether src/fstat.c in
> > your previous patch could be replaced by the stat command in xfs_io [1]. Check
> > `man xfs_io` for the "stat" command to see if it can fulfill your test
> > requirement.
> >
> > Due to I noticed you need information like st_nlink from struct stat, so
> > `xfs_io -c "stat -r" ...` should meet your requirements. Please
^^^^^^^^^^^^^^^^^^
Please note that I have been talking about xfs_io stat subcommand all along, rather
than the coreutils' stat command. I suspect there might be a misunderstanding here.
xfstests inherently depends on xfsprogs, particularly the xfs_io command.
I just checked this for you, the stat subcommand in xfs_io does indeed use
the fstat system call [1][2], not statx, and its -r option will print out fields
like st_nlink.
Please double-check this on your end, make sure it works for you.
Thanks,
Zorro
[1]
xfsprogs/io/stat.c:stat_f() :
int
stat_f(
int argc,
char **argv)
{
struct stat st;
int c, verbose = 0, raw = 0;
while ((c = getopt(argc, argv, "rv")) != EOF) {
switch (c) {
case 'r':
raw = 1;
break;
case 'v':
verbose = 1;
break;
default:
exitcode = 1;
return command_usage(&stat_cmd);
}
}
if (fstat(file->fd, &st) < 0) {
perror("fstat");
exitcode = 1;
return 0;
}
if (raw)
return dump_raw_stat(&st);
...
[2]
$ strace xfs_io -c "stat -r" README 2>&1|grep -E "statx|fstat"
fstat(3, {st_mode=S_IFREG|0644, st_size=106979, ...}) = 0
fstat(3, {st_mode=S_IFREG|0755, st_size=36680, ...}) = 0
fstat(3, {st_mode=S_IFREG|0755, st_size=236720, ...}) = 0
fstat(3, {st_mode=S_IFREG|0755, st_size=2482096, ...}) = 0
fstat(3, {st_mode=S_IFREG|0755, st_size=187232, ...}) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=233380912, ...}) = 0
fstat(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
newfstatat(AT_FDCWD, "/", {st_mode=S_IFDIR|0555, st_size=154, ...}, 0) = 0
newfstatat(AT_FDCWD, "/", {st_mode=S_IFDIR|0555, st_size=154, ...}, 0) = 0
newfstatat(AT_FDCWD, "/home", {st_mode=S_IFDIR|0755, st_size=10, ...}, 0) = 0
newfstatat(AT_FDCWD, "/home", {st_mode=S_IFDIR|0755, st_size=10, ...}, 0) = 0
newfstatat(AT_FDCWD, "/boot", {st_mode=S_IFDIR|0555, st_size=4096, ...}, 0) = 0
newfstatat(AT_FDCWD, "/boot", {st_mode=S_IFDIR|0555, st_size=4096, ...}, 0) = 0
newfstatat(AT_FDCWD, "/boot/efi", {st_mode=S_IFDIR|0700, st_size=4096, ...}, 0) = 0
newfstatat(AT_FDCWD, "/boot/efi", {st_mode=S_IFDIR|0700, st_size=4096, ...}, 0) = 0
newfstatat(AT_FDCWD, "README", {st_mode=S_IFREG|0644, st_size=27145, ...}, 0) = 0
fstatfs(3, {f_type=BTRFS_SUPER_MAGIC, f_bsize=4096, f_blocks=249372928, f_bfree=196292374, f_bavail=195356006, f_files=0, f_ffree=0, f_fsid={val=[0xfb10ffbe, 0x278a3f4f]}, f_namelen=255, f_frsize=4096, f_flags=ST_VALID|ST_RELATIME}) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=27145, ...}) = 0
newfstatat(AT_FDCWD, "README", {st_mode=S_IFREG|0644, st_size=27145, ...}, 0) = 0
fstatfs(3, {f_type=BTRFS_SUPER_MAGIC, f_bsize=4096, f_blocks=249372928, f_bfree=196292374, f_bavail=195356006, f_files=0, f_ffree=0, f_fsid={val=[0xfb10ffbe, 0x278a3f4f]}, f_namelen=255, f_frsize=4096, f_flags=ST_VALID|ST_RELATIME}) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=27145, ...}) = 0
fstat(4, {st_mode=S_IFREG|0644, st_size=2998, ...}) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=27145, ...}) = 0
fstat(1, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
> > give it a try, if it works, it will make the whole patch much cleaner.
> >
> > P.S. For a new test case, please don't use a specific case number (like
> > generic/795) in the subject or commit log, as it might get assigned a
> > different number when merged. You can just use something like:
> > "[PATCH] generic: new test to ..."
>
> --
> ChenXiaoSong <chenxiaosong@chenxiaosong.com>
> Chinese Homepage: https://chenxiaosong.com
> English Homepage: https://chenxiaosong.com/en
>
next parent reply other threads:[~2026-07-21 21:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260720163502.732454-1-chenxiaosong@chenxiaosong.com>
[not found] ` <al8nX7MnPDzmUA5W@zlang-mailbox>
[not found] ` <4021e03f-6d80-4a26-9112-1dc20abeed12@chenxiaosong.com>
2026-07-21 21:21 ` Zorro Lang [this message]
2026-07-22 2:50 ` [PATCH v2 xfstests 0/3] add generic/795 ChenXiaoSong
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=al_e-tLidEugZyY2@zlang-mailbox \
--to=zlang@kernel.org \
--cc=bharathsm@microsoft.com \
--cc=chenxiaosong@chenxiaosong.com \
--cc=chenxiaosong@kylinos.cn \
--cc=dhowells@redhat.com \
--cc=fstests@vger.kernel.org \
--cc=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=metze@samba.org \
--cc=pc@manguebit.org \
--cc=ronniesahlberg@gmail.com \
--cc=senozhatsky@chromium.org \
--cc=smfrench@gmail.com \
--cc=sprasad@microsoft.com \
--cc=tom@talpey.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