mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-07 19:34:56 +00:00
Noux: add dup() to libc_noux
This library function is implemented upon SYSCALL_DUP2. Therfor the syscall was slightly changed. It now returns the new allocated fd in dup2_out.fd.
This commit is contained in:
parent
7a619b9ede
commit
ac3a362fdf
@ -423,7 +423,7 @@ namespace Noux {
|
||||
{ int pid; int status; });
|
||||
SYSIO_DECL(pipe, { }, { int fd[2]; });
|
||||
|
||||
SYSIO_DECL(dup2, { int fd; int to_fd; }, { });
|
||||
SYSIO_DECL(dup2, { int fd; int to_fd; }, { int fd; });
|
||||
|
||||
SYSIO_DECL(unlink, { Path path; }, { });
|
||||
|
||||
|
@ -176,6 +176,20 @@ extern "C" uid_t geteuid()
|
||||
}
|
||||
|
||||
|
||||
extern "C" int dup(int ofd)
|
||||
{
|
||||
sysio()->dup2_in.fd = ofd;
|
||||
sysio()->dup2_in.to_fd = -1;
|
||||
|
||||
if (!noux()->syscall(Noux::Session::SYSCALL_DUP2)) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return sysio()->dup2_out.fd;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Utility to copy-out syscall results to buf struct
|
||||
*
|
||||
|
@ -549,8 +549,11 @@ bool Noux::Child::syscall(Noux::Session::Syscall sc)
|
||||
|
||||
case SYSCALL_DUP2:
|
||||
{
|
||||
add_io_channel(io_channel_by_fd(_sysio->dup2_in.fd),
|
||||
_sysio->dup2_in.to_fd);
|
||||
int fd = add_io_channel(io_channel_by_fd(_sysio->dup2_in.fd),
|
||||
_sysio->dup2_in.to_fd);
|
||||
|
||||
_sysio->dup2_out.fd = fd;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user