From: Joerg Sonnenberger Date: Tue, 13 Dec 2011 23:07:17 +0000 (-0500) Subject: Properly check if EXT2_IOC_GETFLAGS is actually usable. X-Git-Tag: v3.0.2~56 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=95c74682bd5267155fccec00f1d2bc0bf611b3c5;p=thirdparty%2Flibarchive.git Properly check if EXT2_IOC_GETFLAGS is actually usable. OpenIndiana likes to install e2fsprogs, but doesn't provide a working ioctl. SVN-Revision: 3918 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 910032600..04ee4dabe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -236,6 +236,11 @@ LA_CHECK_INCLUDE_FILE("direct.h" HAVE_DIRECT_H) LA_CHECK_INCLUDE_FILE("dlfcn.h" HAVE_DLFCN_H) LA_CHECK_INCLUDE_FILE("errno.h" HAVE_ERRNO_H) LA_CHECK_INCLUDE_FILE("ext2fs/ext2_fs.h" HAVE_EXT2FS_EXT2_FS_H) + +CHECK_C_SOURCE_COMPILES("#include +#include +int main(void) { return EXT2_IOC_GETFLAGS; }" HAVE_WORKING_EXT2_IOC_GETFLAGS) + LA_CHECK_INCLUDE_FILE("fcntl.h" HAVE_FCNTL_H) LA_CHECK_INCLUDE_FILE("grp.h" HAVE_GRP_H) LA_CHECK_INCLUDE_FILE("inttypes.h" HAVE_INTTYPES_H) diff --git a/build/cmake/config.h.in b/build/cmake/config.h.in index 4e9b074b2..b1690515d 100644 --- a/build/cmake/config.h.in +++ b/build/cmake/config.h.in @@ -970,6 +970,9 @@ typedef uint64_t uintmax_t; /* Define to 1 if you have the `wmemcpy' function. */ #cmakedefine HAVE_WMEMCPY 1 +/* Define to 1 if you have a working EXT2_IOC_GETFLAGS */ +#cmakedefine HAVE_WORKING_EXT2_IOC_GETFLAGS 1 + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_ZLIB_H 1 diff --git a/configure.ac b/configure.ac index 322cd0b06..d4977b03a 100644 --- a/configure.ac +++ b/configure.ac @@ -208,6 +208,19 @@ AC_HEADER_DIRENT AC_HEADER_SYS_WAIT AC_CHECK_HEADERS([acl/libacl.h attr/xattr.h copyfile.h ctype.h]) AC_CHECK_HEADERS([errno.h ext2fs/ext2_fs.h fcntl.h grp.h]) + +AC_CACHE_CHECK([whether EXT2_IOC_GETFLAGS is usable], + [ac_cv_have_decl_EXT2_IOC_GETFLAGS], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include +@%:@include ], + [int x = EXT2_IOC_GETFLAGS])], + [AS_VAR_SET([ac_cv_have_decl_EXT2_IOC_GETFLAGS], [yes])], + [AS_VAR_SET([ac_cv_have_decl_EXT2_IOC_GETFLAGS], [no])])]) + +AS_VAR_IF([ac_cv_have_decl_EXT2_IOC_GETFLAGS], [yes], + [AC_DEFINE_UNQUOTED([HAVE_WORKING_EXT2_IOC_GETFLAGS], [1], + [Define to 1 if you have a working EXT2_IOC_GETFLAGS])]) + AC_CHECK_HEADERS([inttypes.h io.h langinfo.h limits.h]) AC_CHECK_HEADERS([linux/fiemap.h linux/fs.h linux/magic.h]) AC_CHECK_HEADERS([locale.h paths.h poll.h pwd.h regex.h signal.h stdarg.h]) diff --git a/libarchive/archive_read_disk_entry_from_file.c b/libarchive/archive_read_disk_entry_from_file.c index f0d678527..cc3915170 100644 --- a/libarchive/archive_read_disk_entry_from_file.c +++ b/libarchive/archive_read_disk_entry_from_file.c @@ -182,7 +182,7 @@ archive_read_disk_entry_from_file(struct archive *_a, archive_entry_set_fflags(entry, st->st_flags, 0); #endif -#ifdef EXT2_IOC_GETFLAGS +#if defined(EXT2_IOC_GETFLAGS) && defined(HAVE_WORKING_EXT2_IOC_GETFLAGS) /* Linux requires an extra ioctl to pull the flags. Although * this is an extra step, it has a nice side-effect: We get an * open file descriptor which we can use in the subsequent lookups. */ diff --git a/libarchive/archive_write_disk_posix.c b/libarchive/archive_write_disk_posix.c index 51b67e86a..98356a942 100644 --- a/libarchive/archive_write_disk_posix.c +++ b/libarchive/archive_write_disk_posix.c @@ -2359,7 +2359,7 @@ set_fflags_platform(struct archive_write_disk *a, int fd, const char *name, return (ARCHIVE_WARN); } -#elif defined(EXT2_IOC_GETFLAGS) && defined(EXT2_IOC_SETFLAGS) +#elif defined(EXT2_IOC_GETFLAGS) && defined(EXT2_IOC_SETFLAGS) && defined(HAVE_WORKING_EXT2_IOC_GETFLAGS) /* * Linux uses ioctl() to read and write file flags. */ diff --git a/tar/write.c b/tar/write.c index 9fb9eac37..711c3e718 100644 --- a/tar/write.c +++ b/tar/write.c @@ -860,7 +860,7 @@ write_hierarchy(struct bsdtar *bsdtar, struct archive *a, const char *path) continue; #endif -#if defined(EXT2_IOC_GETFLAGS) && defined(EXT2_NODUMP_FL) +#if defined(EXT2_IOC_GETFLAGS) && defined(EXT2_NODUMP_FL) && defined(HAVE_WORKING_EXT2_IOC_GETFLAGS) /* Linux uses ioctl to read flags. */ if (bsdtar->option_honor_nodump) { int fd = open(name, O_RDONLY | O_NONBLOCK | O_BINARY);