Add a -l (autoload) flag. For multivolume dumps, this makes dump eject the

tape when a volume is full, and try to reopen the tape drive for 2 mn.
To be used with tape changers which load the next tape when the current one is
ejected.
While I'm there fix eject handling for remote tape.
This commit is contained in:
bouyer 2001-12-14 14:43:33 +00:00
parent 342a82f2dd
commit 740dbf0d62
5 changed files with 68 additions and 30 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: dump.8,v 1.42 2001/12/07 19:53:44 wiz Exp $
.\" $NetBSD: dump.8,v 1.43 2001/12/14 14:43:33 bouyer Exp $
.\"
.\" Copyright (c) 1980, 1991, 1993
.\" Regents of the University of California.
@ -43,7 +43,7 @@
.Nd file system backup
.Sh SYNOPSIS
.Nm ""
.Op Fl 0123456789ceFnStu
.Op Fl 0123456789ceFlnStu
.Op Fl B Ar records
.Op Fl b Ar blocksize
.Op Fl d Ar density
@ -187,6 +187,14 @@ but full backups retain them.
.It Fl k Ar read blocksize
The size in kilobyte of the read buffers, rounded up to a multiple of the
file system block size. Default is 32k.
.It Fl l
If a tape change is required, eject the tape and wait for the drive to
be ready again. This is to be used with tape changers which automatically load
the next tape when the tape is ejected. If after 2 minutes the drive is not
ready
.Nm
falls back to the default behavior, and prompts the operator for the next
tape.
.It Fl L Ar label
The user-supplied text string
.Ar label

View File

@ -1,4 +1,4 @@
/* $NetBSD: dump.h,v 1.29 2001/10/15 13:25:34 blymn Exp $ */
/* $NetBSD: dump.h,v 1.30 2001/12/14 14:43:33 bouyer Exp $ */
/*-
* Copyright (c) 1980, 1993
@ -98,6 +98,7 @@ char lastlevel; /* dump level of previous dump */
char level; /* dump level of this dump */
int uflag; /* update flag */
int eflag; /* eject flag */
int lflag; /* autoload flag */
int diskfd; /* disk file descriptor */
int tapefd; /* tape file descriptor */
int pipeout; /* true => output to standard output */
@ -211,8 +212,9 @@ char *xstrdup(const char *);
#if defined(RDUMP) || defined(RRESTORE)
void rmtclose(void);
int rmthost(char *);
int rmtopen(char *, int);
int rmtopen(char *, int, int);
int rmtwrite(char *, int);
int rmtioctl(int, int);
#endif /* RDUMP || RRESTORE */
void interrupt(int); /* in case operator bangs on console */

View File

