Skip to contentSkip to conversation

fstests: add a new test case for FS_IOC_GETFSUUID

PATCH New Qu Wenruo 1 participant 1 message Nov 24 Btrfs file system

lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

PATCH 1/1 fstests: add a new test case for FS_IOC_GETFSUUID

This is inspired by a recent btrfs patch that adds the support for that generic ioctl.

The new test case is just a simple one to make sure the ioctl returned the same value as the one reported by blkid.

Older kernels or unsupported fs will still be skipped.

---
 .gitignore            |  1 +
 configure.ac          |  1 +
 include/builddefs.in  |  1 +
 m4/package_libcdev.m4 | 14 +++++++
 src/Makefile          |  4 ++
 src/t_getfsuuid.c     | 89 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/816     | 42 ++++++++++++++++++++
 tests/generic/816.out |  2 +
 8 files changed, 154 insertions(+)
 create mode 100644 src/t_getfsuuid.c
 create mode 100755 tests/generic/816
 create mode 100644 tests/generic/816.out
.gitignore +1 -0
index cdcfa06e1119..66bea02fe236 100644
@@ -213,6 +213,7 @@ tags
 /src/perf/*.pyc
 /src/fiemap-fault
 /src/min_dio_alignment
+/src/t_getfsuuid
 /src/dio-writeback-race
 /src/unlink-fsync
 /src/file_attr
configure.ac +1 -0
index 6d7ff3ba35fa..7b4a6052fd4b 100644
@@ -75,6 +75,7 @@ AC_HAVE_FICLONE
 AC_HAVE_TRIVIAL_AUTO_VAR_INIT
 AC_HAVE_FILE_GETATTR
 AC_HAVE_FANOTIFY_FID
+AC_HAVE_FS_IOC_GETFSUUID
 
 AC_CHECK_FUNCS([renameat2])
 AC_CHECK_FUNCS([reallocarray])
include/builddefs.in +1 -0
index 8e9e2e3b4113..fe9817948673 100644
@@ -76,6 +76,7 @@ NEED_INTERNAL_XFS_IOC_EXCHANGE_RANGE = @need_internal_xfs_ioc_exchange_range@
 HAVE_FICLONE = @have_ficlone@
 HAVE_FILE_GETATTR = @have_file_getattr@
 HAVE_FANOTIFY_FID = @have_fanotify_fid@
+HAVE_FS_IOC_GETFSUUID = @have_fs_ioc_getfsuuid@
 
 GCCFLAGS = -std=gnu11 -funsigned-char -fno-strict-aliasing -Wall
 SANITIZER_CFLAGS += @autovar_init_cflags@
m4/package_libcdev.m4 +14 -0
index 340cdad3faf9..7182d9f4f129 100644
@@ -116,3 +116,17 @@ AC_DEFUN([AC_HAVE_FANOTIFY_FID],
        AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])
     AC_SUBST(have_fanotify_fid)
   ])
+
+# Check if we have FS_IOC_GETFSUUID
+AC_DEFUN([AC_HAVE_FS_IOC_GETFSUUID],
+  [ AC_MSG_CHECKING([for FS_IOC_GETFSUUID])
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+#include <sys/ioctl.h>
+#include <linux/fs.h>
+    ]], [[
+	 struct fsuuid2 u;
+	 ioctl(-1, FS_IOC_GETFSUUID, &u);
+    ]])],[have_fs_ioc_getfsuuid=yes
+       AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])
+    AC_SUBST(have_fs_ioc_getfsuuid)
+  ])
src/Makefile +4 -0
index a1fc38d88b8a..cc19abf2517a 100644
@@ -106,6 +106,10 @@ ifeq ($(HAVE_FICLONE),yes)
      LINUX_TARGETS += t_reflink_read_race
 endif
 
+ifeq ($(HAVE_FS_IOC_GETFSUUID),yes)
+     LINUX_TARGETS += t_getfsuuid
+endif
+
 ifeq ($(HAVE_FANOTIFY_FID),yes)
      LINUX_TARGETS += fs-monitor
 endif
src/t_getfsuuid.c new file +89 -0

89 lines not on this page · raw message

tests/generic/816 new file +42 -0

42 lines not on this page · raw message

tests/generic/816.out new file +2 -0
new file mode 100644
index 000000000000..a9d8f943c88c
@@ -0,0 +1,2 @@
+QA output created by 816
+Silence is golden
Signature · 1 line
2.56.1