summaryrefslogtreecommitdiffstats
path: root/tests/ts/mount
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 19:10:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 19:10:49 +0000
commitcfe5e3905201349e9cf3f95d52ff4bd100bde37d (patch)
treed0baf160cbee3195249d095f85e52d20c21acf02 /tests/ts/mount
parentInitial commit. (diff)
downloadutil-linux-cfe5e3905201349e9cf3f95d52ff4bd100bde37d.tar.xz
util-linux-cfe5e3905201349e9cf3f95d52ff4bd100bde37d.zip
Adding upstream version 2.39.3.upstream/2.39.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-xtests/ts/mount/complex106
-rwxr-xr-xtests/ts/mount/devname57
-rwxr-xr-xtests/ts/mount/dm-verity72
-rwxr-xr-xtests/ts/mount/fallback86
-rwxr-xr-xtests/ts/mount/fslists90
-rwxr-xr-xtests/ts/mount/fstab-all156
-rwxr-xr-xtests/ts/mount/fstab-bind35
-rwxr-xr-xtests/ts/mount/fstab-broken81
-rwxr-xr-xtests/ts/mount/fstab-btrfs144
-rwxr-xr-xtests/ts/mount/fstab-devname58
-rwxr-xr-xtests/ts/mount/fstab-devname2label52
-rwxr-xr-xtests/ts/mount/fstab-devname2uuid50
-rwxr-xr-xtests/ts/mount/fstab-label63
-rwxr-xr-xtests/ts/mount/fstab-label2devname60
-rwxr-xr-xtests/ts/mount/fstab-label2uuid63
-rwxr-xr-xtests/ts/mount/fstab-loop56
-rwxr-xr-xtests/ts/mount/fstab-none38
-rwxr-xr-xtests/ts/mount/fstab-symlink71
-rwxr-xr-xtests/ts/mount/fstab-uuid64
-rwxr-xr-xtests/ts/mount/fstab-uuid2devname59
-rwxr-xr-xtests/ts/mount/fstab-uuid2label61
-rwxr-xr-xtests/ts/mount/label56
-rwxr-xr-xtests/ts/mount/move95
-rwxr-xr-xtests/ts/mount/regfile41
-rwxr-xr-xtests/ts/mount/remount59
-rwxr-xr-xtests/ts/mount/set_ugid_mode64
-rwxr-xr-xtests/ts/mount/shared-subtree87
-rwxr-xr-xtests/ts/mount/special61
-rwxr-xr-xtests/ts/mount/subdir66
-rwxr-xr-xtests/ts/mount/umount-alltargets120
-rwxr-xr-xtests/ts/mount/umount-recursive100
-rwxr-xr-xtests/ts/mount/uuid53
32 files changed, 2324 insertions, 0 deletions
diff --git a/tests/ts/mount/complex b/tests/ts/mount/complex
new file mode 100755
index 0000000..9aa6222
--- /dev/null
+++ b/tests/ts/mount/complex
@@ -0,0 +1,106 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2022 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="complex"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_skip_nonroot
+ts_skip_qemu_user
+
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_losetup
+
+$TS_CMD_MOUNT --version | grep -q 'fd-based' || ts_skip "no fd-based API"
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE"
+ts_udevadm_settle "$DEVICE"
+
+ROOT_MOUNTPOINT="$TS_MOUNTPOINT"
+A_MOUNTPOINT="${ROOT_MOUNTPOINT}/A"
+B_MOUNTPOINT="${ROOT_MOUNTPOINT}/B"
+
+[ -d "$ROOT_MOUNTPOINT" ] || mkdir -p $ROOT_MOUNTPOINT
+[ -d "$A_MOUNTPOINT" ] || mkdir -p $A_MOUNTPOINT
+[ -d "$B_MOUNTPOINT" ] || mkdir -p $B_MOUNTPOINT
+
+## create a private directory
+ts_init_subtest "init"
+$TS_CMD_MOUNT --bind --make-private $ROOT_MOUNTPOINT $ROOT_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_FINDMNT -nr --mountpoint $ROOT_MOUNTPOINT -o PROPAGATION | grep -q private \
+ || ts_log "Cannot find private $ROOT_MOUNTPOINT"
+ts_finalize_subtest
+
+
+## mount the device
+ts_init_subtest "rw-mount"
+$TS_CMD_MOUNT -orw $DEVICE $A_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts"
+ts_finalize_subtest
+
+
+## move device and set it read-only for VFS (FS is still rw)
+ts_init_subtest "ro-move"
+$TS_CMD_MOUNT --move -o ro $A_MOUNTPOINT $B_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+findmnt -nr -o VFS-OPTIONS --mountpoint $B_MOUNTPOINT | grep -q 'ro' \
+ || ts_log "Cannot find ro VFS"
+findmnt -nr -o FS-OPTIONS --mountpoint $B_MOUNTPOINT | grep -q 'rw' \
+ || ts_log "Cannot find rw FS"
+ts_finalize_subtest
+
+
+## remount to set FS to read-only (VFS is still ro)
+ts_init_subtest "ro-remount"
+$TS_CMD_MOUNT -oremount,ro,noexec $B_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+findmnt -nr -o VFS-OPTIONS --mountpoint $B_MOUNTPOINT | grep -q 'ro' \
+ || ts_log "Cannot find ro VFS"
+findmnt -nr -o FS-OPTIONS --mountpoint $B_MOUNTPOINT | grep -q 'ro' \
+ || ts_log "Cannot find ro FS"
+ts_finalize_subtest
+
+
+## remount to set FS and VFS to read-write
+ts_init_subtest "rw-remount"
+$TS_CMD_MOUNT -oremount,rw $B_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+findmnt -nr -o VFS-OPTIONS --mountpoint $B_MOUNTPOINT | grep -q 'rw' \
+ || ts_log "Cannot find rw VFS"
+findmnt -nr -o FS-OPTIONS --mountpoint $B_MOUNTPOINT | grep -q 'rw' \
+ || ts_log "Cannot find rw FS"
+ts_finalize_subtest
+
+
+## bind as read-only (VFS), set shared propagation,
+## and remove noexec (but keep FS rw)
+ts_init_subtest "ro-shared-bind"
+$TS_CMD_MOUNT --make-shared --bind -oro,exec $B_MOUNTPOINT $A_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+findmnt -nr -o VFS-OPTIONS --mountpoint $A_MOUNTPOINT | grep -q 'ro' \
+ || ts_log "Cannot find ro VFS"
+findmnt -nr -o FS-OPTIONS --mountpoint $A_MOUNTPOINT | grep -q 'rw' \
+ || ts_log "Cannot find rw FS"
+findmnt -nr -o PROPAGATION --mountpoint $A_MOUNTPOINT | grep -q 'shared' \
+ || ts_log "Cannot find shared flag"
+findmnt -nr -o VFS-OPTIONS --mountpoint $A_MOUNTPOINT | grep -q 'noexec' \
+ && ts_log "Found noexec flag"
+ts_finalize_subtest
+
+
+## cleanup
+$TS_CMD_UMOUNT $A_MOUNTPOINT &> /dev/null
+$TS_CMD_UMOUNT $B_MOUNTPOINT &> /dev/null
+$TS_CMD_UMOUNT $ROOT_MOUNTPOINT &> /dev/null
+
+ts_finalize
diff --git a/tests/ts/mount/devname b/tests/ts/mount/devname
new file mode 100755
index 0000000..fcfa926
--- /dev/null
+++ b/tests/ts/mount/devname
@@ -0,0 +1,57 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="by devname"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+
+ts_skip_nonroot
+ts_check_losetup
+ts_check_prog "mkfs.ext2"
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+MTAB_FILE="/proc/mounts"
+
+mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE"
+
+ts_device_has "TYPE" "ext2" $DEVICE || ts_die "Cannot find ext2 on $DEVICE"
+
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+
+$TS_CMD_MOUNT $DEVICE $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts"
+
+grep -q "\(^\| \)$DEVICE " $MTAB_FILE ||
+ echo "mount failed: cannot find $DEVICE in $MTAB_FILE" >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+$TS_CMD_UMOUNT $DEVICE || ts_die "Cannot umount $DEVICE"
+
+grep -q "\(^\| \)$DEVICE " $MTAB_FILE &&
+ echo "umount failed: found $DEVICE in $MTAB_FILE" >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+ts_log "Success"
+ts_finalize
+
diff --git a/tests/ts/mount/dm-verity b/tests/ts/mount/dm-verity
new file mode 100755
index 0000000..dc8689d
--- /dev/null
+++ b/tests/ts/mount/dm-verity
@@ -0,0 +1,72 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2021 Vojtech Eichler <veichler@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="dm-verity support"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+VERITY_OUTPUT="$TS_OUTPUT.log"
+HASH_DEVICE="$TS_OUTDIR/dm-verity.hash"
+SQUASHFS="$TS_OUTDIR/dm-verity.img"
+VERITY_DEVICE="test_dm_verity"
+VERITY_DEVICE_ABS="/dev/mapper/$VERITY_DEVICE"
+ROOT_HASH_FILE="$TS_OUTDIR/root_hash_file.hash"
+
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+
+ts_skip_nonroot
+ts_check_prog "mksquashfs"
+ts_check_prog "veritysetup"
+
+grep -q '#define HAVE_CRYPTSETUP' ${top_builddir}/config.h || ts_skip "no dm-verity support"
+
+# Make a squashfs and prepare verity device out of it
+mksquashfs $TS_SELF $SQUASHFS &>/dev/null || ts_skip "error: mksquashfs on $TS_SELF"
+veritysetup format $SQUASHFS $HASH_DEVICE > $VERITY_OUTPUT || ts_skip "cannot format $SQUASHFS"
+
+# Extract root hash out of veritysetup output
+HASH=$(cat $VERITY_OUTPUT | awk '/Root hash:/ { print $3 }') || ts_die "error: extract hash"
+echo $HASH > $ROOT_HASH_FILE
+# Activate verity data device
+veritysetup create $VERITY_DEVICE $SQUASHFS $HASH_DEVICE $HASH || ts_skip "cannot activate verity device"
+
+
+ts_init_subtest "roothash"
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+$TS_CMD_MOUNT -o verity.hashdevice=$HASH_DEVICE,verity.roothash=$HASH,verity.hashoffset=0 \
+ $VERITY_DEVICE_ABS \
+ $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_UMOUNT -l $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+
+ts_init_subtest "roothashfile"
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+$TS_CMD_MOUNT -o verity.hashdevice=$HASH_DEVICE,verity.roothashfile=$ROOT_HASH_FILE \
+ $VERITY_DEVICE_ABS \
+ $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_UMOUNT -l $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+
+# Cleanup
+dmsetup remove -f $VERITY_DEVICE
+
+ts_finalize
diff --git a/tests/ts/mount/fallback b/tests/ts/mount/fallback
new file mode 100755
index 0000000..e2a1de7
--- /dev/null
+++ b/tests/ts/mount/fallback
@@ -0,0 +1,86 @@
+#!/bin/bash
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="fstab-fallback"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+ts_check_test_command "$TS_CMD_FINDMNT"
+ts_check_test_command "$TS_CMD_LOSETUP"
+ts_check_enosys_syscalls open_tree fsopen mount_setattr
+
+ts_skip_nonroot
+
+test_mount_fallback() {
+ ts_init_subtest "$1"
+
+ MY_SOURCE="${TS_MOUNTPOINT}-src"
+
+ mkdir -p "$MY_SOURCE"
+ mkdir -p "$TS_MOUNTPOINT"
+
+ "$TS_HELPER_ENOSYS" $2 -- "$TS_CMD_MOUNT" --bind "$MY_SOURCE" "$TS_MOUNTPOINT" \
+ >> "$TS_OUTPUT" 2>> "$TS_ERRLOG"
+ [ "$?" = "0" ] || ts_log "error: mount $TS_MOUNTPOINT"
+
+ "$TS_CMD_FINDMNT" --mountpoint "$TS_MOUNTPOINT" &> /dev/null
+ [ $? -eq 0 ] || ts_die "Not found target (mount failed?)"
+
+ "$TS_CMD_UMOUNT" "$TS_MOUNTPOINT" || ts_die "Cannot umount $TS_MOUNTPOINT"
+
+ ts_finalize_subtest
+}
+
+test_mount_fallback "open_tree" "-s open_tree"
+test_mount_fallback "fsopen" "-s fsopen"
+
+
+ts_device_init
+DEVICE=$TS_LODEV
+mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE"
+ts_udevadm_settle "$DEVICE"
+
+# use the same in all next subtests
+MOUNTPOINT=$TS_MOUNTPOINT
+mkdir -p "$MOUNTPOINT"
+
+
+ts_init_subtest "later-fsopen"
+$TS_HELPER_ENOSYS -s fsopen -- "$TS_CMD_MOUNT" -t foo,bar,ext2 "$DEVICE" "$MOUNTPOINT" \
+ >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts"
+mkdir -p ${MOUNTPOINT}/subdir
+$TS_CMD_UMOUNT $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+
+ts_init_subtest "subdir"
+$TS_HELPER_ENOSYS -s fsopen -s open_tree -- \
+ "$TS_CMD_MOUNT" -o X-mount.subdir=subdir "$DEVICE" "$MOUNTPOINT" \
+ >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $MOUNTPOINT
+ts_finalize_subtest
+
+
+ts_init_subtest "mount_setattr"
+"$TS_CMD_MOUNT" "$DEVICE" "$MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts"
+$TS_HELPER_ENOSYS -s mount_setattr -- \
+ "$TS_CMD_MOUNT" -o remount,ro "$MOUNTPOINT" \
+ >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_FINDMNT --kernel --mountpoint "$MOUNTPOINT" --options "ro" &> /dev/null
+[ "$?" == "0" ] || ts_die "Cannot find read-only in $MOUNTPOINT in /proc/self/mountinfo"
+$TS_HELPER_ENOSYS -s mount_setattr -- \
+ "$TS_CMD_MOUNT" --make-slave "$MOUNTPOINT" \
+ >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_FINDMNT -n --kernel --mountpoint "$MOUNTPOINT" -o PROPAGATION >> $TS_OUTPUT
+$TS_CMD_UMOUNT $MOUNTPOINT
+ts_finalize_subtest
+
+
+ts_finalize
+
diff --git a/tests/ts/mount/fslists b/tests/ts/mount/fslists
new file mode 100755
index 0000000..230186a
--- /dev/null
+++ b/tests/ts/mount/fslists
@@ -0,0 +1,90 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2014 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="fs lists"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+
+ts_skip_nonroot
+ts_check_losetup
+ts_check_prog "mkfs.ext2"
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE"
+
+ts_device_has "TYPE" "ext2" $DEVICE || ts_die "Cannot find ext2 on $DEVICE"
+
+# Don't forget that $TS_MOUNTPOINT is subtest specific, don't create it
+# globally!
+
+
+ts_init_subtest "one-type"
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+$TS_CMD_MOUNT -t ext2 $DEVICE $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $TS_MOUNTPOINT
+ts_log "Success"
+ts_finalize_subtest
+
+
+ts_init_subtest "more-types"
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+$TS_CMD_MOUNT -t foo,bar,ext2 $DEVICE $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $TS_MOUNTPOINT
+ts_log "Success"
+ts_finalize_subtest
+
+
+ts_init_subtest "more-types-fstab"
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+ts_fstab_add $DEVICE $TS_MOUNTPOINT "foo,bar,ext2"
+$TS_CMD_MOUNT $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_fstab_clean
+ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $TS_MOUNTPOINT
+ts_log "Success"
+ts_finalize_subtest
+
+
+ts_init_subtest "type-pattern"
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+$TS_CMD_MOUNT -i -t nofoo,bar $DEVICE $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $TS_MOUNTPOINT
+ts_log "Success"
+ts_finalize_subtest
+
+
+ts_init_subtest "type-pattern-neg"
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+$TS_CMD_MOUNT -i -t nofoo,bar,ext2,ext2,ext4 $DEVICE $TS_MOUNTPOINT &> /dev/null
+ts_is_mounted $DEVICE && ts_die "$DEVICE unexpectedly mounted"
+ts_log "Success"
+ts_finalize_subtest
+
+ts_log "Success"
+ts_finalize
+
diff --git a/tests/ts/mount/fstab-all b/tests/ts/mount/fstab-all
new file mode 100755
index 0000000..83e1b63
--- /dev/null
+++ b/tests/ts/mount/fstab-all
@@ -0,0 +1,156 @@
+#!/bin/bash
+
+# Copyright (C) 2019 Karel Zak <kzak@redhat.com>
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="all (fstab)"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+ts_check_test_command "$TS_CMD_FDISK"
+
+ts_skip_nonroot
+ts_check_prog "mkfs.ext2"
+ts_check_prog "mkfs.ext4"
+
+
+# set global variable TS_DEVICE
+ts_scsi_debug_init dev_size_mb=50
+
+ts_log "Create partitions"
+$TS_CMD_FDISK --noauto-pt ${TS_DEVICE} &> /dev/null <<EOF
+o
+n
+p
+1
+
++10M
+n
+p
+2
+
++10M
+n
+p
+3
+
++10M
+n
+p
+
++10M
+w
+q
+EOF
+
+udevadm settle
+
+ts_log "Create filesystem A"
+mkfs.ext2 ${TS_DEVICE}1 &> /dev/null
+ts_log "Create filesystem B"
+mkfs.ext2 ${TS_DEVICE}2 &> /dev/null
+ts_log "Create filesystem C"
+mkfs.ext2 ${TS_DEVICE}3 &> /dev/null
+ts_log "Create filesystem D"
+mkfs.ext4 ${TS_DEVICE}4 &> /dev/null
+
+udevadm settle
+
+# use the same top-level mountpoint for all sub-tests
+MOUNTPOINT=$TS_MOUNTPOINT
+
+[ -d "${MOUNTPOINT}A" ] || mkdir -p ${MOUNTPOINT}A
+[ -d "${MOUNTPOINT}B" ] || mkdir -p ${MOUNTPOINT}B
+[ -d "${MOUNTPOINT}C" ] || mkdir -p ${MOUNTPOINT}C
+[ -d "${MOUNTPOINT}D" ] || mkdir -p ${MOUNTPOINT}D
+
+# generic fstab
+MY_FSTAB="$TS_OUTDIR/${TS_TESTNAME}.fstab"
+rm -rf $MY_FSTAB
+echo "${TS_DEVICE}1 ${MOUNTPOINT}A ext2 rw,defaults 0 0" >> $MY_FSTAB
+echo "${TS_DEVICE}2 ${MOUNTPOINT}B ext2 rw,defaults 0 0" >> $MY_FSTAB
+echo "${TS_DEVICE}3 ${MOUNTPOINT}C ext2 ro,defaults 0 0" >> $MY_FSTAB
+echo "${TS_DEVICE}4 ${MOUNTPOINT}D ext4 rw,defaults 0 0" >> $MY_FSTAB
+
+
+ts_init_subtest "basic"
+$TS_CMD_MOUNT --all --fstab $MY_FSTAB >> $TS_OUTPUT 2>> $TS_ERRLOG
+[ $? == 0 ] || ts_log "mount failed"
+udevadm settle
+$TS_CMD_UMOUNT ${MOUNTPOINT}{A,B,C,D}
+[ $? == 0 ] || ts_log "umount failed"
+ts_finalize_subtest
+
+
+ts_init_subtest "filter-type"
+$TS_CMD_MOUNT --all --fstab $MY_FSTAB -t ext4 >> $TS_OUTPUT 2>> $TS_ERRLOG
+[ $? == 0 ] || ts_log "mount failed"
+udevadm settle
+$TS_CMD_UMOUNT ${MOUNTPOINT}D
+[ $? == 0 ] || ts_log "umount failed"
+ts_finalize_subtest
+
+
+ts_init_subtest "filter-notype"
+$TS_CMD_MOUNT --all --fstab $MY_FSTAB -t noext4 >> $TS_OUTPUT 2>> $TS_ERRLOG
+[ $? == 0 ] || ts_log "mount failed"
+udevadm settle
+$TS_CMD_UMOUNT ${MOUNTPOINT}{A,B,C}
+[ $? == 0 ] || ts_log "umount failed"
+ts_finalize_subtest
+
+
+ts_init_subtest "filter-option"
+$TS_CMD_MOUNT --all --fstab $MY_FSTAB -O ro >> $TS_OUTPUT 2>> $TS_ERRLOG
+[ $? == 0 ] || ts_log "mount failed"
+udevadm settle
+$TS_CMD_UMOUNT ${MOUNTPOINT}C
+[ $? == 0 ] || ts_log "umount failed"
+ts_finalize_subtest
+
+
+ts_init_subtest "override-option"
+$TS_CMD_MOUNT --all --fstab $MY_FSTAB -o ro >> $TS_OUTPUT 2>> $TS_ERRLOG
+[ $? == 0 ] || ts_log "mount failed"
+udevadm settle
+$TS_CMD_UMOUNT ${MOUNTPOINT}{A,B,C,D}
+[ $? == 0 ] || ts_log "umount failed"
+ts_finalize_subtest
+
+
+ts_init_subtest "relative-path"
+cd "$TS_OUTDIR" > /dev/null
+$TS_CMD_MOUNT --all --fstab $(basename "$MY_FSTAB") >> $TS_OUTPUT 2>> $TS_ERRLOG
+[ $? == 0 ] || ts_log "mount failed"
+udevadm settle
+$TS_CMD_UMOUNT ${MOUNTPOINT}{A,B,C,D}
+[ $? == 0 ] || ts_log "umount failed"
+cd - > /dev/null
+ts_finalize_subtest
+
+
+ts_init_subtest "prefix"
+MY_ROOT="$TS_OUTDIR/${TS_TESTNAME}-rootdir"
+[ -d "${MY_ROOT}" ] || mkdir -p ${MY_ROOT}
+# sub-test specific fstab
+MY_FSTAB="$TS_OUTDIR/${TS_TESTNAME}.fstab"
+rm -rf $MY_FSTAB
+echo "${TS_DEVICE}1 /foo/A ext2 rw,defaults 0 0" >> $MY_FSTAB
+echo "${TS_DEVICE}2 /foo/B ext2 rw,defaults 0 0" >> $MY_FSTAB
+echo "${TS_DEVICE}3 /foo/C ext2 rw,defaults 0 0" >> $MY_FSTAB
+echo "${TS_DEVICE}4 /foo/D ext4 rw,defaults 0 0" >> $MY_FSTAB
+# mount all to prefix
+$TS_CMD_MOUNT --all \
+ --fstab $MY_FSTAB \
+ --target-prefix $MY_ROOT \
+ -o X-mount.mkdir >> $TS_OUTPUT 2>> $TS_ERRLOG
+[ $? == 0 ] || ts_log "mount failed"
+udevadm settle
+$TS_CMD_UMOUNT $MY_ROOT/foo/{A,B,C,D}
+[ $? == 0 ] || ts_log "umount failed"
+ts_finalize_subtest
+
+ts_finalize
diff --git a/tests/ts/mount/fstab-bind b/tests/ts/mount/fstab-bind
new file mode 100755
index 0000000..2c799df
--- /dev/null
+++ b/tests/ts/mount/fstab-bind
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="fstab-bind"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+ts_check_test_command "$TS_CMD_FINDMNT"
+
+ts_skip_nonroot
+ts_skip_docker
+
+MY_SOURCE="${TS_MOUNTPOINT}-src"
+
+ts_fstab_add $MY_SOURCE "$TS_MOUNTPOINT" "none" "bind,default,noauto"
+
+mkdir -p $MY_SOURCE
+mkdir -p $TS_MOUNTPOINT
+
+$TS_CMD_MOUNT $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+[ "$?" = "0" ] || ts_log "error: mount $TS_MOUNTPOINT"
+
+$TS_CMD_FINDMNT --mountpoint "$TS_MOUNTPOINT" &> /dev/null
+[ $? -eq 0 ] || ts_die "Not found target (mount failed?)"
+
+$TS_CMD_UMOUNT $TS_MOUNTPOINT || ts_die "Cannot umount $TS_MOUNTPOINT"
+
+ts_fstab_clean
+
+ts_log "Success"
+ts_finalize
+
diff --git a/tests/ts/mount/fstab-broken b/tests/ts/mount/fstab-broken
new file mode 100755
index 0000000..19edc5f
--- /dev/null
+++ b/tests/ts/mount/fstab-broken
@@ -0,0 +1,81 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="broken fstab"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+ts_check_test_command "$TS_CMD_FINDMNT"
+
+ts_skip_nonroot
+ts_skip_docker
+
+# Let's use the same mountpoint for all subtests
+MNT=$TS_MOUNTPOINT
+mkdir -p $MNT
+
+ts_fstab_lock
+ts_fstab_open
+echo "tmpd $MNT tmpfs" >> /etc/fstab
+ts_fstab_close
+
+ts_init_subtest "mount"
+$TS_CMD_MOUNT $MNT &> /dev/null
+[ "$?" = "0" ] || ts_log "error: mount $MNT"
+$TS_CMD_FINDMNT --kernel --mountpoint "$MNT" &> /dev/null
+if [ "$?" != "0" ]; then
+ ts_log "Cannot find $MNT in /proc/self/mountinfo"
+else
+ ts_log "OK"
+fi
+$TS_CMD_UMOUNT $MNT &> /dev/null
+if [ "$?" = "0" ]; then
+ # for old systems with mtab and /sbin/mount.tmpfs
+ /bin/umount --fake "$MNT" &> /dev/null
+else
+ ts_log "error: umount $MNT"
+fi
+ts_finalize_subtest
+
+
+ts_init_subtest "mount-all"
+$TS_CMD_MOUNT -a &> /dev/null
+[ "$?" = "0" ] || ts_log "error: mount -a"
+$TS_CMD_FINDMNT --kernel --mountpoint "$MNT" &> /dev/null
+if [ "$?" != "0" ]; then
+ ts_log "Cannot find $MNT in /proc/self/mountinfo"
+else
+ ts_log "OK"
+fi
+$TS_CMD_UMOUNT $MNT &> /dev/null
+if [ "$?" = "0" ]; then
+ # for old systems with mtab and /sbin/mount.tmpfs
+ /bin/umount --fake $MNT &> /dev/null
+else
+ ts_log "error: umount $MNT"
+fi
+ts_finalize_subtest
+
+ts_fstab_clean # this unlocks too
+
+ts_log "Success"
+ts_finalize
+
diff --git a/tests/ts/mount/fstab-btrfs b/tests/ts/mount/fstab-btrfs
new file mode 100755
index 0000000..a1003ab
--- /dev/null
+++ b/tests/ts/mount/fstab-btrfs
@@ -0,0 +1,144 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2016 Stanislav Brabec <sbrabec@suse.cz>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="btrfs (fstab)"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+
+ts_skip_nonroot
+ts_check_losetup
+ts_check_enotty
+ts_check_prog "mkfs.btrfs"
+ts_check_prog "btrfs"
+
+# btrfs feature check
+if ! btrfs inspect-internal --help &>/dev/null || \
+ btrfs inspect-internal rootid bla 2>&1 | grep -q "unknown token"; then
+ ts_skip "btrfs too old"
+fi
+
+TS_MOUNTPOINT_ANY="$TS_MOUNTPOINT"
+TS_MOUNTPOINT_CREATE="$TS_MOUNTPOINT-create"
+TS_MOUNTPOINT_DEFAULT="$TS_MOUNTPOINT-default"
+TS_MOUNTPOINT_SUBVOL="$TS_MOUNTPOINT-subvol"
+TS_MOUNTPOINT_SUBVOLID="$TS_MOUNTPOINT-subvolid"
+TS_MOUNTPOINT_BIND="$TS_MOUNTPOINT-bind"
+
+ts_device_init 50
+DEVICE=$TS_LODEV
+[ -d "$TS_MOUNTPOINT_CREATE" ] || mkdir -p "$TS_MOUNTPOINT_CREATE"
+[ -d "$TS_MOUNTPOINT_DEFAULT" ] || mkdir -p "$TS_MOUNTPOINT_DEFAULT"
+[ -d "$TS_MOUNTPOINT_SUBVOL" ] || mkdir -p "$TS_MOUNTPOINT_SUBVOL"
+[ -d "$TS_MOUNTPOINT_SUBVOLID" ] || mkdir -p "$TS_MOUNTPOINT_SUBVOLID"
+[ -d "$TS_MOUNTPOINT_BIND" ] || mkdir -p "$TS_MOUNTPOINT_BIND"
+mkfs.btrfs -d single -m single $DEVICE &> /dev/null || ts_die "Cannot make btrfs on $DEVICE"
+
+btrfs device ready $DEVICE 2>/dev/null || ts_skip "btrfs kernel support is missing"
+
+$TS_CMD_MOUNT -o loop "$DEVICE" "$TS_MOUNTPOINT_CREATE" &> /dev/null
+pushd . >/dev/null
+cd "$TS_MOUNTPOINT_CREATE"
+mkdir -p d0/dd0/ddd0
+cd ./d0/dd0/ddd0
+touch file{1..5}
+btrfs subvol create s1 >/dev/null
+cd ./s1
+touch file{1..5}
+mkdir bind-point
+mkdir -p d1/dd1/ddd1
+cd ./d1/dd1/ddd1
+btrfs subvol create s2 >/dev/null
+DEFAULT_SUBVOLID=$(btrfs inspect-internal rootid s2)
+btrfs subvol set-default $DEFAULT_SUBVOLID . >/dev/null
+NON_DEFAULT_SUBVOLID=$(btrfs subvol list "$TS_MOUNTPOINT_CREATE" | while read dummy id rest ; do if test $id = $DEFAULT_SUBVOLID ; then continue ; fi ; echo $id ; done)
+cd ../../../..
+mkdir -p d2/dd2/ddd2
+cd ./d2/dd2/ddd2
+btrfs subvol create s3 >/dev/null
+mkdir -p s3/bind-mnt
+popd >/dev/null
+NON_DEFAULT_SUBVOL=d0/dd0/ddd0/d2/dd2/ddd2/s3
+$TS_CMD_UMOUNT "$TS_MOUNTPOINT_CREATE"
+
+
+ts_init_subtest "btrfs"
+ts_fstab_lock
+ts_fstab_open
+# Tests with fs == btrfs
+# mounting default subvolume, deep in the structure, without entry in fstab
+ts_fstab_addline "$DEVICE" "$TS_MOUNTPOINT_DEFAULT" "btrfs" ""
+# mounting default subvolume, deep in the structure
+ts_fstab_addline "$DEVICE" "$TS_MOUNTPOINT_SUBVOL" "btrfs" "subvol=$NON_DEFAULT_SUBVOL"
+# mounting non-default subvolume
+ts_fstab_addline "$DEVICE" "$TS_MOUNTPOINT_SUBVOLID" "btrfs" "subvolid=$NON_DEFAULT_SUBVOLID"
+# test bind mount pointing to subvolume root
+ts_fstab_addline "$TS_MOUNTPOINT_SUBVOLID" "$TS_MOUNTPOINT_BIND" "auto" "bind"
+ts_fstab_close
+
+$TS_CMD_MOUNT -a >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_MOUNT -a >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+$TS_CMD_UMOUNT "$TS_MOUNTPOINT_BIND" >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_UMOUNT "$TS_MOUNTPOINT_DEFAULT" >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_UMOUNT "$TS_MOUNTPOINT_SUBVOL" >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_UMOUNT "$TS_MOUNTPOINT_SUBVOLID" >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+# check that everything was unmounted
+$TS_CMD_MOUNT | grep "$TS_MOUNTPOINT_ANY" >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+ts_fstab_clean # this unlock too
+ts_log "Success"
+ts_finalize_subtest
+
+
+ts_init_subtest "auto"
+ts_fstab_lock
+ts_fstab_open
+# Tests with fs == auto
+# mounting default subvolume, deep in the structure, without entry in fstab
+ts_fstab_addline "$DEVICE" "$TS_MOUNTPOINT_DEFAULT" "auto" ""
+# mounting default subvolume, deep in the structure
+ts_fstab_addline "$DEVICE" "$TS_MOUNTPOINT_SUBVOL" "auto" "subvol=$NON_DEFAULT_SUBVOL"
+# mounting non-default subvolume
+ts_fstab_addline "$DEVICE" "$TS_MOUNTPOINT_SUBVOLID" "auto" "subvolid=$NON_DEFAULT_SUBVOLID"
+# test bind mount pointing to subvolume sub-directory
+ts_fstab_addline "$TS_MOUNTPOINT_SUBVOL/bind-mnt" "$TS_MOUNTPOINT_BIND" "auto" "bind"
+ts_fstab_close
+
+$TS_CMD_MOUNT -a >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_MOUNT -a >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+$TS_CMD_UMOUNT "$TS_MOUNTPOINT_BIND" >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_UMOUNT "$TS_MOUNTPOINT_DEFAULT" >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_UMOUNT "$TS_MOUNTPOINT_SUBVOL" >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_UMOUNT "$TS_MOUNTPOINT_SUBVOLID" >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+# check that everything was unmounted
+$TS_CMD_MOUNT | grep "$TS_MOUNTPOINT_ANY" >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+ts_fstab_clean # this unlock too
+ts_log "Success"
+ts_finalize_subtest
+
+
+ts_finalize
+
diff --git a/tests/ts/mount/fstab-devname b/tests/ts/mount/fstab-devname
new file mode 100755
index 0000000..5b64a32
--- /dev/null
+++ b/tests/ts/mount/fstab-devname
@@ -0,0 +1,58 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="by devname (fstab)"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+
+ts_skip_nonroot
+ts_check_losetup
+ts_check_prog "mkfs.ext2"
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE"
+
+ts_device_has "TYPE" "ext2" $DEVICE || ts_die "Cannot find ext2 on $DEVICE"
+
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+# Use one mountpoint for all subtests
+MOUNTPOINT=$TS_MOUNTPOINT
+
+ts_fstab_add $DEVICE
+
+ts_init_subtest "mountpoint"
+$TS_CMD_MOUNT $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE || >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+ts_init_subtest "device-name"
+$TS_CMD_MOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+ts_fstab_clean
+
+ts_finalize
diff --git a/tests/ts/mount/fstab-devname2label b/tests/ts/mount/fstab-devname2label
new file mode 100755
index 0000000..1d85621
--- /dev/null
+++ b/tests/ts/mount/fstab-devname2label
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="by devname (fstab label)"
+LABEL="testMountD2L"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+
+ts_skip_nonroot
+ts_check_losetup
+ts_check_prog "mkfs.ext2"
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+mkfs.ext2 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE"
+ts_device_has "LABEL" $LABEL $DEVICE \
+ || ts_die "Cannot find LABEL '$LABEL' on $DEVICE"
+
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+
+ts_fstab_add "LABEL=$LABEL"
+ts_udevadm_settle "$DEVICE" "LABEL"
+
+$TS_CMD_MOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE || ts_die "Cannot umount $DEVICE"
+
+ts_fstab_clean
+
+ts_log "Success"
+ts_finalize
+
diff --git a/tests/ts/mount/fstab-devname2uuid b/tests/ts/mount/fstab-devname2uuid
new file mode 100755
index 0000000..8105fa0
--- /dev/null
+++ b/tests/ts/mount/fstab-devname2uuid
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="by devname (fstab uuid)"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+
+ts_skip_nonroot
+ts_check_losetup
+ts_check_prog "mkfs.ext2"
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE"
+UUID=$(ts_uuid_by_devname "$DEVICE") || ts_die "Cannot find UUID on $DEVICE"
+
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+
+ts_fstab_add "UUID=$UUID"
+ts_udevadm_settle "$DEVICE" "UUID"
+
+$TS_CMD_MOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE || ts_die "Cannot umount $DEVICE"
+
+ts_fstab_clean
+
+ts_log "Success"
+ts_finalize
+
diff --git a/tests/ts/mount/fstab-label b/tests/ts/mount/fstab-label
new file mode 100755
index 0000000..4b23e7f
--- /dev/null
+++ b/tests/ts/mount/fstab-label
@@ -0,0 +1,63 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="by label (fstab)"
+LABEL="testFstabLabel"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+
+ts_skip_nonroot
+ts_check_losetup
+ts_check_prog "mkfs.ext2"
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+mkfs.ext2 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE"
+ts_device_has "LABEL" $LABEL $DEVICE \
+ || ts_die "Cannot find LABEL '$LABEL' on $DEVICE"
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+MOUNTPOINT=$TS_MOUNTPOINT
+
+ts_fstab_add "LABEL=$LABEL"
+ts_udevadm_settle "$DEVICE" "LABEL"
+
+ts_init_subtest "no-option"
+$TS_CMD_MOUNT $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+ts_init_subtest "L-option"
+$TS_CMD_MOUNT -L $LABEL >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+ts_init_subtest "LABEL-option"
+$TS_CMD_MOUNT LABEL=$LABEL >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+
+ts_finalize
diff --git a/tests/ts/mount/fstab-label2devname b/tests/ts/mount/fstab-label2devname
new file mode 100755
index 0000000..75ca05e
--- /dev/null
+++ b/tests/ts/mount/fstab-label2devname
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="by label (fstab devname)"
+LABEL="testMountL2D"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+
+ts_skip_nonroot
+ts_check_losetup
+ts_check_prog "mkfs.ext2"
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+mkfs.ext2 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE"
+ts_device_has "LABEL" $LABEL $DEVICE \
+ || ts_die "Cannot find LABEL '$LABEL' on $DEVICE"
+
+ts_fstab_add "$DEVICE"
+ts_udevadm_settle "$DEVICE" "LABEL"
+
+# Mountpoint has to be created here rather than in each subtest since ts_fstab_add writes
+# this mountpoint to the /etc/fstab file and the mountpoint is needed in subtests
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+
+ts_init_subtest "L-option"
+$TS_CMD_MOUNT -L $LABEL >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+ts_init_subtest "LABEL-option"
+$TS_CMD_MOUNT "LABEL=$LABEL" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+ts_fstab_clean
+
+ts_finalize
diff --git a/tests/ts/mount/fstab-label2uuid b/tests/ts/mount/fstab-label2uuid
new file mode 100755
index 0000000..4bfcae4
--- /dev/null
+++ b/tests/ts/mount/fstab-label2uuid
@@ -0,0 +1,63 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="by label (fstab uuid)"
+LABEL="testMountL2U"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+
+ts_skip_nonroot
+ts_check_losetup
+ts_check_prog "mkfs.ext2"
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+mkfs.ext2 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE"
+ts_device_has "LABEL" $LABEL $DEVICE \
+ || ts_die "Cannot find LABEL '$LABEL' on $DEVICE"
+UUID=$(ts_uuid_by_devname "$DEVICE") || ts_die "Cannot find UUID on $DEVICE"
+
+ts_fstab_add "UUID=$UUID"
+ts_udevadm_settle "$DEVICE" "LABEL" "UUID"
+
+# Mountpoint has to be created here rather than in each subtest since ts_fstab_add writes
+# this mountpoint to the /etc/fstab file and the mountpoint is needed in subtests
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+
+ts_init_subtest "L-option"
+$TS_CMD_MOUNT -L $LABEL >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+ts_init_subtest "LABEL-option"
+$TS_CMD_MOUNT "LABEL=$LABEL" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+ts_fstab_clean
+
+ts_finalize
+
diff --git a/tests/ts/mount/fstab-loop b/tests/ts/mount/fstab-loop
new file mode 100755
index 0000000..7cc589f
--- /dev/null
+++ b/tests/ts/mount/fstab-loop
@@ -0,0 +1,56 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2016 Stanislav Brabec <sbrabec@suse.cz>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="loop (fstab)"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+
+ts_skip_nonroot
+ts_check_losetup
+ts_check_prog "mkfs.ext2"
+
+IMG=$(ts_image_init)
+
+mkfs.ext2 -F $IMG &> /dev/null || ts_die "Cannot make ext2 on $IMG"
+
+[ -d "$TS_MOUNTPOINT-1" ] || mkdir -p $TS_MOUNTPOINT-1
+[ -d "$TS_MOUNTPOINT-2" ] || mkdir -p $TS_MOUNTPOINT-2
+
+ts_fstab_lock
+ts_fstab_open
+
+ts_fstab_addline "$IMG" "$TS_MOUNTPOINT-1" "ext2" "loop"
+$TS_CMD_MOUNT -a >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+ts_fstab_addline "$IMG" "$TS_MOUNTPOINT-2" "ext2" "loop"
+$TS_CMD_MOUNT -a >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+ts_fstab_close
+
+$TS_CMD_UMOUNT "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_UMOUNT "$TS_MOUNTPOINT-2" >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+ts_fstab_clean
+
+ts_log "Success"
+ts_finalize
+
diff --git a/tests/ts/mount/fstab-none b/tests/ts/mount/fstab-none
new file mode 100755
index 0000000..6a4d05b
--- /dev/null
+++ b/tests/ts/mount/fstab-none
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="none"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+ts_check_test_command "$TS_CMD_FINDMNT"
+
+ts_skip_nonroot
+ts_skip_docker
+
+ts_fstab_add "none" "$TS_MOUNTPOINT" "tmpfs" "rw,nosuid,nodev,relatime"
+
+mkdir -p $TS_MOUNTPOINT
+
+$TS_CMD_MOUNT $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+[ "$?" = "0" ] || ts_log "error: mount $TS_MOUNTPOINT"
+
+$TS_CMD_FINDMNT --mountpoint "$TS_MOUNTPOINT" &> /dev/null
+[ $? -eq 0 ] || ts_die "Not found target (mount failed?)"
+
+$TS_CMD_FINDMNT --source "none" --mountpoint "$TS_MOUNTPOINT" &> /dev/null
+[ $? -eq 0 ] || ts_die "Not found source and target"
+
+$TS_CMD_UMOUNT $TS_MOUNTPOINT || ts_die "Cannot umount $TS_MOUNTPOINT"
+
+# for old systems with mtab and /sbin/mount.tmpfs
+/bin/umount --fake "$TS_MOUNTPOINT" &> /dev/null
+
+ts_fstab_clean
+
+ts_log "Success"
+ts_finalize
+
diff --git a/tests/ts/mount/fstab-symlink b/tests/ts/mount/fstab-symlink
new file mode 100755
index 0000000..4d3e37b
--- /dev/null
+++ b/tests/ts/mount/fstab-symlink
@@ -0,0 +1,71 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="by devname (fstab symlink)"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+
+ts_skip_nonroot
+ts_check_losetup
+ts_check_prog "mkfs.ext2"
+
+LINKNAME="$TS_OUTDIR/${TS_TESTNAME}_lnk"
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE"
+
+ts_device_has "TYPE" "ext2" $DEVICE || ts_die "Cannot find ext2 on $DEVICE"
+
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+
+rm -rf $LINKNAME
+ln -s $DEVICE $LINKNAME
+
+ts_fstab_add $LINKNAME $TS_MOUNTPOINT "auto" "defaults,user"
+
+# variant A) -- UID=0
+$TS_CMD_MOUNT $LINKNAME >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_die "A) Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $LINKNAME || ts_die "A) Cannot umount $LINKNAME"
+
+# variant B) -- disabled, the $TS_CMD_MOUNT is usually not a real program, but
+# libtool wrapper and the real mount is exec()ed with
+# LD_LIBRARY_PATH. This all is bad for suid programs...
+
+#ts_init_suid $TS_CMD_MOUNT
+#ts_init_suid $TS_CMD_UMOUNT
+#
+#su $TS_TESTUSER -c "$TS_CMD_MOUNT -v -v -v $LINKNAME" >> $TS_OUTPUT 2>> $TS_ERRLOG
+#ts_is_mounted $DEVICE
+# || ts_die "B) Cannot find $DEVICE in /proc/mounts"
+#su $TS_TESTUSER -c "$TS_CMD_UMOUNT $LINKNAME" >> $TS_OUTPUT 2>> $TS_ERRLOG \
+# || ts_die "B) Cannot umount $LINKNAME"
+
+ts_fstab_clean
+rm -f $LINKNAME
+
+ts_log "Success"
+ts_finalize
+
diff --git a/tests/ts/mount/fstab-uuid b/tests/ts/mount/fstab-uuid
new file mode 100755
index 0000000..03917b7
--- /dev/null
+++ b/tests/ts/mount/fstab-uuid
@@ -0,0 +1,64 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="by uuid (fstab)"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+
+ts_skip_nonroot
+ts_check_losetup
+ts_check_prog "mkfs.ext2"
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE"
+UUID=$(ts_uuid_by_devname "$DEVICE") || ts_die "Cannot find UUID on $DEVICE"
+
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+# Use one mountpoint for all tests
+MOUNTPOINT=$TS_MOUNTPOINT
+
+ts_fstab_add "UUID=$UUID"
+ts_udevadm_settle "$DEVICE" "UUID"
+
+ts_init_subtest "no-option"
+$TS_CMD_MOUNT $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+ts_init_subtest "U-option"
+$TS_CMD_MOUNT -U $UUID >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+ts_init_subtest "UUID-option"
+$TS_CMD_MOUNT UUID=$UUID >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+ts_fstab_clean
+
+ts_finalize
diff --git a/tests/ts/mount/fstab-uuid2devname b/tests/ts/mount/fstab-uuid2devname
new file mode 100755
index 0000000..9bf165e
--- /dev/null
+++ b/tests/ts/mount/fstab-uuid2devname
@@ -0,0 +1,59 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="by uuid (fstab devname)"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+
+ts_skip_nonroot
+ts_check_losetup
+ts_check_prog "mkfs.ext2"
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE"
+UUID=$(ts_uuid_by_devname "$DEVICE") || ts_die "Cannot find UUID on $DEVICE"
+
+ts_fstab_add "$DEVICE"
+ts_udevadm_settle "$DEVICE" "UUID"
+
+# Mountpoint has to be created here rather than in each subtest since ts_fstab_add writes
+# this mountpoint to the /etc/fstab file and the mountpoint is needed in subtests
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+
+ts_init_subtest "U-option"
+$TS_CMD_MOUNT -U $UUID >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+ts_init_subtest "UUID-option"
+$TS_CMD_MOUNT "UUID=$UUID" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+ts_fstab_clean
+
+ts_finalize
+
diff --git a/tests/ts/mount/fstab-uuid2label b/tests/ts/mount/fstab-uuid2label
new file mode 100755
index 0000000..de10ff0
--- /dev/null
+++ b/tests/ts/mount/fstab-uuid2label
@@ -0,0 +1,61 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="by uuid (fstab label)"
+LABEL="testMountU2L"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+
+ts_skip_nonroot
+ts_check_losetup
+ts_check_prog "mkfs.ext2"
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+mkfs.ext2 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE"
+ts_device_has "LABEL" $LABEL $DEVICE \
+ || ts_die "Cannot find LABEL '$LABEL' on $DEVICE"
+UUID=$(ts_uuid_by_devname "$DEVICE") || ts_die "Cannot find UUID on $DEVICE"
+
+ts_fstab_add "LABEL=$LABEL"
+ts_udevadm_settle "$DEVICE" "LABEL" "UUID"
+
+# Mountpoint has to be created here rather than in each subtest since ts_fstab_add writes
+# this mountpoint to the /etc/fstab file and the mountpoint is needed in subtests
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+
+ts_init_subtest "U-option"
+$TS_CMD_MOUNT -U $UUID >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+ts_init_subtest "UUID-option"
+$TS_CMD_MOUNT "UUID=$UUID" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>>$TS_ERRLOG
+ts_finalize_subtest
+
+ts_fstab_clean
+
+ts_finalize
diff --git a/tests/ts/mount/label b/tests/ts/mount/label
new file mode 100755
index 0000000..402eca6
--- /dev/null
+++ b/tests/ts/mount/label
@@ -0,0 +1,56 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="by label"
+LABEL="testMountLabel"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+
+ts_skip_nonroot
+ts_check_losetup
+ts_check_prog "mkfs.ext2"
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+mkfs.ext2 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE"
+ts_device_has "LABEL" $LABEL $DEVICE \
+ || ts_die "Cannot find LABEL '$LABEL' on $DEVICE"
+
+ts_udevadm_settle "$DEVICE" "LABEL"
+
+ts_init_subtest "L-option"
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+$TS_CMD_MOUNT -L $LABEL $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+ts_init_subtest "LABEL-option"
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+$TS_CMD_MOUNT LABEL=$LABEL $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+ts_finalize
diff --git a/tests/ts/mount/move b/tests/ts/mount/move
new file mode 100755
index 0000000..26b8f3d
--- /dev/null
+++ b/tests/ts/mount/move
@@ -0,0 +1,95 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="move"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+ts_check_test_command "$TS_CMD_FINDMNT"
+ts_check_test_command "$TS_CMD_MOUNTPOINT"
+
+ts_skip_nonroot
+ts_skip_docker
+
+function mount_and_check {
+ # last arg must be an existing or to-be-mounted mountpoint
+ local mountpoint="${@: -1}"
+
+ $TS_CMD_MOUNT "$@" &> /dev/null \
+ || ts_die "error: mount $*"
+
+ $TS_CMD_MOUNTPOINT -q "$mountpoint" \
+ || ts_die "error: mountpoint $mountpoint"
+}
+
+DIR_PRIVATE="$TS_OUTDIR/mnt-move-private"
+
+DIR_SRC="$DIR_PRIVATE/mnt-move-src"
+DIR_A="$DIR_PRIVATE/mnt-move-A"
+DIR_B="$DIR_PRIVATE/mnt-move-B"
+
+# this may fail if there are mounted dirs left
+rm -rf "$DIR_PRIVATE" || ts_die "cleanup failed, check manually!"
+mkdir "$DIR_PRIVATE" || ts_die "error: mkdir DIR_PRIVATE"
+
+# create bind mount and make it private to be sure
+# (kernel cannot move mount with shared parent)
+mount_and_check --bind $DIR_PRIVATE $DIR_PRIVATE
+mount_and_check --make-rprivate $DIR_PRIVATE
+
+# Is the bind mount still rw?
+mkdir $DIR_SRC $DIR_A $DIR_B \
+ || ts_die "error: mkdir on private bind mount"
+
+# bind
+mount_and_check --bind $DIR_SRC $DIR_A
+
+# move
+mount_and_check --move $DIR_A $DIR_B
+
+# BTW a basic test for findmnt(8) and mountpoint(1)
+for f in `find $DIR_PRIVATE2 $DIR_PRIVATE`; do
+ xo="$($TS_CMD_MOUNTPOINT -q "$f" 2>&1)"
+ x=$?
+ # mountpoint(1) returns 32 if mountpoint does not exist, map it to 1 to
+ # be compatible with findmnt(8)
+ if [ "$x" = "32" ]; then
+ x=1
+ fi
+ yo="$($TS_CMD_FINDMNT --kernel --mountpoint "$f" 2>&1)"
+ y=$?
+
+ [ "$x" = "$y" ] || ts_log "error: findmount vs. mountpoint: $x, $y, $f"
+ [ -z "$xo" ] || ts_log "error: mountpoint is not quiet: $x, $y, $f"
+ if [ "$y" = "0" -a "$yo" = "" ] || [ "$y" = "1" -a "$yo" != "" ]; then
+ ts_log "error, findmount return value vs. output: $x, $y, $f"
+ fi
+done
+
+# clean up
+$TS_CMD_UMOUNT $DIR_B || ts_log "error: umount DIR_B"
+rmdir $DIR_SRC $DIR_A $DIR_B || ts_log "error: rmdir DIR_B"
+$TS_CMD_UMOUNT $DIR_PRIVATE || ts_log "error: umount DIR_PRIVATE"
+rmdir $DIR_PRIVATE || ts_log "error: rmdir DIR_PRIVATE"
+
+ts_log "Success"
+ts_finalize
+
diff --git a/tests/ts/mount/regfile b/tests/ts/mount/regfile
new file mode 100755
index 0000000..c17c687
--- /dev/null
+++ b/tests/ts/mount/regfile
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+# Copyright (C) 2011 Karel Zak <kzak@redhat.com>
+# This file is part of util-linux.
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="regular file"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+
+ts_skip_nonroot
+ts_check_losetup
+ts_check_prog "mkfs.ext2"
+
+IMAGE=$(ts_image_init)
+mkfs.ext2 -F $IMAGE &> /dev/null || ts_die "Cannot make ext2 on $IMAGE"
+
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+
+$TS_CMD_MOUNT $IMAGE $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+DEVICE=$(awk '/regfile/ { print $1 }' /proc/mounts)
+
+ts_is_mounted "$TS_MOUNTPOINT" || ts_die "Cannot find $TS_MOUNTPOINT in /proc/mounts"
+
+if [ -f "/sys/block/$(basename $DEVICE)/loop/backing_file" ]; then
+ $TS_CMD_UMOUNT $IMAGE || ts_die "Cannot umount $IMAGE"
+else
+ $TS_CMD_UMOUNT $TS_MOUNTPOINT &> /dev/null
+ ts_skip "too old kernel"
+fi
+
+ts_is_mounted "$TS_MOUNTPOINT" && ts_die "$TS_MOUNTPOINT still in /proc/mounts"
+
+ts_log "Success"
+ts_finalize
+
diff --git a/tests/ts/mount/remount b/tests/ts/mount/remount
new file mode 100755
index 0000000..003f0dc
--- /dev/null
+++ b/tests/ts/mount/remount
@@ -0,0 +1,59 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="remount"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_FINDMNT"
+
+ts_skip_nonroot
+ts_check_losetup
+ts_check_prog "mkfs.ext2"
+
+# mountpoint
+[ -d $TS_MOUNTPOINT ] || mkdir -p $TS_MOUNTPOINT
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+MTAB_FILE="/proc/mounts"
+
+mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE"
+
+# mount read-write
+$TS_CMD_MOUNT $DEVICE $TS_MOUNTPOINT &> /dev/null \
+ || ts_die "Cannot mount $TS_MOUNTPOINT"
+
+# check the mount
+grep -E -q "^$DEVICE $TS_MOUNTPOINT" $MTAB_FILE \
+ || ts_die "Cannot find $TS_MOUNTPOINT in $MTAB_FILE"
+
+# remount
+$TS_CMD_MOUNT -o remount,ro $TS_MOUNTPOINT &> /dev/null \
+ || ts_die "Cannot remount $TS_MOUNTPOINT"
+
+# check the remount
+$TS_CMD_FINDMNT --kernel --mountpoint "$TS_MOUNTPOINT" --options "ro" &> /dev/null
+[ "$?" == "0" ] || ts_die "Cannot find read-only in $TS_MOUNTPOINT in /proc/self/mountinfo"
+
+ts_log "Success"
+ts_finalize
+
diff --git a/tests/ts/mount/set_ugid_mode b/tests/ts/mount/set_ugid_mode
new file mode 100755
index 0000000..8041354
--- /dev/null
+++ b/tests/ts/mount/set_ugid_mode
@@ -0,0 +1,64 @@
+#!/bin/bash
+# SPDX-License-Identifier: 0BSD
+
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="X-mount.{owner,group,mode}="
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+
+ts_skip_nonroot
+ts_check_losetup
+ts_check_prog "mkfs.ext2"
+ts_check_prog "id"
+ts_check_prog "stat"
+
+
+do_one() {
+ expected="$1"; shift
+ what="$1"; shift
+ where="$1"; shift
+ $TS_CMD_MOUNT "$@" "$what" "$where" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ actual=$(stat --format="%A %u %g" "$where")
+ [ "$actual" = "$expected" ] || echo "$*: $actual != $expected" >> $TS_ERRLOG
+ $TS_CMD_UMOUNT "$where" >> $TS_OUTPUT 2>> $TS_ERRLOG
+}
+
+ts_device_init
+
+mkfs.ext2 "$TS_LODEV" > /dev/null 2>&1 || ts_die "Cannot make ext2 on $TS_LODEV"
+ts_device_has "TYPE" "ext2" "$TS_LODEV" || ts_die "Cannot find ext2 on $TS_LODEV"
+
+user_1="$(id -un 1)"
+group_2="$(id -gn 2)"
+
+
+mkdir -p "$TS_MOUNTPOINT"
+
+do_one "drwxr-xr-x 0 0" "$TS_LODEV" "$TS_MOUNTPOINT"
+do_one "drwxr-xr-x 1 0" "$TS_LODEV" "$TS_MOUNTPOINT" -o "X-mount.owner=$user_1"
+do_one "drwxr-xr-x 1 2" "$TS_LODEV" "$TS_MOUNTPOINT" -o "X-mount.group=$group_2"
+do_one "d-w--wxr-T 132 2" "$TS_LODEV" "$TS_MOUNTPOINT" -o "X-mount.owner=132,X-mount.mode=1234"
+do_one "d-ws-w---x 132 123" "$TS_LODEV" "$TS_MOUNTPOINT" -o "X-mount.mode=4321,X-mount.group=123"
+do_one "d-ws-w---x 1 321" "$TS_LODEV" "$TS_MOUNTPOINT" -o "X-mount.owner=$user_1,X-mount.group=321"
+
+
+> "$TS_MOUNTPOINT/bind"
+> "$TS_MOUNTPOINT/bindsrc"
+
+do_one "-rw-r--r-- 0 0" "$TS_MOUNTPOINT/bindsrc" "$TS_MOUNTPOINT/bind" --bind
+do_one "-rw-r--r-- 1 0" "$TS_MOUNTPOINT/bindsrc" "$TS_MOUNTPOINT/bind" --bind -o "X-mount.owner=$user_1"
+do_one "-rw-r--r-- 1 2" "$TS_MOUNTPOINT/bindsrc" "$TS_MOUNTPOINT/bind" --bind -o "X-mount.group=$group_2"
+do_one "--w--wxr-T 132 2" "$TS_MOUNTPOINT/bindsrc" "$TS_MOUNTPOINT/bind" --bind -o "X-mount.owner=132,X-mount.mode=1234"
+do_one "--ws-w---x 132 123" "$TS_MOUNTPOINT/bindsrc" "$TS_MOUNTPOINT/bind" --bind -o "X-mount.mode=4321,X-mount.group=123"
+do_one "--wx-w---x 1 321" "$TS_MOUNTPOINT/bindsrc" "$TS_MOUNTPOINT/bind" --bind -o "X-mount.owner=$user_1,X-mount.group=321"
+
+
+rm -fd "$TS_MOUNTPOINT/bind" "$TS_MOUNTPOINT/bindsrc" "$TS_MOUNTPOINT"
+
+ts_log "Success"
+ts_finalize
diff --git a/tests/ts/mount/shared-subtree b/tests/ts/mount/shared-subtree
new file mode 100755
index 0000000..aaaaf64
--- /dev/null
+++ b/tests/ts/mount/shared-subtree
@@ -0,0 +1,87 @@
+#!/bin/bash
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="shared-subtree"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+ts_check_test_command "$TS_CMD_FINDMNT"
+
+ts_skip_nonroot
+ts_check_losetup
+ts_check_prog "mkfs.ext2"
+
+[ -d $TS_MOUNTPOINT ] || mkdir -p $TS_MOUNTPOINT
+
+# bind
+$TS_CMD_MOUNT --bind $TS_MOUNTPOINT $TS_MOUNTPOINT &> /dev/null
+[ "$?" = "0" ] || ts_die "error: mount --bind"
+
+# check the bind
+$TS_CMD_FINDMNT --kernel --mountpoint $TS_MOUNTPOINT &> /dev/null
+[ "$?" == "0" ] || ts_die "Cannot find binded $TS_MOUNTPOINT in /proc/self/mountinfo"
+
+# use the same mounpoint for all sub-tests
+MOUNTPOINT="$TS_MOUNTPOINT"
+
+
+ts_init_subtest "make-shared"
+$TS_CMD_MOUNT --make-shared $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_FINDMNT -nr --mountpoint $MOUNTPOINT -o PROPAGATION >> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "make-private"
+$TS_CMD_MOUNT --make-private $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_FINDMNT -nr --mountpoint $MOUNTPOINT -o PROPAGATION >> $TS_OUTPUT
+ts_finalize_subtest
+
+
+ts_init_subtest "make-unbindable"
+$TS_CMD_MOUNT --make-unbindable $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_FINDMNT -nr --mountpoint $MOUNTPOINT -o PROPAGATION >> $TS_OUTPUT
+ts_finalize_subtest
+
+# clean up
+$TS_CMD_UMOUNT $MOUNTPOINT
+
+
+ts_init_subtest "bind-shared"
+$TS_CMD_MOUNT --make-shared \
+ --bind $MOUNTPOINT $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_FINDMNT -nr --mountpoint $MOUNTPOINT -o PROPAGATION >> $TS_OUTPUT
+$TS_CMD_UMOUNT $MOUNTPOINT
+ts_finalize_subtest
+
+
+#
+# block dev based mounts
+#
+ts_device_init
+DEVICE=$TS_LODEV
+
+mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE"
+ts_device_has "TYPE" "ext2" $DEVICE || ts_die "Cannot find ext2 on $DEVICE"
+
+
+ts_init_subtest "mount-private"
+$TS_CMD_MOUNT --make-private --make-unbindable \
+ $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_FINDMNT -nr --mountpoint $MOUNTPOINT -o PROPAGATION >> $TS_OUTPUT
+$TS_CMD_UMOUNT $MOUNTPOINT
+ts_finalize_subtest
+
+ts_init_subtest "mount-private-ro"
+$TS_CMD_MOUNT $DEVICE $MOUNTPOINT -o ro,private >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_FINDMNT -nr --mountpoint $MOUNTPOINT -o PROPAGATION >> $TS_OUTPUT
+$TS_CMD_FINDMNT -nr --mountpoint $MOUNTPOINT -o VFS-OPTIONS >> $TS_OUTPUT
+$TS_CMD_UMOUNT $MOUNTPOINT
+ts_finalize_subtest
+
+rmdir $MOUNTPOINT
+
+ts_log "Success"
+ts_finalize
+
diff --git a/tests/ts/mount/special b/tests/ts/mount/special
new file mode 100755
index 0000000..359d8aa
--- /dev/null
+++ b/tests/ts/mount/special
@@ -0,0 +1,61 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="call mount.<type>"
+MOUNTER="/sbin/mount.mytest"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MOUNT"
+
+ts_skip_nonroot
+
+cat > $MOUNTER <<\EOF
+#!/bin/bash
+# This util-linux regression test component
+# It's safe to remove me...
+#
+echo "$0 called with \"$*\""
+EOF
+chmod +x $MOUNTER
+
+ts_init_subtest "basic"
+$TS_CMD_MOUNT -t mytest /foo /bar &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "options"
+$TS_CMD_MOUNT -t mytest -o foo,defaults /foo /bar &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "multi-types"
+$TS_CMD_MOUNT -t mytest,invalid /foo /bar &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "user"
+$TS_CMD_MOUNT -t mytest -ouser,abc /foo /bar &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "username"
+$TS_CMD_MOUNT -t mytest -ouser=name,abc /foo /bar &> $TS_OUTPUT
+ts_finalize_subtest
+
+rm -f $MOUNTER
+
+ts_finalize
+
diff --git a/tests/ts/mount/subdir b/tests/ts/mount/subdir
new file mode 100755
index 0000000..a16a7d0
--- /dev/null
+++ b/tests/ts/mount/subdir
@@ -0,0 +1,66 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2022 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="X-mount.subdir"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_FINDMNT"
+ts_skip_nonroot
+ts_check_losetup
+
+# unshared session is possible to support only on kernels with new mount API
+if [ "$("$TS_HELPER_SYSINFO" fsopen-ok)" = "0" ]; then
+ prop=$($TS_CMD_FINDMNT --task "$$" -n -o PROPAGATION "/")
+ [[ "$prop" == *"private"* ]] && ts_skip "unsupported session"
+fi
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE"
+ts_udevadm_settle "$DEVICE"
+
+# use the same mountpoiunt for all subtests
+MOUNTPOINT="$TS_MOUNTPOINT"
+[ -d "$MOUNTPOINT" ] || mkdir -p $MOUNTPOINT
+
+
+# create subdirectory on the filesystem
+ts_init_subtest "init"
+$TS_CMD_MOUNT $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts"
+mkdir -p $MOUNTPOINT/submnt
+touch $MOUNTPOINT/submnt/file
+$TS_CMD_UMOUNT $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+
+ts_init_subtest "subdir"
+$TS_CMD_MOUNT -o X-mount.subdir=submnt $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts"
+if [ ! -f "$MOUNTPOINT/file" ]; then
+ echo "$MOUNTPOINT/file not found" >> $TS_OUTPUT
+fi
+$TS_CMD_UMOUNT $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+
+ts_finalize
diff --git a/tests/ts/mount/umount-alltargets b/tests/ts/mount/umount-alltargets
new file mode 100755
index 0000000..3277d6e
--- /dev/null
+++ b/tests/ts/mount/umount-alltargets
@@ -0,0 +1,120 @@
+#!/bin/bash
+
+# Copyright (C) 2013 Karel Zak <kzak@redhat.com>
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="umount-all-targets"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+ts_check_test_command "$TS_CMD_FDISK"
+
+ts_skip_nonroot
+ts_check_prog "mkfs.ext2"
+
+$TS_CMD_UMOUNT --help | grep -q all-targets
+[ $? -eq 1 ] && ts_skip "all-targets unsupported"
+
+# set global variable TS_DEVICE
+ts_scsi_debug_init dev_size_mb=50
+
+ts_log "Create partitions"
+$TS_CMD_FDISK --noauto-pt ${TS_DEVICE} &> /dev/null <<EOF
+o
+n
+p
+1
+
++10M
+n
+p
+2
+
++10M
+n
+p
+3
+
++10M
+n
+p
+
++10M
+w
+q
+EOF
+
+udevadm settle
+
+ts_log "Create filesystem A"
+mkfs.ext2 ${TS_DEVICE}1 &> /dev/null
+ts_log "Create filesystem B"
+mkfs.ext2 ${TS_DEVICE}2 &> /dev/null
+ts_log "Create filesystem C"
+mkfs.ext2 ${TS_DEVICE}3 &> /dev/null
+ts_log "Create filesystem D"
+mkfs.ext2 ${TS_DEVICE}4 &> /dev/null
+
+udevadm settle
+
+function multi_mount() {
+ local DEV=$1
+ local MNT=$2
+
+ ts_log "prepare: Mount dev to mnt1"
+ [ -d "${MNT}1" ] || mkdir -p ${MNT}1
+ $TS_CMD_MOUNT $DEV ${MNT}1 >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+ ts_log "prepare: Mount dev to mnt2"
+ [ -d "${MNT}2" ] || mkdir -p ${MNT}2
+ $TS_CMD_MOUNT $DEV ${MNT}2 >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+ ts_log "prepare: Mount /dev/xxx1 to mnt3"
+ [ -d "${MNT}3" ] || mkdir -p ${MNT}3
+ $TS_CMD_MOUNT $DEV ${MNT}3 >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+ udevadm settle
+}
+
+# use the same top-level mountpoint for all sub-tests
+MOUNTPOINT=$TS_MOUNTPOINT
+
+#
+# The same device mounted on more places, umount all by mountpoint name
+#
+ts_init_subtest "all-targets-mnt"
+multi_mount ${TS_DEVICE}1 $MOUNTPOINT
+$TS_CMD_UMOUNT --all-targets ${MOUNTPOINT}1 >> $TS_OUTPUT 2>> $TS_ERRLOG
+[ $? == 0 ] || ts_log "umount failed"
+ts_finalize_subtest
+
+#
+# The same device mounted on more places, umount all by device name
+#
+ts_init_subtest "all-targets-dev"
+multi_mount ${TS_DEVICE}1 $MOUNTPOINT
+$TS_CMD_UMOUNT --all-targets ${TS_DEVICE}1 >> $TS_OUTPUT 2>> $TS_ERRLOG
+[ $? == 0 ] || ts_log "umount failed"
+ts_finalize_subtest
+
+#
+# The same device mounted on more places, one of the mountpoints also contains
+# sub-mounts. Umount all by one umount all by top-level device name.
+#
+ts_init_subtest "all-targets-recursive"
+multi_mount ${TS_DEVICE}1 $MOUNTPOINT
+[ -d "${MOUNTPOINT}1/subA" ] || mkdir -p ${MOUNTPOINT}1/subA
+$TS_CMD_MOUNT ${TS_DEVICE}2 ${MOUNTPOINT}1/subA &> /dev/null
+[ -d "${MOUNTPOINT}1/subA/subAB" ] || mkdir -p ${MOUNTPOINT}1/subA/subAB
+$TS_CMD_MOUNT ${TS_DEVICE}3 ${MOUNTPOINT}1/subA/subAB &> /dev/null
+[ -d "${MOUNTPOINT}1/subB" ] || mkdir -p ${MOUNTPOINT}1/subB
+$TS_CMD_MOUNT ${TS_DEVICE}4 ${MOUNTPOINT}1/subB &> /dev/null
+$TS_CMD_UMOUNT --recursive --all-targets ${TS_DEVICE}1 >> $TS_OUTPUT 2>> $TS_ERRLOG
+[ $? == 0 ] || ts_log "umount failed"
+ts_finalize_subtest
+
+ts_log "Success"
+ts_finalize
diff --git a/tests/ts/mount/umount-recursive b/tests/ts/mount/umount-recursive
new file mode 100755
index 0000000..8b1fd47
--- /dev/null
+++ b/tests/ts/mount/umount-recursive
@@ -0,0 +1,100 @@
+#!/bin/bash
+
+# Copyright (C) 2012 Karel Zak <kzak@redhat.com>
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="umount-recursive"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+ts_check_test_command "$TS_CMD_FDISK"
+
+ts_skip_nonroot
+ts_check_prog "mkfs.ext2"
+
+$TS_CMD_UMOUNT --help | grep -q recursive
+[ $? -eq 1 ] && ts_skip "recursive unsupported"
+
+ts_log "Init device"
+# set global variable TS_DEVICE
+ts_scsi_debug_init dev_size_mb=50
+
+ts_log "Create partitions"
+$TS_CMD_FDISK --noauto-pt ${TS_DEVICE} &> /dev/null <<EOF
+o
+n
+p
+1
+
++10M
+n
+p
+2
+
++10M
+n
+p
+3
+
++10M
+n
+p
+
++10M
+w
+q
+EOF
+
+udevadm settle
+
+ts_log "Create filesystem A"
+mkfs.ext2 ${TS_DEVICE}1 &> /dev/null
+ts_log "Create filesystem B"
+mkfs.ext2 ${TS_DEVICE}2 &> /dev/null
+ts_log "Create filesystem C"
+mkfs.ext2 ${TS_DEVICE}3 &> /dev/null
+ts_log "Create filesystem D"
+mkfs.ext2 ${TS_DEVICE}4 &> /dev/null
+
+udevadm settle
+
+ts_log "Do tests..."
+
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+
+ts_log "A) Mount root"
+$TS_CMD_MOUNT ${TS_DEVICE}1 $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_MOUNT --make-shared $TS_MOUNTPOINT &> /dev/null
+
+ts_log "B) Mount child"
+mkdir -p $TS_MOUNTPOINT/mntB
+$TS_CMD_MOUNT ${TS_DEVICE}2 $TS_MOUNTPOINT/mntB >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+ts_log "B2) Mount child-bind"
+mkdir -p $TS_MOUNTPOINT/bindB
+$TS_CMD_MOUNT --bind $TS_MOUNTPOINT/mntB $TS_MOUNTPOINT/bindB >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+ts_log "C) Mount child/child"
+mkdir -p $TS_MOUNTPOINT/mntB/mnt{C,D}
+$TS_CMD_MOUNT ${TS_DEVICE}3 $TS_MOUNTPOINT/mntB/mntC >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+ts_log "D) Mount child/child"
+$TS_CMD_MOUNT ${TS_DEVICE}4 $TS_MOUNTPOINT/mntB/mntD >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+ts_log "E) Mount child-bind"
+mkdir -p $TS_MOUNTPOINT/bindC
+$TS_CMD_MOUNT --bind $TS_MOUNTPOINT/mntB/mntC $TS_MOUNTPOINT/bindC &> /dev/nul
+
+ts_log "F) Mount mountpoint-bind"
+$TS_CMD_MOUNT --bind $TS_MOUNTPOINT $TS_MOUNTPOINT &> /dev/null
+
+udevadm settle
+$TS_CMD_UMOUNT --recursive $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+[ $? == 0 ] || ts_die "umount failed"
+
+ts_log "Success"
+ts_finalize
+
diff --git a/tests/ts/mount/uuid b/tests/ts/mount/uuid
new file mode 100755
index 0000000..f2edfe1
--- /dev/null
+++ b/tests/ts/mount/uuid
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="by uuid"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+
+ts_skip_nonroot
+ts_check_losetup
+ts_check_prog "mkfs.ext2"
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE"
+UUID=$(ts_uuid_by_devname "$DEVICE") || ts_die "Cannot find UUID on $DEVICE"
+
+ts_udevadm_settle "$DEVICE" "UUID"
+
+ts_init_subtest "U-option"
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+$TS_CMD_MOUNT -U $UUID $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+ts_init_subtest "UUID-option"
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+$TS_CMD_MOUNT UUID=$UUID $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+ts_finalize