#include "arch/arm/linux/process.hh"
+#include <sys/syscall.h>
+
#include "arch/arm/isa_traits.hh"
#include "arch/arm/linux/linux.hh"
#include "base/trace.hh"
/* 214 */ SyscallDesc("setgid", unimplementedFunc),
/* 215 */ SyscallDesc("setfsuid", unimplementedFunc),
/* 216 */ SyscallDesc("setfsgid", unimplementedFunc),
+#if defined(SYS_getdents64)
+ /* 217 */ SyscallDesc("getdents64", getdents64Func),
+#else
/* 217 */ SyscallDesc("getdents64", unimplementedFunc),
+#endif
/* 218 */ SyscallDesc("pivot_root", unimplementedFunc),
/* 219 */ SyscallDesc("mincore", unimplementedFunc),
/* 220 */ SyscallDesc("madvise", ignoreFunc),
/* 58 */ SyscallDesc("vhangup", unimplementedFunc),
/* 59 */ SyscallDesc("pipe2", unimplementedFunc),
/* 60 */ SyscallDesc("quotactl", unimplementedFunc),
+#if defined(SYS_getdents64)
+ /* 61 */ SyscallDesc("getdents64", getdents64Func),
+#else
/* 61 */ SyscallDesc("getdents64", unimplementedFunc),
+#endif
/* 62 */ SyscallDesc("llseek", lseekFunc),
/* 63 */ SyscallDesc("read", readFunc),
/* 64 */ SyscallDesc("write", writeFunc),
return (result == -1) ? -errno : result;
}
-#if defined(SYS_getdents)
-SyscallReturn
-getdentsFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc)
+#if defined(SYS_getdents) || defined(SYS_getdents64)
+template<typename DE, int SYS_NUM>
+static SyscallReturn
+getdentsImpl(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc)
{
int index = 0;
int tgt_fd = p->getSyscallArg(tc, index);
int sim_fd = hbfdp->getSimFD();
BufferArg buf_arg(buf_ptr, count);
- auto status = syscall(SYS_getdents, sim_fd, buf_arg.bufferPtr(), count);
+ auto status = syscall(SYS_NUM, sim_fd, buf_arg.bufferPtr(), count);
if (status == -1)
return -errno;
- typedef struct linux_dirent {
- unsigned long d_ino;
- unsigned long d_off;
- unsigned short d_reclen;
- char dname[];
- } LinDent;
-
unsigned traversed = 0;
while (traversed < status) {
- LinDent *buffer = (LinDent*)((Addr)buf_arg.bufferPtr() + traversed);
+ DE *buffer = (DE*)((Addr)buf_arg.bufferPtr() + traversed);
auto host_reclen = buffer->d_reclen;
return status;
}
#endif
+
+#if defined(SYS_getdents)
+SyscallReturn
+getdentsFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc)
+{
+ typedef struct linux_dirent {
+ unsigned long d_ino;
+ unsigned long d_off;
+ unsigned short d_reclen;
+ char dname[];
+ } LinDent;
+
+ return getdentsImpl<LinDent, SYS_getdents>(desc, callnum, p, tc);
+}
+#endif
+
+#if defined(SYS_getdents64)
+SyscallReturn
+getdents64Func(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc)
+{
+ typedef struct linux_dirent64 {
+ ino64_t d_ino;
+ off64_t d_off;
+ unsigned short d_reclen;
+ char dname[];
+ } LinDent64;
+
+ return getdentsImpl<LinDent64, SYS_getdents64>(desc, callnum, p, tc);
+}
+#endif
Process *p, ThreadContext *tc);
#endif
+#if defined(SYS_getdents64)
+// Target getdents() handler.
+SyscallReturn getdents64Func(SyscallDesc *desc, int num,
+ Process *p, ThreadContext *tc);
+#endif
+
// Target getuid() handler.
SyscallReturn getuidFunc(SyscallDesc *desc, int num,
Process *p, ThreadContext *tc);