Adds statfs() support to other unix.

This commit is contained in:
Andrea Mazzoleni 2013-08-29 00:23:14 +02:00
parent e4e13a669b
commit bec047b0b3
3 changed files with 47 additions and 30 deletions

View file

@ -24,7 +24,7 @@ AC_HEADER_DIRENT
AC_HEADER_TIME
AC_CHECK_HEADERS([fcntl.h stddef.h stdint.h stdlib.h string.h limits.h])
AC_CHECK_HEADERS([unistd.h getopt.h fnmatch.h io.h inttypes.h byteswap.h])
AC_CHECK_HEADERS([sys/time.h sys/file.h sys/ioctl.h sys/vfs.h sys/statfs.h])
AC_CHECK_HEADERS([sys/time.h sys/file.h sys/ioctl.h sys/vfs.h sys/statfs.h sys/param.h sys/mount.h])
AC_CHECK_HEADERS([linux/fiemap.h linux/fs.h])
dnl Checks for typedefs, structures, and compiler characteristics.
@ -52,6 +52,12 @@ AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec, struct stat.st_mtimensec, struct
#endif
]])
AC_CHECK_MEMBERS([struct statfs.f_type], [], [], [[
#if HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#if HAVE_SYS_MOUNT_H
#include <sys/mount.h>
#endif
#if HAVE_SYS_VFS_H
#include <sys/vfs.h>
#endif

View file

@ -31,7 +31,44 @@
#include <windows.h>
#endif
/* Include some standard headers */
/**
* Includes some platform specific headers.
*/
#if HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#if HAVE_SYS_MOUNT_H
#include <sys/mount.h>
#endif
#if HAVE_SYS_VFS_H
#include <sys/vfs.h>
#endif
#if HAVE_SYS_STATFS_H
#include <sys/statfs.h>
#endif
#if HAVE_SYS_FILE_H
#include <sys/file.h>
#endif
#if HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
#if HAVE_LINUX_FS_H
#include <linux/fs.h>
#endif
#if HAVE_LINUX_FIEMAP_H
#include <linux/fiemap.h>
#endif
/**
* Includes some standard headers.
*/
#include <stdio.h>
#include <stdlib.h> /* On many systems (e.g., Darwin), `stdio.h' is a prerequisite. */
#include <stdarg.h>
@ -66,22 +103,6 @@
#endif
#endif
#if HAVE_SYS_FILE_H
#include <sys/file.h>
#endif
#if HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
#if HAVE_LINUX_FS_H
#include <linux/fs.h>
#endif
#if HAVE_LINUX_FIEMAP_H
#include <linux/fiemap.h>
#endif
#if HAVE_DIRENT_H
#include <dirent.h>
#define NAMLEN(dirent) strlen((dirent)->d_name)
@ -107,14 +128,6 @@
#include <sys/stat.h>
#endif
#if HAVE_SYS_VFS_H
#include <sys/vfs.h>
#endif
#if HAVE_SYS_STATFS_H
#include <sys/statfs.h>
#endif
#if HAVE_GETOPT_H
#include <getopt.h>
#endif
@ -145,7 +158,7 @@
#endif
/**
* Enable lock file support.
* Enables lock file support.
*/
#if HAVE_FLOCK && HAVE_FTRUNCATE
#define HAVE_LOCKFILE 1

4
unix.c
View file

@ -170,9 +170,7 @@ int filephy(const char* path, struct stat* st, uint64_t* physical)
int fsinfo(const char* path, int* has_persistent_inode)
{
/* statfs() is really not portable, and to limit possible incompatibility we limit it to Linux */
/* for example, Solaris doesn't have the f_type field, BSD has it as "short" */
#if HAVE_STATFS && HAVE_STRUCT_STATFS_F_TYPE && defined(__linux__)
#if HAVE_STATFS && HAVE_STRUCT_STATFS_F_TYPE
struct statfs st;
if (statfs(path, &st) != 0)