[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: [PATCHv4] nandwrite: new mtd-utils applet
From: Baruch Siach <baruch () tkos ! co ! il>
Date: 2010-08-29 7:33:58
Message-ID: 20100829073358.GA8285 () jasper ! tkos ! co ! il
[Download RAW message or body]
Hi Denys,
On Wed, Aug 25, 2010 at 04:38:08PM +0200, Denys Vlasenko wrote:
> On Wed, Aug 25, 2010 at 6:38 AM, Baruch Siach <baruch@tkos.co.il> wrote:
> > + static unsigned next_good_eraseblock(int fd, struct mtd_info_user *meminfo,
> > + unsigned block_offset)
> > +{
> > + loff_t offs = block_offset;
> > +
> > + while (1) {
> > + if (block_offset >= meminfo->size)
> > + bb_error_msg_and_die("not enough space in MTD device");
> > + if (xioctl(fd, MEMGETBADBLOCK, &offs)) {
> > + offs += meminfo->erasesize;
> > + printf("Skipping bad block at 0x%08llx\n", offs);
>
> The message prints wrong offset (offs +=... should be after the message).
> %llx does not necessarily match loff_t type.
> You forgot to increment block_offset, thus you can run off the MTD.
>
> > + } else
> > + return offs;
> > + }
> > +}
>
> How about this?
>
> while (1) {
> loff_t offs;
> if (block_offset >= meminfo->size)
> bb_error_msg_and_die("not enough space in MTD device");
> offs = block_offset;
> if (xioctl(fd, MEMGETBADBLOCK, &offs) == 0)
> return block_offset;
> /* ioctl returned 1 = "bad block" */
> printf("Skipping bad block at 0x%08x\n", block_offset);
> block_offset += meminfo->erasesize;
> }
>
> Applied with a few changes:
>
> http://git.busybox.net/busybox/commit/?id=6f32ea4039535c48759a217fd6352193846a393c
Thanks.
> Please test current git.
I've found two problems:
1. The move from bb_strtou() to xatou() breaks hex offsets
2. The first erase block isn't checked when mtdoffset is not erase block
aligned
I'll post two patches fixing these problems as a reply to this message
shortly.
baruch
--
~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic