ac-get-fs-info.m4 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. #serial 6
  2. # How to list mounted file systems.
  3. # Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006 Free Software
  4. # Foundation, Inc.
  5. #
  6. # This file is free software; the Free Software Foundation
  7. # gives unlimited permission to copy and/or distribute it,
  8. # with or without modifications, as long as this notice is preserved.
  9. dnl From Jim Meyering.
  10. dnl
  11. dnl This is not pretty. I've just taken the autoconf code and wrapped
  12. dnl it in an AC_DEFUN and made some other fixes.
  13. dnl
  14. # Replace Autoconf's AC_FUNC_GETMNTENT to work around a bug in Autoconf
  15. # through Autoconf 2.59. We can remove this once we assume Autoconf 2.60
  16. # or later.
  17. AC_DEFUN([AC_FUNC_GETMNTENT],
  18. [# getmntent is in the standard C library on UNICOS, in -lsun on Irix 4,
  19. # -lseq on Dynix/PTX, -lgen on Unixware.
  20. AC_SEARCH_LIBS(getmntent, [sun seq gen])
  21. AC_CHECK_FUNCS(getmntent)
  22. ])
  23. # gl_LIST_MOUNTED_FILE_SYSTEMS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
  24. AC_DEFUN([gl_LIST_MOUNTED_FILE_SYSTEMS],
  25. [
  26. AC_CHECK_FUNCS(listmntent getmntinfo)
  27. AC_CHECK_HEADERS_ONCE(sys/param.h sys/statvfs.h)
  28. # We must include grp.h before ucred.h on OSF V4.0, since ucred.h uses
  29. # NGROUPS (as the array dimension for a struct member) without a definition.
  30. AC_CHECK_HEADERS(sys/ucred.h, [], [], [#include <grp.h>])
  31. AC_CHECK_HEADERS(sys/mount.h, [], [],
  32. [AC_INCLUDES_DEFAULT
  33. [#if HAVE_SYS_PARAM_H
  34. #include <sys/param.h>
  35. #endif]])
  36. AC_CHECK_HEADERS(mntent.h sys/fs_types.h)
  37. getfsstat_includes="\
  38. $ac_includes_default
  39. #if HAVE_SYS_PARAM_H
  40. # include <sys/param.h> /* needed by powerpc-apple-darwin1.3.7 */
  41. #endif
  42. #if HAVE_SYS_UCRED_H
  43. # include <grp.h> /* needed for definition of NGROUPS */
  44. # include <sys/ucred.h> /* needed by powerpc-apple-darwin1.3.7 */
  45. #endif
  46. #if HAVE_SYS_MOUNT_H
  47. # include <sys/mount.h>
  48. #endif
  49. #if HAVE_SYS_FS_TYPES_H
  50. # include <sys/fs_types.h> /* needed by powerpc-apple-darwin1.3.7 */
  51. #endif
  52. "
  53. AC_CHECK_MEMBERS([struct fsstat.f_fstypename],,,[$getfsstat_includes])
  54. # Determine how to get the list of mounted file systems.
  55. ac_list_mounted_fs=
  56. # If the getmntent function is available but not in the standard library,
  57. # make sure LIBS contains the appropriate -l option.
  58. AC_FUNC_GETMNTENT
  59. # This test must precede the ones for getmntent because Unicos-9 is
  60. # reported to have the getmntent function, but its support is incompatible
  61. # with other getmntent implementations.
  62. # NOTE: Normally, I wouldn't use a check for system type as I've done for
  63. # `CRAY' below since that goes against the whole autoconf philosophy. But
  64. # I think there is too great a chance that some non-Cray system has a
  65. # function named listmntent to risk the false positive.
  66. if test x"$ac_list_mounted_fs" = x; then
  67. # Cray UNICOS 9
  68. AC_MSG_CHECKING([for listmntent of Cray/Unicos-9])
  69. AC_CACHE_VAL(fu_cv_sys_mounted_cray_listmntent,
  70. [fu_cv_sys_mounted_cray_listmntent=no
  71. AC_EGREP_CPP(yes,
  72. [#ifdef _CRAY
  73. yes
  74. #endif
  75. ], [test x"$ac_cv_func_listmntent" = xyes \
  76. && fu_cv_sys_mounted_cray_listmntent=yes]
  77. )
  78. ]
  79. )
  80. AC_MSG_RESULT($fu_cv_sys_mounted_cray_listmntent)
  81. if test x"$fu_cv_sys_mounted_cray_listmntent" = xyes; then
  82. ac_list_mounted_fs=found
  83. AC_DEFINE(MOUNTED_LISTMNTENT, 1,
  84. [Define if there is a function named listmntent that can be used to
  85. list all mounted file systems. (UNICOS)])
  86. fi
  87. fi
  88. if test x"$ac_list_mounted_fs" = x; then
  89. # AIX.
  90. AC_MSG_CHECKING([for mntctl function and struct vmount])
  91. AC_CACHE_VAL(fu_cv_sys_mounted_vmount,
  92. [AC_TRY_CPP([#include <fshelp.h>],
  93. fu_cv_sys_mounted_vmount=yes,
  94. fu_cv_sys_mounted_vmount=no)])
  95. AC_MSG_RESULT($fu_cv_sys_mounted_vmount)
  96. if test x"$fu_cv_sys_mounted_vmount" = xyes; then
  97. ac_list_mounted_fs=found
  98. AC_DEFINE(MOUNTED_VMOUNT, 1,
  99. [Define if there is a function named mntctl that can be used to read
  100. the list of mounted file systems, and there is a system header file
  101. that declares `struct vmount.' (AIX)])
  102. fi
  103. fi
  104. if test x"$ac_cv_func_getmntent" = xyes; then
  105. # This system has the getmntent function.
  106. # Determine whether it's the one-argument variant or the two-argument one.
  107. if test x"$ac_list_mounted_fs" = x; then
  108. # 4.3BSD, SunOS, HP-UX, Dynix, Irix
  109. AC_MSG_CHECKING([for one-argument getmntent function])
  110. AC_CACHE_VAL(fu_cv_sys_mounted_getmntent1,
  111. [AC_TRY_COMPILE([
  112. /* SunOS 4.1.x /usr/include/mntent.h needs this for FILE */
  113. #include <stdio.h>
  114. #include <mntent.h>
  115. #if !defined MOUNTED
  116. # if defined _PATH_MOUNTED /* GNU libc */
  117. # define MOUNTED _PATH_MOUNTED
  118. # endif
  119. # if defined MNT_MNTTAB /* HP-UX. */
  120. # define MOUNTED MNT_MNTTAB
  121. # endif
  122. # if defined MNTTABNAME /* Dynix. */
  123. # define MOUNTED MNTTABNAME
  124. # endif
  125. #endif
  126. ],
  127. [ struct mntent *mnt = 0; const char *table = MOUNTED;
  128. if (sizeof mnt && sizeof table) return 0;],
  129. fu_cv_sys_mounted_getmntent1=yes,
  130. fu_cv_sys_mounted_getmntent1=no)])
  131. AC_MSG_RESULT($fu_cv_sys_mounted_getmntent1)
  132. if test x"$fu_cv_sys_mounted_getmntent1" = xyes; then
  133. ac_list_mounted_fs=found
  134. AC_DEFINE(MOUNTED_GETMNTENT1, 1,
  135. [Define if there is a function named getmntent for reading the list
  136. of mounted file systems, and that function takes a single argument.
  137. (4.3BSD, SunOS, HP-UX, Dynix, Irix)])
  138. fi
  139. fi
  140. if test x"$ac_list_mounted_fs" = x; then
  141. # SVR4
  142. AC_MSG_CHECKING([for two-argument getmntent function])
  143. AC_CACHE_VAL(fu_cv_sys_mounted_getmntent2,
  144. [AC_EGREP_HEADER(getmntent, sys/mnttab.h,
  145. fu_cv_sys_mounted_getmntent2=yes,
  146. fu_cv_sys_mounted_getmntent2=no)])
  147. AC_MSG_RESULT($fu_cv_sys_mounted_getmntent2)
  148. if test x"$fu_cv_sys_mounted_getmntent2" = xyes; then
  149. ac_list_mounted_fs=found
  150. AC_DEFINE(MOUNTED_GETMNTENT2, 1,
  151. [Define if there is a function named getmntent for reading the list of
  152. mounted file systems, and that function takes two arguments. (SVR4)])
  153. AC_CHECK_FUNCS(hasmntopt)
  154. fi
  155. fi
  156. fi
  157. if test x"$ac_list_mounted_fs" = x; then
  158. # DEC Alpha running OSF/1, and Apple Darwin 1.3.
  159. # powerpc-apple-darwin1.3.7 needs sys/param.h sys/ucred.h sys/fs_types.h
  160. AC_MSG_CHECKING([for getfsstat function])
  161. AC_CACHE_VAL(fu_cv_sys_mounted_getfsstat,
  162. [AC_TRY_LINK([
  163. #include <sys/types.h>
  164. #if HAVE_STRUCT_FSSTAT_F_FSTYPENAME
  165. # define FS_TYPE(Ent) ((Ent).f_fstypename)
  166. #else
  167. # define FS_TYPE(Ent) mnt_names[(Ent).f_type]
  168. #endif
  169. ]$getfsstat_includes
  170. ,
  171. [struct statfs *stats;
  172. int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT);
  173. char *t = FS_TYPE (*stats); ],
  174. fu_cv_sys_mounted_getfsstat=yes,
  175. fu_cv_sys_mounted_getfsstat=no)])
  176. AC_MSG_RESULT($fu_cv_sys_mounted_getfsstat)
  177. if test x"$fu_cv_sys_mounted_getfsstat" = xyes; then
  178. ac_list_mounted_fs=found
  179. AC_DEFINE(MOUNTED_GETFSSTAT, 1,
  180. [Define if there is a function named getfsstat for reading the
  181. list of mounted file systems. (DEC Alpha running OSF/1)])
  182. fi
  183. fi
  184. if test x"$ac_list_mounted_fs" = x; then
  185. # SVR3
  186. AC_MSG_CHECKING([for FIXME existence of three headers])
  187. AC_CACHE_VAL(fu_cv_sys_mounted_fread_fstyp,
  188. [AC_TRY_CPP([
  189. #include <sys/statfs.h>
  190. #include <sys/fstyp.h>
  191. #include <mnttab.h>],
  192. fu_cv_sys_mounted_fread_fstyp=yes,
  193. fu_cv_sys_mounted_fread_fstyp=no)])
  194. AC_MSG_RESULT($fu_cv_sys_mounted_fread_fstyp)
  195. if test x"$fu_cv_sys_mounted_fread_fstyp" = xyes; then
  196. ac_list_mounted_fs=found
  197. AC_DEFINE(MOUNTED_FREAD_FSTYP, 1,
  198. [Define if (like SVR2) there is no specific function for reading the
  199. list of mounted file systems, and your system has these header files:
  200. <sys/fstyp.h> and <sys/statfs.h>. (SVR3)])
  201. fi
  202. fi
  203. if test x"$ac_list_mounted_fs" = x; then
  204. # 4.4BSD and DEC OSF/1.
  205. AC_MSG_CHECKING([for getmntinfo function])
  206. AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo,
  207. [
  208. test x"$ac_cv_func_getmntinfo" = xyes \
  209. && fu_cv_sys_mounted_getmntinfo=yes \
  210. || fu_cv_sys_mounted_getmntinfo=no
  211. ])
  212. AC_MSG_RESULT($fu_cv_sys_mounted_getmntinfo)
  213. if test x"$fu_cv_sys_mounted_getmntinfo" = xyes; then
  214. AC_MSG_CHECKING([whether getmntinfo returns statvfs structures])
  215. AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo2,
  216. [
  217. AC_TRY_COMPILE([
  218. #if HAVE_SYS_PARAM_H
  219. # include <sys/param.h>
  220. #endif
  221. #include <sys/types.h>
  222. #if HAVE_SYS_MOUNT_H
  223. # include <sys/mount.h>
  224. #endif
  225. #if HAVE_SYS_STATVFS_H
  226. # include <sys/statvfs.h>
  227. #endif
  228. extern int getmntinfo (struct statfs **, int);
  229. ], [],
  230. [fu_cv_sys_mounted_getmntinfo2=no],
  231. [fu_cv_sys_mounted_getmntinfo2=yes])
  232. ])
  233. AC_MSG_RESULT([$fu_cv_sys_mounted_getmntinfo2])
  234. if test x"$fu_cv_sys_mounted_getmntinfo2" = xno; then
  235. ac_list_mounted_fs=found
  236. AC_DEFINE(MOUNTED_GETMNTINFO, 1,
  237. [Define if there is a function named getmntinfo for reading the
  238. list of mounted file systems and it returns an array of
  239. 'struct statfs'. (4.4BSD, Darwin)])
  240. else
  241. ac_list_mounted_fs=found
  242. AC_DEFINE(MOUNTED_GETMNTINFO2, 1,
  243. [Define if there is a function named getmntinfo for reading the
  244. list of mounted file systems and it returns an array of
  245. 'struct statvfs'. (NetBSD 3.0)])
  246. fi
  247. fi
  248. fi
  249. if test x"$ac_list_mounted_fs" = x; then
  250. # Ultrix
  251. AC_MSG_CHECKING([for getmnt function])
  252. AC_CACHE_VAL(fu_cv_sys_mounted_getmnt,
  253. [AC_TRY_CPP([
  254. #include <sys/fs_types.h>
  255. #include <sys/mount.h>],
  256. fu_cv_sys_mounted_getmnt=yes,
  257. fu_cv_sys_mounted_getmnt=no)])
  258. AC_MSG_RESULT($fu_cv_sys_mounted_getmnt)
  259. if test x"$fu_cv_sys_mounted_getmnt" = xyes; then
  260. ac_list_mounted_fs=found
  261. AC_DEFINE(MOUNTED_GETMNT, 1,
  262. [Define if there is a function named getmnt for reading the list of
  263. mounted file systems. (Ultrix)])
  264. fi
  265. fi
  266. if test x"$ac_list_mounted_fs" = x; then
  267. # BeOS
  268. AC_CHECK_FUNCS(next_dev fs_stat_dev)
  269. AC_CHECK_HEADERS(fs_info.h)
  270. AC_MSG_CHECKING([for BEOS mounted file system support functions])
  271. if test x"$ac_cv_header_fs_info_h" = xyes \
  272. && test x"$ac_cv_func_next_dev" = xyes \
  273. && test x"$ac_cv_func_fs_stat_dev" = xyes; then
  274. fu_result=yes
  275. else
  276. fu_result=no
  277. fi
  278. AC_MSG_RESULT($fu_result)
  279. if test x"$fu_result" = xyes; then
  280. ac_list_mounted_fs=found
  281. AC_DEFINE(MOUNTED_FS_STAT_DEV, 1,
  282. [Define if there are functions named next_dev and fs_stat_dev for
  283. reading the list of mounted file systems. (BeOS)])
  284. fi
  285. fi
  286. if test x"$ac_list_mounted_fs" = x; then
  287. # SVR2
  288. AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab])
  289. AC_CACHE_VAL(fu_cv_sys_mounted_fread,
  290. [AC_TRY_CPP([#include <mnttab.h>],
  291. fu_cv_sys_mounted_fread=yes,
  292. fu_cv_sys_mounted_fread=no)])
  293. AC_MSG_RESULT($fu_cv_sys_mounted_fread)
  294. if test x"$fu_cv_sys_mounted_fread" = xyes; then
  295. ac_list_mounted_fs=found
  296. AC_DEFINE(MOUNTED_FREAD, 1,
  297. [Define if there is no specific function for reading the list of
  298. mounted file systems. fread will be used to read /etc/mnttab.
  299. (SVR2) ])
  300. fi
  301. fi
  302. if test x"$ac_list_mounted_fs" = x; then
  303. AC_MSG_ERROR([could not determine how to read list of mounted file systems])
  304. # FIXME -- no need to abort building the whole package
  305. # Can't build mountlist.c or anything that needs its functions
  306. fi
  307. AS_IF([test x"$ac_list_mounted_fs" = xfound], [$1], [$2])
  308. ])
  309. # Obtaining file system usage information.
  310. # Copyright (C) 1997, 1998, 2000, 2001, 2003-2007 Free Software Foundation, Inc.
  311. #
  312. # This file is free software; the Free Software Foundation
  313. # gives unlimited permission to copy and/or distribute it,
  314. # with or without modifications, as long as this notice is preserved.
  315. # Written by Jim Meyering.
  316. AC_DEFUN([gl_FSUSAGE],
  317. [
  318. AC_LIBSOURCES([fsusage.c, fsusage.h])
  319. AC_CHECK_HEADERS_ONCE(sys/param.h)
  320. AC_CHECK_HEADERS_ONCE(sys/vfs.h sys/fs_types.h)
  321. AC_CHECK_HEADERS(sys/mount.h, [], [],
  322. [AC_INCLUDES_DEFAULT
  323. [#if HAVE_SYS_PARAM_H
  324. #include <sys/param.h>
  325. #endif]])
  326. gl_FILE_SYSTEM_USAGE([gl_cv_fs_space=yes], [gl_cv_fs_space=no])
  327. if test x"$gl_cv_fs_space" = xyes; then
  328. AC_LIBOBJ(fsusage)
  329. gl_PREREQ_FSUSAGE_EXTRA
  330. fi
  331. ])
  332. # Try to determine how a program can obtain file system usage information.
  333. # If successful, define the appropriate symbol (see fsusage.c) and
  334. # execute ACTION-IF-FOUND. Otherwise, execute ACTION-IF-NOT-FOUND.
  335. #
  336. # gl_FILE_SYSTEM_USAGE([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
  337. AC_DEFUN([gl_FILE_SYSTEM_USAGE],
  338. [
  339. AC_MSG_NOTICE([checking how to get file system space usage])
  340. ac_fsusage_space=no
  341. # Perform only the link test since it seems there are no variants of the
  342. # statvfs function. This check is more than just AC_CHECK_FUNCS(statvfs)
  343. # because that got a false positive on SCO OSR5. Adding the declaration
  344. # of a `struct statvfs' causes this test to fail (as it should) on such
  345. # systems. That system is reported to work fine with STAT_STATFS4 which
  346. # is what it gets when this test fails.
  347. if test x"$ac_fsusage_space" = xno; then
  348. # SVR4
  349. AC_CACHE_CHECK([for statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
  350. [AC_TRY_LINK([#include <sys/types.h>
  351. #if defined __GLIBC__ && !defined __BEOS__
  352. Do not use statvfs on systems with GNU libc, because that function stats
  353. all preceding entries in /proc/mounts, and that makes df hang if even
  354. one of the corresponding file systems is hard-mounted, but not available.
  355. statvfs in GNU libc on BeOS operates differently: it only makes a system
  356. call.
  357. #endif
  358. #ifdef __osf__
  359. "Do not use Tru64's statvfs implementation"
  360. #endif
  361. #include <sys/statvfs.h>],
  362. [struct statvfs fsd; statvfs (0, &fsd);],
  363. fu_cv_sys_stat_statvfs=yes,
  364. fu_cv_sys_stat_statvfs=no)])
  365. if test x"$fu_cv_sys_stat_statvfs" = xyes; then
  366. ac_fsusage_space=yes
  367. AC_DEFINE(STAT_STATVFS, 1,
  368. [ Define if there is a function named statvfs. (SVR4)])
  369. fi
  370. fi
  371. if test x"$ac_fsusage_space" = xno; then
  372. # DEC Alpha running OSF/1
  373. AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
  374. AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
  375. [AC_TRY_RUN([
  376. #include <sys/param.h>
  377. #include <sys/types.h>
  378. #include <sys/mount.h>
  379. int
  380. main ()
  381. {
  382. struct statfs fsd;
  383. fsd.f_fsize = 0;
  384. return statfs (".", &fsd, sizeof (struct statfs)) != 0;
  385. }],
  386. fu_cv_sys_stat_statfs3_osf1=yes,
  387. fu_cv_sys_stat_statfs3_osf1=no,
  388. fu_cv_sys_stat_statfs3_osf1=no)])
  389. AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
  390. if test x"$fu_cv_sys_stat_statfs3_osf1" = xyes; then
  391. ac_fsusage_space=yes
  392. AC_DEFINE(STAT_STATFS3_OSF1, 1,
  393. [ Define if statfs takes 3 args. (DEC Alpha running OSF/1)])
  394. fi
  395. fi
  396. if test x"$ac_fsusage_space" = xno; then
  397. # AIX
  398. AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
  399. member (AIX, 4.3BSD)])
  400. AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
  401. [AC_TRY_RUN([
  402. #ifdef HAVE_SYS_PARAM_H
  403. #include <sys/param.h>
  404. #endif
  405. #ifdef HAVE_SYS_MOUNT_H
  406. #include <sys/mount.h>
  407. #endif
  408. #ifdef HAVE_SYS_VFS_H
  409. #include <sys/vfs.h>
  410. #endif
  411. int
  412. main ()
  413. {
  414. struct statfs fsd;
  415. fsd.f_bsize = 0;
  416. return statfs (".", &fsd) != 0;
  417. }],
  418. fu_cv_sys_stat_statfs2_bsize=yes,
  419. fu_cv_sys_stat_statfs2_bsize=no,
  420. fu_cv_sys_stat_statfs2_bsize=no)])
  421. AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
  422. if test x"$fu_cv_sys_stat_statfs2_bsize" = xyes; then
  423. ac_fsusage_space=yes
  424. AC_DEFINE(STAT_STATFS2_BSIZE, 1,
  425. [ Define if statfs takes 2 args and struct statfs has a field named f_bsize.
  426. (4.3BSD, SunOS 4, HP-UX, AIX PS/2)])
  427. fi
  428. fi
  429. if test x"$ac_fsusage_space" = xno; then
  430. # SVR3
  431. AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
  432. AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
  433. [AC_TRY_RUN([#include <sys/types.h>
  434. #include <sys/statfs.h>
  435. int
  436. main ()
  437. {
  438. struct statfs fsd;
  439. return statfs (".", &fsd, sizeof fsd, 0) != 0;
  440. }],
  441. fu_cv_sys_stat_statfs4=yes,
  442. fu_cv_sys_stat_statfs4=no,
  443. fu_cv_sys_stat_statfs4=no)])
  444. AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
  445. if test x"$fu_cv_sys_stat_statfs4" = xyes; then
  446. ac_fsusage_space=yes
  447. AC_DEFINE(STAT_STATFS4, 1,
  448. [ Define if statfs takes 4 args. (SVR3, Dynix, Irix, Dolphin)])
  449. fi
  450. fi
  451. if test x"$ac_fsusage_space" = xno; then
  452. # 4.4BSD and NetBSD
  453. AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
  454. member (4.4BSD and NetBSD)])
  455. AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
  456. [AC_TRY_RUN([#include <sys/types.h>
  457. #ifdef HAVE_SYS_PARAM_H
  458. #include <sys/param.h>
  459. #endif
  460. #ifdef HAVE_SYS_MOUNT_H
  461. #include <sys/mount.h>
  462. #endif
  463. int
  464. main ()
  465. {
  466. struct statfs fsd;
  467. fsd.f_fsize = 0;
  468. return statfs (".", &fsd) != 0;
  469. }],
  470. fu_cv_sys_stat_statfs2_fsize=yes,
  471. fu_cv_sys_stat_statfs2_fsize=no,
  472. fu_cv_sys_stat_statfs2_fsize=no)])
  473. AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
  474. if test x"$fu_cv_sys_stat_statfs2_fsize" = xyes; then
  475. ac_fsusage_space=yes
  476. AC_DEFINE(STAT_STATFS2_FSIZE, 1,
  477. [ Define if statfs takes 2 args and struct statfs has a field named f_fsize.
  478. (4.4BSD, NetBSD)])
  479. fi
  480. fi
  481. if test x"$ac_fsusage_space" = xno; then
  482. # Ultrix
  483. AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
  484. AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
  485. [AC_TRY_RUN([#include <sys/types.h>
  486. #ifdef HAVE_SYS_PARAM_H
  487. #include <sys/param.h>
  488. #endif
  489. #ifdef HAVE_SYS_MOUNT_H
  490. #include <sys/mount.h>
  491. #endif
  492. #ifdef HAVE_SYS_FS_TYPES_H
  493. #include <sys/fs_types.h>
  494. #endif
  495. int
  496. main ()
  497. {
  498. struct fs_data fsd;
  499. /* Ultrix's statfs returns 1 for success,
  500. 0 for not mounted, -1 for failure. */
  501. return statfs (".", &fsd) != 1;
  502. }],
  503. fu_cv_sys_stat_fs_data=yes,
  504. fu_cv_sys_stat_fs_data=no,
  505. fu_cv_sys_stat_fs_data=no)])
  506. AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
  507. if test x"$fu_cv_sys_stat_fs_data" = xyes; then
  508. ac_fsusage_space=yes
  509. AC_DEFINE(STAT_STATFS2_FS_DATA, 1,
  510. [ Define if statfs takes 2 args and the second argument has
  511. type struct fs_data. (Ultrix)])
  512. fi
  513. fi
  514. if test x"$ac_fsusage_space" = xno; then
  515. # SVR2
  516. AC_TRY_CPP([#include <sys/filsys.h>
  517. ],
  518. AC_DEFINE(STAT_READ_FILSYS, 1,
  519. [Define if there is no specific function for reading file systems usage
  520. information and you have the <sys/filsys.h> header file. (SVR2)])
  521. ac_fsusage_space=yes)
  522. fi
  523. AS_IF([test x"$ac_fsusage_space" = xyes], [$1], [$2])
  524. ])
  525. # Check for SunOS statfs brokenness wrt partitions 2GB and larger.
  526. # If <sys/vfs.h> exists and struct statfs has a member named f_spare,
  527. # enable the work-around code in fsusage.c.
  528. AC_DEFUN([gl_STATFS_TRUNCATES],
  529. [
  530. AC_MSG_CHECKING([for statfs that truncates block counts])
  531. AC_CACHE_VAL(fu_cv_sys_truncating_statfs,
  532. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  533. #if !defined(sun) && !defined(__sun)
  534. choke -- this is a workaround for a Sun-specific problem
  535. #endif
  536. #include <sys/types.h>
  537. #include <sys/vfs.h>]],
  538. [[struct statfs t; long c = *(t.f_spare);
  539. if (c) return 0;]])],
  540. [fu_cv_sys_truncating_statfs=yes],
  541. [fu_cv_sys_truncating_statfs=no])])
  542. if test x"$fu_cv_sys_truncating_statfs" = xyes; then
  543. AC_DEFINE(STATFS_TRUNCATES_BLOCK_COUNTS, 1,
  544. [Define if the block counts reported by statfs may be truncated to 2GB
  545. and the correct values may be stored in the f_spare array.
  546. (SunOS 4.1.2, 4.1.3, and 4.1.3_U1 are reported to have this problem.
  547. SunOS 4.1.1 seems not to be affected.)])
  548. fi
  549. AC_MSG_RESULT($fu_cv_sys_truncating_statfs)
  550. ])
  551. # Prerequisites of lib/fsusage.c not done by gl_FILE_SYSTEM_USAGE.
  552. AC_DEFUN([gl_PREREQ_FSUSAGE_EXTRA],
  553. [
  554. AC_REQUIRE([gl_AC_TYPE_UINTMAX_T])
  555. AC_CHECK_HEADERS(dustat.h sys/fs/s5param.h sys/filsys.h sys/statfs.h)
  556. gl_STATFS_TRUNCATES
  557. ])
  558. dnl From Jim Meyering.
  559. dnl
  560. dnl See if struct statfs has the f_fstypename member.
  561. dnl If so, define HAVE_STRUCT_STATFS_F_FSTYPENAME.
  562. dnl
  563. # Copyright (C) 1998, 1999, 2001, 2004, 2006 Free Software Foundation, Inc.
  564. # This file is free software; the Free Software Foundation
  565. # gives unlimited permission to copy and/or distribute it,
  566. # with or without modifications, as long as this notice is preserved.
  567. AC_DEFUN([gl_FSTYPENAME],
  568. [
  569. AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,
  570. [
  571. #include <sys/types.h>
  572. #include <sys/param.h>
  573. #include <sys/mount.h>
  574. ])
  575. AC_CHECK_MEMBERS([struct statvfs.f_fstypename, struct statvfs.f_basetype],,,
  576. [
  577. AC_INCLUDES_DEFAULT
  578. #include <sys/statvfs.h>
  579. ])
  580. ])
  581. dnl
  582. dnl posix_allocate() function detection
  583. dnl
  584. AC_DEFUN([gl_POSIX_FALLOCATE], [
  585. dnl * Old glibcs have broken posix_fallocate(). Make sure not to use it.
  586. AC_TRY_COMPILE([
  587. #define _XOPEN_SOURCE 600
  588. #include <stdlib.h>
  589. #if defined(__GLIBC__) && (__GLIBC__ < 2 || __GLIBC_MINOR__ < 7)
  590. possibly broken posix_fallocate
  591. #endif
  592. ],
  593. [posix_fallocate(0, 0, 0);],
  594. [AC_DEFINE(
  595. [HAVE_POSIX_FALLOCATE],
  596. [1],
  597. [Define if you have a working posix_fallocate()])
  598. ])
  599. ])
  600. dnl
  601. dnl Filesystem information detection
  602. dnl
  603. dnl To get information about the disk, mount points, etc.
  604. dnl
  605. AC_DEFUN([AC_GET_FS_INFO], [
  606. AC_CHECK_HEADERS([fcntl.h utime.h])
  607. gl_LIST_MOUNTED_FILE_SYSTEMS([
  608. AC_DEFINE(HAVE_INFOMOUNT_LIST, 1,
  609. [Define if the list of mounted filesystems can be determined])],
  610. [AC_MSG_WARN([could not determine how to read list of mounted fs])])
  611. gl_FSUSAGE
  612. gl_FSTYPENAME
  613. gl_POSIX_FALLOCATE
  614. ])