Kernel/LibC: add basic dup2

This commit is contained in:
Bananymous
2023-07-06 23:17:54 +03:00
parent 4cd72992c8
commit 07fec6e211
5 changed files with 52 additions and 2 deletions

View File

@@ -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

View File

@@ -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)