4 * Written by Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
6 * SPDX-License-Identifier: GPL-2.0+
13 struct image_type_params *imagetool_get_type(int type)
15 struct image_type_params *curr;
16 struct image_type_params *start = ll_entry_start(
17 struct image_type_params, image_type);
18 struct image_type_params *end = ll_entry_end(
19 struct image_type_params, image_type);
21 for (curr = start; curr != end; curr++) {
22 if (curr->check_image_type) {
23 if (!curr->check_image_type(type))
30 int imagetool_verify_print_header(
33 struct image_type_params *tparams,
34 struct image_tool_params *params)
37 struct image_type_params *curr;
39 struct image_type_params *start = ll_entry_start(
40 struct image_type_params, image_type);
41 struct image_type_params *end = ll_entry_end(
42 struct image_type_params, image_type);
44 for (curr = start; curr != end; curr++) {
45 if (curr->verify_header) {
46 retval = curr->verify_header((unsigned char *)ptr,
47 sbuf->st_size, params);
51 * Print the image information if verify is
54 if (curr->print_header) {
55 curr->print_header(ptr);
58 "%s: print_header undefined for %s\n",
59 params->cmdname, curr->name);
69 int imagetool_save_subimage(
70 const char *file_name,
76 dfd = open(file_name, O_RDWR | O_CREAT | O_TRUNC | O_BINARY,
79 fprintf(stderr, "Can't open \"%s\": %s\n",
80 file_name, strerror(errno));
84 if (write(dfd, (void *)file_data, file_len) != (ssize_t)file_len) {
85 fprintf(stderr, "Write error on \"%s\": %s\n",
86 file_name, strerror(errno));