summaryrefslogtreecommitdiffstats
path: root/flash_rom.c
diff options
context:
space:
mode:
authorStefan Reinauer <stepan@coresystems.de>2006-11-21 23:48:51 +0000
committerStefan Reinauer <stefan.reinauer@coreboot.org>2006-11-21 23:48:51 +0000
commit018aca8dcc85d696ccd8c036d1d63dca78e761a2 (patch)
treed351e51ad04bef95fdec7db4008f992924073b90 /flash_rom.c
parent566820d7f679f05f32c16b7e701ea438ec1fd4f7 (diff)
downloadast2050-flashrom-018aca8dcc85d696ccd8c036d1d63dca78e761a2.zip
ast2050-flashrom-018aca8dcc85d696ccd8c036d1d63dca78e761a2.tar.gz
Only write the flash if the image has the same size
Corresponding to flashrom svn r76 and coreboot v2 svn r2503. Signed-off-by: Stefan Reinauer <stepan@coresystems.de> Acked-by: Segher Boessenkool <segher@kernel.crashing.org>
Diffstat (limited to 'flash_rom.c')
-rw-r--r--flash_rom.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/flash_rom.c b/flash_rom.c
index b9ef45e..b1ca7b3 100644
--- a/flash_rom.c
+++ b/flash_rom.c
@@ -28,6 +28,8 @@
#include <errno.h>
#include <fcntl.h>
#include <sys/mman.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
@@ -332,10 +334,21 @@ int main(int argc, char *argv[])
fclose(image);
printf("done\n");
} else {
+ struct stat image_stat;
+
if ((image = fopen(filename, "r")) == NULL) {
perror(filename);
exit(1);
}
+ if (fstat(fileno(image), &image_stat) != 0) {
+ perror(filename);
+ exit(1);
+ }
+ if(image_stat.st_size!=flash->total_size*1024) {
+ perror("Image size doesnt match");
+ exit(1);
+ }
+
fread(buf, sizeof(char), size, image);
show_id(buf, size);
fclose(image);
OpenPOWER on IntegriCloud