Skip to content

Commit 339cafe

Browse files
committed
syscalls: add file_attr05 test
Verify that `file_setattr` is correctly raising EOPNOTSUPP when filesystem doesn't support FSX operations. Regression test for 474b155adf392 ("fs: make vfs_fileattr_[get|set] return -EOPNOTSUPP"). Reviewed-by: Petr Vorel <pvorel@suse.cz> Reviewed-by: Li Wang <liwang@redhat.com> Reviewed-by: Cyril Hrubis <chrubis@suse.cz> Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
1 parent 9855506 commit 339cafe

3 files changed

Lines changed: 65 additions & 0 deletions

File tree

runtest/syscalls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ file_attr01 file_attr01
253253
file_attr02 file_attr02
254254
file_attr03 file_attr03
255255
file_attr04 file_attr04
256+
file_attr05 file_attr05
256257

257258
#posix_fadvise test cases
258259
posix_fadvise01 posix_fadvise01

testcases/kernel/syscalls/file_attr/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ file_attr01
22
file_attr02
33
file_attr03
44
file_attr04
5+
file_attr05
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
/*
3+
* Copyright (C) 2025 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
4+
*/
5+
6+
/*\
7+
* Verify that `file_setattr` is correctly raising EOPNOTSUPP when filesystem
8+
* doesn't support FSX operations.
9+
*/
10+
11+
#include "tst_test.h"
12+
#include "lapi/fs.h"
13+
14+
#define MNTPOINT "mntpoint"
15+
#define FILEPATH (MNTPOINT "/ltp_file")
16+
#define BLOCKS 128
17+
#define PROJID 16
18+
19+
static struct file_attr *attr_set;
20+
21+
static void run(void)
22+
{
23+
TST_EXP_FAIL(file_setattr(AT_FDCWD, FILEPATH,
24+
attr_set, FILE_ATTR_SIZE_LATEST, 0), EOPNOTSUPP);
25+
}
26+
27+
static void setup(void)
28+
{
29+
struct stat statbuf;
30+
31+
SAFE_TOUCH(FILEPATH, 0777, NULL);
32+
33+
SAFE_STAT(MNTPOINT, &statbuf);
34+
35+
attr_set->fa_xflags |= FS_XFLAG_EXTSIZE;
36+
attr_set->fa_xflags |= FS_XFLAG_COWEXTSIZE;
37+
attr_set->fa_extsize = BLOCKS * statbuf.st_blksize;
38+
attr_set->fa_cowextsize = BLOCKS * statbuf.st_blksize;
39+
attr_set->fa_projid = PROJID;
40+
}
41+
42+
static struct tst_test test = {
43+
.test_all = run,
44+
.setup = setup,
45+
.mntpoint = MNTPOINT,
46+
.needs_root = 1,
47+
.mount_device = 1,
48+
.all_filesystems = 1,
49+
.skip_filesystems = (const char *const []) {
50+
"xfs",
51+
"fuse", /* EINVAL is raised before EOPNOTSUPP */
52+
"vfat", /* vfat is not implementing file_[set|get]attr */
53+
NULL,
54+
},
55+
.bufs = (struct tst_buffers []) {
56+
{&attr_set, .size = sizeof(struct file_attr)},
57+
{}
58+
},
59+
.tags = (const struct tst_tag[]) {
60+
{"linux-git", "474b155adf392"},
61+
{},
62+
}
63+
};

0 commit comments

Comments
 (0)