From s.moeding@ndh.net  Thu Sep  7 09:05:16 2000
Return-Path: <s.moeding@ndh.net>
Received: from public.ndh.com (public.ndh.net [195.94.90.21])
	by hub.freebsd.org (Postfix) with ESMTP id D286937B424
	for <FreeBSD-gnats-submit@freebsd.org>; Thu,  7 Sep 2000 09:05:14 -0700 (PDT)
Received: from elan.firekeys.org (port2089.duesseldorf.ndh.net [195.227.37.89]) by public.ndh.com (8.9.3/8.8.0) with ESMTP id SAA26229 for <FreeBSD-gnats-submit@freebsd.org>; Thu, 7 Sep 2000 18:05:06 +0200 (MET DST)
Received: from esprit.firekeys.org (esprit.firekeys.org [192.168.1.101])
	by elan.firekeys.org (8.11.0/8.11.0) with ESMTP id e87G5oX01608
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 7 Sep 2000 18:05:50 +0200 (CEST)
	(envelope-from sm@firekeys.org)
Message-Id: <200009071605.e87G5o001105@esprit.firekeys.org>
Date: Thu, 7 Sep 2000 18:05:50 +0200 (CEST)
From: s.moeding@ndh.net
Reply-To: s.moeding@ndh.net
To: FreeBSD-gnats-submit@freebsd.org
Subject: New option for restore (patch)
X-Send-Pr-Version: 3.2

>Number:         21093
>Category:       bin
>Synopsis:       New option for restore (patch)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Sep 07 09:10:00 PDT 2000
>Closed-Date:    Fri Sep 8 07:41:59 PDT 2000
>Last-Modified:  Fri Sep 08 07:42:48 PDT 2000
>Originator:     Stefan Moeding
>Release:        FreeBSD 4.1-STABLE i386
>Organization:
FreeBSD: The Power to Serve
>Environment:

	FreeBSD 4.1-STABLE i386

>Description:

	The vrestore command in Compaqs Tru64 Unix has an option '-D',
	which allows the vrestore command to perform a chdir into a
	given directory before performing the restore.  This allows the
	simpler command line

		dump -0af - /usr | restore -rf - -D /mnt

	instead of

		dump -0 -a -f - /usr | (cd /mnt; restore -r -f -)

>How-To-Repeat:

>Fix:

	The attached patch adds the '-D' flag to the restore command.

	Stefan

==============================================================================
diff -ruN restore/main.c /usr/src/sbin/restore/main.c
--- restore/main.c	Wed Sep  6 21:58:51 2000
+++ /usr/src/sbin/restore/main.c	Thu Sep  7 17:41:01 2000
@@ -52,6 +52,7 @@
 #include <protocols/dumprestore.h>
 
 #include <err.h>
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -99,9 +100,9 @@
 		inputdev = _PATH_DEFTAPE;
 	obsolete(&argc, &argv);
 #ifdef KERBEROS
-#define	optlist "b:cdf:hikmNRrs:tuvxy"
+#define	optlist "b:cD:df:hikmNRrs:tuvxy"
 #else
-#define	optlist "b:cdf:himNRrs:tuvxy"
+#define	optlist "b:cD:df:himNRrs:tuvxy"
 #endif
 	while ((ch = getopt(argc, argv, optlist)) != -1)
 		switch(ch) {
@@ -117,6 +118,12 @@
 		case 'c':
 			cvtflag = 1;
 			break;
+		case 'D':
+			if (chdir(optarg) < 0)
+				errx(1,
+				     "error accessing file system %s; %s",
+				     optarg, strerror(errno));
+			break;
 		case 'd':
 			dflag = 1;
 			break;
@@ -293,11 +300,11 @@
 usage()
 {
 	(void)fprintf(stderr, "usage:\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n",
-	  "restore -i [-chkmuvy] [-b blocksize] [-f file] [-s fileno]",
-	  "restore -r [-ckuvy] [-b blocksize] [-f file] [-s fileno]",
-	  "restore -R [-ckuvy] [-b blocksize] [-f file] [-s fileno]",
-	  "restore -x [-chkmuvy] [-b blocksize] [-f file] [-s fileno] [file ...]",
-	  "restore -t [-chkuvy] [-b blocksize] [-f file] [-s fileno] [file ...]");
+	  "restore -i [-chkmuvy] [-b blocksize] [-D path] [-f file] [-s fileno]",
+	  "restore -r [-ckuvy] [-b blocksize] [-D path] [-f file] [-s fileno]",
+	  "restore -R [-ckuvy] [-b blocksize] [-D path] [-f file] [-s fileno]",
+	  "restore -x [-chkmuvy] [-b blocksize] [-D path] [-f file] [-s fileno] [file ...]",
+	  "restore -t [-chkuvy] [-b blocksize] [-D path] [-f file] [-s fileno] [file ...]");
 	done(1);
 }
 
diff -ruN restore/restore.8 /usr/src/sbin/restore/restore.8
--- restore/restore.8	Wed Sep  6 21:58:51 2000
+++ /usr/src/sbin/restore/restore.8	Thu Sep  7 17:31:00 2000
@@ -44,24 +44,28 @@
 .Fl i
 .Op Fl chkmNuvy
 .Op Fl b Ar blocksize
+.Op Fl D Ar path
 .Op Fl f Ar file
 .Op Fl s Ar fileno
 .Nm restore
 .Fl R
 .Op Fl ckNuvy
 .Op Fl b Ar blocksize
