bug-coreutils
[Top][All Lists]
Advanced

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

Re: [PATCH] remove "dev=" mount option special processing for df


From: Paul Eggert
Subject: Re: [PATCH] remove "dev=" mount option special processing for df
Date: Tue, 18 Oct 2005 11:47:27 -0700
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

"Paul A. Clarke" <address@hidden> writes:

> Indeed, the above referenced code from mountlist.c will accidentally
> trip over the "logdev=" and "rtdev=" options for XFS, as well as the
> "dev=" option used by IBM's GPFS.

Thanks for your detailed analysis.  The former should be easy to fix,
but what's the latter?  I couldn't find documentation about GPFS and
mnttab with a quick Google search.

> Attached is a trivial and minimal patch which removes the code which
> does the "dev=" special processing, although only for Linux.

How about the following fancier patch.  Does it treat GPFS correctly?

2005-10-18  Paul Eggert  <address@hidden>

        * lib/mountlist.c (ME_DUMMY) [!defined ME_DUMMY]: Ignore "none"
        file systems.  Problem reported by Bob Proulx.
        Ignore "proc" file systems.  Problem reported by address@hidden
        (read_file_system_list): Make the parsing of "dev=..." more robust.
        Problem reported by Paul A. Clarke.

--- mountlist.c.~1.55.~ 2005-09-21 23:05:39.000000000 -0700
+++ mountlist.c 2005-10-18 11:16:08.000000000 -0700
@@ -23,6 +23,7 @@
 
 #include "mountlist.h"
 
+#include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -143,6 +144,8 @@ char *strstr ();
 #ifndef ME_DUMMY
 # define ME_DUMMY(Fs_name, Fs_type)            \
     (strcmp (Fs_type, "autofs") == 0           \
+     || strcmp (Fs_type, "none") == 0          \
+     || strcmp (Fs_type, "proc") == 0          \
      || strcmp (Fs_type, "subfs") == 0         \
      /* for Irix 6.5 */                                \
      || strcmp (Fs_type, "ignore") == 0)
@@ -345,11 +348,21 @@ read_file_system_list (bool need_fs_type
        me->me_type_malloced = 1;
        me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
        me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
-       devopt = strstr (mnt->mnt_opts, "dev=");
+       me->me_dev = (dev_t) -1;        /* Magic; means not known yet. */
+       devopt = strstr (mnt->mnt_opts, ",dev=");
        if (devopt)
-         me->me_dev = strtoul (devopt + 4, NULL, 16);
-       else
-         me->me_dev = (dev_t) -1;      /* Magic; means not known yet. */
+         {
+           char const *optval = devopt + 5;
+           char *optvalend;
+           unsigned long int dev;
+           errno = 0;
+           dev = strtoul (optval, &optvalend, 16);
+           if (optval != optvalend
+               && (*optvalend == '\0' || *optvalend == ',')
+               && ! (dev == ULONG_MAX && errno == ERANGE)
+               && dev == (dev_t) dev)
+             me->me_dev = dev;
+         }
 
        /* Add to the linked list. */
        *mtail = me;




reply via email to

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