xfstests: add fuse support

This allows using any fuse filesystem that can be mounted with

  mount -t fuse$FUSE_SUBTYP ...

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Jakob Unterwurzacher <jakobunt@gmail.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
diff --git a/README.fuse b/README.fuse
new file mode 100644
index 0000000..969dbd5
--- /dev/null
+++ b/README.fuse
@@ -0,0 +1,26 @@
+Here are instructions for testing fuse using the passthrough_ll example
+filesystem provided in the libfuse source tree:
+
+git clone git://github.com/libfuse/libfuse.git
+cd libfuse
+meson build
+cd build
+ninja
+cat << EOF | sudo tee /sbin/mount.fuse.passthrough_ll
+#!/bin/bash
+ulimit -n 1048576
+exec $(pwd)/example/passthrough_ll -ofsname="\$@"
+EOF
+sudo chmod +x /sbin/mount.fuse.passthrough_ll
+mkdir -p /mnt/test /mnt/scratch /home/test/test /home/test/scratch
+
+Use the following local.config file:
+
+export TEST_DEV=non1
+export TEST_DIR=/mnt/test
+export SCRATCH_DEV=non2
+export SCRATCH_MNT=/mnt/scratch
+export FSTYP=fuse
+export FUSE_SUBTYP=.passthrough_ll
+export MOUNT_OPTIONS="-osource=/home/test/scratch,allow_other,default_permissions"
+export TEST_FS_MOUNT_OPTS="-osource=/home/test/test,allow_other,default_permissions"
diff --git a/check b/check
index 2206293..0bf5b22 100755
--- a/check
+++ b/check
@@ -60,6 +60,7 @@
     -glusterfs		test GlusterFS
     -cifs		test CIFS
     -9p			test 9p
+    -fuse		test fuse
     -virtiofs		test virtiofs
     -overlay		test overlay
     -pvfs2		test PVFS2
@@ -279,7 +280,7 @@
 	case "$1" in
 	-\? | -h | --help) usage ;;
 
-	-nfs|-glusterfs|-cifs|-9p|-virtiofs|-pvfs2|-tmpfs|-ubifs)
+	-nfs|-glusterfs|-cifs|-9p|-fuse|-virtiofs|-pvfs2|-tmpfs|-ubifs)
 		FSTYP="${1:1}"
 		;;
 	-overlay)
diff --git a/common/config b/common/config
index e2aba5a..6c8cb3a 100644
--- a/common/config
+++ b/common/config
@@ -341,6 +341,9 @@
 	9p)
 		echo $PLAN9_MOUNT_OPTIONS
 		;;
+	fuse)
+		echo $FUSE_MOUNT_OPTIONS
+		;;
 	xfs)
 		echo $XFS_MOUNT_OPTIONS
 		;;
@@ -511,6 +514,8 @@
 		;;
 	9p)
 		;;
+	fuse)
+		;;
 	ceph)
 		. ./common/ceph
 		;;
@@ -583,8 +588,8 @@
 	fi
 
 	case "$FSTYP" in
-	9p|tmpfs|virtiofs)
-		# 9p and virtiofs mount tags are just plain strings, so anything is allowed
+	9p|fuse|tmpfs|virtiofs)
+		# 9p, fuse and virtiofs mount tags are just plain strings, so anything is allowed
 		# tmpfs doesn't use mount source, ignore
 		;;
 	ceph)
diff --git a/common/rc b/common/rc
index 81ce102..36eb90e 100644
--- a/common/rc
+++ b/common/rc
@@ -261,7 +261,7 @@
 		_overlay_scratch_mount $*
 		return $?
 	fi
-	_mount -t $FSTYP `_scratch_mount_options $*`
+	_mount -t $FSTYP$FUSE_SUBTYP `_scratch_mount_options $*`
 	mount_ret=$?
 	[ $mount_ret -ne 0 ] && return $mount_ret
 	_idmapped_mount $SCRATCH_DEV $SCRATCH_MNT
