diff options
-rw-r--r-- | src/sim/syscall_emul.cc | 19 | ||||
-rw-r--r-- | src/sim/syscall_emul.hh | 4 |
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); |