From 2f88afdc5200f1f70e7674b35784b714e1286bee Mon Sep 17 00:00:00 2001 From: Giacomo Travaglini Date: Wed, 13 Oct 2021 09:03:02 +0100 Subject: [PATCH] sim-se: Implement fchmodat syscall Signed-off-by: Giacomo Travaglini Change-Id: Id3b738fa50d0739da5df856c87a8e172ec7a423a Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/51747 Reviewed-by: Jason Lowe-Power Maintainer: Jason Lowe-Power Tested-by: kokoro --- src/sim/syscall_emul.hh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh index 52110db73c..6cbbf00fb9 100644 --- a/src/sim/syscall_emul.hh +++ b/src/sim/syscall_emul.hh @@ -1130,19 +1130,24 @@ sysinfoFunc(SyscallDesc *desc, ThreadContext *tc, /// Target chmod() handler. template SyscallReturn -chmodFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, mode_t mode) +fchmodatFunc(SyscallDesc *desc, ThreadContext *tc, + int dirfd, VPtr<> pathname, mode_t mode) { 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; + } + mode_t hostMode = 0; // XXX translate mode flags via OS::something??? hostMode = mode; + auto process = tc->getProcessPtr(); // Adjust path for cwd and redirection path = process->checkPathRedirect(path); @@ -1154,6 +1159,14 @@ chmodFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, mode_t mode) return 0; } +/// Target chmod() handler. +template +SyscallReturn +chmodFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, mode_t mode) +{ + return fchmodatFunc(desc, tc, OS::TGT_AT_FDCWD, pathname, mode); +} + template SyscallReturn pollFunc(SyscallDesc *desc, ThreadContext *tc,