Kernel/LibC: add basic dup2
This commit is contained in:
@@ -40,6 +40,7 @@ __BEGIN_DECLS
|
||||
#define SYS_SET_PWD 33
|
||||
#define SYS_CLOCK_GETTIME 34
|
||||
#define SYS_PIPE 35
|
||||
#define SYS_DUP2 36
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
||||
@@ -257,6 +257,13 @@ long syscall(long syscall, ...)
|
||||
ret = Kernel::syscall(SYS_PIPE, (uintptr_t)fildes);
|
||||
break;
|
||||
}
|
||||
case SYS_DUP2:
|
||||
{
|
||||
int fildes = va_arg(args, int);
|
||||
int fildes2 = va_arg(args, int);
|
||||
ret = Kernel::syscall(SYS_DUP2, fildes, fildes2);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
puts("LibC: Unhandeled syscall");
|
||||
ret = -ENOSYS;
|
||||
@@ -289,6 +296,11 @@ ssize_t write(int fildes, const void* buf, size_t nbyte)
|
||||
return syscall(SYS_WRITE, fildes, buf, nbyte);
|
||||
}
|
||||
|
||||
int dup2(int fildes, int fildes2)
|
||||
{
|
||||
return syscall(SYS_DUP2, fildes, fildes2);
|
||||
}
|
||||
|
||||
int execl(const char* pathname, const char* arg0, ...)
|
||||
{
|
||||
if (arg0 == nullptr)
|
||||
|
||||
Reference in New Issue
Block a user