* Re: [PATCH v2 xfstests 0/3] add generic/795
[not found] ` <4021e03f-6d80-4a26-9112-1dc20abeed12@chenxiaosong.com>
@ 2026-07-21 21:21 ` Zorro Lang
2026-07-22 2:50 ` ChenXiaoSong
0 siblings, 1 reply; 2+ messages in thread
From: Zorro Lang @ 2026-07-21 21:21 UTC (permalink / raw)
To: ChenXiaoSong
Cc: smfrench, linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
senozhatsky, dhowells, metze, linux-cifs, ChenXiaoSong, fstests
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
>
^ permalink raw reply [flat|nested] 2+ messages in thread