summaryrefslogtreecommitdiff
path: root/src/sim/syscall_emul.hh
diff options
context:
space:
mode:
authorGiacomo Gabrielli <Giacomo.Gabrielli@arm.com>2015-05-26 03:21:35 -0400
committerGiacomo Gabrielli <Giacomo.Gabrielli@arm.com>2015-05-26 03:21:35 -0400
commitcc2346e8ca7ad247c701ec58ffddd98fa9f03574 (patch)
tree8e648af761bc413d8d7f7feb68f7e85076d9bc0f /src/sim/syscall_emul.hh
parent0cc350d2c59d0e1b19cc377814ae7ef0860ee7ab (diff)
downloadgem5-cc2346e8ca7ad247c701ec58ffddd98fa9f03574.tar.xz
arm: Implement some missing syscalls (SE mode)
Adding a few syscalls that were previously considered unimplemented.
Diffstat (limited to 'src/sim/syscall_emul.hh')
-rw-r--r--src/sim/syscall_emul.hh38
1 files changed, 37 insertions, 1 deletions
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 <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;
+}
+
/// Target sysinfo() handler.
template <class OS>
SyscallReturn