]> wimlib.net Git - wimlib/commitdiff
Support basic reading WIMBoot WIMs
authorEric Biggers <ebiggers3@gmail.com>
Sun, 13 Apr 2014 06:56:23 +0000 (01:56 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Fri, 18 Apr 2014 06:23:03 +0000 (01:23 -0500)
These use a new compression flag, but it's actually just XPRESS with a
really small chunk size.

include/wimlib/header.h
include/wimlib/xml.h
src/header.c
src/wim.c
src/xml.c

index 34e910cbb15fe1b338ce132bd053f6dadf70eebc..2bbb8388d7e8d928670605198cb8acab20354550 100644 (file)
@@ -190,4 +190,7 @@ struct wim_header {
  * wimlib v1.6.0 and later and WIMGAPI Windows 8 and later.  */
 #define WIM_HDR_FLAG_COMPRESS_LZMS      0x00080000
 
+/* XPRESS, with small chunk size???  */
+#define WIM_HDR_FLAG_COMPRESS_XPRESS_2 0x00200000
+
 #endif /* _WIMLIB_HEADER_H */
index e9c044afd8854076a3e9ec10ce72aa6be365bed8..18c60b989058298d53ad6800c1a24c463a01e030 100644 (file)
@@ -19,6 +19,9 @@ wim_info_get_image_total_bytes(const struct wim_info *info, int image);
 extern unsigned
 wim_info_get_num_images(const struct wim_info *info);
 
+extern void
+wim_info_set_wimboot(struct wim_info *info, int image, bool value);
+
 extern int
 xml_export_image(const struct wim_info *old_wim_info, int image,
                 struct wim_info **new_wim_info_p,
index 0f9555195238e170aee895c640f96f9292b4cb80..f52c72b7562a852e36b09e9a350dcd00316558e2 100644 (file)
@@ -226,7 +226,8 @@ set_wim_hdr_cflags(int ctype, struct wim_header *hdr)
                        WIM_HDR_FLAG_COMPRESS_LZX |
                        WIM_HDR_FLAG_COMPRESS_RESERVED |
                        WIM_HDR_FLAG_COMPRESS_XPRESS |
-                       WIM_HDR_FLAG_COMPRESS_LZMS);
+                       WIM_HDR_FLAG_COMPRESS_LZMS |
+                       WIM_HDR_FLAG_COMPRESS_XPRESS_2);
        switch (ctype) {
 
        case WIMLIB_COMPRESSION_TYPE_NONE:
@@ -289,6 +290,8 @@ struct hdr_flag hdr_flags[] = {
        {WIM_HDR_FLAG_COMPRESS_RESERVED,"COMPRESS_RESERVED"},
        {WIM_HDR_FLAG_COMPRESS_LZX,     "COMPRESS_LZX"},
        {WIM_HDR_FLAG_COMPRESS_XPRESS,  "COMPRESS_XPRESS"},
+       {WIM_HDR_FLAG_COMPRESS_LZMS,    "COMPRESS_LZMS"},
+       {WIM_HDR_FLAG_COMPRESS_XPRESS_2,"COMPRESS_XPRESS_2"},
 };
 
 /* API function documented in wimlib.h  */
index 9daa8e3bc60c8765ac1022a89002da1d32f19bea..95a3cb2872f07a54ef6cb6aaa0c3376a5d7bd574 100644 (file)
--- a/src/wim.c
+++ b/src/wim.c
@@ -130,7 +130,7 @@ wim_chunk_size_valid(u32 chunk_size, int ctype)
                return order >= 15 && order <= 21;
 
        case WIMLIB_COMPRESSION_TYPE_XPRESS:
-               return order >= 15 && order <= 26;
+               return order >= 12 && order <= 26;
        case WIMLIB_COMPRESSION_TYPE_LZMS:
                return order >= 15 && order <= 30;
        }
@@ -621,7 +621,8 @@ begin_read(WIMStruct *wim, const void *wim_filename_or_fd,
        if (wim->hdr.flags & WIM_HDR_FLAG_COMPRESSION) {
                if (wim->hdr.flags & WIM_HDR_FLAG_COMPRESS_LZX) {
                        wim->compression_type = WIMLIB_COMPRESSION_TYPE_LZX;
-               } else if (wim->hdr.flags & WIM_HDR_FLAG_COMPRESS_XPRESS) {
+               } else if (wim->hdr.flags & (WIM_HDR_FLAG_COMPRESS_XPRESS |
+                                            WIM_HDR_FLAG_COMPRESS_XPRESS_2)) {
                        wim->compression_type = WIMLIB_COMPRESSION_TYPE_XPRESS;
                } else if (wim->hdr.flags & WIM_HDR_FLAG_COMPRESS_LZMS) {
                        wim->compression_type = WIMLIB_COMPRESSION_TYPE_LZMS;
index 142c1a91a6f4d9f20dba78454a56ba66c6e6d906..dd7de12ea40b617fe866f98e83fee5e38a42854e 100644 (file)
--- a/src/xml.c
+++ b/src/xml.c
@@ -89,6 +89,7 @@ struct image_info {
        tchar *display_name;
        tchar *display_description;
        tchar *flags;
+       bool wimboot;
        struct wim_lookup_table *lookup_table; /* temporary field */
 };
 
@@ -167,6 +168,12 @@ wim_info_get_num_images(const struct wim_info *info)
                return 0;
 }
 
+void
+wim_info_set_wimboot(struct wim_info *info, int image, bool value)
+{
+       info->images[image - 1].wimboot = value;
+}
+
 /* Architecture constants are from w64 mingw winnt.h  */
 #define PROCESSOR_ARCHITECTURE_INTEL 0
 #define PROCESSOR_ARCHITECTURE_MIPS 1
@@ -520,6 +527,10 @@ xml_read_image_info(xmlNode *image_node, struct image_info *image_info)
                        ret = node_get_string(child, &image_info->display_name);
                } else if (node_name_is(child, "DISPLAYDESCRIPTION")) {
                        ret = node_get_string(child, &image_info->display_description);
+               } else if (node_name_is(child, "WIMBOOT")) {
+                       if (node_get_u64(child) == 1) {
+                               image_info->wimboot = true;
+                       }
                }
                if (ret != 0)
                        return ret;
@@ -944,6 +955,12 @@ xml_write_image_info(xmlTextWriter *writer, const struct image_info *image_info)
        if (rc)
                return rc;
 
+       if (image_info->wimboot) {
+               rc = xmlTextWriterWriteFormatElement(writer, "WIMBOOT", "%d", 1);
+               if (rc < 0)
+                       return rc;
+       }
+
        rc = xmlTextWriterEndElement(writer); /* </IMAGE> */
        if (rc < 0)
                return rc;
@@ -1336,6 +1353,8 @@ print_image_info(const struct wim_info *wim_info, int image)
                print_windows_info(&image_info->windows_info);
        if (image_info->flags)
                tprintf(T("Flags:                  %"TS"\n"), image_info->flags);
+       tprintf(T("WIMBoot compatible:     %"TS"\n"),
+               image_info->wimboot ? T("yes") : T("no"));
        tputchar('\n');
 }