Subject: Re: CVS commit: src/lib/libc/gen
To: Quentin Garnier <cube@cubidou.net>
From: Elad Efrat <elad@NetBSD.org>
List: source-changes
Date: 12/31/2005 02:17:00
This is a multi-part message in MIME format.
--------------040805000607030402070302
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Quentin Garnier wrote:

> Please re-re-re-revert (or whatever) that change.

Test attached patch.

-e.

-- 
Elad Efrat

--------------040805000607030402070302
Content-Type: text/plain;
 name="realpath.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="realpath.diff"

Index: getcwd.c
===================================================================
RCS file: /cvsroot/src/lib/libc/gen/getcwd.c,v
retrieving revision 1.41
diff -u -p -r1.41 getcwd.c
--- getcwd.c	22 Dec 2005 23:29:23 -0000	1.41
+++ getcwd.c	31 Dec 2005 00:15:36 -0000
@@ -69,7 +69,7 @@ char *
 realpath(const char *path, char *resolved)
 {
 	struct stat sb;
-	int idx = 0, n, nlnk = 0;
+	int idx = 0, n, nlnk = 0, serrno = errno;
 	const char *q;
 	char *p, wbuf[2][MAXPATHLEN];
 	size_t len;
@@ -163,8 +163,10 @@ loop:
 		while (*q == '/')
 			q++;
 
-		if (*q == 0  && errno == ENOENT)
+		if (*q == 0  && errno == ENOENT) {
+			errno = serrno;
 			return (resolved);
+		}
 
 		return (NULL);
 	}

--------------040805000607030402070302--