arm: add access syscall for ARM SE mode
authorMitch Hayenga <mitch.hayenga+gem5@gmail.com>
Tue, 8 Jan 2013 13:54:07 +0000 (08:54 -0500)
committerMitch Hayenga <mitch.hayenga+gem5@gmail.com>
Tue, 8 Jan 2013 13:54:07 +0000 (08:54 -0500)
This patch adds the "access" syscall for ARM SE as required by some spec2006
benchmarks.

src/arch/arm/linux/process.cc
src/sim/syscall_emul.cc
src/sim/syscall_emul.hh

index 088f9907e2ca99a680f11fe83ce60794ccadad69..169565a04d818a57f828ea09c2cb73ca7b481ec8 100644 (file)
@@ -108,7 +108,7 @@ SyscallDesc ArmLinuxProcess::syscallDescs[] = {
     /* 30 */ SyscallDesc("utime", unimplementedFunc),
     /* 31 */ SyscallDesc("unused#31", unimplementedFunc),
     /* 32 */ SyscallDesc("unused#32", unimplementedFunc),
-    /* 33 */ SyscallDesc("access", unimplementedFunc),
+    /* 33 */ SyscallDesc("access", accessFunc),
     /* 34 */ SyscallDesc("nice", unimplementedFunc),
     /* 35 */ SyscallDesc("unused#35", unimplementedFunc),
     /* 36 */ SyscallDesc("sync", unimplementedFunc),
index 779e567f5b14da05c6d55b24915d8679bf554424..a860653178fa6f5749b46f27bc8d5a24dfc282e2 100644 (file)
@@ -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;
+}
index e98e771d50cd19ec14248a9e0a26711bc914706f..364b66c0a1f1d39772df1f89a3b44106cd749b99 100644 (file)
@@ -335,6 +335,10 @@ SyscallReturn getegidFunc(SyscallDesc *desc, int num,
 SyscallReturn cloneFunc(SyscallDesc *desc, int num,
                                LiveProcess *p, ThreadContext *tc);
 
+/// Target access() handler
+SyscallReturn accessFunc(SyscallDesc *desc, int num,
+                               LiveProcess *p, ThreadContext *tc);
+
 /// Futex system call
 ///  Implemented by Daniel Sanchez
 ///  Used by printf's in multi-threaded apps