diff mbox series

[LEDE-DEV] jffs corruption

Message ID CACwWb3AHr8cO3A-QOHAhvtwpTHp8xa8jgPs3JWD97x4DfbKssA@mail.gmail.com
State Awaiting Upstream
Delegated to: John Crispin
Headers show
Series [LEDE-DEV] jffs corruption | expand

Commit Message

Levente May 17, 2018, 7:28 a.m. UTC
Dear all,


One of my college ended up with corrupted jffs filesystem. He had
issues with bad blocks in the FLASH memory.

He ended up this patch that fixed his issue.

Is it worth submitting?

                if (read(outfd, buf, erasesize) != erasesize) {
                        fdeof = 1;
                        break;

Comments

Jo-Philipp Wich May 17, 2018, 8:42 a.m. UTC | #1
Hi,

the patch seems useful, I suggest to send it upstream to receive wider
feedback there. If the MTD guys deem it suitable, we can cherry pick it
from there.

~ Jo
diff mbox series

Patch

diff --git a/package/system/mtd/src/jffs2.c b/package/system/mtd/src/jffs2.c
index b432f64ac0..5bf3eec328 100644
--- a/package/system/mtd/src/jffs2.c
+++ b/package/system/mtd/src/jffs2.c
@@ -308,6 +308,16 @@  int mtd_write_jffs2(const char *mtd, const char
*filename, const char *dir)
        for(;;) {
                struct jffs2_unknown_node *node = (struct
jffs2_unknown_node *) buf;

+               while (mtd_block_is_bad(outfd, mtdofs) && (mtdofs < mtdsize)) {
+                       if (!quiet)
+                               fprintf(stderr, "\nSkipping bad block
at 0x%08x   ", mtdofs);
+
+                       mtdofs += erasesize;
+
+                       /* Move the file pointer along over the bad block. */
+                       lseek(outfd, erasesize, SEEK_CUR);
+               }
+