Hi Richard,

On Wed, Jun 18, 2014 at 03:44:30PM +0200, Richard Genoud wrote:
> With the "skip bad block" option, nanddump is not dumping the right
> length if there's bad blocks.
> 
> This patch moves the end read address each time a bad block is
> encountered.

This changes nanddump behaviour from upstream historical --omitbad (-b; 
removed in upstream d8b8f780ec3c), to existing skipbad, for which upstream 
uses the --bb=skipbad command line parameter. To avoid confusion, we should 
adapt to upstream command line parameter names, IMO.

Thanks,
baruch

> Signed-off-by: Richard Genoud <[email protected]>
> ---
>  miscutils/nandwrite.c | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/miscutils/nandwrite.c b/miscutils/nandwrite.c
> index 8c4da802f6b3..a3593adedc82 100644
> --- a/miscutils/nandwrite.c
> +++ b/miscutils/nandwrite.c
> @@ -166,6 +166,10 @@ int nandwrite_main(int argc UNUSED_PARAM, char **argv)
>                               int bad_len = MIN(tmp, end_addr) - mtdoffset;
>                               dump_bad(&meminfo, bad_len, opts & OPT_o);
>                       }
> +                     /* with option skip bad block, increase the length */
> +                     if (IS_NANDDUMP && (opts & OPT_b)) {
> +                             end_addr += (tmp - blockstart);
> +                     }
>                       mtdoffset = tmp;
>               }
>       }
> @@ -182,9 +186,16 @@ int nandwrite_main(int argc UNUSED_PARAM, char **argv)
>                       mtdoffset = next_good_eraseblock(fd, &meminfo, 
> blockstart);
>                       if (IS_NANDWRITE)
>                               printf("Writing at 0x%08x\n", mtdoffset);
> -                     else if (mtdoffset > blockstart && !(opts & OPT_b)) {
> -                             int bad_len = MIN(mtdoffset, limit) - 
> blockstart;
> -                             dump_bad(&meminfo, bad_len, opts & OPT_o);
> +                     else if (mtdoffset > blockstart) {
> +                             if (opts & OPT_b) {
> +                                     /* omit bad block, but increase the 
> length */
> +                                     end_addr += (mtdoffset - blockstart);
> +                                     limit = MIN(meminfo.size, end_addr);
> +                             } else {
> +                                     /* dump bad block if asked */
> +                                     int bad_len = MIN(mtdoffset, limit) - 
> blockstart;
> +                                     dump_bad(&meminfo, bad_len, opts & 
> OPT_o);
> +                             }
>                       }
>                       if (mtdoffset >= limit)
>                               break;

-- 
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - [email protected] - tel: +972.2.679.5364, http://www.tkos.co.il -
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to