Skip to content

Commit

Permalink
Get rid of redundant sys$spawn now that we have fork+exec.
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed Nov 9, 2018
1 parent 3e0a0dd commit 8249c08
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 71 deletions.
40 changes: 0 additions & 40 deletions Kernel/Process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,46 +450,6 @@ int Process::sys$execve(const char* filename, const char** argv, const char** en
return rc;
}

pid_t Process::sys$spawn(const char* filename, const char** argv, const char** envp)
{
VALIDATE_USER_READ(filename, strlen(filename));
if (argv) {
for (size_t i = 0; argv[i]; ++i) {
VALIDATE_USER_READ(argv[i], strlen(argv[i]));
}
}
if (envp) {
for (size_t i = 0; envp[i]; ++i) {
VALIDATE_USER_READ(envp[i], strlen(envp[i]));
}
}

String path(filename);
auto parts = path.split('/');

Vector<String> arguments;
if (argv) {
for (size_t i = 0; argv[i]; ++i) {
arguments.append(argv[i]);
}
} else {
arguments.append(parts.last());
}

Vector<String> environment;
if (envp) {
for (size_t i = 0; envp[i]; ++i) {
environment.append(envp[i]);
}
}

int error;
auto* child = create_user_process(path, m_uid, m_gid, m_pid, error, move(arguments), move(environment), m_tty);
if (child)
return child->pid();
return error;
}

Process* Process::create_user_process(const String& path, uid_t uid, gid_t gid, pid_t parent_pid, int& error, Vector<String>&& arguments, Vector<String>&& environment, TTY* tty)
{
// FIXME: Don't split() the path twice (sys$spawn also does it...)
Expand Down
1 change: 0 additions & 1 deletion Kernel/Process.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ class Process : public InlineLinkedListNode<Process> {
int sys$geterror() { return m_error; }
void sys$exit(int status) NORETURN;
void sys$sigreturn() NORETURN;
pid_t sys$spawn(const char* path, const char** args, const char** envp);
pid_t sys$waitpid(pid_t, int* wstatus, int options);
void* sys$mmap(const Syscall::SC_mmap_params*);
int sys$munmap(void*, size_t size);
Expand Down
2 changes: 0 additions & 2 deletions Kernel/Syscall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ static DWORD handle(RegisterDump& regs, DWORD function, DWORD arg1, DWORD arg2,
return current->sys$sleep((unsigned)arg1);
case Syscall::SC_gettimeofday:
return current->sys$gettimeofday((timeval*)arg1);
case Syscall::SC_spawn:
return current->sys$spawn((const char*)arg1, (const char**)arg2, (const char**)arg3);
case Syscall::SC_get_dir_entries:
return current->sys$get_dir_entries((int)arg1, (void*)arg2, (size_t)arg3);
case Syscall::SC_lstat:
Expand Down
1 change: 0 additions & 1 deletion Kernel/Syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <AK/Types.h>

#define ENUMERATE_SYSCALLS \
__ENUMERATE_SYSCALL(spawn) \
__ENUMERATE_SYSCALL(sleep) \
__ENUMERATE_SYSCALL(yield) \
__ENUMERATE_SYSCALL(putch) \
Expand Down
1 change: 0 additions & 1 deletion LibC/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ LIBC_OBJS = \
stdio.o \
unistd.o \
string.o \
process.o \
mman.o \
dirent.o \
stdlib.o \
Expand Down
14 changes: 0 additions & 14 deletions LibC/process.cpp

This file was deleted.

11 changes: 0 additions & 11 deletions LibC/process.h

This file was deleted.

1 change: 0 additions & 1 deletion Userland/sh.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include <stdio.h>
#include <unistd.h>
#include <process.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
Expand Down

0 comments on commit 8249c08

Please sign in to comment.