mtd/util flash_eraseall.c,1.18,1.19

lavinen at infradead.org lavinen at infradead.org
Thu Dec 9 06:06:10 EST 2004


Update of /home/cvs/mtd/util
In directory phoenix.infradead.org:/tmp/cvs-serv16056

Modified Files:
	flash_eraseall.c 
Log Message:
Fixed overflow in progress percent. Added check for bad blocks.


Index: flash_eraseall.c
===================================================================
RCS file: /home/cvs/mtd/util/flash_eraseall.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- flash_eraseall.c	2 Dec 2004 19:27:54 -0000	1.18
+++ flash_eraseall.c	9 Dec 2004 11:06:07 -0000	1.19
@@ -61,7 +61,7 @@
 	mtd_info_t meminfo;
 	int fd, clmpos = 0, clmlen = 8;
 	erase_info_t erase;
-	int isNAND;
+	int isNAND, bbtest = 1;
 
 	process_options(argc, argv);
 
@@ -127,11 +127,27 @@
 	}
 
 	for (erase.start = 0; erase.start < meminfo.size; erase.start += meminfo.erasesize) {
+		if (bbtest) {
+			loff_t offset = erase.start;
+			int ret = ioctl(fd, MEMGETBADBLOCK, &offset);
+			if (ret > 0) {
+				if (!quiet)
+					printf ("\nSkipping bad block at 0x%08x\n", erase.start);
+				continue;
+			} else if (ret == -EOPNOTSUPP) {
+				fprintf(stderr, "%s: %s: Bad block check not available\n", exe_name, mtd_device);
+				bbtest = 0;
+			} else if (ret < 0) {
+				fprintf(stderr, "\n%s: %s: MTD get bad block failed: %s\n", exe_name, mtd_device, strerror(errno));
+				exit(1);
+			}				
+		}
 
 		if (!quiet) {
 			printf
-			    ("\rErasing %d Kibyte @ %x -- %2d %% complete.",
+                           ("\rErasing %d Kibyte @ %x -- %2llu %% complete.",
 			     meminfo.erasesize / 1024, erase.start,
+			     (unsigned long long) 
 			     erase.start * 100 / meminfo.size);
 		}
 		fflush(stdout);





More information about the linux-mtd-cvs mailing list