X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=utils%2Fmkyaffs.c;h=c9b436799a3f04ca5bf94c1f0a3520cfdbf4c24d;hb=f7b95a3fb1e45ff10c22d3148ae3c97d61a9c449;hp=a0107bad89e917f8f98c6adc6aac6036d8447096;hpb=f5b76bfb34c6b0b5e42a4247dc2df3014a70a425;p=yaffs%2F.git diff --git a/utils/mkyaffs.c b/utils/mkyaffs.c index a0107ba..c9b4367 100644 --- a/utils/mkyaffs.c +++ b/utils/mkyaffs.c @@ -27,14 +27,14 @@ #include #include #include +#include #include #include #include #include -#include -#include +#include -const char *mkyaffs_c_version = "$Id: mkyaffs.c,v 1.6 2003-03-11 05:16:53 charles Exp $"; +const char *mkyaffs_c_version = "$Id: mkyaffs.c,v 1.9 2005-10-11 23:39:56 charles Exp $"; // countBits is a quick way of counting the number of bits in a byte. // ie. countBits[n] holds the number of 1 bits in a byte with the value n. @@ -92,23 +92,41 @@ int main(int argc, char **argv) int optcnt = 1; int usemtdecc = 0; int imglen = 0; + int showHelp = 0; struct mtd_oob_buf oob = {0, 16, (unsigned char *) &oobbuf}; mtd_info_t meminfo; erase_info_t erase; struct nand_oobinfo oobsel; - if (strcmp (argv[optcnt], "-e") == 0) { + if (argc > 1 && strcmp (argv[optcnt], "-?") == 0) { + showHelp = 1; + } + + if (argc > 1 && strcmp (argv[optcnt], "-h") == 0) { + showHelp = 1; + } + + if (argc > 1 && strcmp (argv[optcnt], "-e") == 0) { optcnt++; usemtdecc = 1; } + printf("argc %d sh %d optcnt %d\n",argc, showHelp, optcnt); + /* Make sure a device was specified */ - if(argc < (optcnt + 2)) { - printf("usage: %s -e \n", argv[0]); + if(showHelp || argc < (optcnt + 1)) { + printf("usage: %s [-e] [image name]\n", argv[0]); + printf(" -e Use mtd ecc. Default: do not use mtd ecc\n"); + printf(" mtdname Name of mtd device\n"); + printf(" image name Name of optional image file\n\n"); + printf("Function: Formats a NAND mtd device for YAFFS. If the optional\n" + "image file is specified, then the file system is loaded with\n" + "this image.\n\n"); exit(1); } - if((img = open(argv[optcnt + 1],O_RDONLY)) == -1) { + if( argc > (optcnt + 1) && + (img = open(argv[optcnt + 1],O_RDONLY)) == -1) { perror("opening image file"); exit(1); }