From 9e1dd4594d352bf3e31908a8c5031fc3f588cbff Mon Sep 17 00:00:00 2001 From: Pavel Tsekov Date: Sat, 17 Jun 2006 15:39:07 +0000 Subject: [PATCH] * m4/fstypename.m4: New file. * acinclude.m4 (AC_GET_FS_INFO): Add a check to determine whether getmntinfo() takes struct statvfs instead of struct statfs as its first argument. Define MOUNTED_GETMNTINFO_STATVFS if it does. Add a check to determine whether struct statvfs has a field named f_fstypename. Use gl_FSTYPENAME tp determine whether struct statfs has a field named f_fstypename. * src/mountlist.c (HAVE_F_FSTYPENAME): Define when getmntinfo() is used and the struct which it fills has a field named f_fstypename. (read_filesystem_list) [MOUNTED_GETMNTINFO]: Use MOUNTED_GETMNTINFO_STATVFS to determine the type of the first argument to getmntinfo(). --- ChangeLog | 11 +++++++++++ acinclude.m4 | 45 +++++++++++++++++++++++++++++++++++++++++++++ m4/fstypename.m4 | 37 +++++++++++++++++++++++++++++++++++++ src/ChangeLog | 8 ++++++++ src/mountlist.c | 14 ++++++++++++++ 5 files changed, 115 insertions(+) create mode 100644 m4/fstypename.m4 diff --git a/ChangeLog b/ChangeLog index 76f047dbe..492448cfb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2006-06-17 Pavel Tsekov + + * m4/fstypename.m4: New file. + * acinclude.m4 (AC_GET_FS_INFO): Add a check to determine whether + getmntinfo() takes struct statvfs instead of struct statfs as its + first argument. Define MOUNTED_GETMNTINFO_STATVFS if it does. + Add a check to determine whether struct statvfs has a field named + f_fstypename. + Use gl_FSTYPENAME tp determine whether struct statfs has a field + named f_fstypename. + 2006-06-07 Pavel Tsekov * configure.ac: Revert last commit. diff --git a/acinclude.m4 b/acinclude.m4 index e37ef3742..caa379412 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -283,6 +283,51 @@ AC_DEFUN([AC_GET_FS_INFO], [ [AC_MSG_WARN([could not determine how to read list of mounted fs])]) gl_FSUSAGE + + if test $ac_cv_func_getmntinfo = yes; then + if test $ac_cv_header_sys_statvfs_h = yes; then + AC_MSG_CHECKING([for getmntinfo taking struct statvfs as dnl +first argument (NetBSD 3.0)]) + AC_CACHE_VAL(mc_cv_sys_mounted_getmntinfo_statvfs, + [AC_TRY_RUN([ +#if HAVE_SYS_PARAM_H +#include +#endif +#if HAVE_SYS_TYPES_H +#include +#endif +#if HAVE_SYS_UCRED_H +#include /* needed by FreeBSD */ +#endif +#if HAVE_SYS_MOUNT_H +#include +#endif +#include +main () +{ +struct statvfs *mntbufp; +exit (getmntinfo (&mntbufp, MNT_NOWAIT)); +}], + mc_cv_sys_mounted_getmntinfo_statvfs=yes, + mc_cv_sys_mounted_getmntinfo_statvfs=no, + mc_cv_sys_mounted_getmntinfo_statvfs=no)]) + AC_MSG_RESULT($mc_cv_sys_mounted_getmntinfo_statvfs) + if test $mc_cv_sys_mounted_getmntinfo_statvfs = yes; then + AC_DEFINE(MOUNTED_GETMNTINFO_STATVFS, 1, + [Define if there is a function named getmntinfo for + reading the list of mounted file systems. (NetBSD 3.0)]) + fi + fi + fi + + gl_FSTYPENAME + + AC_CHECK_MEMBERS([struct statvfs.f_fstypename],,,[ + AC_INCLUDES_DEFAULT() + #ifdef HAVE_SYS_STATVFS_H + # include + #endif]) + ]) diff --git a/m4/fstypename.m4 b/m4/fstypename.m4 new file mode 100644 index 000000000..7ff33e20a --- /dev/null +++ b/m4/fstypename.m4 @@ -0,0 +1,37 @@ +#serial 5 + +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 + +# Copyright (C) 1998, 1999, 2001, 2004 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 + ] +) diff --git a/src/ChangeLog b/src/ChangeLog index 2cb535b40..a29efdd88 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2006-06-17 Pavel Tsekov + + * mountlist.c (HAVE_F_FSTYPENAME): Define when getmntinfo() is + used and the struct which it fills has a field named f_fstypename. + (read_filesystem_list) [MOUNTED_GETMNTINFO]: Use + MOUNTED_GETMNTINFO_STATVFS to determine the type of the first + argument to getmntinfo(). + 2006-06-11 Leonard den Ottolander * dir.c (sort_orders): Substitute duplicate hotkey 'C' in sort order diff --git a/src/mountlist.c b/src/mountlist.c index 6fe5c0e0b..c96f35e23 100644 --- a/src/mountlist.c +++ b/src/mountlist.c @@ -119,6 +119,16 @@ # define HAVE_INFOMOUNT #endif +#ifdef MOUNTED_GETMNTINFO_STATVFS +# if defined(HAVE_STRUCT_STATVFS_F_FSTYPENAME) +# define HAVE_F_FSTYPENAME +# endif +#elif MOUNTED_GETMNTINFO +# if defined(HAVE_F_FSTYPENAME_IN_STATFS) +# define HAVE_F_FSTYPENAME +# endif +#endif + /* A mount table entry. */ struct mount_entry { @@ -282,7 +292,11 @@ read_filesystem_list (int need_fs_type, int all_fs) #ifdef MOUNTED_GETMNTINFO /* 4.4BSD. */ { +#ifdef MOUNTED_GETMNTINFO_STATVFS + struct statvfs *fsp; +#else struct statfs *fsp; +#endif int entries; entries = getmntinfo (&fsp, MNT_NOWAIT);