2 # Ensure that df /dev/loop0 errors out if overmounted by another device
4 # Copyright (C) 2014-2017 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 .
"${srcdir=.}/tests/init.sh"; path_prepend_ .
/src
24 cleanup_
() { cd /; umount
"$cwd/mnt"; umount
"$cwd/mnt"; }
28 # Create 2 file systems
30 dd if=/dev
/zero of
=blob
$i bs
=8192 count
=200 > /dev
/null
2>&1 \
32 mkfs
-t ext2
-F blob
$i \
33 || skip_
"failed to create ext2 file system"
36 # Mount both at the same place (eclipsing the first)
38 mount
-oloop blob1 mnt || skip
=1
39 eclipsed_dev
=$
(df
--o=source mnt |
tail -n1) || skip
=1
40 mount
-oloop blob2 mnt || skip
=1
43 && skip_
"insufficient mount/ext2 support"
45 df . || skip_
"failed to lookup the device for the current dir"
47 echo "df: cannot access '$eclipsed_dev': over-mounted by another device" > exp
49 # We should get an error for the eclipsed device and continue
50 df
$eclipsed_dev .
> out
2> err
&& fail
=1
52 # header and single entry in output
53 test $
(wc -l < out
) = 2 || fail
=1
55 compare exp err || fail
=1
57 test "$fail" = 1 && dump_mount_list_