@@ -445,7 +445,7 @@
     fi
 
     _test_options mount
-    _mount -t $FSTYP $TEST_OPTIONS $TEST_FS_MOUNT_OPTS $SELINUX_MOUNT_OPTIONS $* $TEST_DEV $TEST_DIR
+    _mount -t $FSTYP$FUSE_SUBTYP $TEST_OPTIONS $TEST_FS_MOUNT_OPTS $SELINUX_MOUNT_OPTIONS $* $TEST_DEV $TEST_DIR
     mount_ret=$?
     [ $mount_ret -ne 0 ] && return $mount_ret
     _idmapped_mount $TEST_DEV $TEST_DIR
@@ -571,6 +571,9 @@
     9p)
 	# do nothing for 9p
 	;;
+    fuse)
+	# do nothing for fuse
+	;;
     virtiofs)
 	# do nothing for virtiofs
 	;;
@@ -611,6 +614,9 @@
     9p)
 	# do nothing for 9p
 	;;
+    fuse)
+	# do nothing for fuse
+	;;
     virtiofs)
 	# do nothing for virtiofs
 	;;
@@ -678,7 +684,7 @@
 	local mkfs_status
 
 	case $FSTYP in
-	nfs*|cifs|ceph|overlay|glusterfs|pvfs2|9p|virtiofs)
+	nfs*|cifs|ceph|overlay|glusterfs|pvfs2|9p|fuse|virtiofs)
 		# unable to re-create this fstyp, just remove all files in
 		# $SCRATCH_MNT to avoid EEXIST caused by the leftover files
 		# created in previous runs
@@ -1574,7 +1580,7 @@
 			_notrun "this test requires a valid \$SCRATCH_MNT"
 		fi
 		;;
-	9p|virtiofs)
+	9p|fuse|virtiofs)
 		if [ -z "$SCRATCH_DEV" ]; then
 			_notrun "this test requires a valid \$SCRATCH_DEV"
 		fi
@@ -1774,7 +1780,7 @@
 			_notrun "this test requires a valid \$TEST_DIR"
 		fi
 		;;
-	9p|virtiofs)
+	9p|fuse|virtiofs)
 		if [ -z "$TEST_DEV" ]; then
 			_notrun "this test requires a valid \$TEST_DEV"
 		fi
@@ -2973,7 +2979,7 @@
 
 	if [ $USE_REMOUNT -eq 0 ]; then
 		if [ "$FSTYP" != "overlay" ]; then
-			_mount -t $FSTYP $mount_opts $device $mountpoint
+			_mount -t $FSTYP$FUSE_SUBTYP $mount_opts $device $mountpoint
 			_idmapped_mount $device $mountpoint
 		else
 			_overlay_mount $device $mountpoint
@@ -3111,6 +3117,9 @@
     9p)
 	# no way to check consistency for 9p
 	;;
+    fuse)
+	# no way to check consistency for fuse
+	;;
     virtiofs)
 	# no way to check consistency for virtiofs
 	;;
@@ -3172,6 +3181,9 @@
     9p)
 	# no way to check consistency for 9p
 	;;
+    fuse)
+	# no way to check consistency for fuse
+	;;
     virtiofs)
 	# no way to check consistency for virtiofs
 	;;
diff --git a/tests/generic/020 b/tests/generic/020
index b91bca3..be5ceca 100755
--- a/tests/generic/020
+++ b/tests/generic/020
@@ -56,7 +56,7 @@
 {
 	# set maximum total attr space based on fs type
 	case "$FSTYP" in
-	xfs|udf|pvfs2|9p|ceph|nfs)
+	xfs|udf|pvfs2|9p|ceph|fuse|nfs)
 		max_attrs=1000
 		;;
 	ext2|ext3|ext4)
@@ -134,7 +134,7 @@
 	pvfs2)
 		max_attrval_size=8192
 		;;
-	xfs|udf|9p)
+	xfs|udf|9p|fuse)
 		max_attrval_size=65536
 		;;
 	bcachefs)