summaryrefslogtreecommitdiffstats
path: root/tools/imagetool.c
diff options
context:
space:
mode:
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>2015-01-15 02:48:06 -0200
committerTom Rini <trini@ti.com>2015-01-29 13:38:41 -0500
commit067d15607598884e270f3076c721f56d3c4f65e6 (patch)
tree06f5767d8a717e895179d0209cc32ab1af2fb7e1 /tools/imagetool.c
parent0ca6691c2ec20ff264d882854c339795579991f5 (diff)
downloadtalos-obmc-uboot-067d15607598884e270f3076c721f56d3c4f65e6.tar.gz
talos-obmc-uboot-067d15607598884e270f3076c721f56d3c4f65e6.zip
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>
Diffstat (limited to 'tools/imagetool.c')
-rw-r--r--tools/imagetool.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/tools/imagetool.c b/tools/imagetool.c
index e4de7af984..a25b86b36e 100644
--- a/tools/imagetool.c
+++ b/tools/imagetool.c
@@ -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;
+}
OpenPOWER on IntegriCloud