From: deraadt Date: Mon, 3 Feb 1997 11:53:23 +0000 (+0000) Subject: new -a option autosizes, meaning it runs till it hits EOM (no need for X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=31ebca967e57c965a85916a9c7a3b5f7543926a7;p=openbsd new -a option autosizes, meaning it runs till it hits EOM (no need for pesky sizing options) -- from FreeBSD. also make -b option aware of MAXPHYS issues (via a little hack) --- diff --git a/sbin/dump/Makefile b/sbin/dump/Makefile index ff3b9a9f756..2257156bd72 100644 --- a/sbin/dump/Makefile +++ b/sbin/dump/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.4 1996/09/14 19:26:56 deraadt Exp $ +# $OpenBSD: Makefile,v 1.5 1997/02/03 11:53:23 deraadt Exp $ # $NetBSD: Makefile,v 1.16 1995/03/18 14:54:53 cgd Exp $ # dump.h header file @@ -16,7 +16,7 @@ PROG= dump LINKS= ${BINDIR}/dump ${BINDIR}/rdump CFLAGS+=-DRDUMP -SRCS= itime.c main.c optr.c dumprmt.c tape.c traverse.c unctime.c +SRCS= itime.c main.c optr.c dumprmt.c tape.c traverse.c unctime.c maxbsize.c MAN= dump.8 MLINKS+=dump.8 rdump.8 diff --git a/sbin/dump/dump.8 b/sbin/dump/dump.8 index 611efc43fe5..2d7f1a45d9b 100644 --- a/sbin/dump/dump.8 +++ b/sbin/dump/dump.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: dump.8,v 1.3 1996/06/23 14:30:09 deraadt Exp $ +.\" $OpenBSD: dump.8,v 1.4 1997/02/03 11:53:24 deraadt Exp $ .\" $NetBSD: dump.8,v 1.14 1996/02/05 23:59:37 mrg Exp $ .\" .\" Copyright (c) 1980, 1991, 1993 @@ -43,7 +43,7 @@ .Nd filesystem backup .Sh SYNOPSIS .Nm dump -.Op Fl 0123456789cnu +.Op Fl 0123456789cnua .Op Fl B Ar records .Op Fl b Ar blocksize .Op Fl d Ar density @@ -73,7 +73,11 @@ option below for doing remote backups). 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. +end-of-media indication is returned. This can be enforced +by using the +.Cm 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; @@ -102,8 +106,26 @@ The default level is 9. The number of kilobytes per volume, rounded down to a multiple of the blocksize. This option overrides the calculation of tape size +.It Cm 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). based on length and density. .It Fl b Ar blocksize +Since the IO system slices all requests into chunks of MAXBSIZE +(typically 64KB), it is not possible to use a larger blocksize +without having problems later with +.Xr restore 8 . +Therefore +.Nm +will constrain writes to MAXBSIZE. +.It Cm c +Change the defaults for use with a cartridge tape drive, with a density +of 8000 bpi, and a length of 1700 feet. The number of kilobytes per dump record. .It Fl c Modify the calculation of the default density and tape size to be more diff --git a/sbin/dump/dump.h b/sbin/dump/dump.h index 369e97cdcfa..b29ddac83af 100644 --- a/sbin/dump/dump.h +++ b/sbin/dump/dump.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dump.h,v 1.3 1996/09/01 13:12:35 deraadt Exp $ */ +/* $OpenBSD: dump.h,v 1.4 1997/02/03 11:53:25 deraadt Exp $ */ /* $NetBSD: dump.h,v 1.9 1995/03/18 14:54:57 cgd Exp $ */ /*- @@ -74,6 +74,7 @@ int newtape; /* new tape flag */ int density; /* density in 0.1" units */ long tapesize; /* estimated tape size, blocks */ long tsize; /* tape size in 0.1" units */ +int unlimited; /* if set, write to end of medium */ 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 */ diff --git a/sbin/dump/main.c b/sbin/dump/main.c index 7975d557052..04ca7018e3a 100644 --- a/sbin/dump/main.c +++ b/sbin/dump/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.11 1996/12/16 17:11:32 deraadt Exp $ */ +/* $OpenBSD: main.c,v 1.12 1997/02/03 11:53:25 deraadt Exp $ */ /* $NetBSD: main.c,v 1.8 1996/03/15 22:39:32 scottr Exp $ */ /*- @@ -94,6 +94,8 @@ static long numarg __P((char *, long, long)); static void obsolete __P((int *, char **[])); static void usage __P((void)); +extern int maxbsize; + int main(argc, argv) int argc; @@ -138,6 +140,11 @@ main(argc, argv) case 'b': /* blocks per tape write */ ntrec = numarg("blocks per write", 1L, 1000L); + if (ntrec > maxbsize/1024) { + msg("Please choose a blocksize <= %dKB\n", + maxbsize/1024); + exit(X_ABORT); + } break; case 'c': /* Tape is cart. not 9-track */ @@ -186,6 +193,10 @@ main(argc, argv) lastdump(ch); exit(0); /* do nothing else */ + case 'a': /* `auto-size', Write to EOM. */ + unlimited = 1; + break; + default: usage(); } @@ -217,7 +228,7 @@ main(argc, argv) if (blocksperfile) blocksperfile = blocksperfile / ntrec * ntrec; /* round down */ - else { + else if (!unlimited) { /* * Determine how to default tape size and density * @@ -334,7 +345,7 @@ main(argc, argv) anydirskipped = mapdirs(maxino, &tapesize); } - if (pipeout) { + if (pipeout || unlimited) { tapesize += 10; /* 10 trailer blocks */ msg("estimated %ld tape blocks.\n", tapesize); } else { diff --git a/sbin/dump/maxbsize.c b/sbin/dump/maxbsize.c new file mode 100644 index 00000000000..2040c736f2d --- /dev/null +++ b/sbin/dump/maxbsize.c @@ -0,0 +1,36 @@ +/* $OpenBSD: maxbsize.c,v 1.1 1997/02/03 11:53:26 deraadt Exp $ */ + +/* + * Copyright (c) 1997 Theo de Raadt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Theo de Raadt. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#define _KERNEL +#include + +int maxbsize = MAXBSIZE; diff --git a/sbin/dump/tape.c b/sbin/dump/tape.c index 64a78953944..052b679cb10 100644 --- a/sbin/dump/tape.c +++ b/sbin/dump/tape.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tape.c,v 1.2 1996/06/23 14:30:13 deraadt Exp $ */ +/* $OpenBSD: tape.c,v 1.3 1997/02/03 11:53:27 deraadt Exp $ */ /* $NetBSD: tape.c,v 1.7 1995/03/21 18:48:47 mycroft Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)tape.c 8.2 (Berkeley) 3/17/94"; #else -static char rcsid[] = "$OpenBSD: tape.c,v 1.2 1996/06/23 14:30:13 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: tape.c,v 1.3 1997/02/03 11:53:27 deraadt Exp $"; #endif #endif /* not lint */ @@ -145,7 +145,7 @@ alloctape() * 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); /* @@ -309,7 +309,7 @@ flushtape() asize += tenths; blockswritten += ntrec; blocksthisvol += ntrec; - if (!pipeout && (blocksperfile ? + if (!pipeout && !unlimited && (blocksperfile ? (blocksthisvol >= blocksperfile) : (asize > tsize))) { close_rewind(); startnewtape(0);