On Thu, Jul 17, 2014 at 06:12:42PM +0200, Michal Privoznik wrote: > The statfs(2) gets filesystem statistics. Currently, we use it only on > linux, and leave stub to implement on other platforms. But hey, other > platforms (like FreeBSD) have statfs() too. If we check it in > configure we can wider platforms supported. Speaking of FreeBSD, the > headers to include are of course different: sys/param.h and > sys/mount.h on the FreeBSD and sys/statfs.h on the Linux. The header > files are checked too. > > Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> > --- > configure.ac | 4 ++-- > src/util/virfile.c | 21 ++++++++++++++------- > 2 files changed, 16 insertions(+), 9 deletions(-) > > diff --git a/configure.ac b/configure.ac > index 8001e24..68ebf75 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -275,7 +275,7 @@ dnl and various less common threadsafe functions > AC_CHECK_FUNCS_ONCE([cfmakeraw fallocate geteuid getgid getgrnam_r \ > getmntent_r getpwuid_r getuid kill mmap newlocale posix_fallocate \ > posix_memalign prlimit regexec sched_getaffinity setgroups setns \ > - setrlimit symlink sysctlbyname getifaddrs]) > + setrlimit symlink sysctlbyname getifaddrs statfs]) > > dnl Availability of pthread functions. Because of $LIB_PTHREAD, we > dnl cannot use AC_CHECK_FUNCS_ONCE. LIB_PTHREAD and LIBMULTITHREAD > @@ -316,7 +316,7 @@ dnl Availability of various common headers (non-fatal if missing). > AC_CHECK_HEADERS([pwd.h paths.h regex.h sys/un.h \ > sys/poll.h syslog.h mntent.h net/ethernet.h linux/magic.h \ > sys/un.h sys/syscall.h sys/sysctl.h netinet/tcp.h ifaddrs.h \ > - libtasn1.h sys/ucred.h sys/mount.h]) > + libtasn1.h sys/ucred.h sys/mount.h sys/param.h sys/statfs.h]) > dnl Check whether endian provides handy macros. > AC_CHECK_DECLS([htole64], [], [], [[#include <endian.h>]]) > > diff --git a/src/util/virfile.c b/src/util/virfile.c > index 463064c..699b9f8 100644 > --- a/src/util/virfile.c > +++ b/src/util/virfile.c > @@ -43,11 +43,15 @@ > # include <sys/mman.h> > #endif > > -#ifdef __linux__ > -# if HAVE_LINUX_MAGIC_H > -# include <linux/magic.h> > -# endif > +#if HAVE_LINUX_MAGIC_H > +# include <linux/magic.h> > +#endif > + > +#ifdef HAVE_SYS_STATFS_H > # include <sys/statfs.h> > +#elif defined HAVE_SYS_PARAM_H && defined HAVE_SYS_MOUNT_H > +# include <sys/param.h> > +# include <sys/mount.h> > #endif > > #if defined(__linux__) && HAVE_DECL_LO_FLAGS_AUTOCLEAR > @@ -2817,7 +2821,7 @@ int virFilePrintf(FILE *fp, const char *msg, ...) > } > > > -#ifdef __linux__ > +#ifdef HAVE_STATFS > > # ifndef NFS_SUPER_MAGIC > # define NFS_SUPER_MAGIC 0x6969 I'm fairly sure these constants are entirely Linux specific, so although you got it to compile on BSD, I don't think it'll be returning sensible results. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list