Hi everyone,

This is my version of the 'ftruncate64' system call. It simply passes the call through to the underlying OS.

Cheers
Tim

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

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,21 @@
 }
 
 SyscallReturn
+ftruncate64Func(SyscallDesc *desc, int num,
+                LiveProcess *process, ThreadContext *tc)
+{
+    int fd = process->sim_fd(process->getSyscallArg(tc, 0));
+
+    if (fd < 0)
+        return -EBADF;
+
+    loff_t length = process->getSyscallArg(tc, 1);
+
+    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
@@ -258,6 +258,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);
_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to