[LTP] [PATCH v3 3/3] lib: mount tmpfs name as ltp-tmpfs

Li Wang liwang@redhat.com
Fri Jul 9 09:52:04 CEST 2021


Given a specific name as "ltp-tmpfs" instead of the "/dev/loopX"
string in order to make "tmpfs" filesystem more evident.

Achieve that in get_device_name() function.

Suggested-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Li Wang <liwang@redhat.com>
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
---
 lib/tst_test.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/lib/tst_test.c b/lib/tst_test.c
index b996f1b2e..f4d9f8e3b 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -898,6 +898,14 @@ static char *limit_tmpfs_mount_size(const char *mnt_data,
 	return buf;
 }
 
+static const char *get_device_name(const char *fs_type)
+{
+       if (!strcmp(fs_type, "tmpfs"))
+               return "ltp-tmpfs";
+       else
+               return tdev.dev;
+}
+
 static void prepare_device(void)
 {
 	char *mnt_data, buf[1024];
@@ -917,8 +925,8 @@ static void prepare_device(void)
 		mnt_data = limit_tmpfs_mount_size(tst_test->mnt_data,
 				buf, sizeof(buf), tdev.fs_type);
 
-		SAFE_MOUNT(tdev.dev, tst_test->mntpoint, tdev.fs_type,
-			   tst_test->mnt_flags, mnt_data);
+		SAFE_MOUNT(get_device_name(tdev.fs_type), tst_test->mntpoint,
+				tdev.fs_type, tst_test->mnt_flags, mnt_data);
 		mntpoint_mounted = 1;
 	}
 }
-- 
2.31.1



More information about the ltp mailing list