summaryrefslogtreecommitdiff
path: root/src/sim/syscall_emul.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/sim/syscall_emul.cc')
-rw-r--r--src/sim/syscall_emul.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc
index 9028d590b..ab44c0a35 100644
--- a/src/sim/syscall_emul.cc
+++ b/src/sim/syscall_emul.cc
@@ -214,6 +214,9 @@ unlinkFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
if (!tc->getMemPort()->tryReadString(path, tc->getSyscallArg(0)))
return (TheISA::IntReg)-EFAULT;
+ // Adjust path for current working directory
+ path = p->fullPath(path);
+
int result = unlink(path.c_str());
return (result == -1) ? -errno : result;
}
@@ -231,6 +234,10 @@ renameFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
if (!tc->getMemPort()->tryReadString(new_name, tc->getSyscallArg(1)))
return -EFAULT;
+ // Adjust path for current working directory
+ old_name = p->fullPath(old_name);
+ new_name = p->fullPath(new_name);
+
int64_t result = rename(old_name.c_str(), new_name.c_str());
return (result == -1) ? -errno : result;
}
@@ -245,6 +252,9 @@ truncateFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
off_t length = tc->getSyscallArg(1);
+ // Adjust path for current working directory
+ path = p->fullPath(path);
+
int result = truncate(path.c_str(), length);
return (result == -1) ? -errno : result;
}
@@ -277,6 +287,9 @@ chownFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
uint32_t group = tc->getSyscallArg(2);
gid_t hostGroup = group;
+ // Adjust path for current working directory
+ path = p->fullPath(path);
+
int result = chown(path.c_str(), hostOwner, hostGroup);
return (result == -1) ? -errno : result;
}