coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Hide rootfs filesystem in df


From: Robert Milasan
Subject: Hide rootfs filesystem in df
Date: Mon, 24 Sep 2012 10:45:09 +0200

Hello, I've seen lately on a lot of distros using systemd that when
running "df" there is also a filesystem rootfs.

This filesystem is available in /proc/mounts or /proc/self/mounts, but
before systemd usually /etc/mtab was generated at boot times by the
booting scripts. Now most distros link /etc/mtab to /proc/self/mounts
so this "rootfs" filesystem is also there. This filesystem
is actually the root filesystem "/" so you will be having the same
filesystem twice but with different names, lets say.

"rootfs" should not be available or viewable when user is running "df".
The user could do "df -x rootfs", but seems pointless to always run it
like that, so I create a small patch for df which will ignore "rootfs":

Index: coreutils-8.16/src/df.c
===================================================================
--- coreutils-8.16.orig/src/df.c
+++ coreutils-8.16/src/df.c
@@ -465,6 +465,9 @@ get_dev (char const *disk, char const *m
   char* cell;
   size_t field;
 
+  if (STRNCMP_LIT (fstype, "rootfs") == 0)
+    return;
+
   if (me_remote && show_local_fs)
     return;
 

The patch is simple, but if someone knows how to make this better,
please do. I'm not really a developer nor a coder :)

This has been tested on openSUSE 12.1 and 12.2.
Also on openSUSE even mount command doesn't show this "rootfs"
filesystem, so "df" shouldn't also.

-- 
Robert Milasan
L3 Support Engineer
SUSE Linux
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]