Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(890)

Unified Diff: flashrom.c

Issue 6611015: Support -i partition:file feature for both read and write. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/flashrom.git@master
Patch Set: fixed according to code review and security check. Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « flash.h ('k') | layout.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: flashrom.c
diff --git a/flashrom.c b/flashrom.c
index 2cf853ae36832b9500a9835504233e0569974932..e9eddc235f728b0cf076433c9976aba1a0389d02 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -1316,6 +1316,7 @@ int read_flash_to_file(struct flashchip *flash, char *filename)
unsigned long size = flash->total_size * 1024;
unsigned char *buf = calloc(size, sizeof(char));
int ret = 0;
+ int i;
msg_cinfo("Reading flash... ");
if (!buf) {
@@ -1323,12 +1324,27 @@ int read_flash_to_file(struct flashchip *flash, char *filename)
msg_cinfo("FAILED.\n");
return 1;
}
+
+ /* To support partial read, fill buffer to all 0xFF at beginning to make
+ * debug easier. */
+ memset(buf, 0xFF, size);
+
if (!flash->read) {
msg_cerr("No read function available for this flash chip.\n");
ret = 1;
goto out_free;
}
- if (flash->read(flash, buf, 0, size)) {
+
+ /* First try to handle partial read case, rather than read the whole
+ * flash, which is slow. */
+ ret = handle_partial_read(flash, buf, flash->read);
+ if (ret < 0) {
+ msg_cerr("Partial read operation failed!\n");
+ ret = 1;
+ goto out_free;
+ } else if (ret > 0) {
+ /* Partial read has been handled, pass the whole flash read. */
+ } else if (flash->read(flash, buf, 0, size)) {
msg_cerr("Read operation failed!\n");
ret = 1;
goto out_free;
« no previous file with comments | « flash.h ('k') | layout.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698