From owner-svn-src-all@FreeBSD.ORG Sun Feb 7 01:26:45 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9CDC31065694; Sun, 7 Feb 2010 01:26:45 +0000 (UTC) (envelope-from kientzle@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 82E188FC08; Sun, 7 Feb 2010 01:26:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o171Qj4O096980; Sun, 7 Feb 2010 01:26:45 GMT (envelope-from kientzle@svn.freebsd.org) Received: (from kientzle@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o171Qj6u096977; Sun, 7 Feb 2010 01:26:45 GMT (envelope-from kientzle@svn.freebsd.org) Message-Id: <201002070126.o171Qj6u096977@svn.freebsd.org> From: Tim Kientzle Date: Sun, 7 Feb 2010 01:26:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203589 - head/usr.bin/tar X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Feb 2010 01:26:45 -0000 Author: kientzle Date: Sun Feb 7 01:26:45 2010 New Revision: 203589 URL: http://svn.freebsd.org/changeset/base/203589 Log: Various portability workarounds for non-FreeBSD platforms. Modified: head/usr.bin/tar/bsdtar.c head/usr.bin/tar/write.c Modified: head/usr.bin/tar/bsdtar.c ============================================================================== --- head/usr.bin/tar/bsdtar.c Sun Feb 7 01:22:55 2010 (r203588) +++ head/usr.bin/tar/bsdtar.c Sun Feb 7 01:26:45 2010 (r203589) @@ -82,6 +82,10 @@ __FBSDID("$FreeBSD$"); #define _PATH_DEFTAPE "/dev/tape" #endif +#ifdef __MINGW32__ +int _CRT_glob = 0; /* Disable broken CRT globbing. */ +#endif + #if defined(HAVE_SIGACTION) && (defined(SIGINFO) || defined(SIGUSR1)) static volatile int siginfo_occurred; Modified: head/usr.bin/tar/write.c ============================================================================== --- head/usr.bin/tar/write.c Sun Feb 7 01:22:55 2010 (r203588) +++ head/usr.bin/tar/write.c Sun Feb 7 01:26:45 2010 (r203589) @@ -139,6 +139,23 @@ static int write_file_data(struct bsdt static void write_hierarchy(struct bsdtar *, struct archive *, const char *); +#if defined(_WIN32) && !defined(__CYGWIN__) +/* Not a full lseek() emulation, but enough for our needs here. */ +static int +seek_file(int fd, int64_t offset, int whence) +{ + LARGE_INTEGER distance; + (void)whence; /* UNUSED */ + distance.QuadPart = offset; + return (SetFilePointerEx((HANDLE)_get_osfhandle(fd), + distance, NULL, FILE_BEGIN) ? 1 : -1); +} +#define open _open +#define close _close +#define read _read +#define lseek seek_file +#endif + void tar_mode_c(struct bsdtar *bsdtar) { @@ -236,7 +253,11 @@ tar_mode_r(struct bsdtar *bsdtar) format = ARCHIVE_FORMAT_TAR_PAX_RESTRICTED; +#if defined(__BORLANDC__) + bsdtar->fd = open(bsdtar->filename, O_RDWR | O_CREAT); +#else bsdtar->fd = open(bsdtar->filename, O_RDWR | O_CREAT, 0666); +#endif if (bsdtar->fd < 0) bsdtar_errc(1, errno, "Cannot open %s", bsdtar->filename); @@ -451,12 +472,7 @@ write_archive(struct archive *a, struct arg + 1) != 0) break; } else -#if defined(_WIN32) && !defined(__CYGWIN__) - write_hierarchy_win(bsdtar, a, arg, - write_hierarchy); -#else write_hierarchy(bsdtar, a, arg); -#endif } bsdtar->argv++; } @@ -786,6 +802,22 @@ write_hierarchy(struct bsdtar *bsdtar, s * calling this so we can pass in an fd and shorten * the race to query metadata. The linkify dance * makes this more complex than it might sound. */ +#if defined(_WIN32) && !defined(__CYGWIN__) + /* TODO: tree.c uses stat(), which is badly broken + * on Windows. To fix this, we should + * deprecate tree_current_stat() and provide a new + * call tree_populate_entry(t, entry). This call + * would use stat() internally on POSIX and + * GetInfoByFileHandle() internally on Windows. + * This would be another step towards a tree-walker + * that can be integrated deep into libarchive. + * For now, just set st to NULL on Windows; + * archive_read_disk_entry_from_file() should + * be smart enough to use platform-appropriate + * ways to probe file information. + */ + st = NULL; +#endif r = archive_read_disk_entry_from_file(bsdtar->diskreader, entry, -1, st); if (r != ARCHIVE_OK) @@ -801,7 +833,7 @@ write_hierarchy(struct bsdtar *bsdtar, s * If this file/dir is flagged "nodump" and we're * honoring such flags, skip this file/dir. */ -#ifdef HAVE_STRUCT_STAT_ST_FLAGS +#if defined(HAVE_STRUCT_STAT_ST_FLAGS) && defined(UF_NODUMP) /* BSD systems store flags in struct stat */ if (bsdtar->option_honor_nodump && (lst->st_flags & UF_NODUMP)) @@ -1092,4 +1124,11 @@ test_for_append(struct bsdtar *bsdtar) bsdtar_errc(1, 0, "Cannot append to %s: not a regular file.", bsdtar->filename); + +/* Is this an appropriate check here on Windows? */ +/* + if (GetFileType(handle) != FILE_TYPE_DISK) + bsdtar_errc(1, 0, "Cannot append"); +*/ + }