From 1808da8f97ea7e7ddc35433cb5411317a49aceaa Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Tue, 7 Dec 2021 03:38:24 -0800 Subject: [PATCH] sim-se: Handle empty paths when resolving an "at" path. When the "path" argument is empty, use the file name of the node referred to by the fd file descriptor. This matches the behavior of "at" system calls when the TGT_AT_EMPTY_PATH flag is set. The system calls themselves are responsible for checking for that flag, and returning an error if an empty "path" is not allowed. Change-Id: Ib48d91ff983b3edb6f65e83686b90d79d74f3471 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/53683 Reviewed-by: Giacomo Travaglini Maintainer: Giacomo Travaglini Tested-by: kokoro --- src/sim/syscall_emul.hh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh index c53175b011..2f49f5e0ea 100644 --- a/src/sim/syscall_emul.hh +++ b/src/sim/syscall_emul.hh @@ -367,7 +367,10 @@ atSyscallPath(ThreadContext *tc, int dirfd, std::string &path) if (!ffdp) return -EBADF; - path = ffdp->getFileName() + "/" + path; + if (path.empty()) + path = ffdp->getFileName(); + else + path = ffdp->getFileName() + "/" + path; } return 0;