packages: clean up the package folder
[openwrt.org/openwrt.git] / package / system / mtd / src / jffs2.c
blob:a/package/system/mtd/src/jffs2.c -> blob:b/package/system/mtd/src/jffs2.c
--- a/package/system/mtd/src/jffs2.c
+++ b/package/system/mtd/src/jffs2.c
@@ -1,7 +1,7 @@
 /*
  * jffs2 on-disk structure generator for mtd
  *
- * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+ * Copyright (C) 2008 Felix Fietkau <nbd@nbd.name>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License v2
@@ -59,6 +59,15 @@
 	}
 	ofs = ofs % erasesize;
 	if (ofs == 0) {
+		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);
+		}
 		mtd_erase_block(outfd, mtdofs);
 		write(outfd, buf, erasesize);
 		mtdofs += erasesize;

comments