summaryrefslogtreecommitdiff
path: root/src/sim
diff options
context:
space:
mode:
authorMichael Adler <Michael.Adler@intel.com>2014-10-20 16:44:53 -0500
committerMichael Adler <Michael.Adler@intel.com>2014-10-20 16:44:53 -0500
commita3fe4c06620439aa317f257d3bcdde34508d3d43 (patch)
treee6bd4f80dddbe7404fcf87f82a2deeb803f93ab2 /src/sim
parente72736aaf0508dd545ae9949c31ed91ba41d761b (diff)
downloadgem5-a3fe4c06620439aa317f257d3bcdde34508d3d43.tar.xz
sim: implement getdents/getdents64 in user mode
Has been tested only for alpha. Committed by: Nilay Vaish <nilay@cs.wisc.edu>
Diffstat (limited to 'src/sim')
-rw-r--r--src/sim/syscall_emul.cc36
-rw-r--r--src/sim/syscall_emul.hh8
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