>From d5c8cb28f509fde9ab4713f3541ae5294967123f Mon Sep 17 00:00:00 2001 From: Bernhard Voelker Date: Mon, 28 Jan 2013 11:40:01 +0100 Subject: [PATCH] df: do not treat rootfs specially Like any other pseudo file system, df should show rootfs only when the -a option is specified, i.e. specifying -trootfs alone is not suffient. As the rootfs entry is now elided by the general deduplication in filter_mount_list (commit v8.20-103-gbb116d3), all other references to "rootfs" can be removed again. * src/df.c (show_rootfs): Remove global variable. (ROOTFS): Remove constant. (filter_mount_list): Remove case to handle rootfs specially. (main): In the case for handling the -t option, remove setting of the show_rootfs variable. * tests/df/skip-rootfs.sh: Adapt the test case "df -t rootfs": the rootfs file system must not be printed (because no -a). * doc/coreutils.texi (df invocation): Correct the documentation about eliding mount entries: it is not the first occurrence of the the device which wins, but now rather the entry with the shortest mount point name. Also adapt the description about eliding pseudo file system types like "rootfs". * NEWS (Changes in behavior): Adapt entry. --- NEWS | 4 +--- doc/coreutils.texi | 9 +++++---- src/df.c | 20 +------------------- tests/df/skip-rootfs.sh | 12 +++++++----- 4 files changed, 14 insertions(+), 31 deletions(-) diff --git a/NEWS b/NEWS index 152a51a..60db555 100644 --- a/NEWS +++ b/NEWS @@ -73,9 +73,7 @@ GNU coreutils NEWS -*- outline -*- df now properly outputs file system information with bind mounts present on the system by skipping duplicate entries (identified by the device number). - - df now elides any entry with the early-boot pseudo file system type - "rootfs" unless either the -a option or "-t rootfs" is specified. + Consequently, df also elides the early-boot pseudo file system type "rootfs". nl no longer supports the --page-increment option, which has been deprecated since coreutils-7.5. Use --line-increment instead. diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 1d508c9..eac8d52 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -10588,13 +10588,14 @@ Normally the disk space is printed in units of Non-integer quantities are rounded up to the next higher unit. For bind mounts and without arguments, @command{df} only outputs the statistics -for the first occurrence of that device in the list of file systems +for that device with the shortest mount point name in the list of file systems (@var{mtab}), i.e., it hides duplicate entries, unless the @option{-a} option is specified. -By default, @command{df} omits the early-boot pseudo file system type -@samp{rootfs}, unless the @option{-a} option is specified or that file system -type is explicitly to be included by using the @option{-t} option. +With the same logic, @command{df} elides a mount entry of a dummy pseude device +if there is another mount entry of a real block device for that mount point with +the same device number, e.g. the early-boot pseudo file system @samp{rootfs} is +not shown per default when already the real root device has been mounted. @cindex disk device file @cindex device file, disk diff --git a/src/df.c b/src/df.c index 70dabb5..0515131 100644 --- a/src/df.c +++ b/src/df.c @@ -63,12 +63,6 @@ static bool show_local_fs; command line argument -- even if it's a dummy (automounter) entry. */ static bool show_listed_fs; -/* If true, include rootfs in the output. */ -static bool show_rootfs; - -/* The literal name of the initial root file system. */ -static char const *ROOTFS = "rootfs"; - /* Human-readable options for output. */ static int human_output_opts; @@ -608,8 +602,7 @@ excluded_fstype (const char *fstype) In the case of duplicities - based on to the device number - the mount entry with a '/' in its me_devname (i.e. not pseudo name like tmpfs) wins. If both have a real devname (e.g. bind mounts), then that with the shorter - me_mountdir wins. - Finally, do not filter out a rootfs entry if -trootfs is specified. */ + me_mountdir wins. */ static void filter_mount_list (void) @@ -630,16 +623,6 @@ filter_mount_list (void) ; /* Stat failed - add ME to be able to complain about it later. */ } else - if (show_rootfs - && ( STREQ (me->me_mountdir, "/") - || STREQ (me->me_type, ROOTFS))) - { - /* Df should show rootfs (due to -trootfs). - Add this ME both if it is the rootfs entry itself or "/" - (as that must not replace the rootfs entry in the devlist). */ - ; - } - else { /* If the device name is a real path name ... */ if (strchr (me->me_devname, '/')) @@ -1383,7 +1366,6 @@ main (int argc, char **argv) /* Accept -F as a synonym for -t for compatibility with Solaris. */ case 't': add_fs_type (optarg); - show_rootfs = selected_fstype (ROOTFS); break; case 'v': /* For SysV compatibility. */ diff --git a/tests/df/skip-rootfs.sh b/tests/df/skip-rootfs.sh index 7b9632b..9c5d0a9 100755 --- a/tests/df/skip-rootfs.sh +++ b/tests/df/skip-rootfs.sh @@ -29,12 +29,14 @@ grep '^rootfs' out || skip_ "no rootfs in mtab" df >out || fail=1 grep '^rootfs' out && { fail=1; cat out; } -# Ensure that the rootfs is shown when explicitly specifying "-t rootfs". -df -t rootfs >out || fail=1 -grep '^rootfs' out || { fail=1; cat out; } +# Ensure that rootfs is yet skipped when explicitly specifying "-t rootfs". +# As df emits "no file systems processed" in this case, it would be a failure +# if df exited with status Zero. +df -t rootfs >out && fail=1 +grep '^rootfs' out && { fail=1; cat out; } -# Ensure that the rootfs is shown when explicitly specifying "-t rootfs", -# even when the -a option is specified. +# Ensure that the rootfs is shown when explicitly both specifying "-t rootfs" +# and the -a option. df -t rootfs -a >out || fail=1 grep '^rootfs' out || { fail=1; cat out; } -- 1.7.7