From 5f14a46422228124b85345ee25cb8b83e377a844 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Fri, 7 Dec 2018 20:18:01 +0100 Subject: [PATCH] mescc: getcwd: Support getcwd (0, 0) GNU extension. * lib/linux/libc.c (_getcwd): Rename from getcwd. (_getcwd): New function. Support getcwd (0, 0) GNU extension. --- lib/linux/libc.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/linux/libc.c b/lib/linux/libc.c index da7383e7..6d990c27 100644 --- a/lib/linux/libc.c +++ b/lib/linux/libc.c @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -151,7 +152,7 @@ fsync (int filedes) } char * -getcwd (char *buffer, size_t size) +_getcwd (char *buffer, size_t size) { int r = _sys_call2 (SYS_getcwd, (long)buffer, (long)size); if (r >= 0) @@ -159,6 +160,15 @@ getcwd (char *buffer, size_t size) return 0; } +char * +getcwd (char *buffer, size_t size) +{ + static char buf[PATH_MAX]; + if (buffer) + return _getcwd (buffer, size); + return _getcwd (buf, PATH_MAX); +} + int dup (int old) {