diff options
author | kientzle <kientzle@FreeBSD.org> | 2009-03-08 05:47:21 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2009-03-08 05:47:21 +0000 |
commit | 9ab299b136d96059e3903cf712eadfd82dddc3ac (patch) | |
tree | bcdf4e5f9ce124f6ac9ca61f2bf0b1a77d73818c /usr.bin/tar/bsdtar.c | |
parent | f11509af10454a047769d60c430b85c2aba51000 (diff) | |
download | FreeBSD-src-9ab299b136d96059e3903cf712eadfd82dddc3ac.zip FreeBSD-src-9ab299b136d96059e3903cf712eadfd82dddc3ac.tar.gz |
Merger r629-631,633-646,648,654,678,681,682 from libarchive.googlecode.com:
Many changes for Windows compatibility. bsdtar_test now runs successfully
on both POSIX platforms and Windows.
Diffstat (limited to 'usr.bin/tar/bsdtar.c')
-rw-r--r-- | usr.bin/tar/bsdtar.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/usr.bin/tar/bsdtar.c b/usr.bin/tar/bsdtar.c index 24aaad7..af762ea 100644 --- a/usr.bin/tar/bsdtar.c +++ b/usr.bin/tar/bsdtar.c @@ -73,6 +73,9 @@ __FBSDID("$FreeBSD$"); #ifdef __linux #define _PATH_DEFTAPE "/dev/st0" #endif +#ifdef _WIN32 +#define _PATH_DEFTAPE "\\\\.\\tape0" +#endif #ifndef _PATH_DEFTAPE #define _PATH_DEFTAPE "/dev/tape" @@ -109,12 +112,20 @@ main(int argc, char **argv) memset(bsdtar, 0, sizeof(*bsdtar)); bsdtar->fd = -1; /* Mark as "unused" */ option_o = 0; +#ifdef _WIN32 + /* open() function is always with a binary mode. */ + _set_fmode(_O_BINARY); +#endif /* Need bsdtar->progname before calling bsdtar_warnc. */ if (*argv == NULL) bsdtar->progname = "bsdtar"; else { +#if _WIN32 + bsdtar->progname = strrchr(*argv, '\\'); +#else bsdtar->progname = strrchr(*argv, '/'); +#endif if (bsdtar->progname != NULL) bsdtar->progname++; else @@ -143,7 +154,7 @@ main(int argc, char **argv) bsdtar->extract_flags |= SECURITY; /* Defaults for root user: */ - if (bsdtar->user_uid == 0) { + if (bsdtar_is_privileged(bsdtar)) { /* --same-owner */ bsdtar->extract_flags |= ARCHIVE_EXTRACT_OWNER; /* -p */ @@ -152,6 +163,10 @@ main(int argc, char **argv) bsdtar->extract_flags |= ARCHIVE_EXTRACT_XATTR; bsdtar->extract_flags |= ARCHIVE_EXTRACT_FFLAGS; } +#ifdef _WIN32 + /* Windows cannot set UNIX like uid/gid. */ + bsdtar->extract_flags &= ~ARCHIVE_EXTRACT_OWNER; +#endif bsdtar->argv = argv; bsdtar->argc = argc; |