[PATCH] mtd-utils: fix corrupt cleanmarker with flash_erase -j command

LiuShuo b35362 at freescale.com
Wed Aug 17 03:35:34 EDT 2011


于 2011年08月16日 23:06, Artem Bityutskiy 写道:
> On Wed, 2011-08-03 at 13:50 +0800, b35362 at freescale.com wrote:
>> From: Liu Shuo<b35362 at freescale.com>
>>
>> Flash_erase -j should fill discrete freeoob areas with required bytes
>> of JFFS2 cleanmarker in jffs2_check_nand_cleanmarker(). Not just fill
>> the first freeoob area.
>>
>> Signed-off-by: Liu Shuo<b35362 at freescale.com>
>> Signed-off-by: Li Yang<leoli at freescale.com>
> ...
>
>>   	/*
>>   	 * Process user arguments
>> @@ -197,15 +198,40 @@ int main(int argc, char *argv[])
>>   			if (ioctl(fd, MEMGETOOBSEL,&oobinfo) != 0)
>>   				return sys_errmsg("%s: unable to get NAND oobinfo", mtd_device);
>>
>> +			cleanmarker.totlen = cpu_to_je32(8);
>>   			/* Check for autoplacement */
>>   			if (oobinfo.useecc == MTD_NANDECC_AUTOPLACE) {
>> +				struct nand_ecclayout_user ecclayout;
>>   				/* Get the position of the free bytes */
>> -				if (!oobinfo.oobfree[0][1])
>> +				if (ioctl(fd, ECCGETLAYOUT,&ecclayout) != 0)
>> +					return sys_errmsg("%s: unable to get NAND ecclayout", mtd_device);
>> +
> Hmm, shouldn't we instead make MTD_OOB_AUTO be available for userspace
> via an ioctl instead and make flash_eraseall use it instead?
>


I think We can add a new ioctl MEMSETOOBMODE for selecting a mode to 
access the OOB area.

Add new member into struct mtd_info:

struct mtd_info {
     ......

     enum {
          MTD_OOB_PLACE,
          MTD_OOB_AUTO,
          MTD_OOB_RAW,
     } oob_mode;
}

In function mtd_do_writeoob() (in drivers/mtd/mtdchar.c) :
     -  ops.mode = MTD_OOB_PLACE;
     + ops.mode = mtd->oob_mode;



Could we do it like this ?

Thanks
-LiuShuo










More information about the linux-mtd mailing list