Skip to content

Commit

Permalink
syscalls: exposed readdir_r()
Browse files Browse the repository at this point in the history
  • Loading branch information
jewelcodes committed Sep 26, 2024
1 parent 307bbea commit d704d76
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 @@ -276,6 +276,24 @@ void syscallDispatchOpendir(SyscallRequest *req) {
}
}

void syscallDispatchReaddir(SyscallRequest *req) {
if(syscallVerifyPointer(req, req->params[1], sizeof(struct dirent)) &&
syscallVerifyPointer(req, req->params[2], sizeof(struct dirent *))) {
uint64_t id = platformRand();
req->requestID = id;

int status = readdir_r(req->thread, id, (DIR *) req->params[0], (struct dirent *) req->params[1], (struct dirent **) req->params[2]);
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 @@ -456,7 +474,7 @@ void (*syscallDispatchTable[])(SyscallRequest *) = {
NULL, // 32 - fnctl()
syscallDispatchOpendir, // 33 - opendir()
NULL, // 34 - closedir()
NULL, // 35 - readdir_r()
syscallDispatchReaddir, // 35 - readdir_r()
NULL, // 36 - seekdir()
NULL, // 37 - telldir()

Expand Down

0 comments on commit d704d76

Please sign in to comment.