+
+ return 0;
+}
+
+static int
+handle_pwm_metadata_resource(WIMStruct *pwm, int image, bool is_needed)
+{
+ struct blob_descriptor *blob;
+ struct wim_reshdr reshdr;
+ struct wim_resource_descriptor *rdesc;
+ int ret;
+
+ ret = WIMLIB_ERR_NOMEM;
+ blob = new_blob_descriptor();
+ if (!blob)
+ goto out;
+
+ ret = read_pwm_blob_header(pwm, blob->hash, &reshdr, NULL);
+ if (ret)
+ goto out;
+
+ ret = WIMLIB_ERR_INVALID_PIPABLE_WIM;
+ if (!(reshdr.flags & WIM_RESHDR_FLAG_METADATA)) {
+ ERROR("Expected metadata resource, but found non-metadata "
+ "resource");
+ goto out;
+ }
+
+ ret = WIMLIB_ERR_NOMEM;
+ rdesc = MALLOC(sizeof(*rdesc));
+ if (!rdesc)
+ goto out;
+
+ wim_reshdr_to_desc_and_blob(&reshdr, pwm, rdesc, blob);
+ pwm->refcnt++;
+
+ ret = WIMLIB_ERR_NOMEM;
+ pwm->image_metadata[image - 1] = new_unloaded_image_metadata(blob);
+ if (!pwm->image_metadata[image - 1])
+ goto out;
+ blob = NULL;
+
+ /* If the metadata resource is for the image being extracted, then parse
+ * it and save the metadata in memory. Otherwise, skip over it. */
+ if (is_needed)
+ ret = select_wim_image(pwm, image);
+ else
+ ret = skip_wim_resource(rdesc);