diff options
author | charnier <charnier@FreeBSD.org> | 1997-09-17 06:27:23 +0000 |
---|---|---|
committer | charnier <charnier@FreeBSD.org> | 1997-09-17 06:27:23 +0000 |
commit | 8d96034d356cc71c451f193a8b5550ee048fdbbe (patch) | |
tree | d01e7c7a2f9bc6f0fb182119ae0bc016e2285616 | |
parent | 9b3a5c04f489ab22fa4a1913c89cf18546171f3b (diff) | |
download | FreeBSD-src-8d96034d356cc71c451f193a8b5550ee048fdbbe.zip FreeBSD-src-8d96034d356cc71c451f193a8b5550ee048fdbbe.tar.gz |
Use err(3), add usage().
-rw-r--r-- | usr.sbin/diskpart/diskpart.8 | 4 | ||||
-rw-r--r-- | usr.sbin/diskpart/diskpart.c | 36 |
2 files changed, 21 insertions, 19 deletions
diff --git a/usr.sbin/diskpart/diskpart.8 b/usr.sbin/diskpart/diskpart.8 index 0b02de2..e13613a 100644 --- a/usr.sbin/diskpart/diskpart.8 +++ b/usr.sbin/diskpart/diskpart.8 @@ -110,7 +110,7 @@ partitions are variable-sized, occupying whatever space remains after allocation of the fixed sized partitions. If the disk is smaller than 20 Megabytes, then -.Nm diskpart +.Nm aborts with the message .Dq Li disk too small, calculate by hand . .Bl -column Partition 20-60\ MB 61-205\ MB 206-355\ MB 356+\ MB @@ -123,7 +123,7 @@ h unused unused 291346 291346 .El .Pp If an unknown disk type is specified, -.Nm diskpart +.Nm will prompt for the required disk geometry information. .Sh SEE ALSO .Xr disktab 5 , diff --git a/usr.sbin/diskpart/diskpart.c b/usr.sbin/diskpart/diskpart.c index c9505fd..86b4122 100644 --- a/usr.sbin/diskpart/diskpart.c +++ b/usr.sbin/diskpart/diskpart.c @@ -32,7 +32,7 @@ */ #ifndef lint -static char copyright[] = +static const char copyright[] = "@(#) Copyright (c) 1983, 1988, 1993\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ @@ -42,7 +42,7 @@ static char copyright[] = static char sccsid[] = "@(#)diskpart.c 8.3 (Berkeley) 11/30/94"; #endif static const char rcsid[] = - "$Id$"; + "$Id: diskpart.c,v 1.8 1997/02/22 16:05:46 peter Exp $"; #endif /* not lint */ /* @@ -52,8 +52,9 @@ static const char rcsid[] = #define DKTYPENAMES #include <sys/disklabel.h> -#include <stdio.h> #include <ctype.h> +#include <err.h> +#include <stdio.h> #define for_now /* show all of `c' partition for disklabel */ #define NPARTITIONS 8 @@ -113,7 +114,9 @@ int pflag; /* print device driver partition tables */ int dflag; /* print disktab entry */ struct disklabel *promptfordisk(); +static void usage __P((void)); +int main(argc, argv) int argc; char *argv[]; @@ -125,11 +128,8 @@ main(argc, argv) char *lp, *tyname; argc--, argv++; - if (argc < 1) { - fprintf(stderr, - "usage: disktab [ -p ] [ -d ] [ -s size ] disk-type\n"); - exit(1); - } + if (argc < 1) + usage(); if (argc > 0 && strcmp(*argv, "-p") == 0) { pflag++; argc--, argv++; @@ -146,10 +146,8 @@ main(argc, argv) if (dp == NULL) { if (isatty(0)) dp = promptfordisk(*argv); - if (dp == NULL) { - fprintf(stderr, "%s: unknown disk type\n", *argv); - exit(2); - } + if (dp == NULL) + errx(2, "%s: unknown disk type", *argv); } else { if (dp->d_flags & D_REMOVABLE) tyname = "removable"; @@ -198,11 +196,8 @@ main(argc, argv) if (curcyl < dp->d_ncylinders - threshhold) break; } - if (def >= NDEFAULTS) { - fprintf(stderr, "%s: disk too small, calculate by hand\n", - *argv); - exit(3); - } + if (def >= NDEFAULTS) + errx(3, "%s: disk too small, calculate by hand", *argv); /* * Calculate number of cylinders allocated to each disk @@ -344,6 +339,13 @@ main(argc, argv) } } +static void +usage() +{ + fprintf(stderr, "usage: disktab [-p] [-d] [-s size] disk-type\n"); + exit(1); +} + struct disklabel disk; struct field { |