[LinuxBIOS] r2503 - trunk/LinuxBIOSv2/util/flashrom
svn at openbios.org
svn at openbios.org
Wed Nov 22 00:48:53 CET 2006
Author: stepan
Date: 2006-11-22 00:48:51 +0100 (Wed, 22 Nov 2006)
New Revision: 2503
Modified:
trunk/LinuxBIOSv2/util/flashrom/flash_rom.c
Log:
flashrom: Only write the flash if the image has the same size
Signed-off-by: Stefan Reinauer <stepan at coresystems.de>
Acked-by: Segher Boessenkool <segher at kernel.crashing.org>
Modified: trunk/LinuxBIOSv2/util/flashrom/flash_rom.c
===================================================================
--- trunk/LinuxBIOSv2/util/flashrom/flash_rom.c 2006-11-21 15:09:05 UTC (rev 2502)
+++ trunk/LinuxBIOSv2/util/flashrom/flash_rom.c 2006-11-21 23:48:51 UTC (rev 2503)
@@ -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 @@
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);
More information about the coreboot
mailing list