libpayload: rename cbfs variable from name to vardata
The dynamically sized region after struct cbfs_file doesn't contain only the file name anymore. Change-Id: I3241cb2f0cbec3fcf4d3c27d638e2847e43f4761 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-on: http://review.coreboot.org/11676 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
parent
377d1db57d
commit
5c6dc72501
|
@ -97,8 +97,8 @@ const struct cbfs_header *cbfs_get_header(struct cbfs_media *media)
|
||||||
/* public API starts here*/
|
/* public API starts here*/
|
||||||
struct cbfs_file *cbfs_get_file(struct cbfs_media *media, const char *name)
|
struct cbfs_file *cbfs_get_file(struct cbfs_media *media, const char *name)
|
||||||
{
|
{
|
||||||
const char *file_name;
|
const char *vardata;
|
||||||
uint32_t offset, romsize, name_len;
|
uint32_t offset, romsize, vardata_len;
|
||||||
const struct cbfs_header *header;
|
const struct cbfs_header *header;
|
||||||
struct cbfs_file file, *file_ptr;
|
struct cbfs_file file, *file_ptr;
|
||||||
struct cbfs_media default_media;
|
struct cbfs_media default_media;
|
||||||
|
@ -153,29 +153,29 @@ struct cbfs_file *cbfs_get_file(struct cbfs_media *media, const char *name)
|
||||||
offset += new_align;
|
offset += new_align;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
name_len = ntohl(file.offset) - sizeof(file);
|
vardata_len = ntohl(file.offset) - sizeof(file);
|
||||||
DEBUG(" - load entry 0x%x file name (%d bytes)...\n", offset,
|
DEBUG(" - load entry 0x%x variable data (%d bytes)...\n",
|
||||||
name_len);
|
offset, vardata_len);
|
||||||
|
|
||||||
// load file name (arbitrary length).
|
// load file name (arbitrary length).
|
||||||
file_name = (const char*)media->map(
|
vardata = (const char*)media->map(
|
||||||
media, offset + sizeof(file), name_len);
|
media, offset + sizeof(file), vardata_len);
|
||||||
if (file_name == CBFS_MEDIA_INVALID_MAP_ADDRESS) {
|
if (vardata == CBFS_MEDIA_INVALID_MAP_ADDRESS) {
|
||||||
ERROR("ERROR: Failed to get filename: 0x%x.\n", offset);
|
ERROR("ERROR: Failed to get filename: 0x%x.\n", offset);
|
||||||
} else if (strcmp(file_name, name) == 0) {
|
} else if (strcmp(vardata, name) == 0) {
|
||||||
int file_offset = ntohl(file.offset),
|
int file_offset = ntohl(file.offset),
|
||||||
file_len = ntohl(file.len);
|
file_len = ntohl(file.len);
|
||||||
DEBUG("Found file (offset=0x%x, len=%d).\n",
|
DEBUG("Found file (offset=0x%x, len=%d).\n",
|
||||||
offset + file_offset, file_len);
|
offset + file_offset, file_len);
|
||||||
media->unmap(media, file_name);
|
media->unmap(media, vardata);
|
||||||
file_ptr = media->map(media, offset,
|
file_ptr = media->map(media, offset,
|
||||||
file_offset + file_len);
|
file_offset + file_len);
|
||||||
media->close(media);
|
media->close(media);
|
||||||
return file_ptr;
|
return file_ptr;
|
||||||
} else {
|
} else {
|
||||||
DEBUG(" (unmatched file @0x%x: %s)\n", offset,
|
DEBUG(" (unmatched file @0x%x: %s)\n", offset,
|
||||||
file_name);
|
vardata);
|
||||||
media->unmap(media, file_name);
|
media->unmap(media, vardata);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move to next file.
|
// Move to next file.
|
||||||
|
|
Loading…
Reference in New Issue