]> www.infradead.org Git - mtd-utils.git/commitdiff
rename crc32 to mtd_crc32
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Wed, 1 Sep 2010 11:10:21 +0000 (14:10 +0300)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Wed, 1 Sep 2010 11:31:52 +0000 (14:31 +0300)
Because of namespace collisions mkfs.ubifs uses crc32() implementation from
/lib/libz.so.1, which generates incompatible CRC and later on the kernel reports
many CRC errors.

Fix this by re-naming mtd-utils' crc32 function to mtd_crc32.

Reported-by: Jon Povey <Jon.Povey@racelogic.co.uk>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
12 files changed:
flash_eraseall.c
include/crc32.h
jffs2dump.c
lib/libcrc32.c
mkfs.ubifs/mkfs.ubifs.c
recv_image.c
serve_image.c
sumtool.c
ubi-utils/src/libscan.c
ubi-utils/src/libubigen.c
ubi-utils/src/ubicrc32.c
ubi-utils/src/ubiformat.c

index 5740719b8a8e6264da65ac17275925d4ca56cdb8..cb6f632d810b7c636d0555e8be865f137e213a04 100644 (file)
@@ -210,7 +210,7 @@ int main (int argc, char *argv[])
                        }
                        cleanmarker.totlen = cpu_to_je32(8);
                }
-               cleanmarker.hdr_crc =  cpu_to_je32 (crc32 (0, &cleanmarker,  sizeof (struct jffs2_unknown_node) - 4));
+               cleanmarker.hdr_crc =  cpu_to_je32 (mtd_crc32 (0, &cleanmarker,  sizeof (struct jffs2_unknown_node) - 4));
        }
 
        for (eb = 0; eb < (mtd.size / mtd.eb_size); eb++) {
index affa303fe94461d7aaf8c3ec5a67003f48cefd35..9c1f742c6229a272bf4d92dd0ca1f1d7d088b9ef 100644 (file)
@@ -8,6 +8,6 @@
 #include <stdint.h>
 
 /* Return a 32-bit CRC of the contents of the buffer */
-extern uint32_t crc32(uint32_t val, const void *ss, int len);
+extern uint32_t mtd_crc32(uint32_t val, const void *ss, int len);
 
 #endif /* __CRC32_H__ */
index 500ee58a8a338fbf84afb44a04c8b5283db09b05..d282d9d6e0965792fff3e060f0f283fd9fe298b5 100644 (file)
@@ -219,7 +219,7 @@ void do_dumpcontent (void)
                /* Set accurate for CRC check */
                node->u.nodetype = cpu_to_je16(type);
 
-               crc = crc32 (0, node, sizeof (struct jffs2_unknown_node) - 4);
+               crc = mtd_crc32 (0, node, sizeof (struct jffs2_unknown_node) - 4);
                if (crc != je32_to_cpu (node->u.hdr_crc)) {
                        printf ("Wrong hdr_crc  at  0x%08zx, 0x%08x instead of 0x%08x\n", p - data, je32_to_cpu (node->u.hdr_crc), crc);
                        p += 4;
@@ -236,7 +236,7 @@ void do_dumpcontent (void)
                                                je32_to_cpu ( node->i.version), je32_to_cpu (node->i.isize),
                                                je32_to_cpu (node->i.csize), je32_to_cpu (node->i.dsize), je32_to_cpu (node->i.offset));
 
-                               crc = crc32 (0, node, sizeof (struct jffs2_raw_inode) - 8);
+                               crc = mtd_crc32 (0, node, sizeof (struct jffs2_raw_inode) - 8);
                                if (crc != je32_to_cpu (node->i.node_crc)) {
                                        printf ("Wrong node_crc at  0x%08zx, 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));
@@ -244,7 +244,7 @@ void do_dumpcontent (void)
                                        continue;
                                }
 
-                               crc = crc32(0, p + sizeof (struct jffs2_raw_inode), je32_to_cpu(node->i.csize));
+                               crc = mtd_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%08zx, 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));
@@ -264,7 +264,7 @@ void do_dumpcontent (void)
                                                je32_to_cpu ( node->d.version), je32_to_cpu (node->d.ino),
                                                node->d.nsize, name);
 
