mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-09-27 07:00:46 +09:00
tools: image-host: clean function fit_config_get_hash_list
This commit creates a function fit_config_add_hash that will be used in the next commit to support several 'sub-images'. Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
184aa65041
commit
5a4116f1a2
@ -700,53 +700,13 @@ static const char *fit_config_get_image_list(void *fit, int noffset,
|
||||
return default_list;
|
||||
}
|
||||
|
||||
static int fit_config_get_hash_list(void *fit, int conf_noffset,
|
||||
int sig_offset, struct strlist *node_inc)
|
||||
static int fit_config_add_hash(void *fit, const char *conf_name, const char *sig_name,
|
||||
struct strlist *node_inc, const char *iname, int image_noffset)
|
||||
{
|
||||
int allow_missing;
|
||||
const char *prop, *iname, *end;
|
||||
const char *conf_name, *sig_name;
|
||||
char name[200], path[200];
|
||||
int image_count;
|
||||
int ret, len;
|
||||
|
||||
conf_name = fit_get_name(fit, conf_noffset, NULL);
|
||||
sig_name = fit_get_name(fit, sig_offset, NULL);
|
||||
|
||||
/*
|
||||
* Build a list of nodes we need to hash. We always need the root
|
||||
* node and the configuration.
|
||||
*/
|
||||
strlist_init(node_inc);
|
||||
snprintf(name, sizeof(name), "%s/%s", FIT_CONFS_PATH, conf_name);
|
||||
if (strlist_add(node_inc, "/") ||
|
||||
strlist_add(node_inc, name))
|
||||
goto err_mem;
|
||||
|
||||
/* Get a list of images that we intend to sign */
|
||||
prop = fit_config_get_image_list(fit, sig_offset, &len,
|
||||
&allow_missing);
|
||||
if (!prop)
|
||||
return 0;
|
||||
|
||||
/* Locate the images */
|
||||
end = prop + len;
|
||||
image_count = 0;
|
||||
for (iname = prop; iname < end; iname += strlen(iname) + 1) {
|
||||
int noffset;
|
||||
int image_noffset;
|
||||
int hash_count;
|
||||
|
||||
image_noffset = fit_conf_get_prop_node(fit, conf_noffset,
|
||||
iname);
|
||||
if (image_noffset < 0) {
|
||||
printf("Failed to find image '%s' in configuration '%s/%s'\n",
|
||||
iname, conf_name, sig_name);
|
||||
if (allow_missing)
|
||||
continue;
|
||||
|
||||
return -ENOENT;
|
||||
}
|
||||
int ret;
|
||||
|
||||
ret = fdt_get_path(fit, image_noffset, path, sizeof(path));
|
||||
if (ret < 0)
|
||||
@ -798,6 +758,71 @@ static int fit_config_get_hash_list(void *fit, int conf_noffset,
|
||||
goto err_mem;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err_mem:
|
||||
printf("Out of memory processing configuration '%s/%s'\n", conf_name,
|
||||
sig_name);
|
||||
return -ENOMEM;
|
||||
|
||||
err_path:
|
||||
printf("Failed to get path for image '%s' in configuration '%s/%s': %s\n",
|
||||
iname, conf_name, sig_name, fdt_strerror(ret));
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static int fit_config_get_hash_list(void *fit, int conf_noffset,
|
||||
int sig_offset, struct strlist *node_inc)
|
||||
{
|
||||
int allow_missing;
|
||||
const char *prop, *iname, *end;
|
||||
const char *conf_name, *sig_name;
|
||||
char name[200];
|
||||
int image_count;
|
||||
int ret, len;
|
||||
|
||||
conf_name = fit_get_name(fit, conf_noffset, NULL);
|
||||
sig_name = fit_get_name(fit, sig_offset, NULL);
|
||||
|
||||
/*
|
||||
* Build a list of nodes we need to hash. We always need the root
|
||||
* node and the configuration.
|
||||
*/
|
||||
strlist_init(node_inc);
|
||||
snprintf(name, sizeof(name), "%s/%s", FIT_CONFS_PATH, conf_name);
|
||||
if (strlist_add(node_inc, "/") ||
|
||||
strlist_add(node_inc, name))
|
||||
goto err_mem;
|
||||
|
||||
/* Get a list of images that we intend to sign */
|
||||
prop = fit_config_get_image_list(fit, sig_offset, &len,
|
||||
&allow_missing);
|
||||
if (!prop)
|
||||
return 0;
|
||||
|
||||
/* Locate the images */
|
||||
end = prop + len;
|
||||
image_count = 0;
|
||||
for (iname = prop; iname < end; iname += strlen(iname) + 1) {
|
||||
int image_noffset;
|
||||
|
||||
image_noffset = fit_conf_get_prop_node(fit, conf_noffset,
|
||||
iname);
|
||||
if (image_noffset < 0) {
|
||||
printf("Failed to find image '%s' in configuration '%s/%s'\n",
|
||||
iname, conf_name, sig_name);
|
||||
if (allow_missing)
|
||||
continue;
|
||||
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
ret = fit_config_add_hash(fit, conf_name,
|
||||
sig_name, node_inc,
|
||||
iname, image_noffset);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
image_count++;
|
||||
}
|
||||
|
||||
@ -813,11 +838,6 @@ err_mem:
|
||||
printf("Out of memory processing configuration '%s/%s'\n", conf_name,
|
||||
sig_name);
|
||||
return -ENOMEM;
|
||||
|
||||
err_path:
|
||||
printf("Failed to get path for image '%s' in configuration '%s/%s': %s\n",
|
||||
iname, conf_name, sig_name, fdt_strerror(ret));
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static int fit_config_get_data(void *fit, int conf_noffset, int noffset,
|
||||
|
Loading…
Reference in New Issue
Block a user