mc-get-fs-info.m4 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. dnl
  2. dnl posix_allocate() function detection
  3. dnl
  4. AC_DEFUN([POSIX_FALLOCATE], [
  5. dnl * Old glibcs have broken posix_fallocate(). Make sure not to use it.
  6. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  7. #define _XOPEN_SOURCE 600
  8. #include <stdlib.h>
  9. #include <fcntl.h>
  10. #if defined(__GLIBC__) && (__GLIBC__ < 2 || __GLIBC_MINOR__ < 7)
  11. possibly broken posix_fallocate
  12. #endif
  13. ]],
  14. [[posix_fallocate(0, 0, 0);]])],
  15. [AC_DEFINE(
  16. [HAVE_POSIX_FALLOCATE],
  17. [1],
  18. [Define if you have a working posix_fallocate()])
  19. ])
  20. ])
  21. dnl
  22. dnl Get from the coreutils package (stat-prog.m4 serial 7)
  23. dnl
  24. AC_DEFUN([mc_cu_PREREQ_STAT_PROG],
  25. [
  26. AC_REQUIRE([gl_FSUSAGE])
  27. AC_REQUIRE([gl_FSTYPENAME])
  28. AC_CHECK_HEADERS_ONCE([OS.h netinet/in.h sys/param.h sys/vfs.h])
  29. dnl Check for vfs.h first, since this avoids a warning with nfs_client.h
  30. dnl on Solaris 8.
  31. test $ac_cv_header_sys_param_h = yes &&
  32. test $ac_cv_header_sys_mount_h = yes &&
  33. AC_CHECK_HEADERS([nfs/vfs.h],
  34. [AC_CHECK_HEADERS([nfs/nfs_client.h])])
  35. statvfs_includes="\
  36. AC_INCLUDES_DEFAULT
  37. #include <sys/statvfs.h>
  38. "
  39. statfs_includes="\
  40. AC_INCLUDES_DEFAULT
  41. #ifdef HAVE_SYS_VFS_H
  42. # include <sys/vfs.h>
  43. #elif defined HAVE_SYS_MOUNT_H && defined HAVE_SYS_PARAM_H
  44. # include <sys/param.h>
  45. # include <sys/mount.h>
  46. # if defined HAVE_NETINET_IN_H && defined HAVE_NFS_NFS_CLNT_H && defined HAVE_NFS_VFS_H
  47. # include <netinet/in.h>
  48. # include <nfs/nfs_clnt.h>
  49. # include <nfs/vfs.h>
  50. # endif
  51. #elif defined HAVE_OS_H
  52. # include <fs_info.h>
  53. #endif
  54. "
  55. if case "$fu_cv_sys_stat_statvfs$fu_cv_sys_stat_statvfs64" in
  56. *yes*) ;; *) false;; esac &&
  57. { AC_CHECK_MEMBERS([struct statvfs.f_basetype],,, [$statvfs_includes])
  58. test $ac_cv_member_struct_statvfs_f_basetype = yes ||
  59. { AC_CHECK_MEMBERS([struct statvfs.f_fstypename],,, [$statvfs_includes])
  60. test $ac_cv_member_struct_statvfs_f_fstypename = yes ||
  61. { test $ac_cv_member_struct_statfs_f_fstypename != yes &&
  62. { AC_CHECK_MEMBERS([struct statvfs.f_type],,, [$statvfs_includes])
  63. test $ac_cv_member_struct_statvfs_f_type = yes; }; }; }; }
  64. then
  65. AC_CHECK_MEMBERS([struct statvfs.f_namemax],,, [$statvfs_includes])
  66. AC_COMPILE_IFELSE(
  67. [AC_LANG_PROGRAM(
  68. [$statvfs_includes],
  69. [static statvfs s;
  70. return (s.s_fsid ^ 0) == 0;])],
  71. [AC_DEFINE([STRUCT_STATVFS_F_FSID_IS_INTEGER], [1],
  72. [Define to 1 if the f_fsid member of struct statvfs is an integer.])])
  73. else
  74. AC_CHECK_MEMBERS([struct statfs.f_namelen, struct statfs.f_type,
  75. struct statfs.f_frsize],,, [$statfs_includes])
  76. if test $ac_cv_header_OS_h != yes; then
  77. AC_COMPILE_IFELSE(
  78. [AC_LANG_PROGRAM(
  79. [$statfs_includes],
  80. [static statfs s;
  81. return (s.s_fsid ^ 0) == 0;])],
  82. [AC_DEFINE([STRUCT_STATFS_F_FSID_IS_INTEGER], [1],
  83. [Define to 1 if the f_fsid member of struct statfs is an integer.])])
  84. fi
  85. fi
  86. ])
  87. dnl
  88. dnl Filesystem information detection
  89. dnl
  90. dnl To get information about the disk, mount points, etc.
  91. dnl
  92. AC_DEFUN([mc_GET_FS_INFO], [
  93. AC_CHECK_HEADERS([fcntl.h utime.h])
  94. gl_MOUNTLIST
  95. if test $gl_cv_list_mounted_fs = yes; then
  96. gl_PREREQ_MOUNTLIST_EXTRA
  97. AC_DEFINE(HAVE_INFOMOUNT_LIST, 1,
  98. [Define if the list of mounted filesystems can be determined])
  99. else
  100. AC_MSG_WARN([could not determine how to read list of mounted fs]);
  101. fi
  102. gl_FSUSAGE
  103. if test $gl_cv_fs_space = yes; then
  104. gl_PREREQ_FSUSAGE_EXTRA
  105. fi
  106. gl_FSTYPENAME
  107. POSIX_FALLOCATE
  108. mc_cu_PREREQ_STAT_PROG
  109. ])