[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
coreutils mountlist int cleanup
From: |
Paul Eggert |
Subject: |
coreutils mountlist int cleanup |
Date: |
Mon, 02 Aug 2004 13:30:10 -0700 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) |
This patch allows mount device numbers up to ULONG_MAX instead of
merely UINT_MAX. (Does anybody know of a system where they can be
larger?)
2004-08-02 Paul Eggert <address@hidden>
* mountlist.h (read_file_system_list): Accept bool flag, not int.
* mountlist.c (read_file_system_list): Likewise.
* mountlist.h: Include <stdbool.h>.
* mountlist.c (errno): Remove decl; we now assume C89 or better.
(xatoi): Remove; replaced by strtoul. Hence device numbers can now
go up to ULONG_MAX.
Index: lib/mountlist.h
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/mountlist.h,v
retrieving revision 1.15
diff -p -u -r1.15 mountlist.h
--- lib/mountlist.h 30 Jun 2004 22:37:20 -0000 1.15
+++ lib/mountlist.h 17 Jul 2004 03:42:41 -0000
@@ -17,6 +17,8 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+#include <stdbool.h>
+
/* A mount table entry. */
struct mount_entry
{
@@ -30,7 +32,7 @@ struct mount_entry
struct mount_entry *me_next;
};
-struct mount_entry *read_file_system_list (int need_fs_type);
+struct mount_entry *read_file_system_list (bool need_fs_type);
#ifndef ME_DUMMY
# define ME_DUMMY(Fs_name, Fs_type) \
Index: lib/mountlist.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/mountlist.c,v
retrieving revision 1.46
diff -p -u -r1.46 mountlist.c
--- lib/mountlist.c 30 Jun 2004 22:39:59 -0000 1.46
+++ lib/mountlist.c 2 Aug 2004 20:25:46 -0000
@@ -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. */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- coreutils mountlist int cleanup,
Paul Eggert <=