Commits

Dima Zavin  committed 193ce3d

mkyaffs2image: add commandline options for specifying chunk and spare sizes

Change-Id: Ibd8f93eeaf8cfe845876435b0427079c35590c39
Cc: Ajay Dudani <adudani@quicinc.com>
Signed-off-by: Dima Zavin <dima@android.com>

  • Participants
  • Parent commits eadd925

Comments (0)

Files changed (1)

File yaffs2/utils/mkyaffs2image.c

 
 #define MAX_OBJECTS 50000
 
-#define chunkSize 2048
-#define spareSize 64
+unsigned chunkSize = 2048;
+unsigned spareSize = 64;
 
 const char * mkyaffsimage_c_version = "$Id: mkyaffs2image.c,v 1.2 2005/12/13 00:34:58 tpoynor Exp $";
 
 static void usage(void)
 {
 	fprintf(stderr,"mkyaffs2image: image building tool for YAFFS2 built "__DATE__"\n");
-	fprintf(stderr,"usage: mkyaffs2image [-f] dir image_file [convert]\n");
+	fprintf(stderr,"usage: mkyaffs2image [-f] [-c <size>] [-s <size>] dir image_file [convert]\n");
 	fprintf(stderr,"           -f         fix file stat (mods, user, group) for device\n");
+	fprintf(stderr,"           -c <size>  set the chunk (NAND page) size. default: 2048\n");
+	fprintf(stderr,"           -s <size>  set the spare (NAND OOB) size. default: 64\n");
 	fprintf(stderr,"           dir        the directory tree to be converted\n");
 	fprintf(stderr,"           image_file the output file to hold the image\n");
 	fprintf(stderr,"           'convert'  produce a big-endian image from a little-endian machine\n");
 	char *image;
 	char *dir;
 
-	while ((opt = getopt(argc, argv, "f")) != -1) {
+	while ((opt = getopt(argc, argv, "fc:s:")) != -1) {
 		switch (opt) {
 		case 'f':
 			fixstats = 1;
 			break;
+		case 'c':
+			chunkSize = (unsigned)strtoul(optarg, NULL, 0);
+			break;
+		case 's':
+			spareSize = (unsigned)strtoul(optarg, NULL, 0);
+			break;
 		default:
 			usage();
 			exit(1);
 		}
 	}
 
+	if (!chunkSize || !spareSize) {
+		usage();
+		exit(1);
+	}
+
 	if ((argc - optind < 2) || (argc - optind > 3)) {
 		usage();
 		exit(1);