From: Tim Kientzle Date: Sun, 18 Jan 2009 05:42:00 +0000 (-0500) Subject: Help archive_read_disk_entry_from_file.c build on Windows and Linux. X-Git-Tag: v2.7.0~428 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9a140f0819c2fe45f2ec9722b03eb4b6383bd879;p=thirdparty%2Flibarchive.git Help archive_read_disk_entry_from_file.c build on Windows and Linux. Submitted by: Michihiro NAKAJIMA SVN-Revision: 430 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 76d68d2e5..6517945c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -156,7 +156,7 @@ CHECK_HEADERS(locale.h paths.h poll.h pwd.h regex.h stdarg.h) CHECK_HEADERS(stdint.h stdlib.h string.h) CHECK_HEADERS(sys/acl.h sys/extattr.h sys/ioctl.h) CHECK_HEADERS(sys/param.h sys/poll.h sys/select.h sys/time.h sys/utime.h) -CHECK_HEADERS(time.h unistd.h utime.h wchar.h wctype.h) +CHECK_HEADERS(time.h unistd.h utime.h wchar.h wctype.h windows.h) CHECK_INCLUDE_FILE(direct.h HAVE_DIRECT_H) CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H) @@ -169,12 +169,14 @@ CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_H) # # Check functions # -CHECK_FUNCS(chflags chown chroot extattr_set_fd extattr_set_file) +CHECK_FUNCS(chflags chown chroot) +CHECK_FUNCS(extattr_get_file extattr_list_file) +CHECK_FUNCS(extattr_set_fd extattr_set_file) CHECK_FUNCS(fchdir fchflags fchmod fchown fcntl fork) CHECK_FUNCS(fstat ftruncate futimes geteuid getpid) CHECK_FUNCS(lchflags lchmod lchown) CHECK_FUNCS(lutimes memmove memset mkdir mkfifo mknod) -CHECK_FUNCS(nl_langinfo pipe poll select setenv setlocale) +CHECK_FUNCS(nl_langinfo pipe poll readlink select setenv setlocale) CHECK_FUNCS(strchr strdup strerror strrchr timegm) CHECK_FUNCS(tzset unsetenv utime utimes vfork) CHECK_FUNCS(wcscpy wcslen wctomb wmemcmp wmemcpy) diff --git a/configure.ac b/configure.ac index 06d89fbdb..cd5094cdf 100644 --- a/configure.ac +++ b/configure.ac @@ -168,7 +168,7 @@ AC_CHECK_HEADERS([locale.h paths.h poll.h pwd.h regex.h stdarg.h]) AC_CHECK_HEADERS([stdint.h stdlib.h string.h]) AC_CHECK_HEADERS([sys/acl.h sys/extattr.h sys/ioctl.h]) AC_CHECK_HEADERS([sys/param.h sys/poll.h sys/select.h sys/time.h sys/utime.h]) -AC_CHECK_HEADERS([time.h unistd.h utime.h wchar.h wctype.h]) +AC_CHECK_HEADERS([time.h unistd.h utime.h wchar.h wctype.h windows.h]) # Checks for libraries. AC_ARG_WITH([zlib], @@ -259,12 +259,14 @@ AC_FUNC_STAT AC_FUNC_STRERROR_R AC_FUNC_STRFTIME AC_FUNC_VPRINTF -AC_CHECK_FUNCS([chflags chown chroot extattr_set_fd extattr_set_file]) +AC_CHECK_FUNCS([chflags chown chroot]) +AC_CHECK_FUNCS([extattr_get_file extattr_list_file]) +AC_CHECK_FUNCS([extattr_set_fd extattr_set_file]) AC_CHECK_FUNCS([fchdir fchflags fchmod fchown fcntl fork]) AC_CHECK_FUNCS([fstat ftruncate futimes geteuid getpid]) AC_CHECK_FUNCS([lchflags lchmod lchown]) AC_CHECK_FUNCS([lutimes memmove memset mkdir mkfifo mknod]) -AC_CHECK_FUNCS([nl_langinfo pipe poll select setenv setlocale]) +AC_CHECK_FUNCS([nl_langinfo pipe poll readlink select setenv setlocale]) AC_CHECK_FUNCS([strchr strdup strerror strrchr timegm]) AC_CHECK_FUNCS([tzset unsetenv utime utimes vfork]) AC_CHECK_FUNCS([wcscpy wcslen wctomb wmemcmp wmemcpy]) diff --git a/libarchive/archive_read_disk_entry_from_file.c b/libarchive/archive_read_disk_entry_from_file.c index c3f6cfd58..48668fa15 100644 --- a/libarchive/archive_read_disk_entry_from_file.c +++ b/libarchive/archive_read_disk_entry_from_file.c @@ -26,15 +26,24 @@ #include "archive_platform.h" __FBSDID("$FreeBSD$"); -#ifdef HAVE_SYS_STAT_H -#include -#endif #ifdef HAVE_SYS_ACL_H #include #endif +#ifdef HAVE_SYS_PARAM_H +#include +#endif +#ifdef HAVE_SYS_STAT_H +#include +#endif #ifdef HAVE_ERRNO_H #include #endif +#ifdef HAVE_LIMITS_H +#include +#endif +#ifdef HAVE_WINDOWS_H +#include +#endif #include "archive.h" #include "archive_entry.h" @@ -62,10 +71,10 @@ archive_read_disk_entry_from_file(struct archive *_a, int fd, const struct stat *st) { struct archive_read_disk *a = (struct archive_read_disk *)_a; - static char linkbuffer[PATH_MAX + 1]; const char *path; struct stat s; int initial_fd = fd; + int r, r1; path = archive_entry_sourcepath(entry); if (path == NULL) @@ -113,7 +122,9 @@ archive_read_disk_entry_from_file(struct archive *_a, archive_entry_set_fflags(entry, st->st_flags, 0); #endif +#ifdef HAVE_READLINK if (S_ISLNK(st->st_mode)) { + char linkbuffer[PATH_MAX + 1]; int lnklen = readlink(path, linkbuffer, PATH_MAX); if (lnklen < 0) { archive_set_error(&a->archive, errno, @@ -123,14 +134,16 @@ archive_read_disk_entry_from_file(struct archive *_a, linkbuffer[lnklen] = 0; archive_entry_set_symlink(entry, linkbuffer); } +#endif - /* TODO: collect errors here. */ - setup_acls_posix1e(a, entry, fd); - setup_xattrs(a, entry, fd); + r = setup_acls_posix1e(a, entry, fd); + r1 = setup_xattrs(a, entry, fd); + if (r1 < r) + r = r1; /* If we opened the file earlier in this function, close it. */ if (initial_fd != fd) close(fd); - return (ARCHIVE_OK); + return (r); } #ifdef HAVE_POSIX_ACL @@ -174,6 +187,7 @@ setup_acls_posix1e(struct archive_read_disk *a, acl_free(acl); } } + return (ARCHIVE_OK); } /* @@ -237,7 +251,7 @@ setup_acl_posix1e(struct archive_read_disk *a, } } #else -static void +static int setup_acls_posix1e(struct archive_read_disk *a, struct archive_entry *entry, int fd) { @@ -374,6 +388,7 @@ setup_xattrs(struct archive_read_disk *a, (void)a; /* UNUSED */ (void)entry; /* UNUSED */ (void)fd; /* UNUSED */ + return (ARCHIVE_OK); } #else @@ -388,6 +403,7 @@ setup_xattrs(struct archive_read_disk *a, (void)a; /* UNUSED */ (void)entry; /* UNUSED */ (void)fd; /* UNUSED */ + return (ARCHIVE_OK); } #endif diff --git a/libarchive/config_freebsd.h b/libarchive/config_freebsd.h index a559950ee..edfad77d6 100644 --- a/libarchive/config_freebsd.h +++ b/libarchive/config_freebsd.h @@ -34,6 +34,8 @@ #define HAVE_ACL_SET_FD_NP 1 #define HAVE_ACL_SET_FILE 1 #define HAVE_ACL_USER 1 +#define HAVE_EXTATTR_GET_FILE 1 +#define HAVE_EXTATTR_LIST_FILE 1 #define HAVE_EXTATTR_SET_FD 1 #define HAVE_EXTATTR_SET_FILE 1 #define HAVE_SYS_ACL_H 1 @@ -82,6 +84,7 @@ #define HAVE_POLL 1 #define HAVE_POLL_H 1 #define HAVE_PWD_H 1 +#define HAVE_READLINK 1 #define HAVE_SELECT 1 #define HAVE_SETENV 1 #define HAVE_STDINT_H 1