--- src/usr.bin/xinstall/xinstall.c.orig	2009-05-31 00:15:01.000000000 +0300
+++ src/usr.bin/xinstall/xinstall.c	2009-05-31 00:12:16.000000000 +0300
@@ -1104,13 +1104,21 @@
                 if (!*p || (p != path && *p  == '/')) {
                         ch = *p;
                         *p = '\0';
-                        if (stat(path, &sb)) {
-                                if (errno != ENOENT || mkdir(path, 0777) < 0) {
+                        if (mkdir(path, 0777) < 0) {
+				/*
+				 * Can't create; path exists or no perms.
+				 * stat() path to determine what's there now.
+				 */
+				int sverrno;
+				sverrno = errno;
+				if (stat(path, &sb) < 0) {
+					/* Not there; use mkdir()s error */
+					errno = sverrno;
 					err(1, "%s: mkdir", path);
                                 }
-                        }
-			else if (!S_ISDIR(sb.st_mode)) {
-				errx(1, "%s exists but is not a directory", path);
+				if (!S_ISDIR(sb.st_mode)) {
+					errx(1, "%s exists but is not a directory", path);
+				}
 			}
                         if (!(*p = ch))
 				break;
