Allow to specify size in terabytes by using T or t suffix.

This speeds up my testing a bit. Because truncate(1) doesn't allocate
blocks on file system before they are used, it is very useful to
emulate huge file systems:

	# truncate -s 16T fs.img
	# mdconfig -a -f fs.img
	# newfs /dev/mdX

(-t swap can be used as well)
This commit is contained in:
Pawel Jakub Dawidek 2006-04-09 19:16:24 +00:00
parent dfa9422b4a
commit e6f3621dd3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=157614
2 changed files with 10 additions and 5 deletions

View file

@ -39,7 +39,7 @@
.Sm off
.Op Cm + | -
.Ar size
.Op Cm K | k | M | m | G | g
.Op Cm K | k | M | m | G | g | T | t
.Sm on
.Xc
.Ek
@ -71,7 +71,7 @@ Truncate files to the length of the file
.Sm off
.Op Cm + | -
.Ar size
.Op Cm K | k | M | m | G | g
.Op Cm K | k | M | m | G | g | T | t
.Sm on
.Xc
If the
@ -94,11 +94,12 @@ The
.Ar size
argument may be suffixed with one of
.Cm K ,
.Cm M
or
.Cm M ,
.Cm G
or
.Cm T
(either upper or lower case) to indicate a multiple of
Kilobytes, Megabytes or Gigabytes
Kilobytes, Megabytes, Gigabytes or Terabytes
respectively.
.El
.Pp

View file

@ -176,6 +176,10 @@ parselength(char *ls, off_t *sz)
}
switch (*ls) {
case 'T':
case 't':
oflow = length * 1024;
ASSIGN_CHK_OFLOW(oflow, length);
case 'G':
case 'g':
oflow = length * 1024;