diff options
-rw-r--r-- | usr.bin/tar/write.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/usr.bin/tar/write.c b/usr.bin/tar/write.c index 31005eb..207122e 100644 --- a/usr.bin/tar/write.c +++ b/usr.bin/tar/write.c @@ -95,6 +95,10 @@ __FBSDID("$FreeBSD$"); /* Fixed size of uname/gname caches. */ #define name_cache_size 101 +#ifndef O_BINARY +#define O_BINARY 0 +#endif + static const char * const NO_NAME = "(noname)"; struct archive_dir_entry { @@ -256,9 +260,9 @@ tar_mode_r(struct bsdtar *bsdtar) format = ARCHIVE_FORMAT_TAR_PAX_RESTRICTED; #if defined(__BORLANDC__) - bsdtar->fd = open(bsdtar->filename, O_RDWR | O_CREAT); + bsdtar->fd = open(bsdtar->filename, O_RDWR | O_CREAT | O_BINARY); #else - bsdtar->fd = open(bsdtar->filename, O_RDWR | O_CREAT, 0666); + bsdtar->fd = open(bsdtar->filename, O_RDWR | O_CREAT | O_BINARY, 0666); #endif if (bsdtar->fd < 0) bsdtar_errc(1, errno, @@ -353,7 +357,7 @@ tar_mode_u(struct bsdtar *bsdtar) /* Sanity-test some arguments and the file. */ test_for_append(bsdtar); - bsdtar->fd = open(bsdtar->filename, O_RDWR); + bsdtar->fd = open(bsdtar->filename, O_RDWR | O_BINARY); if (bsdtar->fd < 0) bsdtar_errc(1, errno, "Cannot open %s", bsdtar->filename); @@ -843,7 +847,7 @@ write_hierarchy(struct bsdtar *bsdtar, struct archive *a, const char *path) #if defined(EXT2_IOC_GETFLAGS) && defined(EXT2_NODUMP_FL) /* Linux uses ioctl to read flags. */ if (bsdtar->option_honor_nodump) { - int fd = open(name, O_RDONLY | O_NONBLOCK); + int fd = open(name, O_RDONLY | O_NONBLOCK | O_BINARY); if (fd >= 0) { unsigned long fflags; int r = ioctl(fd, EXT2_IOC_GETFLAGS, &fflags); @@ -913,7 +917,7 @@ write_entry_backend(struct bsdtar *bsdtar, struct archive *a, if (archive_entry_size(entry) > 0) { const char *pathname = archive_entry_sourcepath(entry); - fd = open(pathname, O_RDONLY); + fd = open(pathname, O_RDONLY | O_BINARY); if (fd == -1) { if (!bsdtar->verbose) bsdtar_warnc(errno, |