From 25d291e3ecb447937c243c32893949ebce7a26fe Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 2 Aug 2004 20:27:45 +0000 Subject: (read_file_system_list): Accept bool flag, not int. (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 | 44 ++++---------------------------------------- 1 file changed, 4 insertions(+), 40 deletions(-) (limited to 'lib/mountlist.c') diff --git a/lib/mountlist.c b/lib/mountlist.c index fe2c9a5a5..af4633b9d 100644 --- a/lib/mountlist.c +++ b/lib/mountlist.c @@ -35,9 +35,6 @@ char *strstr (); #endif #include -#ifndef errno -extern int errno; -#endif #ifdef HAVE_FCNTL_H # include @@ -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. */ -- cgit v1.2.3-54-g00ecf