Files
MSYS2-packages/tar/1.29-mode-binary.patch
2019-01-16 08:04:32 +03:00

128 lines
4.1 KiB
Diff

diff -Naur tar-1.31-orig/lib/rmt.h tar-1.31/lib/rmt.h
--- tar-1.31-orig/lib/rmt.h 2015-12-06 00:53:30.000000000 +0300
+++ tar-1.31/lib/rmt.h 2019-01-15 11:43:57.167024200 +0300
@@ -62,7 +62,7 @@
#define rmtcreat(dev_name, mode, command) \
(_remdev (dev_name) \
? rmt_open__ (dev_name, O_CREAT | O_WRONLY, __REM_BIAS, command) \
- : creat (dev_name, mode))
+ : open (dev_name, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, mode))
#define rmtlstat(dev_name, muffer) \
(_remdev (dev_name) ? (errno = EOPNOTSUPP), -1 : lstat (dev_name, buffer))
diff -Naur tar-1.31-orig/rmt/rmt.c tar-1.31/rmt/rmt.c
--- tar-1.31-orig/rmt/rmt.c 2018-07-31 11:55:58.000000000 +0300
+++ tar-1.31/rmt/rmt.c 2019-01-15 11:43:57.182624300 +0300
@@ -338,7 +338,7 @@
if (device_fd >= 0)
close (device_fd);
- device_fd = open (device, flag, MODE_RW);
+ device_fd = open (device, flag | O_BINARY, MODE_RW);
if (device_fd < 0)
rmt_error (errno);
else
diff -Naur tar-1.31-orig/src/buffer.c tar-1.31/src/buffer.c
--- tar-1.31-orig/src/buffer.c 2019-01-02 21:07:47.000000000 +0300
+++ tar-1.31/src/buffer.c 2019-01-15 11:43:57.182624300 +0300
@@ -766,6 +766,7 @@
enum compress_type type;
archive = STDIN_FILENO;
+ freopen (NULL, "rb", stdin);
type = check_compressed_archive (&shortfile);
if (type != ct_tar && type != ct_none)
FATAL_ERROR ((0, 0,
@@ -778,12 +779,19 @@
case ACCESS_WRITE:
archive = STDOUT_FILENO;
+ freopen (NULL,
+ fcntl (STDOUT_FILENO, F_GETFL) & O_APPEND ? "ab" : "wb",
+ stdout);
if (!index_file_name)
stdlis = stderr;
break;
case ACCESS_UPDATE:
archive = STDIN_FILENO;
+ freopen (NULL, "rb", stdin);
+ freopen (NULL,
+ fcntl (STDOUT_FILENO, F_GETFL) & O_APPEND ? "ab" : "wb",
+ stdout);
write_archive_to_stdout = true;
record_end = record_start; /* set up for 1st record = # 0 */
if (!index_file_name)
@@ -1182,7 +1190,7 @@
void
closeout_volume_number (void)
{
- FILE *file = fopen (volno_file_option, "w");
+ FILE *file = fopen (volno_file_option, "wb");
if (file)
{
diff -Naur tar-1.31-orig/src/incremen.c tar-1.31/src/incremen.c
--- tar-1.31-orig/src/incremen.c 2019-01-02 21:07:48.000000000 +0300
+++ tar-1.31/src/incremen.c 2019-01-15 11:43:57.198224300 +0300
@@ -1035,7 +1035,14 @@
lineno++;
if (buf[n - 1] == '\n')
- buf[n - 1] = '\0';
+ {
+ buf[n - 1] = '\0';
+ /* Cygwin hack - older tars created incremental files with \r\n
+ line endings, so strip the \r. This breaks on managed mount
+ on directories with a trailing \r, oh well. */
+ if (buf[n - 2] == '\r')
+ buf[n - 2] = '\0';
+ }
if (version == 1)
{
@@ -1330,7 +1337,7 @@
int fd;
char *buf = NULL;
size_t bufsize = 0;
- int flags = O_RDWR | O_CREAT;
+ int flags = O_RDWR | O_CREAT | O_BINARY;
if (incremental_level == 0)
flags |= O_TRUNC;
@@ -1344,7 +1351,7 @@
return;
}
- listed_incremental_stream = fdopen (fd, "r+");
+ listed_incremental_stream = fdopen (fd, "rb+");
if (! listed_incremental_stream)
{
open_error (listed_incremental_option);
diff -Naur tar-1.31-orig/src/system.c tar-1.31/src/system.c
--- tar-1.31-orig/src/system.c 2019-01-02 21:07:48.000000000 +0300
+++ tar-1.31/src/system.c 2019-01-15 11:43:57.213824300 +0300
@@ -366,7 +366,8 @@
compressor. */
if (strcmp (archive_name_array[0], "-"))
{
- archive = creat (archive_name_array[0], MODE_RW);
+ archive = open (archive_name_array[0],
+ O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, MODE_RW);
if (archive < 0)
{
int saved_errno = errno;
@@ -407,7 +408,11 @@
xclose (child_pipe[PWRITE]);
if (strcmp (archive_name_array[0], "-") == 0)
- archive = STDOUT_FILENO;
+ {
+ archive = STDOUT_FILENO;
+ freopen (NULL, fcntl (STDOUT_FILENO, F_GETFL) & O_APPEND ? "ab" : "wb",
+ stdout);
+ }
else
{
archive = rmtcreat (archive_name_array[0], MODE_RW, rsh_command_option);