MCPcopy Create free account
hub / github.com/coreboot/coreboot / update_anchor

Function update_anchor

util/cbfstool/cbfstool.c:259–283  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

257}
258
259static int update_anchor(struct mh_cache *mhc, uint8_t *fmap_hash)
260{
261 struct buffer buffer;
262 if (!partitioned_file_read_region(&buffer, param.image_file,
263 mhc->region))
264 return -1;
265 struct metadata_hash_anchor *anchor = buffer_get(&buffer) + mhc->offset;
266 /* The metadata hash anchor should always still be where we left it. */
267 assert(!memcmp(anchor->magic, METADATA_HASH_ANCHOR_MAGIC,
268 sizeof(anchor->magic)) &&
269 anchor->cbfs_hash.algo == mhc->cbfs_hash.algo);
270 update_and_info("CBFS metadata hash", anchor->cbfs_hash.raw,
271 mhc->cbfs_hash.raw, vb2_digest_size(anchor->cbfs_hash.algo));
272 if (fmap_hash) {
273 update_and_info("FMAP hash",
274 metadata_hash_anchor_fmap_hash(anchor), fmap_hash,
275 vb2_digest_size(anchor->cbfs_hash.algo));
276 }
277 if (mhc->fixup && mhc->fixup(&buffer, mhc->offset) != 0)
278 return -1;
279 if (!partitioned_file_write_region(param.image_file, &buffer))
280 return -1;
281 return 0;
282
283}
284
285/* This should be called after every time CBFS metadata might have changed. It
286 will recalculate and update the metadata hash in the bootblock if needed. */

Callers 2

maybe_update_fmap_hashFunction · 0.85

Calls 8

buffer_getFunction · 0.85
update_and_infoFunction · 0.85
fixupMethod · 0.80
memcmpFunction · 0.50
vb2_digest_sizeFunction · 0.50

Tested by

no test coverage detected