summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2015-11-14 17:42:31 +0000
committerkrw <krw@openbsd.org>2015-11-14 17:42:31 +0000
commit324e5c8d2ca19958d5558828a1ce927e0ea6ecfc (patch)
tree4df03cf255eb23d1ff694f05a3e28cbb69241faf
parentAdd missing header found while removing <sys/srp.h> from <sys/param.h> (diff)
downloadwireguard-openbsd-324e5c8d2ca19958d5558828a1ce927e0ea6ecfc.tar.xz
wireguard-openbsd-324e5c8d2ca19958d5558828a1ce927e0ea6ecfc.zip
Consolidate usage() checking for -c/-h/-s with other checks. Tweak
usage() verbiage a bit so it's clear all of '-c -h -s' are required if any are used.
-rw-r--r--sbin/fdisk/fdisk.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/sbin/fdisk/fdisk.c b/sbin/fdisk/fdisk.c
index 1e2bdaf9931..c9246042278 100644
--- a/sbin/fdisk/fdisk.c
+++ b/sbin/fdisk/fdisk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fdisk.c,v 1.86 2015/11/14 00:20:59 krw Exp $ */
+/* $OpenBSD: fdisk.c,v 1.87 2015/11/14 17:42:31 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -53,7 +53,7 @@ usage(void)
"[-egy] [-i|-u] [-b #] [-c # -h # -s #] "
"[-f mbrfile] [-l # ] disk\n"
"\t-b: specify special boot partition block count; requires -i\n"
- "\t-chs: specify disk geometry\n"
+ "\t-chs: specify disk geometry; all three must be specified\n"
"\t-e: interactively edit MBR or GPT\n"
"\t-f: specify non-standard MBR template\n"
"\t-g: initialize disk with GPT; requires -i\n"
@@ -143,7 +143,8 @@ main(int argc, char *argv[])
/* Argument checking */
if (argc != 1 || (i_flag && u_flag) ||
- (i_flag == 0 && (b_arg || g_flag)))
+ (i_flag == 0 && (b_arg || g_flag)) ||
+ ((c_arg | h_arg | s_arg) && !(c_arg && h_arg && s_arg)))
usage();
disk.name = argv[0];
@@ -159,14 +160,10 @@ main(int argc, char *argv[])
}
if (c_arg | h_arg | s_arg) {
- /* Use supplied geometry if it is completely specified. */
- if (c_arg && h_arg && s_arg) {
- disk.cylinders = c_arg;
- disk.heads = h_arg;
- disk.sectors = s_arg;
- disk.size = c_arg * h_arg * s_arg;
- } else
- errx(1, "Please specify a full geometry with [-chs].");
+ disk.cylinders = c_arg;
+ disk.heads = h_arg;
+ disk.sectors = s_arg;
+ disk.size = c_arg * h_arg * s_arg;
} else if (l_arg) {
/* Use supplied size to calculate a geometry. */
disk.cylinders = l_arg / 64;