mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-30 00:08:30 +00:00
Add /dev/(u)random on NT (#1163)
This commit is contained in:
parent
8f6bc9dabc
commit
b6e40a3a58
17 changed files with 97 additions and 22 deletions
|
@ -159,6 +159,15 @@ static textwindows int sys_open_nt_special(int fd, int flags, int mode,
|
|||
return fd;
|
||||
}
|
||||
|
||||
static textwindows int sys_open_nt_no_handle(int fd, int flags, int mode,
|
||||
int kind) {
|
||||
g_fds.p[fd].kind = kind;
|
||||
g_fds.p[fd].mode = mode;
|
||||
g_fds.p[fd].flags = flags;
|
||||
g_fds.p[fd].handle = -1;
|
||||
return fd;
|
||||
}
|
||||
|
||||
static textwindows int sys_open_nt_dup(int fd, int flags, int mode, int oldfd) {
|
||||
int64_t handle;
|
||||
if (!__isfdopen(oldfd)) {
|
||||
|
@ -211,6 +220,8 @@ textwindows int sys_open_nt(int dirfd, const char *file, uint32_t flags,
|
|||
rc = sys_open_nt_special(fd, flags, mode, kFdConsole, u"CONIN$");
|
||||
} else if (!strcmp(file + 5, "null")) {
|
||||
rc = sys_open_nt_special(fd, flags, mode, kFdDevNull, u"NUL");
|
||||
} else if (!strcmp(file + 5, "urandom") || !strcmp(file + 5, "random")) {
|
||||
rc = sys_open_nt_no_handle(fd, flags, mode, kFdDevRandom);
|
||||
} else if (!strcmp(file + 5, "stdin")) {
|
||||
rc = sys_open_nt_dup(fd, flags, mode, STDIN_FILENO);
|
||||
} else if (!strcmp(file + 5, "stdout")) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue