All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin Doucha <mdoucha@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 1/3] struct tst_fs: Add flag for checking filesystem mount support in kernel
Date: Fri, 14 Aug 2026 14:49:36 +0200	[thread overview]
Message-ID: <20260814124943.36853-2-mdoucha@suse.cz> (raw)
In-Reply-To: <20260814124943.36853-1-mdoucha@suse.cz>

Add flag for skipping filesystem if mount() fails with EOPNOTSUPP. This
error usually happens when special mkfs options are not supported
by the kernel.

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
 include/old/tso_safe_macros.h |  2 +-
 include/safe_macros_fn.h      |  2 +-
 include/tst_safe_macros.h     |  7 ++++---
 include/tst_test.h            |  4 ++++
 lib/safe_macros.c             | 14 ++++++++++----
 lib/tst_test.c                |  3 ++-
 6 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/include/old/tso_safe_macros.h b/include/old/tso_safe_macros.h
index f3965cc68..fec31e666 100644
--- a/include/old/tso_safe_macros.h
+++ b/include/old/tso_safe_macros.h
@@ -154,7 +154,7 @@
 #define SAFE_MOUNT(cleanup_fn, source, target, filesystemtype, \
 		   mountflags, data) \
 	safe_mount(__FILE__, __LINE__, (cleanup_fn), (source), (target), \
-		   (filesystemtype), (mountflags), (data), NULL)
+		   (filesystemtype), (mountflags), (data), NULL, 0)
 
 #define SAFE_UMOUNT(cleanup_fn, target) \
 	safe_umount(__FILE__, __LINE__, (cleanup_fn), (target))
diff --git a/include/safe_macros_fn.h b/include/safe_macros_fn.h
index e8dc02539..f01378b0a 100644
--- a/include/safe_macros_fn.h
+++ b/include/safe_macros_fn.h
@@ -187,7 +187,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, int *is_fuse);
+	       const void *data, int *is_fuse, unsigned int check_support);
 
 int safe_umount(const char *file, const int lineno, void (*cleanup_fn)(void),
 		const char *target);
diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
index 91a130a48..55ca2bf8b 100644
--- a/include/tst_safe_macros.h
+++ b/include/tst_safe_macros.h
@@ -245,12 +245,13 @@ 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), NULL)
+		   (filesystemtype), (mountflags), (data), NULL, 0)
 
 #define SAFE_MOUNT2(source, target, filesystemtype, \
-		    mountflags, data, is_fuse) \
+		    mountflags, data, is_fuse, check_support) \
 	safe_mount(__FILE__, __LINE__, NULL, (source), (target), \
-		   (filesystemtype), (mountflags), (data), (is_fuse))
+		   (filesystemtype), (mountflags), (data), (is_fuse), \
+		   (check_support))
 
 #define SAFE_UMOUNT(target) \
 	safe_umount(__FILE__, __LINE__, NULL, (target))
diff --git a/include/tst_test.h b/include/tst_test.h
index c69362485..d3de042db 100644
--- a/include/tst_test.h
+++ b/include/tst_test.h
@@ -280,6 +280,8 @@ struct tst_ulimit_val {
  *
  * @min_kver: A minimum kernel version supporting the filesystem which has been
  *            created with mkfs.
+ *
+ * @mount_check_support: Skip this filesystem if mount() fails with EOPNOTSUPP.
  */
 struct tst_fs {
 	const char *type;
@@ -292,6 +294,8 @@ struct tst_fs {
 	const void *mnt_data;
 
 	const char *min_kver;
+
+	unsigned int mount_check_support:1;
 };
 
 /**
diff --git a/lib/safe_macros.c b/lib/safe_macros.c
index f95c5fdc5..187550041 100644
--- a/lib/safe_macros.c
+++ b/lib/safe_macros.c
@@ -930,7 +930,7 @@ 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, int *is_fuse)
+	       const void *data, int *is_fuse, unsigned int check_support)
 {
 	int rval = -1;
 	char mpath[PATH_MAX];
@@ -993,9 +993,15 @@ int safe_mount(const char *file, const int lineno, void (*cleanup_fn)(void),
 			"mount.%s failed with %i", filesystemtype, rval);
 		return -1;
 	} else if (rval == -1) {
-		tst_brkm_(file, lineno, TBROK | TERRNO, cleanup_fn,
-			"mount(%s, %s, %s, %lu, %p) failed", source, target,
-			filesystemtype, mountflags, data);
+		if (check_support && errno == EOPNOTSUPP) {
+			tst_brkm_(file, lineno, TCONF | TERRNO, cleanup_fn,
+				"Kernel does not support required %s features",
+				filesystemtype);
+		} else {
+			tst_brkm_(file, lineno, TBROK | TERRNO, cleanup_fn,
+				"mount(%s, %s, %s, %lu, %p) failed", source,
+				target, filesystemtype, mountflags, data);
+		}
 	} else {
 		tst_brkm_(file, lineno, TBROK | TERRNO, cleanup_fn,
 			"Invalid mount(%s, %s, %s, %lu, %p) return value %d",
diff --git a/lib/tst_test.c b/lib/tst_test.c
index 9c5f2617f..166e0f672 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -1301,7 +1301,8 @@ static void prepare_device(struct tst_fs *fs)
 				buf, sizeof(buf), tdev.fs_type);
 
 		SAFE_MOUNT2(get_device_name(tdev.fs_type), tst_test->mntpoint,
-				tdev.fs_type, fs->mnt_flags, mnt_data, &tdev.is_fuse);
+				tdev.fs_type, fs->mnt_flags, mnt_data,
+				&tdev.is_fuse, fs->mount_check_support);
 		context->mntpoint_mounted = 1;
 	}
 }
-- 
2.54.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2026-08-14 12:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-14 12:49 [LTP] [PATCH 0/3] Add optional kernel support checks for filesystem features Martin Doucha
2026-08-14 12:49 ` Martin Doucha [this message]
2026-08-14 13:05   ` [LTP] struct tst_fs: Add flag for checking filesystem mount support in kernel linuxtestproject.agent
2026-08-14 12:49 ` [LTP] [PATCH 2/3] refluxfs: Check kernel reflink support before mount Martin Doucha
2026-08-14 12:49 ` [LTP] [PATCH 3/3] file_attr02: Simplify device mounting Martin Doucha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260814124943.36853-2-mdoucha@suse.cz \
    --to=mdoucha@suse.cz \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.