+.Op Fl D Ar path
 .Op Fl f Ar file
 .Op Fl s Ar fileno
 .Nm restore
 .Fl r
 .Op Fl ckNuvy
 .Op Fl b Ar blocksize
+.Op Fl D Ar path
 .Op Fl f Ar file
 .Op Fl s Ar fileno
 .Nm restore
 .Fl t
 .Op Fl chkNuvy
 .Op Fl b Ar blocksize
+.Op Fl D Ar path
 .Op Fl f Ar file
 .Op Fl s Ar fileno
 .Op file ...
@@ -69,6 +73,7 @@
 .Fl x
 .Op Fl chkmNuvy
 .Op Fl b Ar blocksize
+.Op Fl D Ar path
 .Op Fl f Ar file
 .Op Fl s Ar fileno
 .Op file ...
@@ -275,6 +280,11 @@
 .Fl c
 flag disables this check, and only allows reading a dump in the old
 format.
+.It Fl D Ar path
+Specifies the destination path of where to restore the files.
+Without the
+.Fl D
+flag, the files are restored to the current directory.
 .It Fl f Ar file
 Read the backup from
 .Ar file ;
@@ -422,6 +432,17 @@
 owner, mode, and time stamps for directories.
 .It Pa \&./restoresymtable
 information passed between incremental restores.
+.El
+.Sh EXAMPLES
+The dump and
+.Nm restore
+commands may be used in a pipeline expression to copy file systems.
+The following are typical commands, both equivalent:
+.Bd -literal -offset indent
+dump -0 -a -f - /usr | (cd /mnt; restore -r -f -)
+dump -0af - /usr | restore -rf - -D /mnt
+.Ed
+.Pp
 .El
 .Sh SEE ALSO
 .Xr dump 8 ,





>Release-Note:
>Audit-Trail:

From: Matthew Jacob <mjacob@feral.com>
To: s.moeding@ndh.net
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/21093: New option for restore (patch)
Date: Thu, 7 Sep 2000 09:12:06 -0700 (PDT)

 Other than making this look like Tru64's changes, why is this desirable?
 
 
 
 

From: Stefan Moeding <s.moeding@ndh.net>
To: mjacob@feral.com
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/21093: New option for restore (patch)
Date: Thu, 7 Sep 2000 18:20:12 +0200 (CEST)

 Matthew Jacob writes:
 
 > Other than making this look like Tru64's changes, why is this desirable?
 
 To avoid the (IMHO!) awkward subshell.
 
 Stefan
 

From: Matthew Jacob <mjacob@feral.com>
To: Stefan Moeding <s.moeding@ndh.net>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/21093: New option for restore (patch)
Date: Thu, 7 Sep 2000 09:21:26 -0700 (PDT)

 IMO, this is not sufficient enough reason to add the feature.
 
 
 On Thu, 7 Sep 2000, Stefan Moeding wrote:
 
 > Matthew Jacob writes:
 > 
 > > Other than making this look like Tru64's changes, why is this desirable?
 > 
 > To avoid the (IMHO!) awkward subshell.
 > 
 > Stefan
 > 
 
 

From: Will Andrews <will@physics.purdue.edu>
To: Matthew Jacob <mjacob@feral.com>,
	Stefan Moeding <s.moeding@ndh.net>
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: bin/21093: New option for restore (patch)
Date: Thu, 7 Sep 2000 11:51:02 -0500

 On Thu, Sep 07, 2000 at 09:30:03AM -0700, Matthew Jacob wrote:
 >  IMO, this is not sufficient enough reason to add the feature.
 
 I agree with Matt.  If X feature does not require complex scripts, it's
 probably not going to be added to Y program (see df -c, etc.).
 
 -- 
 Will Andrews <will@physics.purdue.edu> <will@FreeBSD.org>
 GCS/E/S @d- s+:+ a--- C++ UB++++$ P+ L- E--- W+ N-- !o ?K w---
 O- M+ V- PS+ PE++ Y+ PGP+>+++ t++ 5 X+ R+ tv+ b++ DI+++ D+ 
 G++ e>++++ h! r- y?
 

From: Matthew Jacob <mjacob@feral.com>
To: Will Andrews <will@physics.purdue.edu>
Cc: Stefan Moeding <s.moeding@ndh.net>,
	FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: bin/21093: New option for restore (patch)
Date: Thu, 7 Sep 2000 11:30:57 -0700 (PDT)

 > On Thu, Sep 07, 2000 at 09:30:03AM -0700, Matthew Jacob wrote:
 > >  IMO, this is not sufficient enough reason to add the feature.
 > 
 > I agree with Matt.  If X feature does not require complex scripts, it's
 > probably not going to be added to Y program (see df -c, etc.).
 
 If there were some overriding other reason, like, "Amanda needs it", or
 "PicoBSD needs it and doesn't like to run subshells", or "subshells are bad",
 I could go for it. It's a trivial change.
 
 But, especially for dump (which should Die! Die! Die!), creeping featurism
 probably should be avoided.
 
 
 
State-Changed-From-To: open->feedback 
State-Changed-By: sheldonh 
State-Changed-When: Fri Sep 8 05:39:43 PDT 2000 
State-Changed-Why:  
So can we close this, or what? :-) 


http://www.freebsd.org/cgi/query-pr.cgi?pr=21093 
State-Changed-From-To: feedback->closed 
State-Changed-By: sheldonh 
State-Changed-When: Fri Sep 8 07:41:59 PDT 2000 
State-Changed-Why:  
Nobody seems to think this should be included.  The patch 
remains here for all to see, of course. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=21093 
>Unformatted:
