blob: 44b460b57cef085e3a22d78fc36f99cd07a669b6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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
[ "$?" = "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
|