diff options
author | pjd <pjd@FreeBSD.org> | 2006-04-09 19:16:24 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2006-04-09 19:16:24 +0000 |
commit | a6661f4c728b5c43df159bb1738d216d5527df92 (patch) | |
tree | 60b82e70cca63c24d3c6cf456fc8c618c9affac7 /usr.bin/truncate | |
parent | 0501edbc66645c32bd26858286dc77bbda7e3720 (diff) | |
download | FreeBSD-src-a6661f4c728b5c43df159bb1738d216d5527df92.zip FreeBSD-src-a6661f4c728b5c43df159bb1738d216d5527df92.tar.gz |
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)
Diffstat (limited to 'usr.bin/truncate')
-rw-r--r-- | usr.bin/truncate/truncate.1 | 11 | ||||
-rw-r--r-- | usr.bin/truncate/truncate.c | 4 |
2 files changed, 10 insertions, 5 deletions
diff --git a/usr.bin/truncate/truncate.1 b/usr.bin/truncate/truncate.1 index c79e64a..95d6d99 100644 --- a/usr.bin/truncate/truncate.1 +++ b/usr.bin/truncate/truncate.1 @@ -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 diff --git a/usr.bin/truncate/truncate.c b/usr.bin/truncate/truncate.c index 364f400..a0df091 100644 --- a/usr.bin/truncate/truncate.c +++ b/usr.bin/truncate/truncate.c @@ -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; |