Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/pax mkdir(2) can return EISDIR for /



details:   https://anonhg.NetBSD.org/src/rev/82f5b4a6f3fd
branches:  trunk
changeset: 584429:82f5b4a6f3fd
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Sep 17 06:05:04 2005 +0000

description:
mkdir(2) can return EISDIR for /

diffstat:

 bin/pax/ar_subs.c |  24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)

diffs (48 lines):

diff -r 0b56b5e5a04d -r 82f5b4a6f3fd bin/pax/ar_subs.c
--- a/bin/pax/ar_subs.c Sat Sep 17 01:51:21 2005 +0000
+++ b/bin/pax/ar_subs.c Sat Sep 17 06:05:04 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ar_subs.c,v 1.43 2005/09/16 16:48:18 christos Exp $    */
+/*     $NetBSD: ar_subs.c,v 1.44 2005/09/17 06:05:04 christos Exp $    */
 
 /*-
  * Copyright (c) 1992 Keith Muller.
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)ar_subs.c  8.2 (Berkeley) 4/18/94";
 #else
-__RCSID("$NetBSD: ar_subs.c,v 1.43 2005/09/16 16:48:18 christos Exp $");
+__RCSID("$NetBSD: ar_subs.c,v 1.44 2005/09/17 06:05:04 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -134,17 +134,21 @@
        int error;
        struct stat sb;
 
-       if ((error = mkdir(fname, mode)) != -1 || errno != EEXIST)
+       if ((error = mkdir(fname, mode)) != -1)
                return error;
 
-       error = errno;
-
-       if (stat(fname, &sb) == 0 && S_ISDIR(sb.st_mode))
+       switch (errno) {
+       case EISDIR:
                return 0;
-
-       errno = error;
-
-       return -1;
+       case EEXIST:
+               error = errno;
+               if (stat(fname, &sb) != -1 && S_ISDIR(sb.st_mode))
+                       return 0;
+               errno = error;
+               /*FALLTHROUGH*/
+       default:
+               return -1;
+       }
 }
 
 static int



Home | Main Index | Thread Index | Old Index