RE: [U-Boot-Users] jffs2 view u-boot/linux

Jonas Dietsche wrote:
******The directory Entries******
testfile
build_list: version = 00000001 build_list: ino = 00000002
testfile
build_list: version = 00000002 build_list: ino = 00000000
How can I manage it that the deleted testfile isn't displayed anymore?
Have you tried using CFG_JFFS2_SORT_FRAGMENTS? I use it and I tried a similar test and testfile is deleted for u-boot (for U-Boot 1.1.0). Both jffs2_1pass.c and README.JFFS2 say it is needed if the boot partition is writable.
In this case it may just be masking a bug in jffs2_1pass_find_inode(). The search for the most recent directory entry ignores a directory entry with an inode of 0 (unlinked file) even if the version is newer, so deletion directory entries are ignored. This doesn't look right to me:
for(b = pL->dir.listHead; b; b = b->next, counter++) { jDir = (struct jffs2_raw_dirent *) (b->offset); if ((pino == jDir->pino) && (len == jDir->nsize) && (jDir->ino) && /* 0 for unlink */ ^^^^^^^^^^^ (!strncmp(jDir->name, name, len))) { /* a match */ if (jDir->version < version) continue;
With your test this would find version 1 of the directory entry and ignore version 2, which unlinks the file.
With CFG_JFFS2_SORT_FRAGMENTS all directory entries except the most recent version have their inode set to 0 during the sort, so the obsolete directory entry would be ignored too.
Is this a NAND specific problem?
Probably not.
Dave Ellis
~~~~~~~~~~~~~~~~~~~~~~~~~~ SIXNET - "Leading the Industrial Ethernet Revolution" 331 Ushers Road, P.O. Box 767, Clifton Park, NY 12065 USA Tel +1 (518) 877-5173 Fax +1 (518) 877-8346 Email me at: dge@sixnetio.com Detailed product info: www.sixnetio.com ~~~~~~~~~~~~~~~~~~~~~~~~~~

Hello Dave,
thanks for your helpful reply.
Have you tried using CFG_JFFS2_SORT_FRAGMENTS? I use it and I tried a similar test and testfile is deleted for u-boot (for U-Boot 1.1.0). Both jffs2_1pass.c and README.JFFS2 say it is needed if the boot partition is writable.
Yes and I had the same behaviour. Then I did the following test. Defined CFG_JFFS_CUSTOM_PART, and used struct part_info* jffs2_part_info(int part_num) { DECLARE_GLOBAL_DATA_PTR; bd_t *bd = gd->bd; char* s; char readcmd[60]; int i;
if (part_num != 0) return 0; /* only support one partition */
if (part.usr_priv == (void*)1) return ∂ /* already have part info */
memset(&part, 0, sizeof(part));
/* boot info in NAND flash, get and use copy in RAM */ /* override info from environment if present */ s = getenv("fsaddr"); part.offset = s ? (void *)simple_strtoul(s, NULL, 16) : (void *)CFG_JFFS2_RAMBASE; s = getenv("fssize"); part.size = s ? simple_strtoul(s, NULL, 16) : CFG_JFFS2_RAMSIZE; /* read from nand flash */ sprintf(readcmd, "nand read.jffs2 %x 0 %x", (uint32_t)part.offset, part.size); run_command(readcmd, 0);
part.erasesize = 0; /* unused */ part.usr_priv=(void*)1; /* ready */
return ∂ }
I undefined CONFIG_JFFS2_NAND and did the same tests again. And the results are what they should be like. Deleted files are not displayed anymore. If CFG_JFFS2_SORT_FRAGMENTS is disabled they are displayed. So the NAND functions of jffs2_1pass.c seem not deliver not the values they should. The comparison of the version -where the inode is set to 0 if it is an older version- is never reached and that is why deleted files are always displayed.
Have you tested it with NAND or NOR?
Regards, Jonas

Jonas Dietsche wrote:
Have you tried using CFG_JFFS2_SORT_FRAGMENTS? I use it and I tried
a
similar test and testfile is deleted for u-boot (for U-Boot 1.1.0). Both jffs2_1pass.c and README.JFFS2 say it is needed if the boot partition is writable.
Yes and I had the same behaviour. Then I did the following test. Defined CFG_JFFS_CUSTOM_PART, and used struct part_info* jffs2_part_info(int part_num) {
[ snip - copy NAND to RAM ]
}> I undefined CONFIG_JFFS2_NAND and did the same tests again. And the results are what they should be like. Deleted files are not displayed anymore. If CFG_JFFS2_SORT_FRAGMENTS is disabled they are
displayed.
So the NAND functions of jffs2_1pass.c seem not deliver not the values
they should. The comparison of the version -where the inode is set to 0 if it is an
older version- is never reached and that is why deleted files are
always
displayed.
Have you tested it with NAND or NOR?
I am copying from NAND to RAM and using CFG_JFFS_CUSTOM_PART. I have never tried using the direct NAND functions. They were added after 1.1.0 so I had to copy to RAM.
I have a 2MiB boot partition that is copied to RAM. It takes too long to read the entire NAND FLASH (one of our products has 128MiB). It is faster to load the kernel from a RAM copy, otherwise the entire kernel is read twice from NAND, once for the initial scan and again for the load.
Dave Ellis
participants (3)
-
Dave Ellis
-
Dave Ellis
-
Jonas Dietsche