-                               crc = crc32 (0, node, sizeof (struct jffs2_raw_dirent) - 8);
+                               crc = mtd_crc32 (0, node, sizeof (struct jffs2_raw_dirent) - 8);
                                if (crc != je32_to_cpu (node->d.node_crc)) {
                                        printf ("Wrong node_crc at  0x%08zx, 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));
@@ -272,7 +272,7 @@ void do_dumpcontent (void)
                                        continue;
                                }
 
-                               crc = crc32(0, p + sizeof (struct jffs2_raw_dirent), node->d.nsize);
+                               crc = mtd_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%08zx, 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));
@@ -295,7 +295,7 @@ void do_dumpcontent (void)
                                                                                                         je32_to_cpu (node->s.sum_num),
                                                                                                         je32_to_cpu (node->s.cln_mkr));
 
-                                                                                        crc = crc32 (0, node, sizeof (struct jffs2_raw_summary) - 8);
+                                                                                        crc = mtd_crc32 (0, node, sizeof (struct jffs2_raw_summary) - 8);
                                                                                         if (crc != je32_to_cpu (node->s.node_crc)) {
                                                                                                 printf ("Wrong node_crc at  0x%08zx, 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));
@@ -303,7 +303,7 @@ void do_dumpcontent (void)
                                                                                                 continue;
                                                                                         }
 
-                                                                                        crc = crc32(0, p + sizeof (struct jffs2_raw_summary),  je32_to_cpu (node->s.totlen) - sizeof(struct jffs2_raw_summary));
+                                                                                        crc = mtd_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%08zx, 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));
@@ -451,7 +451,7 @@ void do_endianconvert (void)
                        continue;
                }
 
-               crc = crc32 (0, node, sizeof (struct jffs2_unknown_node) - 4);
+               crc = mtd_crc32 (0, node, sizeof (struct jffs2_unknown_node) - 4);
                if (crc != je32_to_cpu (node->u.hdr_crc)) {
                        printf ("Wrong hdr_crc  at  0x%08zx, 0x%08x instead of 0x%08x\n", p - data, je32_to_cpu (node->u.hdr_crc), crc);
                }
@@ -463,7 +463,7 @@ void do_endianconvert (void)
                                newnode.i.magic = cnv_e16 (node->i.magic);
                                newnode.i.nodetype = cnv_e16 (node->i.nodetype);
                                newnode.i.totlen = cnv_e32 (node->i.totlen);
-                               newnode.i.hdr_crc = cpu_to_e32 (crc32 (0, &newnode, sizeof (struct jffs2_unknown_node) - 4));
+                               newnode.i.hdr_crc = cpu_to_e32 (mtd_crc32 (0, &newnode, sizeof (struct jffs2_unknown_node) - 4));
                                newnode.i.ino = cnv_e32 (node->i.ino);
                                newnode.i.version = cnv_e32 (node->i.version);
                                mode.v32 = node->i.mode.m;
@@ -483,11 +483,11 @@ void do_endianconvert (void)
                                newnode.i.flags = cnv_e16 (node->i.flags);
                                if (recalccrc) {
                                        len = je32_to_cpu(node->i.csize);
-                                       newnode.i.data_crc = cpu_to_e32 ( crc32(0, p + sizeof (struct jffs2_raw_inode), len));
+                                       newnode.i.data_crc = cpu_to_e32 ( mtd_crc32(0, p + sizeof (struct jffs2_raw_inode), len));
                                } else
                                        newnode.i.data_crc = cnv_e32 (node->i.data_crc);
 
-                               newnode.i.node_crc = cpu_to_e32 (crc32 (0, &newnode, sizeof (struct jffs2_raw_inode) - 8));
+                               newnode.i.node_crc = cpu_to_e32 (mtd_crc32 (0, &newnode, sizeof (struct jffs2_raw_inode) - 8));
 
                                write (fd, &newnode, sizeof (struct jffs2_raw_inode));
                                write (fd, p + sizeof (struct jffs2_raw_inode), PAD (je32_to_cpu (node->i.totlen) -  sizeof (struct jffs2_raw_inode)));
