Subject: bin/25355: patch to have restore automatically set owner/mode
To: None <gnats-bugs@gnats.netbsd.org>
From: None <vax@carolina.rr.com>
List: netbsd-bugs
Date: 04/27/2004 17:05:40
>Number:         25355
>Category:       bin
>Synopsis:       add -o flag to restore to automatically set owner/mode
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue Apr 27 21:06:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     VaX#n8
>Release:        NetBSD 1.6.2
>Organization:
	
>Environment:
	
	
>Description:
	

Well basically you restore -xf /dev/nrst0 and it always asks
Set owner/mode for "."? [y/n]

Well now with the -o flag, it no longer asks, it just does it.
Wow, an unattended system restore, what a concept.
Now I can use dump/restore pipelines to move files around preserving
file system metadata and hard links and all that without having it
halt halfway through and ask me stupid questions.
>How-To-Repeat:
	
>Fix:
	

BTW, I think I fixed the Reply-To problem, if not my email is vax at
carolina.rr.com.

Index: NetBSD/sbin/restore/dirs.c
diff -u NetBSD/sbin/restore/dirs.c:1.1.1.1 NetBSD/sbin/restore/dirs.c:1.2
--- NetBSD/sbin/restore/dirs.c:1.1.1.1	Thu Apr  8 12:58:24 2004
+++ NetBSD/sbin/restore/dirs.c	Tue Apr 27 16:56:14 2004
@@ -637,7 +637,7 @@
 				continue;
 			}
 			if (node.ino == ROOTINO &&
-		   	    reply("set owner/mode for '.'") == FAIL)
+		   	    !oflag && reply("set owner/mode for '.'") == FAIL)
 				continue;
 		}
 		if (ep == NULL) {
Index: NetBSD/sbin/restore/main.c
diff -u NetBSD/sbin/restore/main.c:1.1.1.1 NetBSD/sbin/restore/main.c:1.2
--- NetBSD/sbin/restore/main.c:1.1.1.1	Thu Apr  8 12:58:24 2004
+++ NetBSD/sbin/restore/main.c	Tue Apr 27 16:56:15 2004
@@ -67,7 +67,7 @@
 #include "extern.h"
 
 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;
@@ -103,7 +103,7 @@
 	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. */
@@ -143,6 +143,9 @@
 		case 'N':
 			Nflag = 1;
 			break;
+		case 'o':
+			oflag = 1;
+			break;
 		case 's':
 			/* Dumpnum (skip to) for multifile dump tapes. */
 			dumpnum = strtol(optarg, &p, 10);
@@ -295,19 +298,19 @@
 	const char *progname = getprogname();
 
 	(void)fprintf(stderr,
-	    "usage: %s -i [-cdhmvyN] [-b blocksize] [-f file] [-s fileno]\n",
+	    "usage: %s -i [-cdhmovyN] [-b blocksize] [-f file] [-s fileno]\n",
 	    progname);
 	(void)fprintf(stderr,
-	    "\t%s -R [-cdvyN] [-b blocksize] [-f file] [-s fileno]\n",
+	    "\t%s -R [-cdovyN] [-b blocksize] [-f file] [-s fileno]\n",
 	    progname);
 	(void)fprintf(stderr,
-	    "\t%s -r [-cdvyN] [-b blocksize] [-f file] [-s fileno]\n",
+	    "\t%s -r [-cdovyN] [-b blocksize] [-f file] [-s fileno]\n",
 	    progname);
 	(void)fprintf(stderr,
 	    "\t%s -t [-cdhvy] [-b blocksize] [-f file] [-s fileno] [file ...]\n",
 	    progname);
 	(void)fprintf(stderr,
-	    "\t%s -x [-cdhmvyN] [-b blocksize] [-f file] [-s fileno] [file ...]\n",
+	    "\t%s -x [-cdhmovyN] [-b blocksize] [-f file] [-s fileno] [file ...]\n",
 	    progname);
 	exit(1);
 }
Index: NetBSD/sbin/restore/restore.8
diff -u NetBSD/sbin/restore/restore.8:1.1.1.1 NetBSD/sbin/restore/restore.8:1.3
--- NetBSD/sbin/restore/restore.8:1.1.1.1	Thu Apr  8 12:58:24 2004
+++ NetBSD/sbin/restore/restore.8	Tue Apr 27 17:04:08 2004
@@ -43,19 +43,19 @@
 .Sh SYNOPSIS
 .Nm
 .Fl i
-.Op Fl cdhmuvyN
+.Op Fl cdhmouvyN
 .Op Fl b Ar blocksize
 .Op Fl f Ar file
 .Op Fl s Ar fileno
 .Nm ""
 .Fl R
-.Op Fl cduvyN
+.Op Fl cdouvyN
 .Op Fl b Ar blocksize
 .Op Fl f Ar file
 .Op Fl s Ar fileno
 .Nm ""
 .Fl r
-.Op Fl cduvyN
+.Op Fl cdouvyN
 .Op Fl b Ar blocksize
 .Op Fl f Ar file
 .Op Fl s Ar fileno
@@ -68,7 +68,7 @@
 .Op Ar
 .Nm ""
 .Fl x
-.Op Fl cdhmuvyN
+.Op Fl cdhmouvyN
 .Op Fl b Ar blocksize
 .Op Fl f Ar file
 .Op Fl s Ar fileno
@@ -358,6 +358,8 @@
 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 ENVIRONMENT
 If the following environment variable exists it will be utilized by
Index: NetBSD/sbin/restore/restore.h
diff -u NetBSD/sbin/restore/restore.h:1.1.1.1 NetBSD/sbin/restore/restore.h:1.2
--- NetBSD/sbin/restore/restore.h:1.1.1.1	Thu Apr  8 12:58:24 2004
+++ NetBSD/sbin/restore/restore.h	Tue Apr 27 16:56:15 2004
@@ -49,6 +49,7 @@
 extern int	hflag;		/* restore hierarchies */
 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 */
>Release-Note:
>Audit-Trail:
>Unformatted: