46 lines
1.6 KiB
Diff
46 lines
1.6 KiB
Diff
--- origsrc/src/dd.c 2016-11-09 15:11:35.000000000 -0600
|
|
+++ src/src/dd.c 2017-02-03 13:32:48.741217700 -0600
|
|
@@ -37,6 +37,10 @@
|
|
#include "xstrtol.h"
|
|
#include "xtime.h"
|
|
|
|
+#ifdef __CYGWIN__
|
|
+# include <io.h>
|
|
+#endif
|
|
+
|
|
/* The official name of this program (e.g., no 'g' prefix). */
|
|
#define PROGRAM_NAME "dd"
|
|
|
|
@@ -1989,6 +1993,13 @@ copy_with_unblock (char const *buf, size
|
|
static void
|
|
set_fd_flags (int fd, int add_flags, char const *name)
|
|
{
|
|
+#if __CYGWIN__
|
|
+ /* Cygwin does not allow fcntl to set the mode. */
|
|
+ int mode_flags = add_flags & (O_BINARY | O_TEXT);
|
|
+ add_flags &= ~(O_BINARY | O_TEXT);
|
|
+ if (mode_flags && setmode (fd, mode_flags) == -1)
|
|
+ error (EXIT_FAILURE, errno, _("setting flags for %s"), quote (name));
|
|
+#endif /* __CYGWIN__ */
|
|
/* Ignore file creation flags that are no-ops on file descriptors. */
|
|
add_flags &= ~ (O_NOCTTY | O_NOFOLLOW);
|
|
|
|
@@ -2379,6 +2390,8 @@ main (int argc, char **argv)
|
|
}
|
|
else
|
|
{
|
|
+ if ((input_flags & (O_BINARY | O_TEXT)) == 0)
|
|
+ input_flags |= O_BINARY;
|
|
if (ifd_reopen (STDIN_FILENO, input_file, O_RDONLY | input_flags, 0) < 0)
|
|
die (EXIT_FAILURE, errno, _("failed to open %s"),
|
|
quoteaf (input_file));
|
|
@@ -2402,6 +2415,8 @@ main (int argc, char **argv)
|
|
| (conversions_mask & C_NOCREAT ? 0 : O_CREAT)
|
|
| (conversions_mask & C_EXCL ? O_EXCL : 0)
|
|
| (seek_records || (conversions_mask & C_NOTRUNC) ? 0 : O_TRUNC));
|
|
+ if ((opts & (O_BINARY | O_TEXT)) == 0)
|
|
+ opts |= O_BINARY;
|
|
|
|
/* Open the output file with *read* access only if we might
|
|
need to read to satisfy a 'seek=' request. If we can't read
|