diff options
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/Config.src | 3 | ||||
-rw-r--r-- | coreutils/date.c | 13 | ||||
-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 | ||||
-rw-r--r-- | coreutils/whoami.c | 10 |
8 files changed, 82 insertions, 5 deletions
diff --git a/coreutils/Config.src b/coreutils/Config.src index c2fd73e59..b599f7999 100644 --- a/coreutils/Config.src +++ b/coreutils/Config.src | |||
@@ -512,18 +512,21 @@ config SEQ | |||
512 | config SHA1SUM | 512 | config SHA1SUM |
513 | bool "sha1sum" | 513 | bool "sha1sum" |
514 | default y | 514 | default y |
515 | depends on PLATFORM_POSIX || WIN32_NET | ||
515 | help | 516 | help |
516 | Compute and check SHA1 message digest | 517 | Compute and check SHA1 message digest |
517 | 518 | ||
518 | config SHA256SUM | 519 | config SHA256SUM |
519 | bool "sha256sum" | 520 | bool "sha256sum" |
520 | default y | 521 | default y |
522 | depends on PLATFORM_POSIX || WIN32_NET | ||
521 | help | 523 | help |
522 | Compute and check SHA256 message digest | 524 | Compute and check SHA256 message digest |
523 | 525 | ||
524 | config SHA512SUM | 526 | config SHA512SUM |
525 | bool "sha512sum" | 527 | bool "sha512sum" |
526 | default y | 528 | default y |
529 | depends on PLATFORM_POSIX || WIN32_NET | ||
527 | help | 530 | help |
528 | Compute and check SHA512 message digest | 531 | Compute and check SHA512 message digest |
529 | 532 | ||
diff --git a/coreutils/date.c b/coreutils/date.c index 6ad5f1bb6..22d0a5327 100644 --- a/coreutils/date.c +++ b/coreutils/date.c | |||
@@ -290,9 +290,14 @@ int date_main(int argc UNUSED_PARAM, char **argv) | |||
290 | maybe_set_utc(opt); | 290 | maybe_set_utc(opt); |
291 | 291 | ||
292 | /* if setting time, set it */ | 292 | /* if setting time, set it */ |
293 | #if ENABLE_PLATFORM_MINGW32 | ||
294 | if (opt & OPT_SET) | ||
295 | bb_error_msg_and_die("Setting date is not supported"); | ||
296 | #else | ||
293 | if ((opt & OPT_SET) && stime(&ts.tv_sec) < 0) { | 297 | if ((opt & OPT_SET) && stime(&ts.tv_sec) < 0) { |
294 | bb_perror_msg("can't set date"); | 298 | bb_perror_msg("can't set date"); |
295 | } | 299 | } |
300 | #endif | ||
296 | } | 301 | } |
297 | 302 | ||
298 | /* Display output */ | 303 | /* Display output */ |
@@ -320,7 +325,11 @@ int date_main(int argc UNUSED_PARAM, char **argv) | |||
320 | i = sizeof("%a, %d %b %Y %H:%M:%S ")-1; | 325 | i = sizeof("%a, %d %b %Y %H:%M:%S ")-1; |
321 | goto format_utc; | 326 | goto format_utc; |
322 | } else { /* default case */ | 327 | } else { /* default case */ |
328 | #if ENABLE_PLATFORM_MINGW32 | ||
329 | fmt_dt2str = (char*)"%a %b %d %H:%M:%S %Z %Y"; | ||
330 | #else | ||
323 | fmt_dt2str = (char*)"%a %b %e %H:%M:%S %Z %Y"; | 331 | fmt_dt2str = (char*)"%a %b %e %H:%M:%S %Z %Y"; |
332 | #endif | ||
324 | } | 333 | } |
325 | } | 334 | } |
326 | #if ENABLE_FEATURE_DATE_NANO | 335 | #if ENABLE_FEATURE_DATE_NANO |
@@ -373,6 +382,10 @@ int date_main(int argc UNUSED_PARAM, char **argv) | |||
373 | if (strncmp(fmt_dt2str, "%f", 2) == 0) { | 382 | if (strncmp(fmt_dt2str, "%f", 2) == 0) { |
374 | fmt_dt2str = (char*)"%Y.%m.%d-%H:%M:%S"; | 383 | fmt_dt2str = (char*)"%Y.%m.%d-%H:%M:%S"; |
375 | } | 384 | } |
385 | #if ENABLE_PLATFORM_MINGW32 | ||
386 | if (strstr(fmt_dt2str, "%e")) | ||
387 | bb_error_msg_and_die("%%e is not supported by Windows strftime"); | ||
388 | #endif | ||
376 | /* Generate output string */ | 389 | /* Generate output string */ |
377 | strftime(date_buf, sizeof(date_buf), fmt_dt2str, &tm_time); | 390 | strftime(date_buf, sizeof(date_buf), fmt_dt2str, &tm_time); |
378 | } | 391 | } |
diff --git a/coreutils/dd.c b/coreutils/dd.c index 347a19454..da205ec69 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 eab8110dc..35fa11247 100644 --- a/coreutils/dos2unix.c +++ b/coreutils/dos2unix.c | |||
@@ -42,7 +42,7 @@ static void convert(char *fn, int conv_type) | |||
42 | 42 | ||
43 | temp_fn = xasprintf("%sXXXXXX", resolved_fn); | 43 | temp_fn = xasprintf("%sXXXXXX", resolved_fn); |
44 | i = xmkstemp(temp_fn); | 44 | i = xmkstemp(temp_fn); |
45 | if (fchmod(i, st.st_mode) == -1) | 45 | if (!ENABLE_PLATFORM_MINGW32 && fchmod(i, st.st_mode) == -1) |
46 | bb_simple_perror_msg_and_die(temp_fn); | 46 | bb_simple_perror_msg_and_die(temp_fn); |
47 | 47 | ||
48 | out = xfdopen_for_write(i); | 48 | out = xfdopen_for_write(i); |
diff --git a/coreutils/ls.c b/coreutils/ls.c index 2be3afadf..1afe28c8d 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c | |||
@@ -683,7 +683,12 @@ static NOINLINE unsigned list_single(const struct dnode *dn) | |||
683 | if (all_fmt & LIST_INO) | 683 | if (all_fmt & LIST_INO) |
684 | column += printf("%7llu ", (long long) dn->dstat.st_ino); | 684 | column += printf("%7llu ", (long long) dn->dstat.st_ino); |
685 | if (all_fmt & LIST_BLOCKS) | 685 | if (all_fmt & LIST_BLOCKS) |
686 | #if ENABLE_PLATFORM_MINGW32 | ||
687 | /* MinGW does not have st_blocks */ | ||
688 | column += printf("%4"OFF_FMT"u ", (off_t)0); | ||
689 | #else | ||
686 | column += printf("%4"OFF_FMT"u ", (off_t) (dn->dstat.st_blocks >> 1)); | 690 | column += printf("%4"OFF_FMT"u ", (off_t) (dn->dstat.st_blocks >> 1)); |
691 | #endif | ||
687 | if (all_fmt & LIST_MODEBITS) | 692 | if (all_fmt & LIST_MODEBITS) |
688 | column += printf("%-10s ", (char *) bb_mode_string(dn->dstat.st_mode)); | 693 | column += printf("%-10s ", (char *) bb_mode_string(dn->dstat.st_mode)); |
689 | if (all_fmt & LIST_NLINKS) | 694 | if (all_fmt & LIST_NLINKS) |
@@ -863,6 +868,7 @@ static void showfiles(struct dnode **dn, unsigned nfiles) | |||
863 | } | 868 | } |
864 | 869 | ||
865 | 870 | ||
871 | #if !ENABLE_PLATFORM_MINGW32 | ||
866 | #if ENABLE_DESKTOP | 872 | #if ENABLE_DESKTOP |
867 | /* http://www.opengroup.org/onlinepubs/9699919799/utilities/ls.html | 873 | /* http://www.opengroup.org/onlinepubs/9699919799/utilities/ls.html |
868 | * If any of the -l, -n, -s options is specified, each list | 874 | * If any of the -l, -n, -s options is specified, each list |
@@ -891,6 +897,7 @@ static off_t calculate_blocks(struct dnode **dn) | |||
891 | return blocks >> 1; | 897 | return blocks >> 1; |
892 | } | 898 | } |
893 | #endif | 899 | #endif |
900 | #endif | ||
894 | 901 | ||
895 | 902 | ||
896 | static struct dnode **list_dir(const char *, unsigned *); | 903 | static struct dnode **list_dir(const char *, unsigned *); |
@@ -910,10 +917,12 @@ static void showdirs(struct dnode **dn, int first) | |||
910 | printf("%s:\n", (*dn)->fullname); | 917 | printf("%s:\n", (*dn)->fullname); |
911 | } | 918 | } |
912 | subdnp = list_dir((*dn)->fullname, &nfiles); | 919 | subdnp = list_dir((*dn)->fullname, &nfiles); |
920 | #if !ENABLE_PLATFORM_MINGW32 | ||
913 | #if ENABLE_DESKTOP | 921 | #if ENABLE_DESKTOP |
914 | if ((all_fmt & STYLE_MASK) == STYLE_LONG) | 922 | if ((all_fmt & STYLE_MASK) == STYLE_LONG) |
915 | printf("total %"OFF_FMT"u\n", calculate_blocks(subdnp)); | 923 | printf("total %"OFF_FMT"u\n", calculate_blocks(subdnp)); |
916 | #endif | 924 | #endif |
925 | #endif | ||
917 | if (nfiles > 0) { | 926 | if (nfiles > 0) { |
918 | /* list all files at this level */ | 927 | /* list all files at this level */ |
919 | dnsort(subdnp, nfiles); | 928 | 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 8248a1ef5..3e9ab7c65 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) |
diff --git a/coreutils/whoami.c b/coreutils/whoami.c index 78d20db14..f7ac7aa6d 100644 --- a/coreutils/whoami.c +++ b/coreutils/whoami.c | |||
@@ -16,11 +16,21 @@ | |||
16 | int whoami_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 16 | int whoami_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
17 | int whoami_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | 17 | int whoami_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) |
18 | { | 18 | { |
19 | #if ENABLE_PLATFORM_MINGW32 | ||
20 | char buf[64]; | ||
21 | DWORD len = 64; | ||
22 | #endif | ||
23 | |||
19 | if (argv[1]) | 24 | if (argv[1]) |
20 | bb_show_usage(); | 25 | bb_show_usage(); |
21 | 26 | ||
27 | #if ENABLE_PLATFORM_MINGW32 | ||
28 | GetUserName(buf, &len); | ||
29 | puts(buf); | ||
30 | #else | ||
22 | /* Will complain and die if username not found */ | 31 | /* Will complain and die if username not found */ |
23 | puts(xuid2uname(geteuid())); | 32 | puts(xuid2uname(geteuid())); |
33 | #endif | ||
24 | 34 | ||
25 | return fflush_all(); | 35 | return fflush_all(); |
26 | } | 36 | } |