Add -a to "auto-size" the tape, rather than relying upon other options

to define the tape size.  Requires the tape driver to either return ENOSPC
at end of media, or 0 when a write is attempted (such as the "early warning"
support in st(4) enabled with "mt eew 1").   From FreeBSD.
This commit is contained in:
lukem 2001-12-30 04:03:16 +00:00
parent e7408f3af1
commit 9dcaec9cca
4 changed files with 58 additions and 19 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: dump.8,v 1.43 2001/12/14 14:43:33 bouyer Exp $
.\" $NetBSD: dump.8,v 1.44 2001/12/30 04:03:16 lukem Exp $
.\"
.\" Copyright (c) 1980, 1991, 1993
.\" Regents of the University of California.
@ -34,7 +34,7 @@
.\"
.\" @(#)dump.8 8.3 (Berkeley) 5/1/95
.\"
.Dd November 16, 2001
.Dd December 30, 2001
.Dt DUMP 8
.Os
.Sh NAME
@ -43,17 +43,37 @@
.Nd file system backup
.Sh SYNOPSIS
.Nm ""
.Op Fl 0123456789ceFlnStu
.Op Fl 0123456789aceFlnStu
.Bk -words
.Op Fl B Ar records
.Ek
.Bk -words
.Op Fl b Ar blocksize
.Ek
.Bk -words
.Op Fl d Ar density
.Ek
.Bk -words
.Op Fl f Ar file
.Ek
.Bk -words
.Op Fl h Ar level
.Op Fl k Ar read blocksize
.Ek
.Bk -words
.Op Fl k Ar read-blocksize
.Ek
.Bk -words
.Op Fl L Ar label
.Ek
.Bk -words
.Op Fl r Ar cachesize
.Ek
.Bk -words
.Op Fl s Ar feet
.Ek
.Bk -words
.Op Fl T Ar date
.Ek
.Ar files-to-dump
.Nm ""
.Op Fl W Li \&| Fl w
@ -75,6 +95,11 @@ A dump that is larger than the output medium is broken into
multiple volumes.
On most media the size is determined by writing until an
end-of-media indication is returned.
This can be enforced
by using the
.Fl a
option.
.Pp
On media that cannot reliably return an end-of-media indication
(such as some cartridge tape drives)
each volume is of a fixed size;
@ -118,6 +143,14 @@ tells dump to
copy all files new or modified since the
last dump of a lower level.
The default level is 9.
.It Fl a
.Dq auto-size .
Bypass all tape length considerations, and enforce writing
until an end-of-media indication is returned.
This fits best for most modern tape drives.
Use of this option is particularly recommended when appending to an
existing tape, or using a tape drive with hardware compression (where
you can never be sure about the compression ratio).
.It Fl B Ar records
The number of kilobytes per volume, rounded
down to a multiple of the blocksize.

View File

@ -1,4 +1,4 @@
/* $NetBSD: dump.h,v 1.32 2001/12/25 12:06:26 lukem Exp $ */
/* $NetBSD: dump.h,v 1.33 2001/12/30 04:03:16 lukem Exp $ */
/*-
* Copyright (c) 1980, 1993
@ -109,6 +109,7 @@ long tsize; /* tape size in 0.1" units */
long asize; /* number of 0.1" units written on current tape */
int etapes; /* estimated number of tapes */
int nonodump; /* if set, do not honor UF_NODUMP user flags */
int unlimited; /* if set, write to end of medium */
extern int density; /* density in 0.1" units */
extern int notify; /* notify operator flag */

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.48 2001/12/25 12:06:26 lukem Exp $ */
/* $NetBSD: main.c,v 1.49 2001/12/30 04:03:17 lukem 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.48 2001/12/25 12:06:26 lukem Exp $");
__RCSID("$NetBSD: main.c,v 1.49 2001/12/30 04:03:17 lukem Exp $");
#endif
#endif /* not lint */
@ -140,7 +140,7 @@ main(int argc, char *argv[])
obsolete(&argc, &argv);
while ((ch = getopt(argc, argv,
"0123456789B:b:cd:eFf:h:k:lL:nr:s:StT:uWw")) != -1)
"0123456789aB: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':
@ -148,6 +148,10 @@ main(int argc, char *argv[])
level = ch;
break;
case 'a': /* `auto-size', Write to EOM. */
unlimited = 1;
break;
case 'B': /* blocks per output file */
blocksperfile = numarg("blocks per file", 1L, 0L);
break;
@ -336,7 +340,7 @@ main(int argc, char *argv[])
if (blocksperfile)
blocksperfile = blocksperfile / ntrec * ntrec; /* round down */
else {
else if (!unlimited) {
/*
* Determine how to default tape size and density
*
@ -474,7 +478,7 @@ main(int argc, char *argv[])
anydirskipped = mapdirs(maxino, &tapesize);
}
if (pipeout) {
if (pipeout || unlimited) {
tapesize += 10; /* 10 trailer blocks */
msg("estimated %ld tape blocks.\n", tapesize);
} else {
@ -602,12 +606,13 @@ main(int argc, char *argv[])
static void
usage(void)
{
const char *prog = getprogname();
(void)fprintf(stderr, "%s\n%s\n%s\n%s\n",
"usage: dump [-0123456789ceFlnStu] [-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]");
(void)fprintf(stderr,
"usage: %s [-0123456789aceFlnStu] [-B records] [-b blocksize]\n"
" [-d density] [-f file] [-h level] [-k read-blocksize]\n"
" [-L label] [-r read-cache] [-s feet] [-T date] files-to-dump\n"
" %s [-W | -w]\n", prog, prog);
exit(X_STARTUP);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: tape.c,v 1.35 2001/12/25 12:06:26 lukem Exp $ */
/* $NetBSD: tape.c,v 1.36 2001/12/30 04:03:17 lukem 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.35 2001/12/25 12:06:26 lukem Exp $");
__RCSID("$NetBSD: tape.c,v 1.36 2001/12/30 04:03:17 lukem Exp $");
#endif
#endif /* not lint */
@ -143,7 +143,7 @@ alloctape(void)
* repositioning after stopping, i.e, streaming mode, where the gap is
* variable, 0.30" to 0.45". The gap is maximal when the tape stops.
*/
if (blocksperfile == 0)
if (blocksperfile == 0 && !unlimited)
tenths = writesize / density +
(cartridge ? 16 : density == 625 ? 5 : 8);
/*
@ -351,7 +351,7 @@ flushtape(void)
asize += tenths;
blockswritten += ntrec;
blocksthisvol += ntrec;
if (!pipeout && (blocksperfile ?
if (!pipeout && !unlimited && (blocksperfile ?
(blocksthisvol >= blocksperfile) : (asize > tsize))) {
close_rewind();
startnewtape(0);