# HG changeset patch
# User Timothy M. Jones <[email protected]>
# Date 1255004953 -3600
# Node ID affca5319e825ac819c83a5faf8c980745d4472f
# Parent  3f8045e58321a3d55381ecbe2f5ce4cc3e9b0570
Implementation of the ftruncate64 system call.

diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc
--- a/src/sim/syscall_emul.cc
+++ b/src/sim/syscall_emul.cc
@@ -405,6 +405,22 @@
 }
 
 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
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -260,6 +260,11 @@
                             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);

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to