summaryrefslogtreecommitdiff
path: root/sbin/restore
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-06-17 09:06:30 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-06-17 09:06:30 +0000
commitccb6860367246380243bb414f644853b908a31ee (patch)
tree3827f895a19cfe450bc12629477a6cb2f2eef2cd /sbin/restore
parentdf1b0a5d93b83bf318a7669ab80f477a8a8c9eb6 (diff)
updated patch from lukem@supp.cpr.itg.telecom.com.au to also make -r and -R work again
Diffstat (limited to 'sbin/restore')
-rw-r--r--sbin/restore/dirs.c39
-rw-r--r--sbin/restore/restore.822
2 files changed, 47 insertions, 14 deletions
diff --git a/sbin/restore/dirs.c b/sbin/restore/dirs.c
index 377f1f983ca..94138339be2 100644
--- a/sbin/restore/dirs.c
+++ b/sbin/restore/dirs.c
@@ -151,12 +151,15 @@ extractdirs(genmode)
struct direct nulldir;
vprintf(stdout, "Extract directories from tape\n");
- (void) sprintf(dirfile, "%s/rstdir%d-XXXXXX", _PATH_TMP, dumpdate);
- if (mktemp(dirfile) == NULL) {
- fprintf(stderr,
- "restore: %s - cannot generate directory temporary\n",
- dirfile);
- exit(1);
+ (void) sprintf(dirfile, "%s/rstdir%d", _PATH_TMP, dumpdate);
+ if (command != 'r' && command != 'R') {
+ (void *) strcat(dirfile, "-XXXXXX");
+ if (mktemp(dirfile) == NULL) {
+ fprintf(stderr,
+ "restore: %s - cannot mktemp directory temporary\n",
+ dirfile);
+ exit(1);
+ }
}
df = fopen(dirfile, "w");
if (df == NULL) {
@@ -167,13 +170,15 @@ extractdirs(genmode)
exit(1);
}
if (genmode != 0) {
- (void) sprintf(modefile, "%s/rstmode%d-XXXXXX", _PATH_TMP,
- dumpdate);
- if (mktemp(modefile) == NULL) {
- fprintf(stderr,
- "restore: %s - cannot generate modefile\n",
- modefile);
- exit(1);
+ (void) sprintf(modefile, "%s/rstmode%d", _PATH_TMP, dumpdate);
+ if (command != 'r' && command != 'R') {
+ (void *) strcat(modefile, "-XXXXXX");
+ if (mktemp(modefile) == NULL) {
+ fprintf(stderr,
+ "restore: %s - cannot mktemp modefile\n",
+ modefile);
+ exit(1);
+ }
}
mf = fopen(modefile, "w");
if (mf == NULL) {
@@ -604,7 +609,13 @@ setdirmodes(flags)
char *cp;
vprintf(stdout, "Set directory mode, owner, and times.\n");
- (void) sprintf(modefile, "%s/rstmode%d", _PATH_TMP, dumpdate);
+ if (command == 'r' || command == 'R')
+ (void) sprintf(modefile, "%s/rstmode%d", _PATH_TMP, dumpdate);
+ if (modefile[0] == '#') {
+ panic("modefile not defined\n");
+ fprintf(stderr, "directory mode, owner, and times not set\n");
+ return;
+ }
mf = fopen(modefile, "r");
if (mf == NULL) {
fprintf(stderr, "fopen: %s\n", strerror(errno));
diff --git a/sbin/restore/restore.8 b/sbin/restore/restore.8
index dc129143207..088ccb3efdc 100644
--- a/sbin/restore/restore.8
+++ b/sbin/restore/restore.8
@@ -423,6 +423,28 @@ it has no control over inode allocation;
thus a full dump must be done to get a new set of directories
reflecting the new inode numbering,
even though the contents of the files is unchanged.
+.Pp
+The temporary files
+.Pa /tmp/rstdir*
+and
+.Pa /tmp/rstmode*
+are generated with a unique name based on the date of the dump
+and the process ID (see
+.Xr mktemp 3 ),
+except for when
+.Fl r
+or
+.Fl R
+is used.
+Because
+.Fl R
+allows you to restart a
+.Fl r
+operation that may have been interrupted, the temporary files should
+be the same across different processes.
+In all other cases, the files are unique because it is possible to
+have two different dumps started at the same time, and separate
+operations shouldn't conflict with each other.
.Sh HISTORY
The
.Nm restore