# HG changeset patch # Parent ba45735a726a4582e63561ab3dc741d7f0890447 diff -r ba45735a726a src/arch/x86/linux/process.cc --- a/src/arch/x86/linux/process.cc Thu Aug 04 12:32:21 2016 -0400 +++ b/src/arch/x86/linux/process.cc Sat Aug 27 10:34:02 2016 +0200 @@ -296,7 +296,7 @@ /* 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), @@ -435,7 +435,7 @@ /* 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), @@ -682,7 +682,7 @@ /* 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), @@ -762,7 +762,7 @@ /* 218 */ SyscallDesc("mincore", unimplementedFunc), /* 219 */ SyscallDesc("madvise", unimplementedFunc), /* 220 */ SyscallDesc("madvise1", unimplementedFunc), - /* 221 */ SyscallDesc("getdents64", unimplementedFunc), + /* 221 */ SyscallDesc("getdents64", getdents64Func), /* 222 */ SyscallDesc("fcntl64", unimplementedFunc), /* 223 */ SyscallDesc("unused", unimplementedFunc), /* 224 */ SyscallDesc("gettid", unimplementedFunc), diff -r ba45735a726a src/sim/syscall_emul.hh --- a/src/sim/syscall_emul.hh Thu Aug 04 12:32:21 2016 -0400 +++ b/src/sim/syscall_emul.hh Sat Aug 27 10:34:02 2016 +0200 @@ -273,41 +273,49 @@ /// Target setuid() handler. SyscallReturn setuidFunc(SyscallDesc *desc, int num, - LiveProcess *p, ThreadContext *tc); + LiveProcess *p, ThreadContext *tc); /// Target getpid() handler. SyscallReturn getpidFunc(SyscallDesc *desc, int num, - LiveProcess *p, ThreadContext *tc); + LiveProcess *p, ThreadContext *tc); /// Target getuid() handler. SyscallReturn getuidFunc(SyscallDesc *desc, int num, - LiveProcess *p, ThreadContext *tc); + LiveProcess *p, ThreadContext *tc); /// Target getgid() handler. SyscallReturn getgidFunc(SyscallDesc *desc, int num, - LiveProcess *p, ThreadContext *tc); + LiveProcess *p, ThreadContext *tc); /// Target getppid() handler. SyscallReturn getppidFunc(SyscallDesc *desc, int num, - LiveProcess *p, ThreadContext *tc); + LiveProcess *p, ThreadContext *tc); /// Target geteuid() handler. SyscallReturn geteuidFunc(SyscallDesc *desc, int num, - LiveProcess *p, ThreadContext *tc); + LiveProcess *p, ThreadContext *tc); /// Target getegid() handler. SyscallReturn getegidFunc(SyscallDesc *desc, int num, - LiveProcess *p, ThreadContext *tc); + LiveProcess *p, ThreadContext *tc); /// Target clone() handler. SyscallReturn cloneFunc(SyscallDesc *desc, int num, - LiveProcess *p, ThreadContext *tc); + LiveProcess *p, ThreadContext *tc); + +/// Target getdents() handler. +SyscallReturn getdentsFunc(SyscallDesc *desc, int num, + LiveProcess *p, ThreadContext *tc); + +/// Target getdents64() handler. +SyscallReturn getdents64Func(SyscallDesc *desc, int num, + LiveProcess *p, ThreadContext *tc); /// Target access() handler SyscallReturn accessFunc(SyscallDesc *desc, int num, - LiveProcess *p, ThreadContext *tc); + LiveProcess *p, ThreadContext *tc); SyscallReturn accessFunc(SyscallDesc *desc, int num, - LiveProcess *p, ThreadContext *tc, + LiveProcess *p, ThreadContext *tc, int index); /// Futex system call diff -r ba45735a726a src/sim/syscall_emul.cc --- a/src/sim/syscall_emul.cc Thu Aug 04 12:32:21 2016 -0400 +++ b/src/sim/syscall_emul.cc Sat Aug 27 10:34:02 2016 +0200 @@ -349,6 +349,46 @@ } SyscallReturn +getdentsFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc) +{ + int index = 0; + int sim_fd = p->sim_fd(p->getSyscallArg(tc, index)); + if (sim_fd < 0) + return -EBADF; + Addr buf_ptr = p->getSyscallArg(tc, index); + int nbytes = p->getSyscallArg(tc, index); + BufferArg buf_arg(buf_ptr, nbytes); + + int nread = syscall(SYS_getdents, sim_fd, buf_arg.bufferPtr(), nbytes); + int errno_after_call = errno; + + if (nread > 0) + buf_arg.copyOut(tc->getMemProxy()); + + return (nread == -1) ? -errno_after_call : nread; +} + +SyscallReturn +getdents64Func(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc) +{ + int index = 0; + int sim_fd = p->sim_fd(p->getSyscallArg(tc, index)); + if (sim_fd < 0) + return -EBADF; + Addr buf_ptr = p->getSyscallArg(tc, index); + int nbytes = p->getSyscallArg(tc, index); + BufferArg buf_arg(buf_ptr, nbytes); + + int nread = syscall(SYS_getdents64, sim_fd, buf_arg.bufferPtr(), nbytes); + int errno_after_call = errno; + + if (nread > 0) + buf_arg.copyOut(tc->getMemProxy()); + + return (nread == -1) ? -errno_after_call : nread; +} + +SyscallReturn getcwdFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc) { int result = 0;