Skip to content

Commit

Permalink
syscalls: dispatch closedir(), seekdir(), and telldir()
Browse files Browse the repository at this point in the history
  • Loading branch information
jewelcodes committed Sep 26, 2024
1 parent c209677 commit e6022d5
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/syscalls/dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ void syscallDispatchOpendir(SyscallRequest *req) {
}
}

void syscallDispatchClosedir(SyscallRequest *req) {
req->ret = closedir(req->thread, (DIR *) req->params[0]);
req->unblock = true;
}

void syscallDispatchReaddir(SyscallRequest *req) {
if(syscallVerifyPointer(req, req->params[1], sizeof(struct dirent)) &&
syscallVerifyPointer(req, req->params[2], sizeof(struct dirent *))) {
Expand All @@ -294,6 +299,16 @@ void syscallDispatchReaddir(SyscallRequest *req) {
}
}

void syscallDispatchSeekdir(SyscallRequest *req) {
seekdir(req->thread, (DIR *) req->params[0], req->params[1]);
req->unblock = true;
}

void syscallDispatchTelldir(SyscallRequest *req) {
req->ret = telldir(req->thread, (DIR *) req->params[0]);
req->unblock = true;
}

/* Group 3: Interprocess Communication */

void syscallDispatchSocket(SyscallRequest *req) {
Expand Down Expand Up @@ -473,10 +488,10 @@ void (*syscallDispatchTable[])(SyscallRequest *) = {
NULL, // 31 - umount()
NULL, // 32 - fnctl()
syscallDispatchOpendir, // 33 - opendir()
NULL, // 34 - closedir()
syscallDispatchClosedir, // 34 - closedir()
syscallDispatchReaddir, // 35 - readdir_r()
NULL, // 36 - seekdir()
NULL, // 37 - telldir()
syscallDispatchSeekdir, // 36 - seekdir()
syscallDispatchTelldir, // 37 - telldir()

/* group 3: interprocess communication */
syscallDispatchSocket, // 38 - socket()
Expand Down

0 comments on commit e6022d5

Please sign in to comment.