@@ -499,7 +499,7 @@ void do_endianconvert (void)
                                newnode.d.magic = cnv_e16 (node->d.magic);
                                newnode.d.nodetype = cnv_e16 (node->d.nodetype);
                                newnode.d.totlen = cnv_e32 (node->d.totlen);
-                               newnode.d.hdr_crc = cpu_to_e32 (crc32 (0, &newnode, sizeof (struct jffs2_unknown_node) - 4));
+                               newnode.d.hdr_crc = cpu_to_e32 (mtd_crc32 (0, &newnode, sizeof (struct jffs2_unknown_node) - 4));
                                newnode.d.pino = cnv_e32 (node->d.pino);
                                newnode.d.version = cnv_e32 (node->d.version);
                                newnode.d.ino = cnv_e32 (node->d.ino);
@@ -508,9 +508,9 @@ void do_endianconvert (void)
                                newnode.d.type = node->d.type;
                                newnode.d.unused[0] = node->d.unused[0];
                                newnode.d.unused[1] = node->d.unused[1];
-                               newnode.d.node_crc = cpu_to_e32 (crc32 (0, &newnode, sizeof (struct jffs2_raw_dirent) - 8));
+                               newnode.d.node_crc = cpu_to_e32 (mtd_crc32 (0, &newnode, sizeof (struct jffs2_raw_dirent) - 8));
                                if (recalccrc)
-                                       newnode.d.name_crc = cpu_to_e32 ( crc32(0, p + sizeof (struct jffs2_raw_dirent), node->d.nsize));
+                                       newnode.d.name_crc = cpu_to_e32 ( mtd_crc32(0, p + sizeof (struct jffs2_raw_dirent), node->d.nsize));
                                else
                                        newnode.d.name_crc = cnv_e32 (node->d.name_crc);
 
@@ -524,7 +524,7 @@ void do_endianconvert (void)
                                newnode.u.magic = cnv_e16 (node->u.magic);
                                newnode.u.nodetype = cnv_e16 (node->u.nodetype);
                                newnode.u.totlen = cnv_e32 (node->u.totlen);
-                               newnode.u.hdr_crc = cpu_to_e32 (crc32 (0, &newnode, sizeof (struct jffs2_unknown_node) - 4));
+                               newnode.u.hdr_crc = cpu_to_e32 (mtd_crc32 (0, &newnode, sizeof (struct jffs2_unknown_node) - 4));
 
                                write (fd, &newnode, sizeof (struct jffs2_unknown_node));
                                len = PAD(je32_to_cpu (node->u.totlen) - sizeof (struct jffs2_unknown_node));
@@ -542,12 +542,12 @@ void do_endianconvert (void)
                                                                                          newnode.s.magic = cnv_e16 (node->s.magic);
                                                                                          newnode.s.nodetype = cnv_e16 (node->s.nodetype);
                                                                                          newnode.s.totlen = cnv_e32 (node->s.totlen);
-                                                                                         newnode.s.hdr_crc = cpu_to_e32 (crc32 (0, &newnode, sizeof (struct jffs2_unknown_node) - 4));
+                                                                                         newnode.s.hdr_crc = cpu_to_e32 (mtd_crc32 (0, &newnode, sizeof (struct jffs2_unknown_node) - 4));
                                                                                          newnode.s.sum_num = cnv_e32 (node->s.sum_num);
                                                                                          newnode.s.cln_mkr = cnv_e32 (node->s.cln_mkr);
                                                                                          newnode.s.padded = cnv_e32 (node->s.padded);
 
-                                                                                         newnode.s.node_crc = cpu_to_e32 (crc32 (0, &newnode, sizeof (struct jffs2_raw_summary) - 8));
+                                                                                         newnode.s.node_crc = cpu_to_e32 (mtd_crc32 (0, &newnode, sizeof (struct jffs2_raw_summary) - 8));
 
                                                                                          // summary header
                                                                                          p += sizeof (struct jffs2_raw_summary);
