summaryrefslogtreecommitdiffstats
path: root/sbin/hastctl/hastctl.c
diff options
context:
space:
mode:
authortrociny <trociny@FreeBSD.org>2011-03-13 19:23:32 +0000
committertrociny <trociny@FreeBSD.org>2011-03-13 19:23:32 +0000
commit45445ae0ff19bd64204a33ce338f59d9575dc914 (patch)
treeacbbd70b932e483bb358eb7e21ec2d0fbc526c87 /sbin/hastctl/hastctl.c
parent8c134ab018e2f06e785699771decadf41cffb453 (diff)
downloadFreeBSD-src-45445ae0ff19bd64204a33ce338f59d9575dc914.zip
FreeBSD-src-45445ae0ff19bd64204a33ce338f59d9575dc914.tar.gz
In command line options allow size to be specified using k/M/G/T
suffixes. Approved by: pjd (mentor) MFC after: 1 week
Diffstat (limited to 'sbin/hastctl/hastctl.c')
-rw-r--r--sbin/hastctl/hastctl.c29
1 files changed, 5 insertions, 24 deletions
diff --git a/sbin/hastctl/hastctl.c b/sbin/hastctl/hastctl.c
index 78ee6d6..460042b 100644
--- a/sbin/hastctl/hastctl.c
+++ b/sbin/hastctl/hastctl.c
@@ -40,7 +40,7 @@ __FBSDID("$FreeBSD$");
#include <err.h>
#include <errno.h>
#include <fcntl.h>
-#include <inttypes.h>
+#include <libutil.h>
#include <limits.h>
#include <signal.h>
#include <stdio.h>
@@ -342,30 +342,11 @@ control_status(struct nv *nv)
return (ret);
}
-static int
-numfromstr(const char *str, intmax_t *nump)
-{
- intmax_t num;
- char *suffix;
- int rerrno;
-
- rerrno = errno;
- errno = 0;
- num = strtoimax(str, &suffix, 0);
- if (errno == 0 && *suffix != '\0')
- errno = EINVAL;
- if (errno != 0)
- return (-1);
- *nump = num;
- errno = rerrno;
- return (0);
-}
-
int
main(int argc, char *argv[])
{
struct nv *nv;
- intmax_t mediasize, extentsize, keepdirty;
+ int64_t mediasize, extentsize, keepdirty;
int cmd, debug, error, ii;
const char *optstr;
@@ -407,15 +388,15 @@ main(int argc, char *argv[])
debug++;
break;
case 'e':
- if (numfromstr(optarg, &extentsize) < 0)
+ if (expand_number(optarg, &extentsize) < 0)
err(1, "Invalid extentsize");
break;
case 'k':
- if (numfromstr(optarg, &keepdirty) < 0)
+ if (expand_number(optarg, &keepdirty) < 0)
err(1, "Invalid keepdirty");
break;
case 'm':
- if (numfromstr(optarg, &mediasize) < 0)
+ if (expand_number(optarg, &mediasize) < 0)
err(1, "Invalid mediasize");
break;
case 'h':
OpenPOWER on IntegriCloud