summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRichard Laager <[email protected]>2011-04-10 18:08:53 -0500
committerBrian Behlendorf <[email protected]>2011-04-19 12:56:21 -0700
commit826ab7ad1931eb8351af1f4f4b7a65f8b0c45839 (patch)
tree3880f1b9cd21edfd2086473b4276fa92a7645ae4 /lib
parent4da4a9e1a78e14112225fb73de5e465395c9a425 (diff)
Support IEC base-2 prefixes
Signed-off-by: Brian Behlendorf <[email protected]>
Diffstat (limited to 'lib')
-rw-r--r--lib/libzfs/libzfs_util.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/libzfs/libzfs_util.c b/lib/libzfs/libzfs_util.c
index da1b9bcdd..f55b658d0 100644
--- a/lib/libzfs/libzfs_util.c
+++ b/lib/libzfs/libzfs_util.c
@@ -1186,11 +1186,14 @@ str2shift(libzfs_handle_t *hdl, const char *buf)
}
/*
- * We want to allow trailing 'b' characters for 'GB' or 'Mb'. But don't
- * allow 'BB' - that's just weird.
+ * Allow 'G' = 'GB' = 'GiB', case-insensitively.
+ * However, 'BB' and 'BiB' are disallowed.
*/
- if (buf[1] == '\0' || (toupper(buf[1]) == 'B' && buf[2] == '\0' &&
- toupper(buf[0]) != 'B'))
+ if (buf[1] == '\0' ||
+ (toupper(buf[0]) != 'B' &&
+ ((toupper(buf[1]) == 'B' && buf[2] == '\0') ||
+ (toupper(buf[1]) == 'I' && toupper(buf[2]) == 'B' &&
+ buf[3] == '\0'))))
return (10*i);
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,