summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Sinclair <mattdsinclair@gmail.com>2018-06-21 14:17:17 -0400
committerMatt Sinclair <mattdsinclair@gmail.com>2018-06-25 18:36:29 +0000
commit3fb16fa3a3990ee4d2d2546d51db2220adb61a46 (patch)
tree52b547360e736ca3e9d584e1ce4ead9ad2d3cc30
parentfe330fdd3568beb880465a0ee974c7913d73dfcb (diff)
downloadgem5-3fb16fa3a3990ee4d2d2546d51db2220adb61a46.tar.xz
syscall_emul: adding link system call
Change-Id: If8922c2233bbe1f6fce35f64d1a44b91d2cfeed2 Reviewed-on: https://gem5-review.googlesource.com/11489 Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Maintainer: Brandon Potter <Brandon.Potter@amd.com>
-rw-r--r--src/arch/x86/linux/process.cc2
-rw-r--r--src/sim/syscall_emul.cc19
-rw-r--r--src/sim/syscall_emul.hh4
3 files changed, 24 insertions, 1 deletions
diff --git a/src/arch/x86/linux/process.cc b/src/arch/x86/linux/process.cc
index 7993b80f5..5717218f9 100644
--- a/src/arch/x86/linux/process.cc
+++ b/src/arch/x86/linux/process.cc
@@ -306,7 +306,7 @@ static SyscallDesc syscallDescs64[] = {
/* 83 */ SyscallDesc("mkdir", unimplementedFunc),
/* 84 */ SyscallDesc("rmdir", unimplementedFunc),
/* 85 */ SyscallDesc("creat", unimplementedFunc),
- /* 86 */ SyscallDesc("link", unimplementedFunc),
+ /* 86 */ SyscallDesc("link", linkFunc),
/* 87 */ SyscallDesc("unlink", unlinkFunc),
/* 88 */ SyscallDesc("symlink", unimplementedFunc),
/* 89 */ SyscallDesc("readlink", readlinkFunc),
diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc
index 7f4d76630..c56963acf 100644
--- a/src/sim/syscall_emul.cc
+++ b/src/sim/syscall_emul.cc
@@ -519,6 +519,25 @@ unlinkHelper(SyscallDesc *desc, int num, Process *p, ThreadContext *tc,
return (result == -1) ? -errno : result;
}
+SyscallReturn
+linkFunc(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 = link(path.c_str(), new_path.c_str());
+ return (result == -1) ? -errno : result;
+}
SyscallReturn
mkdirFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc)
diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh
index e5b0f455a..e3d99cea9 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -203,6 +203,10 @@ SyscallReturn unlinkHelper(SyscallDesc *desc, int num,
SyscallReturn unlinkFunc(SyscallDesc *desc, int num,
Process *p, ThreadContext *tc);
+/// Target link() handler
+SyscallReturn linkFunc(SyscallDesc *desc, int num, Process *p,
+ ThreadContext *tc);
+
/// Target mkdir() handler.
SyscallReturn mkdirFunc(SyscallDesc *desc, int num,
Process *p, ThreadContext *tc);