summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrm88369 <none@none>2005-08-25 16:24:46 -0700
committerrm88369 <none@none>2005-08-25 16:24:46 -0700
commit33a5e6b27fde6c2d7434c79c15232c335e18950e (patch)
treeec8a91b44e3a8f2e88a014131bcd994e5a563c3e
parent75c9565f0e02b3ffdf937512899b7a4102f7a2a7 (diff)
downloadillumos-joyent-33a5e6b27fde6c2d7434c79c15232c335e18950e.tar.gz
6264883 ufsrestore with the "l" and "t" works incorrectly
-rw-r--r--usr/src/cmd/backup/restore/dirs.c7
-rw-r--r--usr/src/cmd/backup/restore/main.c4
-rw-r--r--usr/src/cmd/backup/restore/restore.h7
-rw-r--r--usr/src/cmd/backup/restore/tape.c25
4 files changed, 27 insertions, 16 deletions
diff --git a/usr/src/cmd/backup/restore/dirs.c b/usr/src/cmd/backup/restore/dirs.c
index 5c39236dd2..7244c40295 100644
--- a/usr/src/cmd/backup/restore/dirs.c
+++ b/usr/src/cmd/backup/restore/dirs.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 1996-2001 by Sun Microsystems, Inc.
- * All rights reserved.
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
@@ -957,8 +957,7 @@ void
done(exitcode)
int exitcode;
{
-
- closemt();
+ closemt(ALLOW_OFFLINE); /* don't force offline on exit */
if (modefile[0] != '#')
(void) unlink(modefile);
if (dirfile[0] != '#')
diff --git a/usr/src/cmd/backup/restore/main.c b/usr/src/cmd/backup/restore/main.c
index b1dc21fb9d..9903c4ee04 100644
--- a/usr/src/cmd/backup/restore/main.c
+++ b/usr/src/cmd/backup/restore/main.c
@@ -1,5 +1,5 @@
/*
- * Copyright 1998, 2001-2003 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -227,7 +227,7 @@ If set, the envar TMPDIR selects where temporary files are kept\n"),
break;
case 'l':
autoload++;
- /*FALLTHROUGH*/
+ break;
case 'o':
offline++;
break;
diff --git a/usr/src/cmd/backup/restore/restore.h b/usr/src/cmd/backup/restore/restore.h
index 1151d07939..9b6b5b9dc3 100644
--- a/usr/src/cmd/backup/restore/restore.h
+++ b/usr/src/cmd/backup/restore/restore.h
@@ -8,7 +8,7 @@
/* All Rights Reserved */
/*
- * Copyright 1994, 1996, 1998-2003 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -274,7 +274,7 @@ extern void getfile(void (*)(char *, size_t), void (*)(char *, size_t));
extern void null(char *, size_t);
extern void findtapeblksize(int);
extern void flsht(void);
-extern void closemt(void);
+extern void closemt(int);
extern int readhdr(struct s_spcl *);
extern int gethead(struct s_spcl *);
extern int volnumber(ino_t);
@@ -414,6 +414,9 @@ extern int complexcopy();
#define GOOD 1
#define FAIL 0
+#define ALLOW_OFFLINE 0
+#define FORCE_OFFLINE 1 /* offline drive for autoload */
+
#define DEF_PAGER "/usr/bin/more"
#ifdef __cplusplus
diff --git a/usr/src/cmd/backup/restore/tape.c b/usr/src/cmd/backup/restore/tape.c
index 9b2746d859..9bee27344e 100644
--- a/usr/src/cmd/backup/restore/tape.c
+++ b/usr/src/cmd/backup/restore/tape.c
@@ -8,7 +8,7 @@
/* All Rights Reserved */
/*
- * Copyright 1994, 1996, 1998-2003 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -556,7 +556,7 @@ with the last volume and work towards the first.\n"));
tapesread[volno-1]++;
return;
}
- closemt();
+ closemt(ALLOW_OFFLINE);
/*
* XXX: if we are switching devices, we should probably try
* the device once without prompting to enable unattended
@@ -1748,19 +1748,26 @@ flsht()
void
#ifdef __STDC__
-closemt(void)
+closemt(int mode)
#else
-closemt()
+closemt(mode)
+ int mode;
#endif
{
+ /*
+ * If mode == FORCE_OFFLINE then we're not done but
+ * we need to change tape. So, rewind and unload current
+ * tape before loading the new one.
+ */
+
static struct mtop mtop = { MTOFFL, 0 };
if (mt < 0)
return;
- if (offline)
+ if (offline || mode == FORCE_OFFLINE)
(void) fprintf(stderr, gettext("Rewinding tape\n"));
if (host) {
- if (offline)
+ if (offline || mode == FORCE_OFFLINE)
(void) rmtioctl(MTOFFL, 1);
rmtclose();
} else if (pipein) {
@@ -1776,7 +1783,7 @@ closemt()
* Only way to tell if this is a floppy is to issue an ioctl
* but why waste one - if the eject fails, tough!
*/
- if (offline)
+ if (offline || mode == FORCE_OFFLINE)
(void) ioctl(mt, MTIOCTOP, &mtop);
(void) ioctl(mt, FDEJECT, 0);
(void) close(mt);
@@ -2146,7 +2153,9 @@ autoload_tape()
* for the open to fail (measured at 21 seconds for an
* Exabyte 8200 under 2.7 on an Ultra 2).
*/
- closemt();
+
+ /* rewind tape and offline drive before loading new tape */
+ closemt(FORCE_OFFLINE);
(void) fprintf(stderr,
gettext("Attempting to autoload next volume\n"));
for (tries = 0; tries < autoload_tries; tries++) {