summaryrefslogtreecommitdiffstats
path: root/tests/ts/mount
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ts/mount')
-rwxr-xr-xtests/ts/mount/devname61
-rwxr-xr-xtests/ts/mount/fslists90
-rwxr-xr-xtests/ts/mount/fstab-all139
-rwxr-xr-xtests/ts/mount/fstab-broken80
-rwxr-xr-xtests/ts/mount/fstab-btrfs141
-rwxr-xr-xtests/ts/mount/fstab-devname54
-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-label2devname58
-rwxr-xr-xtests/ts/mount/fstab-label2uuid60
-rwxr-xr-xtests/ts/mount/fstab-loop56
-rwxr-xr-xtests/ts/mount/fstab-none37
-rwxr-xr-xtests/ts/mount/fstab-symlink71
-rwxr-xr-xtests/ts/mount/fstab-uuid61
-rwxr-xr-xtests/ts/mount/fstab-uuid2devname56
-rwxr-xr-xtests/ts/mount/fstab-uuid2label59
-rwxr-xr-xtests/ts/mount/label55
-rwxr-xr-xtests/ts/mount/move89
-rwxr-xr-xtests/ts/mount/regfile41
-rwxr-xr-xtests/ts/mount/remount62
-rwxr-xr-xtests/ts/mount/rlimit93
-rwxr-xr-xtests/ts/mount/shared-subtree87
-rwxr-xr-xtests/ts/mount/special43
-rwxr-xr-xtests/ts/mount/umount-alltargets125
-rwxr-xr-xtests/ts/mount/umount-recursive97
-rwxr-xr-xtests/ts/mount/uuid52
27 files changed, 1932 insertions, 0 deletions
diff --git a/tests/ts/mount/devname b/tests/ts/mount/devname
new file mode 100755
index 0000000..a311a43
--- /dev/null
+++ b/tests/ts/mount/devname
@@ -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 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.ext3"
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+MTAB_FILE="/proc/mounts"
+has_mtab=$( ts_has_mtab_support )
+if [ "$has_mtab" == "yes" ]; then
+ MTAB_FILE="/etc/mtab"
+fi
+
+mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE"
+
+ts_device_has "TYPE" "ext3" $DEVICE || ts_die "Cannot find ext3 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/fslists b/tests/ts/mount/fslists
new file mode 100755
index 0000000..cb243d5
--- /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.ext3"
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE"
+
+ts_device_has "TYPE" "ext3" $DEVICE || ts_die "Cannot find ext3 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 ext3 $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,ext3 $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,ext3"
+$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,ext3,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..acc64e4
--- /dev/null
+++ b/tests/ts/mount/fstab-all
@@ -0,0 +1,139 @@
+#!/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"
+$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"
+$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"
+$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"
+$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"
+$TS_CMD_UMOUNT ${MOUNTPOINT}{A,B,C,D}
+[ $? == 0 ] || ts_log "umount failed"
+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"
+$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-broken b/tests/ts/mount/fstab-broken
new file mode 100755
index 0000000..947e3af
--- /dev/null
+++ b/tests/ts/mount/fstab-broken
@@ -0,0 +1,80 @@
+#!/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
+
+# 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..0003b5d
--- /dev/null
+++ b/tests/ts/mount/fstab-btrfs
@@ -0,0 +1,141 @@
+#!/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_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"
+
+$TS_CMD_MOUNT -o loop "$DEVICE" "$TS_MOUNTPOINT_CREATE"
+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..95a014d
--- /dev/null
+++ b/tests/ts/mount/fstab-devname
@@ -0,0 +1,54 @@
+#!/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.ext3"
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE"
+
+ts_device_has "TYPE" "ext3" $DEVICE || ts_die "Cannot find ext3 on $DEVICE"
+
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+
+ts_fstab_add $DEVICE
+
+# variant A)
+$TS_CMD_MOUNT $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_die "A) Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE || ts_die "A) Cannot umount $DEVICE"
+
+# variant B)
+$TS_CMD_MOUNT $DEVICE >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_die "B) Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE"
+
+ts_fstab_clean
+ts_log "Success"
+ts_finalize
diff --git a/tests/ts/mount/fstab-devname2label b/tests/ts/mount/fstab-devname2label
new file mode 100755
index 0000000..cd39dfd
--- /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.ext3"
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+mkfs.ext3 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext3 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..90c61c3
--- /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.ext3"
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 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..5f40a87
--- /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.ext3"
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+mkfs.ext3 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext3 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"
+
+# variant A)
+$TS_CMD_MOUNT $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_die "A) Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE || ts_die "A) Cannot umount $DEVICE"
+
+# variant B)
+$TS_CMD_MOUNT -L $LABEL >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_die "B) Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE"
+
+# variant C)
+$TS_CMD_MOUNT LABEL=$LABEL >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_die "C) Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE || ts_die "C) Cannot umount $DEVICE"
+
+ts_fstab_clean
+
+ts_log "Success"
+ts_finalize
+
diff --git a/tests/ts/mount/fstab-label2devname b/tests/ts/mount/fstab-label2devname
new file mode 100755
index 0000000..e9cebb3
--- /dev/null
+++ b/tests/ts/mount/fstab-label2devname
@@ -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 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.ext3"
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+mkfs.ext3 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext3 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 "$DEVICE"
+ts_udevadm_settle "$DEVICE" "LABEL"
+
+# variant A)
+$TS_CMD_MOUNT -L $LABEL >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_die "A) Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE || ts_die "A) Cannot umount $DEVICE"
+
+# variant B)
+$TS_CMD_MOUNT "LABEL=$LABEL" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_die "B) Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE"
+
+ts_fstab_clean
+
+ts_log "Success"
+ts_finalize
+
diff --git a/tests/ts/mount/fstab-label2uuid b/tests/ts/mount/fstab-label2uuid
new file mode 100755
index 0000000..1a97bc0
--- /dev/null
+++ b/tests/ts/mount/fstab-label2uuid
@@ -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 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.ext3"
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+mkfs.ext3 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext3 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"
+
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+
+ts_fstab_add "UUID=$UUID"
+ts_udevadm_settle "$DEVICE" "LABEL" "UUID"
+
+# variant A)
+$TS_CMD_MOUNT -L $LABEL >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_die "A) Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE || ts_die "A) Cannot umount $DEVICE"
+
+# variant B)
+$TS_CMD_MOUNT "LABEL=$LABEL" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_die "B) Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE"
+
+ts_fstab_clean
+
+ts_log "Success"
+ts_finalize
+
diff --git a/tests/ts/mount/fstab-loop b/tests/ts/mount/fstab-loop
new file mode 100755
index 0000000..4b56694
--- /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.ext3"
+
+IMG=$(ts_image_init)
+
+mkfs.ext3 -F $IMG &> /dev/null || ts_die "Cannot make ext3 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" "ext3" "loop"
+$TS_CMD_MOUNT -a >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+ts_fstab_addline "$IMG" "$TS_MOUNTPOINT-2" "ext3" "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..e2ed0af
--- /dev/null
+++ b/tests/ts/mount/fstab-none
@@ -0,0 +1,37 @@
+#!/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_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..3493473
--- /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.ext3"
+
+LINKNAME="$TS_OUTDIR/${TS_TESTNAME}_lnk"
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE"
+
+ts_device_has "TYPE" "ext3" $DEVICE || ts_die "Cannot find ext3 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..6f4ec1f
--- /dev/null
+++ b/tests/ts/mount/fstab-uuid
@@ -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)"
+
+. $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.ext3"
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 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"
+
+# variant A)
+$TS_CMD_MOUNT $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_die "A) Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE || ts_die "A) Cannot umount $DEVICE"
+
+# variant B)
+$TS_CMD_MOUNT -U $UUID >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_die "B) Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE"
+
+# variant C)
+$TS_CMD_MOUNT UUID=$UUID >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_die "C) Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE || ts_die "C) Cannot umount $DEVICE"
+
+ts_fstab_clean
+
+ts_log "Success"
+ts_finalize
+
diff --git a/tests/ts/mount/fstab-uuid2devname b/tests/ts/mount/fstab-uuid2devname
new file mode 100755
index 0000000..47c7a73
--- /dev/null
+++ b/tests/ts/mount/fstab-uuid2devname
@@ -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 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.ext3"
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 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 "$DEVICE"
+ts_udevadm_settle "$DEVICE" "UUID"
+
+# variant A)
+$TS_CMD_MOUNT -U $UUID >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_die "A) Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE || ts_die "A) Cannot umount $DEVICE"
+
+# variant B)
+$TS_CMD_MOUNT "UUID=$UUID" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_die "B) Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE"
+
+ts_fstab_clean
+
+ts_log "Success"
+ts_finalize
+
diff --git a/tests/ts/mount/fstab-uuid2label b/tests/ts/mount/fstab-uuid2label
new file mode 100755
index 0000000..9b0c615
--- /dev/null
+++ b/tests/ts/mount/fstab-uuid2label
@@ -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 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.ext3"
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+mkfs.ext3 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext3 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"
+
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+
+ts_fstab_add "LABEL=$LABEL"
+ts_udevadm_settle "$DEVICE" "LABEL" "UUID"
+
+# variant A)
+$TS_CMD_MOUNT -U $UUID >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_die "A) Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE || ts_die "A) Cannot umount $DEVICE"
+
+# variant B)
+$TS_CMD_MOUNT "UUID=$UUID" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_die "B) Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE"
+
+ts_fstab_clean
+
+ts_log "Success"
+ts_finalize
+
diff --git a/tests/ts/mount/label b/tests/ts/mount/label
new file mode 100755
index 0000000..adb4ac1
--- /dev/null
+++ b/tests/ts/mount/label
@@ -0,0 +1,55 @@
+#!/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.ext3"
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+mkfs.ext3 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE"
+ts_device_has "LABEL" $LABEL $DEVICE \
+ || ts_die "Cannot find LABEL '$LABEL' on $DEVICE"
+
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+ts_udevadm_settle "$DEVICE" "LABEL"
+
+# variant A)
+$TS_CMD_MOUNT -L $LABEL $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_die "A) Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE || ts_die "A) Cannot umount $DEVICE"
+
+# variant B)
+$TS_CMD_MOUNT LABEL=$LABEL $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_die "B) Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE"
+
+ts_log "Success"
+ts_finalize
+
diff --git a/tests/ts/mount/move b/tests/ts/mount/move
new file mode 100755
index 0000000..e828a89
--- /dev/null
+++ b/tests/ts/mount/move
@@ -0,0 +1,89 @@
+#!/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
+
+function mount_and_check {
+ # last arg must be an existing or to-be-mounted mountpoint
+ local mountpoint="${@: -1}"
+
+ $TS_CMD_MOUNT "$@" \
+ || 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=$?
+ 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..8cdf695
--- /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.ext3"
+
+IMAGE=$(ts_image_init)
+mkfs.ext3 -F $IMAGE &> /dev/null || ts_die "Cannot make ext3 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..38db9bf
--- /dev/null
+++ b/tests/ts/mount/remount
@@ -0,0 +1,62 @@
+#!/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"
+has_mtab=$( ts_has_mtab_support )
+if [ "$has_mtab" == "yes" ]; then
+ MTAB_FILE="/etc/mtab"
+fi
+
+mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE"
+
+# mount read-write
+$TS_CMD_MOUNT $DEVICE $TS_MOUNTPOINT || ts_die "Cannot mount $TS_MOUNTPOINT"
+
+# check the mount
+egrep -q "^$DEVICE $TS_MOUNTPOINT" $MTAB_FILE \
+ || ts_die "Cannot find $TS_MOUNTPOINT in $MTAB_FILE"
+
+# remount
+$TS_CMD_MOUNT -o remount,ro $TS_MOUNTPOINT \
+ || 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/rlimit b/tests/ts/mount/rlimit
new file mode 100755
index 0000000..9564d70
--- /dev/null
+++ b/tests/ts/mount/rlimit
@@ -0,0 +1,93 @@
+#!/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.
+#
+
+#
+# The /etc/mtab file should not be modified if RLIMIT_FSIZE (ulimit -f)
+# is too low, otherwise the file could be corrupted (incomplete write).
+# The [u]mount(8) has to block SIGXFSZ and check if all writes and fflush
+# calls are successful.
+#
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="rlimit-fsize"
+
+. $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_HELPER_MD5"
+
+ts_skip_nonroot
+ts_check_losetup
+ts_check_prog "mkfs.ext3"
+
+has_mtab=$( ts_has_mtab_support )
+[ "$has_mtab" == "yes" ] || ts_skip "mtab unsupported"
+
+[ -L /etc/mtab ] && ts_skip "mtab is symlink"
+[ "$(stat --format '%s' /etc/mtab)" -gt "1024" ] || ts_skip "mtab is too small"
+
+function mtab_checksum()
+{
+ "$TS_HELPER_MD5" < /etc/mtab
+}
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE"
+
+
+ts_init_subtest "mount"
+OLD_SUM=$(mtab_checksum)
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+(
+ ulimit -f 1
+ $TS_CMD_MOUNT $DEVICE $TS_MOUNTPOINT
+) &> /dev/null
+NEW_SUM=$(mtab_checksum)
+[ $NEW_SUM = $OLD_SUM ] && echo "OK: mtab unmodified by mount" >> $TS_OUTPUT
+ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $TS_MOUNTPOINT &> /dev/null
+ts_is_mounted $DEVICE && ts_die "$DEVICE is still mounted"
+ts_finalize_subtest
+
+
+ts_init_subtest "umount"
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+$TS_CMD_MOUNT $DEVICE $TS_MOUNTPOINT &> /dev/null
+ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts"
+OLD_SUM=$(mtab_checksum)
+(
+ ulimit -f 1
+ $TS_CMD_UMOUNT $TS_MOUNTPOINT &> /dev/null
+) &> /dev/null
+NEW_SUM=$(mtab_checksum)
+[ $NEW_SUM = $OLD_SUM ] && echo "OK: mtab unmodified by umount" >> $TS_OUTPUT
+if ts_is_mounted $DEVICE; then
+ echo "FAIL: $DEVICE is still mounted" >> $TS_OUTPUT
+ $TS_CMD_UMOUNT $TS_MOUNTPOINT &> /dev/null
+else
+ # repair /etc/mtab
+ $TS_CMD_UMOUNT --fake $TS_MOUNTPOINT &> /dev/null
+fi
+ts_finalize_subtest
+
+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..fe6e27d
--- /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.ext3"
+
+[ -d $TS_MOUNTPOINT ] || mkdir -p $TS_MOUNTPOINT
+
+# bind
+$TS_CMD_MOUNT --bind $TS_MOUNTPOINT $TS_MOUNTPOINT
+[ "$?" = "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.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE"
+ts_device_has "TYPE" "ext3" $DEVICE || ts_die "Cannot find ext3 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..21edd65
--- /dev/null
+++ b/tests/ts/mount/special
@@ -0,0 +1,43 @@
+#!/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_CMD_MOUNT -t mytest /foo /bar &> $TS_OUTPUT
+
+rm -f $MOUNTER
+
+ts_finalize
+
diff --git a/tests/ts/mount/umount-alltargets b/tests/ts/mount/umount-alltargets
new file mode 100755
index 0000000..37a163d
--- /dev/null
+++ b/tests/ts/mount/umount-alltargets
@@ -0,0 +1,125 @@
+#!/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"
+
+has_mtab=$( ts_has_mtab_support )
+if [ "$has_mtab" == "yes" ]; then
+ [ -L /etc/mtab ] || ts_skip "regular mtab"
+fi
+
+# 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
+[ -d "${MOUNTPOINT}1/subA/subAB" ] || mkdir -p ${MOUNTPOINT}1/subA/subAB
+$TS_CMD_MOUNT ${TS_DEVICE}3 ${MOUNTPOINT}1/subA/subAB
+[ -d "${MOUNTPOINT}1/subB" ] || mkdir -p ${MOUNTPOINT}1/subB
+$TS_CMD_MOUNT ${TS_DEVICE}4 ${MOUNTPOINT}1/subB
+$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..700c58c
--- /dev/null
+++ b/tests/ts/mount/umount-recursive
@@ -0,0 +1,97 @@
+#!/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
+
+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
+
+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..7b106a0
--- /dev/null
+++ b/tests/ts/mount/uuid
@@ -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 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.ext3"
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE"
+UUID=$(ts_uuid_by_devname "$DEVICE") || ts_die "Cannot find UUID on $DEVICE"
+
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+ts_udevadm_settle "$DEVICE" "UUID"
+
+# variant A)
+$TS_CMD_MOUNT -U $UUID $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_die "A) Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE || ts_die "A) Cannot umount $DEVICE"
+
+# variant B)
+$TS_CMD_MOUNT UUID=$UUID $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_is_mounted $DEVICE || ts_die "B) Cannot find $DEVICE in /proc/mounts"
+$TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE"
+
+ts_log "Success"
+ts_finalize
+