* mtd-utils warnings
@ 2009-07-07 14:03 Jörn Engel
2009-07-07 16:22 ` [Patch] Support large devices for flash_eraseaal Jörn Engel
0 siblings, 1 reply; 4+ messages in thread
From: Jörn Engel @ 2009-07-07 14:03 UTC (permalink / raw)
To: Josh Boyer, linux-mtd
Hi Josh,
I have a quick and dirty patch that removes most warnings when compiling
mtd-utils. It should be relatively safe and trivial, but I won't give
any guarantees for it. Interested?
Signed-off-by: Joern Engel <joern@logfs.org>
Jörn
--
The only real mistake is the one from which we learn nothing.
-- John Powell
compr.h | 2 +-
fec.c | 10 +++++-----
flash_eraseall.c | 5 +++++
ftl_check.c | 4 ++--
jffs2dump.c | 36 ++++++++++++++++++------------------
mkfs.jffs2.c | 23 ++++++++++++-----------
mtd_debug.c | 2 +-
nandtest.c | 6 +++---
nandwrite.c | 1 -
nftl_format.c | 3 ++-
recv_image.c | 4 ++--
sumtool.c | 38 +++++++++++++++++++-------------------
12 files changed, 70 insertions(+), 64 deletions(-)
diff --git a/compr.h b/compr.h
index 51bf0dd..4b79802 100644
--- a/compr.h
+++ b/compr.h
@@ -67,7 +67,7 @@ int jffs2_set_compressor_priority(const char *name, int priority);
struct jffs2_compressor {
struct list_head list;
int priority; /* used by prirority comr. mode */
- char *name;
+ const char *name;
char compr; /* JFFS2_COMPR_XXX */
int (*compress)(unsigned char *data_in, unsigned char *cpage_out,
uint32_t *srclen, uint32_t *destlen, void *model);
diff --git a/fec.c b/fec.c
index 6d9020f..924701f 100644
--- a/fec.c
+++ b/fec.c
@@ -114,7 +114,7 @@ typedef unsigned short gf;
* Primitive polynomials - see Lin & Costello, Appendix A,
* and Lee & Messerschmitt, p. 453.
*/
-static char *allPp[] = { /* GF_BITS polynomial */
+static const char *allPp[] = { /* GF_BITS polynomial */
NULL, /* 0 no code */
NULL, /* 1 no code */
"111", /* 2 1+x+x^2 */
@@ -226,7 +226,7 @@ gf_mul(x,y)
* one place.
*/
static void *
-my_malloc(int sz, char *err_string)
+my_malloc(int sz, const char *err_string)
{
void *p = malloc( sz );
if (p == NULL) {
@@ -247,7 +247,7 @@ generate_gf(void)
{
int i;
gf mask;
- char *Pp = allPp[GF_BITS] ;
+ const char *Pp = allPp[GF_BITS] ;
mask = 1; /* x ** 0 = 1 */
gf_exp[GF_BITS] = 0; /* will be updated at the end of the 1st loop */
@@ -792,7 +792,7 @@ shuffle(gf *pkt[], int index[], int k)
* a vector of k*k elements, in row-major order
*/
static gf *
-build_decode_matrix(struct fec_parms *code, gf *pkt[], int index[])
+build_decode_matrix(struct fec_parms *code, int index[])
{
int i , k = code->k ;
gf *p, *matrix = NEW_GF_MATRIX(k, k);
@@ -846,7 +846,7 @@ fec_decode(struct fec_parms *code, gf *pkt[], int index[], int sz)
if (shuffle(pkt, index, k)) /* error if true */
return 1 ;
- m_dec = build_decode_matrix(code, pkt, index);
+ m_dec = build_decode_matrix(code, index);
if (m_dec == NULL)
return 1 ; /* error */
diff --git a/flash_eraseall.c b/flash_eraseall.c
index a22fc49..bcc7f88 100644
--- a/flash_eraseall.c
+++ b/flash_eraseall.c
@@ -43,6 +43,11 @@
#define PROGRAM "flash_eraseall"
#define VERSION "$Revision: 1.22 $"
+#define TRACE() do { \
+ printf("trace: %s:%d: %p->%s\n", __FILE__, __LINE__, \
+ __builtin_return_address(0), __func__); \
+} while(0)
+
static const char *exe_name;
static const char *mtd_device;
static int quiet; /* true -- don't output progress */
diff --git a/ftl_check.c b/ftl_check.c
index f41e79a..0e5d139 100644
--- a/ftl_check.c
+++ b/ftl_check.c
@@ -79,7 +79,7 @@ static void print_size(u_int s)
/*====================================================================*/
-static void check_partition(int fd, int verbose)
+static void check_partition(int fd)
{
mtd_info_t mtd;
erase_unit_header_t hdr, hdr2;
@@ -224,7 +224,7 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
- check_partition(fd, verbose);
+ check_partition(fd);
close(fd);
exit(EXIT_SUCCESS);
diff --git a/jffs2dump.c b/jffs2dump.c
index c5a99df..bcb518a 100644
--- a/jffs2dump.c
+++ b/jffs2dump.c
@@ -199,12 +199,12 @@ void do_dumpcontent (void)
}
if (p != p_free_begin)
- printf("Empty space found from 0x%08x to 0x%08x\n", p_free_begin-data, p-data);
+ printf("Empty space found from 0x%08lx to 0x%08lx\n", p_free_begin-data, p-data);
p_free_begin = NULL;
if (je16_to_cpu (node->u.magic) != JFFS2_MAGIC_BITMASK) {
if (!bitchbitmask++)
- printf ("Wrong bitmask at 0x%08x, 0x%04x\n", p - data, je16_to_cpu (node->u.magic));
+ printf ("Wrong bitmask at 0x%08lx, 0x%04x\n", p - data, je16_to_cpu (node->u.magic));
p += 4;
dirty += 4;
continue;
@@ -222,7 +222,7 @@ void do_dumpcontent (void)
crc = crc32 (0, node, sizeof (struct jffs2_unknown_node) - 4);
if (crc != je32_to_cpu (node->u.hdr_crc)) {
- printf ("Wrong hdr_crc at 0x%08x, 0x%08x instead of 0x%08x\n", p - data, je32_to_cpu (node->u.hdr_crc), crc);
+ printf ("Wrong hdr_crc at 0x%08lx, 0x%08x instead of 0x%08x\n", p - data, je32_to_cpu (node->u.hdr_crc), crc);
p += 4;
dirty += 4;
continue;
@@ -231,7 +231,7 @@ void do_dumpcontent (void)
switch(je16_to_cpu(node->u.nodetype)) {
case JFFS2_NODETYPE_INODE:
- printf ("%8s Inode node at 0x%08x, totlen 0x%08x, #ino %5d, version %5d, isize %8d, csize %8d, dsize %8d, offset %8d\n",
+ printf ("%8s Inode node at 0x%08lx, totlen 0x%08x, #ino %5d, version %5d, isize %8d, csize %8d, dsize %8d, offset %8d\n",
obsolete ? "Obsolete" : "",
p - data, je32_to_cpu (node->i.totlen), je32_to_cpu (node->i.ino),
je32_to_cpu ( node->i.version), je32_to_cpu (node->i.isize),
@@ -239,7 +239,7 @@ void do_dumpcontent (void)
crc = crc32 (0, node, sizeof (struct jffs2_raw_inode) - 8);
if (crc != je32_to_cpu (node->i.node_crc)) {
- printf ("Wrong node_crc at 0x%08x, 0x%08x instead of 0x%08x\n", p - data, je32_to_cpu (node->i.node_crc), crc);
+ printf ("Wrong node_crc at 0x%08lx, 0x%08x instead of 0x%08x\n", p - data, je32_to_cpu (node->i.node_crc), crc);
p += PAD(je32_to_cpu (node->i.totlen));
dirty += PAD(je32_to_cpu (node->i.totlen));;
continue;
@@ -247,7 +247,7 @@ void do_dumpcontent (void)
crc = crc32(0, p + sizeof (struct jffs2_raw_inode), je32_to_cpu(node->i.csize));
if (crc != je32_to_cpu(node->i.data_crc)) {
- printf ("Wrong data_crc at 0x%08x, 0x%08x instead of 0x%08x\n", p - data, je32_to_cpu (node->i.data_crc), crc);
+ printf ("Wrong data_crc at 0x%08lx, 0x%08x instead of 0x%08x\n", p - data, je32_to_cpu (node->i.data_crc), crc);
p += PAD(je32_to_cpu (node->i.totlen));
dirty += PAD(je32_to_cpu (node->i.totlen));;
continue;
@@ -259,7 +259,7 @@ void do_dumpcontent (void)
case JFFS2_NODETYPE_DIRENT:
memcpy (name, node->d.name, node->d.nsize);
name [node->d.nsize] = 0x0;
- printf ("%8s Dirent node at 0x%08x, totlen 0x%08x, #pino %5d, version %5d, #ino %8d, nsize %8d, name %s\n",
+ printf ("%8s Dirent node at 0x%08lx, totlen 0x%08x, #pino %5d, version %5d, #ino %8d, nsize %8d, name %s\n",
obsolete ? "Obsolete" : "",
p - data, je32_to_cpu (node->d.totlen), je32_to_cpu (node->d.pino),
je32_to_cpu ( node->d.version), je32_to_cpu (node->d.ino),
@@ -267,7 +267,7 @@ void do_dumpcontent (void)
crc = crc32 (0, node, sizeof (struct jffs2_raw_dirent) - 8);
if (crc != je32_to_cpu (node->d.node_crc)) {
- printf ("Wrong node_crc at 0x%08x, 0x%08x instead of 0x%08x\n", p - data, je32_to_cpu (node->d.node_crc), crc);
+ printf ("Wrong node_crc at 0x%08lx, 0x%08x instead of 0x%08x\n", p - data, je32_to_cpu (node->d.node_crc), crc);
p += PAD(je32_to_cpu (node->d.totlen));
dirty += PAD(je32_to_cpu (node->d.totlen));;
continue;
@@ -275,7 +275,7 @@ void do_dumpcontent (void)
crc = crc32(0, p + sizeof (struct jffs2_raw_dirent), node->d.nsize);
if (crc != je32_to_cpu(node->d.name_crc)) {
- printf ("Wrong name_crc at 0x%08x, 0x%08x instead of 0x%08x\n", p - data, je32_to_cpu (node->d.name_crc), crc);
+ printf ("Wrong name_crc at 0x%08lx, 0x%08x instead of 0x%08x\n", p - data, je32_to_cpu (node->d.name_crc), crc);
p += PAD(je32_to_cpu (node->d.totlen));
dirty += PAD(je32_to_cpu (node->d.totlen));;
continue;
@@ -289,7 +289,7 @@ void do_dumpcontent (void)
int i;
struct jffs2_sum_marker * sm;
- printf("%8s Inode Sum node at 0x%08x, totlen 0x%08x, sum_num %5d, cleanmarker size %5d\n",
+ printf("%8s Inode Sum node at 0x%08lx, totlen 0x%08x, sum_num %5d, cleanmarker size %5d\n",
obsolete ? "Obsolete" : "",
p - data,
je32_to_cpu (node->s.totlen),
@@ -298,7 +298,7 @@ void do_dumpcontent (void)
crc = crc32 (0, node, sizeof (struct jffs2_raw_summary) - 8);
if (crc != je32_to_cpu (node->s.node_crc)) {
- printf ("Wrong node_crc at 0x%08x, 0x%08x instead of 0x%08x\n", p - data, je32_to_cpu (node->s.node_crc), crc);
+ printf ("Wrong node_crc at 0x%08lx, 0x%08x instead of 0x%08x\n", p - data, je32_to_cpu (node->s.node_crc), crc);
p += PAD(je32_to_cpu (node->s.totlen));
dirty += PAD(je32_to_cpu (node->s.totlen));;
continue;
@@ -306,7 +306,7 @@ void do_dumpcontent (void)
crc = crc32(0, p + sizeof (struct jffs2_raw_summary), je32_to_cpu (node->s.totlen) - sizeof(struct jffs2_raw_summary));
if (crc != je32_to_cpu(node->s.sum_crc)) {
- printf ("Wrong data_crc at 0x%08x, 0x%08x instead of 0x%08x\n", p - data, je32_to_cpu (node->s.sum_crc), crc);
+ printf ("Wrong data_crc at 0x%08lx, 0x%08x instead of 0x%08x\n", p - data, je32_to_cpu (node->s.sum_crc), crc);
p += PAD(je32_to_cpu (node->s.totlen));
dirty += PAD(je32_to_cpu (node->s.totlen));;
continue;
@@ -379,7 +379,7 @@ void do_dumpcontent (void)
case JFFS2_NODETYPE_CLEANMARKER:
if (verbose) {
- printf ("%8s Cleanmarker at 0x%08x, totlen 0x%08x\n",
+ printf ("%8s Cleanmarker at 0x%08lx, totlen 0x%08x\n",
obsolete ? "Obsolete" : "",
p - data, je32_to_cpu (node->u.totlen));
}
@@ -388,7 +388,7 @@ void do_dumpcontent (void)
case JFFS2_NODETYPE_PADDING:
if (verbose) {
- printf ("%8s Padding node at 0x%08x, totlen 0x%08x\n",
+ printf ("%8s Padding node at 0x%08lx, totlen 0x%08x\n",
obsolete ? "Obsolete" : "",
p - data, je32_to_cpu (node->u.totlen));
}
@@ -402,7 +402,7 @@ void do_dumpcontent (void)
default:
if (verbose) {
- printf ("%8s Unknown node at 0x%08x, totlen 0x%08x\n",
+ printf ("%8s Unknown node at 0x%08lx, totlen 0x%08x\n",
obsolete ? "Obsolete" : "",
p - data, je32_to_cpu (node->u.totlen));
}
@@ -444,7 +444,7 @@ void do_endianconvert (void)
}
if (je16_to_cpu (node->u.magic) != JFFS2_MAGIC_BITMASK) {
- printf ("Wrong bitmask at 0x%08x, 0x%04x\n", p - data, je16_to_cpu (node->u.magic));
+ printf ("Wrong bitmask at 0x%08lx, 0x%04x\n", p - data, je16_to_cpu (node->u.magic));
newnode.u.magic = cnv_e16 (node->u.magic);
newnode.u.nodetype = cnv_e16 (node->u.nodetype);
write (fd, &newnode, 4);
@@ -454,7 +454,7 @@ void do_endianconvert (void)
crc = crc32 (0, node, sizeof (struct jffs2_unknown_node) - 4);
if (crc != je32_to_cpu (node->u.hdr_crc)) {
- printf ("Wrong hdr_crc at 0x%08x, 0x%08x instead of 0x%08x\n", p - data, je32_to_cpu (node->u.hdr_crc), crc);
+ printf ("Wrong hdr_crc at 0x%08lx, 0x%08x instead of 0x%08x\n", p - data, je32_to_cpu (node->u.hdr_crc), crc);
}
switch(je16_to_cpu(node->u.nodetype)) {
@@ -619,7 +619,7 @@ void do_endianconvert (void)
break;
default:
- printf ("Unknown node type: 0x%04x at 0x%08x, totlen 0x%08x\n", je16_to_cpu (node->u.nodetype), p - data, je32_to_cpu (node->u.totlen));
+ printf ("Unknown node type: 0x%04x at 0x%08lx, totlen 0x%08x\n", je16_to_cpu (node->u.nodetype), p - data, je32_to_cpu (node->u.totlen));
p += PAD(je32_to_cpu (node->u.totlen));
}
diff --git a/mkfs.jffs2.c b/mkfs.jffs2.c
index 23a8cf8..f39e46a 100644
--- a/mkfs.jffs2.c
+++ b/mkfs.jffs2.c
@@ -1089,7 +1089,7 @@ static uint32_t highest_xseqno = 0;
static struct {
int xprefix;
- char *string;
+ const char *string;
int length;
} xprefix_tbl[] = {
{ JFFS2_XPREFIX_USER, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN },
@@ -1231,7 +1231,8 @@ static void write_xattr_entry(struct filesystem_entry *e)
struct jffs2_raw_xref ref;
struct xattr_entry *xe;
char xlist[XATTR_BUFFER_SIZE], xvalue[XATTR_BUFFER_SIZE];
- char *xname, *prefix_str;
+ char *xname;
+ const char *prefix_str;
int i, xprefix, prefix_len;
int list_sz, offset, name_len, value_len;
@@ -1479,7 +1480,7 @@ static struct option long_options[] = {
{NULL, 0, NULL, 0}
};
-static char *helptext =
+static const char *helptext =
"Usage: mkfs.jffs2 [OPTIONS]\n"
"Make a JFFS2 file system image from an existing directory tree\n\n"
"Options:\n"
@@ -1518,7 +1519,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 = "1.60";
+static const char *revtext = "1.60";
int load_next_block() {
@@ -1552,7 +1553,7 @@ void process_buffer(int inp_size) {
if (je16_to_cpu (node->u.magic) != JFFS2_MAGIC_BITMASK) {
if (!bitchbitmask++)
- printf ("Wrong bitmask at 0x%08x, 0x%04x\n", p - file_buffer, je16_to_cpu (node->u.magic));
+ printf ("Wrong bitmask at 0x%08lx, 0x%04x\n", p - file_buffer, je16_to_cpu (node->u.magic));
p += 4;
continue;
}
@@ -1572,7 +1573,7 @@ void process_buffer(int inp_size) {
case JFFS2_NODETYPE_INODE:
if(verbose)
- printf ("%8s Inode node at 0x%08x, totlen 0x%08x, #ino %5d, version %5d, isize %8d, csize %8d, dsize %8d, offset %8d\n",
+ printf ("%8s Inode node at 0x%08lx, totlen 0x%08x, #ino %5d, version %5d, isize %8d, csize %8d, dsize %8d, offset %8d\n",
obsolete ? "Obsolete" : "",
p - file_buffer, je32_to_cpu (node->i.totlen), je32_to_cpu (node->i.ino),
je32_to_cpu ( node->i.version), je32_to_cpu (node->i.isize),
@@ -1589,7 +1590,7 @@ void process_buffer(int inp_size) {
name [node->d.nsize] = 0x0;
if(verbose)
- printf ("%8s Dirent node at 0x%08x, totlen 0x%08x, #pino %5d, version %5d, #ino %8d, nsize %8d, name %s\n",
+ printf ("%8s Dirent node at 0x%08lx, totlen 0x%08x, #pino %5d, version %5d, #ino %8d, nsize %8d, name %s\n",
obsolete ? "Obsolete" : "",
p - file_buffer, je32_to_cpu (node->d.totlen), je32_to_cpu (node->d.pino),
je32_to_cpu ( node->d.version), je32_to_cpu (node->d.ino),
@@ -1600,7 +1601,7 @@ void process_buffer(int inp_size) {
case JFFS2_NODETYPE_CLEANMARKER:
if (verbose) {
- printf ("%8s Cleanmarker at 0x%08x, totlen 0x%08x\n",
+ printf ("%8s Cleanmarker at 0x%08lx, totlen 0x%08x\n",
obsolete ? "Obsolete" : "",
p - file_buffer, je32_to_cpu (node->u.totlen));
}
@@ -1610,7 +1611,7 @@ void process_buffer(int inp_size) {
case JFFS2_NODETYPE_PADDING:
if (verbose) {
- printf ("%8s Padding node at 0x%08x, totlen 0x%08x\n",
+ printf ("%8s Padding node at 0x%08lx, totlen 0x%08x\n",
obsolete ? "Obsolete" : "",
p - file_buffer, je32_to_cpu (node->u.totlen));
}
@@ -1624,7 +1625,7 @@ void process_buffer(int inp_size) {
default:
if (verbose) {
- printf ("%8s Unknown node at 0x%08x, totlen 0x%08x\n",
+ printf ("%8s Unknown node at 0x%08lx, totlen 0x%08x\n",
obsolete ? "Obsolete" : "",
p - file_buffer, je32_to_cpu (node->u.totlen));
}
@@ -1878,7 +1879,7 @@ int main(int argc, char **argv)
if(in_fd != -1)
parse_image();
- root = recursive_add_host_directory(NULL, "/", cwd);
+ root = recursive_add_host_directory(NULL, (char *)"/", cwd);
if (devtable)
parse_device_table(root, devtable);
diff --git a/mtd_debug.c b/mtd_debug.c
index 85d48e9..60e1ce1 100644
--- a/mtd_debug.c
+++ b/mtd_debug.c
@@ -158,7 +158,7 @@ retry:
if (buf != NULL)
free (buf);
close (outfd);
- printf ("Copied %d bytes from address 0x%.8x in flash to %s\n",len,offset,filename);
+ printf ("Copied %zd bytes from address 0x%.8x in flash to %s\n",len,offset,filename);
return (0);
err2:
diff --git a/nandtest.c b/nandtest.c
index 7613a52..e406777 100644
--- a/nandtest.c
+++ b/nandtest.c
@@ -70,7 +70,7 @@ int erase_and_write(loff_t ofs, unsigned char *data, unsigned char *rbuf)
}
if (len < meminfo.erasesize) {
printf("\n");
- fprintf(stderr, "Short write (%d bytes)\n", len);
+ fprintf(stderr, "Short write (%zd bytes)\n", len);
exit(1);
}
@@ -81,7 +81,7 @@ int erase_and_write(loff_t ofs, unsigned char *data, unsigned char *rbuf)
if (len < meminfo.erasesize) {
printf("\n");
if (len)
- fprintf(stderr, "Short read (%d bytes)\n", len);
+ fprintf(stderr, "Short read (%zd bytes)\n", len);
else
perror("read");
exit(1);
@@ -263,7 +263,7 @@ int main(int argc, char **argv)
if (len < meminfo.erasesize) {
printf("\n");
if (len)
- fprintf(stderr, "Short read (%d bytes)\n", len);
+ fprintf(stderr, "Short read (%zd bytes)\n", len);
else
perror("read");
exit(1);
diff --git a/nandwrite.c b/nandwrite.c
index 1a9449b..16c3938 100644
--- a/nandwrite.c
+++ b/nandwrite.c
@@ -260,7 +260,6 @@ int main(int argc, char * const argv[])
int ret, readlen;
int oobinfochanged = 0;
struct nand_oobinfo old_oobinfo;
- int readcnt = 0;
bool failed = true;
process_options(argc, argv);
diff --git a/nftl_format.c b/nftl_format.c
index 42949a0..167098a 100644
--- a/nftl_format.c
+++ b/nftl_format.c
@@ -202,7 +202,8 @@ int main(int argc, char **argv)
long MediaUnitOff1 = 0, MediaUnitOff2 = 0;
unsigned char oobbuf[16];
struct mtd_oob_buf oob = {0, 16, oobbuf};
- char *mtddevice, *nftl;
+ char *mtddevice;
+ const char *nftl;
int c, do_inftl = 0, do_bbt = 0;
diff --git a/recv_image.c b/recv_image.c
index d65aa2a..8d7a2e7 100644
--- a/recv_image.c
+++ b/recv_image.c
@@ -39,7 +39,7 @@ int main(int argc, char **argv)
struct addrinfo *runp;
int ret;
int sock;
- size_t len;
+ ssize_t len;
int flfd;
struct mtd_info_user meminfo;
unsigned char *eb_buf, *decode_buf, **src_pkts;
@@ -166,7 +166,7 @@ int main(int argc, char **argv)
break;
}
if (len < sizeof(thispkt)) {
- fprintf(stderr, "Wrong length %d bytes (expected %d)\n",
+ fprintf(stderr, "Wrong length %zd bytes (expected %ld)\n",
len, sizeof(thispkt));
continue;
}
diff --git a/sumtool.c b/sumtool.c
index 6bb7168..2cd98b1 100644
--- a/sumtool.c
+++ b/sumtool.c
@@ -73,7 +73,7 @@ static unsigned int file_ofs = 0; /* position in the buffer */
int target_endian = __BYTE_ORDER;
-static struct option long_options[] = {
+static const struct option long_options[] = {
{"output", 1, NULL, 'o'},
{"input", 1, NULL, 'i'},
{"eraseblock", 1, NULL, 'e'},
@@ -88,7 +88,7 @@ static struct option long_options[] = {
{NULL, 0, NULL, 0}
};
-static char *helptext =
+static const char *helptext =
"Usage: sumtool [OPTIONS] -i inputfile -o outputfile\n\n"
"Convert the input JFFS2 image to a summarized JFFS2 image\n"
"Summary makes mounting faster - if summary support enabled in your kernel\n\n"
@@ -112,7 +112,7 @@ static char *helptext =
" eraseblock\n\n";
-static char *revtext = "$Revision: 1.9 $";
+static const char *revtext = "$Revision: 1.9 $";
static unsigned char ffbuf[16] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
@@ -740,7 +740,7 @@ void create_summed_image(int inp_size)
if (je16_to_cpu (node->u.magic) != JFFS2_MAGIC_BITMASK) {
if (!bitchbitmask++)
- printf ("Wrong bitmask at 0x%08x, 0x%04x\n", p - file_buffer, je16_to_cpu (node->u.magic));
+ printf ("Wrong bitmask at 0x%08lx, 0x%04x\n", p - file_buffer, je16_to_cpu (node->u.magic));
p += 4;
continue;
}
@@ -759,7 +759,7 @@ void create_summed_image(int inp_size)
crc = crc32 (0, node, sizeof (struct jffs2_unknown_node) - 4);
if (crc != je32_to_cpu (node->u.hdr_crc)) {
- printf ("Wrong hdr_crc at 0x%08x, 0x%08x instead of 0x%08x\n", p - file_buffer, je32_to_cpu (node->u.hdr_crc), crc);
+ printf ("Wrong hdr_crc at 0x%08lx, 0x%08x instead of 0x%08x\n", p - file_buffer, je32_to_cpu (node->u.hdr_crc), crc);
p += 4;
continue;
}
@@ -767,7 +767,7 @@ void create_summed_image(int inp_size)
switch(je16_to_cpu(node->u.nodetype)) {
case JFFS2_NODETYPE_INODE:
if (verbose)
- printf ("%8s Inode node at 0x%08x, totlen 0x%08x, #ino %5d, version %5d, isize %8d, csize %8d, dsize %8d, offset %8d\n",
+ printf ("%8s Inode node at 0x%08lx, totlen 0x%08x, #ino %5d, version %5d, isize %8d, csize %8d, dsize %8d, offset %8d\n",
obsolete ? "Obsolete" : "",
p - file_buffer, je32_to_cpu (node->i.totlen), je32_to_cpu (node->i.ino),
je32_to_cpu ( node->i.version), je32_to_cpu (node->i.isize),
@@ -775,14 +775,14 @@ void create_summed_image(int inp_size)
crc = crc32 (0, node, sizeof (struct jffs2_raw_inode) - 8);
if (crc != je32_to_cpu (node->i.node_crc)) {
- printf ("Wrong node_crc at 0x%08x, 0x%08x instead of 0x%08x\n", p - file_buffer, je32_to_cpu (node->i.node_crc), crc);
+ printf ("Wrong node_crc at 0x%08lx, 0x%08x instead of 0x%08x\n", p - file_buffer, je32_to_cpu (node->i.node_crc), crc);
p += PAD(je32_to_cpu (node->i.totlen));
continue;
}
crc = crc32(0, p + sizeof (struct jffs2_raw_inode), je32_to_cpu(node->i.csize));
if (crc != je32_to_cpu(node->i.data_crc)) {
- printf ("Wrong data_crc at 0x%08x, 0x%08x instead of 0x%08x\n", p - file_buffer, je32_to_cpu (node->i.data_crc), crc);
+ printf ("Wrong data_crc at 0x%08lx, 0x%08x instead of 0x%08x\n", p - file_buffer, je32_to_cpu (node->i.data_crc), crc);
p += PAD(je32_to_cpu (node->i.totlen));
continue;
}
@@ -797,7 +797,7 @@ void create_summed_image(int inp_size)
name [node->d.nsize] = 0x0;
if (verbose)
- printf ("%8s Dirent node at 0x%08x, totlen 0x%08x, #pino %5d, version %5d, #ino %8d, nsize %8d, name %s\n",
+ printf ("%8s Dirent node at 0x%08lx, totlen 0x%08x, #pino %5d, version %5d, #ino %8d, nsize %8d, name %s\n",
obsolete ? "Obsolete" : "",
p - file_buffer, je32_to_cpu (node->d.totlen), je32_to_cpu (node->d.pino),
je32_to_cpu ( node->d.version), je32_to_cpu (node->d.ino),
@@ -805,14 +805,14 @@ void create_summed_image(int inp_size)
crc = crc32 (0, node, sizeof (struct jffs2_raw_dirent) - 8);
if (crc != je32_to_cpu (node->d.node_crc)) {
- printf ("Wrong node_crc at 0x%08x, 0x%08x instead of 0x%08x\n", p - file_buffer, je32_to_cpu (node->d.node_crc), crc);
+ printf ("Wrong node_crc at 0x%08lx, 0x%08x instead of 0x%08x\n", p - file_buffer, je32_to_cpu (node->d.node_crc), crc);
p += PAD(je32_to_cpu (node->d.totlen));
continue;
}
crc = crc32(0, p + sizeof (struct jffs2_raw_dirent), node->d.nsize);
if (crc != je32_to_cpu(node->d.name_crc)) {
- printf ("Wrong name_crc at 0x%08x, 0x%08x instead of 0x%08x\n", p - file_buffer, je32_to_cpu (node->d.name_crc), crc);
+ printf ("Wrong name_crc at 0x%08lx, 0x%08x instead of 0x%08x\n", p - file_buffer, je32_to_cpu (node->d.name_crc), crc);
p += PAD(je32_to_cpu (node->d.totlen));
continue;
}
@@ -826,14 +826,14 @@ void create_summed_image(int inp_size)
if (je32_to_cpu(node->x.node_crc) == 0xffffffff)
obsolete = 1;
if (verbose)
- printf("%8s Xdatum node at 0x%08x, totlen 0x%08x, "
+ printf("%8s Xdatum node at 0x%08lx, totlen 0x%08x, "
"#xid %5u, version %5u\n",
obsolete ? "Obsolete" : "",
p - file_buffer, je32_to_cpu (node->x.totlen),
je32_to_cpu(node->x.xid), je32_to_cpu(node->x.version));
crc = crc32(0, node, sizeof (struct jffs2_raw_xattr) - 4);
if (crc != je32_to_cpu(node->x.node_crc)) {
- printf("Wrong node_crc at 0x%08x, 0x%08x instead of 0x%08x\n",
+ printf("Wrong node_crc at 0x%08lx, 0x%08x instead of 0x%08x\n",
p - file_buffer, je32_to_cpu(node->x.node_crc), crc);
p += PAD(je32_to_cpu (node->x.totlen));
continue;
@@ -841,7 +841,7 @@ void create_summed_image(int inp_size)
length = node->x.name_len + 1 + je16_to_cpu(node->x.value_len);
crc = crc32(0, node->x.data, length);
if (crc != je32_to_cpu(node->x.data_crc)) {
- printf("Wrong data_crc at 0x%08x, 0x%08x instead of 0x%08x\n",
+ printf("Wrong data_crc at 0x%08lx, 0x%08x instead of 0x%08x\n",
p - file_buffer, je32_to_cpu(node->x.data_crc), crc);
p += PAD(je32_to_cpu (node->x.totlen));
continue;
@@ -855,14 +855,14 @@ void create_summed_image(int inp_size)
if (je32_to_cpu(node->r.node_crc) == 0xffffffff)
obsolete = 1;
if (verbose)
- printf("%8s Xref node at 0x%08x, totlen 0x%08x, "
+ printf("%8s Xref node at 0x%08lx, totlen 0x%08x, "
"#ino %5u, xid %5u\n",
obsolete ? "Obsolete" : "",
p - file_buffer, je32_to_cpu(node->r.totlen),
je32_to_cpu(node->r.ino), je32_to_cpu(node->r.xid));
crc = crc32(0, node, sizeof (struct jffs2_raw_xref) - 4);
if (crc != je32_to_cpu(node->r.node_crc)) {
- printf("Wrong node_crc at 0x%08x, 0x%08x instead of 0x%08x\n",
+ printf("Wrong node_crc at 0x%08lx, 0x%08x instead of 0x%08x\n",
p - file_buffer, je32_to_cpu(node->r.node_crc), crc);
p += PAD(je32_to_cpu (node->r.totlen));
continue;
@@ -874,7 +874,7 @@ void create_summed_image(int inp_size)
case JFFS2_NODETYPE_CLEANMARKER:
if (verbose) {
- printf ("%8s Cleanmarker at 0x%08x, totlen 0x%08x\n",
+ printf ("%8s Cleanmarker at 0x%08lx, totlen 0x%08x\n",
obsolete ? "Obsolete" : "",
p - file_buffer, je32_to_cpu (node->u.totlen));
}
@@ -893,7 +893,7 @@ void create_summed_image(int inp_size)
case JFFS2_NODETYPE_PADDING:
if (verbose) {
- printf ("%8s Padding node at 0x%08x, totlen 0x%08x\n",
+ printf ("%8s Padding node at 0x%08lx, totlen 0x%08x\n",
obsolete ? "Obsolete" : "",
p - file_buffer, je32_to_cpu (node->u.totlen));
}
@@ -906,7 +906,7 @@ void create_summed_image(int inp_size)
default:
if (verbose) {
- printf ("%8s Unknown node at 0x%08x, totlen 0x%08x\n",
+ printf ("%8s Unknown node at 0x%08lx, totlen 0x%08x\n",
obsolete ? "Obsolete" : "",
p - file_buffer, je32_to_cpu (node->u.totlen));
}
^ permalink raw reply related [flat|nested] 4+ messages in thread* [Patch] Support large devices for flash_eraseaal
2009-07-07 14:03 mtd-utils warnings Jörn Engel
@ 2009-07-07 16:22 ` Jörn Engel
2009-07-07 16:25 ` Jörn Engel
0 siblings, 1 reply; 4+ messages in thread
From: Jörn Engel @ 2009-07-07 16:22 UTC (permalink / raw)
To: Josh Boyer, linux-mtd
The mtd-abi.h bits may be wrong, not sure. Otherwise it allows me to
erase a large device. No guarantees beyond that.
Signed-off-by: Joern Engel <joern@logfs.org>
Jörn
--
Happiness isn't having what you want, it's wanting what you have.
-- unknown
flash_eraseall.c | 88 +++++++++++++++++++++++++++++++++++++++++--------
include/mtd/mtd-abi.h | 89 +++++++++++++++++++++++++++++---------------------
2 files changed, 126 insertions(+), 51 deletions(-)
diff --git a/flash_eraseall.c b/flash_eraseall.c
index a22fc49..d865cbc 100644
--- a/flash_eraseall.c
+++ b/flash_eraseall.c
@@ -48,33 +48,93 @@ static const char *mtd_device;
static int quiet; /* true -- don't output progress */
static int jffs2; // format for jffs2 usage
+struct mtd_info_user64 {
+ uint8_t type;
+ uint32_t flags;
+ uint64_t size; // Total size of the MTD
+ uint32_t erasesize;
+ uint32_t writesize;
+ uint32_t oobsize; // Amount of OOB data per block (e.g. 16)
+ /* The below two fields are obsolete and broken, do not use them
+ * (TODO: remove at some point) */
+ uint32_t ecctype;
+ uint32_t eccsize;
+};
+
static void process_options (int argc, char *argv[]);
-void show_progress (mtd_info_t *meminfo, erase_info_t *erase);
+void show_progress(struct mtd_info_user64 *meminfo, struct erase_info_user64 *erase);
static void display_help (void);
static void display_version (void);
static struct jffs2_unknown_node cleanmarker;
int target_endian = __BYTE_ORDER;
+static int get_info(const char *devname, struct mtd_info_user64 *mtd64)
+{
+ struct mtd_info_user mtd;
+ char buf[256];
+ int fd;
+
+ if ((fd = open(devname, O_RDWR)) < 0) {
+ fprintf(stderr, "%s: %s: %s\n", exe_name, devname, strerror(errno));
+ return 1;
+ }
+
+
+ if (ioctl(fd, MEMGETINFO, &mtd) != 0) {
+ fprintf(stderr, "%s: %s: unable to get MTD device info\n", exe_name, devname);
+ return 1;
+ }
+ close(fd);
+
+ mtd64->type = mtd.type;
+ mtd64->flags = mtd.flags;
+ mtd64->size = mtd.size;
+ mtd64->erasesize = mtd.erasesize;
+ mtd64->writesize = mtd.writesize;
+ mtd64->oobsize = mtd.oobsize;
+ mtd64->ecctype = mtd.ecctype;
+ mtd64->eccsize = mtd.eccsize;
+
+ /* I'm glad I only have to do this for one parameter. */
+ sprintf(buf, "/sys/class/mtd/%s/size", basename((char *)devname));
+ fd = open(buf, O_RDONLY);
+ if (fd < 0)
+ return 0;
+ read(fd, buf, 256);
+ mtd64->size = strtoull(buf, NULL, 0);
+ close(fd);
+ return 0;
+}
+
+static int do_erase(int fd, struct erase_info_user64 *ei64, struct mtd_info_user64 *mtd64)
+{
+ struct erase_info_user ei;
+
+ if (mtd64->size >= 0x100000000ull)
+ return ioctl(fd, MEMERASE64, ei64);
+ else {
+ ei.start = ei64->start;
+ ei.length = ei64->length;
+ return ioctl(fd, MEMERASE, &ei);
+ }
+}
+
int main (int argc, char *argv[])
{
- mtd_info_t meminfo;
+ struct mtd_info_user64 meminfo;
int fd, clmpos = 0, clmlen = 8;
- erase_info_t erase;
+ struct erase_info_user64 erase;
int isNAND, bbtest = 1;
process_options(argc, argv);
+ if (get_info(mtd_device, &meminfo))
+ return 1;
if ((fd = open(mtd_device, O_RDWR)) < 0) {
fprintf(stderr, "%s: %s: %s\n", exe_name, mtd_device, strerror(errno));
return 1;
}
-
- if (ioctl(fd, MEMGETINFO, &meminfo) != 0) {
- fprintf(stderr, "%s: %s: unable to get MTD device info\n", exe_name, mtd_device);
- return 1;
- }
-
erase.length = meminfo.erasesize;
isNAND = meminfo.type == MTD_NANDFLASH ? 1 : 0;
@@ -130,7 +190,7 @@ int main (int argc, char *argv[])
int ret = ioctl(fd, MEMGETBADBLOCK, &offset);
if (ret > 0) {
if (!quiet)
- printf ("\nSkipping bad block at 0x%08x\n", erase.start);
+ printf ("\nSkipping bad block at 0x%08llx\n", erase.start);
continue;
} else if (ret < 0) {
if (errno == EOPNOTSUPP) {
@@ -149,7 +209,7 @@ int main (int argc, char *argv[])
if (!quiet)
show_progress(&meminfo, &erase);
- if (ioctl(fd, MEMERASE, &erase) != 0) {
+ if (do_erase(fd, &erase, &meminfo) != 0) {
fprintf(stderr, "\n%s: %s: MTD Erase failure: %s\n", exe_name, mtd_device, strerror(errno));
continue;
}
@@ -179,7 +239,7 @@ int main (int argc, char *argv[])
}
}
if (!quiet)
- printf (" Cleanmarker written at %x.", erase.start);
+ printf (" Cleanmarker written at %llx.", erase.start);
}
if (!quiet) {
show_progress(&meminfo, &erase);
@@ -250,9 +310,9 @@ void process_options (int argc, char *argv[])
mtd_device = argv[optind];
}
-void show_progress (mtd_info_t *meminfo, erase_info_t *erase)
+void show_progress(struct mtd_info_user64 *meminfo, struct erase_info_user64 *erase)
{
- printf("\rErasing %d Kibyte @ %x -- %2llu %% complete.",
+ printf("\rErasing %d Kibyte @ %llx -- %2llu %% complete.",
meminfo->erasesize / 1024, erase->start,
(unsigned long long) erase->start * 100 / meminfo->size);
fflush(stdout);
diff --git a/include/mtd/mtd-abi.h b/include/mtd/mtd-abi.h
index 86defe1..c6954ed 100644
--- a/include/mtd/mtd-abi.h
+++ b/include/mtd/mtd-abi.h
@@ -1,23 +1,35 @@
/*
- * $Id: mtd-abi.h,v 1.13 2005/11/07 11:14:56 gleixner Exp $
- *
* Portions of MTD ABI definition which are shared by kernel and user space
*/
#ifndef __MTD_ABI_H__
#define __MTD_ABI_H__
+#include <linux/types.h>
+
struct erase_info_user {
- uint32_t start;
- uint32_t length;
+ __u32 start;
+ __u32 length;
+};
+
+struct erase_info_user64 {
+ __u64 start;
+ __u64 length;
};
struct mtd_oob_buf {
- uint32_t start;
- uint32_t length;
+ __u32 start;
+ __u32 length;
unsigned char *ptr;
};
+struct mtd_oob_buf64 {
+ __u64 start;
+ __u32 pad;
+ __u32 length;
+ __u64 usr_ptr;
+};
+
#define MTD_ABSENT 0
#define MTD_RAM 1
#define MTD_ROM 2
@@ -29,7 +41,7 @@ struct mtd_oob_buf {
#define MTD_WRITEABLE 0x400 /* Device is writeable */
#define MTD_BIT_WRITEABLE 0x800 /* Single bits can be flipped */
#define MTD_NO_ERASE 0x1000 /* No erase necessary */
-#define MTD_STUPID_LOCK 0x2000 /* Always locked after reset */
+#define MTD_POWERUP_LOCK 0x2000 /* Always locked after reset */
// Some common devices / combinations of capabilities
#define MTD_CAP_ROM 0
@@ -50,30 +62,30 @@ struct mtd_oob_buf {
#define MTD_OTP_USER 2
struct mtd_info_user {
- uint8_t type;
- uint32_t flags;
- uint32_t size; // Total size of the MTD
- uint32_t erasesize;
- uint32_t writesize;
- uint32_t oobsize; // Amount of OOB data per block (e.g. 16)
+ __u8 type;
+ __u32 flags;
+ __u32 size; // Total size of the MTD
+ __u32 erasesize;
+ __u32 writesize;
+ __u32 oobsize; // Amount of OOB data per block (e.g. 16)
/* The below two fields are obsolete and broken, do not use them
* (TODO: remove at some point) */
- uint32_t ecctype;
- uint32_t eccsize;
+ __u32 ecctype;
+ __u32 eccsize;
};
struct region_info_user {
- uint32_t offset; /* At which this region starts,
+ __u32 offset; /* At which this region starts,
* from the beginning of the MTD */
- uint32_t erasesize; /* For this region */
- uint32_t numblocks; /* Number of blocks in this region */
- uint32_t regionindex;
+ __u32 erasesize; /* For this region */
+ __u32 numblocks; /* Number of blocks in this region */
+ __u32 regionindex;
};
struct otp_info {
- uint32_t start;
- uint32_t length;
- uint32_t locked;
+ __u32 start;
+ __u32 length;
+ __u32 locked;
};
#define MEMGETINFO _IOR('M', 1, struct mtd_info_user)
@@ -86,8 +98,8 @@ struct otp_info {
#define MEMGETREGIONINFO _IOWR('M', 8, struct region_info_user)
#define MEMSETOOBSEL _IOW('M', 9, struct nand_oobinfo)
#define MEMGETOOBSEL _IOR('M', 10, struct nand_oobinfo)
-#define MEMGETBADBLOCK _IOW('M', 11, loff_t)
-#define MEMSETBADBLOCK _IOW('M', 12, loff_t)
+#define MEMGETBADBLOCK _IOW('M', 11, __kernel_loff_t)
+#define MEMSETBADBLOCK _IOW('M', 12, __kernel_loff_t)
#define OTPSELECT _IOR('M', 13, int)
#define OTPGETREGIONCOUNT _IOW('M', 14, int)
#define OTPGETREGIONINFO _IOW('M', 15, struct otp_info)
@@ -95,21 +107,24 @@ struct otp_info {
#define ECCGETLAYOUT _IOR('M', 17, struct nand_ecclayout)
#define ECCGETSTATS _IOR('M', 18, struct mtd_ecc_stats)
#define MTDFILEMODE _IO('M', 19)
+#define MEMERASE64 _IOW('M', 20, struct erase_info_user64)
+#define MEMWRITEOOB64 _IOWR('M', 21, struct mtd_oob_buf64)
+#define MEMREADOOB64 _IOWR('M', 22, struct mtd_oob_buf64)
/*
* Obsolete legacy interface. Keep it in order not to break userspace
* interfaces
*/
struct nand_oobinfo {
- uint32_t useecc;
- uint32_t eccbytes;
- uint32_t oobfree[8][2];
- uint32_t eccpos[32];
+ __u32 useecc;
+ __u32 eccbytes;
+ __u32 oobfree[8][2];
+ __u32 eccpos[32];
};
struct nand_oobfree {
- uint32_t offset;
- uint32_t length;
+ __u32 offset;
+ __u32 length;
};
#define MTD_MAX_OOBFREE_ENTRIES 8
@@ -118,9 +133,9 @@ struct nand_oobfree {
* diagnosis and to allow creation of raw images
*/
struct nand_ecclayout {
- uint32_t eccbytes;
- uint32_t eccpos[64];
- uint32_t oobavail;
+ __u32 eccbytes;
+ __u32 eccpos[64];
+ __u32 oobavail;
struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES];
};
@@ -133,10 +148,10 @@ struct nand_ecclayout {
* @bbtblocks: number of blocks reserved for bad block tables
*/
struct mtd_ecc_stats {
- uint32_t corrected;
- uint32_t failed;
- uint32_t badblocks;
- uint32_t bbtblocks;
+ __u32 corrected;
+ __u32 failed;
+ __u32 badblocks;
+ __u32 bbtblocks;
};
/*
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [Patch] Support large devices for flash_eraseaal
2009-07-07 16:22 ` [Patch] Support large devices for flash_eraseaal Jörn Engel
@ 2009-07-07 16:25 ` Jörn Engel
2009-07-07 16:29 ` Artem Bityutskiy
0 siblings, 1 reply; 4+ messages in thread
From: Jörn Engel @ 2009-07-07 16:25 UTC (permalink / raw)
To: Josh Boyer, linux-mtd
On Tue, 7 July 2009 18:22:32 +0200, Jörn Engel wrote:
>
> +static int get_info(const char *devname, struct mtd_info_user64 *mtd64)
> +static int do_erase(int fd, struct erase_info_user64 *ei64, struct mtd_info_user64 *mtd64)
Thinking about it, these two functions probably ought to go into a
library of some sorts. I just used flash_eraseall as a proof-of-concept
test program, so my interest in this area is exhausted. But maybe
someone else feels young and energetic. :)
Jörn
--
Sometimes, asking the right question is already the answer.
-- Unknown
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch] Support large devices for flash_eraseaal
2009-07-07 16:25 ` Jörn Engel
@ 2009-07-07 16:29 ` Artem Bityutskiy
0 siblings, 0 replies; 4+ messages in thread
From: Artem Bityutskiy @ 2009-07-07 16:29 UTC (permalink / raw)
To: Jörn Engel; +Cc: Josh Boyer, linux-mtd
On Tue, 2009-07-07 at 18:25 +0200, Jörn Engel wrote:
> On Tue, 7 July 2009 18:22:32 +0200, Jörn Engel wrote:
> >
> > +static int get_info(const char *devname, struct mtd_info_user64 *mtd64)
> > +static int do_erase(int fd, struct erase_info_user64 *ei64, struct mtd_info_user64 *mtd64)
>
> Thinking about it, these two functions probably ought to go into a
> library of some sorts. I just used flash_eraseall as a proof-of-concept
> test program, so my interest in this area is exhausted. But maybe
> someone else feels young and energetic. :)
In ubi-utils I created libmtd library. It can be used in other
places as well.
--
Best regards,
Artem Bityutskiy (Битюцкий Артём)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-07-07 16:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-07 14:03 mtd-utils warnings Jörn Engel
2009-07-07 16:22 ` [Patch] Support large devices for flash_eraseaal Jörn Engel
2009-07-07 16:25 ` Jörn Engel
2009-07-07 16:29 ` Artem Bityutskiy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox