Has been tested only for alpha.
Committed by: Nilay Vaish <nilay@cs.wisc.edu>
/* 302 */ SyscallDesc("mount", unimplementedFunc),
/* 303 */ SyscallDesc("old_adjtimex", unimplementedFunc),
/* 304 */ SyscallDesc("swapoff", unimplementedFunc),
- /* 305 */ SyscallDesc("getdents", unimplementedFunc),
+ /* 305 */ SyscallDesc("getdents", getdentsFunc),
/* 306 */ SyscallDesc("create_module", unimplementedFunc),
/* 307 */ SyscallDesc("init_module", unimplementedFunc),
/* 308 */ SyscallDesc("delete_module", unimplementedFunc),
/* 374 */ SyscallDesc("pivot_root", unimplementedFunc),
/* 375 */ SyscallDesc("mincore", unimplementedFunc),
/* 376 */ SyscallDesc("pciconfig_iobase", unimplementedFunc),
- /* 377 */ SyscallDesc("getdents64", unimplementedFunc),
+ /* 377 */ SyscallDesc("getdents64", getdents64Func),
/* 378 */ SyscallDesc("gettid", unimplementedFunc),
/* 379 */ SyscallDesc("readahead", unimplementedFunc),
/* 380 */ SyscallDesc("security", unimplementedFunc),
/* 138 */ SyscallDesc("setfsuid", unimplementedFunc),
/* 139 */ SyscallDesc("setfsgid", unimplementedFunc),
/* 140 */ SyscallDesc("llseek", _llseekFunc),
- /* 141 */ SyscallDesc("getdents", unimplementedFunc),
+ /* 141 */ SyscallDesc("getdents", getdentsFunc),
/* 142 */ SyscallDesc("newselect", unimplementedFunc),
/* 143 */ SyscallDesc("flock", unimplementedFunc),
/* 144 */ SyscallDesc("msync", unimplementedFunc),
/* 214 */ SyscallDesc("setgid", unimplementedFunc),
/* 215 */ SyscallDesc("setfsuid", unimplementedFunc),
/* 216 */ SyscallDesc("setfsgid", unimplementedFunc),
- /* 217 */ SyscallDesc("getdents64", unimplementedFunc),
+ /* 217 */ SyscallDesc("getdents64", getdents64Func),
/* 218 */ SyscallDesc("pivot_root", unimplementedFunc),
/* 219 */ SyscallDesc("mincore", unimplementedFunc),
/* 220 */ SyscallDesc("madvise", unimplementedFunc),
/* 138 */ SyscallDesc("setfsuid", unimplementedFunc),
/* 139 */ SyscallDesc("setfsgid", unimplementedFunc),
/* 140 */ SyscallDesc("llseek", unimplementedFunc),
- /* 141 */ SyscallDesc("getdents", unimplementedFunc),
+ /* 141 */ SyscallDesc("getdents", getdentsFunc),
/* 142 */ SyscallDesc("newselect", unimplementedFunc),
/* 143 */ SyscallDesc("flock", unimplementedFunc),
/* 144 */ SyscallDesc("msync", unimplementedFunc),
/* 216 */ SyscallDesc("pivot_root", unimplementedFunc),
/* 217 */ SyscallDesc("mincore", unimplementedFunc),
/* 218 */ SyscallDesc("madvise", unimplementedFunc),
- /* 219 */ SyscallDesc("getdents64", unimplementedFunc),
+ /* 219 */ SyscallDesc("getdents64", getdents64Func),
/* 220 */ SyscallDesc("fcntl64", fcntl64Func),
/* 221 */ SyscallDesc("reserved#221", unimplementedFunc),
/* 222 */ SyscallDesc("gettid", unimplementedFunc),
/* 138 */ SyscallDesc("setfsuid", unimplementedFunc),
/* 139 */ SyscallDesc("setfsgid", unimplementedFunc),
/* 140 */ SyscallDesc("llseek", _llseekFunc),
- /* 141 */ SyscallDesc("getdents", unimplementedFunc),
+ /* 141 */ SyscallDesc("getdents", getdentsFunc),
/* 142 */ SyscallDesc("newselect", unimplementedFunc),
/* 143 */ SyscallDesc("flock", unimplementedFunc),
/* 144 */ SyscallDesc("msync", unimplementedFunc),
/* 214 */ SyscallDesc("setgid", unimplementedFunc),
/* 215 */ SyscallDesc("setfsuid", unimplementedFunc),
/* 216 */ SyscallDesc("setfsgid", unimplementedFunc),
- /* 217 */ SyscallDesc("getdents64", unimplementedFunc),
+ /* 217 */ SyscallDesc("getdents64", getdents64Func),
/* 218 */ SyscallDesc("pivot_root", unimplementedFunc),
/* 219 */ SyscallDesc("mincore", unimplementedFunc),
/* 220 */ SyscallDesc("madvise", unimplementedFunc),
/* 151 */ SyscallDesc("inotify_init", unimplementedFunc),
/* 152 */ SyscallDesc("inotify_add_watch", unimplementedFunc),
/* 153 */ SyscallDesc("poll", unimplementedFunc),
- /* 154 */ SyscallDesc("getdents64", unimplementedFunc),
+ /* 154 */ SyscallDesc("getdents64", getdents64Func),
/* 155 */ SyscallDesc("fcntl64", unimplementedFunc),
/* 156 */ SyscallDesc("inotify_rm_watch", unimplementedFunc),
/* 157 */ SyscallDesc("statfs", unimplementedFunc),
/* 171 */ SyscallDesc("fsetxattr", unimplementedFunc), // 32 bit
/* 172 */ SyscallDesc("getxattr", unimplementedFunc),
/* 173 */ SyscallDesc("lgetxattr", unimplementedFunc),
- /* 174 */ SyscallDesc("getdents", unimplementedFunc),
+ /* 174 */ SyscallDesc("getdents", getdentsFunc),
/* 175 */ SyscallDesc("setsid", unimplementedFunc),
/* 176 */ SyscallDesc("fchdir", unimplementedFunc),
/* 177 */ SyscallDesc("fgetxattr", unimplementedFunc), // 32 bit
/* 151 */ SyscallDesc("inotify_init", unimplementedFunc),
/* 152 */ SyscallDesc("inotify_add_watch", unimplementedFunc),
/* 153 */ SyscallDesc("poll", unimplementedFunc),
- /* 154 */ SyscallDesc("getdents64", unimplementedFunc),
+ /* 154 */ SyscallDesc("getdents64", getdents64Func),
/* 155 */ SyscallDesc("fcntl64", unimplementedFunc),
/* 156 */ SyscallDesc("inotify_rm_watch", unimplementedFunc),
/* 157 */ SyscallDesc("statfs", unimplementedFunc),
/* 171 */ SyscallDesc("fsetxattr", unimplementedFunc),
/* 172 */ SyscallDesc("getxattr", unimplementedFunc),
/* 173 */ SyscallDesc("lgetxattr", unimplementedFunc),
- /* 174 */ SyscallDesc("getdents", unimplementedFunc),
+ /* 174 */ SyscallDesc("getdents", getdentsFunc),
/* 175 */ SyscallDesc("setsid", unimplementedFunc),
/* 176 */ SyscallDesc("fchdir", unimplementedFunc),
/* 177 */ SyscallDesc("fgetxattr", unimplementedFunc),
/* 75 */ SyscallDesc("fdatasync", unimplementedFunc),
/* 76 */ SyscallDesc("truncate", truncateFunc),
/* 77 */ SyscallDesc("ftruncate", ftruncateFunc),
- /* 78 */ SyscallDesc("getdents", unimplementedFunc),
+ /* 78 */ SyscallDesc("getdents", getdentsFunc),
/* 79 */ SyscallDesc("getcwd", getcwdFunc),
/* 80 */ SyscallDesc("chdir", unimplementedFunc),
/* 81 */ SyscallDesc("fchdir", unimplementedFunc),
/* 214 */ SyscallDesc("epoll_ctl_old", unimplementedFunc),
/* 215 */ SyscallDesc("epoll_wait_old", unimplementedFunc),
/* 216 */ SyscallDesc("remap_file_pages", unimplementedFunc),
- /* 217 */ SyscallDesc("getdents64", unimplementedFunc),
+ /* 217 */ SyscallDesc("getdents64", getdents64Func),
/* 218 */ SyscallDesc("set_tid_address", unimplementedFunc),
/* 219 */ SyscallDesc("restart_syscall", unimplementedFunc),
/* 220 */ SyscallDesc("semtimedop", unimplementedFunc),
#include <fcntl.h>
#include <unistd.h>
+#include <sys/syscall.h>
#include <cstdio>
#include <iostream>
}
}
+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)
}
+/// 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