diff options
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/Config.src | 3 | ||||
-rw-r--r-- | coreutils/cp.c | 5 | ||||
-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/libcoreutils/cp_mv_stat.c | 5 | ||||
-rw-r--r-- | coreutils/ls.c | 9 | ||||
-rw-r--r-- | coreutils/od_bloaty.c | 7 | ||||
-rw-r--r-- | coreutils/test.c | 27 | ||||
-rw-r--r-- | coreutils/uname.c | 8 | ||||
-rw-r--r-- | coreutils/whoami.c | 10 |
11 files changed, 104 insertions, 5 deletions
diff --git a/coreutils/Config.src b/coreutils/Config.src index 1843e8b0e..2769aa07d 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/cp.c b/coreutils/cp.c index 337054d7b..c35dc2872 100644 --- a/coreutils/cp.c +++ b/coreutils/cp.c | |||
@@ -149,8 +149,13 @@ int cp_main(int argc, char **argv) | |||
149 | last = argv[argc - 1]; | 149 | last = argv[argc - 1]; |
150 | /* If there are only two arguments and... */ | 150 | /* If there are only two arguments and... */ |
151 | if (argc == 2) { | 151 | if (argc == 2) { |
152 | #if ENABLE_PLATFORM_MINGW32 | ||
153 | /* stat can't be aliased, and MinGW uses lstat anyway */ | ||
154 | s_flags = cp_mv_stat2(*argv, &source_stat, lstat); | ||
155 | #else | ||
152 | s_flags = cp_mv_stat2(*argv, &source_stat, | 156 | s_flags = cp_mv_stat2(*argv, &source_stat, |
153 | (flags & FILEUTILS_DEREFERENCE) ? stat : lstat); | 157 | (flags & FILEUTILS_DEREFERENCE) ? stat : lstat); |
158 | #endif | ||
154 | if (s_flags < 0) | 159 | if (s_flags < 0) |
155 | return EXIT_FAILURE; | 160 | return EXIT_FAILURE; |
156 | d_flags = cp_mv_stat(last, &dest_stat); | 161 | d_flags = cp_mv_stat(last, &dest_stat); |
diff --git a/coreutils/date.c b/coreutils/date.c index db1b693aa..497031991 100644 --- a/coreutils/date.c +++ b/coreutils/date.c | |||
@@ -291,9 +291,14 @@ int date_main(int argc UNUSED_PARAM, char **argv) | |||
291 | maybe_set_utc(opt); | 291 | maybe_set_utc(opt); |
292 | 292 | ||
293 | /* if setting time, set it */ | 293 | /* if setting time, set it */ |
294 | #if ENABLE_PLATFORM_MINGW32 | ||
295 | if (opt & OPT_SET) | ||
296 | bb_error_msg_and_die("Setting date is not supported"); | ||
297 | #else | ||
294 | if ((opt & OPT_SET) && stime(&ts.tv_sec) < 0) { | 298 | if ((opt & OPT_SET) && stime(&ts.tv_sec) < 0) { |
295 | bb_perror_msg("can't set date"); | 299 | bb_perror_msg("can't set date"); |
296 | } | 300 | } |
301 | #endif | ||
297 | } | 302 | } |
298 | 303 | ||
299 | /* Display output */ | 304 | /* Display output */ |
@@ -321,7 +326,11 @@ int date_main(int argc UNUSED_PARAM, char **argv) | |||
321 | i = sizeof("%a, %d %b %Y %H:%M:%S ")-1; | 326 | i = sizeof("%a, %d %b %Y %H:%M:%S ")-1; |
322 | goto format_utc; | 327 | goto format_utc; |
323 | } else { /* default case */ | 328 | } else { /* default case */ |
329 | #if ENABLE_PLATFORM_MINGW32 | ||
330 | fmt_dt2str = (char*)"%a %b %d %H:%M:%S %Z %Y"; | ||
331 | #else | ||
324 | fmt_dt2str = (char*)"%a %b %e %H:%M:%S %Z %Y"; | 332 | fmt_dt2str = (char*)"%a %b %e %H:%M:%S %Z %Y"; |
333 | #endif | ||
325 | } | 334 | } |
326 | } | 335 | } |
327 | #if ENABLE_FEATURE_DATE_NANO | 336 | #if ENABLE_FEATURE_DATE_NANO |
@@ -374,6 +383,10 @@ int date_main(int argc UNUSED_PARAM, char **argv) | |||
374 | if (strncmp(fmt_dt2str, "%f", 2) == 0) { | 383 | if (strncmp(fmt_dt2str, "%f", 2) == 0) { |
375 | fmt_dt2str = (char*)"%Y.%m.%d-%H:%M:%S"; | 384 | fmt_dt2str = (char*)"%Y.%m.%d-%H:%M:%S"; |
376 | } | 385 | } |
386 | #if ENABLE_PLATFORM_MINGW32 | ||
387 | if (strstr(fmt_dt2str, "%e")) | ||
388 | bb_error_msg_and_die("%%e is not supported by Windows strftime"); | ||
389 | #endif | ||
377 | /* Generate output string */ | 390 | /* Generate output string */ |
378 | strftime(date_buf, sizeof(date_buf), fmt_dt2str, &tm_time); | 391 | strftime(date_buf, sizeof(date_buf), fmt_dt2str, &tm_time); |
379 | } | 392 | } |
diff --git a/coreutils/dd.c b/coreutils/dd.c index 8a2eaed72..e4b53c0af 100644 --- a/coreutils/dd.c +++ b/coreutils/dd.c | |||
@@ -201,6 +201,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv) | |||
201 | #endif | 201 | #endif |
202 | }; | 202 | }; |
203 | int exitcode = EXIT_FAILURE; | 203 | int exitcode = EXIT_FAILURE; |
204 | int devzero = 0; | ||
204 | size_t ibs = 512, obs = 512; | 205 | size_t ibs = 512, obs = 512; |
205 | ssize_t n, w; | 206 | ssize_t n, w; |
206 | char *ibuf, *obuf; | 207 | char *ibuf, *obuf; |
@@ -318,7 +319,12 @@ int dd_main(int argc UNUSED_PARAM, char **argv) | |||
318 | #endif | 319 | #endif |
319 | 320 | ||
320 | if (infile != NULL) | 321 | if (infile != NULL) |
321 | xmove_fd(xopen(infile, O_RDONLY), ifd); | 322 | if (ENABLE_PLATFORM_MINGW32 && !strcmp(infile, "/dev/zero")) { |
323 | flags |= FLAG_NOERROR; | ||
324 | devzero = 1; | ||
325 | } | ||
326 | else | ||
327 | xmove_fd(xopen(infile, O_RDONLY), ifd); | ||
322 | else { | 328 | else { |
323 | infile = bb_msg_standard_input; | 329 | infile = bb_msg_standard_input; |
324 | } | 330 | } |
@@ -345,7 +351,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv) | |||
345 | } else { | 351 | } else { |
346 | outfile = bb_msg_standard_output; | 352 | outfile = bb_msg_standard_output; |
347 | } | 353 | } |
348 | if (skip) { | 354 | if (skip && !devzero) { |
349 | if (lseek(ifd, skip * ibs, SEEK_CUR) < 0) { | 355 | if (lseek(ifd, skip * ibs, SEEK_CUR) < 0) { |
350 | while (skip-- > 0) { | 356 | while (skip-- > 0) { |
351 | n = safe_read(ifd, ibuf, ibs); | 357 | n = safe_read(ifd, ibuf, ibs); |
@@ -362,7 +368,12 @@ int dd_main(int argc UNUSED_PARAM, char **argv) | |||
362 | } | 368 | } |
363 | 369 | ||
364 | while (!(flags & FLAG_COUNT) || (G.in_full + G.in_part != count)) { | 370 | while (!(flags & FLAG_COUNT) || (G.in_full + G.in_part != count)) { |
365 | n = safe_read(ifd, ibuf, ibs); | 371 | if (devzero) { |
372 | memset(ibuf, 0, ibs); | ||
373 | n = ibs; | ||
374 | } | ||
375 | else | ||
376 | n = safe_read(ifd, ibuf, ibs); | ||
366 | if (n == 0) | 377 | if (n == 0) |
367 | break; | 378 | break; |
368 | if (n < 0) { | 379 | if (n < 0) { |
@@ -416,7 +427,8 @@ int dd_main(int argc UNUSED_PARAM, char **argv) | |||
416 | if (w < 0) goto out_status; | 427 | if (w < 0) goto out_status; |
417 | if (w > 0) G.out_part++; | 428 | if (w > 0) G.out_part++; |
418 | } | 429 | } |
419 | if (close(ifd) < 0) { | 430 | |
431 | if (!devzero && close(ifd) < 0) { | ||
420 | die_infile: | 432 | die_infile: |
421 | bb_simple_perror_msg_and_die(infile); | 433 | bb_simple_perror_msg_and_die(infile); |
422 | } | 434 | } |
diff --git a/coreutils/dos2unix.c b/coreutils/dos2unix.c index df2376bea..add1da666 100644 --- a/coreutils/dos2unix.c +++ b/coreutils/dos2unix.c | |||
@@ -60,7 +60,7 @@ static void convert(char *fn, int conv_type) | |||
60 | 60 | ||
61 | temp_fn = xasprintf("%sXXXXXX", resolved_fn); | 61 | temp_fn = xasprintf("%sXXXXXX", resolved_fn); |
62 | i = xmkstemp(temp_fn); | 62 | i = xmkstemp(temp_fn); |
63 | if (fchmod(i, st.st_mode) == -1) | 63 | if (!ENABLE_PLATFORM_MINGW32 && fchmod(i, st.st_mode) == -1) |
64 | bb_simple_perror_msg_and_die(temp_fn); | 64 | bb_simple_perror_msg_and_die(temp_fn); |
65 | 65 | ||
66 | out = xfdopen_for_write(i); | 66 | out = xfdopen_for_write(i); |
diff --git a/coreutils/libcoreutils/cp_mv_stat.c b/coreutils/libcoreutils/cp_mv_stat.c index 5ba07ecc3..1af2ebb71 100644 --- a/coreutils/libcoreutils/cp_mv_stat.c +++ b/coreutils/libcoreutils/cp_mv_stat.c | |||
@@ -46,5 +46,10 @@ int FAST_FUNC cp_mv_stat2(const char *fn, struct stat *fn_stat, stat_func sf) | |||
46 | 46 | ||
47 | int FAST_FUNC cp_mv_stat(const char *fn, struct stat *fn_stat) | 47 | int FAST_FUNC cp_mv_stat(const char *fn, struct stat *fn_stat) |
48 | { | 48 | { |
49 | #if ENABLE_PLATFORM_MINGW32 | ||
50 | /* stat can't be aliased, and MinGW uses lstat anyway */ | ||
51 | return cp_mv_stat2(fn, fn_stat, lstat); | ||
52 | #else | ||
49 | return cp_mv_stat2(fn, fn_stat, stat); | 53 | return cp_mv_stat2(fn, fn_stat, stat); |
54 | #endif | ||
50 | } | 55 | } |
diff --git a/coreutils/ls.c b/coreutils/ls.c index 217321933..09b9f101a 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c | |||
@@ -684,7 +684,12 @@ static NOINLINE unsigned list_single(const struct dnode *dn) | |||
684 | column += printf("%7llu ", (long long) dn->dstat.st_ino); | 684 | column += printf("%7llu ", (long long) dn->dstat.st_ino); |
685 | //TODO: -h should affect -s too: | 685 | //TODO: -h should affect -s too: |
686 | if (all_fmt & LIST_BLOCKS) | 686 | if (all_fmt & LIST_BLOCKS) |
687 | #if ENABLE_PLATFORM_MINGW32 | ||
688 | /* MinGW does not have st_blocks */ | ||
689 | column += printf("%6"OFF_FMT"u ", (off_t)0); | ||
690 | #else | ||
687 | column += printf("%6"OFF_FMT"u ", (off_t) (dn->dstat.st_blocks >> 1)); | 691 | column += printf("%6"OFF_FMT"u ", (off_t) (dn->dstat.st_blocks >> 1)); |
692 | #endif | ||
688 | if (all_fmt & LIST_MODEBITS) | 693 | if (all_fmt & LIST_MODEBITS) |
689 | column += printf("%-10s ", (char *) bb_mode_string(dn->dstat.st_mode)); | 694 | column += printf("%-10s ", (char *) bb_mode_string(dn->dstat.st_mode)); |
690 | if (all_fmt & LIST_NLINKS) | 695 | if (all_fmt & LIST_NLINKS) |
@@ -867,6 +872,7 @@ static void showfiles(struct dnode **dn, unsigned nfiles) | |||
867 | } | 872 | } |
868 | 873 | ||
869 | 874 | ||
875 | #if !ENABLE_PLATFORM_MINGW32 | ||
870 | #if ENABLE_DESKTOP | 876 | #if ENABLE_DESKTOP |
871 | /* http://www.opengroup.org/onlinepubs/9699919799/utilities/ls.html | 877 | /* http://www.opengroup.org/onlinepubs/9699919799/utilities/ls.html |
872 | * If any of the -l, -n, -s options is specified, each list | 878 | * If any of the -l, -n, -s options is specified, each list |
@@ -895,6 +901,7 @@ static off_t calculate_blocks(struct dnode **dn) | |||
895 | return blocks >> 1; | 901 | return blocks >> 1; |
896 | } | 902 | } |
897 | #endif | 903 | #endif |
904 | #endif | ||
898 | 905 | ||
899 | 906 | ||
900 | static struct dnode **list_dir(const char *, unsigned *); | 907 | static struct dnode **list_dir(const char *, unsigned *); |
@@ -914,10 +921,12 @@ static void showdirs(struct dnode **dn, int first) | |||
914 | printf("%s:\n", (*dn)->fullname); | 921 | printf("%s:\n", (*dn)->fullname); |
915 | } | 922 | } |
916 | subdnp = list_dir((*dn)->fullname, &nfiles); | 923 | subdnp = list_dir((*dn)->fullname, &nfiles); |
924 | #if !ENABLE_PLATFORM_MINGW32 | ||
917 | #if ENABLE_DESKTOP | 925 | #if ENABLE_DESKTOP |
918 | if ((all_fmt & STYLE_MASK) == STYLE_LONG) | 926 | if ((all_fmt & STYLE_MASK) == STYLE_LONG) |
919 | printf("total %"OFF_FMT"u\n", calculate_blocks(subdnp)); | 927 | printf("total %"OFF_FMT"u\n", calculate_blocks(subdnp)); |
920 | #endif | 928 | #endif |
929 | #endif | ||
921 | if (nfiles > 0) { | 930 | if (nfiles > 0) { |
922 | /* list all files at this level */ | 931 | /* list all files at this level */ |
923 | dnsort(subdnp, nfiles); | 932 | 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 1f5398ad8..2e896f4c7 100644 --- a/coreutils/test.c +++ b/coreutils/test.c | |||
@@ -642,6 +642,33 @@ 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 | int len = strlen(nm), ret; | ||
652 | if (len >= 4 && | ||
653 | (!strcmp(nm+len-4,".exe") || | ||
654 | !strcmp(nm+len-4,".com"))) | ||
655 | ret = stat(nm, &s); | ||
656 | else { | ||
657 | char *exepath; | ||
658 | exepath = malloc(len+5); | ||
659 | memcpy(exepath, nm, len); | ||
660 | memcpy(exepath+len, ".exe", 5); | ||
661 | ret = stat(exepath, &s); | ||
662 | if (ret < 0) { | ||
663 | memcpy(exepath+len, ".exe", 5); | ||
664 | ret = stat(exepath, &s); | ||
665 | } | ||
666 | free(exepath); | ||
667 | } | ||
668 | return ret >= 0; | ||
669 | } | ||
670 | #endif | ||
671 | |||
645 | if (stat(nm, &s) != 0) | 672 | if (stat(nm, &s) != 0) |
646 | return 0; | 673 | return 0; |
647 | if (mode == FILEXIST) | 674 | if (mode == FILEXIST) |
diff --git a/coreutils/uname.c b/coreutils/uname.c index 7a86b32a6..775c450df 100644 --- a/coreutils/uname.c +++ b/coreutils/uname.c | |||
@@ -73,7 +73,11 @@ typedef struct { | |||
73 | struct utsname name; | 73 | struct utsname name; |
74 | char processor[sizeof(((struct utsname*)NULL)->machine)]; | 74 | char processor[sizeof(((struct utsname*)NULL)->machine)]; |
75 | char platform[sizeof(((struct utsname*)NULL)->machine)]; | 75 | char platform[sizeof(((struct utsname*)NULL)->machine)]; |
76 | #if ENABLE_PLATFORM_MINGW32 | ||
77 | char os[sizeof("MS/Windows")]; | ||
78 | #else | ||
76 | char os[sizeof("GNU/Linux")]; | 79 | char os[sizeof("GNU/Linux")]; |
80 | #endif | ||
77 | } uname_info_t; | 81 | } uname_info_t; |
78 | 82 | ||
79 | static const char options[] ALIGN1 = "snrvmpioa"; | 83 | static const char options[] ALIGN1 = "snrvmpioa"; |
@@ -140,7 +144,11 @@ int uname_main(int argc UNUSED_PARAM, char **argv) | |||
140 | #endif | 144 | #endif |
141 | strcpy(uname_info.processor, unknown_str); | 145 | strcpy(uname_info.processor, unknown_str); |
142 | strcpy(uname_info.platform, unknown_str); | 146 | strcpy(uname_info.platform, unknown_str); |
147 | #if ENABLE_PLATFORM_MINGW32 | ||
148 | strcpy(uname_info.os, "MS/Windows"); | ||
149 | #else | ||
143 | strcpy(uname_info.os, "GNU/Linux"); | 150 | strcpy(uname_info.os, "GNU/Linux"); |
151 | #endif | ||
144 | #if 0 | 152 | #if 0 |
145 | /* Fedora does something like this */ | 153 | /* Fedora does something like this */ |
146 | strcpy(uname_info.processor, uname_info.name.machine); | 154 | strcpy(uname_info.processor, uname_info.name.machine); |
diff --git a/coreutils/whoami.c b/coreutils/whoami.c index 30b17cab3..500e07166 100644 --- a/coreutils/whoami.c +++ b/coreutils/whoami.c | |||
@@ -21,11 +21,21 @@ | |||
21 | int whoami_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 21 | int whoami_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
22 | int whoami_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | 22 | int whoami_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) |
23 | { | 23 | { |
24 | #if ENABLE_PLATFORM_MINGW32 | ||
25 | char buf[64]; | ||
26 | DWORD len = 64; | ||
27 | #endif | ||
28 | |||
24 | if (argv[1]) | 29 | if (argv[1]) |
25 | bb_show_usage(); | 30 | bb_show_usage(); |
26 | 31 | ||
32 | #if ENABLE_PLATFORM_MINGW32 | ||
33 | GetUserName(buf, &len); | ||
34 | puts(buf); | ||
35 | #else | ||
27 | /* Will complain and die if username not found */ | 36 | /* Will complain and die if username not found */ |
28 | puts(xuid2uname(geteuid())); | 37 | puts(xuid2uname(geteuid())); |
38 | #endif | ||
29 | 39 | ||
30 | return fflush_all(); | 40 | return fflush_all(); |
31 | } | 41 | } |