diff options
author | Matthew Macy <[email protected]> | 2019-09-30 12:16:06 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2019-09-30 12:16:06 -0700 |
commit | 3283f137d713dce293983e573a62c344ddcf8a19 (patch) | |
tree | 0ee2ca31612d7422d6ca750f59a9ab4ce632d5a3 /lib | |
parent | 7bb0c294688ed121477536d7b4a7031c78a5706a (diff) |
OpenZFS restructuring - zpool
Factor Linux specific functions out of the zpool command.
Reviewed-by: Allan Jude <[email protected]>
Reviewed-by: Ryan Moeller <[email protected]>
Reviewed-by: Sean Eric Fagan <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: loli10K <[email protected]>
Signed-off-by: Matt Macy <[email protected]>
Closes #9333
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libzutil/zutil_nicenum.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/libzutil/zutil_nicenum.c b/lib/libzutil/zutil_nicenum.c index 9a81011fc..306cec3ca 100644 --- a/lib/libzutil/zutil_nicenum.c +++ b/lib/libzutil/zutil_nicenum.c @@ -23,11 +23,26 @@ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. */ +#include <ctype.h> #include <math.h> #include <stdio.h> #include <libzutil.h> /* + * Return B_TRUE if "str" is a number string, B_FALSE otherwise. + * Works for integer and floating point numbers. + */ +boolean_t +zfs_isnumber(const char *str) +{ + for (; *str; str++) + if (!(isdigit(*str) || (*str == '.'))) + return (B_FALSE); + + return (B_TRUE); +} + +/* * Convert a number to an appropriately human-readable output. */ void |