mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
get units right
This commit is contained in:
parent
85f595382f
commit
2214d4b6de
1 changed files with 33 additions and 2 deletions
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue