mtd-utils: ubiformat: writing images on flash with badblocks.

Artem Bityutskiy dedekind1 at gmail.com
Sun Sep 11 06:59:22 EDT 2011


On Thu, 2011-08-25 at 10:26 +0200, Anton Olofsson wrote:
> Hi!
> 
> We encountered some problems with ubiformat
> and writing ubi-images onto flash with badblocks.
> 
> If a badblock was encountered during write ubiformat would
> skip writing that “file-block” altogether, and this would eventually
> result in EOF while trying to read the image file.
> 
> The quick fix was to rewind the filedescriptor for the next pass.
> 
> Im not sure if others have encountered this problem
> or even if this is the correct way to handle this situation.
> 
> Here is the change made though:


Hi, thanks for the fix, but I have few notes:

1. The patch does not have your Signed-off-by:
2. The patch is line-wrapped, so does not apply.


> --- a/ubi-utils/ubiformat.c
> +++ b/ubi-utils/ubiformat.c
> @@ -546,6 +546,11 @@ static int flash_image(libmtd_t libmtd, const
> struct mtd_dev_info *mtd,
>                                 if (mark_bad(mtd, si, eb))
>                                         goto out_close;
>                         }
> +                       /*rewind fd so next read_all(...) reads correct block*/
> +                       if (lseek(fd, -mtd->eb_size, SEEK_CUR) == -1) {
> +                               sys_errmsg("unable to rewind file");
> +                               goto out_close;
> +                       }
>                         continue;

But most importantly, I think this will break the case when the input
is stdout (pipe), not a file. So I quickly cooked the below patch
instead. I did not test it - would it be possible for you to give it a
test and let me know if it is ok, in which case I'll push it to the
mtd-utils repository.



More information about the linux-mtd mailing list