From d33bda72d5d980aa4de9739ed5b55b424093e8ac Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Sun, 7 Apr 2013 22:56:01 -0500 Subject: [PATCH 1/1] Add --threads option to imagex-optimize --- doc/imagex-optimize.1.in | 7 ++++++- programs/imagex.c | 11 ++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/doc/imagex-optimize.1.in b/doc/imagex-optimize.1.in index 20041a1e..d5ce7610 100644 --- a/doc/imagex-optimize.1.in +++ b/doc/imagex-optimize.1.in @@ -21,7 +21,7 @@ When reading \fIWIMFILE\fR, verify its integrity if the integrity table is present; in addition, include an integrity table in the optimized WIM. If this option is not specified, no integrity table is included in the optimized WIM, even if there was one in the original WIM. -.TP 6 +.TP \fB--recompress\fR Recompress all compressed streams in \fIWIMFILE\fR when rebuilding it. This will increase the time needed to rebuild the WIM, unless the WIM is @@ -35,6 +35,11 @@ XPRESS compression ratio than Microsoft's software, while it generally provides a slightly worse LZX compression ratio than Microsoft's software. So, you may not want to specify \fB--recompress\fR when optimizing a LZX-compressed WIM created on Windows. +.TP +\fB--threads\fR=\fINUM_THREADS\fR +Number of threads to use for compressing data. Default: autodetect (number of +processors). This parameter is only meaningful when \fB--recompress\fR is also +specified. .SH NOTES diff --git a/programs/imagex.c b/programs/imagex.c index b78fa325..372e115b 100644 --- a/programs/imagex.c +++ b/programs/imagex.c @@ -145,6 +145,7 @@ IMAGEX_PROGNAME" mountrw WIMFILE [IMAGE_NUM | IMAGE_NAME] DIRECTORY\n" [OPTIMIZE] = T( IMAGEX_PROGNAME" optimize WIMFILE [--check] [--recompress]\n" +" [--threads=NUM_THREADS]\n" ), [SPLIT] = T( @@ -262,6 +263,7 @@ static const struct option mount_options[] = { static const struct option optimize_options[] = { {T("check"), no_argument, NULL, IMAGEX_CHECK_OPTION}, {T("recompress"), no_argument, NULL, IMAGEX_RECOMPRESS_OPTION}, + {T("threads"), required_argument, NULL, IMAGEX_THREADS_OPTION}, {NULL, 0, NULL, 0}, }; @@ -2254,6 +2256,7 @@ imagex_optimize(int argc, tchar **argv) const tchar *wimfile; off_t old_size; off_t new_size; + unsigned num_threads = 0; for_opt(c, optimize_options) { switch (c) { @@ -2264,6 +2267,11 @@ imagex_optimize(int argc, tchar **argv) case IMAGEX_RECOMPRESS_OPTION: write_flags |= WIMLIB_WRITE_FLAG_RECOMPRESS; break; + case IMAGEX_THREADS_OPTION: + num_threads = parse_num_threads(optarg); + if (num_threads == UINT_MAX) + return -1; + break; default: usage(OPTIMIZE); return -1; @@ -2291,7 +2299,8 @@ imagex_optimize(int argc, tchar **argv) else tprintf(T("%"PRIu64" KiB\n"), old_size >> 10); - ret = wimlib_overwrite(w, write_flags, 0, imagex_progress_func); + ret = wimlib_overwrite(w, write_flags, num_threads, + imagex_progress_func); if (ret == 0) { new_size = file_get_size(argv[0]); -- 2.43.0