lib: Add tst_dev_fs_type() function

The function returns filesystem type to be used for testing.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt
index c080d6d..af31d38 100644
--- a/doc/test-writing-guidelines.txt
+++ b/doc/test-writing-guidelines.txt
@@ -774,6 +774,20 @@
 -------------------------------------------------------------------------------
 #include "test.h"
 
+const char *tst_dev_fs_type(void);
+-------------------------------------------------------------------------------
+
+Returns name of filesystem that should be used for tests. Unless is your test
+designed to test specific filesystem you should use this function to select
+filesystem for the 'tst_mkfs()'.
+
+NOTE: The default filesytem is hardcoded to 'ext2' in the sources and can be
+      overridden by setting 'LTP_DEV_FS_TYPE' environment variable.
+
+[source,c]
+-------------------------------------------------------------------------------
+#include "test.h"
+
 void tst_mkfs(void (cleanup_fn)(void), const char *dev,
               const char *fs_type, const char *const fs_opts[]);
 -------------------------------------------------------------------------------
diff --git a/include/test.h b/include/test.h
index 086649e..97ce0f0 100644
--- a/include/test.h
+++ b/include/test.h
@@ -281,6 +281,16 @@
 void tst_mkfs(void (cleanup_fn)(void), const char *dev,
 	      const char *fs_type, const char *const fs_opts[]);
 
+/*
+ * Returns filesystem type to be used for the testing. Unless your test is
+ * designed for specific filesystem you should use this function to the tested
+ * filesytem.
+ *
+ * If TST_DEV_FS_TYPE is set the function returns it's content,
+ * otherwise default fs type hardcoded in the library is returned.
+ */
+const char *tst_dev_fs_type(void);
+
 /* lib/tst_device.c
  *
  * Acquires test device.
diff --git a/lib/ltp_priv.h b/lib/ltp_priv.h
index 8fec67f..9507e9d 100644
--- a/lib/ltp_priv.h
+++ b/lib/ltp_priv.h
@@ -32,6 +32,11 @@
  */
 #define TEMPDIR	"/tmp"
 
+/*
+ * Default filesystem to be used for tests.
+ */
+#define DEFAULT_FS_TYPE "ext2"
+
 /* environment variables for controlling  tst_res verbosity */
 #define TOUT_VERBOSE_S  "VERBOSE"	/* All test cases reported */
 #define TOUT_NOPASS_S   "NOPASS"	/* No pass test cases are reported */
diff --git a/lib/tst_mkfs.c b/lib/tst_mkfs.c
index 115019d..5eb3392 100644
--- a/lib/tst_mkfs.c
+++ b/lib/tst_mkfs.c
@@ -17,8 +17,9 @@
  */
 
 #include "test.h"
+#include "ltp_priv.h"
 
-#define OPTS_MAX 32u
+#define OPTS_MAX 32
 
 void tst_mkfs(void (cleanup_fn)(void), const char *dev,
 	      const char *fs_type, const char *const fs_opts[])
@@ -73,3 +74,15 @@
 		 dev, fs_type, fs_opts_str);
 	tst_run_cmd(cleanup_fn, argv, "/dev/null", NULL);
 }
+
+const char *tst_dev_fs_type(void)
+{
+	const char *fs_type;
+
+	fs_type = getenv("LTP_DEV_FS_TYPE");
+
+	if (fs_type)
+		return fs_type;
+
+	return DEFAULT_FS_TYPE;
+}