[U-Boot-Users] ls on a JFFS2 partition results in multiple copies of a single filename

Dan Batryn DBatryn at shoretel.com
Thu Sep 6 01:36:24 CEST 2007


	I am using a JFFS2 file system on a NAND flash based memory system.  I have a file in a partition that has been updated several times from the Linux that is running.  What I notice when I perform an ls from the UBOOT prompt is that there are multiple instances of that file each with a different file length.  I have tried turning on the define CFG_JFFS2_SORT_FRAGMENTS for the UBOOT build but this only results in reordering the ls results.  I was looking at the code in file jffs2_1pass.c:

/* list inodes with the given pino */
static u32
jffs2_1pass_list_inodes(struct b_lists * pL, u32 pino)
{
	struct b_node *b;
	struct jffs2_raw_dirent *jDir;

	for (b = pL->dir.listHead; b; b = b->next) {
		jDir = (struct jffs2_raw_dirent *) get_node_mem(b->offset);
		if ((pino == jDir->pino) && (jDir->ino)) { /* ino=0 -> unlink */
			u32 i_version = 0;
			struct jffs2_raw_inode ojNode;
			struct jffs2_raw_inode *jNode, *i = NULL;
			struct b_node *b2 = pL->frag.listHead;

			while (b2) {
				jNode = (struct jffs2_raw_inode *)
					get_fl_mem(b2->offset, sizeof(ojNode), &ojNode);
				if (jNode->ino == jDir->ino && jNode->version >= i_version) {
					if (i)
						put_fl_mem(i);

					if (jDir->type == DT_LNK)
						i = get_node_mem(b2->offset);
					else
						i = get_fl_mem(b2->offset, sizeof(*i), NULL);
				}
				b2 = b2->next;
			}

			dump_inode(pL, jDir, i);
			put_fl_mem(i);
		}
		put_fl_mem(jDir);
	}
	return pino;
}

So I have several questions:

1. In briefly looking at this code I see that the variable i_version is set to 0 and never updated during the scan of nodes.  I am not familiar with the JFFS2 internals but this seems incorrect.  Can someone please confirm i_version compares?

2. I also noticed that there is an alternate file in the same directory named jffs2_nand_1pass.c.  It appears that this file is not used in the normal build of the fs/jffs2 object.  When I tried using this file as an alternative for jff2_1pass.c, I found that the alternate file would not even compile if either DEBUG, DEBUG_DIRENTS or DEBUG_FRAGMENTS defines set.  Could someone please comment on the state of this file and if it ready for general usage?

3. I also notice that neither of these files has support for the nodetype == JFFS2_NODETYPE_SUMMARY.  So during the scan there are annoying messages that complain about the unknown node types.  Is there a pending patch to take care of the additional node types?

Thank you in advance for any information.


Daniel Batryn
Shoretel Inc.
960 Stewart
Sunnyvale, CA  94085
Phone:	(408) 331-3575
Fax:	(408) 331-3333
 
CONFIDENTIALITY NOTICE: This e-mail and any attachments are confidential and may be protected by legal privilege and/or are otherwise exempt from disclosure. If you are not the intended recipient, be aware that any disclosure, copying, distribution or use of this e-mail or any attachment is prohibited. If you have received this e-mail in error, please notify us immediately by returning it to the sender and delete this copy from your system.




More information about the U-Boot mailing list