ls-mntd-fs.m4 8.7 KB

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