diff options
Diffstat (limited to 'src/sim')
-rw-r--r-- | src/sim/syscall_emul.cc | 36 | ||||
-rw-r--r-- | src/sim/syscall_emul.hh | 8 |
2 files changed, 44 insertions, 0 deletions
diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc index d8df891dd..7eeacd319 100644 --- a/src/sim/syscall_emul.cc +++ b/src/sim/syscall_emul.cc @@ -31,6 +31,7 @@ #include <fcntl.h> #include <unistd.h> +#include <sys/syscall.h> #include <cstdio> #include <iostream> @@ -868,6 +869,41 @@ cloneFunc(SyscallDesc *desc, int callnum, LiveProcess *process, } SyscallReturn +getdentsFunc(SyscallDesc *desc, int num, LiveProcess *p, + ThreadContext *tc) +{ + int index = 0; + int fd = p->sim_fd(p->getSyscallArg(tc, index)); + Addr bufPtr = p->getSyscallArg(tc, index); + int nbytes = p->getSyscallArg(tc, index); + BufferArg bufArg(bufPtr, nbytes); + + int bytes_read = syscall(SYS_getdents, fd, bufArg.bufferPtr(), nbytes); + + if (bytes_read != -1) + bufArg.copyOut(tc->getMemProxy()); + + return bytes_read; +} + +SyscallReturn +getdents64Func(SyscallDesc *desc, int num, LiveProcess *p, + ThreadContext *tc) +{ + int index = 0; + int fd = p->sim_fd(p->getSyscallArg(tc, index)); + Addr bufPtr = p->getSyscallArg(tc, index); + int nbytes = p->getSyscallArg(tc, index); + BufferArg bufArg(bufPtr, nbytes); + + int bytes_read = syscall(SYS_getdents64, fd, bufArg.bufferPtr(), nbytes); + + if (bytes_read != -1) + bufArg.copyOut(tc->getMemProxy()); + + return bytes_read; +} +SyscallReturn accessFunc(SyscallDesc *desc, int callnum, LiveProcess *p, ThreadContext *tc, int index) { diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh index 66c12f07d..a106a1939 100644 --- a/src/sim/syscall_emul.hh +++ b/src/sim/syscall_emul.hh @@ -439,6 +439,14 @@ futexFunc(SyscallDesc *desc, int callnum, LiveProcess *process, } +/// Target getdents() handler. +SyscallReturn getdentsFunc(SyscallDesc *desc, int num, + LiveProcess *process, ThreadContext *tc); + +/// Target getdents64() handler. +SyscallReturn getdents64Func(SyscallDesc *desc, int num, + LiveProcess *process, ThreadContext *tc); + /// Pseudo Funcs - These functions use a different return convension, /// returning a second value in a register other than the normal return register |