Date: Sun, 11 Apr 2010 01:32:30 +0000 (UTC) From: Tim Kientzle <kientzle@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r206465 - head/usr.bin/tar Message-ID: <201004110132.o3B1WURr051268@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kientzle Date: Sun Apr 11 01:32:30 2010 New Revision: 206465 URL: http://svn.freebsd.org/changeset/base/206465 Log: Consistently specify O_BINARY when opening files. Modified: head/usr.bin/tar/write.c Modified: head/usr.bin/tar/write.c ============================================================================== --- head/usr.bin/tar/write.c Sun Apr 11 01:31:50 2010 (r206464) +++ head/usr.bin/tar/write.c Sun Apr 11 01:32:30 2010 (r206465) @@ -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, s #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 *bsdta 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,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201004110132.o3B1WURr051268>