aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2021-01-25 13:57:08 +0000
committerRon Yorston <rmy@pobox.com>2021-01-25 14:15:02 +0000
commiteb0c2bbbaf0722103124a589e3dfe952c2664cbb (patch)
tree3ae3ec89bd7a6041ed5aed1d537f6b2fb3586ed7 /coreutils
parent6422b0ef38d0835c86b40e6e642f18cdfb933e85 (diff)
downloadbusybox-w32-eb0c2bbbaf0722103124a589e3dfe952c2664cbb.tar.gz
busybox-w32-eb0c2bbbaf0722103124a589e3dfe952c2664cbb.tar.bz2
busybox-w32-eb0c2bbbaf0722103124a589e3dfe952c2664cbb.zip
tls: avoid unnecessary changes to POSIX build, part 2
On reflection, the previous commit may have been ill-advised. There are many calls to open_read_close() and most shouldn't be able to access special devices. (Though in practice only a few are enabled in busybox-w32.) Nonetheless, I've implemented a new mechanism which uses the macro MINGW_SPECIAL() to mark calls to functions that are allowed to access special devices. An unrelated change is to avoid compiling fputs_stdout() in coreutils/printf.c for the POSIX build.
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/dd.c6
-rw-r--r--coreutils/printf.c2
-rw-r--r--coreutils/shred.c8
3 files changed, 6 insertions, 10 deletions
diff --git a/coreutils/dd.c b/coreutils/dd.c
index c150ef5bc..bd799aa2b 100644
--- a/coreutils/dd.c
+++ b/coreutils/dd.c
@@ -505,10 +505,8 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
505 if (G.flags & FLAG_IDIRECT) 505 if (G.flags & FLAG_IDIRECT)
506 iflag |= O_DIRECT; 506 iflag |= O_DIRECT;
507#endif 507#endif
508#if !ENABLE_PLATFORM_MINGW32 508 xmove_fd(MINGW_SPECIAL(xopen)(infile, iflag), ifd);
509 xmove_fd(xopen(infile, iflag), ifd); 509#if ENABLE_PLATFORM_MINGW32
510#else
511 xmove_fd(mingw_xopen(infile, iflag), ifd);
512 update_dev_fd(get_dev_type(infile), ifd); 510 update_dev_fd(get_dev_type(infile), ifd);
513#endif 511#endif
514 } else { 512 } else {
diff --git a/coreutils/printf.c b/coreutils/printf.c
index aabc51e0d..d1d22f39c 100644
--- a/coreutils/printf.c
+++ b/coreutils/printf.c
@@ -151,10 +151,12 @@ static double my_xstrtod(const char *arg)
151 return result; 151 return result;
152} 152}
153 153
154#if ENABLE_PLATFORM_MINGW32
154static int fputs_stdout(const char *s) 155static int fputs_stdout(const char *s)
155{ 156{
156 return fputs(s, stdout); 157 return fputs(s, stdout);
157} 158}
159#endif
158 160
159/* Handles %b; return 1 if output is to be short-circuited by \c */ 161/* Handles %b; return 1 if output is to be short-circuited by \c */
160static int print_esc_string(const char *str) 162static int print_esc_string(const char *str)
diff --git a/coreutils/shred.c b/coreutils/shred.c
index 86d4b66b4..0b11b9491 100644
--- a/coreutils/shred.c
+++ b/coreutils/shred.c
@@ -38,10 +38,6 @@
38 38
39#include "libbb.h" 39#include "libbb.h"
40 40
41#if ENABLE_PLATFORM_MINGW32
42#define xopen mingw_xopen
43#endif
44
45int shred_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 41int shred_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
46int shred_main(int argc UNUSED_PARAM, char **argv) 42int shred_main(int argc UNUSED_PARAM, char **argv)
47{ 43{
@@ -61,9 +57,9 @@ int shred_main(int argc UNUSED_PARAM, char **argv)
61 opt = getopt32(argv, "fuzn:+vx", &num_iter); 57 opt = getopt32(argv, "fuzn:+vx", &num_iter);
62 argv += optind; 58 argv += optind;
63 59
64 zero_fd = xopen("/dev/zero", O_RDONLY); 60 zero_fd = MINGW_SPECIAL(xopen)("/dev/zero", O_RDONLY);
65 if (num_iter != 0) 61 if (num_iter != 0)
66 rand_fd = xopen("/dev/urandom", O_RDONLY); 62 rand_fd = MINGW_SPECIAL(xopen)("/dev/urandom", O_RDONLY);
67 63
68 if (!*argv) 64 if (!*argv)
69 bb_show_usage(); 65 bb_show_usage();