diff options
Diffstat (limited to 'src/sim/syscall_emul.cc')
-rw-r--r-- | src/sim/syscall_emul.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc index 779e567f5..a86065317 100644 --- a/src/sim/syscall_emul.cc +++ b/src/sim/syscall_emul.cc @@ -851,3 +851,20 @@ cloneFunc(SyscallDesc *desc, int callnum, LiveProcess *process, } } +SyscallReturn +accessFunc(SyscallDesc *desc, int callnum, LiveProcess *p, ThreadContext *tc) +{ + int index = 0; + + string path; + if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index))) + return (TheISA::IntReg)-EFAULT; + + // Adjust path for current working directory + path = p->fullPath(path); + + mode_t mode = p->getSyscallArg(tc, index); + + int result = access(path.c_str(), mode); + return (result == -1) ? -errno : result; +} |