kernel: fork syscall

This commit is contained in:
Matheus
2023-05-16 19:42:18 -03:00
parent 0f95ff18f0
commit 0afbff3881
3 changed files with 80 additions and 6 deletions
+12 -4
View File
@@ -133,10 +133,10 @@ index 0000000..e5b087a
+
diff --git mlibc-workdir/sysdeps/astral/generic/generic.cpp mlibc-workdir/sysdeps/astral/generic/generic.cpp
new file mode 100644
index 0000000..dc6bd0e
index 0000000..3961e7f
--- /dev/null
+++ mlibc-workdir/sysdeps/astral/generic/generic.cpp
@@ -0,0 +1,178 @@
@@ -0,0 +1,185 @@
+#include <bits/ensure.h>
+#include <mlibc/debug.hpp>
+#include <mlibc/all-sysdeps.hpp>
@@ -200,6 +200,13 @@ index 0000000..dc6bd0e
+ return 0;
+ }
+
+ int sys_fork(pid_t *pid) {
+ long ret = 0;
+ long error = syscall(SYSCALL_FORK, &ret);
+ *pid = ret;
+ return error;
+ }
+
+ int sys_stat(fsfd_target fsfdt, int fd, const char *path, int flags, struct stat *statbuf) {
+ long ret;
+ switch (fsfdt) {
@@ -334,10 +341,10 @@ index 0000000..990eca0
+#endif
diff --git mlibc-workdir/sysdeps/astral/include/astral/syscall.h mlibc-workdir/sysdeps/astral/include/astral/syscall.h
new file mode 100644
index 0000000..fde482a
index 0000000..16c462d
--- /dev/null
+++ mlibc-workdir/sysdeps/astral/include/astral/syscall.h
@@ -0,0 +1,34 @@
@@ -0,0 +1,35 @@
+#ifndef _SYSCALL_H_INCLUDE
+#define _SYSCALL_H_INCLUDE
+
@@ -352,6 +359,7 @@ index 0000000..fde482a
+#define SYSCALL_GETPID 8
+#define SYSCALL_FSTAT 9
+#define SYSCALL_FSTATAT 10
+#define SYSCALL_FORK 11
+
+#include <stddef.h>
+#include <stdint.h>