summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--flash_eraseall.c74
-rw-r--r--ftl_check.c2
-rw-r--r--ftl_format.c2
-rw-r--r--jffs2dump.c37
-rw-r--r--mkfs.jffs2.c77
6 files changed, 61 insertions, 133 deletions
diff --git a/Makefile b/Makefile
index a77c6eb..b5401c4 100644
--- a/Makefile
+++ b/Makefile
@@ -8,7 +8,7 @@ MANDIR=/usr/man
INCLUDEDIR=/usr/include
#CROSS=arm-linux-
CC := $(CROSS)gcc
-CFLAGS := -I../include -O2 -Wall
+CFLAGS := -I./include -O2 -Wall
TARGETS = ftl_format flash_erase flash_eraseall nanddump doc_loadbios \
mkfs.jffs ftl_check mkfs.jffs2 flash_lock flash_unlock flash_info \
diff --git a/flash_eraseall.c b/flash_eraseall.c
index d88246b..3694e3d 100644
--- a/flash_eraseall.c
+++ b/flash_eraseall.c
@@ -18,7 +18,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- $Id: flash_eraseall.c,v 1.24 2005/11/07 11:15:10 gleixner Exp $
+ $Id: flash_eraseall.c,v 1.22 2005/02/17 14:55:06 hvr Exp $
*/
#include <sys/types.h>
#include <stdio.h>
@@ -43,7 +43,7 @@
#include <mtd/jffs2-user.h>
#define PROGRAM "flash_eraseall"
-#define VERSION "$Revision: 1.24 $"
+#define VERSION "$Revision: 1.22 $"
static const char *exe_name;
static const char *mtd_device;
@@ -53,16 +53,15 @@ static int jffs2; // format for jffs2 usage
static void process_options (int argc, char *argv[]);
static void display_help (void);
static void display_version (void);
-static struct jffs2_raw_ebh ebh;
+static struct jffs2_unknown_node cleanmarker;
int target_endian = __BYTE_ORDER;
int main (int argc, char *argv[])
{
mtd_info_t meminfo;
- int fd, ebhpos = 0, ebhlen = 0;
+ int fd, clmpos = 0, clmlen = 8;
erase_info_t erase;
int isNAND, bbtest = 1;
- uint32_t pages_per_eraseblock, available_oob_space;
process_options(argc, argv);
@@ -82,19 +81,11 @@ int main (int argc, char *argv[])
isNAND = meminfo.type == MTD_NANDFLASH ? 1 : 0;
if (jffs2) {
- ebh.magic = cpu_to_je16 (JFFS2_MAGIC_BITMASK);
- ebh.nodetype = cpu_to_je16 (JFFS2_NODETYPE_ERASEBLOCK_HEADER);
- ebh.totlen = cpu_to_je32(sizeof(struct jffs2_raw_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 (isNAND) {
+ cleanmarker.magic = cpu_to_je16 (JFFS2_MAGIC_BITMASK);
+ cleanmarker.nodetype = cpu_to_je16 (JFFS2_NODETYPE_CLEANMARKER);
+ if (!isNAND)
+ cleanmarker.totlen = cpu_to_je32 (sizeof (struct jffs2_unknown_node));
+ else {
struct nand_oobinfo oobinfo;
if (ioctl(fd, MEMGETOOBSEL, &oobinfo) != 0) {
@@ -109,32 +100,30 @@ int main (int argc, char *argv[])
fprintf (stderr, " Eeep. Autoplacement selected and no empty space in oob\n");
exit(1);
}
- ebhpos = oobinfo.oobfree[0][0];
- ebhlen = oobinfo.oobfree[0][1];
+ clmpos = oobinfo.oobfree[0][0];
+ clmlen = oobinfo.oobfree[0][1];
+ if (clmlen > 8)
+ clmlen = 8;
} else {
/* Legacy mode */
switch (meminfo.oobsize) {
case 8:
- ebhpos = 6;
- ebhlen = 2;
+ clmpos = 6;
+ clmlen = 2;
break;
case 16:
- ebhpos = 8;
- ebhlen = 8;
+ clmpos = 8;
+ clmlen = 8;
break;
case 64:
- ebhpos = 16;
- ebhlen = 8;
+ clmpos = 16;
+ clmlen = 8;
break;
}
}
- pages_per_eraseblock = meminfo.erasesize/meminfo.oobblock;
- available_oob_space = ebhlen * pages_per_eraseblock;
- if (available_oob_space < sizeof(struct jffs2_raw_ebh)) {
- fprintf(stderr, "The OOB area(%d) is not big enough to hold eraseblock_header(%d)", available_oob_space, sizeof(struct jffs2_raw_ebh));
- exit(1);
- }
+ cleanmarker.totlen = cpu_to_je32(8);
}
+ cleanmarker.hdr_crc = cpu_to_je32 (crc32 (0, &cleanmarker, sizeof (struct jffs2_unknown_node) - 4));
}
for (erase.start = 0; erase.start < meminfo.size; erase.start += meminfo.erasesize) {
@@ -180,20 +169,11 @@ int main (int argc, char *argv[])
/* write cleanmarker */
if (isNAND) {
struct mtd_oob_buf oob;
- uint32_t i = 0, written = 0;
-
- while (written < sizeof(struct jffs2_raw_ebh)) {
- oob.ptr = (unsigned char *) &ebh + written;
- oob.start = erase.start + meminfo.oobblock*i + ebhpos;
- oob.length = (sizeof(struct jffs2_raw_ebh) - written) < ebhlen ? (sizeof(struct jffs2_raw_ebh) - written) : ebhlen;
- if (ioctl (fd, MEMWRITEOOB, &oob) != 0) {
- fprintf(stderr, "\n%s: %s: MTD writeoob failure: %s\n", exe_name, mtd_device, strerror(errno));
- break;
- }
- i++;
- written += oob.length;
- }
- if (written < sizeof(struct jffs2_raw_ebh)) {
+ oob.ptr = (unsigned char *) &cleanmarker;
+ oob.start = erase.start + clmpos;
+ oob.length = clmlen;
+ if (ioctl (fd, MEMWRITEOOB, &oob) != 0) {
+ fprintf(stderr, "\n%s: %s: MTD writeoob failure: %s\n", exe_name, mtd_device, strerror(errno));
continue;
}
} else {
@@ -201,7 +181,7 @@ int main (int argc, char *argv[])
fprintf(stderr, "\n%s: %s: MTD lseek failure: %s\n", exe_name, mtd_device, strerror(errno));
continue;
}
- if (write (fd , &ebh, sizeof (ebh)) != sizeof (ebh)) {
+ if (write (fd , &cleanmarker, sizeof (cleanmarker)) != sizeof (cleanmarker)) {
fprintf(stderr, "\n%s: %s: MTD write failure: %s\n", exe_name, mtd_device, strerror(errno));
continue;
}
diff --git a/ftl_check.c b/ftl_check.c
index 1a64f6b..f5398ed 100644
--- a/ftl_check.c
+++ b/ftl_check.c
@@ -48,7 +48,7 @@
#include <sys/stat.h>
#include <mtd/mtd-user.h>
-#include <linux/mtd/ftl.h>
+#include <mtd/ftl-user.h>
#include <byteswap.h>
#include <endian.h>
diff --git a/ftl_format.c b/ftl_format.c
index 231fb3f..8739fab 100644
--- a/ftl_format.c
+++ b/ftl_format.c
@@ -48,7 +48,7 @@
#include <sys/stat.h>
#include <mtd/mtd-user.h>
-#include <linux/mtd/ftl.h>
+#include <mtd/ftl-user.h>
#include <byteswap.h>
#include <endian.h>
diff --git a/jffs2dump.c b/jffs2dump.c
index c5179a6..0db0cd7 100644
--- a/jffs2dump.c
+++ b/jffs2dump.c
@@ -3,7 +3,7 @@
*
* Copyright (C) 2003 Thomas Gleixner (tglx@linutronix.de)
*
- * $Id: jffs2dump.c,v 1.12 2005/11/07 11:15:12 gleixner Exp $
+ * $Id: jffs2dump.c,v 1.10 2005/09/26 11:49:39 havasi Exp $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -37,7 +37,7 @@
#include "summary.h"
#define PROGRAM "jffs2dump"
-#define VERSION "$Revision: 1.12 $"
+#define VERSION "$Revision: 1.10 $"
#define PAD(x) (((x)+3)&~3)
@@ -379,22 +379,6 @@ void do_dumpcontent (void)
break;
}
- case JFFS2_NODETYPE_ERASEBLOCK_HEADER:
- printf ("%8s EBH node at 0x%08x, totlen 0x%08x, compat_fset 0x%02x, incompat_fset 0x%02x, rocompat_fset 0x%02x, erase_count 0x%08x\n",
- obsolete ? "Obsolete" : "", p - data, je32_to_cpu (node->eh.totlen), node->eh.compat_fset,
- node->eh.incompat_fset, node->eh.rocompat_fset, je32_to_cpu (node->eh.erase_count));
-
- crc = crc32(0, p + sizeof(struct jffs2_unknown_node) + 4, je32_to_cpu(node->eh.totlen) - sizeof(struct jffs2_unknown_node) - 4);
- if (crc != je32_to_cpu(node->eh.node_crc)) {
- printf ("Wrong node_crc at 0x%08x, 0x%08x instead of 0x%08x\n", p - data, je32_to_cpu (node->eh.node_crc), crc);
- p += PAD(je32_to_cpu (node->eh.totlen));
- dirty += PAD(je32_to_cpu (node->eh.totlen));;
- continue;
- }
-
- p += PAD(je32_to_cpu (node->eh.totlen));
- break;
-
case JFFS2_NODETYPE_CLEANMARKER:
if (verbose) {
printf ("%8s Cleanmarker at 0x%08x, totlen 0x%08x\n",
@@ -631,23 +615,6 @@ void do_endianconvert (void)
break;
}
- case JFFS2_NODETYPE_ERASEBLOCK_HEADER:
- newnode.eh.magic = cnv_e16 (node->eh.magic);
- newnode.eh.nodetype = cnv_e16 (node->eh.nodetype);
- newnode.eh.totlen = cnv_e32 (node->eh.totlen);
- newnode.eh.hdr_crc = cpu_to_e32 (crc32 (0, &newnode, sizeof (struct jffs2_unknown_node) - 4));
- newnode.eh.reserved = node->eh.reserved;
- newnode.eh.compat_fset = node->eh.compat_fset;
- newnode.eh.incompat_fset = node->eh.incompat_fset;
- newnode.eh.rocompat_fset = node->eh.rocompat_fset;
- newnode.eh.erase_count = cnv_e32 (node->eh.erase_count);
- newnode.eh.node_crc = cpu_to_e32 (crc32 (0, (unsigned char *)&newnode + sizeof(struct jffs2_unknown_node) + 4,
- je32_to_cpu(node->eh.totlen) - sizeof(struct jffs2_unknown_node) + 4));
- write(fd, &newnode, sizeof(struct jffs2_raw_ebh));
- write(fd, p + sizeof(struct jffs2_raw_ebh), PAD(je32_to_cpu(node->eh.totlen) - sizeof(struct jffs2_raw_ebh)));
- p += PAD(je32_to_cpu (node->eh.totlen));
- break;
-
case 0xffff:
write (fd, p, 4);
p += 4;
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':