fsusage.m4 7.2 KB

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