From 405094ed62c8af656ba68fbb39c09b1fe8844540 Mon Sep 17 00:00:00 2001 From: Kenneth R Westerback Date: Tue, 10 Aug 2010 23:35:09 +0000 Subject: Add support for t/T == terabyte units to -E. Prodded by deraadt@. Semantically equivalent version ok beck@ millert@ and tested ckeuthe@. "just commit" deraadt@ --- sbin/disklabel/editor.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'sbin') 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 @@ -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 '%': -- cgit v1.2.3