| 1 | #serial 16
|
|---|
| 2 | # Obtaining file system usage information.
|
|---|
| 3 |
|
|---|
| 4 | # Copyright (C) 1997, 1998, 2000, 2001, 2003, 2004, 2005 Free Software
|
|---|
| 5 | # Foundation, Inc.
|
|---|
| 6 | #
|
|---|
| 7 | # This file is free software; the Free Software Foundation
|
|---|
| 8 | # gives unlimited permission to copy and/or distribute it,
|
|---|
| 9 | # with or without modifications, as long as this notice is preserved.
|
|---|
| 10 |
|
|---|
| 11 | # Written by Jim Meyering.
|
|---|
| 12 |
|
|---|
| 13 | AC_DEFUN([gl_FSUSAGE],
|
|---|
| 14 | [
|
|---|
| 15 | AC_LIBSOURCES([fsusage.c, fsusage.h])
|
|---|
| 16 |
|
|---|
| 17 | AC_CHECK_HEADERS_ONCE(sys/param.h)
|
|---|
| 18 | AC_CHECK_HEADERS_ONCE(sys/vfs.h sys/fs_types.h)
|
|---|
| 19 | AC_CHECK_HEADERS(sys/mount.h, [], [],
|
|---|
| 20 | [AC_INCLUDES_DEFAULT
|
|---|
| 21 | [#if HAVE_SYS_PARAM_H
|
|---|
| 22 | #include <sys/param.h>
|
|---|
| 23 | #endif]])
|
|---|
| 24 | gl_FILE_SYSTEM_USAGE([gl_cv_fs_space=yes], [gl_cv_fs_space=no])
|
|---|
| 25 | if test $gl_cv_fs_space = yes; then
|
|---|
| 26 | AC_LIBOBJ(fsusage)
|
|---|
| 27 | gl_PREREQ_FSUSAGE_EXTRA
|
|---|
| 28 | fi
|
|---|
| 29 | ])
|
|---|
| 30 |
|
|---|
| 31 | # Try to determine how a program can obtain file system usage information.
|
|---|
| 32 | # If successful, define the appropriate symbol (see fsusage.c) and
|
|---|
| 33 | # execute ACTION-IF-FOUND. Otherwise, execute ACTION-IF-NOT-FOUND.
|
|---|
| 34 | #
|
|---|
| 35 | # gl_FILE_SYSTEM_USAGE([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
|
|---|
| 36 |
|
|---|
| 37 | AC_DEFUN([gl_FILE_SYSTEM_USAGE],
|
|---|
| 38 | [
|
|---|
| 39 |
|
|---|
| 40 | echo "checking how to get file system space usage..."
|
|---|
| 41 | ac_fsusage_space=no
|
|---|
| 42 |
|
|---|
| 43 | # Perform only the link test since it seems there are no variants of the
|
|---|
| 44 | # statvfs function. This check is more than just AC_CHECK_FUNCS(statvfs)
|
|---|
| 45 | # because that got a false positive on SCO OSR5. Adding the declaration
|
|---|
| 46 | # of a `struct statvfs' causes this test to fail (as it should) on such
|
|---|
| 47 | # systems. That system is reported to work fine with STAT_STATFS4 which
|
|---|
| 48 | # is what it gets when this test fails.
|
|---|
| 49 | if test $ac_fsusage_space = no; then
|
|---|
| 50 | # SVR4
|
|---|
| 51 | AC_CACHE_CHECK([for statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
|
|---|
| 52 | [AC_TRY_LINK([#include <sys/types.h>
|
|---|
| 53 | #ifdef __GLIBC__
|
|---|
| 54 | Do not use statvfs on systems with GNU libc, because that function stats
|
|---|
| 55 | all preceding entries in /proc/mounts, and that makes df hang if even
|
|---|
| 56 | one of the corresponding file systems is hard-mounted, but not available.
|
|---|
| 57 | #endif
|
|---|
| 58 | #include <sys/statvfs.h>],
|
|---|
| 59 | [struct statvfs fsd; statvfs (0, &fsd);],
|
|---|
| 60 | fu_cv_sys_stat_statvfs=yes,
|
|---|
| 61 | fu_cv_sys_stat_statvfs=no)])
|
|---|
| 62 | if test $fu_cv_sys_stat_statvfs = yes; then
|
|---|
| 63 | ac_fsusage_space=yes
|
|---|
| 64 | AC_DEFINE(STAT_STATVFS, 1,
|
|---|
| 65 | [ Define if there is a function named statvfs. (SVR4)])
|
|---|
| 66 | fi
|
|---|
| 67 | fi
|
|---|
| 68 |
|
|---|
| 69 | if test $ac_fsusage_space = no; then
|
|---|
| 70 | # DEC Alpha running OSF/1
|
|---|
| 71 | AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
|
|---|
| 72 | AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
|
|---|
| 73 | [AC_TRY_RUN([
|
|---|
| 74 | #include <sys/param.h>
|
|---|
| 75 | #include <sys/types.h>
|
|---|
| 76 | #include <sys/mount.h>
|
|---|
| 77 | main ()
|
|---|
| 78 | {
|
|---|
| 79 | struct statfs fsd;
|
|---|
| 80 | fsd.f_fsize = 0;
|
|---|
| 81 | exit (statfs (".", &fsd, sizeof (struct statfs)));
|
|---|
| 82 | }],
|
|---|
| 83 | fu_cv_sys_stat_statfs3_osf1=yes,
|
|---|
| 84 | fu_cv_sys_stat_statfs3_osf1=no,
|
|---|
| 85 | fu_cv_sys_stat_statfs3_osf1=no)])
|
|---|
| 86 | AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
|
|---|
| 87 | if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
|
|---|
| 88 | ac_fsusage_space=yes
|
|---|
| 89 | AC_DEFINE(STAT_STATFS3_OSF1, 1,
|
|---|
| 90 | [ Define if statfs takes 3 args. (DEC Alpha running OSF/1)])
|
|---|
| 91 | fi
|
|---|
| 92 | fi
|
|---|
| 93 |
|
|---|
| 94 | if test $ac_fsusage_space = no; then
|
|---|
| 95 | # AIX
|
|---|
| 96 | AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
|
|---|
| 97 | member (AIX, 4.3BSD)])
|
|---|
| 98 | AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
|
|---|
| 99 | [AC_TRY_RUN([
|
|---|
| 100 | #ifdef HAVE_SYS_PARAM_H
|
|---|
| 101 | #include <sys/param.h>
|
|---|
| 102 | #endif
|
|---|
| 103 | #ifdef HAVE_SYS_MOUNT_H
|
|---|
| 104 | #include <sys/mount.h>
|
|---|
| 105 | #endif
|
|---|
| 106 | #ifdef HAVE_SYS_VFS_H
|
|---|
| 107 | #include <sys/vfs.h>
|
|---|
| 108 | #endif
|
|---|
| 109 | main ()
|
|---|
| 110 | {
|
|---|
| 111 | struct statfs fsd;
|
|---|
| 112 | fsd.f_bsize = 0;
|
|---|
| 113 | exit (statfs (".", &fsd));
|
|---|
| 114 | }],
|
|---|
| 115 | fu_cv_sys_stat_statfs2_bsize=yes,
|
|---|
| 116 | fu_cv_sys_stat_statfs2_bsize=no,
|
|---|
| 117 | fu_cv_sys_stat_statfs2_bsize=no)])
|
|---|
| 118 | AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
|
|---|
| 119 | if test $fu_cv_sys_stat_statfs2_bsize = yes; then
|
|---|
| 120 | ac_fsusage_space=yes
|
|---|
| 121 | AC_DEFINE(STAT_STATFS2_BSIZE, 1,
|
|---|
| 122 | [ Define if statfs takes 2 args and struct statfs has a field named f_bsize.
|
|---|
| 123 | (4.3BSD, SunOS 4, HP-UX, AIX PS/2)])
|
|---|
| 124 | fi
|
|---|
| 125 | fi
|
|---|
| 126 |
|
|---|
| 127 | if test $ac_fsusage_space = no; then
|
|---|
| 128 | # SVR3
|
|---|
| 129 | AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
|
|---|
| 130 | AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
|
|---|
| 131 | [AC_TRY_RUN([#include <sys/types.h>
|
|---|
| 132 | #include <sys/statfs.h>
|
|---|
| 133 | main ()
|
|---|
| 134 | {
|
|---|
| 135 | struct statfs fsd;
|
|---|
| 136 | exit (statfs (".", &fsd, sizeof fsd, 0));
|
|---|
| 137 | }],
|
|---|
| 138 | fu_cv_sys_stat_statfs4=yes,
|
|---|
| 139 | fu_cv_sys_stat_statfs4=no,
|
|---|
| 140 | fu_cv_sys_stat_statfs4=no)])
|
|---|
| 141 | AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
|
|---|
| 142 | if test $fu_cv_sys_stat_statfs4 = yes; then
|
|---|
| 143 | ac_fsusage_space=yes
|
|---|
| 144 | AC_DEFINE(STAT_STATFS4, 1,
|
|---|
| 145 | [ Define if statfs takes 4 args. (SVR3, Dynix, Irix, Dolphin)])
|
|---|
| 146 | fi
|
|---|
| 147 | fi
|
|---|
| 148 |
|
|---|
| 149 | if test $ac_fsusage_space = no; then
|
|---|
| 150 | # 4.4BSD and NetBSD
|
|---|
| 151 | AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
|
|---|
| 152 | member (4.4BSD and NetBSD)])
|
|---|
| 153 | AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
|
|---|
| 154 | [AC_TRY_RUN([#include <sys/types.h>
|
|---|
| 155 | #ifdef HAVE_SYS_PARAM_H
|
|---|
| 156 | #include <sys/param.h>
|
|---|
| 157 | #endif
|
|---|
| 158 | #ifdef HAVE_SYS_MOUNT_H
|
|---|
| 159 | #include <sys/mount.h>
|
|---|
| 160 | #endif
|
|---|
| 161 | main ()
|
|---|
| 162 | {
|
|---|
| 163 | struct statfs fsd;
|
|---|
| 164 | fsd.f_fsize = 0;
|
|---|
| 165 | exit (statfs (".", &fsd));
|
|---|
| 166 | }],
|
|---|
| 167 | fu_cv_sys_stat_statfs2_fsize=yes,
|
|---|
| 168 | fu_cv_sys_stat_statfs2_fsize=no,
|
|---|
| 169 | fu_cv_sys_stat_statfs2_fsize=no)])
|
|---|
| 170 | AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
|
|---|
| 171 | if test $fu_cv_sys_stat_statfs2_fsize = yes; then
|
|---|
| 172 | ac_fsusage_space=yes
|
|---|
| 173 | AC_DEFINE(STAT_STATFS2_FSIZE, 1,
|
|---|
| 174 | [ Define if statfs takes 2 args and struct statfs has a field named f_fsize.
|
|---|
| 175 | (4.4BSD, NetBSD)])
|
|---|
| 176 | fi
|
|---|
| 177 | fi
|
|---|
| 178 |
|
|---|
| 179 | if test $ac_fsusage_space = no; then
|
|---|
| 180 | # Ultrix
|
|---|
| 181 | AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
|
|---|
| 182 | AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
|
|---|
| 183 | [AC_TRY_RUN([#include <sys/types.h>
|
|---|
| 184 | #ifdef HAVE_SYS_PARAM_H
|
|---|
| 185 | #include <sys/param.h>
|
|---|
| 186 | #endif
|
|---|
| 187 | #ifdef HAVE_SYS_MOUNT_H
|
|---|
| 188 | #include <sys/mount.h>
|
|---|
| 189 | #endif
|
|---|
| 190 | #ifdef HAVE_SYS_FS_TYPES_H
|
|---|
| 191 | #include <sys/fs_types.h>
|
|---|
| 192 | #endif
|
|---|
| 193 | main ()
|
|---|
| 194 | {
|
|---|
| 195 | struct fs_data fsd;
|
|---|
| 196 | /* Ultrix's statfs returns 1 for success,
|
|---|
| 197 | 0 for not mounted, -1 for failure. */
|
|---|
| 198 | exit (statfs (".", &fsd) != 1);
|
|---|
| 199 | }],
|
|---|
| 200 | fu_cv_sys_stat_fs_data=yes,
|
|---|
| 201 | fu_cv_sys_stat_fs_data=no,
|
|---|
| 202 | fu_cv_sys_stat_fs_data=no)])
|
|---|
| 203 | AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
|
|---|
| 204 | if test $fu_cv_sys_stat_fs_data = yes; then
|
|---|
| 205 | ac_fsusage_space=yes
|
|---|
| 206 | AC_DEFINE(STAT_STATFS2_FS_DATA, 1,
|
|---|
| 207 | [ Define if statfs takes 2 args and the second argument has
|
|---|
| 208 | type struct fs_data. (Ultrix)])
|
|---|
| 209 | fi
|
|---|
| 210 | fi
|
|---|
| 211 |
|
|---|
| 212 | if test $ac_fsusage_space = no; then
|
|---|
| 213 | # SVR2
|
|---|
| 214 | AC_TRY_CPP([#include <sys/filsys.h>
|
|---|
| 215 | ],
|
|---|
| 216 | AC_DEFINE(STAT_READ_FILSYS, 1,
|
|---|
| 217 | [Define if there is no specific function for reading file systems usage
|
|---|
| 218 | information and you have the <sys/filsys.h> header file. (SVR2)])
|
|---|
| 219 | ac_fsusage_space=yes)
|
|---|
| 220 | fi
|
|---|
| 221 |
|
|---|
| 222 | AS_IF([test $ac_fsusage_space = yes], [$1], [$2])
|
|---|
| 223 |
|
|---|
| 224 | ])
|
|---|
| 225 |
|
|---|
| 226 |
|
|---|
| 227 | # Check for SunOS statfs brokenness wrt partitions 2GB and larger.
|
|---|
| 228 | # If <sys/vfs.h> exists and struct statfs has a member named f_spare,
|
|---|
| 229 | # enable the work-around code in fsusage.c.
|
|---|
| 230 | AC_DEFUN([gl_STATFS_TRUNCATES],
|
|---|
| 231 | [
|
|---|
| 232 | AC_MSG_CHECKING([for statfs that truncates block counts])
|
|---|
| 233 | AC_CACHE_VAL(fu_cv_sys_truncating_statfs,
|
|---|
| 234 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
|---|
| 235 | #if !defined(sun) && !defined(__sun)
|
|---|
| 236 | choke -- this is a workaround for a Sun-specific problem
|
|---|
| 237 | #endif
|
|---|
| 238 | #include <sys/types.h>
|
|---|
| 239 | #include <sys/vfs.h>]],
|
|---|
| 240 | [[struct statfs t; long c = *(t.f_spare);]])],
|
|---|
| 241 | [fu_cv_sys_truncating_statfs=yes],
|
|---|
| 242 | [fu_cv_sys_truncating_statfs=no])])
|
|---|
| 243 | if test $fu_cv_sys_truncating_statfs = yes; then
|
|---|
| 244 | AC_DEFINE(STATFS_TRUNCATES_BLOCK_COUNTS, 1,
|
|---|
| 245 | [Define if the block counts reported by statfs may be truncated to 2GB
|
|---|
| 246 | and the correct values may be stored in the f_spare array.
|
|---|
| 247 | (SunOS 4.1.2, 4.1.3, and 4.1.3_U1 are reported to have this problem.
|
|---|
| 248 | SunOS 4.1.1 seems not to be affected.)])
|
|---|
| 249 | fi
|
|---|
| 250 | AC_MSG_RESULT($fu_cv_sys_truncating_statfs)
|
|---|
| 251 | ])
|
|---|
| 252 |
|
|---|
| 253 |
|
|---|
| 254 | # Prerequisites of lib/fsusage.c not done by gl_FILE_SYSTEM_USAGE.
|
|---|
| 255 | AC_DEFUN([gl_PREREQ_FSUSAGE_EXTRA],
|
|---|
| 256 | [
|
|---|
| 257 | AC_REQUIRE([gl_AC_TYPE_UINTMAX_T])
|
|---|
| 258 | AC_CHECK_HEADERS(dustat.h sys/fs/s5param.h sys/filsys.h sys/statfs.h sys/statvfs.h)
|
|---|
| 259 | gl_STATFS_TRUNCATES
|
|---|
| 260 | ])
|
|---|