SysCalls: Implement truncate64 system call
This uses the new stack-based argument infrastructure. Tested on x86 and x86_64.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user