From 65ef21a30878ed3295aa08740d8163aeb00ac2e6 Mon Sep 17 00:00:00 2001 From: Giacomo Travaglini Date: Mon, 11 Oct 2021 10:13:38 +0100 Subject: [PATCH] sim-se: Define rmdirImpl helper This will be used by the following commit when properly reimplementing unlinkat syscall Signed-off-by: Giacomo Travaglini Change-Id: If207bed196ad467decaa1cfee70a538e6dfe8d1d Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/51547 Reviewed-by: Jason Lowe-Power Maintainer: Jason Lowe-Power Tested-by: kokoro --- src/sim/syscall_emul.cc | 8 +++++++- src/sim/syscall_emul.hh | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc index 35f047d42a..acf5dcd86f 100644 --- a/src/sim/syscall_emul.cc +++ b/src/sim/syscall_emul.cc @@ -963,11 +963,17 @@ chdirFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname) SyscallReturn rmdirFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname) { - auto p = tc->getProcessPtr(); std::string path; if (!SETranslatingPortProxy(tc).tryReadString(path, pathname)) return -EFAULT; + return rmdirImpl(desc, tc, path); +} + +SyscallReturn +rmdirImpl(SyscallDesc *desc, ThreadContext *tc, std::string path) +{ + auto p = tc->getProcessPtr(); path = p->checkPathRedirect(path); auto result = rmdir(path.c_str()); diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh index be30797dad..77cdf582c6 100644 --- a/src/sim/syscall_emul.hh +++ b/src/sim/syscall_emul.hh @@ -206,7 +206,10 @@ SyscallReturn mknodFunc(SyscallDesc *desc, ThreadContext *tc, SyscallReturn chdirFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname); // Target rmdir() handler. -SyscallReturn rmdirFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname); +SyscallReturn rmdirFunc(SyscallDesc *desc, ThreadContext *tc, + VPtr<> pathname); +SyscallReturn rmdirImpl(SyscallDesc *desc, ThreadContext *tc, + std::string path); /// Target rename() handler. SyscallReturn renameFunc(SyscallDesc *desc, ThreadContext *tc,