2 # Test df's behavior for skipping the pseudo "rootfs" file system.
4 # Copyright (C) 2012-2024 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 <https://www.gnu.org/licenses/>.
19 .
"${srcdir=.}/tests/init.sh"; path_prepend_ .
/src
22 # Protect against inaccessible remote mounts etc.
23 timeout
10 df || skip_
"df fails"
25 # Exclude "fuse.portal" as this currently returns EPERM from statfs()
26 DF_a
() { df
-a -x fuse.portal
"$@"; }
28 # Verify that rootfs is in mtab (and shown when the -a option is specified).
29 # Note this is the case when /proc/self/mountinfo is parsed
30 # rather than /proc/mounts. I.e., when libmount is being used.
32 grep '^rootfs' out || skip_
'no rootfs in mtab'
34 # Ensure that rootfs is suppressed when no options is specified.
36 grep '^rootfs' out
&& { fail
=1; cat out
; }
38 # Ensure that rootfs is yet skipped when explicitly specifying "-t rootfs".
39 # As df emits "no file systems processed" in this case, it would be a failure
40 # if df exited with status Zero.
41 returns_
1 df
-t rootfs
>out || fail
=1
42 grep '^rootfs' out
&& { fail
=1; cat out
; }
44 # Ensure that the rootfs is shown when explicitly both specifying "-t rootfs"
46 DF_a
-t rootfs
>out || fail
=1
47 grep '^rootfs' out ||
{ fail
=1; cat out
; }
49 # Ensure that the rootfs is omitted in all_fs mode when it is explicitly
51 DF_a
-x rootfs
>out || fail
=1
52 grep '^rootfs' out
&& { fail
=1; cat out
; }
54 test "$fail" = 1 && dump_mount_list_