@@ -601,7 +601,7 @@ void do_endianconvert (void)
                                                                                          p += sizeof (struct jffs2_sum_marker);
 
                                                                                          // generate new crc on sum data
-                                                                                         newnode.s.sum_crc = cpu_to_e32 ( crc32(0, ((char *) node) + sizeof (struct jffs2_raw_summary),
+                                                                                         newnode.s.sum_crc = cpu_to_e32 ( mtd_crc32(0, ((char *) node) + sizeof (struct jffs2_raw_summary),
                                                                                                                  je32_to_cpu (node->s.totlen) - sizeof (struct jffs2_raw_summary)));
 
                                                                                          // write out new node header
index d47a8426b873f2c104fdeab0659f7822e730280b..90b916c93475355e64dde7b0a3d52a6a6cf63e28 100644 (file)
@@ -94,7 +94,7 @@ static const uint32_t crc32_table[256] = {
        0x2d02ef8dL
 };
 
-uint32_t crc32(uint32_t val, const void *ss, int len)
+uint32_t mtd_crc32(uint32_t val, const void *ss, int len)
 {
        const unsigned char *s = ss;
 
index b3dd9bb6d8cf3e5ff41d13e2a72edbb9aee2bd7a..9f2a226f2b97a3a892db798b6e886a25cad980cd 100644 (file)
@@ -753,7 +753,7 @@ static void prepare_node(void *node, int len)
        ch->group_type = UBIFS_NO_NODE_GROUP;
        ch->sqnum = cpu_to_le64(++c->max_sqnum);
        ch->padding[0] = ch->padding[1] = 0;
-       crc = crc32(UBIFS_CRC32_INIT, node + 8, len - 8);
+       crc = mtd_crc32(UBIFS_CRC32_INIT, node + 8, len - 8);
        ch->crc = cpu_to_le32(crc);
 }
 
@@ -823,7 +823,7 @@ static int do_pad(void *buf, int len)
                pad_len -= UBIFS_PAD_NODE_SZ;
                pad_node->pad_len = cpu_to_le32(pad_len);
 
-               crc = crc32(UBIFS_CRC32_INIT, buf + 8,
+               crc = mtd_crc32(UBIFS_CRC32_INIT, buf + 8,
                                  UBIFS_PAD_NODE_SZ - 8);
                ch->crc = cpu_to_le32(crc);
 
index 60b24b371e1bb13706c50013655561dada930426..617711c3c0fd5180b47d5f0905e6656d6e0ed213 100644 (file)
@@ -244,10 +244,10 @@ int main(int argc, char **argv)
                        continue;
                }
 
-               if (crc32(-1, thispkt.data, PKT_SIZE) != ntohl(thispkt.hdr.thiscrc)) {
+               if (mtd_crc32(-1, thispkt.data, PKT_SIZE) != ntohl(thispkt.hdr.thiscrc)) {
                        printf("\nDiscard %08x pkt %d with bad CRC (%08x not %08x)\n",
                               block_nr * meminfo.erasesize, ntohs(thispkt.hdr.pkt_nr),
-                              crc32(-1, thispkt.data, PKT_SIZE),
+                              mtd_crc32(-1, thispkt.data, PKT_SIZE),
                               ntohl(thispkt.hdr.thiscrc));
                        badcrcs++;
                        continue;
@@ -393,10 +393,10 @@ int main(int argc, char **argv)
 
                /* Paranoia */
                gettimeofday(&start, NULL);
-               if (crc32(-1, decode_buf, meminfo.erasesize) != eraseblocks[block_nr].crc) {
+               if (mtd_crc32(-1, decode_buf, meminfo.erasesize) != eraseblocks[block_nr].crc) {
                        printf("\nCRC mismatch for block #%d: want %08x got %08x\n",
                               block_nr, eraseblocks[block_nr].crc, 
-                              crc32(-1, decode_buf, meminfo.erasesize));
+                              mtd_crc32(-1, decode_buf, meminfo.erasesize));
                        exit(1);
                }
                gettimeofday(&now, NULL);
index 5aafa35ff133d3f4c8d326674ec79f25fac79ac5..4b5dba9f7f85e82f3f5022eea807e5ae640ce72f 100644 (file)
@@ -150,7 +150,7 @@ int main(int argc, char **argv)
        fflush(stdout);
 
        pktbuf.hdr.resend = 0;
-       pktbuf.hdr.totcrc = htonl(crc32(-1, image, st.st_size));
+       pktbuf.hdr.totcrc = htonl(mtd_crc32(-1, image, st.st_size));
        pktbuf.hdr.nr_blocks = htonl(nr_blocks);
        pktbuf.hdr.blocksize = htonl(erasesize);
        pktbuf.hdr.thislen = htonl(PKT_SIZE);
@@ -163,7 +163,7 @@ int main(int argc, char **argv)
                printf("\rChecking block CRCS.... %d/%d",
                       block_nr + 1, nr_blocks);
                fflush(stdout);
-               block_crcs[block_nr] = crc32(-1, image + (block_nr * erasesize), erasesize);
+               block_crcs[block_nr] = mtd_crc32(-1, image + (block_nr * erasesize), erasesize);
        }
                
        printf("\nImage size %ld KiB (0x%08lx). %d blocks at %d pkts/block\n"
@@ -213,7 +213,7 @@ int main(int argc, char **argv)
 
                        fec_encode_linear(fec, blockptr, pktbuf.data, actualpkt, PKT_SIZE);
 
-                       pktbuf.hdr.thiscrc = htonl(crc32(-1, pktbuf.data, PKT_SIZE));
+                       pktbuf.hdr.thiscrc = htonl(mtd_crc32(-1, pktbuf.data, PKT_SIZE));
                        pktbuf.hdr.block_crc = htonl(block_crcs[block_nr]);
                        pktbuf.hdr.block_nr = htonl(block_nr);
                        pktbuf.hdr.pkt_nr = htons(actualpkt);
index e93117782dfde56c590f7b413c191796e571e06a..2e2098c1a7710ba7afb7cc72de5763e08717478e 100644 (file)
--- a/sumtool.c
+++ b/sumtool.c
@@ -168,7 +168,7 @@ void setup_cleanmarker()
        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));
+       cleanmarker.hdr_crc = cpu_to_je32(mtd_crc32(0, &cleanmarker, sizeof(struct jffs2_unknown_node)-4));
 }
 
 void process_options (int argc, char **argv)
@@ -394,7 +394,7 @@ void dump_sum_records()
        isum.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
        isum.nodetype = cpu_to_je16(JFFS2_NODETYPE_SUMMARY);
        isum.totlen = cpu_to_je32(infosize);
-       isum.hdr_crc = cpu_to_je32(crc32(0, &isum, sizeof(struct jffs2_unknown_node) - 4));
+       isum.hdr_crc = cpu_to_je32(mtd_crc32(0, &isum, sizeof(struct jffs2_unknown_node) - 4));
        isum.padded = cpu_to_je32(0);
 
        if (add_cleanmarkers && found_cleanmarkers) {
@@ -486,8 +486,8 @@ void dump_sum_records()
        sm->offset = offset;
        sm->magic = magic;
 
-       isum.sum_crc = cpu_to_je32(crc32(0, tpage, datasize));
-       isum.node_crc = cpu_to_je32(crc32(0, &isum, sizeof(isum) - 8));
+       isum.sum_crc = cpu_to_je32(mtd_crc32(0, tpage, datasize));
+       isum.node_crc = cpu_to_je32(mtd_crc32(0, &isum, sizeof(isum) - 8));
 
        full_write(data_buffer + data_ofs, &isum, sizeof(isum));
        full_write(data_buffer + data_ofs, tpage, datasize);
@@ -757,7 +757,7 @@ void create_summed_image(int inp_size)
 
                node->u.nodetype = cpu_to_je16(type);
 
-               crc = crc32 (0, node, sizeof (struct jffs2_unknown_node) - 4);
+               crc = mtd_crc32 (0, node, sizeof (struct jffs2_unknown_node) - 4);
                if (crc != je32_to_cpu (node->u.hdr_crc)) {
                        printf ("Wrong hdr_crc  at  0x%08zx, 0x%08x instead of 0x%08x\n", p - file_buffer, je32_to_cpu (node->u.hdr_crc), crc);
                        p += 4;
@@ -773,14 +773,14 @@ void create_summed_image(int inp_size)
                                                        je32_to_cpu ( node->i.version), je32_to_cpu (node->i.isize),
                                                        je32_to_cpu (node->i.csize), je32_to_cpu (node->i.dsize), je32_to_cpu (node->i.offset));
 
-                               crc = crc32 (0, node, sizeof (struct jffs2_raw_inode) - 8);
+                               crc = mtd_crc32 (0, node, sizeof (struct jffs2_raw_inode) - 8);
                                if (crc != je32_to_cpu (node->i.node_crc)) {
                                        printf ("Wrong node_crc at  0x%08zx, 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));
+                               crc = mtd_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%08zx, 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));
@@ -803,14 +803,14 @@ void create_summed_image(int inp_size)
                                                        je32_to_cpu ( node->d.version), je32_to_cpu (node->d.ino),
                                                        node->d.nsize, name);
 
-                               crc = crc32 (0, node, sizeof (struct jffs2_raw_dirent) - 8);
+                               crc = mtd_crc32 (0, node, sizeof (struct jffs2_raw_dirent) - 8);
                                if (crc != je32_to_cpu (node->d.node_crc)) {
                                        printf ("Wrong node_crc at  0x%08zx, 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);
+                               crc = mtd_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%08zx, 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));
@@ -831,7 +831,7 @@ void create_summed_image(int inp_size)
                                                        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);
