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 34e910c..2bbb838 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 e9c044a..18c60b9 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 0f95551..f52c72b 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 9daa8e3..95a3cb2 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 142c1a9..dd7de12 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');
 }