Skip to contentSkip to conversation

lib: Add is_fuse flag to SAFE_MOUNT() and tst_device

PATCH In review Cyril Hrubis 2 participants 10 messages Jun 30, 2025 – Sep 9, 2025 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 lib: Add is_fuse flag to SAFE_MOUNT() and tst_device

This allows us to adjust tests that need different expectations on FUSE based filesystems.

---
 include/old/safe_macros.h |  2 +-
 include/safe_macros_fn.h  |  2 +-
 include/tst_device.h      |  2 ++
 include/tst_safe_macros.h |  7 ++++++-
 lib/safe_macros.c         | 10 ++++++++--
 lib/tst_test.c            |  4 ++--
 6 files changed, 20 insertions(+), 7 deletions(-)
include/old/safe_macros.h +1 -1
index fb1d7a110..307843ab0 100644
@@ -150,7 +150,7 @@
 #define SAFE_MOUNT(cleanup_fn, source, target, filesystemtype, \
 		   mountflags, data) \
 	safe_mount(__FILE__, __LINE__, (cleanup_fn), (source), (target), \
-		   (filesystemtype), (mountflags), (data))
+		   (filesystemtype), (mountflags), (data), NULL)
 
 #define SAFE_UMOUNT(cleanup_fn, target) \
 	safe_umount(__FILE__, __LINE__, (cleanup_fn), (target))
include/safe_macros_fn.h +1 -1
index d256091b7..b4be482c1 100644
@@ -172,7 +172,7 @@ int safe_rename(const char *file, const int lineno, void (*cleanup_fn)(void),
 int safe_mount(const char *file, const int lineno, void (*cleanup_fn)(void),
 	       const char *source, const char *target,
 	       const char *filesystemtype, unsigned long mountflags,
-	       const void *data);
+	       const void *data, int *is_fuse);
 
 int safe_umount(const char *file, const int lineno, void (*cleanup_fn)(void),
 		const char *target);
