diff options
author | Roland McGrath <roland@gnu.org> | 2000-12-21 07:47:53 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2000-12-21 07:47:53 +0000 |
commit | ba85f6c77981db6f3bfba1d40a1d211a0c6c26ce (patch) | |
tree | ebdf427a0cf071442b8cf17328ff90102983dd66 | |
parent | fb0817d55ff2e9594efa53c2555a527b5fe7b38e (diff) |
2000-12-20 Roland McGrath <roland@frob.com>
* zero.c (zero_open): Check for END being null after strtoul call.
If character following number (*END) is b, multiply size by 512;
k or K, by 1024; m or M by 1024*1024; g or G by 1024*1024*1024.
-rw-r--r-- | libstore/zero.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/libstore/zero.c b/libstore/zero.c index 55f84a2c..f0a23276 100644 --- a/libstore/zero.c +++ b/libstore/zero.c @@ -1,7 +1,7 @@ /* Zero store backend - Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc. - Written by Miles Bader <miles@gnu.ai.mit.edu> + Copyright (C) 1995,96,97,99,2000 Free Software Foundation, Inc. + Written by Miles Bader <miles@gnu.org> This file is part of the GNU Hurd. The GNU Hurd is free software; you can redistribute it and/or @@ -118,8 +118,26 @@ zero_open (const char *name, int flags, { char *end; off_t size = strtoul (name, &end, 0); - if (end == name) + if (end == name || end == NULL) return EINVAL; + switch (*end) + { + case 'b': + size *= 512; + break; + case 'k': + case 'K': + size *= 1024; + break; + case 'm': + case 'M': + size *= 1024 * 1024; + break; + case 'g': + case 'G': + size *= 1024 * 1024 * 1024; + break; + } return store_zero_create (size, flags, store); } else |