implement dup syscall

This commit is contained in:
Florian Fischer
2024-01-03 12:24:49 +01:00
parent 7b6076b612
commit 2d8350f732
9 changed files with 155 additions and 2 deletions
+1
View File
@@ -5,6 +5,7 @@
# Add the library.
add_library(
libc
${CMAKE_SOURCE_DIR}/libc/src/unistd/dup.c
${CMAKE_SOURCE_DIR}/libc/src/stdio.c
${CMAKE_SOURCE_DIR}/libc/src/ctype.c
${CMAKE_SOURCE_DIR}/libc/src/string.c
+6
View File
@@ -253,6 +253,12 @@ int fchdir(int fd);
/// appropriately.
ssize_t getdents(int fd, dirent_t *dirp, unsigned int count);
/// @brief Return a new file descriptor
/// @param fd The fd pointing to the opened file.
/// @return On success, a new file descriptor is returned.
/// On error, -1 is returned, and errno is set appropriately.
int dup(int fd);
/// @brief Send signal to calling thread after desired seconds.
/// @param seconds the amount of seconds.
/// @return If there is a previous alarm() request with time remaining, alarm()
+10
View File
@@ -0,0 +1,10 @@
/// @file dup.c
/// @brief
/// @copyright (c) 2024 This file is distributed under the MIT License.
/// See LICENSE.md for details.
#include "sys/unistd.h"
#include "system/syscall_types.h"
#include "sys/errno.h"
_syscall1(int, dup, int, fd)