aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/Config.src1
-rw-r--r--coreutils/dd.c20
-rw-r--r--coreutils/od_bloaty.c7
-rw-r--r--coreutils/test.c19
-rw-r--r--coreutils/uname.c10
5 files changed, 50 insertions, 7 deletions
diff --git a/coreutils/Config.src b/coreutils/Config.src
index 33defa4db..82b6bf0d9 100644
--- a/coreutils/Config.src
+++ b/coreutils/Config.src
@@ -584,7 +584,6 @@ config FEATURE_SPLIT_FANCY
584config STAT 584config STAT
585 bool "stat" 585 bool "stat"
586 default y 586 default y
587 select PLATFORM_LINUX # statfs()
588 help 587 help
589 display file or filesystem status. 588 display file or filesystem status.
590 589
diff --git a/coreutils/dd.c b/coreutils/dd.c
index 2838f6341..db61f665e 100644
--- a/coreutils/dd.c
+++ b/coreutils/dd.c
@@ -203,6 +203,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
203#endif 203#endif
204 }; 204 };
205 smallint exitcode = EXIT_FAILURE; 205 smallint exitcode = EXIT_FAILURE;
206 int devzero = 0;
206 int i; 207 int i;
207 size_t ibs = 512; 208 size_t ibs = 512;
208 char *ibuf; 209 char *ibuf;
@@ -334,7 +335,12 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
334#endif 335#endif
335 336
336 if (infile) { 337 if (infile) {
337 xmove_fd(xopen(infile, O_RDONLY), ifd); 338 if (ENABLE_PLATFORM_MINGW32 && !strcmp(infile, "/dev/zero")) {
339 flags |= FLAG_NOERROR;
340 devzero = 1;
341 } else {
342 xmove_fd(xopen(infile, O_RDONLY), ifd);
343 }
338 } else { 344 } else {
339 infile = bb_msg_standard_input; 345 infile = bb_msg_standard_input;
340 } 346 }
@@ -361,7 +367,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
361 } else { 367 } else {
362 outfile = bb_msg_standard_output; 368 outfile = bb_msg_standard_output;
363 } 369 }
364 if (skip) { 370 if (skip && !devzero) {
365 if (lseek(ifd, skip * ibs, SEEK_CUR) < 0) { 371 if (lseek(ifd, skip * ibs, SEEK_CUR) < 0) {
366 do { 372 do {
367 ssize_t n = safe_read(ifd, ibuf, ibs); 373 ssize_t n = safe_read(ifd, ibuf, ibs);
@@ -380,7 +386,12 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
380 while (!(flags & FLAG_COUNT) || (G.in_full + G.in_part != count)) { 386 while (!(flags & FLAG_COUNT) || (G.in_full + G.in_part != count)) {
381 ssize_t n; 387 ssize_t n;
382 388
383 n = safe_read(ifd, ibuf, ibs); 389 if (devzero) {
390 memset(ibuf, 0, ibs);
391 n = ibs;
392 }
393 else
394 n = safe_read(ifd, ibuf, ibs);
384 if (n == 0) 395 if (n == 0)
385 break; 396 break;
386 if (n < 0) { 397 if (n < 0) {
@@ -456,7 +467,8 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
456 if (write_and_stats(obuf, oc, obs, outfile)) 467 if (write_and_stats(obuf, oc, obs, outfile))
457 goto out_status; 468 goto out_status;
458 } 469 }
459 if (close(ifd) < 0) { 470
471 if (!devzero && close(ifd) < 0) {
460 die_infile: 472 die_infile:
461 bb_simple_perror_msg_and_die(infile); 473 bb_simple_perror_msg_and_die(infile);
462 } 474 }
diff --git a/coreutils/od_bloaty.c b/coreutils/od_bloaty.c
index 2c26dda16..c4d11601f 100644
--- a/coreutils/od_bloaty.c
+++ b/coreutils/od_bloaty.c
@@ -100,6 +100,13 @@ typedef long long llong;
100# define LDBL_DIG DBL_DIG 100# define LDBL_DIG DBL_DIG
101#endif 101#endif
102 102
103#if ENABLE_PLATFORM_MINGW32
104/* symbol conflict */
105#define CHAR SIZE_CHAR
106#define SHORT SIZE_SHORT
107#define LONG SIZE_LONG
108#define INT SIZE_INT
109#endif
103enum size_spec { 110enum size_spec {
104 NO_SIZE, 111 NO_SIZE,
105 CHAR, 112 CHAR,
diff --git a/coreutils/test.c b/coreutils/test.c
index 4df505a05..139f1db75 100644
--- a/coreutils/test.c
+++ b/coreutils/test.c
@@ -642,6 +642,25 @@ static int filstat(char *nm, enum token mode)
642 return 0; 642 return 0;
643 } 643 }
644 644
645#if ENABLE_PLATFORM_MINGW32
646#undef R_OK
647#define R_OK S_IREAD
648#undef W_OK
649#define W_OK S_IWRITE
650 if (mode == FILEX) {
651 char *p;
652
653 if (file_is_executable(nm)) {
654 return 1;
655 }
656 else if ((p=win32_execable_file(nm))) {
657 free(p);
658 return 1;
659 }
660 return 0;
661 }
662#endif
663
645 if (stat(nm, &s) != 0) 664 if (stat(nm, &s) != 0)
646 return 0; 665 return 0;
647 if (mode == FILEXIST) 666 if (mode == FILEXIST)
diff --git a/coreutils/uname.c b/coreutils/uname.c
index 1c6aa5f79..56d985eb0 100644
--- a/coreutils/uname.c
+++ b/coreutils/uname.c
@@ -70,11 +70,17 @@
70/* After libbb.h, since it needs sys/types.h on some systems */ 70/* After libbb.h, since it needs sys/types.h on some systems */
71#include <sys/utsname.h> 71#include <sys/utsname.h>
72 72
73#if ENABLE_PLATFORM_MINGW32
74# define OSNAME "MS/Windows"
75#else
76# define OSNAME "GNU/Linux"
77#endif
78
73typedef struct { 79typedef struct {
74 struct utsname name; 80 struct utsname name;
75 char processor[sizeof(((struct utsname*)NULL)->machine)]; 81 char processor[sizeof(((struct utsname*)NULL)->machine)];
76 char platform[sizeof(((struct utsname*)NULL)->machine)]; 82 char platform[sizeof(((struct utsname*)NULL)->machine)];
77 char os[sizeof("GNU/Linux")]; 83 char os[sizeof(OSNAME)];
78} uname_info_t; 84} uname_info_t;
79 85
80static const char options[] ALIGN1 = "snrvmpioa"; 86static const char options[] ALIGN1 = "snrvmpioa";
@@ -141,7 +147,7 @@ int uname_main(int argc UNUSED_PARAM, char **argv)
141#endif 147#endif
142 strcpy(uname_info.processor, unknown_str); 148 strcpy(uname_info.processor, unknown_str);
143 strcpy(uname_info.platform, unknown_str); 149 strcpy(uname_info.platform, unknown_str);
144 strcpy(uname_info.os, "GNU/Linux"); 150 strcpy(uname_info.os, OSNAME);
145#if 0 151#if 0
146 /* Fedora does something like this */ 152 /* Fedora does something like this */
147 strcpy(uname_info.processor, uname_info.name.machine); 153 strcpy(uname_info.processor, uname_info.name.machine);