mc-get-fs-info.m4 3.6 KB

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