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