ls-mntd-fs.m4 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. #serial 10
  2. dnl From Jim Meyering.
  3. dnl
  4. dnl This is not pretty. I've just taken the autoconf code and wrapped
  5. dnl it in an AC_DEFUN.
  6. dnl
  7. # jm_LIST_MOUNTED_FILESYSTEMS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
  8. AC_DEFUN(jm_LIST_MOUNTED_FILESYSTEMS,
  9. [
  10. AC_CHECK_FUNCS(listmntent getmntinfo)
  11. AC_CHECK_HEADERS(mntent.h)
  12. # Determine how to get the list of mounted filesystems.
  13. ac_list_mounted_fs=
  14. # If the getmntent function is available but not in the standard library,
  15. # make sure LIBS contains -lsun (on Irix4) or -lseq (on PTX).
  16. AC_FUNC_GETMNTENT
  17. # This test must precede the ones for getmntent because Unicos-9 is
  18. # reported to have the getmntent function, but its support is incompatible
  19. # with other getmntent implementations.
  20. # NOTE: Normally, I wouldn't use a check for system type as I've done for
  21. # `CRAY' below since that goes against the whole autoconf philosophy. But
  22. # I think there is too great a chance that some non-Cray system has a
  23. # function named listmntent to risk the false positive.
  24. if test -z "$ac_list_mounted_fs"; then
  25. # Cray UNICOS 9
  26. AC_MSG_CHECKING([for listmntent of Cray/Unicos-9])
  27. AC_CACHE_VAL(fu_cv_sys_mounted_cray_listmntent,
  28. [fu_cv_sys_mounted_cray_listmntent=no
  29. AC_EGREP_CPP(yes,
  30. [#ifdef _CRAY
  31. yes
  32. #endif
  33. ], [test $ac_cv_func_listmntent = yes \
  34. && fu_cv_sys_mounted_cray_listmntent=yes]
  35. )
  36. ]
  37. )
  38. AC_MSG_RESULT($fu_cv_sys_mounted_cray_listmntent)
  39. if test $fu_cv_sys_mounted_cray_listmntent = yes; then
  40. ac_list_mounted_fs=found
  41. AC_DEFINE_UNQUOTED(MOUNTED_LISTMNTENT, 1,
  42. [Define if there is a function named listmntent that can be used to
  43. list all mounted filesystems. (UNICOS)])
  44. fi
  45. fi
  46. if test $ac_cv_func_getmntent = yes; then
  47. # This system has the getmntent function.
  48. # Determine whether it's the one-argument variant or the two-argument one.
  49. if test -z "$ac_list_mounted_fs"; then
  50. # 4.3BSD, SunOS, HP-UX, Dynix, Irix
  51. AC_MSG_CHECKING([for one-argument getmntent function])
  52. AC_CACHE_VAL(fu_cv_sys_mounted_getmntent1,
  53. [test $ac_cv_header_mntent_h = yes \
  54. && fu_cv_sys_mounted_getmntent1=yes \
  55. || fu_cv_sys_mounted_getmntent1=no])
  56. AC_MSG_RESULT($fu_cv_sys_mounted_getmntent1)
  57. if test $fu_cv_sys_mounted_getmntent1 = yes; then
  58. ac_list_mounted_fs=found
  59. AC_DEFINE_UNQUOTED(MOUNTED_GETMNTENT1, 1,
  60. [Define if there is a function named getmntent for reading the list
  61. of mounted filesystems, and that function takes a single argument.
  62. (4.3BSD, SunOS, HP-UX, Dynix, Irix)])
  63. fi
  64. fi
  65. if test -z "$ac_list_mounted_fs"; then
  66. # SVR4
  67. AC_MSG_CHECKING([for two-argument getmntent function])
  68. AC_CACHE_VAL(fu_cv_sys_mounted_getmntent2,
  69. [AC_EGREP_HEADER(getmntent, sys/mnttab.h,
  70. fu_cv_sys_mounted_getmntent2=yes,
  71. fu_cv_sys_mounted_getmntent2=no)])
  72. AC_MSG_RESULT($fu_cv_sys_mounted_getmntent2)
  73. if test $fu_cv_sys_mounted_getmntent2 = yes; then
  74. ac_list_mounted_fs=found
  75. AC_DEFINE_UNQUOTED(MOUNTED_GETMNTENT2, 1,
  76. [Define if there is a function named getmntent for reading the list of
  77. mounted filesystems, and that function takes two arguments. (SVR4)])
  78. fi
  79. fi
  80. if test -z "$ac_list_mounted_fs"; then
  81. AC_MSG_ERROR([could not determine how to read list of mounted filesystems])
  82. fi
  83. fi
  84. if test -z "$ac_list_mounted_fs"; then
  85. # DEC Alpha running OSF/1.
  86. AC_MSG_CHECKING([for getfsstat function])
  87. AC_CACHE_VAL(fu_cv_sys_mounted_getsstat,
  88. [AC_TRY_LINK([
  89. #include <sys/types.h>
  90. #include <sys/mount.h>
  91. #include <sys/fs_types.h>],
  92. [struct statfs *stats;
  93. int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT); ],
  94. fu_cv_sys_mounted_getsstat=yes,
  95. fu_cv_sys_mounted_getsstat=no)])
  96. AC_MSG_RESULT($fu_cv_sys_mounted_getsstat)
  97. if test $fu_cv_sys_mounted_getsstat = yes; then
  98. ac_list_mounted_fs=found
  99. AC_DEFINE_UNQUOTED(MOUNTED_GETFSSTAT, 1,
  100. [Define if there is a function named getfsstat for reading the
  101. list of mounted filesystems. (DEC Alpha running OSF/1)])
  102. fi
  103. fi
  104. if test -z "$ac_list_mounted_fs"; then
  105. # AIX.
  106. AC_MSG_CHECKING([for mntctl function and struct vmount])
  107. AC_CACHE_VAL(fu_cv_sys_mounted_vmount,
  108. [AC_TRY_CPP([#include <fshelp.h>],
  109. fu_cv_sys_mounted_vmount=yes,
  110. fu_cv_sys_mounted_vmount=no)])
  111. AC_MSG_RESULT($fu_cv_sys_mounted_vmount)
  112. if test $fu_cv_sys_mounted_vmount = yes; then
  113. ac_list_mounted_fs=found
  114. AC_DEFINE_UNQUOTED(MOUNTED_VMOUNT, 1,
  115. [Define if there is a function named mntctl that can be used to read
  116. the list of mounted filesystems, and there is a system header file
  117. that declares struct vmount. (AIX)])
  118. fi
  119. fi
  120. if test -z "$ac_list_mounted_fs"; then
  121. # SVR3
  122. AC_MSG_CHECKING([for FIXME existence of three headers])
  123. AC_CACHE_VAL(fu_cv_sys_mounted_fread_fstyp,
  124. [AC_TRY_CPP([
  125. #include <sys/statfs.h>
  126. #include <sys/fstyp.h>
  127. #include <mnttab.h>],
  128. fu_cv_sys_mounted_fread_fstyp=yes,
  129. fu_cv_sys_mounted_fread_fstyp=no)])
  130. AC_MSG_RESULT($fu_cv_sys_mounted_fread_fstyp)
  131. if test $fu_cv_sys_mounted_fread_fstyp = yes; then
  132. ac_list_mounted_fs=found
  133. AC_DEFINE_UNQUOTED(MOUNTED_FREAD_FSTYP, 1,
  134. [Define if (like SVR2) there is no specific function for reading the
  135. list of mounted filesystems, and your system has these header files:
  136. <sys/fstyp.h> and <sys/statfs.h>. (SVR3)])
  137. fi
  138. fi
  139. if test -z "$ac_list_mounted_fs"; then
  140. # 4.4BSD and DEC OSF/1.
  141. AC_MSG_CHECKING([for getmntinfo function])
  142. AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo,
  143. [
  144. ok=
  145. if test $ac_cv_func_getmntinfo = yes; then
  146. AC_EGREP_HEADER(f_type;, sys/mount.h,
  147. ok=yes)
  148. fi
  149. test -n "$ok" \
  150. && fu_cv_sys_mounted_getmntinfo=yes \
  151. || fu_cv_sys_mounted_getmntinfo=no
  152. ])
  153. AC_MSG_RESULT($fu_cv_sys_mounted_getmntinfo)
  154. if test $fu_cv_sys_mounted_getmntinfo = yes; then
  155. ac_list_mounted_fs=found
  156. AC_DEFINE_UNQUOTED(MOUNTED_GETMNTINFO, 1,
  157. [Define if there is a function named getmntinfo for reading the
  158. list of mounted filesystems. (4.4BSD)])
  159. fi
  160. fi
  161. if test -z "$ac_list_mounted_fs"; then
  162. # Ultrix
  163. AC_MSG_CHECKING([for getmnt function])
  164. AC_CACHE_VAL(fu_cv_sys_mounted_getmnt,
  165. [AC_TRY_CPP([
  166. #include <sys/fs_types.h>
  167. #include <sys/mount.h>],
  168. fu_cv_sys_mounted_getmnt=yes,
  169. fu_cv_sys_mounted_getmnt=no)])
  170. AC_MSG_RESULT($fu_cv_sys_mounted_getmnt)
  171. if test $fu_cv_sys_mounted_getmnt = yes; then
  172. ac_list_mounted_fs=found
  173. AC_DEFINE_UNQUOTED(MOUNTED_GETMNT, 1,
  174. [Define if there is a function named getmnt for reading the list of
  175. mounted filesystems. (Ultrix)])
  176. fi
  177. fi
  178. if test -z "$ac_list_mounted_fs"; then
  179. # BeOS
  180. AC_CHECK_FUNCS(next_dev fs_stat_dev)
  181. AC_CHECK_HEADERS(fs_info.h)
  182. AC_MSG_CHECKING([for BEOS mounted file system support functions])
  183. if test $ac_cv_header_fs_info_h = yes \
  184. && test $ac_cv_func_next_dev = yes \
  185. && test $ac_cv_func_fs_stat_dev = yes; then
  186. fu_result=yes
  187. else
  188. fu_result=no
  189. fi
  190. AC_MSG_RESULT($fu_result)
  191. if test $fu_result = yes; then
  192. ac_list_mounted_fs=found
  193. AC_DEFINE_UNQUOTED(MOUNTED_FS_STAT_DEV, 1,
  194. [Define if there are functions named next_dev and fs_stat_dev for
  195. reading the list of mounted filesystems. (BeOS)])
  196. fi
  197. fi
  198. if test -z "$ac_list_mounted_fs"; then
  199. # SVR2
  200. AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab])
  201. AC_CACHE_VAL(fu_cv_sys_mounted_fread,
  202. [AC_TRY_CPP([#include <mnttab.h>],
  203. fu_cv_sys_mounted_fread=yes,
  204. fu_cv_sys_mounted_fread=no)])
  205. AC_MSG_RESULT($fu_cv_sys_mounted_fread)
  206. if test $fu_cv_sys_mounted_fread = yes; then
  207. ac_list_mounted_fs=found
  208. AC_DEFINE_UNQUOTED(MOUNTED_FREAD, 1,
  209. [Define if there is no specific function for reading the list of
  210. mounted filesystems. fread will be used to read /etc/mnttab. (SVR2) ])
  211. fi
  212. fi
  213. if test -z "$ac_list_mounted_fs"; then
  214. AC_MSG_ERROR([could not determine how to read list of mounted filesystems])
  215. # FIXME -- no need to abort building the whole package
  216. # Can't build mountlist.c or anything that needs its functions
  217. fi
  218. dnl AS_IF([test $ac_list_mounted_fs = found], [$1], [$2])
  219. if test $ac_list_mounted_fs = found ; then [$1] ; else [$2] ; fi
  220. ])