# HG changeset patch
# User Vince Weaver <[email protected]>
# Date 1256920315 14400
# Node ID c4b69afe784dabda866140d01a06fd46de3ea54c
# Parent  4842482e1bd1fbc33b8a6f4cf6cc9eec32cda800
implement truncate64 system call

This uses the new stack-based argument infrastructure.

Tested on x86 and x86_64.

diff -r 4842482e1bd1 -r c4b69afe784d src/sim/syscall_emul.cc
--- a/src/sim/syscall_emul.cc   Fri Oct 30 00:44:55 2009 -0700
+++ b/src/sim/syscall_emul.cc   Fri Oct 30 12:31:55 2009 -0400
@@ -449,6 +449,25 @@
 }
 
 SyscallReturn
+truncate64Func(SyscallDesc *desc, int num,
+                LiveProcess *process, ThreadContext *tc)
+{
+    int index = 0;
+    string path;
+
+    if (!tc->getMemPort()->tryReadString(path, process->getSyscallArg(tc, 
index)))
+       return -EFAULT;
+
+    loff_t length = process->getSyscallArg(tc, index, 64);
+
+    // Adjust path for current working directory
+    path = process->fullPath(path);
+
+    int result = truncate64(path.c_str(), length);
+    return (result == -1) ? -errno : result;
+}
+
+SyscallReturn
 ftruncate64Func(SyscallDesc *desc, int num,
                 LiveProcess *process, ThreadContext *tc)
 {
diff -r 4842482e1bd1 -r c4b69afe784d src/sim/syscall_emul.hh
--- a/src/sim/syscall_emul.hh   Fri Oct 30 00:44:55 2009 -0700
+++ b/src/sim/syscall_emul.hh   Fri Oct 30 12:31:55 2009 -0400
@@ -260,6 +260,10 @@
                             LiveProcess *p, ThreadContext *tc);
 
 
+/// Target truncate64() handler.
+SyscallReturn truncate64Func(SyscallDesc *desc, int num,
+                             LiveProcess *p, ThreadContext *tc);
+
 /// Target ftruncate64() handler.
 SyscallReturn ftruncate64Func(SyscallDesc *desc, int num,
                               LiveProcess *p, ThreadContext *tc);
_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to