sim-se: Implement mkdirat syscall
JIRA: https://gem5.atlassian.net/browse/GEM5-1098 Change-Id: I0a9a5895ddbd337e055fe83f894d0aa67d705779 Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/51053 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Jason Lowe-Power <power.jg@gmail.com> Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
This commit is contained in:
@@ -443,11 +443,17 @@ symlinkFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
SyscallReturn
|
||||
mkdirFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, mode_t mode)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
std::string path;
|
||||
if (!SETranslatingPortProxy(tc).tryReadString(path, pathname))
|
||||
return -EFAULT;
|
||||
|
||||
return mkdirImpl(desc, tc, path, mode);
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
mkdirImpl(SyscallDesc *desc, ThreadContext *tc, std::string path, mode_t mode)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
path = p->checkPathRedirect(path);
|
||||
|
||||
auto result = mkdir(path.c_str(), mode);
|
||||
|
||||
@@ -197,6 +197,8 @@ SyscallReturn symlinkFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
/// Target mkdir() handler.
|
||||
SyscallReturn mkdirFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
VPtr<> pathname, mode_t mode);
|
||||
SyscallReturn mkdirImpl(SyscallDesc *desc, ThreadContext *tc,
|
||||
std::string path, mode_t mode);
|
||||
|
||||
/// Target mknod() handler.
|
||||
SyscallReturn mknodFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
@@ -1072,6 +1074,24 @@ fchownatFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
return chownImpl(desc, tc, path, owner, group);
|
||||
}
|
||||
|
||||
/// Target mkdirat() handler
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
mkdiratFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int dirfd, VPtr<> pathname, mode_t mode)
|
||||
{
|
||||
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 mkdirImpl(desc, tc, path, mode);
|
||||
}
|
||||
|
||||
/// Target sysinfo() handler.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
|
||||
Reference in New Issue
Block a user