Linux-mtd Archive on lore.kernel.org
 help / color / mirror / Atom feed
* mtd
@ 2018-05-18  8:00 Levente
  2018-05-18  9:09 ` mtd David Oberhollenzer
  0 siblings, 1 reply; 6+ messages in thread
From: Levente @ 2018-05-18  8:00 UTC (permalink / raw)
  To: linux-mtd

Dear all,


I don't know if I post this to the right place, so forgive my ignorance.

My college discovered a possible bug in OpenWRT's mtd utility. When
writing to jffs device, the 'mtd' utility does not skip bad blocks.

This patch seems to fix this issue.


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);
+               }
+
                if (read(outfd, buf, erasesize) != erasesize) {
                        fdeof = 1;
                        break;


I've cloned your utility repository, but didn't find jffs2.c anywhere.

Best regards,
Levente

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-07-13  9:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-18  8:00 mtd Levente
2018-05-18  9:09 ` mtd David Oberhollenzer
2018-05-18  9:14   ` mtd Levente
     [not found]     ` <1397936863.163523.1526636992502.JavaMail.zimbra@sigma-star.at>
2018-05-18 10:26       ` [OpenWrt-Devel] OpenWRT mtd tooling vs mtd-utils Jo-Philipp Wich
2018-05-18 11:15         ` David Oberhollenzer
2018-07-13  9:54           ` Rafał Miłecki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox