2c2
< * Copyright (c) 2012-2013 ARM Limited
---
> * Copyright (c) 2012-2013, 2015 ARM Limited
717a718,753
> /// Target renameat() handler.
> template <class OS>
> 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;
> }
>