if (ref_flags(fn->raw) == REF_PRISTINE) { if (fn->frags > 1) {
JFFS2_ERROR("REF_PRISTINE node at 0x%08x had %d frags. Tell dwmw2.\n",
ref_offset(fn->raw), fn->frags);
bitched = 1;
}
/* A hole node which isn't multi-page should be garbage-collected and merged anyway, so we just check for the frag size here, rather than mucking around with actually reading the node and checking the compression type, which is the real way
to tell a hole node. */ if (frag->ofs & (PAGE_SIZE-1) && frag_prev(frag)
&& frag_prev(frag)->size < PAGE_SIZE && frag_prev(frag)->node) {
JFFS2_ERROR("REF_PRISTINE node at 0x%08x had a previous non-hole frag in the same page. Tell dwmw2.\n",
ref_offset(fn->raw));
bitched = 1;
}
if ((frag->ofs+frag->size) & (PAGE_SIZE-1) && frag_next(frag)
&& frag_next(frag)->size < PAGE_SIZE && frag_next(frag)->node) {
JFFS2_ERROR("REF_PRISTINE node at 0x%08x (%08x-%08x) had a following non-hole frag in the same page. Tell dwmw2.\n",
ref_offset(fn->raw), frag->ofs, frag->ofs+frag->size);
bitched = 1;
}
}
}
if (bitched) {
JFFS2_ERROR("fragtree is corrupted.\n");
__jffs2_dbg_dump_fragtree_nolock(f);
BUG();
}
}
/* * Check if the flash contains all 0xFF before we start writing.
*/ void
__jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c,
uint32_t ofs, int len)
{
size_t retlen; int ret, i; unsignedchar *buf;
buf = kmalloc(len, GFP_KERNEL); if (!buf) return;
ret = jffs2_flash_read(c, ofs, len, &retlen, buf); if (ret || (retlen != len)) {
JFFS2_WARNING("read %d bytes failed or short. ret %d, retlen %zd.\n",
len, ret, retlen);
kfree(buf); return;
}
ret = 0; for (i = 0; i < len; i++) if (buf[i] != 0xff)
ret = 1;
if (ret) {
JFFS2_ERROR("argh, about to write node to %#08x on flash, but there are data already there. The first corrupted byte is at %#08x offset.\n",
ofs, ofs + i);
__jffs2_dbg_dump_buffer(buf, len, ofs);
kfree(buf);
BUG();
}
kfree(buf);
}
staticvoid __jffs2_dbg_superblock_counts(struct jffs2_sb_info *c)
{ struct jffs2_eraseblock *jeb;
uint32_t free = 0, dirty = 0, used = 0, wasted = 0,
erasing = 0, bad = 0, unchecked = 0; int nr_counted = 0; int dump = 0;
if (nr_counted != c->nr_blocks) {
pr_warn("%s counted only 0x%x blocks of 0x%x. Where are the others?\n",
__func__, nr_counted, c->nr_blocks);
dump = 1;
}
if (dump) {
__jffs2_dbg_dump_block_lists_nolock(c);
BUG();
}
}
/* * Check the space accounting and node_ref list correctness for the JFFS2 erasable block 'jeb'.
*/ void
__jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb)
{
spin_lock(&c->erase_completion_lock);
__jffs2_dbg_acct_paranoia_check_nolock(c, jeb);
spin_unlock(&c->erase_completion_lock);
}
if ((!ref_next(ref2)) != (ref2 == jeb->last_node)) {
JFFS2_ERROR("node_ref for node at %#08x (mem %p) has next at %#08x (mem %p), last_node is at %#08x (mem %p).\n",
ref_offset(ref2), ref2, ref_offset(ref_next(ref2)), ref_next(ref2),
ref_offset(jeb->last_node), jeb->last_node); goto error;
}
ref2 = ref_next(ref2);
}
if (my_used_size != jeb->used_size) {
JFFS2_ERROR("Calculated used size %#08x != stored used size %#08x.\n",
my_used_size, jeb->used_size); goto error;
}
#ifdefined(JFFS2_DBG_DUMPS) || defined(JFFS2_DBG_PARANOIA_CHECKS) /* * Dump the node_refs of the 'jeb' JFFS2 eraseblock.
*/ void
__jffs2_dbg_dump_node_refs(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb)
{
spin_lock(&c->erase_completion_lock);
__jffs2_dbg_dump_node_refs_nolock(c, jeb);
spin_unlock(&c->erase_completion_lock);
}
void
__jffs2_dbg_dump_node_refs_nolock(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb)
{ struct jffs2_raw_node_ref *ref; int i = 0;
printk(JFFS2_DBG_MSG_PREFIX " Dump node_refs of the eraseblock %#08x\n", jeb->offset); if (!jeb->first_node) {
printk(JFFS2_DBG_MSG_PREFIX " no nodes in the eraseblock %#08x\n", jeb->offset); return;
}
printk(JFFS2_DBG); for (ref = jeb->first_node; ; ref = ref_next(ref)) {
printk("%#08x", ref_offset(ref)); #ifdef TEST_TOTLEN
printk("(%x)", ref->__totlen); #endif if (ref_next(ref))
printk("->"); else break; if (++i == 4) {
i = 0;
printk("\n" JFFS2_DBG);
}
}
printk("\n");
}
/* * Dump an eraseblock's space accounting.
*/ void
__jffs2_dbg_dump_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb)
{
spin_lock(&c->erase_completion_lock);
__jffs2_dbg_dump_jeb_nolock(jeb);
spin_unlock(&c->erase_completion_lock);
}
void
__jffs2_dbg_dump_jeb_nolock(struct jffs2_eraseblock *jeb)
{ if (!jeb) return;
printk(JFFS2_DBG_MSG_PREFIX " dump space accounting for the eraseblock at %#08x:\n",
jeb->offset);
printk(JFFS2_DBG_MSG_PREFIX " dump fragtree of ino #%u\n", f->inocache->ino); while(this) { if (this->node)
printk(JFFS2_DBG "frag %#04x-%#04x: %#08x(%d) on flash (*%p), left (%p), right (%p), parent (%p)\n",
this->ofs, this->ofs+this->size, ref_offset(this->node->raw),
ref_flags(this->node->raw), this, frag_left(this), frag_right(this),
frag_parent(this)); else
printk(JFFS2_DBG "frag %#04x-%#04x: hole (*%p). left (%p), right (%p), parent (%p)\n",
this->ofs, this->ofs+this->size, this, frag_left(this),
frag_right(this), frag_parent(this)); if (this->ofs != lastofs)
buggy = 1;
lastofs = this->ofs + this->size; this = frag_next(this);
}
if (f->metadata)
printk(JFFS2_DBG "metadata at 0x%08x\n", ref_offset(f->metadata->raw));
if (buggy) {
JFFS2_ERROR("frag tree got a hole in it.\n");
BUG();
}
}
#define JFFS2_BUFDUMP_BYTES_PER_LINE 32 void
__jffs2_dbg_dump_buffer(unsignedchar *buf, int len, uint32_t offs)
{ int skip; int i;
printk(JFFS2_DBG_MSG_PREFIX " dump from offset %#08x to offset %#08x (%x bytes).\n",
offs, offs + len, len);
i = skip = offs % JFFS2_BUFDUMP_BYTES_PER_LINE;
offs = offs & ~(JFFS2_BUFDUMP_BYTES_PER_LINE - 1);
if (skip != 0)
printk(JFFS2_DBG "%#08x: ", offs);
while (skip--)
printk(" ");
while (i < len) { if ((i % JFFS2_BUFDUMP_BYTES_PER_LINE) == 0 && i != len -1) { if (i != 0)
printk("\n");
offs += JFFS2_BUFDUMP_BYTES_PER_LINE;
printk(JFFS2_DBG "%0#8x: ", offs);
}
printk("%02x ", buf[i]);
i += 1;
}
printk("\n");
}
/* * Dump a JFFS2 node.
*/ void
__jffs2_dbg_dump_node(struct jffs2_sb_info *c, uint32_t ofs)
{ union jffs2_node_union node; int len = sizeof(union jffs2_node_union);
size_t retlen;
uint32_t crc; int ret;
printk(JFFS2_DBG_MSG_PREFIX " dump node at offset %#08x.\n", ofs);
ret = jffs2_flash_read(c, ofs, len, &retlen, (unsignedchar *)&node); if (ret || (retlen != len)) {
JFFS2_ERROR("read %d bytes failed or short. ret %d, retlen %zd.\n",
len, ret, retlen); return;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.