Subject: restore asks "set owner/mode" stupid question
To: None <tech-userlevel@NetBSD.org>
From: Frederick Bruckman <fredb@immanent.net>
List: tech-userlevel
Date: 01/03/2005 11:54:23
When running "restore" with -x or -i (but not -r), it always prompts
you near the end of the process with a "set owner/mode for '.'"? As
pointed out by VaX#n8 in PR bin/24690 (and others), this can be quite
annoying, if say, you were hoping to accomplish a dump/restore -x
pipeline unattended.
The issue is this: Because restore always restores all intervening
directories, it will always "restore" ".". But if you are only
extracting a few files from the dump in, say, "/tmp", you really don't
want the permissions on the current directory (/tmp), to be changed.
On the other hand, if you're using "-x" to extract an entire file
system, you do. Interrogating the user, though, isn't the unix way,
and it isn't a robust solution. Particularly, since it comes out of
nowhere, an admin is likely to answer wrongly.
So, I propose letting restore figure out and perform the recommended
practice all by itself: In the patch below, the implicit dot-dir
(when no arguments are given) will be extracted, the explicit dot-dir
will be extracted (i.e.: when "." is supplied as an argument), but the
incidental, intervening dot-dir will not. Of course I would update the
man page, too.
Index: ./sbin/restore/dirs.c
===================================================================
RCS file: /cvsroot/src/sbin/restore/dirs.c,v
retrieving revision 1.41
diff -u -r1.41 dirs.c
--- ./sbin/restore/dirs.c 22 Oct 2004 22:38:38 -0000 1.41
+++ ./sbin/restore/dirs.c 3 Jan 2005 17:21:23 -0000
@@ -636,8 +636,7 @@
ep->e_flags &= ~NEW;
continue;
}
- if (node.ino == ROOTINO &&
- reply("set owner/mode for '.'") == FAIL)
+ if (node.ino == ROOTINO && dotflag == 0)
continue;
}
if (ep == NULL) {
Index: ./sbin/restore/interactive.c
===================================================================
RCS file: /cvsroot/src/sbin/restore/interactive.c,v
retrieving revision 1.19
diff -u -r1.19 interactive.c
--- ./sbin/restore/interactive.c 7 Aug 2003 10:04:37 -0000 1.19
+++ ./sbin/restore/interactive.c 3 Jan 2005 17:21:23 -0000
@@ -135,6 +135,8 @@
ino = dirlookup(name);
if (ino == 0)
break;
+ if (ino == ROOTINO)
+ dotflag = 1;
if (mflag)
pathcheck(name);
treescan(name, ino, addfile);
Index: ./sbin/restore/main.c
===================================================================
RCS file: /cvsroot/src/sbin/restore/main.c,v
retrieving revision 1.28
diff -u -r1.28 main.c
--- ./sbin/restore/main.c 24 Oct 2004 17:01:07 -0000 1.28
+++ ./sbin/restore/main.c 3 Jan 2005 17:21:24 -0000
@@ -76,6 +76,7 @@
size_t pagesize;
FILE *terminal;
char *tmpdir;
+int dotflag = 0;
FILE *Mtreefile = NULL;
@@ -285,6 +286,8 @@
ino = dirlookup(name);
if (ino == 0)
continue;
+ if (ino == ROOTINO)
+ dotflag = 1;
if (mflag)
pathcheck(name);
treescan(name, ino, addfile);
Index: ./sbin/restore/restore.h
===================================================================
RCS file: /cvsroot/src/sbin/restore/restore.h,v
retrieving revision 1.16
diff -u -r1.16 restore.h
--- ./sbin/restore/restore.h 22 Oct 2004 22:38:38 -0000 1.16
+++ ./sbin/restore/restore.h 3 Jan 2005 17:21:24 -0000
@@ -49,6 +49,7 @@
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 */
+extern int dotflag; /* restore owner/mode of "." directory */
/*
* Global variables
*/
Comments?
Frederick