fsusage.m4 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. #serial 7
  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. #include <sys/statvfs.h>],
  23. [struct statvfs fsd; statvfs (0, &fsd);],
  24. fu_cv_sys_stat_statvfs=yes,
  25. fu_cv_sys_stat_statvfs=no)])
  26. if test $fu_cv_sys_stat_statvfs = yes; then
  27. ac_fsusage_space=yes
  28. AC_DEFINE_UNQUOTED(STAT_STATVFS, 1,
  29. [ Define if there is a function named statvfs. (SVR4)])
  30. fi
  31. fi
  32. if test $ac_fsusage_space = no; then
  33. # DEC Alpha running OSF/1
  34. AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
  35. AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
  36. [AC_TRY_RUN([
  37. #include <sys/param.h>
  38. #include <sys/types.h>
  39. #include <sys/mount.h>
  40. main ()
  41. {
  42. struct statfs fsd;
  43. fsd.f_fsize = 0;
  44. exit (statfs (".", &fsd, sizeof (struct statfs)));
  45. }],
  46. fu_cv_sys_stat_statfs3_osf1=yes,
  47. fu_cv_sys_stat_statfs3_osf1=no,
  48. fu_cv_sys_stat_statfs3_osf1=no)])
  49. AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
  50. if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
  51. ac_fsusage_space=yes
  52. AC_DEFINE_UNQUOTED(STAT_STATFS3_OSF1, 1,
  53. [ Define if statfs takes 3 args. (DEC Alpha running OSF/1)])
  54. fi
  55. fi
  56. if test $ac_fsusage_space = no; then
  57. # AIX
  58. AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
  59. member (AIX, 4.3BSD)])
  60. AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
  61. [AC_TRY_RUN([
  62. #ifdef HAVE_SYS_PARAM_H
  63. #include <sys/param.h>
  64. #endif
  65. #ifdef HAVE_SYS_MOUNT_H
  66. #include <sys/mount.h>
  67. #endif
  68. #ifdef HAVE_SYS_VFS_H
  69. #include <sys/vfs.h>
  70. #endif
  71. main ()
  72. {
  73. struct statfs fsd;
  74. fsd.f_bsize = 0;
  75. exit (statfs (".", &fsd));
  76. }],
  77. fu_cv_sys_stat_statfs2_bsize=yes,
  78. fu_cv_sys_stat_statfs2_bsize=no,
  79. fu_cv_sys_stat_statfs2_bsize=no)])
  80. AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
  81. if test $fu_cv_sys_stat_statfs2_bsize = yes; then
  82. ac_fsusage_space=yes
  83. AC_DEFINE_UNQUOTED(STAT_STATFS2_BSIZE, 1,
  84. [ Define if statfs takes 2 args and struct statfs has a field named f_bsize.
  85. (4.3BSD, SunOS 4, HP-UX, AIX PS/2)])
  86. fi
  87. fi
  88. if test $ac_fsusage_space = no; then
  89. # SVR3
  90. AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
  91. AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
  92. [AC_TRY_RUN([#include <sys/types.h>
  93. #include <sys/statfs.h>
  94. main ()
  95. {
  96. struct statfs fsd;
  97. exit (statfs (".", &fsd, sizeof fsd, 0));
  98. }],
  99. fu_cv_sys_stat_statfs4=yes,
  100. fu_cv_sys_stat_statfs4=no,
  101. fu_cv_sys_stat_statfs4=no)])
  102. AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
  103. if test $fu_cv_sys_stat_statfs4 = yes; then
  104. ac_fsusage_space=yes
  105. AC_DEFINE_UNQUOTED(STAT_STATFS4, 1,
  106. [ Define if statfs takes 4 args. (SVR3, Dynix, Irix, Dolphin)])
  107. fi
  108. fi
  109. if test $ac_fsusage_space = no; then
  110. # 4.4BSD and NetBSD
  111. AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
  112. member (4.4BSD and NetBSD)])
  113. AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
  114. [AC_TRY_RUN([#include <sys/types.h>
  115. #ifdef HAVE_SYS_PARAM_H
  116. #include <sys/param.h>
  117. #endif
  118. #ifdef HAVE_SYS_MOUNT_H
  119. #include <sys/mount.h>
  120. #endif
  121. main ()
  122. {
  123. struct statfs fsd;
  124. fsd.f_fsize = 0;
  125. exit (statfs (".", &fsd));
  126. }],
  127. fu_cv_sys_stat_statfs2_fsize=yes,
  128. fu_cv_sys_stat_statfs2_fsize=no,
  129. fu_cv_sys_stat_statfs2_fsize=no)])
  130. AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
  131. if test $fu_cv_sys_stat_statfs2_fsize = yes; then
  132. ac_fsusage_space=yes
  133. AC_DEFINE_UNQUOTED(STAT_STATFS2_FSIZE, 1,
  134. [ Define if statfs takes 2 args and struct statfs has a field named f_fsize.
  135. (4.4BSD, NetBSD)])
  136. fi
  137. fi
  138. if test $ac_fsusage_space = no; then
  139. # Ultrix
  140. AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
  141. AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
  142. [AC_TRY_RUN([#include <sys/types.h>
  143. #ifdef HAVE_SYS_PARAM_H
  144. #include <sys/param.h>
  145. #endif
  146. #ifdef HAVE_SYS_MOUNT_H
  147. #include <sys/mount.h>
  148. #endif
  149. #ifdef HAVE_SYS_FS_TYPES_H
  150. #include <sys/fs_types.h>
  151. #endif
  152. main ()
  153. {
  154. struct fs_data fsd;
  155. /* Ultrix's statfs returns 1 for success,
  156. 0 for not mounted, -1 for failure. */
  157. exit (statfs (".", &fsd) != 1);
  158. }],
  159. fu_cv_sys_stat_fs_data=yes,
  160. fu_cv_sys_stat_fs_data=no,
  161. fu_cv_sys_stat_fs_data=no)])
  162. AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
  163. if test $fu_cv_sys_stat_fs_data = yes; then
  164. ac_fsusage_space=yes
  165. AC_DEFINE_UNQUOTED(STAT_STATFS2_FS_DATA, 1,
  166. [ Define if statfs takes 2 args and the second argument has
  167. type struct fs_data. (Ultrix)])
  168. fi
  169. fi
  170. if test $ac_fsusage_space = no; then
  171. # SVR2
  172. AC_TRY_CPP([#include <sys/filsys.h>
  173. ],
  174. AC_DEFINE_UNQUOTED(STAT_READ_FILSYS, 1,
  175. [Define if there is no specific function for reading filesystems usage
  176. information and you have the <sys/filsys.h> header file. (SVR2)])
  177. ac_fsusage_space=yes)
  178. fi
  179. dnl AS_IF([test $ac_fsusage_space = yes], [$1], [$2])
  180. if test $ac_fsusage_space = yes ; then [$1] ; else [$2] ; fi
  181. ])