Add a new option "e" to "dump" which allows to eject tapes automatically

if a tape change is required.
This commit is contained in:
tron 2001-05-07 21:17:48 +00:00
parent 9e29be957a
commit d6be44d3c8
4 changed files with 25 additions and 8 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: dump.8,v 1.34 1999/07/01 19:18:47 abs Exp $
.\" $NetBSD: dump.8,v 1.35 2001/05/07 21:17:48 tron Exp $
.\"
.\" Copyright (c) 1980, 1991, 1993
.\" Regents of the University of California.
@ -43,7 +43,7 @@
.Nd filesystem backup
.Sh SYNOPSIS
.Nm ""
.Op Fl 0123456789cnSu
.Op Fl 0123456789cenSu
.Op Fl B Ar records
.Op Fl b Ar blocksize
.Op Fl d Ar density
@ -125,6 +125,8 @@ appropriate for cartridge tapes.
Set tape density to
.Ar density .
The default is 1600 Bits Per Inch (BPI).
.It Fl e
Eject tape automatically if a tape change is required.
.It Fl f Ar file
Write the backup to
.Ar file ;

View File

@ -1,4 +1,4 @@
/* $NetBSD: dump.h,v 1.23 2001/02/04 21:37:29 christos Exp $ */
/* $NetBSD: dump.h,v 1.24 2001/05/07 21:17:48 tron Exp $ */
/*-
* Copyright (c) 1980, 1993
@ -97,6 +97,7 @@ char *temp; /* name of the file for doing rewrite of dumpdates */
char lastlevel; /* dump level of previous dump */
char level; /* dump level of this dump */
int uflag; /* update flag */
int eflag; /* eject flag */
int diskfd; /* disk file descriptor */
int tapefd; /* tape file descriptor */
int pipeout; /* true => output to standard output */

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.27 2000/12/13 22:45:12 scw Exp $ */
/* $NetBSD: main.c,v 1.28 2001/05/07 21:17:48 tron 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.27 2000/12/13 22:45:12 scw Exp $");
__RCSID("$NetBSD: main.c,v 1.28 2001/05/07 21:17:48 tron Exp $");
#endif
#endif /* not lint */
@ -134,7 +134,7 @@ main(argc, argv)
obsolete(&argc, &argv);
while ((ch = getopt(argc, argv,
"0123456789B:b:cd:f:h:k:L:nr:s:ST:uWw")) != -1)
"0123456789B:b:cd:ef:h:k:L:nr:s:ST:uWw")) != -1)
switch (ch) {
/* dump level */
case '0': case '1': case '2': case '3': case '4':
@ -161,6 +161,10 @@ main(argc, argv)
ntrec = HIGHDENSITYTREC;
break;
case 'e': /* eject full tapes */
eflag = 1;
break;
case 'f': /* output file */
tape = optarg;
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: tape.c,v 1.23 2000/10/11 20:25:29 he Exp $ */
/* $NetBSD: tape.c,v 1.24 2001/05/07 21:17:48 tron 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.23 2000/10/11 20:25:29 he Exp $");
__RCSID("$NetBSD: tape.c,v 1.24 2001/05/07 21:17:48 tron Exp $");
#endif
#endif /* not lint */
@ -54,6 +54,8 @@ __RCSID("$NetBSD: tape.c,v 1.23 2000/10/11 20:25:29 he Exp $");
#else
#include <ufs/ufs/dinode.h>
#endif
#include <sys/ioctl.h>
#include <sys/mtio.h>
#include <protocols/dumprestore.h>
@ -424,6 +426,14 @@ trewind()
(void) close(tapefd);
while ((f = open(tape, 0)) < 0)
sleep (10);
if (eflag) {
struct mtop offl;
msg("Ejecting %s\n", tape);
offl.mt_op = MTOFFL;
offl.mt_count = 0;
(void) ioctl(f, MTIOCTOP, &offl);
}
(void) close(f);
}