From 975462a6cbfe5c97ba6d7207978467748611b5ab Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 23 Dec 2009 08:54:52 +0100 Subject: [PATCH] Allow 'b' postfix for integer values Fio would previously regard '1tb' as just 1 byte, since the 'b' postfix isn't a valid multiplier. Allow the 'b' as well, just ignore it. Signed-off-by: Jens Axboe --- parse.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/parse.c b/parse.c index 78218615..a55e52b0 100644 --- a/parse.c +++ b/parse.c @@ -162,9 +162,19 @@ int str_to_decimal(const char *str, long long *val, int kilo, void *data) if (*val == LONG_MAX && errno == ERANGE) return 1; - if (kilo) - *val *= get_mult_bytes(str[len - 1], data); - else + if (kilo) { + const char *p; + /* + * if the last char is 'b' or 'B', the user likely used + * "1gb" instead of just "1g". If the second to last is also + * a letter, adjust. + */ + p = str + len - 1; + if ((*p == 'b' || *p == 'B') && isalpha(*(p - 1))) + --p; + + *val *= get_mult_bytes(*p, data); + } else *val *= get_mult_time(str[len - 1]); return 0; -- 2.25.1