Use err(3), add usage().

This commit is contained in:
charnier 1997-09-17 06:27:23 +00:00
parent 9b3a5c04f4
commit 8d96034d35
2 changed files with 21 additions and 19 deletions

View File

@ -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 ,

View File

@ -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 {