From 9ac0768d746906b3592565ed674d11d99d9e3ec7 Mon Sep 17 00:00:00 2001 From: Ian Dowse Date: Fri, 1 Mar 2002 20:54:23 +0000 Subject: [PATCH] Add a new "-S" flag to dump to allow it just print out dump estimate size and then exit. PR: bin/35450 Submitted by: Mark Hannon Obtained from: NetBSD MFC after: 1 week --- sbin/dump/dump.8 | 7 +++++-- sbin/dump/main.c | 18 +++++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/sbin/dump/dump.8 b/sbin/dump/dump.8 index a6362c174a2d..0191da1a4810 100644 --- a/sbin/dump/dump.8 +++ b/sbin/dump/dump.8 @@ -33,7 +33,7 @@ .\" @(#)dump.8 8.3 (Berkeley) 5/1/95 .\" $FreeBSD$ .\" -.Dd July 9, 2001 +.Dd March 1, 2002 .Dt DUMP 8 .Os .Sh NAME @@ -42,7 +42,7 @@ .Nd filesystem backup .Sh SYNOPSIS .Nm -.Op Fl 0123456789acknu +.Op Fl 0123456789acknSu .Op Fl B Ar records .Op Fl b Ar blocksize .Op Fl D Ar dumpdates @@ -194,6 +194,9 @@ If this amount is exceeded, prompts for a new tape. It is recommended to be a bit conservative on this option. The default tape length is 2300 feet. +.It Fl S +Display an estimate of the backup size and the number of +tapes required, and exit without actually performing the dump. .It Fl T Ar date Use the specified date as the starting time for the dump instead of the time determined from looking in diff --git a/sbin/dump/main.c b/sbin/dump/main.c index 666b65f41b00..e1fc40d234e5 100644 --- a/sbin/dump/main.c +++ b/sbin/dump/main.c @@ -99,6 +99,7 @@ main(argc, argv) char *map; int ch; int i, anydirskipped, bflag = 0, Tflag = 0, honorlevel = 1; + int just_estimate = 0; ino_t maxino; char *tmsg; time_t t; @@ -119,9 +120,9 @@ main(argc, argv) obsolete(&argc, &argv); #ifdef KERBEROS -#define optstring "0123456789aB:b:cd:f:h:kns:T:uWwD:" +#define optstring "0123456789aB:b:cd:f:h:kns:ST:uWwD:" #else -#define optstring "0123456789aB:b:cd:f:h:ns:T:uWwD:" +#define optstring "0123456789aB:b:cd:f:h:ns:ST:uWwD:" #endif while ((ch = getopt(argc, argv, optstring)) != -1) #undef optstring @@ -182,6 +183,10 @@ main(argc, argv) tsize = numarg("tape size", 1L, 0L) * 12 * 10; break; + case 'S': /* exit after estimating # of tapes */ + just_estimate = 1; + break; + case 'T': /* time of last dump */ spcl.c_ddate = unctime(optarg); if (spcl.c_ddate < 0) { @@ -420,6 +425,13 @@ main(argc, argv) tapesize, fetapes); } + /* + * If the user only wants an estimate of the number of + * tapes, exit now. + */ + if (just_estimate) + exit(0); + /* * Allocate tape buffer. */ @@ -508,7 +520,7 @@ usage() #ifdef KERBEROS "k" #endif - "nu] [-B records] [-b blocksize] [-D dumpdates]\n" + "nSu] [-B records] [-b blocksize] [-D dumpdates]\n" " [-d density] [-f file ] [-h level] [-s feet] " "[-T date] filesystem\n" " dump [-W | -w]\n");