diff options
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. * |