SysCalls: Implement truncate64 system call

This uses the new stack-based argument infrastructure.

Tested on x86 and x86_64.
This commit is contained in:
Vince Weaver 2009-10-30 12:31:55 -04:00
parent d6ff7929b3
commit 9ad3acab5e
2 changed files with 23 additions and 0 deletions

View file

@ -450,6 +450,25 @@ ftruncateFunc(SyscallDesc *desc, int num,
return (result == -1) ? -errno : result;
}
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)

View file

@ -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);