--- mtd_9_28_EBH_1:1_ect/util/mkfs.jffs2.c 2005-09-29 09:34:08.000000000 +0800 +++ mtd_9_28_EBH_1:1_ect_wl/util/mkfs.jffs2.c 2005-10-10 16:10:33.000000000 +0800 @@ -659,9 +659,9 @@ static uint8_t *file_buffer = NULL; /* static int out_ofs = 0; static int erase_block_size = 65536; static int pad_fs_size = 0; -static int add_cleanmarkers = 1; -static struct jffs2_unknown_node cleanmarker; -static int cleanmarker_size = sizeof(cleanmarker); +static int add_ebhs = 1; +static struct jffs2_raw_ebh ebh; +static int ebh_size = sizeof(ebh); static unsigned char ffbuf[16] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff @@ -722,20 +722,20 @@ static inline void padword(void) static inline void pad_block_if_less_than(int req) { - if (add_cleanmarkers) { + if (add_ebhs) { if ((out_ofs % erase_block_size) == 0) { - full_write(out_fd, &cleanmarker, sizeof(cleanmarker)); - pad(cleanmarker_size - sizeof(cleanmarker)); + full_write(out_fd, &ebh, sizeof(ebh)); + pad(ebh_size - sizeof(ebh)); padword(); } } if ((out_ofs % erase_block_size) + req > erase_block_size) { padblock(); } - if (add_cleanmarkers) { + if (add_ebhs) { if ((out_ofs % erase_block_size) == 0) { - full_write(out_fd, &cleanmarker, sizeof(cleanmarker)); - pad(cleanmarker_size - sizeof(cleanmarker)); + full_write(out_fd, &ebh, sizeof(ebh)); + pad(ebh_size - sizeof(ebh)); padword(); } } @@ -1112,10 +1112,17 @@ static void recursive_populate_directory static void create_target_filesystem(struct filesystem_entry *root) { - cleanmarker.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); - cleanmarker.nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER); - cleanmarker.totlen = cpu_to_je32(cleanmarker_size); - cleanmarker.hdr_crc = cpu_to_je32(crc32(0, &cleanmarker, sizeof(struct jffs2_unknown_node)-4)); + ebh.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); + ebh.nodetype = cpu_to_je16(JFFS2_NODETYPE_ERASEBLOCK_HEADER); + ebh.totlen = cpu_to_je32(sizeof(ebh)); + ebh.hdr_crc = cpu_to_je32(crc32(0, &ebh, sizeof(struct jffs2_unknown_node)-4)); + ebh.reserved = 0; + ebh.compat_fset = JFFS2_EBH_COMPAT_FSET; + ebh.incompat_fset = JFFS2_EBH_INCOMPAT_FSET; + ebh.rocompat_fset = JFFS2_EBH_ROCOMPAT_FSET; + ebh.erase_count = cpu_to_je32(0); + ebh.node_crc = cpu_to_je32(crc32(0, (unsigned char *)&ebh + sizeof(struct jffs2_unknown_node) + 4, + sizeof(struct jffs2_raw_ebh) - sizeof(struct jffs2_unknown_node) - 4)); if (ino == 0) ino = 1; @@ -1126,11 +1133,11 @@ static void create_target_filesystem(str if (pad_fs_size == -1) { padblock(); } else { - if (pad_fs_size && add_cleanmarkers){ + if (pad_fs_size && add_ebhs){ padblock(); while (out_ofs < pad_fs_size) { - full_write(out_fd, &cleanmarker, sizeof(cleanmarker)); - pad(cleanmarker_size - sizeof(cleanmarker)); + full_write(out_fd, &ebh, sizeof(ebh)); + pad(ebh_size - sizeof(ebh)); padblock(); } } else { @@ -1153,8 +1160,8 @@ static struct option long_options[] = { {"version", 0, NULL, 'V'}, {"big-endian", 0, NULL, 'b'}, {"little-endian", 0, NULL, 'l'}, - {"no-cleanmarkers", 0, NULL, 'n'}, - {"cleanmarker", 1, NULL, 'c'}, + {"no-eraseblock-headers", 0, NULL, 'n'}, + {"eraseblock-header", 1, NULL, 'c'}, {"squash", 0, NULL, 'q'}, {"squash-uids", 0, NULL, 'U'}, {"squash-perms", 0, NULL, 'P'}, @@ -1178,7 +1185,7 @@ static char *helptext = " -r, -d, --root=DIR Build file system from directory DIR (default: cwd)\n" " -s, --pagesize=SIZE Use page size (max data node size) SIZE (default: 4KiB)\n" " -e, --eraseblock=SIZE Use erase block size SIZE (default: 64KiB)\n" - " -c, --cleanmarker=SIZE Size of cleanmarker (default 12)\n" + " -c, --eraseblock-header=SIZE Size of eraseblock header (default 28)\n" " -m, --compr-mode=MODE Select compression mode (default: priortiry)\n" " -x, --disable-compressor=COMPRESSOR_NAME\n" " Disable a compressor\n" @@ -1188,7 +1195,7 @@ static char *helptext = " Set the priority of a compressor\n" " -L, --list-compressors Show the list of the avaiable compressors\n" " -t, --test-compression Call decompress and compare with the original (for test)\n" - " -n, --no-cleanmarkers Don't add a cleanmarker to every eraseblock\n" + " -n, --no-eraseblock-headers Don't add a eraseblock header to every eraseblock\n" " -o, --output=FILE Output to FILE (default: stdout)\n" " -l, --little-endian Create a little-endian filesystem\n" " -b, --big-endian Create a big-endian filesystem\n" @@ -1291,6 +1298,15 @@ void process_buffer(int inp_size) { p += PAD(je32_to_cpu (node->u.totlen)); break; + + case JFFS2_NODETYPE_ERASEBLOCK_HEADER: + if (verbose) { + printf ("%8s Eraseblock header at 0x%08x, totlen 0x%08\n", + obsolete ? "Obsolete" : "", + p - file_buffer, je32_to_cpu (node->eh.totlen)); + } + p += PAD(je32_to_cpu (node->eh.totlen)); + break; case JFFS2_NODETYPE_PADDING: if (verbose) { @@ -1462,15 +1478,15 @@ int main(int argc, char **argv) pad_fs_size = -1; break; case 'n': - add_cleanmarkers = 0; + add_ebhs = 0; break; case 'c': - cleanmarker_size = strtol(optarg, NULL, 0); - if (cleanmarker_size < sizeof(cleanmarker)) { - error_msg_and_die("cleanmarker size must be >= 12"); + ebh_size = strtol(optarg, NULL, 0); + if (ebh_size < sizeof(ebh)) { + error_msg_and_die("ebh size must be >= 28"); } - if (cleanmarker_size >= erase_block_size) { - error_msg_and_die("cleanmarker size must be < eraseblock size"); + if (ebh_size >= erase_block_size) { + error_msg_and_die("ebh size must be < eraseblock size"); } break; case 'm':