summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2010-08-10 23:35:09 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2010-08-10 23:35:09 +0000
commit405094ed62c8af656ba68fbb39c09b1fe8844540 (patch)
treedeca2e5afb3b7a887e51155a5f7a4223d05615ed /sbin
parent997b31155719f70da2ff7393da89305e2ef10389 (diff)
Add support for t/T == terabyte units to -E. Prodded by deraadt@.
Semantically equivalent version ok beck@ millert@ and tested ckeuthe@. "just commit" deraadt@
Diffstat (limited to 'sbin')
-rw-r--r--sbin/disklabel/editor.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c
index 509969a7c5d..21bbcd5a458 100644
--- a/sbin/disklabel/editor.c
+++ b/sbin/disklabel/editor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: editor.c,v 1.242 2010/08/09 17:31:45 deraadt Exp $ */
+/* $OpenBSD: editor.c,v 1.243 2010/08/10 23:35:08 krw Exp $ */
/*
* Copyright (c) 1997-2000 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -1130,8 +1130,8 @@ getuint(struct disklabel *lp, char *prompt, char *helpstring,
{
char buf[BUFSIZ], *endptr, *p, operator = '\0';
u_int64_t rval = oval;
+ int64_t mult = 1;
size_t n;
- int mult = 1;
double d, percent = 1.0;
/* We only care about the remainder */
@@ -1173,17 +1173,23 @@ getuint(struct disklabel *lp, char *prompt, char *helpstring,
break;
case 'k':
if (lp->d_secsize > 1024)
- mult = -lp->d_secsize / 1024;
+ mult = -lp->d_secsize / 1024LL;
else
- mult = 1024 / lp->d_secsize;
+ mult = 1024LL / lp->d_secsize;
buf[--n] = '\0';
break;
case 'm':
- mult = 1048576 / lp->d_secsize;
+ mult = (1024LL * 1024) / lp->d_secsize;
buf[--n] = '\0';
break;
case 'g':
- mult = 1073741824 / lp->d_secsize;
+ mult = (1024LL * 1024 * 1024) /
+ lp->d_secsize;
+ buf[--n] = '\0';
+ break;
+ case 't':
+ mult = (1024LL * 1024 * 1024 * 1024) /
+ lp->d_secsize;
buf[--n] = '\0';
break;
case '%':