Well, nobody objected, so here's my -u (unlink) flag to restore.
This commit is contained in:
parent
a6919ef89d
commit
2640840497
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=35852
@ -62,6 +62,7 @@ static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/4/95";
|
|||||||
|
|
||||||
int bflag = 0, cvtflag = 0, dflag = 0, vflag = 0, yflag = 0;
|
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;
|
||||||
|
int uflag = 0;
|
||||||
int dokerberos = 0;
|
int dokerberos = 0;
|
||||||
char command = '\0';
|
char command = '\0';
|
||||||
long dumpnum = 1;
|
long dumpnum = 1;
|
||||||
@ -98,9 +99,9 @@ main(argc, argv)
|
|||||||
inputdev = _PATH_DEFTAPE;
|
inputdev = _PATH_DEFTAPE;
|
||||||
obsolete(&argc, &argv);
|
obsolete(&argc, &argv);
|
||||||
#ifdef KERBEROS
|
#ifdef KERBEROS
|
||||||
#define optlist "b:cdf:hikmNRrs:tvxy"
|
#define optlist "b:cdf:hikmNRrs:tuvxy"
|
||||||
#else
|
#else
|
||||||
#define optlist "b:cdf:himNRrs:tvxy"
|
#define optlist "b:cdf:himNRrs:tuvxy"
|
||||||
#endif
|
#endif
|
||||||
while ((ch = getopt(argc, argv, optlist)) != -1)
|
while ((ch = getopt(argc, argv, optlist)) != -1)
|
||||||
switch(ch) {
|
switch(ch) {
|
||||||
@ -155,6 +156,9 @@ main(argc, argv)
|
|||||||
if (dumpnum <= 0)
|
if (dumpnum <= 0)
|
||||||
errx(1, "dump number must be greater than 0");
|
errx(1, "dump number must be greater than 0");
|
||||||
break;
|
break;
|
||||||
|
case 'u':
|
||||||
|
uflag = 1;
|
||||||
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
vflag = 1;
|
vflag = 1;
|
||||||
break;
|
break;
|
||||||
@ -289,11 +293,11 @@ static void
|
|||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
(void)fprintf(stderr, "usage:\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n",
|
(void)fprintf(stderr, "usage:\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n",
|
||||||
"restore -i [-chkmvy] [-b blocksize] [-f file] [-s fileno]",
|
"restore -i [-chkmuvy] [-b blocksize] [-f file] [-s fileno]",
|
||||||
"restore -r [-ckvy] [-b blocksize] [-f file] [-s fileno]",
|
"restore -r [-ckuvy] [-b blocksize] [-f file] [-s fileno]",
|
||||||
"restore -R [-ckvy] [-b blocksize] [-f file] [-s fileno]",
|
"restore -R [-ckuvy] [-b blocksize] [-f file] [-s fileno]",
|
||||||
"restore -x [-chkmvy] [-b blocksize] [-f file] [-s fileno] [file ...]",
|
"restore -x [-chkmuvy] [-b blocksize] [-f file] [-s fileno] [file ...]",
|
||||||
"restore -t [-chkvy] [-b blocksize] [-f file] [-s fileno] [file ...]");
|
"restore -t [-chkuvy] [-b blocksize] [-f file] [-s fileno] [file ...]");
|
||||||
done(1);
|
done(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.\" @(#)restore.8 8.4 (Berkeley) 5/1/95
|
.\" @(#)restore.8 8.4 (Berkeley) 5/1/95
|
||||||
.\" $Id: restore.8,v 1.10 1997/03/11 12:55:16 peter Exp $
|
.\" $Id: restore.8,v 1.11 1997/04/29 17:48:58 wollman Exp $
|
||||||
.\"
|
.\"
|
||||||
.Dd May 1, 1995
|
.Dd May 1, 1995
|
||||||
.Dt RESTORE 8
|
.Dt RESTORE 8
|
||||||
@ -41,32 +41,32 @@
|
|||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm restore
|
.Nm restore
|
||||||
.Fl i
|
.Fl i
|
||||||
.Op Fl chkmvy
|
.Op Fl chkmuvy
|
||||||
.Op Fl b Ar blocksize
|
.Op Fl b Ar blocksize
|
||||||
.Op Fl f Ar file
|
.Op Fl f Ar file
|
||||||
.Op Fl s Ar fileno
|
.Op Fl s Ar fileno
|
||||||
.Nm restore
|
.Nm restore
|
||||||
.Fl R
|
.Fl R
|
||||||
.Op Fl ckvy
|
.Op Fl ckuvy
|
||||||
.Op Fl b Ar blocksize
|
.Op Fl b Ar blocksize
|
||||||
.Op Fl f Ar file
|
.Op Fl f Ar file
|
||||||
.Op Fl s Ar fileno
|
.Op Fl s Ar fileno
|
||||||
.Nm restore
|
.Nm restore
|
||||||
.Fl r
|
.Fl r
|
||||||
.Op Fl ckvy
|
.Op Fl ckuvy
|
||||||
.Op Fl b Ar blocksize
|
.Op Fl b Ar blocksize
|
||||||
.Op Fl f Ar file
|
.Op Fl f Ar file
|
||||||
.Op Fl s Ar fileno
|
.Op Fl s Ar fileno
|
||||||
.Nm restore
|
.Nm restore
|
||||||
.Fl t
|
.Fl t
|
||||||
.Op Fl chkvy
|
.Op Fl chkuvy
|
||||||
.Op Fl b Ar blocksize
|
.Op Fl b Ar blocksize
|
||||||
.Op Fl f Ar file
|
.Op Fl f Ar file
|
||||||
.Op Fl s Ar fileno
|
.Op Fl s Ar fileno
|
||||||
.Op file ...
|
.Op file ...
|
||||||
.Nm restore
|
.Nm restore
|
||||||
.Fl x
|
.Fl x
|
||||||
.Op Fl chkmvy
|
.Op Fl chkmuvy
|
||||||
.Op Fl b Ar blocksize
|
.Op Fl b Ar blocksize
|
||||||
.Op Fl f Ar file
|
.Op Fl f Ar file
|
||||||
.Op Fl s Ar fileno
|
.Op Fl s Ar fileno
|
||||||
@ -316,6 +316,13 @@ Read from the specified
|
|||||||
.Ar fileno
|
.Ar fileno
|
||||||
on a multi-file tape.
|
on a multi-file tape.
|
||||||
File numbering starts at 1.
|
File numbering starts at 1.
|
||||||
|
.It Fl u
|
||||||
|
When creating certain types of files, restore may generate a warning
|
||||||
|
diagnostic if they already exist in the target directory.
|
||||||
|
To prevent this, the
|
||||||
|
.Fl u
|
||||||
|
(unlink) flag causes restore to remove old entries before attempting
|
||||||
|
to create new ones.
|
||||||
.It Fl v
|
.It Fl v
|
||||||
Normally
|
Normally
|
||||||
.Nm restore
|
.Nm restore
|
||||||
|
@ -47,6 +47,7 @@ extern int dflag; /* print out debugging info */
|
|||||||
extern int hflag; /* restore heirarchies */
|
extern int hflag; /* restore heirarchies */
|
||||||
extern int mflag; /* restore by name instead of inode number */
|
extern int mflag; /* restore by name instead of inode number */
|
||||||
extern int Nflag; /* do not write the disk */
|
extern int Nflag; /* do not write the disk */
|
||||||
|
extern int uflag; /* unlink symlink targets */
|
||||||
extern int vflag; /* print out actions taken */
|
extern int vflag; /* print out actions taken */
|
||||||
extern int yflag; /* always try to recover from tape errors */
|
extern int yflag; /* always try to recover from tape errors */
|
||||||
/*
|
/*
|
||||||
|
@ -566,6 +566,8 @@ extractfile(name)
|
|||||||
skipfile();
|
skipfile();
|
||||||
return (GOOD);
|
return (GOOD);
|
||||||
}
|
}
|
||||||
|
if (uflag && !Nflag)
|
||||||
|
(void)unlink(name);
|
||||||
if (mkfifo(name, mode) < 0) {
|
if (mkfifo(name, mode) < 0) {
|
||||||
fprintf(stderr, "%s: cannot create fifo: %s\n",
|
fprintf(stderr, "%s: cannot create fifo: %s\n",
|
||||||
name, strerror(errno));
|
name, strerror(errno));
|
||||||
@ -586,6 +588,8 @@ extractfile(name)
|
|||||||
skipfile();
|
skipfile();
|
||||||
return (GOOD);
|
return (GOOD);
|
||||||
}
|
}
|
||||||
|
if (uflag)
|
||||||
|
(void)unlink(name);
|
||||||
if (mknod(name, mode, (int)curfile.dip->di_rdev) < 0) {
|
if (mknod(name, mode, (int)curfile.dip->di_rdev) < 0) {
|
||||||
fprintf(stderr, "%s: cannot create special file: %s\n",
|
fprintf(stderr, "%s: cannot create special file: %s\n",
|
||||||
name, strerror(errno));
|
name, strerror(errno));
|
||||||
@ -605,6 +609,8 @@ extractfile(name)
|
|||||||
skipfile();
|
skipfile();
|
||||||
return (GOOD);
|
return (GOOD);
|
||||||
}
|
}
|
||||||
|
if (uflag)
|
||||||
|
(void)unlink(name);
|
||||||
if ((ofile = open(name, O_WRONLY | O_CREAT | O_TRUNC,
|
if ((ofile = open(name, O_WRONLY | O_CREAT | O_TRUNC,
|
||||||
0666)) < 0) {
|
0666)) < 0) {
|
||||||
fprintf(stderr, "%s: cannot create file: %s\n",
|
fprintf(stderr, "%s: cannot create file: %s\n",
|
||||||
|
@ -145,7 +145,7 @@ newnode(np)
|
|||||||
if (np->e_type != NODE)
|
if (np->e_type != NODE)
|
||||||
badentry(np, "newnode: not a node");
|
badentry(np, "newnode: not a node");
|
||||||
cp = myname(np);
|
cp = myname(np);
|
||||||
if (!Nflag && mkdir(cp, 0777) < 0) {
|
if (!Nflag && mkdir(cp, 0777) < 0 && !uflag) {
|
||||||
np->e_flags |= EXISTED;
|
np->e_flags |= EXISTED;
|
||||||
fprintf(stderr, "warning: %s: %s\n", cp, strerror(errno));
|
fprintf(stderr, "warning: %s: %s\n", cp, strerror(errno));
|
||||||
return;
|
return;
|
||||||
@ -206,6 +206,10 @@ linkit(existing, new, type)
|
|||||||
int type;
|
int type;
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/* if we want to unlink first, do it now so *link() won't fail */
|
||||||
|
if (uflag && !Nflag)
|
||||||
|
(void)unlink(new);
|
||||||
|
|
||||||
if (type == SYMLINK) {
|
if (type == SYMLINK) {
|
||||||
if (!Nflag && symlink(existing, new) < 0) {
|
if (!Nflag && symlink(existing, new) < 0) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
|
Loading…
Reference in New Issue
Block a user