mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-06-24 15:42:48 +00:00
imagetool: make the image_save_datafile() available to all image types
Move the image_save_datafile() function from an U-Multi specific file (default_image.c) to a file common to all image types (image.c). And rename it to genimg_save_datafile(), to make clear it is useful for any image type. Signed-off-by: Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
This commit is contained in:
parent
0ca6691c2e
commit
067d156075
4 changed files with 46 additions and 28 deletions
|
@ -113,3 +113,30 @@ int imagetool_verify_print_header(
|
|||
|
||||
return retval;
|
||||
}
|
||||
|
||||
int imagetool_save_datafile(
|
||||
const char *file_name,
|
||||
ulong file_data,
|
||||
ulong file_len)
|
||||
{
|
||||
int dfd;
|
||||
|
||||
dfd = open(file_name, O_RDWR | O_CREAT | O_TRUNC | O_BINARY,
|
||||
S_IRUSR | S_IWUSR);
|
||||
if (dfd < 0) {
|
||||
fprintf(stderr, "Can't open \"%s\": %s\n",
|
||||
file_name, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (write(dfd, (void *)file_data, file_len) != (ssize_t)file_len) {
|
||||
fprintf(stderr, "Write error on \"%s\": %s\n",
|
||||
file_name, strerror(errno));
|
||||
close(dfd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
close(dfd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue