From eb0c2bbbaf0722103124a589e3dfe952c2664cbb Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Mon, 25 Jan 2021 13:57:08 +0000 Subject: 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. --- win32/mingw.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'win32') diff --git a/win32/mingw.c b/win32/mingw.c index ed0989be2..474d9cdc6 100644 --- a/win32/mingw.c +++ b/win32/mingw.c @@ -229,6 +229,15 @@ int mingw_xopen(const char *pathname, int flags) return ret; } +ssize_t FAST_FUNC mingw_open_read_close(const char *fn, void *buf, size_t size) +{ + /* allow use of special devices */ + int fd = mingw_open(fn, O_RDONLY|O_SPECIAL); + if (fd < 0) + return fd; + return read_close(fd, buf, size); +} + #undef fopen FILE *mingw_fopen (const char *filename, const char *otype) { -- cgit v1.2.3-55-g6feb