Add flag for disabling solid sort
authorEric Biggers <ebiggers3@gmail.com>
Sat, 14 Feb 2015 20:58:45 +0000 (14:58 -0600)
committerEric Biggers <ebiggers3@gmail.com>
Sat, 14 Feb 2015 20:58:45 +0000 (14:58 -0600)
include/wimlib.h
include/wimlib/write.h
programs/imagex.c
src/write.c

index 26719cb..a7b1848 100644 (file)
@@ -2262,6 +2262,13 @@ typedef int (*wimlib_iterate_lookup_table_callback_t)(const struct wimlib_resour
  */
 #define WIMLIB_WRITE_FLAG_SEND_DONE_WITH_FILE_MESSAGES 0x00002000
 
+/**
+ * If using solid compression, do not sort the streams ("files") to compress by
+ * estimated content similarily.  This flag only has an effect if
+ * ::WIMLIB_WRITE_FLAG_SOLID is also specified.
+ */
+#define WIMLIB_WRITE_FLAG_NO_SOLID_SORT                        0x00004000
+
 /** @} */
 /** @addtogroup G_general
  * @{ */
index 93b9293..a46460b 100644 (file)
@@ -28,7 +28,8 @@
        WIMLIB_WRITE_FLAG_STREAMS_OK                    | \
        WIMLIB_WRITE_FLAG_RETAIN_GUID                   | \
        WIMLIB_WRITE_FLAG_SOLID                         | \
-       WIMLIB_WRITE_FLAG_SEND_DONE_WITH_FILE_MESSAGES)
+       WIMLIB_WRITE_FLAG_SEND_DONE_WITH_FILE_MESSAGES  | \
+       WIMLIB_WRITE_FLAG_NO_SOLID_SORT)
 
 #if defined(HAVE_SYS_FILE_H) && defined(HAVE_FLOCK)
 extern int
