sim-se: Implemnt fchownat syscall

JIRA: https://gem5.atlassian.net/browse/GEM5-1098

Change-Id: I46f9a5ba30a27c29a8a50323a0fb95074016ddb2
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/51050
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Giacomo Travaglini
2021-09-27 17:40:34 +01:00
parent b1a2d5f293
commit a4cec05e58
2 changed files with 30 additions and 2 deletions

View File

@@ -657,11 +657,18 @@ chownFunc(SyscallDesc *desc, ThreadContext *tc,
VPtr<> pathname, uint32_t owner, uint32_t group)
{
std::string path;
auto p = tc->getProcessPtr();
if (!SETranslatingPortProxy(tc).tryReadString(path, pathname))
return -EFAULT;
return chownImpl(desc, tc, path, owner, group);
}
SyscallReturn
chownImpl(SyscallDesc *desc, ThreadContext *tc,
std::string path, uint32_t owner, uint32_t group)
{
auto p = tc->getProcessPtr();
/* XXX endianess */
uid_t hostOwner = owner;
gid_t hostGroup = group;

View File

@@ -256,6 +256,8 @@ SyscallReturn gettidFunc(SyscallDesc *desc, ThreadContext *tc);
/// Target chown() handler.
SyscallReturn chownFunc(SyscallDesc *desc, ThreadContext *tc,
VPtr<> pathname, uint32_t owner, uint32_t group);
SyscallReturn chownImpl(SyscallDesc *desc, ThreadContext *tc,
std::string path, uint32_t owner, uint32_t group);
/// Target getpgrpFunc() handler.
SyscallReturn getpgrpFunc(SyscallDesc *desc, ThreadContext *tc);
@@ -1019,6 +1021,25 @@ renameatFunc(SyscallDesc *desc, ThreadContext *tc,
return renameImpl(desc, tc, old_name, new_name);
}
/// Target fchownat() handler
template <class OS>
SyscallReturn
fchownatFunc(SyscallDesc *desc, ThreadContext *tc,
int dirfd, VPtr<> pathname, uint32_t owner, uint32_t group,
int flags)
{
std::string path;
if (!SETranslatingPortProxy(tc).tryReadString(path, pathname))
return -EFAULT;
// Modifying path from the directory descriptor
if (auto res = atSyscallPath<OS>(tc, dirfd, path); !res.successful()) {
return res;
}
return chownImpl(desc, tc, path, owner, group);
}
/// Target sysinfo() handler.
template <class OS>
SyscallReturn