From 9ad3acab5ea79effe27fba240d8f89aadc138f6f Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Fri, 30 Oct 2009 12:31:55 -0400 Subject: [PATCH] SysCalls: Implement truncate64 system call This uses the new stack-based argument infrastructure. Tested on x86 and x86_64. --- src/sim/syscall_emul.cc | 19 +++++++++++++++++++ src/sim/syscall_emul.hh | 4 ++++ 2 files changed, 23 insertions(+) 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 @@ -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) 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);