[OpenWrt-Devel] [PATCH] mtd: skip bad blocks when writing
Rafał Miłecki
zajec5 at gmail.com
Wed Jul 11 00:36:51 EDT 2018
Please sign off your patch with full real name and send again.
On 18.05.2018 17:25, Lev wrote:
> ---
> package/system/mtd/src/jffs2.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> 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)) {
I think your checks should happen in reverted order. It makes more sense
to first validate mtdofs value and then use it.
> + if (!quiet)
> + fprintf(stderr, "\nSkipping bad block at 0x%08x ", mtdofs);
Why \n at the beginning? Why empty spaces at the end?
> +
> + 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;
>
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list