diff mbox series

[mtd-utils,6/7] misc-utils: flashcp: verify data in --partition

Message ID 20221102224757.58012-7-brandon.maier@collins.com
State Accepted
Delegated to: David Oberhollenzer
Headers show
Series misc-utils: flashcp: Bugfixes to --partition | expand

Commit Message

Brandon Maier Nov. 2, 2022, 10:47 p.m. UTC
The --partition mode is not verifying that data is being written
successfully.

Signed-off-by: Brandon Maier <brandon.maier@collins.com>
---
 misc-utils/flashcp.c | 9 +++++++++
 1 file changed, 9 insertions(+)
diff mbox series

Patch

diff --git a/misc-utils/flashcp.c b/misc-utils/flashcp.c
index 02be081..13ff2f1 100644
--- a/misc-utils/flashcp.c
+++ b/misc-utils/flashcp.c
@@ -465,6 +465,15 @@  DIFF_BLOCKS:
 			/* write to device */
 			safe_lseek(dev_fd, current_dev_block, SEEK_SET, device);
 			safe_write(dev_fd,src,i,written,(unsigned long long)filestat.st_size,device);
+
+			/* read from device */
+			safe_lseek(dev_fd, current_dev_block, SEEK_SET, device);
+			safe_read (dev_fd,device,dest,i);
+
+			/* compare buffers for write success */
+			if (memcmp (src,dest,i))
+				log_failure("File does not seem to match flash data. First mismatch at 0x%.8zx-0x%.8zx\n",
+						written,written + i);
 		}
 
 		erase.start += i;