summaryrefslogtreecommitdiff
path: root/userland
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2024-11-22 22:33:06 +0100
committerAnton Kling <anton@kling.gg>2024-11-22 22:33:06 +0100
commit8fa2af9678b9e257a1dfb1e5111f35d22366f2c6 (patch)
treed82d3b9678b2fcfdc901455f4ca2ed13dc49aaa7 /userland
parent8827f3033d76b0d9c7d8d8225077176a813f7f49 (diff)
vfs: Add dup()
Diffstat (limited to 'userland')
-rw-r--r--userland/libc/include/syscall.h1
-rw-r--r--userland/libc/include/unistd.h1
-rw-r--r--userland/libc/unistd/dup.c6
3 files changed, 8 insertions, 0 deletions
diff --git a/userland/libc/include/syscall.h b/userland/libc/include/syscall.h
index a0303f4..95ab817 100644
--- a/userland/libc/include/syscall.h
+++ b/userland/libc/include/syscall.h
@@ -53,6 +53,7 @@
#define SYS_QUEUE_WAIT 45
#define SYS_SENDFILE 46
#define SYS_SHM_UNLINK 47
+#define SYS_DUP 48
int syscall(uint32_t eax, uint32_t ebx, uint32_t ecx, uint32_t edx,
uint32_t esi, uint32_t edi);
diff --git a/userland/libc/include/unistd.h b/userland/libc/include/unistd.h
index b44ca3e..3f17df4 100644
--- a/userland/libc/include/unistd.h
+++ b/userland/libc/include/unistd.h
@@ -15,6 +15,7 @@ int close(int fildes);
int ftruncate(int fildes, size_t length);
int execv(char *path, char **argv);
int pipe(int fd[2]);
+int dup(int fildes);
int dup2(int org_fd, int new_fd);
int getopt(int argc, char *const argv[], const char *optstring);
pid_t getpid(void);
diff --git a/userland/libc/unistd/dup.c b/userland/libc/unistd/dup.c
new file mode 100644
index 0000000..176659b
--- /dev/null
+++ b/userland/libc/unistd/dup.c
@@ -0,0 +1,6 @@
+#include <syscall.h>
+#include <unistd.h>
+
+int dup(int fildes) {
+ RC_ERRNO(syscall(SYS_DUP, (u32)fildes, 0, 0, 0, 0));
+}