@ -1,4 +1,4 @@
/* $NetBSD: dumprmt.c,v 1.26 2001/11/01 08:03:03 lukem Exp $ */
/* $NetBSD: dumprmt.c,v 1.27 2001/12/14 14:43:33 bouyer Exp $ */
/*-
* Copyright (c) 1980, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)dumprmt.c 8.3 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: dumprmt.c,v 1.26 2001/11/01 08:03:03 lukem Exp $");
__RCSID("$NetBSD: dumprmt.c,v 1.27 2001/12/14 14:43:33 bouyer Exp $");
#endif
#endif /* not lint */
@ -84,14 +84,13 @@ static int rmtape;
static char *rmtpeer;
static int okname(char *);
static int rmtcall(char *, char *);
static int rmtcall(char *, char *, int);
static void rmtconnaborted(int);
static int rmtgetb(void);
static void rmtgetconn(void);
static void rmtgets(char *, int);
int rmtioctl(int, int);
int rmtread(char *, int);
static int rmtreply(char *);
static int rmtreply(char *, int);
int rmtseek(int, int);
extern int ntrec; /* blocking factor on tape */
@ -184,13 +183,13 @@ okname(char *cp0)
}
int
rmtopen(char *tapedevice, int mode)
rmtopen(char *tapedevice, int mode, int verbose)
{
char buf[256];
(void)snprintf(buf, sizeof buf, "O%s\n%d\n", tapedevice, mode);
rmtstate = TS_OPEN;
return (rmtcall(tapedevice, buf));
return (rmtcall(tapedevice, buf, verbose));
}
void
@ -199,7 +198,7 @@ rmtclose(void)
if (rmtstate != TS_OPEN)
return;
rmtcall("close", "C\n");
rmtcall("close", "C\n", 1);
rmtstate = TS_CLOSED;
}
@ -210,7 +209,7 @@ rmtread(char *buf, int count)
int n, i, cc;
(void)snprintf(line, sizeof line, "R%d\n", count);
n = rmtcall("read", line);
n = rmtcall("read", line, 1);
if (n < 0) {
errno = n;
return (-1);
@ -232,7 +231,7 @@ rmtwrite(char *buf, int count)
(void)snprintf(line, sizeof line, "W%d\n", count);
write(rmtape, line, strlen(line));
write(rmtape, buf, count);
return (rmtreply("write"));
return (rmtreply("write", 1));
}
#if 0 /* XXX unused? */
@ -256,7 +255,7 @@ int
rmtwrite2(void)
{
return (rmtreply("write"));
return (rmtreply("write", 1));
}
#endif
@ -266,7 +265,7 @@ rmtseek(int offset, int pos)
char line[80];
(void)snprintf(line, sizeof line, "L%d\n%d\n", offset, pos);
return (rmtcall("seek", line));
return (rmtcall("seek", line, 1));
}
@ -280,7 +279,7 @@ rmtstatus(void)
if (rmtstate != TS_OPEN)
return (NULL);
rmtcall("status", "S\n");
rmtcall("status", "S\n", 1);
for (i = 0, cp = (char *)&mts; i < sizeof(mts); i++)
*cp++ = rmtgetb();
return (&mts);
@ -295,20 +294,20 @@ rmtioctl(int cmd, int count)
if (count < 0)
return (-1);
(void)snprintf(buf, sizeof buf, "I%d\n%d\n", cmd, count);
return (rmtcall("ioctl", buf));
return (rmtcall("ioctl", buf, 1));
}
static int
rmtcall(char *cmd, char *buf)
rmtcall(char *cmd, char *buf, int verbose)
{
if (write(rmtape, buf, strlen(buf)) != strlen(buf))
rmtconnaborted(0);
return (rmtreply(cmd));
return (rmtreply(cmd, verbose));
}
static int
rmtreply(char *cmd)
rmtreply(char *cmd, int verbose)
{
char *cp;
char code[30], emsg[BUFSIZ];
@ -316,7 +315,8 @@ rmtreply(char *cmd)
rmtgets(code, sizeof (code));
if (*code == 'E' || *code == 'F') {
rmtgets(emsg, sizeof (emsg));
msg("%s: %s", cmd, emsg);
if (verbose)
msg("%s: %s", cmd, emsg);
if (*code == 'F') {
rmtstate = TS_CLOSED;
return (-1);

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.40 2001/11/16 04:41:23 lukem Exp $ */
/* $NetBSD: main.c,v 1.41 2001/12/14 14:43:33 bouyer Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993, 1994
@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1991, 1993, 1994\n\
#if 0
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/1/95";
#else
__RCSID("$NetBSD: main.c,v 1.40 2001/11/16 04:41:23 lukem Exp $");
__RCSID("$NetBSD: main.c,v 1.41 2001/12/14 14:43:33 bouyer Exp $");
#endif
#endif /* not lint */
@ -146,7 +146,7 @@ main(int argc, char *argv[])
obsolete(&argc, &argv);
while ((ch = getopt(argc, argv,
"0123456789B:b:cd:eFf:h:k:L:nr:s:StT:uWw")) != -1)
"0123456789B:b:cd:eFf:h:k:lL:nr:s:StT:uWw")) != -1)
switch (ch) {
/* dump level */
case '0': case '1': case '2': case '3': case '4':
@ -193,6 +193,11 @@ main(int argc, char *argv[])
readblksize = numarg("read block size", 0, 64) * 1024;
break;
case 'l': /* autoload after eject full tapes */
eflag = 1;
lflag = 1;
break;
case 'L':
/*
* Note that although there are LBLSIZE characters,
@ -605,7 +610,7 @@ usage(void)
{
(void)fprintf(stderr, "%s\n%s\n%s\n%s\n",
"usage: dump [-0123456789ceFntu] [-B records] [-b blocksize] [-d density]",
"usage: dump [-0123456789ceFlntu] [-B records] [-b blocksize] [-d density]",
" [-f file] [-h level] [-k read block size] [-L label]",
" [-r read cache size] [-s feet] [-T date] file system",
" dump [-W | -w]");

View File

@ -1,4 +1,4 @@
/* $NetBSD: tape.c,v 1.30 2001/11/01 08:03:03 lukem Exp $ */
/* $NetBSD: tape.c,v 1.31 2001/12/14 14:43:34 bouyer Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)tape.c 8.4 (Berkeley) 5/1/95";
#else
__RCSID("$NetBSD: tape.c,v 1.30 2001/11/01 08:03:03 lukem Exp $");
__RCSID("$NetBSD: tape.c,v 1.31 2001/12/14 14:43:34 bouyer Exp $");
#endif
#endif /* not lint */
@ -404,8 +404,12 @@ trewind(int eject)
#ifdef RDUMP
if (host) {
rmtclose();
while (rmtopen(tape, 0) < 0)
while (rmtopen(tape, 0, 0) < 0)
sleep(10);
if (eflag && eject) {
msg("Ejecting %s\n", tape);
(void) rmtioctl(MTOFFL, 0);
}
rmtclose();
return;
}
@ -427,6 +431,8 @@ trewind(int eject)
void
close_rewind(void)
{
int i, f;
trewind(1);
(void)do_stats();
if (nexttape)
@ -435,6 +441,23 @@ close_rewind(void)
msg("Change Volumes: Mount volume #%d\n", tapeno+1);
broadcast("CHANGE DUMP VOLUMES!\7\7\n");
}
if (lflag) {
for (i = 0; i < 12; i++) { /* wait 2 mn */
if (host) {
if (rmtopen(tape, 0, 0) >= 0) {
rmtclose();
return;
}
} else {
if ((f = open(tape, 0)) >= 0) {
close(f);
return;
}
}
sleep (10);
}
}
while (!query("Is the new volume mounted and ready to go?"))
if (query("Do you want to abort?")) {
dumpabort(0);
@ -658,7 +681,7 @@ restore_check_point:
msg("Dumping volume %d on %s\n", tapeno, tape);
}
#ifdef RDUMP
while ((tapefd = (host ? rmtopen(tape, 2) :
while ((tapefd = (host ? rmtopen(tape, 2, 1) :
pipeout ? 1 : open(tape, O_WRONLY|O_CREAT, 0666))) < 0)
#else
while ((tapefd = (pipeout ? 1 :