Matt Sinclair has uploaded this change for review. ( https://gem5-review.googlesource.com/11490

Change subject: syscall_emul: adding symlink syscall
......................................................................

syscall_emul: adding symlink syscall

Change-Id: Iebda05c130b4d2ee8434cad1e703933bfda486c8
---
M src/arch/x86/linux/process.cc
M src/sim/syscall_emul.cc
M src/sim/syscall_emul.hh
3 files changed, 26 insertions(+), 1 deletion(-)



diff --git a/src/arch/x86/linux/process.cc b/src/arch/x86/linux/process.cc
index ca42350..6ccdc63 100644
--- a/src/arch/x86/linux/process.cc
+++ b/src/arch/x86/linux/process.cc
@@ -308,7 +308,7 @@
     /*  85 */ SyscallDesc("creat", unimplementedFunc),
     /*  86 */ SyscallDesc("link", unimplementedFunc),
     /*  87 */ SyscallDesc("unlink", unlinkFunc),
-    /*  88 */ SyscallDesc("symlink", unimplementedFunc),
+    /*  88 */ SyscallDesc("symlink", symlinkFunc),
     /*  89 */ SyscallDesc("readlink", readlinkFunc),
     /*  90 */ SyscallDesc("chmod", unimplementedFunc),
     /*  91 */ SyscallDesc("fchmod", unimplementedFunc),
diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc
index e8c1f18..5ab1fb2 100644
--- a/src/sim/syscall_emul.cc
+++ b/src/sim/syscall_emul.cc
@@ -542,6 +542,28 @@
 }

 SyscallReturn
+symlinkFunc(SyscallDesc *desc, int num, ThreadContext *tc)
+{
+    string path;
+    string new_path;
+
+    int index = 0;
+    auto p = tc->getProcessPtr();
+    auto mem_state = p->getMemState();
+    auto &virt_mem = mem_state->getVirtMem();
+    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->checkPathRedirect(path);
+    new_path = p->checkPathRedirect(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 8a7591d..c476f28 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -206,6 +206,9 @@
 /// Target link() handler
 SyscallReturn linkFunc(SyscallDesc *desc, int num, ThreadContext *tc);

+/// Target symlink() handler.
+SyscallReturn symlinkFunc(SyscallDesc *desc, int num, ThreadContext *tc);
+
 /// Target mkdir() handler.
 SyscallReturn mkdirFunc(SyscallDesc *desc, int num,
                         Process *p, ThreadContext *tc);

--
To view, visit https://gem5-review.googlesource.com/11490
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: Iebda05c130b4d2ee8434cad1e703933bfda486c8
Gerrit-Change-Number: 11490
Gerrit-PatchSet: 1
Gerrit-Owner: Matt Sinclair <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to