@@ -22,6 +22,8 @@
#include "fit_common.h"
#include <image.h>
#include <u-boot/crc.h>
+#include <sys/ioctl.h>
+#include <linux/fs.h>
int fit_verify_header(unsigned char *ptr, int image_size,
struct image_tool_params *params)
@@ -58,6 +60,14 @@ int mmap_fdt(const char *cmdname, const char *fname, size_t size_inc,
goto err;
}
+ if (sbuf->st_size == 0 && S_ISBLK(sbuf->st_mode)) {
+ if (ioctl(fd, BLKGETSIZE64, &sbuf->st_size) < 0) {
+ fprintf(stderr, "%s: Can't determine size of %s: %s\n",
+ cmdname, fname, strerror(errno));
+ goto err;
+ }
+ }
+
if (size_inc) {
sbuf->st_size += size_inc;
if (ftruncate(fd, sbuf->st_size)) {