summaryrefslogtreecommitdiff
path: root/sys/src/cmd
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2014-02-07 23:33:34 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2014-02-07 23:33:34 +0100
commit88cc09a5800b80cf45e81531014ec8e8ba44386d (patch)
tree9d2ff51f64a07adaec475be0ed9ccdbf65d47f83 /sys/src/cmd
parentc3917ec566559e0a3565b1d412147c951a6c4fc0 (diff)
cwfs: limit memsize() to 1GB until pool can handle huge allocations
Diffstat (limited to 'sys/src/cmd')
-rw-r--r--sys/src/cmd/cwfs/malloc.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/sys/src/cmd/cwfs/malloc.c b/sys/src/cmd/cwfs/malloc.c
index ee3140bec..aed02b117 100644
--- a/sys/src/cmd/cwfs/malloc.c
+++ b/sys/src/cmd/cwfs/malloc.c
@@ -4,7 +4,7 @@
static ulong
memsize(void)
{
- ulong pgsize, userpgs, userused;
+ ulong pgsize, pgmax, userpgs, userused;
char *s, *f[2];
int n, mpcnt;
Biobuf *bp;
@@ -29,13 +29,18 @@ memsize(void)
Bterm(bp);
}
if(pgsize && userused < userpgs){
+ userpgs -= userused;
if(s = getenv("fsmempercent")){
mpcnt = atoi(s);
free(s);
}
if(mpcnt < 1)
mpcnt = 1;
- return ((userpgs-userused)*mpcnt/100)*pgsize;
+ userpgs = (userpgs*mpcnt)/100;
+ pgmax = (1024*1024*1024)/pgsize; /* 1GB max */
+ if(userpgs > pgmax)
+ userpgs = pgmax;
+ return userpgs*pgsize;
}
return 16*MB;
}