Re: [PATCH] mtd-utils: fix corrupt cleanmarker with flash_erase -j command
From: LiuShuo <hidden>
Date: 2011-08-17 07:29:10
=E4=BA=8E 2011=E5=B9=B408=E6=9C=8816=E6=97=A5 23:06, Artem Bityutskiy =E5= =86=99=E9=81=93:
On Wed, 2011-08-03 at 13:50 +0800, b35362@freescale.com wrote:quoted
From: Liu Shuo<redacted> 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<redacted> Signed-off-by: Li Yang<redacted>...quoted
/* * Process user arguments@@ -197,15 +198,40 @@ int main(int argc, char *argv[]) if (ioctl(fd, MEMGETOOBSEL,&oobinfo) !=3D 0) return sys_errmsg("%s: unable to get NAND oobinfo", mtd_device); + cleanmarker.totlen =3D cpu_to_je32(8); /* Check for autoplacement */ if (oobinfo.useecc =3D=3D 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) !=3D 0) + return sys_errmsg("%s: unable to get NAND ecclayout", mtd_device=
);
quoted
+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=20
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 =3D MTD_OOB_PLACE;
+ ops.mode =3D mtd->oob_mode;
Could we do it like this ?
Thanks
-LiuShuo