diff options
Diffstat (limited to 'gl/m4/fsusage.m4')
| -rw-r--r-- | gl/m4/fsusage.m4 | 127 |
1 files changed, 101 insertions, 26 deletions
diff --git a/gl/m4/fsusage.m4 b/gl/m4/fsusage.m4 index 216b9dd8..6277bfa5 100644 --- a/gl/m4/fsusage.m4 +++ b/gl/m4/fsusage.m4 | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | # serial 25 | 1 | # serial 30 |
| 2 | # Obtaining file system usage information. | 2 | # Obtaining file system usage information. |
| 3 | 3 | ||
| 4 | # Copyright (C) 1997-1998, 2000-2001, 2003-2010 Free Software Foundation, Inc. | 4 | # Copyright (C) 1997-1998, 2000-2001, 2003-2013 Free Software Foundation, Inc. |
| 5 | # | 5 | # |
| 6 | # This file is free software; the Free Software Foundation | 6 | # This file is free software; the Free Software Foundation |
| 7 | # gives unlimited permission to copy and/or distribute it, | 7 | # gives unlimited permission to copy and/or distribute it, |
| @@ -19,10 +19,6 @@ AC_DEFUN([gl_FSUSAGE], | |||
| 19 | #include <sys/param.h> | 19 | #include <sys/param.h> |
| 20 | #endif]]) | 20 | #endif]]) |
| 21 | gl_FILE_SYSTEM_USAGE([gl_cv_fs_space=yes], [gl_cv_fs_space=no]) | 21 | gl_FILE_SYSTEM_USAGE([gl_cv_fs_space=yes], [gl_cv_fs_space=no]) |
| 22 | if test $gl_cv_fs_space = yes; then | ||
| 23 | AC_LIBOBJ([fsusage]) | ||
| 24 | gl_PREREQ_FSUSAGE_EXTRA | ||
| 25 | fi | ||
| 26 | ]) | 22 | ]) |
| 27 | 23 | ||
| 28 | # Try to determine how a program can obtain file system usage information. | 24 | # Try to determine how a program can obtain file system usage information. |
| @@ -33,6 +29,12 @@ AC_DEFUN([gl_FSUSAGE], | |||
| 33 | 29 | ||
| 34 | AC_DEFUN([gl_FILE_SYSTEM_USAGE], | 30 | AC_DEFUN([gl_FILE_SYSTEM_USAGE], |
| 35 | [ | 31 | [ |
| 32 | dnl Enable large-file support. This has the effect of changing the size | ||
| 33 | dnl of field f_blocks in 'struct statvfs' from 32 bit to 64 bit on | ||
| 34 | dnl glibc/Hurd, HP-UX 11, Solaris (32-bit mode). It also changes the size | ||
| 35 | dnl of field f_blocks in 'struct statfs' from 32 bit to 64 bit on | ||
| 36 | dnl Mac OS X >= 10.5 (32-bit mode). | ||
| 37 | AC_REQUIRE([AC_SYS_LARGEFILE]) | ||
| 36 | 38 | ||
| 37 | AC_MSG_NOTICE([checking how to get file system space usage]) | 39 | AC_MSG_NOTICE([checking how to get file system space usage]) |
| 38 | ac_fsusage_space=no | 40 | ac_fsusage_space=no |
| @@ -40,36 +42,98 @@ ac_fsusage_space=no | |||
| 40 | # Perform only the link test since it seems there are no variants of the | 42 | # Perform only the link test since it seems there are no variants of the |
| 41 | # statvfs function. This check is more than just AC_CHECK_FUNCS([statvfs]) | 43 | # statvfs function. This check is more than just AC_CHECK_FUNCS([statvfs]) |
| 42 | # because that got a false positive on SCO OSR5. Adding the declaration | 44 | # because that got a false positive on SCO OSR5. Adding the declaration |
| 43 | # of a `struct statvfs' causes this test to fail (as it should) on such | 45 | # of a 'struct statvfs' causes this test to fail (as it should) on such |
| 44 | # systems. That system is reported to work fine with STAT_STATFS4 which | 46 | # systems. That system is reported to work fine with STAT_STATFS4 which |
| 45 | # is what it gets when this test fails. | 47 | # is what it gets when this test fails. |
| 46 | if test $ac_fsusage_space = no; then | 48 | if test $ac_fsusage_space = no; then |
| 47 | # SVR4 | 49 | # glibc/{Hurd,kFreeBSD}, FreeBSD >= 5.0, NetBSD >= 3.0, |
| 50 | # OpenBSD >= 4.4, AIX, HP-UX, IRIX, Solaris, Cygwin, Interix, BeOS. | ||
| 48 | AC_CACHE_CHECK([for statvfs function (SVR4)], [fu_cv_sys_stat_statvfs], | 51 | AC_CACHE_CHECK([for statvfs function (SVR4)], [fu_cv_sys_stat_statvfs], |
| 49 | [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> | 52 | [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> |
| 50 | #if defined __GLIBC__ && defined __linux__ | ||
| 51 | Do not use statvfs on systems with GNU libc on Linux, because that function | ||
| 52 | stats all preceding entries in /proc/mounts, and that makes df hang if even | ||
| 53 | one of the corresponding file systems is hard-mounted, but not available. | ||
| 54 | statvfs in GNU libc on Hurd, BeOS, Haiku operates differently: it only makes | ||
| 55 | a system call. | ||
| 56 | #endif | ||
| 57 | |||
| 58 | #ifdef __osf__ | 53 | #ifdef __osf__ |
| 59 | "Do not use Tru64's statvfs implementation" | 54 | "Do not use Tru64's statvfs implementation" |
| 60 | #endif | 55 | #endif |
| 61 | 56 | ||
| 62 | #include <sys/statvfs.h>]], | 57 | #include <sys/statvfs.h> |
| 63 | [[struct statvfs fsd; statvfs (0, &fsd);]])], | 58 | |
| 59 | struct statvfs fsd; | ||
| 60 | |||
| 61 | #if defined __APPLE__ && defined __MACH__ | ||
| 62 | #include <limits.h> | ||
| 63 | /* On Mac OS X >= 10.5, f_blocks in 'struct statvfs' is a 32-bit quantity; | ||
| 64 | that commonly limits file systems to 4 TiB. Whereas f_blocks in | ||
| 65 | 'struct statfs' is a 64-bit type, thanks to the large-file support | ||
| 66 | that was enabled above. In this case, don't use statvfs(); use statfs() | ||
| 67 | instead. */ | ||
| 68 | int check_f_blocks_size[sizeof fsd.f_blocks * CHAR_BIT <= 32 ? -1 : 1]; | ||
| 69 | #endif | ||
| 70 | ]], | ||
| 71 | [[statvfs (0, &fsd);]])], | ||
| 64 | [fu_cv_sys_stat_statvfs=yes], | 72 | [fu_cv_sys_stat_statvfs=yes], |
| 65 | [fu_cv_sys_stat_statvfs=no])]) | 73 | [fu_cv_sys_stat_statvfs=no])]) |
| 66 | if test $fu_cv_sys_stat_statvfs = yes; then | 74 | if test $fu_cv_sys_stat_statvfs = yes; then |
| 67 | ac_fsusage_space=yes | 75 | ac_fsusage_space=yes |
| 68 | AC_DEFINE([STAT_STATVFS], [1], | 76 | # AIX >= 5.2 has statvfs64 that has a wider f_blocks field than statvfs. |
| 69 | [ Define if there is a function named statvfs. (SVR4)]) | 77 | # glibc, HP-UX, IRIX, Solaris have statvfs64 as well, but on these systems |
| 78 | # statvfs with large-file support is already equivalent to statvfs64. | ||
| 79 | AC_CACHE_CHECK([whether to use statvfs64], | ||
| 80 | [fu_cv_sys_stat_statvfs64], | ||
| 81 | [AC_LINK_IFELSE( | ||
| 82 | [AC_LANG_PROGRAM( | ||
| 83 | [[#include <sys/types.h> | ||
| 84 | #include <sys/statvfs.h> | ||
| 85 | struct statvfs64 fsd; | ||
| 86 | int check_f_blocks_larger_in_statvfs64 | ||
| 87 | [sizeof (((struct statvfs64 *) 0)->f_blocks) | ||
| 88 | > sizeof (((struct statvfs *) 0)->f_blocks) | ||
| 89 | ? 1 : -1]; | ||
| 90 | ]], | ||
| 91 | [[statvfs64 (0, &fsd);]])], | ||
| 92 | [fu_cv_sys_stat_statvfs64=yes], | ||
| 93 | [fu_cv_sys_stat_statvfs64=no]) | ||
| 94 | ]) | ||
| 95 | if test $fu_cv_sys_stat_statvfs64 = yes; then | ||
| 96 | AC_DEFINE([STAT_STATVFS64], [1], | ||
| 97 | [ Define if statvfs64 should be preferred over statvfs.]) | ||
| 98 | else | ||
| 99 | AC_DEFINE([STAT_STATVFS], [1], | ||
| 100 | [ Define if there is a function named statvfs. (SVR4)]) | ||
| 101 | fi | ||
| 70 | fi | 102 | fi |
| 71 | fi | 103 | fi |
| 72 | 104 | ||
| 105 | # Check for this unconditionally so we have a | ||
| 106 | # good fallback on glibc/Linux > 2.6 < 2.6.36 | ||
| 107 | AC_MSG_CHECKING([for two-argument statfs with statfs.f_frsize member]) | ||
| 108 | AC_CACHE_VAL([fu_cv_sys_stat_statfs2_frsize], | ||
| 109 | [AC_RUN_IFELSE([AC_LANG_SOURCE([[ | ||
| 110 | #ifdef HAVE_SYS_PARAM_H | ||
| 111 | #include <sys/param.h> | ||
| 112 | #endif | ||
| 113 | #ifdef HAVE_SYS_MOUNT_H | ||
| 114 | #include <sys/mount.h> | ||
| 115 | #endif | ||
| 116 | #ifdef HAVE_SYS_VFS_H | ||
| 117 | #include <sys/vfs.h> | ||
| 118 | #endif | ||
| 119 | int | ||
| 120 | main () | ||
| 121 | { | ||
| 122 | struct statfs fsd; | ||
| 123 | fsd.f_frsize = 0; | ||
| 124 | return statfs (".", &fsd) != 0; | ||
| 125 | }]])], | ||
| 126 | [fu_cv_sys_stat_statfs2_frsize=yes], | ||
| 127 | [fu_cv_sys_stat_statfs2_frsize=no], | ||
| 128 | [fu_cv_sys_stat_statfs2_frsize=no])]) | ||
| 129 | AC_MSG_RESULT([$fu_cv_sys_stat_statfs2_frsize]) | ||
| 130 | if test $fu_cv_sys_stat_statfs2_frsize = yes; then | ||
| 131 | ac_fsusage_space=yes | ||
| 132 | AC_DEFINE([STAT_STATFS2_FRSIZE], [1], | ||
| 133 | [ Define if statfs takes 2 args and struct statfs has a field named f_frsize. | ||
| 134 | (glibc/Linux > 2.6)]) | ||
| 135 | fi | ||
| 136 | |||
| 73 | if test $ac_fsusage_space = no; then | 137 | if test $ac_fsusage_space = no; then |
| 74 | # DEC Alpha running OSF/1 | 138 | # DEC Alpha running OSF/1 |
| 75 | AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)]) | 139 | AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)]) |
| @@ -97,8 +161,13 @@ if test $ac_fsusage_space = no; then | |||
| 97 | fi | 161 | fi |
| 98 | 162 | ||
| 99 | if test $ac_fsusage_space = no; then | 163 | if test $ac_fsusage_space = no; then |
| 100 | # AIX | 164 | # glibc/Linux, Mac OS X, FreeBSD < 5.0, NetBSD < 3.0, OpenBSD < 4.4. |
| 101 | AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl | 165 | # (glibc/{Hurd,kFreeBSD}, FreeBSD >= 5.0, NetBSD >= 3.0, |
| 166 | # OpenBSD >= 4.4, AIX, HP-UX, OSF/1, Cygwin already handled above.) | ||
| 167 | # (On IRIX you need to include <sys/statfs.h>, not only <sys/mount.h> and | ||
| 168 | # <sys/vfs.h>.) | ||
| 169 | # (On Solaris, statfs has 4 arguments.) | ||
| 170 | AC_MSG_CHECKING([for two-argument statfs with statfs.f_bsize dnl | ||
| 102 | member (AIX, 4.3BSD)]) | 171 | member (AIX, 4.3BSD)]) |
| 103 | AC_CACHE_VAL([fu_cv_sys_stat_statfs2_bsize], | 172 | AC_CACHE_VAL([fu_cv_sys_stat_statfs2_bsize], |
| 104 | [AC_RUN_IFELSE([AC_LANG_SOURCE([[ | 173 | [AC_RUN_IFELSE([AC_LANG_SOURCE([[ |
| @@ -131,7 +200,8 @@ member (AIX, 4.3BSD)]) | |||
| 131 | fi | 200 | fi |
| 132 | 201 | ||
| 133 | if test $ac_fsusage_space = no; then | 202 | if test $ac_fsusage_space = no; then |
| 134 | # SVR3 | 203 | # SVR3 |
| 204 | # (Solaris already handled above.) | ||
| 135 | AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)]) | 205 | AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)]) |
| 136 | AC_CACHE_VAL([fu_cv_sys_stat_statfs4], | 206 | AC_CACHE_VAL([fu_cv_sys_stat_statfs4], |
| 137 | [AC_RUN_IFELSE([AC_LANG_SOURCE([[ | 207 | [AC_RUN_IFELSE([AC_LANG_SOURCE([[ |
| @@ -150,13 +220,17 @@ if test $ac_fsusage_space = no; then | |||
| 150 | if test $fu_cv_sys_stat_statfs4 = yes; then | 220 | if test $fu_cv_sys_stat_statfs4 = yes; then |
| 151 | ac_fsusage_space=yes | 221 | ac_fsusage_space=yes |
| 152 | AC_DEFINE([STAT_STATFS4], [1], | 222 | AC_DEFINE([STAT_STATFS4], [1], |
| 153 | [ Define if statfs takes 4 args. (SVR3, Dynix, Irix, Dolphin)]) | 223 | [ Define if statfs takes 4 args. (SVR3, Dynix, old Irix, old AIX, Dolphin)]) |
| 154 | fi | 224 | fi |
| 155 | fi | 225 | fi |
| 156 | 226 | ||
| 157 | if test $ac_fsusage_space = no; then | 227 | if test $ac_fsusage_space = no; then |
| 158 | # 4.4BSD and NetBSD | 228 | # 4.4BSD and older NetBSD |
| 159 | AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl | 229 | # (OSF/1 already handled above.) |
| 230 | # (On AIX, you need to include <sys/statfs.h>, not only <sys/mount.h>.) | ||
| 231 | # (On Solaris, statfs has 4 arguments and 'struct statfs' is not declared in | ||
| 232 | # <sys/mount.h>.) | ||
| 233 | AC_MSG_CHECKING([for two-argument statfs with statfs.f_fsize dnl | ||
| 160 | member (4.4BSD and NetBSD)]) | 234 | member (4.4BSD and NetBSD)]) |
| 161 | AC_CACHE_VAL([fu_cv_sys_stat_statfs2_fsize], | 235 | AC_CACHE_VAL([fu_cv_sys_stat_statfs2_fsize], |
| 162 | [AC_RUN_IFELSE([AC_LANG_SOURCE([[ | 236 | [AC_RUN_IFELSE([AC_LANG_SOURCE([[ |
| @@ -223,6 +297,7 @@ fi | |||
| 223 | 297 | ||
| 224 | if test $ac_fsusage_space = no; then | 298 | if test $ac_fsusage_space = no; then |
| 225 | # SVR2 | 299 | # SVR2 |
| 300 | # (AIX, HP-UX, OSF/1 already handled above.) | ||
| 226 | AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <sys/filsys.h> | 301 | AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <sys/filsys.h> |
| 227 | ]])], | 302 | ]])], |
| 228 | [AC_DEFINE([STAT_READ_FILSYS], [1], | 303 | [AC_DEFINE([STAT_READ_FILSYS], [1], |
