[LTP] [PATCH v3] syscalls: add file_attr05 test
Andrea Cervesato
andrea.cervesato@suse.com
Tue Jan 20 14:22:41 CET 2026
On Tue Jan 20, 2026 at 1:43 PM CET, Petr Vorel wrote:
> Hi Andrea,
>
> > From: Andrea Cervesato <andrea.cervesato@suse.com>
>
> > Verify that `file_setattr` is correctly raising EOPNOTSUPP when
> > filesystem doesn't support FSX operations.
>
> > Regression test for "474b155adf39 - fs: make vfs_fileattr_[get|set]
> > return -EOPNOTSUPP".
>
> Reason for changing approach in v3:
> https://lore.kernel.org/ltp/DFTCS1EEBMDD.21X779ISM0MTF@suse.com/
>
> > +++ b/testcases/kernel/syscalls/file_attr/file_attr05.c
> > @@ -0,0 +1,63 @@
> > +// SPDX-License-Identifier: GPL-2.0-or-later
> > +/*
> > + * Copyright (C) 2025 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
> > + */
> > +
> > +/*\
> > + * Verify that `file_setattr` is correctly raising EOPNOTSUPP when filesystem
> > + * doesn't support FSX operations.
> > + *
> > + * Regression test for "474b155adf39 - fs: make vfs_fileattr_[get|set] return
> > + * -EOPNOTSUPP".
> Why not added into .tags?
> nit: Also the usual way of referring commits is:
> 474b155adf392 ("fs: make vfs_fileattr_[get|set] return -EOPNOTSUPP")
>
> > + */
> > +
> > +#include "tst_test.h"
> > +#include "lapi/fs.h"
> > +
> > +#define MNTPOINT "mntpoint"
> > +#define FILEPATH (MNTPOINT "/ltp_file")
> > +#define BLOCKS 128
> > +#define PROJID 16
> > +
> > +static struct file_attr *attr_set;
> > +
> > +static void run(void)
> > +{
> > + TST_EXP_FAIL(file_setattr(AT_FDCWD, FILEPATH,
> > + attr_set, FILE_ATTR_SIZE_LATEST, 0), EOPNOTSUPP);
> > +}
> > +
> > +static void setup(void)
> > +{
> > + struct stat statbuf;
> > +
> > + SAFE_TOUCH(FILEPATH, 0777, NULL);
> > +
> > + SAFE_STAT(MNTPOINT, &statbuf);
> > +
> > + attr_set->fa_xflags |= FS_XFLAG_EXTSIZE;
> > + attr_set->fa_xflags |= FS_XFLAG_COWEXTSIZE;
> > + attr_set->fa_extsize = BLOCKS * statbuf.st_blksize;
> > + attr_set->fa_cowextsize = BLOCKS * statbuf.st_blksize;
> > + attr_set->fa_projid = PROJID;
> > +}
> > +
> > +static struct tst_test test = {
> > + .test_all = run,
> > + .setup = setup,
> > + .mntpoint = MNTPOINT,
> > + .needs_root = 1,
> > + .mount_device = 1,
> > + .all_filesystems = 1,
> > + .format_device = 1,
> > + .skip_filesystems = (const char *const []) {
> > + "xfs",
> > + "fuse", /* EINVAL is raised before EOPNOTSUPP */
> > + "vfat", /* vfat is not implementing file_[set|get]attr */
>
> Hm, funny, vfat not implementing also raises EOPNOTSUPP. I wonder if we should
> keep it as well.
It makes sense from the point of view of the results, but it doesn't
make sense from the point of view of the test's meaning. EOPNOTSUPP in
case of vfat is raised for other reasons.
>
> > + NULL,
> > + },
> > + .bufs = (struct tst_buffers []) {
> > + {&attr_set, .size = sizeof(struct file_attr)},
> Again, I'd put 474b155adf392 into tags. It's IMHO enough (no need for mentioning
> it in the docs.
Sorry I forgot, I'm going to send a v4.
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
More information about the ltp
mailing list