Subject: bin/24690: have restore automatically set owner/mode without prompting
To: None <gnats-bugs@gnats.netbsd.org>
From: None <vax@carolina.rr.com>
List: netbsd-bugs
Date: 03/06/2004 15:37:59
>Number:         24690
>Category:       bin
>Synopsis:       have restore automatically set owner/mode without prompting
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sat Mar 06 20:41:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     VaX#n8
>Release:        NetBSD 1.5.1
>Organization:
	
>Environment:
	

>Description:
	
restore -x and restore -i insist on interactive prompting
>How-To-Repeat:
	
I'm not exactly sure when it prompts, there's some code about it being the
root inode, but it seems to do so every time I use restore -i or restore -x

This is particularly annoying when I'm using a long-running
"dump | restore" pipeline since this prompt punctuates the middle of a long
process.
>Fix:
	

diff -ur -U 5 restore.old/dirs.c restore/dirs.c
--- restore.old/dirs.c	Mon May 11 20:42:48 1998
+++ restore/dirs.c	Sat Mar  6 15:23:19 2004
@@ -631,11 +631,11 @@
 			if ((flags & FORCE) == 0 && ep->e_flags & EXISTED) {
 				ep->e_flags &= ~NEW;
 				continue;
 			}
 			if (node.ino == ROOTINO &&
-		   	    reply("set owner/mode for '.'") == FAIL)
+		   	    !oflag && reply("set owner/mode for '.'") == FAIL)
 				continue;
 		}
 		if (ep == NULL) {
 			panic("cannot find directory inode %d\n", node.ino);
 		} else {
diff -ur -U 5 restore.old/main.c restore/main.c
--- restore.old/main.c	Fri Jun  9 05:05:02 2000
+++ restore/main.c	Sat Mar  6 15:30:06 2004
@@ -67,11 +67,11 @@
 #include "extern.h"
 
 extern char *__progname;	/* from crt0.o */
 
 int	bflag = 0, cvtflag = 0, dflag = 0, vflag = 0, yflag = 0;
-int	hflag = 1, mflag = 1, Nflag = 0;
+int	hflag = 1, mflag = 1, Nflag = 0, oflag = 0;
 char	command = '\0';
 int32_t	dumpnum = 1;
 int32_t	volno = 0;
 int32_t	ntrec;
 char	*dumpmap;
@@ -103,11 +103,11 @@
 	if ((inputdev = getenv("TAPE")) == NULL)
 		inputdev = _PATH_DEFTAPE;
 	if ((tmpdir = getenv("TMPDIR")) == NULL)
 		tmpdir = _PATH_TMP;
 	obsolete(&argc, &argv);
-	while ((ch = getopt(argc, argv, "b:cdf:himNRrs:tuvxy")) != -1)
+	while ((ch = getopt(argc, argv, "b:cdf:himNoRrs:tuvxy")) != -1)
 		switch(ch) {
 		case 'b':
 			/* Change default tape blocksize. */
 			bflag = 1;
 			ntrec = strtol(optarg, &p, 10);
@@ -142,10 +142,13 @@
 		case 'm':
 			mflag = 0;
 			break;
 		case 'N':
 			Nflag = 1;
+			break;
+		case 'o':
+			oflag = 1;
 			break;
 		case 's':
 			/* Dumpnum (skip to) for multifile dump tapes. */
 			dumpnum = strtol(optarg, &p, 10);
 			if (*p)
Only in restore.old: obj
diff -ur -U 5 restore.old/restore.8 restore/restore.8
--- restore.old/restore.8	Fri Jun  9 05:05:02 2000
+++ restore/restore.8	Sat Mar  6 15:27:03 2004
@@ -41,11 +41,11 @@
 .Nm rrestore
 .Nd "restore files or file systems from backups made with dump"
 .Sh SYNOPSIS
 .Nm
 .Fl i
-.Op Fl cdhmuvyN
+.Op Fl cdhmuvyNo
 .Op Fl b Ar blocksize
 .Op Fl f Ar file
 .Op Fl s Ar fileno
 .Nm ""
 .Fl R
@@ -66,11 +66,11 @@
 .Op Fl f Ar file
 .Op Fl s Ar fileno
 .Op Ar
 .Nm ""
 .Fl x
-.Op Fl cdhmuvyN
+.Op Fl cdhmuvyNo
 .Op Fl b Ar blocksize
 .Op Fl f Ar file
 .Op Fl s Ar fileno
 .Op Ar
 .Pp
@@ -356,10 +356,12 @@
 .It Fl y
 Do not ask the user whether to abort the restore in the event of an error.
 Always try to skip over the bad block(s) and continue.
 .It Fl N
 Do not perform actual writing to disk.
+.It Fl o
+Set owner/mode without asking.
 .El
 .Sh DIAGNOSTICS
 Complains if it gets a read error.
 If
 .Fl y
diff -ur -U 5 restore.old/restore.h restore/restore.h
--- restore.old/restore.h	Wed Jun 24 15:56:11 1998
+++ restore/restore.h	Sat Mar  6 15:31:15 2004
@@ -47,10 +47,11 @@
 extern int	bflag;		/* set input block size */
 extern int	dflag;		/* print out debugging info */
 extern int	hflag;		/* restore heirarchies */
 extern int	mflag;		/* restore by name instead of inode number */
 extern int	Nflag;		/* do not write the disk */
+extern int	oflag;		/* automatically set owner/mode */
 extern int	vflag;		/* print out actions taken */
 extern int	uflag;		/* unlink file before writing to it */
 extern int	yflag;		/* always try to recover from tape errors */
 /*
  * Global variables
>Release-Note:
>Audit-Trail:
>Unformatted: