summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/arch/arm/linux/process.cc2
-rw-r--r--src/sim/syscall_emul.cc8
-rw-r--r--src/sim/syscall_emul.hh17
3 files changed, 25 insertions, 2 deletions
diff --git a/src/arch/arm/linux/process.cc b/src/arch/arm/linux/process.cc
index faa39fd34..269e92bae 100644
--- a/src/arch/arm/linux/process.cc
+++ b/src/arch/arm/linux/process.cc
@@ -523,7 +523,7 @@ static SyscallDesc syscallDescs64[] = {
/* 32 */ SyscallDesc("flock", unimplementedFunc),
/* 33 */ SyscallDesc("mknodat", unimplementedFunc),
/* 34 */ SyscallDesc("mkdirat", unimplementedFunc),
- /* 35 */ SyscallDesc("unlinkat", unimplementedFunc),
+ /* 35 */ SyscallDesc("unlinkat", unlinkatFunc<ArmLinux64>),
/* 36 */ SyscallDesc("symlinkat", unimplementedFunc),
/* 37 */ SyscallDesc("linkat", unimplementedFunc),
/* 38 */ SyscallDesc("renameat", unimplementedFunc),
diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc
index 37d0121c5..bf7efe210 100644
--- a/src/sim/syscall_emul.cc
+++ b/src/sim/syscall_emul.cc
@@ -400,9 +400,15 @@ readlinkFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc,
SyscallReturn
unlinkFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
{
+ return unlinkHelper(desc, num, p, tc, 0);
+}
+
+SyscallReturn
+unlinkHelper(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc,
+ int index)
+{
string path;
- int index = 0;
if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index)))
return -EFAULT;
diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh
index 0c06a5147..cc430b949 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -195,6 +195,9 @@ SyscallReturn readlinkFunc(SyscallDesc *desc, int num,
LiveProcess *p, ThreadContext *tc);
/// Target unlink() handler.
+SyscallReturn unlinkHelper(SyscallDesc *desc, int num,
+ LiveProcess *p, ThreadContext *tc,
+ int index);
SyscallReturn unlinkFunc(SyscallDesc *desc, int num,
LiveProcess *p, ThreadContext *tc);
@@ -655,6 +658,20 @@ openatFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
return openFunc<OS>(desc, callnum, process, tc, 1);
}
+/// Target unlinkat() handler.
+template <class OS>
+SyscallReturn
+unlinkatFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
+ ThreadContext *tc)
+{
+ int index = 0;
+ int dirfd = process->getSyscallArg(tc, index);
+ if (dirfd != OS::TGT_AT_FDCWD)
+ warn("unlinkat: first argument not AT_FDCWD; unlikely to work");
+
+ return unlinkHelper(desc, callnum, process, tc, 1);
+}
+
/// Target facessat() handler
template <class OS>
SyscallReturn