Matt Sinclair has submitted this change and it was merged. ( https://gem5-review.googlesource.com/11489 )

Change subject: syscall_emul: adding link system call
......................................................................

syscall_emul: adding link system call

Change-Id: If8922c2233bbe1f6fce35f64d1a44b91d2cfeed2
Reviewed-on: https://gem5-review.googlesource.com/11489
Reviewed-by: Jason Lowe-Power <[email protected]>
Maintainer: Brandon Potter <[email protected]>
---
M src/arch/x86/linux/process.cc
M src/sim/syscall_emul.cc
M src/sim/syscall_emul.hh
3 files changed, 24 insertions(+), 1 deletion(-)

Approvals:
  Jason Lowe-Power: Looks good to me, approved
  Brandon Potter: Looks good to me, approved



diff --git a/src/arch/x86/linux/process.cc b/src/arch/x86/linux/process.cc
index 7993b80..5717218 100644
--- a/src/arch/x86/linux/process.cc
+++ b/src/arch/x86/linux/process.cc
@@ -306,7 +306,7 @@
     /*  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 7f4d766..c56963a 100644
--- a/src/sim/syscall_emul.cc
+++ b/src/sim/syscall_emul.cc
@@ -519,6 +519,25 @@
     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 e5b0f45..e3d99ce 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -203,6 +203,10 @@
 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);

--
To view, visit https://gem5-review.googlesource.com/11489
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: If8922c2233bbe1f6fce35f64d1a44b91d2cfeed2
Gerrit-Change-Number: 11489
Gerrit-PatchSet: 3
Gerrit-Owner: Matt Sinclair <[email protected]>
Gerrit-Reviewer: Anthony Gutierrez <[email protected]>
Gerrit-Reviewer: Brandon Potter <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Matt Sinclair <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to