mkfs.jffs2 format option
PATCH 1/1 mkfs.jffs2 format option
This adds an option to eraseall that formats the block for jffs2. This avoids the double erase that happens if you directly mount the erased partition without first copying a jffs2 image to it.
Signature · 4 lines
Kenneth Johansson Ericsson AB Tel: +46 8 404 71 83 Borgafjordsgatan 9 Fax: +46 8 404 72 72 164 80 Stockholm [email protected]
util/eraseall.c +18 -5
@@ -32,8 +32,10 @@#include <linux/mtd/mtd.h> #define PROGRAM "eraseall" -#define VERSION "0.1.0" +#define VERSION "0.2.0" +static char cleanmarker[]={0x19 ,0x85 ,0x20 ,0x03 ,0x00 ,0x00 ,0x00 ,0x0c ,0xf0 ,0x60 ,0xdc ,0x98 }; +static int jffs2_format;static const char *exe_name;static const char *mtd_device;static int quiet;/* true -- don't output progress */
@@ -68,7 +70,7 @@ erase.start += meminfo.erasesize) {if ( !quiet ) { -printf ("\rErasing %ld Kibyte @ %lx -- %2ld %% complete." , +printf ("\rErasing %d Kibyte @ %x -- %2d %% complete." , meminfo.erasesize/1024 , erase.start, erase.start*100 /meminfo.size ); }
@@ -80,9 +82,15 @@ mtd_device, strerror( errno) );//exit( 1 ); } +if (jffs2_format){ +if (erase.start !=lseek (fd,erase.start,SEEK_SET )) +fprintf ( stderr,"Could not seek to pos %x on %s" ,erase.start,mtd_device); +write (fd,cleanmarker,sizeof (cleanmarker)); + } + }if ( !quiet ) { -printf ("\rErased %ld Kibyte @ %lx -- 100%% complete. \n" , +printf ("\rErased %d Kibyte @ %lx -- 100%% complete. \n" , meminfo.size/1024 ,0L ); }
@@ -98,10 +106,11 @@for (;;) {int option_index =0 ; -static const char * short_options="q" ; +static const char * short_options="qf" ;static const struct option long_options[] = { {"help" , no_argument,0 ,0 }, {"version" , no_argument,0 ,0 }, + {"format" , no_argument,0 ,'f' }, {"quiet" , no_argument,0 ,'q' }, {"silent" , no_argument,0 ,'q' },
@@ -126,8 +135,11 @@ }break ;case 'q' : - quiet=1 ; + quiet=1 ;break ; +case 'f' : + jffs2_format=1 ; +break ;case '?' : error=1 ;break ;
@@ -151,6 +163,7 @@printf ("Usage: %s [OPTION] MTD_DEVICE\n" "Erases all of the specified MTD device.\n" "\n" +" -f, --format write cleanmarker for jffs2\n" " -q, --quiet don't display progress messages\n" " --silent same as --quiet\n" " --help display this help and exit\n"