From cc2346e8ca7ad247c701ec58ffddd98fa9f03574 Mon Sep 17 00:00:00 2001 From: Giacomo Gabrielli Date: Tue, 26 May 2015 03:21:35 -0400 Subject: arm: Implement some missing syscalls (SE mode) Adding a few syscalls that were previously considered unimplemented. --- src/sim/syscall_emul.hh | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'src/sim/syscall_emul.hh') diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh index 05f87fd7d..07b910727 100644 --- a/src/sim/syscall_emul.hh +++ b/src/sim/syscall_emul.hh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2013 ARM Limited + * Copyright (c) 2012-2013, 2015 ARM Limited * Copyright (c) 2015 Advanced Micro Devices, Inc. * All rights reserved * @@ -715,6 +715,42 @@ readlinkatFunc(SyscallDesc *desc, int callnum, LiveProcess *process, return readlinkFunc(desc, callnum, process, tc, 1); } +/// Target renameat() handler. +template +SyscallReturn +renameatFunc(SyscallDesc *desc, int callnum, LiveProcess *process, + ThreadContext *tc) +{ + int index = 0; + + int olddirfd = process->getSyscallArg(tc, index); + if (olddirfd != OS::TGT_AT_FDCWD) + warn("renameat: first argument not AT_FDCWD; unlikely to work"); + + std::string old_name; + + if (!tc->getMemProxy().tryReadString(old_name, + process->getSyscallArg(tc, index))) + return -EFAULT; + + int newdirfd = process->getSyscallArg(tc, index); + if (newdirfd != OS::TGT_AT_FDCWD) + warn("renameat: third argument not AT_FDCWD; unlikely to work"); + + std::string new_name; + + if (!tc->getMemProxy().tryReadString(new_name, + process->getSyscallArg(tc, index))) + return -EFAULT; + + // Adjust path for current working directory + old_name = process->fullPath(old_name); + new_name = process->fullPath(new_name); + + int result = rename(old_name.c_str(), new_name.c_str()); + return (result == -1) ? -errno : result; +} + /// Target sysinfo() handler. template SyscallReturn -- cgit v1.2.3