return blob->blob_extraction_targets;
}
+/*
+ * Declare that the specified blob is located in the specified WIM resource at
+ * the specified offset. The caller is expected to set blob->size if required.
+ */
static inline void
blob_set_is_located_in_wim_resource(struct blob_descriptor *blob,
- struct wim_resource_descriptor *rdesc)
+ struct wim_resource_descriptor *rdesc,
+ u64 offset_in_res)
{
blob->blob_location = BLOB_IN_WIM;
blob->rdesc = rdesc;
list_add_tail(&blob->rdesc_node, &rdesc->blob_list);
+ blob->offset_in_res = offset_in_res;
+}
+
+/*
+ * Declare that the specified blob is located in the specified non-solid WIM
+ * resource. In this case, the blob data is the entire uncompressed resource.
+ */
+static inline void
+blob_set_is_located_in_nonsolid_wim_resource(struct blob_descriptor *blob,
+ struct wim_resource_descriptor *rdesc)
+{
+ blob_set_is_located_in_wim_resource(blob, rdesc, 0);
+ blob->size = rdesc->uncompressed_size;
}
static inline void
blob->blob_location = BLOB_NONEXISTENT;
}
+static inline void
+blob_set_is_located_in_attached_buffer(struct blob_descriptor *blob,
+ void *buffer, size_t size)
+{
+ blob->blob_location = BLOB_IN_ATTACHED_BUFFER;
+ blob->attached_buffer = buffer;
+ blob->size = size;
+}
+
extern struct blob_descriptor *
new_blob_from_data_buffer(const void *buffer, size_t size,
struct blob_table *blob_table);
blob->size = reshdr->size_in_wim;
for (size_t i = 0; i < num_rdescs; i++) {
if (offset + blob->size <= rdescs[i]->uncompressed_size) {
- blob->offset_in_res = offset;
- blob_set_is_located_in_wim_resource(blob, rdescs[i]);
+ blob_set_is_located_in_wim_resource(blob, rdescs[i], offset);
return 0;
}
offset -= rdescs[i]->uncompressed_size;
wim_res_hdr_to_desc(&reshdr, wim, rdesc);
- cur_blob->offset_in_res = 0;
- cur_blob->size = reshdr.uncompressed_size;
-
- blob_set_is_located_in_wim_resource(cur_blob, rdesc);
+ blob_set_is_located_in_nonsolid_wim_resource(cur_blob, rdesc);
}
/* cur_blob is now a blob bound to a resource. */
free_blob_descriptor(blob);
return NULL;
}
- blob->blob_location = BLOB_IN_ATTACHED_BUFFER;
- blob->attached_buffer = buffer_copy;
- blob->size = size;
+ blob_set_is_located_in_attached_buffer(blob, buffer_copy, size);
copy_hash(blob->hash, hash);
blob_table_insert(blob_table, blob);
}
reshdr.offset_in_wim = pwm->in_fd.offset;
reshdr.uncompressed_size = le64_to_cpu(buf.blob_hdr.uncompressed_size);
wim_res_hdr_to_desc(&reshdr, pwm, rdesc);
- blob_set_is_located_in_wim_resource(blob, rdesc);
- blob->size = rdesc->uncompressed_size;
- blob->offset_in_res = 0;
+ blob_set_is_located_in_nonsolid_wim_resource(blob, rdesc);
blob->is_metadata = (rdesc->flags & WIM_RESHDR_FLAG_METADATA) != 0;
return 0;
&& (needed_blob = lookup_blob(blob_table, found_blob->hash))
&& (needed_blob->out_refcnt))
{
- needed_blob->offset_in_res = found_blob->offset_in_res;
- needed_blob->size = found_blob->size;
-
blob_unset_is_located_in_wim_resource(found_blob);
- blob_set_is_located_in_wim_resource(needed_blob, rdesc);
+ blob_set_is_located_in_nonsolid_wim_resource(needed_blob, rdesc);
ret = (*cbs->begin_blob)(needed_blob,
cbs->begin_blob_ctx);
struct blob_descriptor blob;
wim_res_hdr_to_desc(reshdr, wim, &rdesc);
- blob_set_is_located_in_wim_resource(&blob, &rdesc);
-
- blob.size = rdesc.uncompressed_size;
- blob.offset_in_res = 0;
+ blob_set_is_located_in_nonsolid_wim_resource(&blob, &rdesc);
return read_full_blob_into_alloc_buf(&blob, buf_ret);
}
int ret;
wim_res_hdr_to_desc(reshdr, wim, &rdesc);
- blob_set_is_located_in_wim_resource(&blob, &rdesc);
-
- blob.size = rdesc.uncompressed_size;
- blob.offset_in_res = 0;
+ blob_set_is_located_in_nonsolid_wim_resource(&blob, &rdesc);
blob.unhashed = 1;
ret = sha1_blob(&blob);
int ret;
struct blob_descriptor blob_override;
- blob_override.blob_location = BLOB_IN_ATTACHED_BUFFER;
- blob_override.attached_buffer = (void *)rpdata;
- blob_override.size = rpdatalen;
+ blob_set_is_located_in_attached_buffer(&blob_override,
+ (void *)rpdata, rpdatalen);
ret = wim_inode_readlink(inode, link_target,
sizeof(link_target) - 1, &blob_override);
int ret;
struct blob_descriptor blob;
- blob.blob_location = BLOB_IN_ATTACHED_BUFFER;
- blob.attached_buffer = (void*)buf;
- blob.size = buf_size;
+ blob_set_is_located_in_attached_buffer(&blob, (void *)buf, buf_size);
sha1_buffer(buf, buf_size, blob.hash);
blob.unhashed = 0;
blob.is_metadata = is_metadata;