SysCalls: Implement truncate64 system call
authorVince Weaver <vince@csl.cornell.edu>
Fri, 30 Oct 2009 16:31:55 +0000 (12:31 -0400)
committerVince Weaver <vince@csl.cornell.edu>
Fri, 30 Oct 2009 16:31:55 +0000 (12:31 -0400)
This uses the new stack-based argument infrastructure.

Tested on x86 and x86_64.

src/sim/syscall_emul.cc
src/sim/syscall_emul.hh

index fae3586a40ef7e5f66019a8a857e4cadccd37e6e..cc8d99bcdc3da2dcd77197c538686348a65eeea8 100644 (file)
@@ -450,6 +450,25 @@ ftruncateFunc(SyscallDesc *desc, int num,
     return (result == -1) ? -errno : result;
 }
 
+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)
index 8fe53e266698d92d85aeb36f940557749bb70184..27c26afb0f08714bf015cf33b0a54fdf2cddc3b0 100644 (file)
@@ -260,6 +260,10 @@ SyscallReturn ftruncateFunc(SyscallDesc *desc, int num,
                             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);