mtd/util jffs2dump.c,1.5,1.6

gleixner at infradead.org gleixner at infradead.org
Fri Jun 18 18:11:50 EDT 2004


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

Modified Files:
	jffs2dump.c 
Log Message:
Make it possible to decode nanddump generated images, which contain
data-oob-data-oob.



Index: jffs2dump.c
===================================================================
RCS file: /home/cvs/mtd/util/jffs2dump.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- jffs2dump.c	7 May 2004 15:41:14 -0000	1.5
+++ jffs2dump.c	18 Jun 2004 22:11:48 -0000	1.6
@@ -63,6 +63,8 @@
 	       "-c         --content  	              dump image contents\n"
 	       "-e fname   --endianconvert=fname      convert image endianness, output to file fname\n"
 	       "-r         --recalccrc                recalc name and data crc on endian conversion\n" 	
+	       "-d len     --datsize=len              size of data chunks, when oob data in binary image (NAND only)\n" 	
+	       "-o len     --oobsize=len              size of oob data chunk in binary image (NAND only)\n" 	
 	       "-v         --verbose		      verbose output\n");
 	exit(0);
 }
@@ -91,6 +93,8 @@
 int	convertendian;		// convert endianness
 int	recalccrc;		// recalc name and data crc's on endian conversion
 char	cnvfile[256];		// filename for conversion output
+int	datsize;		// Size of data chunks, when oob data is inside the binary image
+int	oobsize;		// Size of oob chunks, when oob data is inside the binary image
 
 void process_options (int argc, char *argv[])
 {
@@ -98,7 +102,7 @@
 
 	for (;;) {
 		int option_index = 0;
-		static const char *short_options = "bce:rv";
+		static const char *short_options = "bce:rd:o:v";
 		static const struct option long_options[] = {
 			{"help", no_argument, 0, 0},
 			{"version", no_argument, 0, 0},
@@ -106,6 +110,8 @@
 			{"littleendian", no_argument, 0, 'l'},
 			{"content", no_argument, 0, 'c'},
 			{"endianconvert", required_argument, 0, 'e'},
+			{"datsize", required_argument, 0, 'd'},
+			{"oobsize", required_argument, 0, 'o'},
 			{"recalccrc", required_argument, 0, 'r'},
 			{"verbose", no_argument, 0, 'v'},
 			{0, 0, 0, 0},
@@ -140,6 +146,12 @@
 		case 'c':
 			dumpcontent = 1;
 			break;
+		case 'd':
+			datsize = atoi(optarg);
+			break;
+		case 'o':
+			oobsize = atoi(optarg);
+			break;
 		case 'e':
 			convertendian = 1;
 			strcpy (cnvfile, optarg);
@@ -466,9 +478,24 @@
 		exit(1);
 	}
 	
-	// read image data
-	read (fd, data, imglen);
-		
+	if (datsize && oobsize) {
+		int  idx = 0;
+		long len = imglen;
+		uint8_t oob[oobsize];
+		printf ("Peeling data out of combined data/oob image\n");
+		while (len) {
+			// read image data
+			read (fd, &data[idx], datsize);
+			read (fd, oob, oobsize);
+			idx += datsize;
+			imglen -= oobsize;
+			len -= datsize + oobsize;
+		}
+	
+	} else {
+		// read image data
+		read (fd, data, imglen);
+	}	
 	// Close the input file
 	close(fd);
 





More information about the linux-mtd-cvs mailing list