]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(read_file_system_list): Accept bool flag, not int.
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 2 Aug 2004 20:27:45 +0000 (20:27 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 2 Aug 2004 20:27:45 +0000 (20:27 +0000)
(errno): Remove decl; we now assume C89 or better.
(xatoi): Remove; replaced by strtoul.  Hence device numbers can now
go up to ULONG_MAX.

lib/mountlist.c

index fe2c9a5a5a7961f0319ba7fff9acafdae57546ac..af4633b9d4b560df19317eb6e88aabc444a58102 100644 (file)
@@ -35,9 +35,6 @@ char *strstr ();
 #endif
 
 #include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
 
 #ifdef HAVE_FCNTL_H
 # include <fcntl.h>
@@ -143,39 +140,11 @@ extern int errno;
 #include "mountlist.h"
 #include "unlocked-io.h"
 
-#ifdef MOUNTED_GETMNTENT1      /* 4.3BSD, SunOS, HP-UX, Dynix, Irix.  */
-/* Return the value of the hexadecimal number represented by CP.
-   No prefix (like '0x') or suffix (like 'h') is expected to be
-   part of CP. */
-/* FIXME: this can overflow */
-
-static int
-xatoi (char *cp)
-{
-  int val;
-
-  val = 0;
-  while (*cp)
-    {
-      if (*cp >= 'a' && *cp <= 'f')
-       val = val * 16 + *cp - 'a' + 10;
-      else if (*cp >= 'A' && *cp <= 'F')
-       val = val * 16 + *cp - 'A' + 10;
-      else if (*cp >= '0' && *cp <= '9')
-       val = val * 16 + *cp - '0';
-      else
-       break;
-      cp++;
-    }
-  return val;
-}
-#endif /* MOUNTED_GETMNTENT1.  */
-
 #if MOUNTED_GETMNTINFO
 
 # if ! HAVE_F_FSTYPENAME_IN_STATFS
 static char *
-fstype_to_string (short t)
+fstype_to_string (short int t)
 {
   switch (t)
     {
@@ -298,11 +267,11 @@ fstype_to_string (int t)
 
 /* Return a list of the currently mounted file systems, or NULL on error.
    Add each entry to the tail of the list so that they stay in order.
-   If NEED_FS_TYPE is nonzero, ensure that the file system type fields in
+   If NEED_FS_TYPE is true, ensure that the file system type fields in
    the returned list are valid.  Otherwise, they might not be.  */
 
 struct mount_entry *
-read_file_system_list (int need_fs_type)
+read_file_system_list (bool need_fs_type)
 {
   struct mount_entry *mount_list;
   struct mount_entry *me;
@@ -360,12 +329,7 @@ read_file_system_list (int need_fs_type)
        me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
        devopt = strstr (mnt->mnt_opts, "dev=");
        if (devopt)
-         {
-           if (devopt[4] == '0' && (devopt[5] == 'x' || devopt[5] == 'X'))
-             me->me_dev = xatoi (devopt + 6);
-           else
-             me->me_dev = xatoi (devopt + 4);
-         }
+         me->me_dev = strtoul (devopt + 4, NULL, 16);
        else
          me->me_dev = (dev_t) -1;      /* Magic; means not known yet. */