+                               crc = mtd_crc32(0, node, sizeof (struct jffs2_raw_xattr) - 4);
                                if (crc != je32_to_cpu(node->x.node_crc)) {
                                        printf("Wrong node_crc at 0x%08zx, 0x%08x instead of 0x%08x\n",
                                                        p - file_buffer, je32_to_cpu(node->x.node_crc), crc);
@@ -839,7 +839,7 @@ void create_summed_image(int inp_size)
                                        continue;
                                }
                                length = node->x.name_len + 1 + je16_to_cpu(node->x.value_len);
-                               crc = crc32(0, node->x.data, length);
+                               crc = mtd_crc32(0, node->x.data, length);
                                if (crc != je32_to_cpu(node->x.data_crc)) {
                                        printf("Wrong data_crc at 0x%08zx, 0x%08x instead of 0x%08x\n",
                                                        p - file_buffer, je32_to_cpu(node->x.data_crc), crc);
@@ -860,7 +860,7 @@ void create_summed_image(int inp_size)
                                                        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);
+                               crc = mtd_crc32(0, node, sizeof (struct jffs2_raw_xref) - 4);
                                if (crc != je32_to_cpu(node->r.node_crc)) {
                                        printf("Wrong node_crc at 0x%08zx, 0x%08x instead of 0x%08x\n",
                                                        p - file_buffer, je32_to_cpu(node->r.node_crc), crc);
index 85f3d7fad38125ca19e89648caa1ffc13febd014..6c6990f0773f2fe3ab061605471d69527c889d7f 100644 (file)
@@ -116,7 +116,7 @@ int ubi_scan(struct mtd_dev_info *mtd, int fd, struct ubi_scan_info **info,
                        continue;
                }
 
-               crc = crc32(UBI_CRC32_INIT, &ech, UBI_EC_HDR_SIZE_CRC);
+               crc = mtd_crc32(UBI_CRC32_INIT, &ech, UBI_EC_HDR_SIZE_CRC);
                if (be32_to_cpu(ech.hdr_crc) != crc) {
                        si->corrupted_cnt += 1;
                        si->ec[eb] = EB_CORRUPTED;
index 62792d0057536f31c08ef130b7f2861028a83119..710aa974dfea3025b41610d5625abb967bf2327e 100644 (file)
@@ -75,7 +75,7 @@ struct ubi_vtbl_record *ubigen_create_empty_vtbl(const struct ubigen_info *ui)
        }
 
        for (i = 0; i < ui->max_volumes; i++) {
-               uint32_t crc = crc32(UBI_CRC32_INIT, &vtbl[i],
+               uint32_t crc = mtd_crc32(UBI_CRC32_INIT, &vtbl[i],
                                     UBI_VTBL_RECORD_SIZE_CRC);
                vtbl[i].crc = cpu_to_be32(crc);
        }
@@ -117,7 +117,7 @@ int ubigen_add_volume(const struct ubigen_info *ui,
        vtbl_rec->name[vi->name_len] = '\0';
        vtbl_rec->name_len = cpu_to_be16(vi->name_len);
 
-       tmp = crc32(UBI_CRC32_INIT, vtbl_rec, UBI_VTBL_RECORD_SIZE_CRC);
+       tmp = mtd_crc32(UBI_CRC32_INIT, vtbl_rec, UBI_VTBL_RECORD_SIZE_CRC);
        vtbl_rec->crc =  cpu_to_be32(tmp);
        return 0;
 }
@@ -136,7 +136,7 @@ void ubigen_init_ec_hdr(const struct ubigen_info *ui,
        hdr->data_offset = cpu_to_be32(ui->data_offs);
        hdr->image_seq = cpu_to_be32(ui->image_seq);
 
-       crc = crc32(UBI_CRC32_INIT, hdr, UBI_EC_HDR_SIZE_CRC);
+       crc = mtd_crc32(UBI_CRC32_INIT, hdr, UBI_EC_HDR_SIZE_CRC);
        hdr->hdr_crc = cpu_to_be32(crc);
 }
 
@@ -160,11 +160,11 @@ void ubigen_init_vid_hdr(const struct ubigen_info *ui,
        if (vi->type == UBI_VID_STATIC) {
                hdr->data_size = cpu_to_be32(data_size);
                hdr->used_ebs = cpu_to_be32(vi->used_ebs);
-               crc = crc32(UBI_CRC32_INIT, data, data_size);
+               crc = mtd_crc32(UBI_CRC32_INIT, data, data_size);
                hdr->data_crc = cpu_to_be32(crc);
        }
 
-       crc = crc32(UBI_CRC32_INIT, hdr, UBI_VID_HDR_SIZE_CRC);
+       crc = mtd_crc32(UBI_CRC32_INIT, hdr, UBI_VID_HDR_SIZE_CRC);
        hdr->hdr_crc = cpu_to_be32(crc);
 }
 
index 2dd69e1d5e13c0250d8d78eb93687d827a405042..becd6049bcf9dc125b94d22332764391696857c1 100644 (file)
@@ -112,7 +112,7 @@ int main(int argc, char * const argv[])
                        err = -1;
                        goto out_close;
                }
-               crc = crc32(crc, buf, read);
+               crc = mtd_crc32(crc, buf, read);
        }
 
        printf("0x%08x\n", crc);
