ls-mntd-fs.m4 9.1 KB

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