summaryrefslogtreecommitdiff
path: root/src/libc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libc')
-rw-r--r--src/libc/socket.c9
-rw-r--r--src/libc/syscall.c4
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);
}