From 3db96e21c9c03d1797c471fa47fafdd65b71cf11 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Sun, 18 Nov 2012 22:27:50 -0600 Subject: [PATCH] wimlib_set_boot_idx(): Update boot metadata immediately 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 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/wim.c b/src/wim.c index ed6ab33d..3e9b4523 100644 --- 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; } -- 2.43.0