diff options
Diffstat (limited to 'coreutils')
| -rw-r--r-- | coreutils/dd.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/coreutils/dd.c b/coreutils/dd.c index a9ef68fbc..e6b88acf5 100644 --- a/coreutils/dd.c +++ b/coreutils/dd.c | |||
| @@ -333,6 +333,17 @@ static void *alloc_buf(size_t size) | |||
| 333 | return xmalloc(size); | 333 | return xmalloc(size); |
| 334 | } | 334 | } |
| 335 | 335 | ||
| 336 | #if ENABLE_PLATFORM_MINGW32 | ||
| 337 | // Does 'path' refer to a physical drive in the win32 device namespace? | ||
| 338 | static int is_drive_path(const char *path) | ||
| 339 | { | ||
| 340 | char *s = auto_string(strdup(path)); | ||
| 341 | |||
| 342 | bs_to_slash(s); | ||
| 343 | return strncasecmp(s, "//./PhysicalDrive", 17) == 0; | ||
| 344 | } | ||
| 345 | #endif | ||
| 346 | |||
| 336 | int dd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 347 | int dd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
| 337 | int dd_main(int argc UNUSED_PARAM, char **argv) | 348 | int dd_main(int argc UNUSED_PARAM, char **argv) |
| 338 | { | 349 | { |
| @@ -558,6 +569,12 @@ int dd_main(int argc UNUSED_PARAM, char **argv) | |||
| 558 | # endif | 569 | # endif |
| 559 | } | 570 | } |
| 560 | #endif | 571 | #endif |
| 572 | #if ENABLE_PLATFORM_MINGW32 | ||
| 573 | if (is_drive_path(outfile)) { | ||
| 574 | // Turn off options not supported by Windows device files. | ||
| 575 | oflag &= ~(O_CREAT | O_TRUNC); | ||
| 576 | } | ||
| 577 | #endif | ||
| 561 | xmove_fd(xopen(outfile, oflag), ofd); | 578 | xmove_fd(xopen(outfile, oflag), ofd); |
| 562 | 579 | ||
| 563 | #if ENABLE_PLATFORM_MINGW32 | 580 | #if ENABLE_PLATFORM_MINGW32 |
