summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/sys/include/compat/unix/syscall.h3
-rw-r--r--src/sys/include/sys/proc.h5
-rw-r--r--src/sys/include/sys/syscall.h1
-rw-r--r--src/sys/os/os_proc.c15
4 files changed, 23 insertions, 1 deletions
diff --git a/src/sys/include/compat/unix/syscall.h b/src/sys/include/compat/unix/syscall.h
index d39f627..ab464c4 100644
--- a/src/sys/include/compat/unix/syscall.h
+++ b/src/sys/include/compat/unix/syscall.h
@@ -60,7 +60,8 @@ scret_t(*g_unix_sctab[])(struct syscall_args *) = {
[SYS_exit] = sys_exit,
[SYS_write] = sys_write,
[SYS_cross] = sys_cross,
- [SYS_query] = sys_query
+ [SYS_query] = sys_query,
+ [SYS_spawn] = sys_spawn
};
#endif /* !_NEED_UNIX_SCTAB */
diff --git a/src/sys/include/sys/proc.h b/src/sys/include/sys/proc.h
index fe45506..ea89d4c 100644
--- a/src/sys/include/sys/proc.h
+++ b/src/sys/include/sys/proc.h
@@ -207,5 +207,10 @@ __dead void md_proc_yield(void);
*/
__dead void md_proc_kick(struct proc *procp);
+/*
+ * Spawn a new process
+ */
+scret_t sys_spawn(struct syscall_args *scargs);
+
#endif /* !_KERNEL */
#endif /* !_SYS_PROC_H_ */
diff --git a/src/sys/include/sys/syscall.h b/src/sys/include/sys/syscall.h
index 215ea22..c1c06bb 100644
--- a/src/sys/include/sys/syscall.h
+++ b/src/sys/include/sys/syscall.h
@@ -48,6 +48,7 @@
#define SYS_cross 0x03 /* cross a border (mandatory) */
#define SYS_sigaction 0x04
#define SYS_query 0x05 /* query a border (mandatory) */
+#define SYS_spawn 0x06 /* spawn a process */
typedef __ssize_t scret_t;
typedef __ssize_t scarg_t;
diff --git a/src/sys/os/os_proc.c b/src/sys/os/os_proc.c
index e32e59c..14f8ceb 100644
--- a/src/sys/os/os_proc.c
+++ b/src/sys/os/os_proc.c
@@ -212,3 +212,18 @@ proc_spawn(const char *path, struct penv_blk *envbp)
sched_enq(&core->scq, proc);
return proc->pid;
}
+
+scret_t
+sys_spawn(struct syscall_args *scargs)
+{
+ const char *u_path = SCARG(scargs, const char *, 0);
+ char buf[PATH_MAX];
+ int error;
+
+ error = copyinstr(u_path, buf, sizeof(buf));
+ if (error < 0) {
+ return error;
+ }
+
+ return proc_spawn(buf, NULL);
+}