Get rid of redundant sys$spawn now that we have fork+exec.

This commit is contained in:
Andreas Kling 2018-11-09 10:22:14 +01:00
parent 3e0a0dd7ed
commit 8249c086c3
Notes: sideshowbarker 2024-07-19 18:31:17 +09:00
8 changed files with 0 additions and 71 deletions

View file

@ -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...)

View file

@ -135,7 +135,6 @@ public:
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);

View file

@ -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:

View file

@ -3,7 +3,6 @@
#include <AK/Types.h>
#define ENUMERATE_SYSCALLS \
__ENUMERATE_SYSCALL(spawn) \
__ENUMERATE_SYSCALL(sleep) \
__ENUMERATE_SYSCALL(yield) \
__ENUMERATE_SYSCALL(putch) \

View file

@ -9,7 +9,6 @@ LIBC_OBJS = \
stdio.o \
unistd.o \
string.o \
process.o \
mman.o \
dirent.o \
stdlib.o \

View file

@ -1,14 +0,0 @@
#include "process.h"
#include "errno.h"
#include <Kernel/Syscall.h>
extern "C" {
int spawn(const char* path, const char** args, const char** envp)
{
int rc = Syscall::invoke(Syscall::SC_spawn, (dword)path, (dword)args, (dword)envp);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
}

View file

@ -1,11 +0,0 @@
#pragma once
#include <sys/cdefs.h>
#include <sys/types.h>
__BEGIN_DECLS
pid_t spawn(const char* path, const char** args, const char** envp);
__END_DECLS

View file

@ -1,6 +1,5 @@
#include <stdio.h>
#include <unistd.h>
#include <process.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>