From: Ciro Santilli Date: Wed, 26 Sep 2018 16:11:07 +0000 (+0100) Subject: syscall_emul: fix openat when directory does not end in "/" X-Git-Tag: v19.0.0.0~1448 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=006eb36634a35f6b6d44ee63254f31ba96ac5267;p=gem5.git syscall_emul: fix openat when directory does not end in "/" Before this commit, the following code: dir_fd = open(".", O_DIRECTORY); file_fd = openat(dir_fd, "ble", O_CREAT, S_IRUSR | S_IWUSR); would create a file called ".ble" in the current working directory, instead of the correct "ble". Change-Id: I1525a088d49744e29b760387afabef9f1ac98646 Reviewed-by: Andreas Sandberg Reviewed-on: https://gem5-review.googlesource.com/c/13005 Reviewed-by: Brandon Potter Maintainer: Brandon Potter --- diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh index c7818b6c6..17d410937 100644 --- a/src/sim/syscall_emul.hh +++ b/src/sim/syscall_emul.hh @@ -695,7 +695,7 @@ openImpl(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc, auto ffdp = std::dynamic_pointer_cast(fdep); if (!ffdp) return -EBADF; - path.insert(0, ffdp->getFileName()); + path.insert(0, ffdp->getFileName() + "/"); } /**