From d407b130f49293c88ae8378ec0340f5d7672f2af Mon Sep 17 00:00:00 2001 From: Pavel Tsekov Date: Thu, 7 Sep 2006 15:12:47 +0000 Subject: [PATCH] * m4/ls-mntd-fs.m4: Update to serial#22, which adds support for getmntinfo() returning its result in struct statvfs. * m4/fstypename.m4: Update to serial#6, which replaces HAVE_F_FSTYPENAME_IN_STATFS with HAVE_STRUCT_STATFS_F_FSTYPENAME. * src/mountlist.c: Sync with gnulib. All uses of HAVE_F_FSTYPENAME replaced by HAVE_STRUCT_STATFS_F_FSTYPENAME. [MOUNTED_GETMNTINFO2] Include sys/statvfs.h. (read_file_system_list) [MOUNTED_GETMNTINFO2]: Implement. --- ChangeLog | 7 +++++++ m4/fstypename.m4 | 37 +++++++++++-------------------------- m4/ls-mntd-fs.m4 | 38 ++++++++++++++++++++++++++++++++------ src/ChangeLog | 8 ++++++++ src/mountlist.c | 32 +++++++++++++++++++++++++++++--- 5 files changed, 87 insertions(+), 35 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0e28bd584..6fe3f38e1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-09-07 Pavel Tsekov + + * m4/ls-mntd-fs.m4: Update to serial#22, which adds support + for getmntinfo() returning its result in struct statvfs. + * m4/fstypename.m4: Update to serial#6, which replaces + HAVE_F_FSTYPENAME_IN_STATFS with HAVE_STRUCT_STATFS_F_FSTYPENAME. + 2006-09-07 Pavel Tsekov * acinclude.m4 (AC_GET_FS_INFO): Revert a failed attempt to diff --git a/m4/fstypename.m4 b/m4/fstypename.m4 index 7ff33e20a..aa676f3ae 100644 --- a/m4/fstypename.m4 +++ b/m4/fstypename.m4 @@ -1,37 +1,22 @@ -#serial 5 +#serial 6 dnl From Jim Meyering. dnl dnl See if struct statfs has the f_fstypename member. -dnl If so, define HAVE_F_FSTYPENAME_IN_STATFS. +dnl If so, define HAVE_STRUCT_STATFS_F_FSTYPENAME. dnl -# Copyright (C) 1998, 1999, 2001, 2004 Free Software Foundation, Inc. +# Copyright (C) 1998, 1999, 2001, 2004, 2006 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FSTYPENAME], - [ - AC_CACHE_CHECK([for f_fstypename in struct statfs], - fu_cv_sys_f_fstypename_in_statfs, - [ - AC_TRY_COMPILE( - [ -#include -#include -#include - ], - [struct statfs s; int i = sizeof s.f_fstypename;], - fu_cv_sys_f_fstypename_in_statfs=yes, - fu_cv_sys_f_fstypename_in_statfs=no - ) - ] - ) - - if test $fu_cv_sys_f_fstypename_in_statfs = yes; then - AC_DEFINE(HAVE_F_FSTYPENAME_IN_STATFS, 1, - [Define if struct statfs has the f_fstypename member.]) - fi - ] -) +[ + AC_CHECK_MEMBERS([struct statfs.f_fstypename],,, + [ + #include + #include + #include + ]) +]) diff --git a/m4/ls-mntd-fs.m4 b/m4/ls-mntd-fs.m4 index a4c808907..c29933162 100644 --- a/m4/ls-mntd-fs.m4 +++ b/m4/ls-mntd-fs.m4 @@ -1,4 +1,4 @@ -#serial 21 +#serial 22 # How to list mounted file systems. # Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006 Free Software @@ -28,7 +28,7 @@ AC_CHECK_FUNCS(getmntent) AC_DEFUN([gl_LIST_MOUNTED_FILE_SYSTEMS], [ AC_CHECK_FUNCS(listmntent getmntinfo) -AC_CHECK_HEADERS_ONCE(sys/param.h) +AC_CHECK_HEADERS_ONCE(sys/param.h sys/statvfs.h) # We must include grp.h before ucred.h on OSF V4.0, since ucred.h uses # NGROUPS (as the array dimension for a struct member) without a definition. @@ -232,10 +232,36 @@ if test -z "$ac_list_mounted_fs"; then ]) AC_MSG_RESULT($fu_cv_sys_mounted_getmntinfo) if test $fu_cv_sys_mounted_getmntinfo = yes; then - ac_list_mounted_fs=found - AC_DEFINE(MOUNTED_GETMNTINFO, 1, - [Define if there is a function named getmntinfo for reading the - list of mounted file systems. (4.4BSD, Darwin)]) + AC_MSG_CHECKING([whether getmntinfo returns statvfs structures]) + AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo2, + [ + AC_TRY_COMPILE([ +#include +#if HAVE_SYS_MOUNT_H +# include +#endif +#if HAVE_SYS_STATVFS_H +# include +#endif +extern int getmntinfo (struct statfs **, int); + ], [], + [fu_cv_sys_mounted_getmntinfo2=no], + [fu_cv_sys_mounted_getmntinfo2=yes]) + ]) + AC_MSG_RESULT([$fu_cv_sys_mounted_getmntinfo2]) + if test $fu_cv_sys_mounted_getmntinfo2 = no; then + ac_list_mounted_fs=found + AC_DEFINE(MOUNTED_GETMNTINFO, 1, + [Define if there is a function named getmntinfo for reading the + list of mounted file systems and it returns an array of + 'struct statfs'. (4.4BSD, Darwin)]) + else + ac_list_mounted_fs=found + AC_DEFINE(MOUNTED_GETMNTINFO2, 1, + [Define if there is a function named getmntinfo for reading the + list of mounted file systems and it returns an array of + 'struct statvfs'. (NetBSD 3.0)]) + fi fi fi diff --git a/src/ChangeLog b/src/ChangeLog index 7fa753569..6ec8cfa44 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2006-09-07 Pavel Tsekov + + * mountlist.c: Sync with gnulib. + All uses of HAVE_F_FSTYPENAME replaced by + HAVE_STRUCT_STATFS_F_FSTYPENAME. + [MOUNTED_GETMNTINFO2] Include sys/statvfs.h. + (read_file_system_list) [MOUNTED_GETMNTINFO2]: Implement. + 2006-09-07 Pavel Tsekov * mountlist.c: Revert a failed attempt to properly detect and use diff --git a/src/mountlist.c b/src/mountlist.c index 355cf81d8..7a6ed8c19 100644 --- a/src/mountlist.c +++ b/src/mountlist.c @@ -48,6 +48,10 @@ #include #endif +#ifdef MOUNTED_GETMNTINFO2 /* NetBSD 3.0. */ +#include +#endif + #ifdef MOUNTED_GETMNT /* Ultrix. */ #include #include @@ -169,7 +173,7 @@ static int xatoi (const char *cp) } #endif /* MOUNTED_GETMNTENT1 */ -#if defined (MOUNTED_GETMNTINFO) && !defined (HAVE_F_FSTYPENAME) +#if ! HAVE_STRUCT_STATFS_F_FSTYPENAME static char *fstype_to_string (short t) { switch (t) { @@ -261,7 +265,7 @@ static char *fstype_to_string (short t) return "?"; } } -#endif /* MOUNTED_GETMNTINFO && !HAVE_F_FSTYPENAME */ +#endif /* ! HAVE_STRUCT_STATFS_F_FSTYPENAME */ #ifdef MOUNTED_VMOUNT /* AIX. */ static char * @@ -352,7 +356,7 @@ read_filesystem_list (int need_fs_type, int all_fs) me = (struct mount_entry *) malloc (sizeof (struct mount_entry)); me->me_devname = strdup (fsp->f_mntfromname); me->me_mountdir = strdup (fsp->f_mntonname); -#ifdef HAVE_F_FSTYPENAME +#ifdef HAVE_STRUCT_STATFS_F_FSTYPENAME me->me_type = strdup (fsp->f_fstypename); #else me->me_type = fstype_to_string (fsp->f_type); @@ -368,6 +372,28 @@ read_filesystem_list (int need_fs_type, int all_fs) } #endif /* MOUNTED_GETMNTINFO */ +#ifdef MOUNTED_GETMNTINFO2 /* NetBSD 3.0. */ + { + struct statvfs *fsp; + int entries; + + entries = getmntinfo (&fsp, MNT_NOWAIT); + if (entries < 0) + return NULL; + for (; entries-- > 0; fsp++) { + me = (struct mount_entry *) malloc (sizeof (struct mount_entry)); + me->me_devname = strdup (fsp->f_mntfromname); + me->me_mountdir = strdup (fsp->f_mntonname); + me->me_type = strdup (fsp->f_fstypename); + me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ + + /* Add to the linked list. */ + mtail->me_next = me; + mtail = me; + } + } +#endif /* MOUNTED_GETMNTINFO2 */ + #ifdef MOUNTED_GETMNT /* Ultrix. */ { int offset = 0;