include/tst_device.h +2 -0
index 2597fb4e2..9ca802735 100644
@@ -15,6 +15,8 @@ struct tst_device {
 	const char *dev;
 	const char *fs_type;
 	uint64_t size;
+	/* If device was mounted by the test library this flag is set for fuse fileystems. */
+	int is_fuse;
 };
 
 /*
include/tst_safe_macros.h +6 -1
index 19504beb5..6d53c0bbc 100644
@@ -241,7 +241,12 @@ int safe_getgroups(const char *file, const int lineno, int size, gid_t list[]);
 #define SAFE_MOUNT(source, target, filesystemtype, \
 		   mountflags, data) \
 	safe_mount(__FILE__, __LINE__, NULL, (source), (target), \
-		   (filesystemtype), (mountflags), (data))
+		   (filesystemtype), (mountflags), (data), NULL)
+
+#define SAFE_MOUNT2(source, target, filesystemtype, \
+		    mountflags, data, is_fuse) \
+	safe_mount(__FILE__, __LINE__, NULL, (source), (target), \
+		   (filesystemtype), (mountflags), (data), (is_fuse))
 
 #define SAFE_UMOUNT(target) \
 	safe_umount(__FILE__, __LINE__, NULL, (target))
lib/safe_macros.c +8 -2
index 726c9ae8e..6d267522f 100644
@@ -907,11 +907,14 @@ static int possibly_fuse(const char *fs_type)
 int safe_mount(const char *file, const int lineno, void (*cleanup_fn)(void),
 	       const char *source, const char *target,
 	       const char *filesystemtype, unsigned long mountflags,
-	       const void *data)
+	       const void *data, int *is_fuse)
 {
 	int rval = -1;
 	char mpath[PATH_MAX];
 
+	if (is_fuse)
+		*is_fuse = 0;
+
 	if (realpath(target, mpath)) {
 		tst_resm_(file, lineno, TINFO,
 			"Mounting %s to %s fstyp=%s flags=%lx",
@@ -957,8 +960,11 @@ int safe_mount(const char *file, const int lineno, void (*cleanup_fn)(void),
 			filesystemtype, mount_ro, source, target);
 
 		rval = tst_system(buf);
-		if (WIFEXITED(rval) && WEXITSTATUS(rval) == 0)
+		if (WIFEXITED(rval) && WEXITSTATUS(rval) == 0) {
+			if (is_fuse)
+				*is_fuse = 1;
 			return 0;
+		}
 
 		tst_brkm_(file, lineno, TBROK, cleanup_fn,
 			"mount.%s failed with %i", filesystemtype, rval);
lib/tst_test.c +2 -2
index 17ce91932..2130e4be8 100644
@@ -1273,8 +1273,8 @@ static void prepare_device(struct tst_fs *fs)
 		mnt_data = limit_tmpfs_mount_size(fs->mnt_data,
 				buf, sizeof(buf), tdev.fs_type);
 
-		SAFE_MOUNT(get_device_name(tdev.fs_type), tst_test->mntpoint,
-				tdev.fs_type, fs->mnt_flags, mnt_data);
+		SAFE_MOUNT2(get_device_name(tdev.fs_type), tst_test->mntpoint,
+				tdev.fs_type, fs->mnt_flags, mnt_data, &tdev.is_fuse);
 		context->mntpoint_mounted = 1;
 	}
 }
Signature · 5 lines
2.49.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

PATCH 2/2 syscalls/statmount06: Fix and enable the test on FUSE

---
 testcases/kernel/syscalls/statmount/statmount06.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
testcases/kernel/syscalls/statmount/statmount06.c +3 -5
index fe41d5b87..89717a3fb 100644
@@ -36,8 +36,10 @@ static void run(void)
 	if (!TST_PASS)
 		return;
 
+	const char *fs_type = tst_device->is_fuse ? "fuseblk" : tst_device->fs_type;
+
 	TST_EXP_EQ_LI(st_mount->mask, STATMOUNT_FS_TYPE);
-	TST_EXP_EQ_STR(st_mount->str + st_mount->fs_type, tst_device->fs_type);
+	TST_EXP_EQ_STR(st_mount->str + st_mount->fs_type, fs_type);
 }
 
 static void setup(void)
@@ -55,10 +57,6 @@ static struct tst_test test = {
 	.mount_device = 1,
 	.mntpoint = MNTPOINT,
 	.all_filesystems = 1,
-	.skip_filesystems = (const char *const []) {
-		"fuse",
-		NULL
-	},
 	.bufs = (struct tst_buffers []) {
 		{&st_mount, .size = SM_SIZE},
 		{}
Signature · 5 lines
2.49.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by Wei Gao on v1 2/2
#2 lore raw

Re: [LTP] [PATCH 2/2] syscalls/statmount06: Fix and enable the test on FUSE

Quoted 35 lines · Cyril Hrubis
---
 testcases/kernel/syscalls/statmount/statmount06.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
testcases/kernel/syscalls/statmount/statmount06.c +3 -5
index fe41d5b87..89717a3fb 100644
@@ -36,8 +36,10 @@ static void run(void)
 	if (!TST_PASS)
 		return;
 
+	const char *fs_type = tst_device->is_fuse ? "fuseblk" : tst_device->fs_type;
+
 	TST_EXP_EQ_LI(st_mount->mask, STATMOUNT_FS_TYPE);
-	TST_EXP_EQ_STR(st_mount->str + st_mount->fs_type, tst_device->fs_type);
+	TST_EXP_EQ_STR(st_mount->str + st_mount->fs_type, fs_type);
 }
 
 static void setup(void)
@@ -55,10 +57,6 @@ static struct tst_test test = {
 	.mount_device = 1,
 	.mntpoint = MNTPOINT,
 	.all_filesystems = 1,
-	.skip_filesystems = (const char *const []) {
-		"fuse",
-		NULL
-	},
 	.bufs = (struct tst_buffers []) {
 		{&st_mount, .size = SM_SIZE},
 		{}
Signature · 1 line
2.49.0
Quoted 4 lines
Signature · 2 lines
-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw

Re: [LTP] [PATCH 2/2] syscalls/statmount06: Fix and enable the test on FUSE

Hi!
Patchset pushed, thanks for the reviews.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#5 lore raw
In reply to Cyril Hrubis

Hi!
FYI the CI fails here because it needs to be applied over the first patch for SAFE_MOUNT(). I should have probably send the changes as a single patcheset.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#6 lore raw

Hi!

Quoted 3 lines

FYI the CI fails here because it needs to be applied over the first patch for SAFE_MOUNT(). I should have probably send the changes as a single patcheset.

Ping. Can anyone have a look please?

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#7 lore raw
In reply to Cyril Hrubis
Quoted 4 lines · Cyril Hrubis

This allows us to adjust tests that need different expectations on FUSE based filesystems.

Very nit: Reported-by: Jan Polensky <[email protected]> Is there any issue link can be provide?

Quoted 120 lines
---
 include/old/safe_macros.h |  2 +-
 include/safe_macros_fn.h  |  2 +-
 include/tst_device.h      |  2 ++
 include/tst_safe_macros.h |  7 ++++++-
 lib/safe_macros.c         | 10 ++++++++--
 lib/tst_test.c            |  4 ++--
 6 files changed, 20 insertions(+), 7 deletions(-)
include/old/safe_macros.h +1 -1
index fb1d7a110..307843ab0 100644
@@ -150,7 +150,7 @@
 #define SAFE_MOUNT(cleanup_fn, source, target, filesystemtype, \
 		   mountflags, data) \
 	safe_mount(__FILE__, __LINE__, (cleanup_fn), (source), (target), \
-		   (filesystemtype), (mountflags), (data))
+		   (filesystemtype), (mountflags), (data), NULL)
 
 #define SAFE_UMOUNT(cleanup_fn, target) \
 	safe_umount(__FILE__, __LINE__, (cleanup_fn), (target))
include/safe_macros_fn.h +1 -1
index d256091b7..b4be482c1 100644
@@ -172,7 +172,7 @@ int safe_rename(const char *file, const int lineno, void (*cleanup_fn)(void),
 int safe_mount(const char *file, const int lineno, void (*cleanup_fn)(void),
 	       const char *source, const char *target,
 	       const char *filesystemtype, unsigned long mountflags,
-	       const void *data);
+	       const void *data, int *is_fuse);
 
 int safe_umount(const char *file, const int lineno, void (*cleanup_fn)(void),
 		const char *target);
include/tst_device.h +2 -0
index 2597fb4e2..9ca802735 100644
@@ -15,6 +15,8 @@ struct tst_device {
 	const char *dev;
 	const char *fs_type;
 	uint64_t size;
+	/* If device was mounted by the test library this flag is set for fuse fileystems. */
+	int is_fuse;
 };
 
 /*
include/tst_safe_macros.h +6 -1
index 19504beb5..6d53c0bbc 100644
@@ -241,7 +241,12 @@ int safe_getgroups(const char *file, const int lineno, int size, gid_t list[]);
 #define SAFE_MOUNT(source, target, filesystemtype, \
 		   mountflags, data) \
 	safe_mount(__FILE__, __LINE__, NULL, (source), (target), \
-		   (filesystemtype), (mountflags), (data))
+		   (filesystemtype), (mountflags), (data), NULL)
+
+#define SAFE_MOUNT2(source, target, filesystemtype, \
+		    mountflags, data, is_fuse) \
+	safe_mount(__FILE__, __LINE__, NULL, (source), (target), \
+		   (filesystemtype), (mountflags), (data), (is_fuse))
 
 #define SAFE_UMOUNT(target) \
 	safe_umount(__FILE__, __LINE__, NULL, (target))
lib/safe_macros.c +8 -2
index 726c9ae8e..6d267522f 100644
@@ -907,11 +907,14 @@ static int possibly_fuse(const char *fs_type)
 int safe_mount(const char *file, const int lineno, void (*cleanup_fn)(void),
 	       const char *source, const char *target,
 	       const char *filesystemtype, unsigned long mountflags,
-	       const void *data)
+	       const void *data, int *is_fuse)
 {
 	int rval = -1;
 	char mpath[PATH_MAX];
 
+	if (is_fuse)
+		*is_fuse = 0;
+
 	if (realpath(target, mpath)) {
 		tst_resm_(file, lineno, TINFO,
 			"Mounting %s to %s fstyp=%s flags=%lx",
@@ -957,8 +960,11 @@ int safe_mount(const char *file, const int lineno, void (*cleanup_fn)(void),
 			filesystemtype, mount_ro, source, target);
 
 		rval = tst_system(buf);
-		if (WIFEXITED(rval) && WEXITSTATUS(rval) == 0)
+		if (WIFEXITED(rval) && WEXITSTATUS(rval) == 0) {
+			if (is_fuse)
+				*is_fuse = 1;
 			return 0;
+		}
 
 		tst_brkm_(file, lineno, TBROK, cleanup_fn,
 			"mount.%s failed with %i", filesystemtype, rval);
lib/tst_test.c +2 -2
index 17ce91932..2130e4be8 100644
@@ -1273,8 +1273,8 @@ static void prepare_device(struct tst_fs *fs)
 		mnt_data = limit_tmpfs_mount_size(fs->mnt_data,
 				buf, sizeof(buf), tdev.fs_type);
 
-		SAFE_MOUNT(get_device_name(tdev.fs_type), tst_test->mntpoint,
-				tdev.fs_type, fs->mnt_flags, mnt_data);
+		SAFE_MOUNT2(get_device_name(tdev.fs_type), tst_test->mntpoint,
+				tdev.fs_type, fs->mnt_flags, mnt_data, &tdev.is_fuse);
 		context->mntpoint_mounted = 1;
 	}
 }
Signature · 5 lines
2.49.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp