Allow friendly partition sizing: a foo . .+600M creates a 600MB partition. The parser recognizes K, M, G, and T (and the corresponding lowercase variants) as viable suffixes. The scaling is binary, not decimal. Reference: /n/sources/patch/applied/prep-scaling Date: Wed Sep 23 23:35:16 CES 2009 Signed-off-by: lyndon@orthanc.ca --- /sys/src/cmd/disk/prep/calc.y Wed Sep 23 23:29:20 2009 +++ /sys/src/cmd/disk/prep/calc.y Wed Sep 23 23:29:18 2009 @@ -85,6 +85,8 @@ static int yylex(void) { + vlong n; + while(isspace(*inp)) inp++; @@ -92,7 +94,26 @@ return 0; if(isdigit(*inp)) { - yylval = mkNUM(strtoll(inp, &inp, 0)); + n = strtoll(inp, &inp, 0); + switch(*inp) { + case 'k': + case 'K': n *= 2; + inp++; + break; + case 'm': + case 'M': n *= (1024*2); + inp++; + break; + case 'g': + case 'G': n *= (1024*1024*2); + inp++; + break; + case 't': + case 'T': n *= (1024LL*1024*1024*2); + inp++; + break; + } + yylval = mkNUM(n); return NUMBER; } --- /sys/man/8/prep Wed Sep 23 23:29:25 2009 +++ /sys/man/8/prep Wed Sep 23 23:29:22 2009 @@ -364,6 +364,10 @@ .I end can take on without running off the disk or into another partition. +Numeric constants suffixed by +K, M, G, or T +are scaled to the respective size in kilo-, mega-, giga-, +or terabytes. Finally, the expression .IB n % evaluates to @@ -375,6 +379,12 @@ creates a new partition starting at .B . that takes up a fifth of the disk, +.B a +.B . +.B .+21G +creates a new partition starting at +.B . +that takes up 21 gigabytes (21 × 2^30 bytes), and .B a .B 1000