summaryrefslogtreecommitdiff
path: root/src/sim
diff options
context:
space:
mode:
authorTimothy M. Jones <tjones1@inf.ed.ac.uk>2009-10-24 10:53:58 -0700
committerTimothy M. Jones <tjones1@inf.ed.ac.uk>2009-10-24 10:53:58 -0700
commitc32d919bc07d87e5fc59d98cb58e9143182c1aef (patch)
treec25ea1020ee460c75c2ff03693e81149c5ece57e /src/sim
parent7cdd5316abaf91755edd9186d3836ff371902146 (diff)
downloadgem5-c32d919bc07d87e5fc59d98cb58e9143182c1aef.tar.xz
syscall: Implementation of the ftruncate64 system call.
Diffstat (limited to 'src/sim')
-rw-r--r--src/sim/syscall_emul.cc16
-rw-r--r--src/sim/syscall_emul.hh5
2 files changed, 21 insertions, 0 deletions
diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc
index bd66594af..9a797bcdb 100644
--- a/src/sim/syscall_emul.cc
+++ b/src/sim/syscall_emul.cc
@@ -405,6 +405,22 @@ ftruncateFunc(SyscallDesc *desc, int num,
}
SyscallReturn
+ftruncate64Func(SyscallDesc *desc, int num,
+ LiveProcess *process, ThreadContext *tc)
+{
+ int fd = process->sim_fd(process->getSyscallArg(tc, 0));
+
+ if (fd < 0)
+ return -EBADF;
+
+ // I'm not sure why, but the length argument is in arg reg 3
+ loff_t length = process->getSyscallArg(tc, 3);
+
+ int result = ftruncate64(fd, length);
+ return (result == -1) ? -errno : result;
+}
+
+SyscallReturn
umaskFunc(SyscallDesc *desc, int num, LiveProcess *process, ThreadContext *tc)
{
// Letting the simulated program change the simulator's umask seems like
diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh
index 6937e35f0..f5e8a02e5 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -260,6 +260,11 @@ SyscallReturn ftruncateFunc(SyscallDesc *desc, int num,
LiveProcess *p, ThreadContext *tc);
+/// Target ftruncate64() handler.
+SyscallReturn ftruncate64Func(SyscallDesc *desc, int num,
+ LiveProcess *p, ThreadContext *tc);
+
+
/// Target umask() handler.
SyscallReturn umaskFunc(SyscallDesc *desc, int num,
LiveProcess *p, ThreadContext *tc);