From: Michihiro NAKAJIMA Date: Fri, 11 Jun 2010 07:07:53 +0000 (-0400) Subject: Add support for archive_read_disk_current_filesystem_is_remote on NetBSD and OpenBSD. X-Git-Tag: v3.0.0a~963 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8161d987d097beaa3cf6c95dc09a4010b76f5ab6;p=thirdparty%2Flibarchive.git Add support for archive_read_disk_current_filesystem_is_remote on NetBSD and OpenBSD. SVN-Revision: 2464 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 6edd1b903..72cb5f012 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -247,6 +247,7 @@ LA_CHECK_INCLUDE_FILE("sys/param.h" HAVE_SYS_PARAM_H) LA_CHECK_INCLUDE_FILE("sys/poll.h" HAVE_SYS_POLL_H) LA_CHECK_INCLUDE_FILE("sys/select.h" HAVE_SYS_SELECT_H) LA_CHECK_INCLUDE_FILE("sys/stat.h" HAVE_SYS_STAT_H) +LA_CHECK_INCLUDE_FILE("sys/statvfs.h" HAVE_SYS_STATVFS_H) LA_CHECK_INCLUDE_FILE("sys/time.h" HAVE_SYS_TIME_H) LA_CHECK_INCLUDE_FILE("sys/utime.h" HAVE_SYS_UTIME_H) LA_CHECK_INCLUDE_FILE("sys/utsname.h" HAVE_SYS_UTSNAME_H) @@ -516,6 +517,7 @@ CHECK_FUNCTION_EXISTS_GLIBC(setenv HAVE_SETENV) CHECK_FUNCTION_EXISTS_GLIBC(setlocale HAVE_SETLOCALE) CHECK_FUNCTION_EXISTS_GLIBC(sigaction HAVE_SIGACTION) CHECK_FUNCTION_EXISTS_GLIBC(statfs HAVE_STATFS) +CHECK_FUNCTION_EXISTS_GLIBC(statvfs HAVE_STATVFS) CHECK_FUNCTION_EXISTS_GLIBC(strchr HAVE_STRCHR) CHECK_FUNCTION_EXISTS_GLIBC(strdup HAVE_STRDUP) CHECK_FUNCTION_EXISTS_GLIBC(strerror HAVE_STRERROR) diff --git a/build/cmake/config.h.in b/build/cmake/config.h.in index 3f64b3a63..fc17ddc29 100644 --- a/build/cmake/config.h.in +++ b/build/cmake/config.h.in @@ -465,6 +465,9 @@ /* Define to 1 if you have the `statfs' function. */ #cmakedefine HAVE_STATFS 1 +/* Define to 1 if you have the `statvfs' function. */ +#cmakedefine HAVE_STATVFS 1 + /* Define to 1 if `stat' has the bug that it succeeds when given the zero-length file name argument. */ #cmakedefine HAVE_STAT_EMPTY_STRING_BUG 1 @@ -573,6 +576,9 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_SELECT_H 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_STATVFS_H 1 + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_STAT_H 1 diff --git a/configure.ac b/configure.ac index da462acdf..2ae97470f 100644 --- a/configure.ac +++ b/configure.ac @@ -200,7 +200,8 @@ AC_CHECK_HEADERS([locale.h paths.h poll.h pwd.h regex.h signal.h stdarg.h]) AC_CHECK_HEADERS([stdint.h stdlib.h string.h]) AC_CHECK_HEADERS([sys/acl.h sys/cdefs.h sys/extattr.h sys/ioctl.h]) AC_CHECK_HEADERS([sys/mkdev.h sys/mount.h]) -AC_CHECK_HEADERS([sys/param.h sys/poll.h sys/select.h sys/time.h sys/utime.h]) +AC_CHECK_HEADERS([sys/param.h sys/poll.h sys/select.h sys/statvfs.h]) +AC_CHECK_HEADERS([sys/time.h sys/utime.h]) AC_CHECK_HEADERS([sys/utsname.h time.h unistd.h utime.h wchar.h wctype.h]) AC_CHECK_HEADERS([windows.h winioctl]) @@ -419,7 +420,7 @@ AC_CHECK_FUNCS([getgrnam_r getpwnam_r getvfsbyname gmtime_r]) AC_CHECK_FUNCS([lchflags lchmod lchown link localtime_r lstat]) AC_CHECK_FUNCS([lutimes mbrtowc memmove memset mkdir mkfifo mknod mkstemp]) AC_CHECK_FUNCS([nl_langinfo pipe poll readlink]) -AC_CHECK_FUNCS([select setenv setlocale sigaction statfs]) +AC_CHECK_FUNCS([select setenv setlocale sigaction statfs statvfs]) AC_CHECK_FUNCS([strchr strdup strerror strncpy_s strrchr symlink timegm]) AC_CHECK_FUNCS([tzset unsetenv utime utimensat utimes vfork]) AC_CHECK_FUNCS([wcrtomb wcscpy wcslen wctomb wmemcmp wmemcpy]) diff --git a/libarchive/archive_read_disk.c b/libarchive/archive_read_disk.c index d34cb0b8f..67e58b36e 100644 --- a/libarchive/archive_read_disk.c +++ b/libarchive/archive_read_disk.c @@ -28,15 +28,18 @@ #include "archive_platform.h" __FBSDID("$FreeBSD: head/lib/libarchive/archive_read_disk.c 189429 2009-03-06 04:35:31Z kientzle $"); -#ifdef HAVE_SYS_STAT_H -#include -#endif #ifdef HAVE_SYS_PARAM_H #include #endif #ifdef HAVE_SYS_MOUNT_H #include #endif +#ifdef HAVE_SYS_STAT_H +#include +#endif +#ifdef HAVE_SYS_STATVFS_H +#include +#endif #ifdef HAVE_DIRECT_H #include #endif @@ -920,6 +923,32 @@ filesystem_information(struct archive_read_disk *a, const char *path, return (ARCHIVE_OK); } +#elif defined(HAVE_STATVFS) && defined(MNT_LOCAL) + +/* + * Get conditions of synthetic and remote on NetBSD and OpenBSD + */ +static int +filesystem_information(struct archive_read_disk *a, const char *path, + struct filesystem *fs) +{ + struct statvfs sfs; + int r; + + fs->synthetic = -1; + r = statvfs(path, &sfs); + if (r == -1) { + fs->remote = -1; + archive_set_error(&a->archive, errno, "statfs failed"); + return (ARCHIVE_FAILED); + } + if (sfs.f_flag & MNT_LOCAL) + fs->remote = 0; + else + fs->remote = 1; + return (ARCHIVE_OK); +} + #else /*