X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=tools%2Fimagetool.c;h=08d191d9f894a6b86afd867de33ec4026c2286f2;hb=efa7ed7236ee5bfab871f35ce70f3e3e1d39b4f6;hp=4b0b73db5277a07629bc306156b37f12ae440d82;hpb=b9cb64825b5e6efeb715abd8b48d9b12f98973e9;p=u-boot diff --git a/tools/imagetool.c b/tools/imagetool.c index 4b0b73db52..08d191d9f8 100644 --- a/tools/imagetool.c +++ b/tools/imagetool.c @@ -51,7 +51,8 @@ int imagetool_verify_print_header( * successful */ if ((*curr)->print_header) { - (*curr)->print_header(ptr); + if (!params->quiet) + (*curr)->print_header(ptr); } else { fprintf(stderr, "%s: print_header undefined for %s\n", @@ -91,3 +92,26 @@ int imagetool_save_subimage( return 0; } + +int imagetool_get_filesize(struct image_tool_params *params, const char *fname) +{ + struct stat sbuf; + int fd; + + fd = open(fname, O_RDONLY | O_BINARY); + if (fd < 0) { + fprintf(stderr, "%s: Can't open %s: %s\n", + params->cmdname, fname, strerror(errno)); + return -1; + } + + if (fstat(fd, &sbuf) < 0) { + fprintf(stderr, "%s: Can't stat %s: %s\n", + params->cmdname, fname, strerror(errno)); + close(fd); + return -1; + } + close(fd); + + return sbuf.st_size; +}