Syscall Emulation: Add stat64 syscall.
authorAli Saidi <saidi@eecs.umich.edu>
Thu, 13 Sep 2007 16:30:12 +0000 (12:30 -0400)
committerAli Saidi <saidi@eecs.umich.edu>
Thu, 13 Sep 2007 16:30:12 +0000 (12:30 -0400)
Patch submitted by: Jonas Diemer [diemer (a) ida.ing.tu-bs.de]

--HG--
extra : convert_revision : 07638c05bb3f79aacce49457bbb8c17d0a3a7238

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

index f7d946e2e577ecbb7fd23e9281bcd4b46dc5b492..b638aa927c9fcb9ceb66e88ba3f396c929b7cb34 100644 (file)
@@ -549,7 +549,7 @@ SyscallDesc AlphaLinuxProcess::syscallDescs[] = {
     /* 422 */ SyscallDesc("clock_nanosleep", unimplementedFunc),
     /* 423 */ SyscallDesc("semtimedop", unimplementedFunc),
     /* 424 */ SyscallDesc("tgkill", unimplementedFunc),
-    /* 425 */ SyscallDesc("stat64", unimplementedFunc),
+    /* 425 */ SyscallDesc("stat64", stat64Func<AlphaLinux>),
     /* 426 */ SyscallDesc("lstat64", lstat64Func<AlphaLinux>),
     /* 427 */ SyscallDesc("fstat64", fstat64Func<AlphaLinux>),
     /* 428 */ SyscallDesc("vserver", unimplementedFunc),
index a3d95b8ec9026545e996f87cf37ff5d76660ebcb..e2d13067cd9fbccd0130617ff80ca5788ae2b8d4 100644 (file)
@@ -604,6 +604,32 @@ statFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
 }
 
 
+/// Target stat64() handler.
+template <class OS>
+SyscallReturn
+stat64Func(SyscallDesc *desc, int callnum, LiveProcess *process,
+           ThreadContext *tc)
+{
+    std::string path;
+
+    if (!tc->getMemPort()->tryReadString(path, tc->getSyscallArg(0)))
+        return -EFAULT;
+
+    // Adjust path for current working directory
+    path = process->fullPath(path);
+
+    struct stat64 hostBuf;
+    int result = stat64(path.c_str(), &hostBuf);
+
+    if (result < 0)
+        return -errno;
+
+    copyOutStat64Buf<OS>(tc->getMemPort(), tc->getSyscallArg(1), &hostBuf);
+
+    return 0;
+}
+
+
 /// Target fstat64() handler.
 template <class OS>
 SyscallReturn