summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVince Weaver <vince@csl.cornell.edu>2009-10-30 12:31:55 -0400
committerVince Weaver <vince@csl.cornell.edu>2009-10-30 12:31:55 -0400
commit9ad3acab5ea79effe27fba240d8f89aadc138f6f (patch)
treeede62ff08422e8cf1a467faac7e29669e5b42fc8 /src
parentd6ff7929b30cde7bce1b3f3be89e1ef6eda82a2d (diff)
downloadgem5-9ad3acab5ea79effe27fba240d8f89aadc138f6f.tar.xz
SysCalls: Implement truncate64 system call
This uses the new stack-based argument infrastructure. Tested on x86 and x86_64.
Diffstat (limited to 'src')
-rw-r--r--src/sim/syscall_emul.cc19
-rw-r--r--src/sim/syscall_emul.hh4
2 files changed, 23 insertions, 0 deletions
diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc
index fae3586a4..cc8d99bcd 100644
--- a/src/sim/syscall_emul.cc
+++ b/src/sim/syscall_emul.cc
@@ -451,6 +451,25 @@ ftruncateFunc(SyscallDesc *desc, int num,
}
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 --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh
index 8fe53e266..27c26afb0 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -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);