# Check for some functions
AC_CHECK_FUNCS(lstat strerror strsignal memmove vsnprintf stpcpy strcasecmp strncasecmp poll getcwd vasprintf setenv unsetenv getc_unlocked readlink symlink fdwalk memmem)
-AC_CHECK_FUNCS(chown lchmod lchown fchmod fchown link statvfs statfs utimes getgrgid getpwuid)
+AC_CHECK_FUNCS(chown lchmod lchown fchmod fchown link utimes getgrgid getpwuid)
AC_CHECK_FUNCS(getmntent_r setmntent endmntent hasmntopt getmntinfo)
# Check for high-resolution sleep functions
AC_CHECK_FUNCS(splice)
+# To avoid finding a compatibility unusable statfs, which typically
+# successfully compiles, but warns to use the newer statvfs interface:
+AS_IF([test $ac_cv_header_sys_statvfs_h = yes], [AC_CHECK_FUNCS([statvfs])])
+AS_IF([test $ac_cv_header_sys_statfs_h = yes], [AC_CHECK_FUNCS([statfs])])
+
+AC_MSG_CHECKING([whether to use statfs or statvfs])
+# Some systems have both statfs and statvfs, pick the most "native" for these
+AS_IF([test x$ac_cv_func_statfs = xyes && test x$ac_cv_func_statvfs = yes],
+ [
+ # on solaris and irix, statfs doesn't even have the f_bavail field
+ AS_IF([test $ac_cv_member_struct_statfs_f_bavail = yes],
+ [ac_cv_func_statfs=no],
+ # else, at least on linux, statfs is the actual syscall
+ [ac_cv_func_statvfs=no])
+ ])
+
+AS_IF([test x$ac_cv_func_statfs = xyes],
+ [
+ AC_DEFINE([USE_STATFS], [1], [Define to use statfs()])
+ AC_MSG_RESULT([statfs])
+ ],
+ [test x$ac_cv_func_statvfs = xyes],
+ [
+ AC_DEFINE([USE_STATVFS], [1], [Define to use statvfs()])
+ AC_MSG_RESULT([statvfs])
+ ],
+ [ AC_MSG_RESULT([neither])])
+
AC_CHECK_HEADERS(crt_externs.h)
AC_CHECK_FUNCS(_NSGetEnviron)
#define O_BINARY 0
#endif
-#if defined(HAVE_STATFS) && defined(HAVE_STATVFS)
-/* Some systems have both statfs and statvfs, pick the
- most "native" for these */
-# if !defined(HAVE_STRUCT_STATFS_F_BAVAIL)
- /* on solaris and irix, statfs doesn't even have the
- f_bavail field */
-# define USE_STATVFS
-# else
- /* at least on linux, statfs is the actual syscall */
-# define USE_STATFS
-# endif
-
-#elif defined(HAVE_STATFS)
-
-# define USE_STATFS
-
-#elif defined(HAVE_STATVFS)
-
-# define USE_STATVFS
-
-#endif
-
#include "gfileattribute.h"
#include "glocalfile.h"
#include "glocalfileinfo.h"
#ifdef HAVE_POLL_H
#include <poll.h>
#endif
-#if HAVE_SYS_STATVFS_H
-#include <sys/statvfs.h>
-#endif
#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
#include <gstdio.h>
#include <dirent.h>
+#if HAVE_SYS_STATFS_H
+#include <sys/statfs.h>
+#endif
+#if HAVE_SYS_STATVFS_H
+#include <sys/statvfs.h>
+#endif
+#if HAVE_SYS_VFS_H
+#include <sys/vfs.h>
+#elif HAVE_SYS_MOUNT_H
+#if HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
+#include <sys/mount.h>
+#endif
+
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
#include "gunixmounts.h"
#include "gfile.h"
#include "gfilemonitor.h"
static GList *
_g_get_unix_mounts (void)
{
+#if defined(USE_STATFS)
struct statfs *mntent = NULL;
+#elif defined(USE_STATVFS)
+ struct statvfs *mntent = NULL;
+#else
+ #error statfs juggling failed
+#endif
int num_mounts, i;
GUnixMountEntry *mount_entry;
GList *return_list;
mount_entry->mount_path = g_strdup (mntent[i].f_mntonname);
mount_entry->device_path = g_strdup (mntent[i].f_mntfromname);
mount_entry->filesystem_type = g_strdup (mntent[i].f_fstypename);
+#if defined(USE_STATFS)
if (mntent[i].f_flags & MNT_RDONLY)
+#elif defined(USE_STATVFS)
+ if (mntent[i].f_flag & MNT_RDONLY)
+#endif
mount_entry->is_read_only = TRUE;
mount_entry->is_system_internal =