]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
df: ignore non file system entries in /proc/mounts
authorPádraig Brady <P@draigBrady.com>
Mon, 12 May 2014 13:49:13 +0000 (14:49 +0100)
committerPádraig Brady <P@draigBrady.com>
Tue, 13 May 2014 22:23:30 +0000 (23:23 +0100)
Linux with network namespaces contains entries in /proc/mounts like:
  proc net:[4026532464] proc rw,nosuid,nodev,noexec,relatime 0 0
resulting in a failure to stat 'net:[...]', inducing a warning
and an exit with failure status.

* src/df.c (get_dev): Ignore all relative mount points.
* tests/df/skip-duplicates.sh: Add an entry to test relative dirs.

src/df.c
tests/df/skip-duplicates.sh

index 24897a33f153a83a19d2fc3697d6d1d010e84e40..a7fc57ff796236c6ac193f62c72c06c4dc046d06 100644 (file)
--- a/src/df.c
+++ b/src/df.c
@@ -853,6 +853,11 @@ get_dev (char const *disk, char const *mount_point, char const* file,
   if (!selected_fstype (fstype) || excluded_fstype (fstype))
     return;
 
+  /* Ignore relative MOUNT_POINTs, which are present for example
+     in /proc/mounts on Linux with network namespaces.  */
+  if (!force_fsu && mount_point && ! IS_ABSOLUTE_FILE_NAME (mount_point))
+    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,
index d872f27fc79489a9ccbc33fd7c57458286f3a534..44f7d4ca78edbf428f67f2089370f3071978a2cf 100755 (executable)
@@ -56,6 +56,7 @@ struct mntent *getmntent (FILE *fp)
     {.mnt_fsname="/fsname", .mnt_dir="/"},
     {.mnt_fsname="virtfs",  .mnt_dir="/NONROOT"},
     {.mnt_fsname="virtfs",  .mnt_dir="/NONROOT"},
+    {.mnt_fsname="netns",   .mnt_dir="net:[1234567]"},
   };
 
   if (done == 1)
@@ -68,7 +69,7 @@ struct mntent *getmntent (FILE *fp)
   if (done == 1 && !getenv ("CU_TEST_DUPE_INVALID"))
     done++;  /* skip the first entry.  */
 
-  while (done++ <= 6)
+  while (done++ <= 7)
     {
       mntents[done-2].mnt_type = "-";
       if (STREQ (mntents[done-2].mnt_dir, "/NONROOT"))