From 467ca7e2c85063197668d568b7f1bb270c26235d Mon Sep 17 00:00:00 2001 From: enami Date: Fri, 2 Jul 2004 07:17:17 +0000 Subject: [PATCH] Salvage the `create parent directories and try again' path which is removed by the previous commit. --- bin/pax/file_subs.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/bin/pax/file_subs.c b/bin/pax/file_subs.c index 410adf5d30ed..5d2e680e8e7c 100644 --- a/bin/pax/file_subs.c +++ b/bin/pax/file_subs.c @@ -1,4 +1,4 @@ -/* $NetBSD: file_subs.c,v 1.49 2004/06/26 13:28:09 grant Exp $ */ +/* $NetBSD: file_subs.c,v 1.50 2004/07/02 07:17:17 enami Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)file_subs.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: file_subs.c,v 1.49 2004/06/26 13:28:09 grant Exp $"); +__RCSID("$NetBSD: file_subs.c,v 1.50 2004/07/02 07:17:17 enami Exp $"); #endif #endif /* not lint */ @@ -407,7 +407,7 @@ node_creat(ARCHD *arcn) file_mode = arcn->sb.st_mode & FILEBITS(arcn->type == PAX_DIR); for (;;) { - switch(arcn->type) { + switch (arcn->type) { case PAX_DIR: /* * If -h (or -L) was given in tar-mode, follow the @@ -421,7 +421,8 @@ node_creat(ARCHD *arcn) sizeof target - 1); if (len == -1) { syswarn(0, errno, - "cannot follow symlink %s in chain for %s", + "cannot follow symlink %s " + "in chain for %s", nm, arcn->name); res = -1; goto badlink; @@ -454,7 +455,7 @@ badlink: tty_warn(0, "%s skipped. Sockets cannot be copied or extracted", nm); - return(-1); + return (-1); case PAX_SLK: res = symlink(arcn->ln_name, nm); break; @@ -468,7 +469,7 @@ badlink: */ tty_warn(0, "%s has an unknown file type, skipping", nm); - return(-1); + return (-1); } /* @@ -483,15 +484,20 @@ badlink: * we failed to make the node */ oerrno = errno; - if ((ign = unlnk_exist(nm, arcn->type)) < 0) - return(-1); - - if (++pass <= 1) + switch (pass++) { + case 0: + if ((ign = unlnk_exist(nm, arcn->type)) < 0) + return (-1); continue; - if (nodirs || chk_path(nm,arcn->sb.st_uid,arcn->sb.st_gid) < 0) { - syswarn(1, oerrno, "Cannot create %s", nm); - return(-1); + case 1: + if (nodirs || + chk_path(nm, arcn->sb.st_uid, + arcn->sb.st_gid) < 0) { + syswarn(1, oerrno, "Cannot create %s", nm); + return (-1); + } + continue; } /*