sim-se: Implement futimesat syscall

Change-Id: I0cfb577b77663f8e4fac5c68633bdd69c4c8e2ea
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/51059
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:
Giacomo Travaglini
2021-09-28 09:39:21 +01:00
parent 4808a22dae
commit 1c708f76f1

View File

@@ -2075,19 +2075,21 @@ gettimeofdayFunc(SyscallDesc *desc, ThreadContext *tc,
return 0;
}
/// Target utimes() handler.
/// Target futimesat() handler.
template <class OS>
SyscallReturn
utimesFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname,
VPtr<typename OS::timeval [2]> tp)
futimesatFunc(SyscallDesc *desc, ThreadContext *tc,
int dirfd, VPtr<> pathname, VPtr<typename OS::timeval [2]> tp)
{
std::string path;
auto process = tc->getProcessPtr();
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;
}
struct timeval hostTimeval[2];
for (int i = 0; i < 2; ++i) {
hostTimeval[i].tv_sec = gtoh((*tp)[i].tv_sec, OS::byteOrder);
@@ -2095,6 +2097,7 @@ utimesFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname,
}
// Adjust path for cwd and redirection
auto process = tc->getProcessPtr();
path = process->checkPathRedirect(path);
int result = utimes(path.c_str(), hostTimeval);
@@ -2105,6 +2108,15 @@ utimesFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname,
return 0;
}
/// Target utimes() handler.
template <class OS>
SyscallReturn
utimesFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname,
VPtr<typename OS::timeval [2]> tp)
{
return futimesatFunc<OS>(desc, tc, OS::TGT_AT_FDCWD, pathname, tp);
}
template <class OS>
SyscallReturn
execveFunc(SyscallDesc *desc, ThreadContext *tc,