index 4e27e4f7d34ebb319818e79c604ccd901bf45a98..8559f61a22b6447499707fb7294ce6284644aa92 100644 (file)
@@ -306,14 +306,14 @@ static int change_ech(struct ubi_ec_hdr *hdr, uint32_t image_seq,
                return errmsg("bad UBI magic %#08x, should be %#08x",
                              be32_to_cpu(hdr->magic), UBI_EC_HDR_MAGIC);
 
-       crc = crc32(UBI_CRC32_INIT, hdr, UBI_EC_HDR_SIZE_CRC);
+       crc = mtd_crc32(UBI_CRC32_INIT, hdr, UBI_EC_HDR_SIZE_CRC);
        if (be32_to_cpu(hdr->hdr_crc) != crc)
                return errmsg("bad CRC %#08x, should be %#08x\n",
                              crc, be32_to_cpu(hdr->hdr_crc));
 
        hdr->image_seq = cpu_to_be32(image_seq);
        hdr->ec = cpu_to_be64(ec);
-       crc = crc32(UBI_CRC32_INIT, hdr, UBI_EC_HDR_SIZE_CRC);
+       crc = mtd_crc32(UBI_CRC32_INIT, hdr, UBI_EC_HDR_SIZE_CRC);
        hdr->hdr_crc = cpu_to_be32(crc);
 
        return 0;