diff options
author | Ron Yorston <rmy@pobox.com> | 2018-02-22 11:40:53 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2018-02-22 11:40:53 +0000 |
commit | 4e6d0dc9476e5cf43ff0bc5e66a54d812ddb4225 (patch) | |
tree | 03dfcab70ff58cae77db6a7ad75dfac3203765c7 /include/mingw.h | |
parent | 1efab55196bea6d93aa26ca2fb1d3d358f16452f (diff) | |
download | busybox-w32-4e6d0dc9476e5cf43ff0bc5e66a54d812ddb4225.tar.gz busybox-w32-4e6d0dc9476e5cf43ff0bc5e66a54d812ddb4225.tar.bz2 busybox-w32-4e6d0dc9476e5cf43ff0bc5e66a54d812ddb4225.zip |
win32: handle /dev/zero and /dev/urandom in open and read functions
Currently /dev/zero is handled as a special case in dd. Add hacks
to the open and read functions in mingw.c to handle the zero and
urandom devices.
- Opening /dev/zero or /dev/urandom actually opens the special
Windows file 'nul' which behaves like /dev/null. This allows
manipulation of the file descriptor with things like seek and
close
- When /dev/zero or /dev/urandom is opened the resulting file
descriptor is stored and used to override the behaviour of read.
- No attempt is made to track duplicated file descriptors, so using
these devices for redirections in the shell isn't going to work
and won't be permitted. (Could be, but won't.)
- Limited control of the special file descriptors is provided by
allowing the internal variables to be changed.
- The numbers from /dev/urandom aren't very random.
Diffstat (limited to 'include/mingw.h')
-rw-r--r-- | include/mingw.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/mingw.h b/include/mingw.h index a59ce6fc4..46be4dc23 100644 --- a/include/mingw.h +++ b/include/mingw.h | |||
@@ -395,6 +395,10 @@ int kill(pid_t pid, int sig); | |||
395 | int link(const char *oldpath, const char *newpath); | 395 | int link(const char *oldpath, const char *newpath); |
396 | NOIMPL(mknod,const char *name UNUSED_PARAM, mode_t mode UNUSED_PARAM, dev_t device UNUSED_PARAM); | 396 | NOIMPL(mknod,const char *name UNUSED_PARAM, mode_t mode UNUSED_PARAM, dev_t device UNUSED_PARAM); |
397 | int mingw_open (const char *filename, int oflags, ...); | 397 | int mingw_open (const char *filename, int oflags, ...); |
398 | void mingw_read_zero(int fd); | ||
399 | void mingw_read_random(int fd); | ||
400 | ssize_t mingw_read(int fd, void *buf, size_t count); | ||
401 | int mingw_close(int fd); | ||
398 | int pipe(int filedes[2]); | 402 | int pipe(int filedes[2]); |
399 | NOIMPL(readlink,const char *path UNUSED_PARAM, char *buf UNUSED_PARAM, size_t bufsiz UNUSED_PARAM); | 403 | NOIMPL(readlink,const char *path UNUSED_PARAM, char *buf UNUSED_PARAM, size_t bufsiz UNUSED_PARAM); |
400 | NOIMPL(setgid,gid_t gid UNUSED_PARAM); | 404 | NOIMPL(setgid,gid_t gid UNUSED_PARAM); |
@@ -418,6 +422,7 @@ int mingw_isatty(int fd); | |||
418 | #define getcwd mingw_getcwd | 422 | #define getcwd mingw_getcwd |
419 | #define lchown chown | 423 | #define lchown chown |
420 | #define open mingw_open | 424 | #define open mingw_open |
425 | #define close mingw_close | ||
421 | #define unlink mingw_unlink | 426 | #define unlink mingw_unlink |
422 | #define rmdir mingw_rmdir | 427 | #define rmdir mingw_rmdir |
423 | #undef lseek | 428 | #undef lseek |