]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Help archive_read_disk_entry_from_file.c build on Windows and Linux.
authorTim Kientzle <kientzle@gmail.com>
Sun, 18 Jan 2009 05:42:00 +0000 (00:42 -0500)
committerTim Kientzle <kientzle@gmail.com>
Sun, 18 Jan 2009 05:42:00 +0000 (00:42 -0500)
Submitted by: Michihiro NAKAJIMA

SVN-Revision: 430

CMakeLists.txt
configure.ac
libarchive/archive_read_disk_entry_from_file.c
libarchive/config_freebsd.h

index 76d68d2e5b8093980977919b2f3ce73168e2bc99..6517945c8b5b585b19f454f3cf693b61579461e5 100644 (file)
@@ -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)
index 06d89fbdbd1c8614dab9a097e8a03697e47b8d6a..cd5094cdfa0b10292a73d6cfccd67065f0040874 100644 (file)
@@ -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])
index c3f6cfd5876cc65347ba73d756e9ef794c0d23ec..48668fa159d7fd2861a9cedde40176f0be8492ba 100644 (file)
 #include "archive_platform.h"
 __FBSDID("$FreeBSD$");
 
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
 #ifdef HAVE_SYS_ACL_H
 #include <sys/acl.h>
 #endif
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
 #endif
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+#ifdef HAVE_WINDOWS_H
+#include <windows.h>
+#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
index a559950ee25bc900efe2e1bbf9263a0ef739b636..edfad77d6cf0082325c19d4525fbb7afc8dd16b7 100644 (file)
@@ -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