| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# |
| 4 |
# Copyright (C) 2022 Karel Zak <[email protected]> |
| 5 |
# |
| 6 |
# This file is part of util-linux. |
| 7 |
# |
| 8 |
# This file is free software; you can redistribute it and/or modify |
| 9 |
# it under the terms of the GNU General Public License as published by |
| 10 |
# the Free Software Foundation; either version 2 of the License, or |
| 11 |
# (at your option) any later version. |
| 12 |
# |
| 13 |
# This file is distributed in the hope that it will be useful, |
| 14 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
# GNU General Public License for more details. |
| 17 |
# |
| 18 |
TS_TOPDIR="${0%/*}/../.." |
| 19 |
TS_DESC="X-mount.subdir" |
| 20 |
|
| 21 |
. $TS_TOPDIR/functions.sh |
| 22 |
ts_init "$*" |
| 23 |
|
| 24 |
ts_check_test_command "$TS_CMD_MOUNT" |
| 25 |
ts_check_test_command "$TS_CMD_FINDMNT" |
| 26 |
ts_skip_nonroot |
| 27 |
ts_check_losetup |
| 28 |
|
| 29 |
# unshared session is possible to support only on kernels with new mount API |
| 30 |
if [ "$("$TS_HELPER_SYSINFO" fsopen-ok)" = "0" ]; then |
| 31 |
prop=$($TS_CMD_FINDMNT --task "$$" -n -o PROPAGATION "/") |
| 32 |
[[ "$prop" == *"private"* ]] && ts_skip "unsupported session" |
| 33 |
fi |
| 34 |
|
| 35 |
ts_device_init |
| 36 |
DEVICE=$TS_LODEV |
| 37 |
|
| 38 |
mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE" |
| 39 |
ts_udevadm_settle "$DEVICE" |
| 40 |
|
| 41 |
# use the same mountpoiunt for all subtests |
| 42 |
MOUNTPOINT="$TS_MOUNTPOINT" |
| 43 |
[ -d "$MOUNTPOINT" ] || mkdir -p $MOUNTPOINT |
| 44 |
|
| 45 |
|
| 46 |
# create subdirectory on the filesystem |
| 47 |
ts_init_subtest "init" |
| 48 |
$TS_CMD_MOUNT $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 49 |
ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts" |
| 50 |
mkdir -p $MOUNTPOINT/submnt |
| 51 |
touch $MOUNTPOINT/submnt/file |
| 52 |
$TS_CMD_UMOUNT $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 53 |
ts_finalize_subtest |
| 54 |
|
| 55 |
|
| 56 |
ts_init_subtest "subdir" |
| 57 |
$TS_CMD_MOUNT -o X-mount.subdir=submnt $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 58 |
ts_is_mounted $DEVICE || ts_log "Cannot find $DEVICE in /proc/mounts" |
| 59 |
if [ ! -f "$MOUNTPOINT/file" ]; then |
| 60 |
echo "$MOUNTPOINT/file not found" >> $TS_OUTPUT |
| 61 |
fi |
| 62 |
$TS_CMD_UMOUNT $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 63 |
ts_finalize_subtest |
| 64 |
|
| 65 |
|
| 66 |
ts_finalize |