diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2006-08-18 18:36:04 +0000 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2006-08-18 18:36:04 +0000 |
commit | 5f57935678613334bfa18ee547cb1f22a3a0a7dd (patch) | |
tree | e102859dc4d733d8423f0aaf91e26a8c3f9c0d2e | |
parent | 47c8512a6ff9a6df52f6848ff7881e5c55b719c2 (diff) | |
download | coreutils-5f57935678613334bfa18ee547cb1f22a3a0a7dd.tar.xz |
Add support for NetBSD 3.0.
* src/stat.c (USE_STATVFS): Set to 1 if 'struct statvfs' has a field
f_fstypename.
(STATXFS_FILE_SYSTEM_TYPE_MEMBER_NAME): Define also if 'struct statvfs'
has a field f_fstypename.
This undoes the 2006-08-15 to src/stat.c.
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
(ME_DUMMY): Treat "kernfs" as a dummy.
(read_file_system_list) [MOUNTED_GETMNTINFO2]: Implement.
* m4/ls-mntd-fs.m4 (gl_LIST_MOUNTED_FILE_SYSTEMS): Also check for
sys/statvfs.h. When getmntinfo was found, check its declaration and
set either MOUNTED_GETMNTINFO or MOUNTED_GETMNTINFO2 depending on it.
* m4/stat-prog.m4 (cu_PREREQ_STAT_PROG): Test also for f_fstypename
in struct statvfs.
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | lib/ChangeLog | 6 | ||||
-rw-r--r-- | lib/mountlist.c | 33 | ||||
-rw-r--r-- | m4/ChangeLog | 8 | ||||
-rw-r--r-- | m4/ls-mntd-fs.m4 | 38 | ||||
-rw-r--r-- | m4/stat-prog.m4 | 5 | ||||
-rw-r--r-- | src/stat.c | 11 |
7 files changed, 102 insertions, 15 deletions
@@ -1,3 +1,17 @@ +2006-08-18 Paul Eggert <eggert@cs.ucla.edu> + + * src/system.h (select_plural): Reduce by 1000000, not 1000, since + the CVS gettext manual now suggests 1000000. + +2006-08-18 Bruno Haible <bruno@clisp.org> + + Add support for NetBSD 3.0. + * src/stat.c (USE_STATVFS): Set to 1 if 'struct statvfs' has a field + f_fstypename. + (STATXFS_FILE_SYSTEM_TYPE_MEMBER_NAME): Define also if 'struct statvfs' + has a field f_fstypename. + This undoes the 2006-08-15 to src/stat.c. + 2006-08-17 Paul Eggert <eggert@cs.ucla.edu> Copyright notice fixes. @@ -420,7 +434,7 @@ * tests/misc/Makefile.am (TESTS): Add df. * tests/misc/df: New file. -2006-08-15 Eric Blake <ebb9@byu.net> +2006-08-15 Eric Blake <ebb9@byu.net> * src/stat.c (USE_STATVFS): Define to 0 if f_type is needed, but statvfs.f_type not present. See diff --git a/lib/ChangeLog b/lib/ChangeLog index 56e7a4adf..613ae228d 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,9 @@ +2006-08-18 Bruno Haible <bruno@clisp.org> + + * mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h. + (ME_DUMMY): Treat "kernfs" as a dummy. + (read_file_system_list) [MOUNTED_GETMNTINFO2]: Implement. + 2006-08-17 Paul Eggert <eggert@cs.ucla.edu> * ChangeLog: Add copyright notice. diff --git a/lib/mountlist.c b/lib/mountlist.c index 3774c8e4e..1b6424101 100644 --- a/lib/mountlist.c +++ b/lib/mountlist.c @@ -82,6 +82,10 @@ char *strstr (); # include <sys/mount.h> #endif +#ifdef MOUNTED_GETMNTINFO2 /* NetBSD 3.0. */ +# include <sys/statvfs.h> +#endif + #ifdef MOUNTED_GETMNT /* Ultrix. */ # include <sys/mount.h> # include <sys/fs_types.h> @@ -147,6 +151,8 @@ char *strstr (); || strcmp (Fs_type, "none") == 0 \ || strcmp (Fs_type, "proc") == 0 \ || strcmp (Fs_type, "subfs") == 0 \ + /* for NetBSD 3.0 */ \ + || strcmp (Fs_type, "kernfs") == 0 \ /* for Irix 6.5 */ \ || strcmp (Fs_type, "ignore") == 0) #endif @@ -260,7 +266,6 @@ fstype_to_string (short int t) } # endif /* ! HAVE_F_FSTYPENAME_IN_STATFS */ -/* __NetBSD__ || BSD_NET2 || __OpenBSD__ */ static char * fsp_to_string (const struct statfs *fsp) { @@ -426,6 +431,32 @@ read_file_system_list (bool need_fs_type) } #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 = xmalloc (sizeof *me); + me->me_devname = xstrdup (fsp->f_mntfromname); + me->me_mountdir = xstrdup (fsp->f_mntonname); + me->me_type = xstrdup (fsp->f_fstypename); + me->me_type_malloced = 1; + 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 = (dev_t) -1; /* Magic; means not known yet. */ + + /* Add to the linked list. */ + *mtail = me; + mtail = &me->me_next; + } + } +#endif /* MOUNTED_GETMNTINFO2 */ + #ifdef MOUNTED_GETMNT /* Ultrix. */ { int offset = 0; diff --git a/m4/ChangeLog b/m4/ChangeLog index 6bf97c912..a531c6665 100644 --- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,11 @@ +2006-08-18 Bruno Haible <bruno@clisp.org> + + * ls-mntd-fs.m4 (gl_LIST_MOUNTED_FILE_SYSTEMS): Also check for + sys/statvfs.h. When getmntinfo was found, check its declaration and + set either MOUNTED_GETMNTINFO or MOUNTED_GETMNTINFO2 depending on it. + * stat-prog.m4 (cu_PREREQ_STAT_PROG): Test also for f_fstypename + in struct statvfs. + 2006-08-18 Jim Meyering <jim@meyering.net> * gethrxtime.m4 (gl_PREREQ_GETHRXTIME): Also check for CLOCK_REALTIME, 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 <sys/types.h> +#if HAVE_SYS_MOUNT_H +# include <sys/mount.h> +#endif +#if HAVE_SYS_STATVFS_H +# include <sys/statvfs.h> +#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/m4/stat-prog.m4 b/m4/stat-prog.m4 index 489ed7558..4505f54a3 100644 --- a/m4/stat-prog.m4 +++ b/m4/stat-prog.m4 @@ -1,7 +1,7 @@ -# stat-prog.m4 serial 2 +# stat-prog.m4 serial 3 # Record the prerequisites of src/stat.c from the coreutils package. -# Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. +# Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -60,6 +60,7 @@ $ac_includes_default AC_CHECK_MEMBERS([struct statfs.f_basetype],,,[$statxfs_includes]) AC_CHECK_MEMBERS([struct statvfs.f_basetype],,,[$statxfs_includes]) AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$statxfs_includes]) + AC_CHECK_MEMBERS([struct statvfs.f_fstypename],,,[$statxfs_includes]) AC_CHECK_MEMBERS([struct statfs.f_type],,,[$statxfs_includes]) AC_CHECK_MEMBERS([struct statvfs.f_type],,,[$statxfs_includes]) AC_CHECK_MEMBERS([struct statfs.f_fsid.__val],,,[$statxfs_includes]) diff --git a/src/stat.c b/src/stat.c index 481096d27..4ea66fde7 100644 --- a/src/stat.c +++ b/src/stat.c @@ -20,8 +20,8 @@ #include <config.h> #if (STAT_STATVFS \ - && (HAVE_STRUCT_STATVFS_F_BASETYPE \ - || (! HAVE_STRUCT_STATFS_F_FSTYPENAME && HAVE_STRUCT_STATVFS_F_TYPE))) + && (HAVE_STRUCT_STATVFS_F_BASETYPE || HAVE_STRUCT_STATVFS_F_FSTYPENAME \ + || ! HAVE_STRUCT_STATFS_F_FSTYPENAME)) # define USE_STATVFS 1 #else # define USE_STATVFS 0 @@ -93,7 +93,7 @@ #if HAVE_STRUCT_STATVFS_F_BASETYPE # define STATXFS_FILE_SYSTEM_TYPE_MEMBER_NAME f_basetype #else -# if HAVE_STRUCT_STATFS_F_FSTYPENAME +# if HAVE_STRUCT_STATVFS_F_FSTYPENAME || HAVE_STRUCT_STATFS_F_FSTYPENAME # define STATXFS_FILE_SYSTEM_TYPE_MEMBER_NAME f_fstypename # endif #endif @@ -136,8 +136,9 @@ static bool interpret_backslash_escapes; static char const *trailing_delim = ""; /* Return the type of the specified file system. - Some systems have statfvs.f_basetype[FSTYPSZ]. (AIX, HP-UX, and Solaris) - Others have statfs.f_fstypename[MFSNAMELEN]. (NetBSD 1.5.2) + Some systems have statfvs.f_basetype[FSTYPSZ] (AIX, HP-UX, and Solaris). + Others have statvfs.f_fstypename[_VFS_NAMELEN] (NetBSD 3.0). + Others have statfs.f_fstypename[MFSNAMELEN] (NetBSD 1.5.2). Still others have neither and have to get by with f_type (Linux). */ static char const * human_fstype (STRUCT_STATVFS const *statfsbuf) |