[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Hide rootfs filesystem in df
From: |
Robert Milasan |
Subject: |
Re: Hide rootfs filesystem in df |
Date: |
Mon, 3 Dec 2012 09:53:44 +0100 |
On Mon, 03 Dec 2012 02:25:19 +0100
"Bernhard Voelker" <address@hidden> wrote:
> CC'ed Philipp (because the patch is already
> on the way to openSUSE:Factory).
>
> On 11/29/2012 08:50 AM, Bernhard Voelker wrote:
> > Hi Jim,
> >
> > as Robert wrote, it's the easiest way to fix it.
> > [...]
> > So I'm 60:40 for adding it.
>
> Unfortunately, it can't be added like this:
>
> >>> + if (STRNCMP_LIT (fstype, "rootfs") == 0)
> >>> + return;
> >>> +
>
> If fstype is NULL - which is the case e.g. for
> "df --total" -,then STRNCMP_LIT dumps core.
> The fix is to test fstype against NULL.
>
> I'm still thinking about how to combine "hide rootfs"
> with "hide duplicates" (from Ondrej), but I've not
> found an elegant solution yet.
>
> Have a nice day,
> Berny
>
Ok, how about this:
Index: coreutils-8.17/src/df.c
===================================================================
--- coreutils-8.17.orig/src/df.c
+++ coreutils-8.17/src/df.c
@@ -474,6 +474,11 @@ get_dev (char const *disk, char const *m
if (!selected_fstype (fstype) || excluded_fstype (fstype))
return;
+ if (fstype != NULL) {
+ if (STRNCMP_LIT (fstype, "rootfs") == 0)
+ return;
+ }
+
/* If MOUNT_POINT is NULL, then the file system is not mounted, and this
program reports on the file system that the special file is on.
It would be better to report on the unmounted file system,
Test this on openSUSE 12.1 with "df --total" and works properly:
> ./df --total
Filesystem 1K-blocks Used Available Use% Mounted on
devtmpfs 3934516 8 3934508 1% /dev
tmpfs 3942324 288 3942036 1% /dev/shm
tmpfs 3942324 632 3941692 1% /run
/dev/sda5 103210272 6970060 95191660 7% /
tmpfs 3942324 0 3942324 0% /sys/fs/cgroup
tmpfs 3942324 632 3941692 1% /var/run
tmpfs 3942324 632 3941692 1% /var/lock
tmpfs 3942324 0 3942324 0% /media
buildfs 5242880 749012 4493868 15% /var/tmp
/dev/sda6 369245224 64179592 286308976 19% /home
total 505286836 71900856 413580772 15%
--
Robert Milasan
L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: address@hidden
GPG fingerprint: B6FE F4A8 0FA3 3040 3402 6FE7 2F64 167C 1909 6D1A