wimlib_set_boot_idx(): Update boot metadata immediately
authorEric Biggers <ebiggers3@gmail.com>
Mon, 19 Nov 2012 04:27:50 +0000 (22:27 -0600)
committerEric Biggers <ebiggers3@gmail.com>
Mon, 19 Nov 2012 04:27:50 +0000 (22:27 -0600)
Update the boot metadata resource entry in the WIM header as soon as
wimlib_set_boot_idx() is called.  Otherwise, the correct entry is never updated
if wimlib_overwrite_xml_and_header() is called.

src/wim.c

index ed6ab33d97650ad4dcf50a70e7280130f62b8ef5..3e9b4523c7141a72df49ae8936e15a88601630ea 100644 (file)
--- a/src/wim.c
+++ b/src/wim.c
@@ -391,6 +391,17 @@ WIMLIBAPI int wimlib_set_boot_idx(WIMStruct *w, int boot_idx)
        if (boot_idx < 0 || boot_idx > w->hdr.image_count)
                return WIMLIB_ERR_INVALID_IMAGE;
        w->hdr.boot_idx = boot_idx;
+
+       if (boot_idx == 0) {
+               memset(&w->hdr.boot_metadata_res_entry, 0,
+                      sizeof(struct resource_entry));
+       } else {
+               memcpy(&w->hdr.boot_metadata_res_entry,
+                      &w->image_metadata[
+                         boot_idx - 1].metadata_lte->resource_entry,
+                      sizeof(struct resource_entry));
+       }
+
        return 0;
 }