@@ -178,6 +178,11 @@ const char **tst_get_supported_fs_types(void);
*/
void tst_fill_fs(const char *path, int verbose);
+/*
+ * test if FIBMAP ioctl is supported
+ */
+int tst_fibmap(const char *filename);
+
#ifdef TST_TEST_H__
static inline long tst_fs_type(const char *path)
{
new file mode 100644
@@ -0,0 +1,37 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <linux/fs.h>
+
+#define TST_NO_DEFAULT_MAIN
+
+#include "tst_test.h"
+
+int tst_fibmap(const char *filename)
+{
+ /* test if FIBMAP ioctl is supported */
+ int fd, block = 0;
+
+ fd = open(filename, O_RDWR | O_CREAT, 0666);
+ if (fd < 0) {
+ tst_res(TWARN | TERRNO,
+ "open(%s, O_RDWR | O_CREAT, 0666) failed", filename);
+ return -1;
+ }
+
+ if (ioctl(fd, FIBMAP, &block)) {
+ tst_res(TINFO | TERRNO, "FIBMAP ioctl is NOT supported");
+ close(fd);
+ return 1;
+ }
+ tst_res(TINFO, "FIBMAP ioctl is supported");
+
+ if (close(fd)) {
+ tst_res(TWARN | TERRNO, "close(fd) failed");
+ return -1;
+ }
+ return 0;
+}