[U-Boot-Users] RO jffs2 implementation for bootloader

Ladislav Michl ladis at linux-mips.org
Wed May 16 13:00:27 CEST 2007


On Mon, May 07, 2007 at 07:38:20PM +0200, Stefan Roese wrote:
> Hi Matthieu,
> 
> On Monday 07 May 2007, Matthieu CASTET wrote:
> > Using jffs2_nand_1pass.c make thing lot's of better (very fast scaning)
> >
> > Unfortunalty the code seems incomplete : if I do a ls, there are missing
> > files.
> 
> Do I understand this correctly? Some files are displayed and some are missing? 
> Could you give an example?

I'm also interrested in test case. Having filesystem image would help as
well.

> > Do you know what's the status of jffs2_nand_1pass.c ?
> 
> No, sorry I personally haven't used the JFFS2 code in U-Boot before.
> 
> IIRC this code originally is coming from Ladislav Michl (please correct me if 
> I'm wrong here). So Ladis, can you say something about the status of this 
> file and why it not used at all?

Indeed... I wrote it (modified from jffs2_1pass.c) when I was adding NAND
code. Unfortunately it is not that easy to support JFFS2 on NOR and NAND
simultaneously. It would need more work... Below is what I'm currently
using - some changes to shut up newer gcc warnings. Perhaps some kind
of #define (evil grin) would be enough?

Best regards,
	ladis

diff --git a/fs/jffs2/Makefile b/fs/jffs2/Makefile
index c1357d0..d02b678 100644
--- a/fs/jffs2/Makefile
+++ b/fs/jffs2/Makefile
@@ -26,7 +26,7 @@ include $(TOPDIR)/config.mk
 LIB	= $(obj)libjffs2.a
 
 AOBJS	=
-COBJS	= jffs2_1pass.o compr_rtime.o compr_rubin.o compr_zlib.o mini_inflate.o
+COBJS	= jffs2_nand_1pass.o compr_rtime.o compr_rubin.o compr_zlib.o mini_inflate.o
 COBJS	+= compr_lzo.o compr_lzari.o
 
 SRCS	:= $(AOBJS:.o=.S) $(COBJS:.o=.c)
diff --git a/fs/jffs2/jffs2_nand_1pass.c b/fs/jffs2/jffs2_nand_1pass.c
index e78af75..e908929 100644
--- a/fs/jffs2/jffs2_nand_1pass.c
+++ b/fs/jffs2/jffs2_nand_1pass.c
@@ -166,7 +166,7 @@ insert_dirent(struct b_list *list, struct jffs2_raw_dirent *node, u32 offset)
 	new->version = node->version;
 	new->pino = node->pino;
 	new->ino = node->ino;
-	new->nhash = full_name_hash(node->name, node->nsize);
+	new->nhash = full_name_hash((char *)node->name, node->nsize);
 	new->nsize = node->nsize;
 	new->type = node->type;
 
@@ -298,16 +298,16 @@ jffs2_1pass_read_inode(struct b_lists *pL, u32 ino, char *dest,
 		}
 #endif
 		if (dest || stat) {
-			char *src, *dst;
+			unsigned char *src, *dst;
 			char data[4096 + sizeof(struct jffs2_raw_inode)];
 			struct jffs2_raw_inode *inode;
-			size_t len;
+			ulong len;
 
 			inode = (struct jffs2_raw_inode *)&data;
 			len = sizeof(struct jffs2_raw_inode);
 			if (dest)
 				len += jNode->csize;
-			nand_read(nand, jNode->offset, &len, inode);
+			nand_read(nand, jNode->offset, &len, (u_char *)inode);
 			/* ignore data behind latest known EOF */
 			if (inode->offset > totalSize)
 				continue;
@@ -322,8 +322,8 @@ jffs2_1pass_read_inode(struct b_lists *pL, u32 ino, char *dest,
 			if (!dest)
 				continue;
 
-			src = ((char *) inode) + sizeof(struct jffs2_raw_inode);
-			dst = (char *) (dest + inode->offset);
+			src = ((unsigned char *) inode) + sizeof(struct jffs2_raw_inode);
+			dst = (unsigned char *) (dest + inode->offset);
 
 			switch (inode->compr) {
 			case JFFS2_COMPR_NONE:
@@ -434,7 +434,7 @@ static inline void dump_stat(struct stat *st, const char *name)
 	if (st->st_mtime == (time_t)(-1)) /* some ctimes really hate -1 */
 		st->st_mtime = 1;
 
-	ctime_r(&st->st_mtime, s/*,64*/); /* newlib ctime doesn't have buflen */
+	ctime_r((time_t *)&st->st_mtime, s/*,64*/); /* newlib ctime doesn't have buflen */
 
 	if ((p = strchr(s,'\n')) != NULL) *p = '\0';
 	if ((p = strchr(s,'\r')) != NULL) *p = '\0';
@@ -452,12 +452,12 @@ dump_inode(struct b_lists *pL, struct b_dirent *d, struct b_inode *i)
 {
 	char fname[JFFS2_MAX_NAME_LEN + 1];
 	struct stat st;
-	size_t len;
+	ulong len;
 
 	if(!d || !i) return -1;
 	len = d->nsize;
 	nand_read(nand, d->offset + sizeof(struct jffs2_raw_dirent),
-		  &len, &fname);
+		  &len, (uchar *)fname);
 	fname[d->nsize] = '\0';
 
 	memset(&st, 0, sizeof(st));
@@ -597,8 +597,9 @@ jffs2_1pass_resolve_inode(struct b_lists * pL, u32 ino)
 	/* it's a soft link so we follow it again. */
 	for (jNode = (struct b_inode *)pL->frag.listHead; jNode; jNode = jNode->next) {
 		if (jNode->ino == jDirFoundIno) {
-			size_t len = jNode->csize;
-			nand_read(nand, jNode->offset + sizeof(struct jffs2_raw_inode), &len, &tmp);
+			ulong len = jNode->csize;
+			nand_read(nand, jNode->offset + sizeof(struct jffs2_raw_inode),
+				&len, (uchar *)tmp);
 			tmp[jNode->csize] = '\0';
 			break;
 		}
@@ -664,9 +665,11 @@ jffs2_1pass_search_list_inodes(struct b_lists * pL, const char *fname, u32 pino)
 unsigned char
 jffs2_1pass_rescan_needed(struct part_info *part)
 {
+/*	FIXME
 	struct b_node *b;
 	struct jffs2_unknown_node onode;
 	struct jffs2_unknown_node *node;
+*/
 	struct b_lists *pL = (struct b_lists *)part->jffs2_priv;
 
 	if (part->jffs2_priv == 0){
@@ -685,8 +688,9 @@ jffs2_1pass_rescan_needed(struct part_info *part)
 		return 1;
 	}
 
-	/* FIXME */
+
 #if 0
+	/* FIXME */
 	/* but suppose someone reflashed a partition at the same offset... */
 	b = pL->dir.listHead;
 	while (b) {
@@ -770,7 +774,7 @@ jffs2_fill_scan_buf(nand_info_t *nand, unsigned char *buf,
 		    unsigned ofs, unsigned len)
 {
 	int ret;
-	unsigned olen;
+	ulong olen;
 
 	olen = len;
 	ret = nand_read(nand, ofs, &olen, buf);
@@ -792,7 +796,7 @@ jffs2_1pass_build_lists(struct part_info * part)
 	struct b_lists *pL;
 	struct jffs2_unknown_node *node;
 	unsigned nr_blocks, sectorsize, ofs, offset;
-	char *buf;
+	unsigned char *buf;
 	int i;
 	u32 counter = 0;
 	u32 counter4 = 0;
@@ -910,9 +914,11 @@ jffs2_1pass_build_lists(struct part_info * part)
 static u32
 jffs2_1pass_fill_info(struct b_lists * pL, struct b_jffs2_info * piL)
 {
+/*	FIXME
 	struct b_node *b;
 	struct jffs2_raw_inode ojNode;
 	struct jffs2_raw_inode *jNode;
+*/
 	int i;
 
 	for (i = 0; i < JFFS2_NUM_COMPR; i++) {
diff --git a/fs/jffs2/jffs2_nand_private.h b/fs/jffs2/jffs2_nand_private.h
index 18cca8d..2e4d50c 100644
--- a/fs/jffs2/jffs2_nand_private.h
+++ b/fs/jffs2/jffs2_nand_private.h
@@ -35,7 +35,7 @@ struct b_list {
 };
 
 struct b_lists {
-	char *partOffset;
+	u32 partOffset;
 	struct b_list dir;
 	struct b_list frag;
 };
@@ -122,7 +122,7 @@ static inline unsigned long end_name_hash(unsigned long hash)
 
 /* Compute the hash for a name string. */
 static inline unsigned int
-full_name_hash(const unsigned char *name, unsigned int len)
+full_name_hash(const char *name, unsigned int len)
 {
 	unsigned long hash = init_name_hash();
 	while (len--)




More information about the U-Boot mailing list