Subject: restore & file flags
To: None <tech-userlevel@netbsd.org>
From: Manuel Bouyer <bouyer@antioche.lip6.fr>
List: tech-userlevel
Date: 05/03/2000 12:12:16
--IJpNTDwzlM2Ie8A6
Content-Type: text/plain; charset=us-ascii
Hi,
I've been hit by a problem with restore today: I've some dump of a system
where most files have the schg flag set. When restoring these dumps,
restore sets the schg flag when a file is extracted, which prevent
hard links to this file and cause restore to fail later.
One can easily immagine another failure case, involving incrmental dumps.
To solve this problem I changed restore (see attached patch) to not restore
file flags, unless the '-o' flag has been passed. If noone object in the next
few days I'll commit this change.
--
Manuel Bouyer, LIP6, Universite Paris VI. Manuel.Bouyer@lip6.fr
--
--IJpNTDwzlM2Ie8A6
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=diff
Index: dirs.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/restore/dirs.c,v
retrieving revision 1.33
diff -u -r1.33 dirs.c
--- dirs.c 1998/05/12 00:42:48 1.33
+++ dirs.c 2000/05/03 10:07:13
@@ -644,7 +644,8 @@
(void) utimes(cp, node.timep);
(void) chown(cp, node.uid, node.gid);
(void) chmod(cp, node.mode);
- (void) chflags(cp, node.flags);
+ if (oflag)
+ (void) chflags(cp, node.flags);
}
ep->e_flags &= ~NEW;
}
Index: main.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/restore/main.c,v
retrieving revision 1.19
diff -u -r1.19 main.c
--- main.c 1999/11/09 15:06:33 1.19
+++ main.c 2000/05/03 10:07:24
@@ -69,7 +69,7 @@
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;
@@ -105,7 +105,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. */
@@ -145,6 +145,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);
@@ -293,19 +296,21 @@
{
(void)fprintf(stderr,
- "usage: %s -i [-cdhmvyN] [-b blocksize] [-f file] [-s fileno]\n",
+ "usage: %s -i [-cdhmvyNo] [-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 [-cdvyNo] [-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 [-cdvyNo] [-b blocksize] [-f file] [-s fileno]\n",
__progname);
(void)fprintf(stderr,
- "\t%s -t [-cdhvy] [-b blocksize] [-f file] [-s fileno] [file ...]\n",
+ "\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 [-cdhmvyNo] [-b blocksize] [-f file] [-s fileno] "
+ "[file ...]\n",
__progname);
exit(1);
}
Index: restore.8
===================================================================
RCS file: /cvsroot/basesrc/sbin/restore/restore.8,v
retrieving revision 1.29
diff -u -r1.29 restore.8
--- restore.8 1999/11/19 01:47:13 1.29
+++ restore.8 2000/05/03 10:07:24
@@ -43,19 +43,19 @@
.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
-.Op Fl cduvyN
+.Op Fl cduvyNo
.Op Fl b Ar blocksize
.Op Fl f Ar file
.Op Fl s Ar fileno
.Nm ""
.Fl r
-.Op Fl cduvyN
+.Op Fl cduvyNo
.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 cdhmuvyNo
.Op Fl b Ar blocksize
.Op Fl f Ar file
.Op Fl s Ar fileno
@@ -333,6 +333,17 @@
.Ar fileno
on a multi-file tape.
File numbering starts at 1.
+.It Fl o
+Normally
+.Nm
+doesn't restore file flags, as the immutable or append-only flag may prevent
+.Nm
+from extracting the next incremental backup, or doing hard links.
+The
+.Fl o
+flag cause
+.Nm
+to restore file flags.
.It Fl u
The
.Fl u
Index: restore.h
===================================================================
RCS file: /cvsroot/basesrc/sbin/restore/restore.h,v
retrieving revision 1.10
diff -u -r1.10 restore.h
--- restore.h 1998/06/24 19:56:11 1.10
+++ restore.h 2000/05/03 10:07:24
@@ -49,6 +49,7 @@
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; /* set file flags */
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 */
Index: tape.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/restore/tape.c,v
retrieving revision 1.39
diff -u -r1.39 tape.c
--- tape.c 2000/01/27 15:25:00 1.39
+++ tape.c 2000/05/03 10:07:24
@@ -597,7 +597,8 @@
(void) utimes(name, timep);
(void) chown(name, uid, gid);
(void) chmod(name, mode);
- (void) chflags(name, flags);
+ if (oflag)
+ (void) chflags(name, flags);
return (GOOD);
case IFIFO:
@@ -618,7 +619,8 @@
(void) utimes(name, timep);
(void) chown(name, uid, gid);
(void) chmod(name, mode);
- (void) chflags(name, flags);
+ if (oflag)
+ (void) chflags(name, flags);
return (GOOD);
case IFREG:
@@ -640,7 +642,8 @@
(void) futimes(ofile, timep);
(void) fchown(ofile, uid, gid);
(void) fchmod(ofile, mode);
- (void) fchflags(ofile, flags);
+ if (oflag)
+ (void) fchflags(ofile, flags);
(void) close(ofile);
return (GOOD);
}
--IJpNTDwzlM2Ie8A6--