diff options
author | rsc <devnull@localhost> | 2005-12-30 18:52:20 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2005-12-30 18:52:20 +0000 |
commit | 2214d4b6dec29cb6f1fe28f9932ddeda47beafbe (patch) | |
tree | 1729036eca6fcacd241132f01e7d6b176cde6e57 /src/cmd/vbackup | |
parent | 85f595382f8613dfa9fcdb3f6b4c3db4f50ffa8d (diff) | |
download | plan9port-2214d4b6dec29cb6f1fe28f9932ddeda47beafbe.tar.gz plan9port-2214d4b6dec29cb6f1fe28f9932ddeda47beafbe.tar.bz2 plan9port-2214d4b6dec29cb6f1fe28f9932ddeda47beafbe.zip |
get units right
Diffstat (limited to 'src/cmd/vbackup')
-rw-r--r-- | src/cmd/vbackup/vnfs.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/cmd/vbackup/vnfs.c b/src/cmd/vbackup/vnfs.c index ad43b250..7ec7d525 100644 --- a/src/cmd/vbackup/vnfs.c +++ b/src/cmd/vbackup/vnfs.c @@ -69,6 +69,8 @@ int readconfigfile(Config *cp); void setrootfid(void); int ipokay(uchar *ip, ushort port); +u64int unittoull(char*); + void usage(void) { @@ -120,10 +122,10 @@ threadmain(int argc, char **argv) addr = EARGF(usage()); break; case 'b': - blocksize = strtoull(EARGF(usage()), 0, 0); + blocksize = unittoull(EARGF(usage())); break; case 'c': - cachesize = strtoull(EARGF(usage()), 0, 0); + cachesize = unittoull(EARGF(usage())); break; case 'r': srv->alwaysreject++; @@ -163,6 +165,35 @@ threadmain(int argc, char **argv) threadexits(nil); } +#define TWID64 ((u64int)~(u64int)0) + +u64int +unittoull(char *s) +{ + char *es; + u64int n; + + if(s == nil) + return TWID64; + n = strtoul(s, &es, 0); + if(*es == 'k' || *es == 'K'){ + n *= 1024; + es++; + }else if(*es == 'm' || *es == 'M'){ + n *= 1024*1024; + es++; + }else if(*es == 'g' || *es == 'G'){ + n *= 1024*1024*1024; + es++; + }else if(*es == 't' || *es == 'T'){ + n *= 1024*1024; + n *= 1024*1024; + } + if(*es != '\0') + return TWID64; + return n; +} + /* * Handles. * |