index 052c4e1..c20ce83 100644 (file)
@@ -170,6 +170,7 @@ enum {
        IMAGEX_NO_ATTRIBUTES_OPTION,
        IMAGEX_NO_REPLACE_OPTION,
        IMAGEX_NO_GLOBS_OPTION,
+       IMAGEX_NO_SOLID_SORT_OPTION,
        IMAGEX_NULLGLOB_OPTION,
        IMAGEX_ONE_FILE_ONLY_OPTION,
        IMAGEX_PATH_OPTION,
@@ -232,6 +233,7 @@ static const struct option capture_or_append_options[] = {
        {T("pack-compress"), required_argument, NULL, IMAGEX_SOLID_COMPRESS_OPTION},
        {T("solid-chunk-size"),required_argument, NULL, IMAGEX_SOLID_CHUNK_SIZE_OPTION},
        {T("pack-chunk-size"), required_argument, NULL, IMAGEX_SOLID_CHUNK_SIZE_OPTION},
+       {T("no-solid-sort"), no_argument,     NULL, IMAGEX_NO_SOLID_SORT_OPTION},
        {T("config"),      required_argument, NULL, IMAGEX_CONFIG_OPTION},
        {T("dereference"), no_argument,       NULL, IMAGEX_DEREFERENCE_OPTION},
        {T("flags"),       required_argument, NULL, IMAGEX_FLAGS_OPTION},
@@ -281,6 +283,7 @@ static const struct option export_options[] = {
        {T("pack-compress"), required_argument, NULL, IMAGEX_SOLID_COMPRESS_OPTION},
        {T("solid-chunk-size"),required_argument, NULL, IMAGEX_SOLID_CHUNK_SIZE_OPTION},
        {T("pack-chunk-size"), required_argument, NULL, IMAGEX_SOLID_CHUNK_SIZE_OPTION},
+       {T("no-solid-sort"), no_argument,     NULL, IMAGEX_NO_SOLID_SORT_OPTION},
        {T("ref"),         required_argument, NULL, IMAGEX_REF_OPTION},
        {T("threads"),     required_argument, NULL, IMAGEX_THREADS_OPTION},
        {T("rebuild"),     no_argument,       NULL, IMAGEX_REBUILD_OPTION},
@@ -354,6 +357,7 @@ static const struct option optimize_options[] = {
        {T("pack-compress"), required_argument, NULL, IMAGEX_SOLID_COMPRESS_OPTION},
        {T("solid-chunk-size"),required_argument, NULL, IMAGEX_SOLID_CHUNK_SIZE_OPTION},
        {T("pack-chunk-size"), required_argument, NULL, IMAGEX_SOLID_CHUNK_SIZE_OPTION},
+       {T("no-solid-sort"), no_argument,     NULL, IMAGEX_NO_SOLID_SORT_OPTION},
        {T("threads"),     required_argument, NULL, IMAGEX_THREADS_OPTION},
        {T("pipable"),     no_argument,       NULL, IMAGEX_PIPABLE_OPTION},
        {T("not-pipable"), no_argument,       NULL, IMAGEX_NOT_PIPABLE_OPTION},
@@ -1816,6 +1820,9 @@ imagex_capture_or_append(int argc, tchar **argv, int cmd)
                case IMAGEX_SOLID_OPTION:
                        write_flags |= WIMLIB_WRITE_FLAG_SOLID;
                        break;
+               case IMAGEX_NO_SOLID_SORT_OPTION:
+                       write_flags |= WIMLIB_WRITE_FLAG_NO_SOLID_SORT;
+                       break;
                case IMAGEX_FLAGS_OPTION:
                        flags_element = optarg;
                        break;
@@ -2690,6 +2697,9 @@ imagex_export(int argc, tchar **argv, int cmd)
                case IMAGEX_SOLID_OPTION:
                        write_flags |= WIMLIB_WRITE_FLAG_SOLID;
                        break;
+               case IMAGEX_NO_SOLID_SORT_OPTION:
+                       write_flags |= WIMLIB_WRITE_FLAG_NO_SOLID_SORT;
+                       break;
                case IMAGEX_CHUNK_SIZE_OPTION:
                        chunk_size = parse_chunk_size(optarg);
                        if (chunk_size == UINT32_MAX)
@@ -3595,6 +3605,9 @@ imagex_optimize(int argc, tchar **argv, int cmd)
                        write_flags |= WIMLIB_WRITE_FLAG_SOLID;
                        write_flags |= WIMLIB_WRITE_FLAG_RECOMPRESS;
                        break;
+               case IMAGEX_NO_SOLID_SORT_OPTION:
+                       write_flags |= WIMLIB_WRITE_FLAG_NO_SOLID_SORT;
+                       break;
                case IMAGEX_THREADS_OPTION:
                        num_threads = parse_num_threads(optarg);
                        if (num_threads == UINT_MAX)
index fcaa52e..8886f8f 100644 (file)
@@ -64,6 +64,7 @@
 #define WRITE_RESOURCE_FLAG_PIPABLE            0x00000002
 #define WRITE_RESOURCE_FLAG_SOLID              0x00000004
 #define WRITE_RESOURCE_FLAG_SEND_DONE_WITH_FILE        0x00000008
+#define WRITE_RESOURCE_FLAG_SOLID_SORT         0x00000010
 
 static inline int
 write_flags_to_resource_flags(int write_flags)
@@ -78,6 +79,10 @@ write_flags_to_resource_flags(int write_flags)
                write_resource_flags |= WRITE_RESOURCE_FLAG_SOLID;
        if (write_flags & WIMLIB_WRITE_FLAG_SEND_DONE_WITH_FILE_MESSAGES)
                write_resource_flags |= WRITE_RESOURCE_FLAG_SEND_DONE_WITH_FILE;
+       if ((write_flags & (WIMLIB_WRITE_FLAG_SOLID |
+                           WIMLIB_WRITE_FLAG_NO_SOLID_SORT)) ==
+           WIMLIB_WRITE_FLAG_SOLID)
+               write_resource_flags |= WRITE_RESOURCE_FLAG_SOLID_SORT;
        return write_resource_flags;
 }
 
@@ -1590,7 +1595,7 @@ write_stream_list(struct list_head *stream_list,
 
        compute_stream_list_stats(stream_list, &ctx);
 
-       if (write_resource_flags & WRITE_RESOURCE_FLAG_SOLID) {
+       if (write_resource_flags & WRITE_RESOURCE_FLAG_SOLID_SORT) {
                ret = sort_stream_list_for_solid_compression(stream_list);
                if (unlikely(ret))
                        WARNING("Failed to sort streams for solid compression. Continuing anyways.");