aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/dd.c20
-rw-r--r--coreutils/od_bloaty.c7
-rw-r--r--coreutils/stat.c1
-rw-r--r--coreutils/test.c15
4 files changed, 38 insertions, 5 deletions
diff --git a/coreutils/dd.c b/coreutils/dd.c
index 4dc302926..00139773e 100644
--- a/coreutils/dd.c
+++ b/coreutils/dd.c
@@ -292,6 +292,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
292#endif 292#endif
293 }; 293 };
294 smallint exitcode = EXIT_FAILURE; 294 smallint exitcode = EXIT_FAILURE;
295 int devzero = 0;
295 int i; 296 int i;
296 size_t ibs = 512; 297 size_t ibs = 512;
297 char *ibuf; 298 char *ibuf;
@@ -418,7 +419,12 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
418#endif 419#endif
419 420
420 if (infile) { 421 if (infile) {
421 xmove_fd(xopen(infile, O_RDONLY), ifd); 422 if (ENABLE_PLATFORM_MINGW32 && !strcmp(infile, "/dev/zero")) {
423 G.flags |= FLAG_NOERROR;
424 devzero = 1;
425 } else {
426 xmove_fd(xopen(infile, O_RDONLY), ifd);
427 }
422 } else { 428 } else {
423 infile = bb_msg_standard_input; 429 infile = bb_msg_standard_input;
424 } 430 }
@@ -445,7 +451,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
445 } else { 451 } else {
446 outfile = bb_msg_standard_output; 452 outfile = bb_msg_standard_output;
447 } 453 }
448 if (skip) { 454 if (skip && !devzero) {
449 size_t blocksz = (G.flags & FLAG_SKIP_BYTES) ? 1 : ibs; 455 size_t blocksz = (G.flags & FLAG_SKIP_BYTES) ? 1 : ibs;
450 if (lseek(ifd, skip * blocksz, SEEK_CUR) < 0) { 456 if (lseek(ifd, skip * blocksz, SEEK_CUR) < 0) {
451 do { 457 do {
@@ -465,7 +471,12 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
465 while (!(G.flags & FLAG_COUNT) || (G.in_full + G.in_part != count)) { 471 while (!(G.flags & FLAG_COUNT) || (G.in_full + G.in_part != count)) {
466 ssize_t n; 472 ssize_t n;
467 473
468 n = safe_read(ifd, ibuf, ibs); 474 if (devzero) {
475 memset(ibuf, 0, ibs);
476 n = ibs;
477 }
478 else
479 n = safe_read(ifd, ibuf, ibs);
469 if (n == 0) 480 if (n == 0)
470 break; 481 break;
471 if (n < 0) { 482 if (n < 0) {
@@ -541,7 +552,8 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
541 if (write_and_stats(obuf, oc, obs, outfile)) 552 if (write_and_stats(obuf, oc, obs, outfile))
542 goto out_status; 553 goto out_status;
543 } 554 }
544 if (close(ifd) < 0) { 555
556 if (!devzero && close(ifd) < 0) {
545 die_infile: 557 die_infile:
546 bb_simple_perror_msg_and_die(infile); 558 bb_simple_perror_msg_and_die(infile);
547 } 559 }
diff --git a/coreutils/od_bloaty.c b/coreutils/od_bloaty.c
index f13bdfc11..b02fb09bd 100644
--- a/coreutils/od_bloaty.c
+++ b/coreutils/od_bloaty.c
@@ -101,6 +101,13 @@ typedef long long llong;
101# define LDBL_DIG DBL_DIG 101# define LDBL_DIG DBL_DIG
102#endif 102#endif
103 103
104#if ENABLE_PLATFORM_MINGW32
105/* symbol conflict */
106#define CHAR SIZE_CHAR
107#define SHORT SIZE_SHORT
108#define LONG SIZE_LONG
109#define INT SIZE_INT
110#endif
104enum size_spec { 111enum size_spec {
105 NO_SIZE, 112 NO_SIZE,
106 CHAR, 113 CHAR,
diff --git a/coreutils/stat.c b/coreutils/stat.c
index ddcfcf2d7..f608045d7 100644
--- a/coreutils/stat.c
+++ b/coreutils/stat.c
@@ -31,7 +31,6 @@
31//config: bool "Enable display of filesystem status (-f)" 31//config: bool "Enable display of filesystem status (-f)"
32//config: default y 32//config: default y
33//config: depends on STAT 33//config: depends on STAT
34//config: select PLATFORM_LINUX # statfs()
35//config: help 34//config: help
36//config: Without this, stat will not support the '-f' option to display 35//config: Without this, stat will not support the '-f' option to display
37//config: information about filesystem status. 36//config: information about filesystem status.
diff --git a/coreutils/test.c b/coreutils/test.c
index bf8dc47e8..b8a5d798c 100644
--- a/coreutils/test.c
+++ b/coreutils/test.c
@@ -638,6 +638,21 @@ static int filstat(char *nm, enum token mode)
638 return 0; 638 return 0;
639 } 639 }
640 640
641#if ENABLE_PLATFORM_MINGW32
642 if (mode == FILEX) {
643 char *p;
644
645 if (file_is_executable(nm)) {
646 return 1;
647 }
648 else if ((p=file_is_win32_executable(nm))) {
649 free(p);
650 return 1;
651 }
652 return 0;
653 }
654#endif
655
641 if (stat(nm, &s) != 0) 656 if (stat(nm, &s) != 0)
642 return 0; 657 return 0;
643 if (mode == FILEXIST) 658 if (mode == FILEXIST)