[LTP] [PATCH 3/3] file_attr02: Simplify device mounting
Martin Doucha
mdoucha@suse.cz
Fri Aug 14 14:49:38 CEST 2026
The file_attr02 test creates an XFS partition with reflinks enabled.
However, some kernels cannot mount such partitions so the test
needs to check kernel support. The LTP library can now do the check
internally so use this feature instead of mounting explicitly in setup().
Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
.../kernel/syscalls/file_attr/file_attr02.c | 17 +++--------------
1 file changed, 3 insertions(+), 14 deletions(-)
diff --git a/testcases/kernel/syscalls/file_attr/file_attr02.c b/testcases/kernel/syscalls/file_attr/file_attr02.c
index f6625985a..0adfa5f6e 100644
--- a/testcases/kernel/syscalls/file_attr/file_attr02.c
+++ b/testcases/kernel/syscalls/file_attr/file_attr02.c
@@ -9,7 +9,6 @@
* currently implementing the features we need.
*/
-#include <sys/mount.h>
#include "tst_test.h"
#include "lapi/fs.h"
@@ -44,15 +43,6 @@ static void setup(void)
{
struct stat statbuf;
- SAFE_MKDIR(MNTPOINT, 0755);
- TEST(mount(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL));
-
- if (TST_RET == -1 && TST_ERR == EOPNOTSUPP)
- tst_brk(TCONF, "Kernel does not support XFS reflinks");
-
- if (TST_RET)
- tst_brk(TBROK | TTERRNO, "Mount failed");
-
SAFE_STAT(MNTPOINT, &statbuf);
dfd = SAFE_OPEN(MNTPOINT, O_RDONLY);
@@ -82,9 +72,6 @@ static void cleanup(void)
if (dfd != -1)
SAFE_CLOSE(dfd);
-
- if (tst_is_mounted(MNTPOINT))
- SAFE_UMOUNT(MNTPOINT);
}
static struct tst_test test = {
@@ -92,10 +79,12 @@ static struct tst_test test = {
.setup = setup,
.cleanup = cleanup,
.needs_root = 1,
- .format_device = 1,
+ .mount_device = 1,
+ .mntpoint = MNTPOINT,
.filesystems = (struct tst_fs []) {
{
.type = "xfs",
+ .mount_check_support = 1,
.mkfs_opts = (const char *const[]){
"-m", "reflink=1", NULL
},
--
2.54.0
More information about the ltp
mailing list