aboutsummaryrefslogtreecommitdiff
path: root/linux-user/syscall.c
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@suse.de>2020-07-23 12:27:13 +0200
committerLaurent Vivier <laurent@vivier.eu>2020-07-27 22:05:34 +0200
commit0f6bb1958f3aae0171996941df7fb7ea7536bb12 (patch)
treecfe4f1dd08ee6e0d609ec5b4902448e0055a9136 /linux-user/syscall.c
parent4d213001b356c4a24c05afbc72f4860088900627 (diff)
linux-user: Use getcwd syscall directly
The glibc getcwd function returns different errors than the getcwd syscall, which triggers an assertion failure in the glibc getcwd function when running under the emulation. When the syscall returns ENAMETOOLONG, the glibc wrapper uses a fallback implementation that potentially handles an unlimited path length, and returns with ERANGE if the provided buffer is too small. The qemu emulation cannot distinguish the two cases, and thus always returns ERANGE. This is unexpected by the glibc wrapper. Signed-off-by: Andreas Schwab <schwab@suse.de> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <mvmmu3qplvi.fsf@suse.de> [lv: updated description] Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Diffstat (limited to 'linux-user/syscall.c')
-rw-r--r--linux-user/syscall.c9
1 files changed, 1 insertions, 8 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index c1ebf7b8f3..945fc25279 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -388,14 +388,7 @@ static bitmask_transtbl fcntl_flags_tbl[] = {
{ 0, 0, 0, 0 }
};
-static int sys_getcwd1(char *buf, size_t size)
-{
- if (getcwd(buf, size) == NULL) {
- /* getcwd() sets errno */
- return (-1);
- }
- return strlen(buf)+1;
-}
+_syscall2(int, sys_getcwd1, char *, buf, size_t, size)
#ifdef TARGET_NR_utimensat
#if defined(__NR_utimensat)