diff options
author | aurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162> | 2009-03-08 19:49:44 +0000 |
---|---|---|
committer | aurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162> | 2009-03-08 19:49:44 +0000 |
commit | 245014892041640d634ee4cf458e7961a78dfd53 (patch) | |
tree | a3af406783c680b1dbfc91f4e96b9f21bac0cbd2 /qemu-img.c | |
parent | 72fcd388b6a8f6b5c4874418a0152300a14b2d5b (diff) |
qemu-img: accept sizes with decimal values
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6786 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'qemu-img.c')
-rw-r--r-- | qemu-img.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/qemu-img.c b/qemu-img.c index 2af695fbe..ad25cb3e6 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -220,6 +220,7 @@ static int img_create(int argc, char **argv) const char *filename; const char *base_filename = NULL; uint64_t size; + double sizef; const char *p; BlockDriver *drv; @@ -260,13 +261,13 @@ static int img_create(int argc, char **argv) if (optind >= argc) help(); p = argv[optind]; - size = strtoul(p, (char **)&p, 0); + sizef = strtod(p, (char **)&p); if (*p == 'M') { - size *= 1024 * 1024; + size = (uint64_t)(sizef * 1024 * 1024); } else if (*p == 'G') { - size *= 1024 * 1024 * 1024; + size = (uint64_t)(sizef * 1024 * 1024 * 1024); } else if (*p == 'k' || *p == 'K' || *p == '\0') { - size *= 1024; + size = (uint64_t)(sizef * 1024); } else { help(); } |