diff options
Diffstat (limited to 'mkfs.jffs2.c')
-rw-r--r-- | mkfs.jffs2.c | 77 |
1 files changed, 29 insertions, 48 deletions
diff --git a/mkfs.jffs2.c b/mkfs.jffs2.c index 82439e5..feac88d 100644 --- a/mkfs.jffs2.c +++ b/mkfs.jffs2.c @@ -659,9 +659,9 @@ static uint8_t *file_buffer = NULL; /* file buffer contains the actual erase bl static int out_ofs = 0; static int erase_block_size = 65536; static int pad_fs_size = 0; -static int add_ebhs = 1; -static struct jffs2_raw_ebh ebh; -static int ebh_size = sizeof(ebh); +static int add_cleanmarkers = 1; +static struct jffs2_unknown_node cleanmarker; +static int cleanmarker_size = sizeof(cleanmarker); 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_ebhs) { + if (add_cleanmarkers) { if ((out_ofs % erase_block_size) == 0) { - full_write(out_fd, &ebh, sizeof(ebh)); - pad(ebh_size - sizeof(ebh)); + full_write(out_fd, &cleanmarker, sizeof(cleanmarker)); + pad(cleanmarker_size - sizeof(cleanmarker)); padword(); } } if ((out_ofs % erase_block_size) + req > erase_block_size) { padblock(); } - if (add_ebhs) { + if (add_cleanmarkers) { if ((out_ofs % erase_block_size) == 0) { - full_write(out_fd, &ebh, sizeof(ebh)); - pad(ebh_size - sizeof(ebh)); + full_write(out_fd, &cleanmarker, sizeof(cleanmarker)); + pad(cleanmarker_size - sizeof(cleanmarker)); padword(); } } @@ -862,14 +862,11 @@ static void write_regular_file(struct filesystem_entry *e) full_write(out_fd, wbuf, space); padword(); - if (tbuf != cbuf) { - free(cbuf); - cbuf = NULL; - } - tbuf += dsize; len -= dsize; offset += dsize; + + if (tbuf!=cbuf) if (!cbuf) free(cbuf); } } if (!je32_to_cpu(ri.version)) { @@ -1115,17 +1112,10 @@ static void recursive_populate_directory(struct filesystem_entry *dir) static void create_target_filesystem(struct filesystem_entry *root) { - 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)); + 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)); if (ino == 0) ino = 1; @@ -1136,11 +1126,11 @@ static void create_target_filesystem(struct filesystem_entry *root) if (pad_fs_size == -1) { padblock(); } else { - if (pad_fs_size && add_ebhs){ + if (pad_fs_size && add_cleanmarkers){ padblock(); while (out_ofs < pad_fs_size) { - full_write(out_fd, &ebh, sizeof(ebh)); - pad(ebh_size - sizeof(ebh)); + full_write(out_fd, &cleanmarker, sizeof(cleanmarker)); + pad(cleanmarker_size - sizeof(cleanmarker)); padblock(); } } else { @@ -1163,8 +1153,8 @@ static struct option long_options[] = { {"version", 0, NULL, 'V'}, {"big-endian", 0, NULL, 'b'}, {"little-endian", 0, NULL, 'l'}, - {"no-eraseblock-headers", 0, NULL, 'n'}, - {"eraseblock-header", 1, NULL, 'c'}, + {"no-cleanmarkers", 0, NULL, 'n'}, + {"cleanmarker", 1, NULL, 'c'}, {"squash", 0, NULL, 'q'}, {"squash-uids", 0, NULL, 'U'}, {"squash-perms", 0, NULL, 'P'}, @@ -1188,7 +1178,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, --eraseblock-header=SIZE Size of eraseblock header (default 28)\n" + " -c, --cleanmarker=SIZE Size of cleanmarker (default 12)\n" " -m, --compr-mode=MODE Select compression mode (default: priortiry)\n" " -x, --disable-compressor=COMPRESSOR_NAME\n" " Disable a compressor\n" @@ -1198,7 +1188,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-eraseblock-headers Don't add a eraseblock header to every eraseblock\n" + " -n, --no-cleanmarkers Don't add a cleanmarker 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" @@ -1212,7 +1202,7 @@ static char *helptext = " -V, --version Display version information\n" " -i, --incremental=FILE Parse FILE and generate appendage output for it\n\n"; -static char *revtext = "$Revision: 1.50 $"; +static char *revtext = "$Revision: 1.45 $"; int load_next_block() { @@ -1302,15 +1292,6 @@ 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%08x\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) { printf ("%8s Padding node at 0x%08x, totlen 0x%08x\n", @@ -1481,15 +1462,15 @@ int main(int argc, char **argv) pad_fs_size = -1; break; case 'n': - add_ebhs = 0; + add_cleanmarkers = 0; break; case 'c': - ebh_size = strtol(optarg, NULL, 0); - if (ebh_size < sizeof(ebh)) { - error_msg_and_die("ebh size must be >= 28"); + cleanmarker_size = strtol(optarg, NULL, 0); + if (cleanmarker_size < sizeof(cleanmarker)) { + error_msg_and_die("cleanmarker size must be >= 12"); } - if (ebh_size >= erase_block_size) { - error_msg_and_die("ebh size must be < eraseblock size"); + if (cleanmarker_size >= erase_block_size) { + error_msg_and_die("cleanmarker size must be < eraseblock size"); } break; case 'm': |