14 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
16 #include <linux/kernel.h>
17 #include <linux/slab.h>
21 #include <linux/compiler.h>
33 JFFS2_WARNING(
"Can't allocate memory for summary information!\n");
40 JFFS2_WARNING(
"Can't allocate buffer for writing out summary information!\n");
84 #ifdef CONFIG_JFFS2_FS_XATTR
88 dbg_summary(
"xattr (xid=%u, version=%u) added to summary\n",
157 #ifdef CONFIG_JFFS2_FS_XATTR
193 static void jffs2_sum_clean_collected(
struct jffs2_summary *s)
213 jffs2_sum_clean_collected(s);
220 jffs2_sum_clean_collected(s);
233 dbg_summary(
"oldsize=0x%x oldnum=%u => newsize=0x%x newnum=%u\n",
255 dbg_summary(
"Summary is disabled for this jeb! Skipping summary info!\n");
272 temp->
inode = node->
i.ino;
291 temp->
pino = node->
d.pino;
293 temp->
ino = node->
d.ino;
294 temp->
nsize = node->
d.nsize;
295 temp->
type = node->
d.type;
314 #ifdef CONFIG_JFFS2_FS_XATTR
322 temp->
xid = node->
x.xid;
447 pr_err(
"Dirent at %08x has zero at start of name. Aborting mount.\n",
452 if (checkedlen < spd->
nsize) {
453 pr_err(
"Dirent at %08x has zeroes in name. Truncating to %d chars\n",
465 fd->
name[checkedlen] = 0;
490 #ifdef CONFIG_JFFS2_FS_XATTR
496 dbg_summary(
"xattr at %#08x-%#08x (xid=%u, version=%u)\n",
532 ref = jffs2_alloc_xattr_ref();
537 ref->
next = c->xref_temp;
543 *pseudo_random += ref->
node->flash_offset;
551 JFFS2_WARNING(
"Unsupported node type %x found in summary! Exiting...\n", nodetype);
582 dbg_summary(
"summary found for 0x%08x at 0x%08x (0x%x bytes)\n",
589 crc =
crc32(0, &crcnode,
sizeof(crcnode)-4);
592 dbg_summary(
"Summary node header is corrupt (bad CRC or "
593 "no summary at all)\n");
598 dbg_summary(
"Summary node is corrupt (wrong erasesize?)\n");
605 dbg_summary(
"Summary node is corrupt (bad CRC)\n");
612 dbg_summary(
"Summary node data is corrupt (bad CRC)\n");
625 dbg_summary(
"CLEANMARKER node has totlen 0x%x != normal 0x%x\n",
630 dbg_summary(
"CLEANMARKER node not first node in block "
631 "(0x%08x)\n", jeb->
offset);
640 ret = jffs2_sum_process_sum_data(c, jeb, summary, pseudo_random);
656 JFFS2_WARNING(
"Free size 0x%x bytes in eraseblock @0x%08x with summary?\n",
667 JFFS2_WARNING(
"Summary node crc error, skipping summary information.\n");
690 JFFS2_WARNING(
"Summary too big (%d data, %d pad) in eraseblock at %08x\n",
691 datasize, padsize, jeb->
offset);
700 JFFS2_WARNING(
"Not enough space for summary, padsize = %d\n",
707 memset(&isum, 0,
sizeof(isum));
719 temp = c->
summary->sum_list_head;
726 sino_ptr->
inode = temp->
i.inode;
727 sino_ptr->
version = temp->
i.version;
728 sino_ptr->
offset = temp->
i.offset;
729 sino_ptr->
totlen = temp->
i.totlen;
740 sdrnt_ptr->
totlen = temp->
d.totlen;
741 sdrnt_ptr->
offset = temp->
d.offset;
742 sdrnt_ptr->
pino = temp->
d.pino;
743 sdrnt_ptr->
version = temp->
d.version;
744 sdrnt_ptr->
ino = temp->
d.ino;
745 sdrnt_ptr->
nsize = temp->
d.nsize;
746 sdrnt_ptr->
type = temp->
d.type;
755 #ifdef CONFIG_JFFS2_FS_XATTR
759 temp = c->
summary->sum_list_head;
761 sxattr_ptr->
xid = temp->
x.xid;
762 sxattr_ptr->
version = temp->
x.version;
763 sxattr_ptr->
offset = temp->
x.offset;
764 sxattr_ptr->
totlen = temp->
x.totlen;
772 temp = c->
summary->sum_list_head;
774 sxref_ptr->
offset = temp->
r.offset;
783 dbg_summary(
"Writing unknown RWCOMPAT_COPY node type %x\n",
792 c->
summary->sum_list_head = temp->
u.next;
809 vecs[0].iov_base = &isum;
810 vecs[0].iov_len =
sizeof(isum);
811 vecs[1].iov_base = c->
summary->sum_buf;
812 vecs[1].iov_len = datasize;
816 dbg_summary(
"writing out data to flash to pos : 0x%08x\n", sum_ofs);
820 if (ret || (retlen != infosize)) {
822 JFFS2_WARNING(
"Write of %u bytes at 0x%08x failed. returned %d, retlen %zd\n",
823 infosize, sum_ofs, ret, retlen);
848 int datasize, infosize,
padsize;
870 ret = jffs2_sum_write_data(c, jeb, infosize, datasize, padsize);