From 8ab9e98ce27487c40289664d6cb1a58f963679cb Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Wed, 1 Sep 2010 14:10:21 +0300 Subject: rename crc32 to mtd_crc32 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 Signed-off-by: Artem Bityutskiy --- flash_eraseall.c | 2 +- include/crc32.h | 2 +- jffs2dump.c | 36 ++++++++++++++++++------------------ lib/libcrc32.c | 2 +- mkfs.ubifs/mkfs.ubifs.c | 4 ++-- recv_image.c | 8 ++++---- serve_image.c | 6 +++--- sumtool.c | 24 ++++++++++++------------ ubi-utils/src/libscan.c | 2 +- ubi-utils/src/libubigen.c | 10 +++++----- ubi-utils/src/ubicrc32.c | 2 +- ubi-utils/src/ubiformat.c | 4 ++-- 12 files changed, 51 insertions(+), 51 deletions(-) diff --git a/flash_eraseall.c b/flash_eraseall.c index 5740719..cb6f632 100644 --- a/flash_eraseall.c +++ b/flash_eraseall.c @@ -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++) { diff --git a/include/crc32.h b/include/crc32.h index affa303..9c1f742 100644 --- a/include/crc32.h +++ b/include/crc32.h @@ -8,6 +8,6 @@ #include /* 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__ */ diff --git a/jffs2dump.c b/jffs2dump.c index 500ee58..d282d9d 100644 --- a/jffs2dump.c +++ b/jffs2dump.c @@ -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 diff --git a/lib/libcrc32.c b/lib/libcrc32.c index d47a842..90b916c 100644 --- a/lib/libcrc32.c +++ b/lib/libcrc32.c @@ -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; diff --git a/mkfs.ubifs/mkfs.ubifs.c b/mkfs.ubifs/mkfs.ubifs.c index b3dd9bb..9f2a226 100644 --- a/mkfs.ubifs/mkfs.ubifs.c +++ b/mkfs.ubifs/mkfs.ubifs.c @@ -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); diff --git a/recv_image.c b/recv_image.c index 60b24b3..617711c 100644 --- a/recv_image.c +++ b/recv_image.c @@ -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); diff --git a/serve_image.c b/serve_image.c index 5aafa35..4b5dba9 100644 --- a/serve_image.c +++ b/serve_image.c @@ -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); diff --git a/sumtool.c b/sumtool.c index e931177..2e2098c 100644 --- 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); diff --git a/ubi-utils/src/libscan.c b/ubi-utils/src/libscan.c index 85f3d7f..6c6990f 100644 --- a/ubi-utils/src/libscan.c +++ b/ubi-utils/src/libscan.c @@ -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; diff --git a/ubi-utils/src/libubigen.c b/ubi-utils/src/libubigen.c index 62792d0..710aa97 100644 --- a/ubi-utils/src/libubigen.c +++ b/ubi-utils/src/libubigen.c @@ -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); } diff --git a/ubi-utils/src/ubicrc32.c b/ubi-utils/src/ubicrc32.c index 2dd69e1..becd604 100644 --- a/ubi-utils/src/ubicrc32.c +++ b/ubi-utils/src/ubicrc32.c @@ -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); diff --git a/ubi-utils/src/ubiformat.c b/ubi-utils/src/ubiformat.c index 4e27e4f..8559f61 100644 --- a/ubi-utils/src/ubiformat.c +++ b/ubi-utils/src/ubiformat.c @@ -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; -- cgit v1.2.3