/* 85 */ SyscallDesc("creat", unimplementedFunc),
/* 86 */ SyscallDesc("link", linkFunc),
/* 87 */ SyscallDesc("unlink", unlinkFunc),
- /* 88 */ SyscallDesc("symlink", unimplementedFunc),
+ /* 88 */ SyscallDesc("symlink", symlinkFunc),
/* 89 */ SyscallDesc("readlink", readlinkFunc),
/* 90 */ SyscallDesc("chmod", unimplementedFunc),
/* 91 */ SyscallDesc("fchmod", unimplementedFunc),
return (result == -1) ? -errno : result;
}
+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)
{
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);