Skip to content

Commit

Permalink
syscalls: dispatch execve()
Browse files Browse the repository at this point in the history
  • Loading branch information
jewelcodes committed Sep 30, 2024
1 parent 5d96f32 commit 841c77f
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/syscalls/dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,26 @@ void syscallDispatchYield(SyscallRequest *req) {
req->unblock = true;
}

void syscallDispatchExecve(SyscallRequest *req) {
if(syscallVerifyPointer(req, req->params[0], MAX_FILE_PATH) &&
syscallVerifyPointer(req, req->params[1], ARG_MAX*sizeof(uintptr_t)) &&
syscallVerifyPointer(req, req->params[2], ARG_MAX*sizeof(uintptr_t))) {
req->requestID = syscallID();
int status = execve(req->thread, req->requestID, (const char *) req->params[0],
(const char **) req->params[1], (const char **) req->params[2]);
if(status) {
// error code
req->external = false;
req->ret = status;
req->unblock = true;
} else {
// block until completion
req->external = true;
req->unblock = false;
}
}
}

void syscallDispatchExecrdv(SyscallRequest *req) {
req->ret = execrdv(req->thread, (const char *) req->params[0], (const char **) req->params[1]);
req->unblock = true;
Expand Down Expand Up @@ -475,7 +495,7 @@ void (*syscallDispatchTable[])(SyscallRequest *) = {
syscallDispatchFork, // 1 - fork()
syscallDispatchYield, // 2 - yield()
NULL, // 3 - waitpid()
NULL, // 4 - execve()
syscallDispatchExecve, // 4 - execve()
syscallDispatchExecrdv, // 5 - execrdv()
syscallDispatchGetPID, // 6 - getpid()
syscallDispatchGetTID, // 7 - gettid()
Expand Down

0 comments on commit 841c77f

Please sign in to comment.