Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F147882820
D10480.1784673109.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D10480.1784673109.diff
View Options
Index: usr.bin/mkuzip/mkuzip.8
===================================================================
--- usr.bin/mkuzip/mkuzip.8
+++ usr.bin/mkuzip/mkuzip.8
@@ -37,7 +37,7 @@
.Nm
.Op Fl v
.Op Fl o Ar outfile
-.Op Fl s Ar cluster_size
+.Op Fl s Ar cluster_size Op Fl t Ar trimto
.Op Fl j Ar compression_jobs
.Ar infile
.Sh DESCRIPTION
@@ -131,6 +131,10 @@
.Va hw.ncpu
.Xr sysctl 8
variable.
+.It Fl t Ar trimto
+Limit the compressed image size to
+.Ar trimto
+blocks.
.El
.Sh NOTES
The compression ratio largely depends on the cluster size used.
Index: usr.bin/mkuzip/mkuzip.c
===================================================================
--- usr.bin/mkuzip/mkuzip.c
+++ usr.bin/mkuzip/mkuzip.c
@@ -110,6 +110,8 @@
struct mkuz_blk_info *chit;
size_t ncpusz, ncpu;
double st, et;
+ int blksz_set;
+ long long trim_nblocks;
st = getdtime();
@@ -131,8 +133,10 @@
cfs.handler = &uzip_fmt;
cfs.nworkers = ncpu;
struct mkuz_blk *iblk, *oblk;
+ blksz_set = 0;
+ trim_nblocks = -1;
- while((opt = getopt(argc, argv, "o:s:vZdLSj:")) != -1) {
+ while((opt = getopt(argc, argv, "o:s:vZdLSj:t:")) != -1) {
switch(opt) {
case 'o':
oname = optarg;
@@ -146,6 +150,7 @@
/* Not reached */
}
cfs.blksz = tmp;
+ blksz_set = 1;
break;
case 'v':
@@ -179,6 +184,15 @@
cfs.nworkers = tmp;
break;
+ case 't':
+ trim_nblocks = atoll(optarg);
+ if (trim_nblocks <= 0) {
+ errx(1, "invalid number of blocks specified:"
+ " %s", optarg);
+ /* Not reached */
+ }
+ break;
+
default:
usage();
/* Not reached */
@@ -191,6 +205,11 @@
usage();
/* Not reached */
}
+ if (blksz_set == 0 && trim_nblocks > 0) {
+ errx(1, "cluster size needs to be specified explicitly when "
+ "using -t option");
+ /* Not reached */
+ }
strcpy(hdr.magic, cfs.handler->magic);
@@ -247,6 +266,14 @@
"of %d, padding data\n", cfs.blksz);
hdr.nblocks++;
}
+ if (trim_nblocks > 0) {
+ if (trim_nblocks > hdr.nblocks) {
+ errx(1, "requested trim size (%lld) is greater than "
+ "projected size (%u)", trim_nblocks, hdr.nblocks);
+ /* Not reached */
+ }
+ hdr.nblocks = trim_nblocks;
+ }
toc = mkuz_safe_malloc((hdr.nblocks + 1) * sizeof(*toc));
cfs.fdw = open(oname, (cfs.en_dedup ? O_RDWR : O_WRONLY) | O_TRUNC | O_CREAT,
@@ -408,8 +435,8 @@
usage(void)
{
- fprintf(stderr, "usage: mkuzip [-vZdLS] [-o outfile] [-s cluster_size] "
- "[-j ncompr] infile\n");
+ fprintf(stderr, "usage: mkuzip [-vZdLS] [-o outfile] [-s cluster_size "
+ "[-t trimto]] [-j ncompr] infile\n");
exit(1);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Jul 21, 10:31 PM (1 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29222060
Default Alt Text
D10480.1784673109.diff (2 KB)
Attached To
Mode
D10480: Add option to limit output image to a certain size
Attached
Detach File
Event Timeline
Log In to Comment