summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2006-04-09 19:16:24 +0000
committerpjd <pjd@FreeBSD.org>2006-04-09 19:16:24 +0000
commita6661f4c728b5c43df159bb1738d216d5527df92 (patch)
tree60b82e70cca63c24d3c6cf456fc8c618c9affac7 /usr.bin
parent0501edbc66645c32bd26858286dc77bbda7e3720 (diff)
downloadFreeBSD-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')
-rw-r--r--usr.bin/truncate/truncate.111
-rw-r--r--usr.bin/truncate/truncate.c4
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;
OpenPOWER on IntegriCloud