X-Git-Url: https://git.karo-electronics.de/?a=blobdiff_plain;f=tools%2Fimagetool.c;h=351211cd5387b9e727ce22501428d2a6af19cc7b;hb=7e4a6ae62c7ee567ae43e94445e561b3ec8343b9;hp=4b0b73db5277a07629bc306156b37f12ae440d82;hpb=a851604ca36493e8319a7d3a17594b7224d546fe;p=karo-tx-uboot.git diff --git a/tools/imagetool.c b/tools/imagetool.c index 4b0b73db52..351211cd53 100644 --- a/tools/imagetool.c +++ b/tools/imagetool.c @@ -91,3 +91,25 @@ 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)); + return -1; + } + close(fd); + + return sbuf.st_size; +}