summaryrefslogtreecommitdiff
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.c18
-rw-r--r--coreutils/test.c19
-rw-r--r--coreutils/uname.c10
5 files changed, 56 insertions, 12 deletions
diff --git a/coreutils/Config.src b/coreutils/Config.src
index 68c717883..2914fc36a 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..34ceefb1c 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,
@@ -387,8 +394,8 @@ print_named_ascii(size_t n_bytes, const char *block,
387 " sp" 394 " sp"
388 }; 395 };
389 // buf[N] pos: 01234 56789 396 // buf[N] pos: 01234 56789
390 char buf[12] = " x\0 0xx\0"; 397 char buf[12] = " x\0 xxx\0";
391 // actually " x\0 xxx\0", but want to share string with print_ascii. 398 // share string with print_ascii.
392 // [12] because we take three 32bit stack slots anyway, and 399 // [12] because we take three 32bit stack slots anyway, and
393 // gcc is too dumb to initialize with constant stores, 400 // gcc is too dumb to initialize with constant stores,
394 // it copies initializer from rodata. Oh well. 401 // it copies initializer from rodata. Oh well.
@@ -419,7 +426,7 @@ print_ascii(size_t n_bytes, const char *block,
419 const char *unused_fmt_string UNUSED_PARAM) 426 const char *unused_fmt_string UNUSED_PARAM)
420{ 427{
421 // buf[N] pos: 01234 56789 428 // buf[N] pos: 01234 56789
422 char buf[12] = " x\0 0xx\0"; 429 char buf[12] = " x\0 xxx\0";
423 430
424 while (n_bytes--) { 431 while (n_bytes--) {
425 const char *s; 432 const char *s;
@@ -458,8 +465,9 @@ print_ascii(size_t n_bytes, const char *block,
458 case '\x7f': 465 case '\x7f':
459 s = " 177"; 466 s = " 177";
460 break; 467 break;
461 default: /* c is never larger than 040 */ 468 default:
462 buf[7] = (c >> 3) + '0'; 469 buf[6] = (c >> 6 & 3) + '0';
470 buf[7] = (c >> 3 & 7) + '0';
463 buf[8] = (c & 7) + '0'; 471 buf[8] = (c & 7) + '0';
464 s = buf + 5; 472 s = buf + 5;
465 } 473 }
diff --git a/coreutils/test.c b/coreutils/test.c
index 88cc55050..6b16ffeb1 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=file_is_win32_executable(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);