[LTP] [PATCH v3] syscalls: add file_attr05 test

Petr Vorel pvorel@suse.cz
Tue Jan 20 13:43:23 CET 2026


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.

> +		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.

Kind regards,
Petr

> +		{}
> +	}
> +};


More information about the ltp mailing list