diff options
author | dzwdz | 2023-12-25 19:08:04 +0100 |
---|---|---|
committer | dzwdz | 2023-12-25 19:08:04 +0100 |
commit | b9f5f92bff69059471a76e73539780eedb356455 (patch) | |
tree | 55302764cbc2a6ab159cf2621dc34aab04ca4085 /src/libc | |
parent | 4e1a6f1b3c543b9fbeb882a9e97551f7c58ca65a (diff) |
kernel: _sys_getnull() (basically /dev/null)
Diffstat (limited to 'src/libc')
-rw-r--r-- | src/libc/socket.c | 9 | ||||
-rw-r--r-- | src/libc/syscall.c | 4 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/libc/socket.c b/src/libc/socket.c index a8871a3..5ea7266 100644 --- a/src/libc/socket.c +++ b/src/libc/socket.c @@ -1,5 +1,6 @@ #include <arpa/inet.h> #include <camellia.h> +#include <camellia/syscalls.h> #include <errno.h> #include <netdb.h> #include <netinet/in.h> @@ -10,8 +11,12 @@ int socket(int domain, int type, int protocol) { if (domain != AF_INET || type != SOCK_STREAM || protocol != IPPROTO_TCP) { return errno = ENOSYS, -1; } - // TODO! /dev/null - return dup(1); // yolo + int h = _sys_getnull(0); + if (h < 0) { + return errno = -h, -1; + } else { + return h; + } } int bind(int, const struct sockaddr *, socklen_t) { diff --git a/src/libc/syscall.c b/src/libc/syscall.c index 8142028..f44c775 100644 --- a/src/libc/syscall.c +++ b/src/libc/syscall.c @@ -94,6 +94,10 @@ uint64_t _sys_time(int flags) { return (uint64_t)_syscall(_SYS_TIME, (long)flags, 0, 0, 0, 0); } +hid_t _sys_getnull(int flags) { + return (hid_t)_syscall(_SYS_GETNULL, (long)flags, 0, 0, 0, 0); +} + long _sys_execbuf(void __user *buf, size_t len) { return _syscall(_SYS_EXECBUF, (long)buf, (long)len, 0, 0, 0); } |