syscall: Implementation of the ftruncate64 system call.
authorTimothy M. Jones <tjones1@inf.ed.ac.uk>
Sat, 24 Oct 2009 17:53:58 +0000 (10:53 -0700)
committerTimothy M. Jones <tjones1@inf.ed.ac.uk>
Sat, 24 Oct 2009 17:53:58 +0000 (10:53 -0700)
src/sim/syscall_emul.cc
src/sim/syscall_emul.hh

index bd66594afe989226fafa579cbeab0a81ce4d963b..9a797bcdb0e0fd4ceef3cc5a0e8a3ac2a441080f 100644 (file)
@@ -404,6 +404,22 @@ ftruncateFunc(SyscallDesc *desc, int num,
     return (result == -1) ? -errno : result;
 }
 
+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)
 {
index 6937e35f0d0bbfc5d6e73070ab1a7a6ccfb6091d..f5e8a02e5c5195f6aeb5d4c0701afb793b022ac4 100644 (file)
@@ -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);