summaryrefslogtreecommitdiff
path: root/src/sim
diff options
context:
space:
mode:
authorMatt Sinclair <mattdsinclair@gmail.com>2018-06-21 19:31:09 -0400
committerMatt Sinclair <mattdsinclair@gmail.com>2018-06-25 20:42:30 +0000
commit1678a08ded7e00049f4335d856c91043904002f7 (patch)
treed96eed3f514842fc7df4b8165a760019b1bbae1e /src/sim
parent3fb16fa3a3990ee4d2d2546d51db2220adb61a46 (diff)
downloadgem5-1678a08ded7e00049f4335d856c91043904002f7.tar.xz
syscall_emul: adding symlink system call
Change-Id: Iebda05c130b4d2ee8434cad1e703933bfda486c8 Reviewed-on: https://gem5-review.googlesource.com/11490 Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Maintainer: Jason Lowe-Power <jason@lowepower.com>
Diffstat (limited to 'src/sim')
-rw-r--r--src/sim/syscall_emul.cc20
-rw-r--r--src/sim/syscall_emul.hh4
2 files changed, 24 insertions, 0 deletions
diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc
index c56963acf..dd2323eaa 100644
--- a/src/sim/syscall_emul.cc
+++ b/src/sim/syscall_emul.cc
@@ -540,6 +540,26 @@ linkFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
}
SyscallReturn
+symlinkFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
+{
+ string path;
+ string new_path;
+
+ int index = 0;
+ auto &virt_mem = tc->getMemProxy();
+ if (!virt_mem.tryReadString(path, p->getSyscallArg(tc, index)))
+ return -EFAULT;
+ if (!virt_mem.tryReadString(new_path, p->getSyscallArg(tc, index)))
+ return -EFAULT;
+
+ path = p->fullPath(path);
+ new_path = p->fullPath(new_path);
+
+ int result = symlink(path.c_str(), new_path.c_str());
+ return (result == -1) ? -errno : result;
+}
+
+SyscallReturn
mkdirFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
{
string path;
diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh
index e3d99cea9..1f4233aa8 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -207,6 +207,10 @@ SyscallReturn unlinkFunc(SyscallDesc *desc, int num,
SyscallReturn linkFunc(SyscallDesc *desc, int num, Process *p,
ThreadContext *tc);
+/// Target symlink() handler.
+SyscallReturn symlinkFunc(SyscallDesc *desc, int num, Process *p,
+ ThreadContext *tc);
+
/// Target mkdir() handler.
SyscallReturn mkdirFunc(SyscallDesc *desc, int num,
Process *p, ThreadContext *tc);