summaryrefslogtreecommitdiff
path: root/src/sim
diff options
context:
space:
mode:
Diffstat (limited to 'src/sim')
-rw-r--r--src/sim/syscall_emul.cc19
-rw-r--r--src/sim/syscall_emul.hh4
2 files changed, 23 insertions, 0 deletions
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);