[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-gnulib] mountlist merges from coreutils
From: |
Paul Eggert |
Subject: |
[Bug-gnulib] mountlist merges from coreutils |
Date: |
14 Aug 2003 16:37:50 -0700 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 |
I installed this. (Sorry, I should have put Jim's name on most of the previous
changelog entries; I'll fix this in the ChangeLog files).
2003-08-14 Jim Meyering <address@hidden>
* lib/mountlist.c: Remove anachronistic casts of xmalloc, xrealloc,
and xcalloc return values.
(read_filesystem_list) [MOUNTED_GETFSSTAT]:
Use MNT_NOWAIT, rather than MNT_WAIT. Otherwise, `df DIR' could
hang on OSF/1 5.1 for DIR on both local and remote file systems.
Reported by (and fix confirmed by) Nelson H. F. Beebe.
(read_filesystem_list) [MOUNTED_VMOUNT]: Detect any
error from mntctl.
Use mntctl's return value to drive the entry-processing loop, since
we can't rely on the value of the vmt_length member in the last
entry. On some systems doing so could result in exhausting
virtual memory. Based in part on a patch from Mike Jetzer.
* m4/ls-mntd-fs.m4 (jm_LIST_MOUNTED_FILESYSTEMS): Move the
MOUNTED_VMOUNT
test to precede the MOUNTED_GETMNTENT1 tests, since otherwise, AIX 5.1
systems would end up using the latter. MOUNTED_GETMNTENT1 support
is inadequate on such systems: 1) detecting whether a file system
is remote doesn't work 2) the MOUNTED_VMOUNT code reports the
HOSTNAME:/MOUNT_POINT, while the MOUNTED_GETMNTENT1 code reports
merely /MOUNT_POINT. Reported by Mike Jetzer.
Index: lib/mountlist.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/mountlist.c,v
retrieving revision 1.40
diff -p -u -r1.40 mountlist.c
--- lib/mountlist.c 5 Apr 2003 06:46:00 -0000 1.40
+++ lib/mountlist.c 14 Aug 2003 23:31:24 -0000
@@ -322,21 +322,21 @@ read_filesystem_list (int need_fs_type)
remove. Specifically, automount create normal NFS mounts.
*/
- if(listmntent(&mntlist, KMTAB, NULL, NULL) < 0)
+ if (listmntent (&mntlist, KMTAB, NULL, NULL) < 0)
return NULL;
for (p = mntlist; p; p = p->next) {
mnt = p->ment;
- me = (struct mount_entry*) xmalloc(sizeof (struct mount_entry));
- me->me_devname = xstrdup(mnt->mnt_fsname);
- me->me_mountdir = xstrdup(mnt->mnt_dir);
- me->me_type = xstrdup(mnt->mnt_type);
+ me = xmalloc (sizeof (struct mount_entry));
+ me->me_devname = xstrdup (mnt->mnt_fsname);
+ me->me_mountdir = xstrdup (mnt->mnt_dir);
+ me->me_type = xstrdup (mnt->mnt_type);
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
me->me_dev = -1;
*mtail = me;
mtail = &me->me_next;
}
- freemntlist(mntlist);
+ freemntlist (mntlist);
}
#endif
@@ -353,7 +353,7 @@ read_filesystem_list (int need_fs_type)
while ((mnt = getmntent (fp)))
{
- me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
+ me = xmalloc (sizeof (struct mount_entry));
me->me_devname = xstrdup (mnt->mnt_fsname);
me->me_mountdir = xstrdup (mnt->mnt_dir);
me->me_type = xstrdup (mnt->mnt_type);
@@ -392,7 +392,7 @@ read_filesystem_list (int need_fs_type)
{
char *fs_type = fsp_to_string (fsp);
- me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
+ me = xmalloc (sizeof (struct mount_entry));
me->me_devname = xstrdup (fsp->f_mntfromname);
me->me_mountdir = xstrdup (fsp->f_mntonname);
me->me_type = fs_type;
@@ -417,7 +417,7 @@ read_filesystem_list (int need_fs_type)
0 < (val = getmnt (&offset, &fsd, sizeof (fsd), NOSTAT_MANY,
(char *) 0)))
{
- me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
+ me = xmalloc (sizeof (struct mount_entry));
me->me_devname = xstrdup (fsd.fd_req.devname);
me->me_mountdir = xstrdup (fsd.fd_req.path);
me->me_type = gt_names[fsd.fd_req.fstype];
@@ -489,7 +489,7 @@ read_filesystem_list (int need_fs_type)
{
struct rootdir_entry *re;
- re = (struct rootdir_entry *) xmalloc (sizeof (struct
rootdir_entry));
+ re = xmalloc (sizeof (struct rootdir_entry));
re->name = name;
re->dev = statbuf.st_dev;
re->ino = statbuf.st_ino;
@@ -515,7 +515,7 @@ read_filesystem_list (int need_fs_type)
if (re->dev == fi.dev && re->ino == fi.root)
break;
- me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
+ me = xmalloc (sizeof (struct mount_entry));
me->me_devname = xstrdup (fi.device_name[0] != '\0' ? fi.device_name
: fi.fsh_name);
me->me_mountdir = xstrdup (re != NULL ? re->name : fi.fsh_name);
me->me_type = xstrdup (fi.fsh_name);
@@ -544,13 +544,13 @@ read_filesystem_list (int need_fs_type)
int numsys, counter, bufsize;
struct statfs *stats;
- numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT);
+ numsys = getfsstat ((struct statfs *)0, 0L, MNT_NOWAIT);
if (numsys < 0)
return (NULL);
bufsize = (1 + numsys) * sizeof (struct statfs);
- stats = (struct statfs *)xmalloc (bufsize);
- numsys = getfsstat (stats, bufsize, MNT_WAIT);
+ stats = xmalloc (bufsize);
+ numsys = getfsstat (stats, bufsize, MNT_NOWAIT);
if (numsys < 0)
{
@@ -560,7 +560,7 @@ read_filesystem_list (int need_fs_type)
for (counter = 0; counter < numsys; counter++)
{
- me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
+ me = xmalloc (sizeof (struct mount_entry));
me->me_devname = xstrdup (stats[counter].f_mntfromname);
me->me_mountdir = xstrdup (stats[counter].f_mntonname);
me->me_type = xstrdup (FS_TYPE (stats[counter]));
@@ -589,7 +589,7 @@ read_filesystem_list (int need_fs_type)
while (fread (&mnt, sizeof mnt, 1, fp) > 0)
{
- me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
+ me = xmalloc (sizeof (struct mount_entry));
# ifdef GETFSTYP /* SVR3. */
me->me_devname = xstrdup (mnt.mt_dev);
# else
@@ -634,12 +634,12 @@ read_filesystem_list (int need_fs_type)
#ifdef MOUNTED_GETMNTTBL /* DolphinOS goes it's own way */
{
- struct mntent **mnttbl=getmnttbl(),**ent;
+ struct mntent **mnttbl = getmnttbl (), **ent;
for (ent=mnttbl;*ent;ent++)
{
- me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
+ me = xmalloc (sizeof (struct mount_entry));
me->me_devname = xstrdup ( (*ent)->mt_resource);
- me->me_mountdir = xstrdup( (*ent)->mt_directory);
+ me->me_mountdir = xstrdup ( (*ent)->mt_directory);
me->me_type = xstrdup ((*ent)->mt_fstype);
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
@@ -649,7 +649,7 @@ read_filesystem_list (int need_fs_type)
*mtail = me;
mtail = &me->me_next;
}
- endmnttbl();
+ endmnttbl ();
}
#endif
@@ -698,7 +698,7 @@ read_filesystem_list (int need_fs_type)
{
while ((ret = getmntent (fp, &mnt)) == 0)
{
- me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
+ me = xmalloc (sizeof (struct mount_entry));
me->me_devname = xstrdup (mnt.mnt_special);
me->me_mountdir = xstrdup (mnt.mnt_mountp);
me->me_type = xstrdup (mnt.mnt_fstype);
@@ -755,7 +755,7 @@ read_filesystem_list (int need_fs_type)
char *options, *ignore;
vmp = (struct vmount *) thisent;
- me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
+ me = xmalloc (sizeof (struct mount_entry));
if (vmp->vmt_flags & MNT_REMOTE)
{
char *host, *path;
Index: m4/ls-mntd-fs.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/ls-mntd-fs.m4,v
retrieving revision 1.24
diff -p -u -r1.24 ls-mntd-fs.m4
--- m4/ls-mntd-fs.m4 31 Dec 2002 13:43:06 -0000 1.24
+++ m4/ls-mntd-fs.m4 14 Aug 2003 23:31:24 -0000
@@ -1,4 +1,4 @@
-#serial 12
+#serial 13
dnl From Jim Meyering.
dnl
@@ -68,6 +68,23 @@ yes
fi
fi
+if test -z "$ac_list_mounted_fs"; then
+ # AIX.
+ AC_MSG_CHECKING([for mntctl function and struct vmount])
+ AC_CACHE_VAL(fu_cv_sys_mounted_vmount,
+ [AC_TRY_CPP([#include <fshelp.h>],
+ fu_cv_sys_mounted_vmount=yes,
+ fu_cv_sys_mounted_vmount=no)])
+ AC_MSG_RESULT($fu_cv_sys_mounted_vmount)
+ if test $fu_cv_sys_mounted_vmount = yes; then
+ ac_list_mounted_fs=found
+ AC_DEFINE(MOUNTED_VMOUNT, 1,
+ [Define if there is a function named mntctl that can be used to read
+ the list of mounted filesystems, and there is a system header file
+ that declares `struct vmount.' (AIX)])
+ fi
+fi
+
if test $ac_cv_func_getmntent = yes; then
# This system has the getmntent function.
@@ -151,23 +168,6 @@ if test -z "$ac_list_mounted_fs"; then
AC_DEFINE(MOUNTED_GETFSSTAT, 1,
[Define if there is a function named getfsstat for reading the
list of mounted filesystems. (DEC Alpha running OSF/1)])
- fi
-fi
-
-if test -z "$ac_list_mounted_fs"; then
- # AIX.
- AC_MSG_CHECKING([for mntctl function and struct vmount])
- AC_CACHE_VAL(fu_cv_sys_mounted_vmount,
- [AC_TRY_CPP([#include <fshelp.h>],
- fu_cv_sys_mounted_vmount=yes,
- fu_cv_sys_mounted_vmount=no)])
- AC_MSG_RESULT($fu_cv_sys_mounted_vmount)
- if test $fu_cv_sys_mounted_vmount = yes; then
- ac_list_mounted_fs=found
- AC_DEFINE(MOUNTED_VMOUNT, 1,
- [Define if there is a function named mntctl that can be used to read
- the list of mounted filesystems, and there is a system header file
- that declares `struct vmount.' (AIX)])
fi
fi
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Bug-gnulib] mountlist merges from coreutils,
Paul Eggert <=