fsusage.m4 5.7 KB

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