Skip to content

Commit

Permalink
syscalls: exposed opendir()
Browse files Browse the repository at this point in the history
  • Loading branch information
jewelcodes committed Sep 25, 2024
1 parent 1c0b2e9 commit 33efcb8
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/syscalls/dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <kernel/memory.h>
#include <kernel/file.h>
#include <kernel/irq.h>
#include <kernel/dirent.h>
#include <sys/types.h>
#include <sys/stat.h>

Expand Down Expand Up @@ -258,6 +259,23 @@ void syscallDispatchMount(SyscallRequest *req) {
}
}

void syscallDispatchOpendir(SyscallRequest *req) {
if(syscallVerifyPointer(req, req->params[0], MAX_FILE_PATH)) {
uint64_t id = platformRand();
req->requestID = id;

int status = opendir(req->thread, id, (const char *)req->params[0]);
if(status) {
req->external = false;
req->ret = status;
req->unblock = true;
} else {
req->external = true;
req->unblock = false;
}
}
}

/* Group 3: Interprocess Communication */

void syscallDispatchSocket(SyscallRequest *req) {
Expand Down Expand Up @@ -436,7 +454,7 @@ void (*syscallDispatchTable[])(SyscallRequest *) = {
syscallDispatchMount, // 30 - mount()
NULL, // 31 - umount()
NULL, // 32 - fnctl()
NULL, // 33 - opendir()
syscallDispatchOpendir, // 33 - opendir()
NULL, // 34 - closedir()
NULL, // 35 - readdir_r()
NULL, // 36 - seekdir()
Expand Down

0 comments on commit 33efcb8

Please sign in to comment.