diff options
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/dd.c | 20 | ||||
-rw-r--r-- | coreutils/dos2unix.c | 2 | ||||
-rw-r--r-- | coreutils/ls.c | 9 | ||||
-rw-r--r-- | coreutils/od_bloaty.c | 7 | ||||
-rw-r--r-- | coreutils/test.c | 23 |
5 files changed, 57 insertions, 4 deletions
diff --git a/coreutils/dd.c b/coreutils/dd.c index 7c1a0c0df..eb9f8885f 100644 --- a/coreutils/dd.c +++ b/coreutils/dd.c | |||
@@ -168,6 +168,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv) | |||
168 | #endif | 168 | #endif |
169 | }; | 169 | }; |
170 | int exitcode = EXIT_FAILURE; | 170 | int exitcode = EXIT_FAILURE; |
171 | int devzero = 0; | ||
171 | size_t ibs = 512, obs = 512; | 172 | size_t ibs = 512, obs = 512; |
172 | ssize_t n, w; | 173 | ssize_t n, w; |
173 | char *ibuf, *obuf; | 174 | char *ibuf, *obuf; |
@@ -285,7 +286,12 @@ int dd_main(int argc UNUSED_PARAM, char **argv) | |||
285 | #endif | 286 | #endif |
286 | 287 | ||
287 | if (infile != NULL) | 288 | if (infile != NULL) |
288 | xmove_fd(xopen(infile, O_RDONLY), ifd); | 289 | if (ENABLE_PLATFORM_MINGW32 && !strcmp(infile, "/dev/zero")) { |
290 | flags |= FLAG_NOERROR; | ||
291 | devzero = 1; | ||
292 | } | ||
293 | else | ||
294 | xmove_fd(xopen(infile, O_RDONLY), ifd); | ||
289 | else { | 295 | else { |
290 | infile = bb_msg_standard_input; | 296 | infile = bb_msg_standard_input; |
291 | } | 297 | } |
@@ -312,7 +318,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv) | |||
312 | } else { | 318 | } else { |
313 | outfile = bb_msg_standard_output; | 319 | outfile = bb_msg_standard_output; |
314 | } | 320 | } |
315 | if (skip) { | 321 | if (skip && !devzero) { |
316 | if (lseek(ifd, skip * ibs, SEEK_CUR) < 0) { | 322 | if (lseek(ifd, skip * ibs, SEEK_CUR) < 0) { |
317 | while (skip-- > 0) { | 323 | while (skip-- > 0) { |
318 | n = safe_read(ifd, ibuf, ibs); | 324 | n = safe_read(ifd, ibuf, ibs); |
@@ -329,7 +335,12 @@ int dd_main(int argc UNUSED_PARAM, char **argv) | |||
329 | } | 335 | } |
330 | 336 | ||
331 | while (!(flags & FLAG_COUNT) || (G.in_full + G.in_part != count)) { | 337 | while (!(flags & FLAG_COUNT) || (G.in_full + G.in_part != count)) { |
332 | n = safe_read(ifd, ibuf, ibs); | 338 | if (devzero) { |
339 | memset(ibuf, 0, ibs); | ||
340 | n = ibs; | ||
341 | } | ||
342 | else | ||
343 | n = safe_read(ifd, ibuf, ibs); | ||
333 | if (n == 0) | 344 | if (n == 0) |
334 | break; | 345 | break; |
335 | if (n < 0) { | 346 | if (n < 0) { |
@@ -383,7 +394,8 @@ int dd_main(int argc UNUSED_PARAM, char **argv) | |||
383 | if (w < 0) goto out_status; | 394 | if (w < 0) goto out_status; |
384 | if (w > 0) G.out_part++; | 395 | if (w > 0) G.out_part++; |
385 | } | 396 | } |
386 | if (close(ifd) < 0) { | 397 | |
398 | if (!devzero && close(ifd) < 0) { | ||
387 | die_infile: | 399 | die_infile: |
388 | bb_simple_perror_msg_and_die(infile); | 400 | bb_simple_perror_msg_and_die(infile); |
389 | } | 401 | } |
diff --git a/coreutils/dos2unix.c b/coreutils/dos2unix.c index 1911f5319..1c8b4af1b 100644 --- a/coreutils/dos2unix.c +++ b/coreutils/dos2unix.c | |||
@@ -41,7 +41,9 @@ static void convert(char *fn, int conv_type) | |||
41 | temp_fn = xasprintf("%sXXXXXX", resolved_fn); | 41 | temp_fn = xasprintf("%sXXXXXX", resolved_fn); |
42 | i = mkstemp(temp_fn); | 42 | i = mkstemp(temp_fn); |
43 | if (i == -1 | 43 | if (i == -1 |
44 | #if !ENABLE_PLATFORM_MINGW32 | ||
44 | || fchmod(i, st.st_mode) == -1 | 45 | || fchmod(i, st.st_mode) == -1 |
46 | #endif | ||
45 | ) { | 47 | ) { |
46 | bb_simple_perror_msg_and_die(temp_fn); | 48 | bb_simple_perror_msg_and_die(temp_fn); |
47 | } | 49 | } |
diff --git a/coreutils/ls.c b/coreutils/ls.c index 1197f7d71..717b3f493 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c | |||
@@ -612,7 +612,12 @@ static NOINLINE unsigned list_single(const struct dnode *dn) | |||
612 | if (all_fmt & LIST_INO) | 612 | if (all_fmt & LIST_INO) |
613 | column += printf("%7llu ", (long long) dn->dstat.st_ino); | 613 | column += printf("%7llu ", (long long) dn->dstat.st_ino); |
614 | if (all_fmt & LIST_BLOCKS) | 614 | if (all_fmt & LIST_BLOCKS) |
615 | #if ENABLE_PLATFORM_MINGW32 | ||
616 | /* MinGW does not have st_blocks */ | ||
617 | column += printf("%4"OFF_FMT"u ", (off_t)0); | ||
618 | #else | ||
615 | column += printf("%4"OFF_FMT"u ", (off_t) (dn->dstat.st_blocks >> 1)); | 619 | column += printf("%4"OFF_FMT"u ", (off_t) (dn->dstat.st_blocks >> 1)); |
620 | #endif | ||
616 | if (all_fmt & LIST_MODEBITS) | 621 | if (all_fmt & LIST_MODEBITS) |
617 | column += printf("%-10s ", (char *) bb_mode_string(dn->dstat.st_mode)); | 622 | column += printf("%-10s ", (char *) bb_mode_string(dn->dstat.st_mode)); |
618 | if (all_fmt & LIST_NLINKS) | 623 | if (all_fmt & LIST_NLINKS) |
@@ -790,6 +795,7 @@ static void showfiles(struct dnode **dn, unsigned nfiles) | |||
790 | } | 795 | } |
791 | 796 | ||
792 | 797 | ||
798 | #if !ENABLE_PLATFORM_MINGW32 | ||
793 | #if ENABLE_DESKTOP | 799 | #if ENABLE_DESKTOP |
794 | /* http://www.opengroup.org/onlinepubs/9699919799/utilities/ls.html | 800 | /* http://www.opengroup.org/onlinepubs/9699919799/utilities/ls.html |
795 | * If any of the -l, -n, -s options is specified, each list | 801 | * If any of the -l, -n, -s options is specified, each list |
@@ -818,6 +824,7 @@ static off_t calculate_blocks(struct dnode **dn) | |||
818 | return blocks >> 1; | 824 | return blocks >> 1; |
819 | } | 825 | } |
820 | #endif | 826 | #endif |
827 | #endif | ||
821 | 828 | ||
822 | 829 | ||
823 | static struct dnode **list_dir(const char *, unsigned *); | 830 | static struct dnode **list_dir(const char *, unsigned *); |
@@ -843,10 +850,12 @@ static void showdirs(struct dnode **dn, int first) | |||
843 | printf("%s:\n", (*dn)->fullname); | 850 | printf("%s:\n", (*dn)->fullname); |
844 | } | 851 | } |
845 | subdnp = list_dir((*dn)->fullname, &nfiles); | 852 | subdnp = list_dir((*dn)->fullname, &nfiles); |
853 | #if !ENABLE_PLATFORM_MINGW32 | ||
846 | #if ENABLE_DESKTOP | 854 | #if ENABLE_DESKTOP |
847 | if ((all_fmt & STYLE_MASK) == STYLE_LONG) | 855 | if ((all_fmt & STYLE_MASK) == STYLE_LONG) |
848 | printf("total %"OFF_FMT"u\n", calculate_blocks(subdnp)); | 856 | printf("total %"OFF_FMT"u\n", calculate_blocks(subdnp)); |
849 | #endif | 857 | #endif |
858 | #endif | ||
850 | if (nfiles > 0) { | 859 | if (nfiles > 0) { |
851 | /* list all files at this level */ | 860 | /* list all files at this level */ |
852 | dnsort(subdnp, nfiles); | 861 | dnsort(subdnp, nfiles); |
diff --git a/coreutils/od_bloaty.c b/coreutils/od_bloaty.c index a9a45c8d3..4c6b64d5e 100644 --- a/coreutils/od_bloaty.c +++ b/coreutils/od_bloaty.c | |||
@@ -84,6 +84,13 @@ typedef long long llong; | |||
84 | # define LDBL_DIG DBL_DIG | 84 | # define LDBL_DIG DBL_DIG |
85 | #endif | 85 | #endif |
86 | 86 | ||
87 | #ifdef __MINGW32__ | ||
88 | /* symbol conflict */ | ||
89 | #define CHAR SIZE_CHAR | ||
90 | #define SHORT SIZE_SHORT | ||
91 | #define LONG SIZE_LONG | ||
92 | #define INT SIZE_INT | ||
93 | #endif | ||
87 | enum size_spec { | 94 | enum size_spec { |
88 | NO_SIZE, | 95 | NO_SIZE, |
89 | CHAR, | 96 | CHAR, |
diff --git a/coreutils/test.c b/coreutils/test.c index 70eac5f6c..fb5778760 100644 --- a/coreutils/test.c +++ b/coreutils/test.c | |||
@@ -619,6 +619,29 @@ static int filstat(char *nm, enum token mode) | |||
619 | return 0; | 619 | return 0; |
620 | } | 620 | } |
621 | 621 | ||
622 | #if ENABLE_PLATFORM_MINGW32 | ||
623 | if (mode == FILEX) { | ||
624 | int len = strlen(nm), ret; | ||
625 | if (len >= 4 && | ||
626 | (!strcmp(nm+len-4,".exe") || | ||
627 | !strcmp(nm+len-4,".com"))) | ||
628 | ret = stat(nm, &s); | ||
629 | else { | ||
630 | char *exepath; | ||
631 | exepath = malloc(len+5); | ||
632 | memcpy(exepath, nm, len); | ||
633 | memcpy(exepath+len, ".exe", 5); | ||
634 | ret = stat(exepath, &s); | ||
635 | if (ret < 0) { | ||
636 | memcpy(exepath+len, ".exe", 5); | ||
637 | ret = stat(exepath, &s); | ||
638 | } | ||
639 | free(exepath); | ||
640 | } | ||
641 | return ret >= 0; | ||
642 | } | ||
643 | #endif | ||
644 | |||
622 | if (stat(nm, &s) != 0) | 645 | if (stat(nm, &s) != 0) |
623 | return 0; | 646 | return 0; |
624 | if (mode == FILEXIST) | 647 | if (mode == FILEXIST) |