diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh index 0f27cb2aca..52110db73c 100644 --- a/src/sim/syscall_emul.hh +++ b/src/sim/syscall_emul.hh @@ -2075,19 +2075,21 @@ gettimeofdayFunc(SyscallDesc *desc, ThreadContext *tc, return 0; } - -/// Target utimes() handler. +/// Target futimesat() handler. template SyscallReturn -utimesFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, - VPtr tp) +futimesatFunc(SyscallDesc *desc, ThreadContext *tc, + int dirfd, VPtr<> pathname, VPtr 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(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 +SyscallReturn +utimesFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, + VPtr tp) +{ + return futimesatFunc(desc, tc, OS::TGT_AT_FDCWD, pathname, tp); +} + template SyscallReturn execveFunc(SyscallDesc *desc, ThreadContext *tc,