mtd/util jffs2dump.c,1.4,1.5

gleixner at infradead.org gleixner at infradead.org
Fri May 7 11:41:17 EDT 2004


Update of /home/cvs/mtd/util
In directory phoenix.infradead.org:/tmp/cvs-serv31412

Modified Files:
	jffs2dump.c 
Log Message:
limit wrong magic output, check obsolete nodes too

Index: jffs2dump.c
===================================================================
RCS file: /home/cvs/mtd/util/jffs2dump.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- jffs2dump.c	7 May 2004 12:53:29 -0000	1.4
+++ jffs2dump.c	7 May 2004 15:41:14 -0000	1.5
@@ -170,6 +170,9 @@
 	int			empty = 0, dirty = 0;
 	char			name[256];
 	uint32_t		crc;
+	uint16_t		type;
+	int			bitchbitmask = 0;
+	int			obsolete;
 
 	while ( p < (data + imglen)) {
 		node = (union jffs2_node_union*) p;
@@ -182,12 +185,23 @@
 		}
 		
 		if (je16_to_cpu (node->u.magic) != JFFS2_MAGIC_BITMASK)	{
-			printf ("Wrong bitmask  at  0x%08x, 0x%04x\n", p - data, je16_to_cpu (node->u.magic));
+			if (!bitchbitmask++)
+    			    printf ("Wrong bitmask  at  0x%08x, 0x%04x\n", p - data, je16_to_cpu (node->u.magic));
 			p += 4;
 			dirty += 4;
 			continue;
 		}
-
+		bitchbitmask = 0;
+		
+		type = je16_to_cpu(node->u.nodetype);
+		if ((type & JFFS2_NODE_ACCURATE) != JFFS2_NODE_ACCURATE) {
+			obsolete = 1;
+			type |= JFFS2_NODE_ACCURATE;
+		} else
+			obsolete = 0;
+		/* Set accurate for CRC check */	
+		node->u.nodetype = cpu_to_je16(type);
+	    
 		crc = crc32 (0, node, sizeof (struct jffs2_unknown_node) - 4);
 		if (crc != je32_to_cpu (node->u.hdr_crc)) {
 			printf ("Wrong hdr_crc  at  0x%08x, 0x%08x instead of 0x%08x\n", p - data, je32_to_cpu (node->u.hdr_crc), crc);
@@ -199,7 +213,8 @@
 		switch(je16_to_cpu(node->u.nodetype)) {
 		
 		case JFFS2_NODETYPE_INODE:
-			printf ("Inode      node at 0x%08x, totlen 0x%08x, #ino  %5d, version %5d, isize %8d, csize %8d, dsize %8d, offset %8d\n",
+			printf ("%8s Inode      node at 0x%08x, totlen 0x%08x, #ino  %5d, version %5d, isize %8d, csize %8d, dsize %8d, offset %8d\n",
+					obsolete ? "Obsolete" : "",
 					p - data, je32_to_cpu (node->i.totlen), je32_to_cpu (node->i.ino),
 					je32_to_cpu ( node->i.version), je32_to_cpu (node->i.isize), 
 					je32_to_cpu (node->i.csize), je32_to_cpu (node->i.dsize), je32_to_cpu (node->i.offset));
@@ -226,7 +241,8 @@
 		case JFFS2_NODETYPE_DIRENT:
 			memcpy (name, node->d.name, node->d.nsize);
 			name [node->d.nsize] = 0x0;
-			printf ("Dirent     node at 0x%08x, totlen 0x%08x, #pino %5d, version %5d, #ino  %8d, nsize %8d, name %s\n",
+			printf ("%8s Dirent     node at 0x%08x, totlen 0x%08x, #pino %5d, version %5d, #ino  %8d, nsize %8d, name %s\n",
+					obsolete ? "Obsolete" : "",
 					p - data, je32_to_cpu (node->d.totlen), je32_to_cpu (node->d.pino),
 					je32_to_cpu ( node->d.version), je32_to_cpu (node->d.ino), 
 					node->d.nsize, name);
@@ -251,14 +267,20 @@
 			break;
 	
 		case JFFS2_NODETYPE_CLEANMARKER:
-			if (verbose)
-				printf ("Cleanmarker     at 0x%08x, totlen 0x%08x\n", p - data, je32_to_cpu (node->u.totlen));
+			if (verbose) {
+				printf ("%8s Cleanmarker     at 0x%08x, totlen 0x%08x\n", 
+					obsolete ? "Obsolete" : "",
+					p - data, je32_to_cpu (node->u.totlen));
+			}		
 			p += PAD(je32_to_cpu (node->u.totlen));						
 			break;
 	
 		case JFFS2_NODETYPE_PADDING:
-			if (verbose)
-				printf ("Padding    node at 0x%08x, totlen 0x%08x\n", p - data, je32_to_cpu (node->u.totlen));
+			if (verbose) {
+				printf ("%8s Padding    node at 0x%08x, totlen 0x%08x\n", 
+					obsolete ? "Obsolete" : "",
+					p - data, je32_to_cpu (node->u.totlen));
+			}		
 			p += PAD(je32_to_cpu (node->u.totlen));						
 			break;
 			
@@ -268,8 +290,11 @@
 			break;
 			
 		default:	
-			if (verbose)
-				printf ("Unknown    node at 0x%08x, totlen 0x%08x\n", p - data, je32_to_cpu (node->u.totlen));
+			if (verbose) {
+				printf ("%8s Unknown    node at 0x%08x, totlen 0x%08x\n", 
+					obsolete ? "Obsolete" : "",
+					p - data, je32_to_cpu (node->u.totlen));
+			}		
 			p += PAD(je32_to_cpu (node->u.totlen));						
 			dirty += PAD(je32_to_cpu (node->u.totlen));						
 	




More information about the linux-mtd-cvs mailing list