diff options
author | Artem B. Bityutskiy <dedekind@infradead.org> | 2005-07-24 11:14:17 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@mtd.linutronix.de> | 2005-11-06 11:06:49 -0500 |
commit | e0c8e42f8f218063ff6838b25038ccef7ddf257e (patch) | |
tree | a072b5cfd6b9af41dfef13821383af584d989ca6 /fs/jffs2/debug.c | |
parent | 6dac02a5e1bba0bb88ece50160fc4a64cccf30d1 (diff) |
[JFFS2] Debug code clean up - step 3
Various simplifiactions. printk format corrections.
Convert more code to use the new debug functions.
Signed-off-by: Artem B. Bityutskiy <dedekind@infradead.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'fs/jffs2/debug.c')
-rw-r--r-- | fs/jffs2/debug.c | 526 |
1 files changed, 370 insertions, 156 deletions
diff --git a/fs/jffs2/debug.c b/fs/jffs2/debug.c index 9da524ca4e66..fb88eb19711b 100644 --- a/fs/jffs2/debug.c +++ b/fs/jffs2/debug.c | |||
@@ -7,18 +7,30 @@ | |||
7 | * | 7 | * |
8 | * For licensing information, see the file 'LICENCE' in this directory. | 8 | * For licensing information, see the file 'LICENCE' in this directory. |
9 | * | 9 | * |
10 | * $Id: debug.c,v 1.1 2005/07/17 06:56:20 dedekind Exp $ | 10 | * $Id: debug.c,v 1.7 2005/07/24 15:14:14 dedekind Exp $ |
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
14 | #include <linux/pagemap.h> | 14 | #include <linux/pagemap.h> |
15 | #include <linux/crc32.h> | ||
16 | #include <linux/jffs2.h> | ||
15 | #include "nodelist.h" | 17 | #include "nodelist.h" |
16 | #include "debug.h" | 18 | #include "debug.h" |
17 | 19 | ||
18 | #ifdef JFFS2_DBG_PARANOIA_CHECKS | 20 | #ifdef JFFS2_DBG_PARANOIA_CHECKS |
19 | 21 | /* | |
22 | * Check the fragtree. | ||
23 | */ | ||
20 | void | 24 | void |
21 | jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f) | 25 | __jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f) |
26 | { | ||
27 | down(&f->sem); | ||
28 | __jffs2_dbg_fragtree_paranoia_check_nolock(f); | ||
29 | up(&f->sem); | ||
30 | } | ||
31 | |||
32 | void | ||
33 | __jffs2_dbg_fragtree_paranoia_check_nolock(struct jffs2_inode_info *f) | ||
22 | { | 34 | { |
23 | struct jffs2_node_frag *frag; | 35 | struct jffs2_node_frag *frag; |
24 | int bitched = 0; | 36 | int bitched = 0; |
@@ -31,7 +43,7 @@ jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f) | |||
31 | 43 | ||
32 | if (ref_flags(fn->raw) == REF_PRISTINE) { | 44 | if (ref_flags(fn->raw) == REF_PRISTINE) { |
33 | if (fn->frags > 1) { | 45 | if (fn->frags > 1) { |
34 | printk(KERN_ERR "REF_PRISTINE node at 0x%08x had %d frags. Tell dwmw2\n", | 46 | JFFS2_ERROR("REF_PRISTINE node at 0x%08x had %d frags. Tell dwmw2.\n", |
35 | ref_offset(fn->raw), fn->frags); | 47 | ref_offset(fn->raw), fn->frags); |
36 | bitched = 1; | 48 | bitched = 1; |
37 | } | 49 | } |
@@ -43,15 +55,15 @@ jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f) | |||
43 | to tell a hole node. */ | 55 | to tell a hole node. */ |
44 | if (frag->ofs & (PAGE_CACHE_SIZE-1) && frag_prev(frag) | 56 | if (frag->ofs & (PAGE_CACHE_SIZE-1) && frag_prev(frag) |
45 | && frag_prev(frag)->size < PAGE_CACHE_SIZE && frag_prev(frag)->node) { | 57 | && frag_prev(frag)->size < PAGE_CACHE_SIZE && frag_prev(frag)->node) { |
46 | printk(KERN_ERR "REF_PRISTINE node at 0x%08x had a previous non-hole frag " | 58 | JFFS2_ERROR("REF_PRISTINE node at 0x%08x had a previous non-hole frag " |
47 | "in the same page. Tell dwmw2\n", ref_offset(fn->raw)); | 59 | "in the same page. Tell dwmw2.\n", ref_offset(fn->raw)); |
48 | bitched = 1; | 60 | bitched = 1; |
49 | } | 61 | } |
50 | 62 | ||
51 | if ((frag->ofs+frag->size) & (PAGE_CACHE_SIZE-1) && frag_next(frag) | 63 | if ((frag->ofs+frag->size) & (PAGE_CACHE_SIZE-1) && frag_next(frag) |
52 | && frag_next(frag)->size < PAGE_CACHE_SIZE && frag_next(frag)->node) { | 64 | && frag_next(frag)->size < PAGE_CACHE_SIZE && frag_next(frag)->node) { |
53 | printk(KERN_ERR "REF_PRISTINE node at 0x%08x (%08x-%08x) had a following " | 65 | JFFS2_ERROR("REF_PRISTINE node at 0x%08x (%08x-%08x) had a following " |
54 | "non-hole frag in the same page. Tell dwmw2\n", | 66 | "non-hole frag in the same page. Tell dwmw2.\n", |
55 | ref_offset(fn->raw), frag->ofs, frag->ofs+frag->size); | 67 | ref_offset(fn->raw), frag->ofs, frag->ofs+frag->size); |
56 | bitched = 1; | 68 | bitched = 1; |
57 | } | 69 | } |
@@ -59,8 +71,8 @@ jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f) | |||
59 | } | 71 | } |
60 | 72 | ||
61 | if (bitched) { | 73 | if (bitched) { |
62 | printk(KERN_ERR "Fragtree is corrupted. Fragtree dump:\n"); | 74 | JFFS2_ERROR("fragtree is corrupted.\n"); |
63 | jffs2_dbg_dump_fragtree(f); | 75 | __jffs2_dbg_dump_fragtree_nolock(f); |
64 | BUG(); | 76 | BUG(); |
65 | } | 77 | } |
66 | } | 78 | } |
@@ -69,7 +81,8 @@ jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f) | |||
69 | * Check if the flash contains all 0xFF before we start writing. | 81 | * Check if the flash contains all 0xFF before we start writing. |
70 | */ | 82 | */ |
71 | void | 83 | void |
72 | jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c, uint32_t ofs, int len) | 84 | __jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c, |
85 | uint32_t ofs, int len) | ||
73 | { | 86 | { |
74 | size_t retlen; | 87 | size_t retlen; |
75 | int ret, i; | 88 | int ret, i; |
@@ -81,8 +94,8 @@ jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c, uint32_t ofs, int len | |||
81 | 94 | ||
82 | ret = jffs2_flash_read(c, ofs, len, &retlen, buf); | 95 | ret = jffs2_flash_read(c, ofs, len, &retlen, buf); |
83 | if (ret || (retlen != len)) { | 96 | if (ret || (retlen != len)) { |
84 | printk(KERN_WARNING "read %d bytes failed or short in %s(). ret %d, retlen %zd\n", | 97 | JFFS2_WARNING("read %d bytes failed or short. ret %d, retlen %zd.\n", |
85 | len, __FUNCTION__, ret, retlen); | 98 | len, ret, retlen); |
86 | kfree(buf); | 99 | kfree(buf); |
87 | return; | 100 | return; |
88 | } | 101 | } |
@@ -93,9 +106,9 @@ jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c, uint32_t ofs, int len | |||
93 | ret = 1; | 106 | ret = 1; |
94 | 107 | ||
95 | if (ret) { | 108 | if (ret) { |
96 | printk(KERN_ERR "ARGH. About to write node to %#08x on flash, but there are data " | 109 | JFFS2_ERROR("argh, about to write node to %#08x on flash, but there are data " |
97 | "already there. The first corrupted byte is at %#08x.\n", ofs, ofs + i); | 110 | "already there. The first corrupted byte is at %#08x offset.\n", ofs, ofs + i); |
98 | jffs2_dbg_dump_buffer(buf, len, ofs); | 111 | __jffs2_dbg_dump_buffer(buf, len, ofs); |
99 | kfree(buf); | 112 | kfree(buf); |
100 | BUG(); | 113 | BUG(); |
101 | } | 114 | } |
@@ -107,7 +120,17 @@ jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c, uint32_t ofs, int len | |||
107 | * Check the space accounting and node_ref list correctness for the JFFS2 erasable block 'jeb'. | 120 | * Check the space accounting and node_ref list correctness for the JFFS2 erasable block 'jeb'. |
108 | */ | 121 | */ |
109 | void | 122 | void |
110 | jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb) | 123 | __jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c, |
124 | struct jffs2_eraseblock *jeb) | ||
125 | { | ||
126 | spin_lock(&c->erase_completion_lock); | ||
127 | __jffs2_dbg_acct_paranoia_check_nolock(c, jeb); | ||
128 | spin_unlock(&c->erase_completion_lock); | ||
129 | } | ||
130 | |||
131 | void | ||
132 | __jffs2_dbg_acct_paranoia_check_nolock(struct jffs2_sb_info *c, | ||
133 | struct jffs2_eraseblock *jeb) | ||
111 | { | 134 | { |
112 | uint32_t my_used_size = 0; | 135 | uint32_t my_used_size = 0; |
113 | uint32_t my_unchecked_size = 0; | 136 | uint32_t my_unchecked_size = 0; |
@@ -119,11 +142,9 @@ jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c, struct jffs2_eraseblock * | |||
119 | 142 | ||
120 | if (ref2->flash_offset < jeb->offset || | 143 | if (ref2->flash_offset < jeb->offset || |
121 | ref2->flash_offset > jeb->offset + c->sector_size) { | 144 | ref2->flash_offset > jeb->offset + c->sector_size) { |
122 | printk(KERN_ERR "node_ref %#08x shouldn't be in block at %#08x!\n", | 145 | JFFS2_ERROR("node_ref %#08x shouldn't be in block at %#08x.\n", |
123 | ref_offset(ref2), jeb->offset); | 146 | ref_offset(ref2), jeb->offset); |
124 | jffs2_dbg_dump_node_refs(c, jeb); | 147 | goto error; |
125 | jffs2_dbg_dump_block_lists(c); | ||
126 | BUG(); | ||
127 | 148 | ||
128 | } | 149 | } |
129 | if (ref_flags(ref2) == REF_UNCHECKED) | 150 | if (ref_flags(ref2) == REF_UNCHECKED) |
@@ -134,69 +155,82 @@ jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c, struct jffs2_eraseblock * | |||
134 | my_dirty_size += totlen; | 155 | my_dirty_size += totlen; |
135 | 156 | ||
136 | if ((!ref2->next_phys) != (ref2 == jeb->last_node)) { | 157 | if ((!ref2->next_phys) != (ref2 == jeb->last_node)) { |
137 | printk(KERN_ERR "node_ref for node at %#08x (mem %p) has next_phys at %#08x (mem %p), " | 158 | JFFS2_ERROR("node_ref for node at %#08x (mem %p) has next_phys at %#08x (mem %p), " |
138 | "last_node is at %#08x (mem %p)\n", | 159 | "last_node is at %#08x (mem %p).\n", |
139 | ref_offset(ref2), ref2, ref_offset(ref2->next_phys), ref2->next_phys, | 160 | ref_offset(ref2), ref2, ref_offset(ref2->next_phys), ref2->next_phys, |
140 | ref_offset(jeb->last_node), jeb->last_node); | 161 | ref_offset(jeb->last_node), jeb->last_node); |
141 | jffs2_dbg_dump_node_refs(c, jeb); | 162 | goto error; |
142 | jffs2_dbg_dump_block_lists(c); | ||
143 | BUG(); | ||
144 | } | 163 | } |
145 | ref2 = ref2->next_phys; | 164 | ref2 = ref2->next_phys; |
146 | } | 165 | } |
147 | 166 | ||
148 | if (my_used_size != jeb->used_size) { | 167 | if (my_used_size != jeb->used_size) { |
149 | printk(KERN_ERR "Calculated used size %#08x != stored used size %#08x\n", | 168 | JFFS2_ERROR("Calculated used size %#08x != stored used size %#08x.\n", |
150 | my_used_size, jeb->used_size); | 169 | my_used_size, jeb->used_size); |
151 | jffs2_dbg_dump_node_refs(c, jeb); | 170 | goto error; |
152 | jffs2_dbg_dump_block_lists(c); | ||
153 | BUG(); | ||
154 | } | 171 | } |
155 | 172 | ||
156 | if (my_unchecked_size != jeb->unchecked_size) { | 173 | if (my_unchecked_size != jeb->unchecked_size) { |
157 | printk(KERN_ERR "Calculated unchecked size %#08x != stored unchecked size %#08x\n", | 174 | JFFS2_ERROR("Calculated unchecked size %#08x != stored unchecked size %#08x.\n", |
158 | my_unchecked_size, jeb->unchecked_size); | 175 | my_unchecked_size, jeb->unchecked_size); |
159 | jffs2_dbg_dump_node_refs(c, jeb); | 176 | goto error; |
160 | jffs2_dbg_dump_block_lists(c); | ||
161 | BUG(); | ||
162 | } | 177 | } |
163 | 178 | ||
179 | #if 0 | ||
180 | /* This should work when we implement ref->__totlen elemination */ | ||
164 | if (my_dirty_size != jeb->dirty_size + jeb->wasted_size) { | 181 | if (my_dirty_size != jeb->dirty_size + jeb->wasted_size) { |
165 | printk(KERN_ERR "Calculated dirty+wasted size %#08x != stored dirty + wasted size %#08x\n", | 182 | JFFS2_ERROR("Calculated dirty+wasted size %#08x != stored dirty + wasted size %#08x\n", |
166 | my_dirty_size, jeb->dirty_size + jeb->wasted_size); | 183 | my_dirty_size, jeb->dirty_size + jeb->wasted_size); |
167 | jffs2_dbg_dump_node_refs(c, jeb); | 184 | goto error; |
168 | jffs2_dbg_dump_block_lists(c); | ||
169 | BUG(); | ||
170 | } | 185 | } |
171 | 186 | ||
172 | if (jeb->free_size == 0 | 187 | if (jeb->free_size == 0 |
173 | && my_used_size + my_unchecked_size + my_dirty_size != c->sector_size) { | 188 | && my_used_size + my_unchecked_size + my_dirty_size != c->sector_size) { |
174 | printk(KERN_ERR "The sum of all nodes in block (%#x) != size of block (%#x)\n", | 189 | JFFS2_ERROR("The sum of all nodes in block (%#x) != size of block (%#x)\n", |
175 | my_used_size + my_unchecked_size + my_dirty_size, | 190 | my_used_size + my_unchecked_size + my_dirty_size, |
176 | c->sector_size); | 191 | c->sector_size); |
177 | jffs2_dbg_dump_node_refs(c, jeb); | 192 | goto error; |
178 | jffs2_dbg_dump_block_lists(c); | ||
179 | BUG(); | ||
180 | } | 193 | } |
194 | #endif | ||
195 | |||
196 | return; | ||
197 | |||
198 | error: | ||
199 | __jffs2_dbg_dump_node_refs_nolock(c, jeb); | ||
200 | __jffs2_dbg_dump_jeb_nolock(jeb); | ||
201 | __jffs2_dbg_dump_block_lists_nolock(c); | ||
202 | BUG(); | ||
203 | |||
181 | } | 204 | } |
182 | #endif /* JFFS2_PARANOIA_CHECKS */ | 205 | #endif /* JFFS2_DBG_PARANOIA_CHECKS */ |
183 | 206 | ||
184 | #if defined(JFFS2_PARANOIA_CHECKS) || (CONFIG_JFFS2_FS_DEBUG > 0) | 207 | #if defined(JFFS2_DBG_DUMPS) || defined(JFFS2_DBG_PARANOIA_CHECKS) |
185 | /* | 208 | /* |
186 | * Dump the node_refs of the 'jeb' JFFS2 eraseblock. | 209 | * Dump the node_refs of the 'jeb' JFFS2 eraseblock. |
187 | */ | 210 | */ |
188 | void | 211 | void |
189 | jffs2_dbg_dump_node_refs(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb) | 212 | __jffs2_dbg_dump_node_refs(struct jffs2_sb_info *c, |
213 | struct jffs2_eraseblock *jeb) | ||
214 | { | ||
215 | spin_lock(&c->erase_completion_lock); | ||
216 | __jffs2_dbg_dump_node_refs_nolock(c, jeb); | ||
217 | spin_unlock(&c->erase_completion_lock); | ||
218 | } | ||
219 | |||
220 | void | ||
221 | __jffs2_dbg_dump_node_refs_nolock(struct jffs2_sb_info *c, | ||
222 | struct jffs2_eraseblock *jeb) | ||
190 | { | 223 | { |
191 | struct jffs2_raw_node_ref *ref; | 224 | struct jffs2_raw_node_ref *ref; |
192 | int i = 0; | 225 | int i = 0; |
193 | 226 | ||
227 | JFFS2_DEBUG("Dump node_refs of the eraseblock %#08x\n", jeb->offset); | ||
194 | if (!jeb->first_node) { | 228 | if (!jeb->first_node) { |
195 | printk(KERN_DEBUG "no nodes in block %#08x\n", jeb->offset); | 229 | JFFS2_DEBUG("no nodes in the eraseblock %#08x\n", jeb->offset); |
196 | return; | 230 | return; |
197 | } | 231 | } |
198 | 232 | ||
199 | printk(KERN_DEBUG); | 233 | printk(JFFS2_DBG_LVL); |
200 | for (ref = jeb->first_node; ; ref = ref->next_phys) { | 234 | for (ref = jeb->first_node; ; ref = ref->next_phys) { |
201 | printk("%#08x(%#x)", ref_offset(ref), ref->__totlen); | 235 | printk("%#08x(%#x)", ref_offset(ref), ref->__totlen); |
202 | if (ref->next_phys) | 236 | if (ref->next_phys) |
@@ -205,46 +239,83 @@ jffs2_dbg_dump_node_refs(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb) | |||
205 | break; | 239 | break; |
206 | if (++i == 4) { | 240 | if (++i == 4) { |
207 | i = 0; | 241 | i = 0; |
208 | printk("\n" KERN_DEBUG); | 242 | printk("\n" JFFS2_DBG_LVL); |
209 | } | 243 | } |
210 | } | 244 | } |
211 | printk("\n"); | 245 | printk("\n"); |
212 | } | 246 | } |
213 | 247 | ||
248 | /* | ||
249 | * Dump an eraseblock's space accounting. | ||
250 | */ | ||
251 | void | ||
252 | __jffs2_dbg_dump_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb) | ||
253 | { | ||
254 | spin_lock(&c->erase_completion_lock); | ||
255 | __jffs2_dbg_dump_jeb_nolock(jeb); | ||
256 | spin_unlock(&c->erase_completion_lock); | ||
257 | } | ||
258 | |||
214 | void | 259 | void |
215 | jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c) | 260 | __jffs2_dbg_dump_jeb_nolock(struct jffs2_eraseblock *jeb) |
216 | { | 261 | { |
217 | printk(KERN_DEBUG "flash_size: %#08x\n", c->flash_size); | 262 | if (!jeb) |
218 | printk(KERN_DEBUG "used_size: %#08x\n", c->used_size); | 263 | return; |
219 | printk(KERN_DEBUG "dirty_size: %#08x\n", c->dirty_size); | 264 | |
220 | printk(KERN_DEBUG "wasted_size: %#08x\n", c->wasted_size); | 265 | JFFS2_DEBUG("dump space accounting for the eraseblock at %#08x:\n", |
221 | printk(KERN_DEBUG "unchecked_size: %#08x\n", c->unchecked_size); | 266 | jeb->offset); |
222 | printk(KERN_DEBUG "free_size: %#08x\n", c->free_size); | 267 | |
223 | printk(KERN_DEBUG "erasing_size: %#08x\n", c->erasing_size); | 268 | printk(JFFS2_DBG_LVL "used_size: %#08x\n", jeb->used_size); |
224 | printk(KERN_DEBUG "bad_size: %#08x\n", c->bad_size); | 269 | printk(JFFS2_DBG_LVL "dirty_size: %#08x\n", jeb->dirty_size); |
225 | printk(KERN_DEBUG "sector_size: %#08x\n", c->sector_size); | 270 | printk(JFFS2_DBG_LVL "wasted_size: %#08x\n", jeb->wasted_size); |
226 | printk(KERN_DEBUG "jffs2_reserved_blocks size: %#08x\n", | 271 | printk(JFFS2_DBG_LVL "unchecked_size: %#08x\n", jeb->unchecked_size); |
272 | printk(JFFS2_DBG_LVL "free_size: %#08x\n", jeb->free_size); | ||
273 | } | ||
274 | |||
275 | void | ||
276 | __jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c) | ||
277 | { | ||
278 | spin_lock(&c->erase_completion_lock); | ||
279 | __jffs2_dbg_dump_block_lists_nolock(c); | ||
280 | spin_unlock(&c->erase_completion_lock); | ||
281 | } | ||
282 | |||
283 | void | ||
284 | __jffs2_dbg_dump_block_lists_nolock(struct jffs2_sb_info *c) | ||
285 | { | ||
286 | JFFS2_DEBUG("dump JFFS2 blocks lists:\n"); | ||
287 | |||
288 | printk(JFFS2_DBG_LVL "flash_size: %#08x\n", c->flash_size); | ||
289 | printk(JFFS2_DBG_LVL "used_size: %#08x\n", c->used_size); | ||
290 | printk(JFFS2_DBG_LVL "dirty_size: %#08x\n", c->dirty_size); | ||
291 | printk(JFFS2_DBG_LVL "wasted_size: %#08x\n", c->wasted_size); | ||
292 | printk(JFFS2_DBG_LVL "unchecked_size: %#08x\n", c->unchecked_size); | ||
293 | printk(JFFS2_DBG_LVL "free_size: %#08x\n", c->free_size); | ||
294 | printk(JFFS2_DBG_LVL "erasing_size: %#08x\n", c->erasing_size); | ||
295 | printk(JFFS2_DBG_LVL "bad_size: %#08x\n", c->bad_size); | ||
296 | printk(JFFS2_DBG_LVL "sector_size: %#08x\n", c->sector_size); | ||
297 | printk(JFFS2_DBG_LVL "jffs2_reserved_blocks size: %#08x\n", | ||
227 | c->sector_size * c->resv_blocks_write); | 298 | c->sector_size * c->resv_blocks_write); |
228 | 299 | ||
229 | if (c->nextblock) | 300 | if (c->nextblock) |
230 | printk(KERN_DEBUG "nextblock: %#08x (used %#08x, dirty %#08x, wasted %#08x, " | 301 | printk(JFFS2_DBG_LVL "nextblock: %#08x (used %#08x, dirty %#08x, wasted %#08x, " |
231 | "unchecked %#08x, free %#08x)\n", | 302 | "unchecked %#08x, free %#08x)\n", |
232 | c->nextblock->offset, c->nextblock->used_size, | 303 | c->nextblock->offset, c->nextblock->used_size, |
233 | c->nextblock->dirty_size, c->nextblock->wasted_size, | 304 | c->nextblock->dirty_size, c->nextblock->wasted_size, |
234 | c->nextblock->unchecked_size, c->nextblock->free_size); | 305 | c->nextblock->unchecked_size, c->nextblock->free_size); |
235 | else | 306 | else |
236 | printk(KERN_DEBUG "nextblock: NULL\n"); | 307 | printk(JFFS2_DBG_LVL "nextblock: NULL\n"); |
237 | 308 | ||
238 | if (c->gcblock) | 309 | if (c->gcblock) |
239 | printk(KERN_DEBUG "gcblock: %#08x (used %#08x, dirty %#08x, wasted %#08x, " | 310 | printk(JFFS2_DBG_LVL "gcblock: %#08x (used %#08x, dirty %#08x, wasted %#08x, " |
240 | "unchecked %#08x, free %#08x)\n", | 311 | "unchecked %#08x, free %#08x)\n", |
241 | c->gcblock->offset, c->gcblock->used_size, c->gcblock->dirty_size, | 312 | c->gcblock->offset, c->gcblock->used_size, c->gcblock->dirty_size, |
242 | c->gcblock->wasted_size, c->gcblock->unchecked_size, c->gcblock->free_size); | 313 | c->gcblock->wasted_size, c->gcblock->unchecked_size, c->gcblock->free_size); |
243 | else | 314 | else |
244 | printk(KERN_DEBUG "gcblock: NULL\n"); | 315 | printk(JFFS2_DBG_LVL "gcblock: NULL\n"); |
245 | 316 | ||
246 | if (list_empty(&c->clean_list)) { | 317 | if (list_empty(&c->clean_list)) { |
247 | printk(KERN_DEBUG "clean_list: empty\n"); | 318 | printk(JFFS2_DBG_LVL "clean_list: empty\n"); |
248 | } else { | 319 | } else { |
249 | struct list_head *this; | 320 | struct list_head *this; |
250 | int numblocks = 0; | 321 | int numblocks = 0; |
@@ -255,19 +326,19 @@ jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c) | |||
255 | numblocks ++; | 326 | numblocks ++; |
256 | dirty += jeb->wasted_size; | 327 | dirty += jeb->wasted_size; |
257 | if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { | 328 | if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { |
258 | printk(KERN_DEBUG "clean_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, " | 329 | printk(JFFS2_DBG_LVL "clean_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, " |
259 | "unchecked %#08x, free %#08x)\n", | 330 | "unchecked %#08x, free %#08x)\n", |
260 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, | 331 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, |
261 | jeb->unchecked_size, jeb->free_size); | 332 | jeb->unchecked_size, jeb->free_size); |
262 | } | 333 | } |
263 | } | 334 | } |
264 | 335 | ||
265 | printk (KERN_DEBUG "Contains %d blocks with total wasted size %u, average wasted size: %u\n", | 336 | printk (JFFS2_DBG_LVL "Contains %d blocks with total wasted size %u, average wasted size: %u\n", |
266 | numblocks, dirty, dirty / numblocks); | 337 | numblocks, dirty, dirty / numblocks); |
267 | } | 338 | } |
268 | 339 | ||
269 | if (list_empty(&c->very_dirty_list)) { | 340 | if (list_empty(&c->very_dirty_list)) { |
270 | printk(KERN_DEBUG "very_dirty_list: empty\n"); | 341 | printk(JFFS2_DBG_LVL "very_dirty_list: empty\n"); |
271 | } else { | 342 | } else { |
272 | struct list_head *this; | 343 | struct list_head *this; |
273 | int numblocks = 0; | 344 | int numblocks = 0; |
@@ -279,19 +350,19 @@ jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c) | |||
279 | numblocks ++; | 350 | numblocks ++; |
280 | dirty += jeb->dirty_size; | 351 | dirty += jeb->dirty_size; |
281 | if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { | 352 | if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { |
282 | printk(KERN_DEBUG "very_dirty_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, " | 353 | printk(JFFS2_DBG_LVL "very_dirty_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, " |
283 | "unchecked %#08x, free %#08x)\n", | 354 | "unchecked %#08x, free %#08x)\n", |
284 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, | 355 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, |
285 | jeb->unchecked_size, jeb->free_size); | 356 | jeb->unchecked_size, jeb->free_size); |
286 | } | 357 | } |
287 | } | 358 | } |
288 | 359 | ||
289 | printk (KERN_DEBUG "Contains %d blocks with total dirty size %u, average dirty size: %u\n", | 360 | printk (JFFS2_DBG_LVL "Contains %d blocks with total dirty size %u, average dirty size: %u\n", |
290 | numblocks, dirty, dirty / numblocks); | 361 | numblocks, dirty, dirty / numblocks); |
291 | } | 362 | } |
292 | 363 | ||
293 | if (list_empty(&c->dirty_list)) { | 364 | if (list_empty(&c->dirty_list)) { |
294 | printk(KERN_DEBUG "dirty_list: empty\n"); | 365 | printk(JFFS2_DBG_LVL "dirty_list: empty\n"); |
295 | } else { | 366 | } else { |
296 | struct list_head *this; | 367 | struct list_head *this; |
297 | int numblocks = 0; | 368 | int numblocks = 0; |
@@ -303,19 +374,19 @@ jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c) | |||
303 | numblocks ++; | 374 | numblocks ++; |
304 | dirty += jeb->dirty_size; | 375 | dirty += jeb->dirty_size; |
305 | if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { | 376 | if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { |
306 | printk(KERN_DEBUG "dirty_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, " | 377 | printk(JFFS2_DBG_LVL "dirty_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, " |
307 | "unchecked %#08x, free %#08x)\n", | 378 | "unchecked %#08x, free %#08x)\n", |
308 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, | 379 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, |
309 | jeb->unchecked_size, jeb->free_size); | 380 | jeb->unchecked_size, jeb->free_size); |
310 | } | 381 | } |
311 | } | 382 | } |
312 | 383 | ||
313 | printk (KERN_DEBUG "Contains %d blocks with total dirty size %u, average dirty size: %u\n", | 384 | printk (JFFS2_DBG_LVL "contains %d blocks with total dirty size %u, average dirty size: %u\n", |
314 | numblocks, dirty, dirty / numblocks); | 385 | numblocks, dirty, dirty / numblocks); |
315 | } | 386 | } |
316 | 387 | ||
317 | if (list_empty(&c->erasable_list)) { | 388 | if (list_empty(&c->erasable_list)) { |
318 | printk(KERN_DEBUG "erasable_list: empty\n"); | 389 | printk(JFFS2_DBG_LVL "erasable_list: empty\n"); |
319 | } else { | 390 | } else { |
320 | struct list_head *this; | 391 | struct list_head *this; |
321 | 392 | ||
@@ -323,16 +394,16 @@ jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c) | |||
323 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); | 394 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); |
324 | 395 | ||
325 | if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { | 396 | if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { |
326 | printk(KERN_DEBUG "erasable_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, " | 397 | printk(JFFS2_DBG_LVL "erasable_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, " |
327 | "unchecked %#08x, free %#08x)\n", | 398 | "unchecked %#08x, free %#08x)\n", |
328 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, | 399 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, |
329 | jeb->unchecked_size, jeb->free_size); | 400 | jeb->unchecked_size, jeb->free_size); |
330 | } | 401 | } |
331 | } | 402 | } |
332 | } | 403 | } |
333 | 404 | ||
334 | if (list_empty(&c->erasing_list)) { | 405 | if (list_empty(&c->erasing_list)) { |
335 | printk(KERN_DEBUG "erasing_list: empty\n"); | 406 | printk(JFFS2_DBG_LVL "erasing_list: empty\n"); |
336 | } else { | 407 | } else { |
337 | struct list_head *this; | 408 | struct list_head *this; |
338 | 409 | ||
@@ -340,16 +411,16 @@ jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c) | |||
340 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); | 411 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); |
341 | 412 | ||
342 | if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { | 413 | if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { |
343 | printk(KERN_DEBUG "erasing_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, " | 414 | printk(JFFS2_DBG_LVL "erasing_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, " |
344 | "unchecked %#08x, free %#08x)\n", | 415 | "unchecked %#08x, free %#08x)\n", |
345 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, | 416 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, |
346 | jeb->unchecked_size, jeb->free_size); | 417 | jeb->unchecked_size, jeb->free_size); |
347 | } | 418 | } |
348 | } | 419 | } |
349 | } | 420 | } |
350 | 421 | ||
351 | if (list_empty(&c->erase_pending_list)) { | 422 | if (list_empty(&c->erase_pending_list)) { |
352 | printk(KERN_DEBUG "erase_pending_list: empty\n"); | 423 | printk(JFFS2_DBG_LVL "erase_pending_list: empty\n"); |
353 | } else { | 424 | } else { |
354 | struct list_head *this; | 425 | struct list_head *this; |
355 | 426 | ||
@@ -357,16 +428,16 @@ jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c) | |||
357 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); | 428 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); |
358 | 429 | ||
359 | if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { | 430 | if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { |
360 | printk(KERN_DEBUG "erase_pending_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, " | 431 | printk(JFFS2_DBG_LVL "erase_pending_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, " |
361 | "unchecked %#08x, free %#08x)\n", | 432 | "unchecked %#08x, free %#08x)\n", |
362 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, | 433 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, |
363 | jeb->unchecked_size, jeb->free_size); | 434 | jeb->unchecked_size, jeb->free_size); |
364 | } | 435 | } |
365 | } | 436 | } |
366 | } | 437 | } |
367 | 438 | ||
368 | if (list_empty(&c->erasable_pending_wbuf_list)) { | 439 | if (list_empty(&c->erasable_pending_wbuf_list)) { |
369 | printk(KERN_DEBUG "erasable_pending_wbuf_list: empty\n"); | 440 | printk(JFFS2_DBG_LVL "erasable_pending_wbuf_list: empty\n"); |
370 | } else { | 441 | } else { |
371 | struct list_head *this; | 442 | struct list_head *this; |
372 | 443 | ||
@@ -374,16 +445,16 @@ jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c) | |||
374 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); | 445 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); |
375 | 446 | ||
376 | if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { | 447 | if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { |
377 | printk(KERN_DEBUG "erasable_pending_wbuf_list: %#08x (used %#08x, dirty %#08x, " | 448 | printk(JFFS2_DBG_LVL "erasable_pending_wbuf_list: %#08x (used %#08x, dirty %#08x, " |
378 | "wasted %#08x, unchecked %#08x, free %#08x)\n", | 449 | "wasted %#08x, unchecked %#08x, free %#08x)\n", |
379 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, | 450 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, |
380 | jeb->unchecked_size, jeb->free_size); | 451 | jeb->unchecked_size, jeb->free_size); |
381 | } | 452 | } |
382 | } | 453 | } |
383 | } | 454 | } |
384 | 455 | ||
385 | if (list_empty(&c->free_list)) { | 456 | if (list_empty(&c->free_list)) { |
386 | printk(KERN_DEBUG "free_list: empty\n"); | 457 | printk(JFFS2_DBG_LVL "free_list: empty\n"); |
387 | } else { | 458 | } else { |
388 | struct list_head *this; | 459 | struct list_head *this; |
389 | 460 | ||
@@ -391,16 +462,16 @@ jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c) | |||
391 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); | 462 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); |
392 | 463 | ||
393 | if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { | 464 | if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { |
394 | printk(KERN_DEBUG "free_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, " | 465 | printk(JFFS2_DBG_LVL "free_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, " |
395 | "unchecked %#08x, free %#08x)\n", | 466 | "unchecked %#08x, free %#08x)\n", |
396 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, | 467 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, |
397 | jeb->unchecked_size, jeb->free_size); | 468 | jeb->unchecked_size, jeb->free_size); |
398 | } | 469 | } |
399 | } | 470 | } |
400 | } | 471 | } |
401 | 472 | ||
402 | if (list_empty(&c->bad_list)) { | 473 | if (list_empty(&c->bad_list)) { |
403 | printk(KERN_DEBUG "bad_list: empty\n"); | 474 | printk(JFFS2_DBG_LVL "bad_list: empty\n"); |
404 | } else { | 475 | } else { |
405 | struct list_head *this; | 476 | struct list_head *this; |
406 | 477 | ||
@@ -408,16 +479,16 @@ jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c) | |||
408 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); | 479 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); |
409 | 480 | ||
410 | if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { | 481 | if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { |
411 | printk(KERN_DEBUG "bad_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, " | 482 | printk(JFFS2_DBG_LVL "bad_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, " |
412 | "unchecked %#08x, free %#08x)\n", | 483 | "unchecked %#08x, free %#08x)\n", |
413 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, | 484 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, |
414 | jeb->unchecked_size, jeb->free_size); | 485 | jeb->unchecked_size, jeb->free_size); |
415 | } | 486 | } |
416 | } | 487 | } |
417 | } | 488 | } |
418 | 489 | ||
419 | if (list_empty(&c->bad_used_list)) { | 490 | if (list_empty(&c->bad_used_list)) { |
420 | printk(KERN_DEBUG "bad_used_list: empty\n"); | 491 | printk(JFFS2_DBG_LVL "bad_used_list: empty\n"); |
421 | } else { | 492 | } else { |
422 | struct list_head *this; | 493 | struct list_head *this; |
423 | 494 | ||
@@ -425,34 +496,42 @@ jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c) | |||
425 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); | 496 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); |
426 | 497 | ||
427 | if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { | 498 | if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { |
428 | printk(KERN_DEBUG "bad_used_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, " | 499 | printk(JFFS2_DBG_LVL "bad_used_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, " |
429 | "unchecked %#08x, free %#08x)\n", | 500 | "unchecked %#08x, free %#08x)\n", |
430 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, | 501 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, |
431 | jeb->unchecked_size, jeb->free_size); | 502 | jeb->unchecked_size, jeb->free_size); |
432 | } | 503 | } |
433 | } | 504 | } |
434 | } | 505 | } |
435 | } | 506 | } |
436 | 507 | ||
437 | void | 508 | void |
438 | jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f) | 509 | __jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f) |
510 | { | ||
511 | down(&f->sem); | ||
512 | jffs2_dbg_dump_fragtree_nolock(f); | ||
513 | up(&f->sem); | ||
514 | } | ||
515 | |||
516 | void | ||
517 | __jffs2_dbg_dump_fragtree_nolock(struct jffs2_inode_info *f) | ||
439 | { | 518 | { |
440 | struct jffs2_node_frag *this = frag_first(&f->fragtree); | 519 | struct jffs2_node_frag *this = frag_first(&f->fragtree); |
441 | uint32_t lastofs = 0; | 520 | uint32_t lastofs = 0; |
442 | int buggy = 0; | 521 | int buggy = 0; |
443 | 522 | ||
444 | printk(KERN_DEBUG "inode is ino #%u\n", f->inocache->ino); | 523 | JFFS2_DEBUG("dump fragtree of ino #%u\n", f->inocache->ino); |
445 | while(this) { | 524 | while(this) { |
446 | if (this->node) | 525 | if (this->node) |
447 | printk(KERN_DEBUG "frag %#04x-%#04x: %#08x(%d) on flash (*%p), left (%p), " | 526 | printk(JFFS2_DBG_LVL "frag %#04x-%#04x: %#08x(%d) on flash (*%p), left (%p), " |
448 | "right (%p), parent (%p)\n", | 527 | "right (%p), parent (%p)\n", |
449 | this->ofs, this->ofs+this->size, ref_offset(this->node->raw), | 528 | this->ofs, this->ofs+this->size, ref_offset(this->node->raw), |
450 | ref_flags(this->node->raw), this, frag_left(this), frag_right(this), | 529 | ref_flags(this->node->raw), this, frag_left(this), frag_right(this), |
451 | frag_parent(this)); | 530 | frag_parent(this)); |
452 | else | 531 | else |
453 | printk(KERN_DEBUG "frag %#04x-%#04x: hole (*%p). left (%p), right (%p), parent (%p)\n", | 532 | printk(JFFS2_DBG_LVL "frag %#04x-%#04x: hole (*%p). left (%p), right (%p), parent (%p)\n", |
454 | this->ofs, this->ofs+this->size, this, frag_left(this), | 533 | this->ofs, this->ofs+this->size, this, frag_left(this), |
455 | frag_right(this), frag_parent(this)); | 534 | frag_right(this), frag_parent(this)); |
456 | if (this->ofs != lastofs) | 535 | if (this->ofs != lastofs) |
457 | buggy = 1; | 536 | buggy = 1; |
458 | lastofs = this->ofs + this->size; | 537 | lastofs = this->ofs + this->size; |
@@ -460,36 +539,171 @@ jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f) | |||
460 | } | 539 | } |
461 | 540 | ||
462 | if (f->metadata) | 541 | if (f->metadata) |
463 | printk(KERN_DEBUG "metadata at 0x%08x\n", ref_offset(f->metadata->raw)); | 542 | printk(JFFS2_DBG_LVL "metadata at 0x%08x\n", ref_offset(f->metadata->raw)); |
464 | 543 | ||
465 | if (buggy) { | 544 | if (buggy) { |
466 | printk(KERN_ERR "Error! %s(): Frag tree got a hole in it\n", __FUNCTION__); | 545 | JFFS2_ERROR("frag tree got a hole in it.\n"); |
467 | BUG(); | 546 | BUG(); |
468 | } | 547 | } |
469 | } | 548 | } |
470 | 549 | ||
471 | #define JFFS3_BUFDUMP_BYTES_PER_LINE 8 | 550 | #define JFFS2_BUFDUMP_BYTES_PER_LINE 32 |
472 | void | 551 | void |
473 | jffs2_dbg_dump_buffer(char *buf, int len, uint32_t offs) | 552 | __jffs2_dbg_dump_buffer(unsigned char *buf, int len, uint32_t offs) |
474 | { | 553 | { |
475 | int i = 0; | 554 | int skip; |
476 | int skip = offs & ~(JFFS3_BUFDUMP_BYTES_PER_LINE - 1); | 555 | int i; |
556 | |||
557 | JFFS2_DEBUG("dump from offset %#08x to offset %#08x (%x bytes).\n", | ||
558 | offs, offs + len, len); | ||
559 | i = skip = offs % JFFS2_BUFDUMP_BYTES_PER_LINE; | ||
560 | offs = offs & ~(JFFS2_BUFDUMP_BYTES_PER_LINE - 1); | ||
561 | |||
562 | if (skip != 0) | ||
563 | printk(JFFS2_DBG_LVL "%#08x: ", offs); | ||
564 | |||
565 | while (skip--) | ||
566 | printk(" "); | ||
477 | 567 | ||
478 | while (i < len) { | 568 | while (i < len) { |
479 | int j = 0; | 569 | if ((i % JFFS2_BUFDUMP_BYTES_PER_LINE) == 0 && i != len -1) { |
480 | 570 | if (i != 0) | |
481 | printk(KERN_DEBUG "0x#x: \n"); | 571 | printk("\n"); |
482 | while (skip) { | 572 | offs += JFFS2_BUFDUMP_BYTES_PER_LINE; |
483 | printk(" "); | 573 | printk(JFFS2_DBG_LVL "%0#8x: ", offs); |
484 | skip -= 1; | ||
485 | } | 574 | } |
486 | 575 | ||
487 | while (j < JFFS3_BUFDUMP_BYTES_PER_LINE) { | 576 | printk("%02x ", buf[i]); |
488 | if (i + j < len) | 577 | |
489 | printk(" %#02x", buf[i + j++]); | 578 | i += 1; |
579 | } | ||
580 | |||
581 | printk("\n"); | ||
582 | } | ||
583 | |||
584 | /* | ||
585 | * Dump a JFFS2 node. | ||
586 | */ | ||
587 | void | ||
588 | __jffs2_dbg_dump_node(struct jffs2_sb_info *c, uint32_t ofs) | ||
589 | { | ||
590 | union jffs2_node_union node; | ||
591 | int len = sizeof(union jffs2_node_union); | ||
592 | size_t retlen; | ||
593 | uint32_t crc; | ||
594 | int ret; | ||
595 | |||
596 | JFFS2_DEBUG("dump node at offset %#08x.\n", ofs); | ||
597 | |||
598 | ret = jffs2_flash_read(c, ofs, len, &retlen, (unsigned char *)&node); | ||
599 | if (ret || (retlen != len)) { | ||
600 | JFFS2_ERROR("read %d bytes failed or short. ret %d, retlen %zd.\n", | ||
601 | len, ret, retlen); | ||
602 | return; | ||
603 | } | ||
604 | |||
605 | printk(JFFS2_DBG_LVL "magic:\t%#04x\n", | ||
606 | je16_to_cpu(node.u.magic)); | ||
607 | printk(JFFS2_DBG_LVL "nodetype:\t%#04x\n", | ||
608 | je16_to_cpu(node.u.nodetype)); | ||
609 | printk(JFFS2_DBG_LVL "totlen:\t%#08x\n", | ||
610 | je32_to_cpu(node.u.totlen)); | ||
611 | printk(JFFS2_DBG_LVL "hdr_crc:\t%#08x\n", | ||
612 | je32_to_cpu(node.u.hdr_crc)); | ||
613 | |||
614 | crc = crc32(0, &node.u, sizeof(node.u) - 4); | ||
615 | if (crc != je32_to_cpu(node.u.hdr_crc)) { | ||
616 | JFFS2_ERROR("wrong common header CRC.\n"); | ||
617 | return; | ||
618 | } | ||
619 | |||
620 | if (je16_to_cpu(node.u.magic) != JFFS2_MAGIC_BITMASK && | ||
621 | je16_to_cpu(node.u.magic) != JFFS2_OLD_MAGIC_BITMASK) | ||
622 | { | ||
623 | JFFS2_ERROR("wrong node magic: %#04x instead of %#04x.\n", | ||
624 | je16_to_cpu(node.u.magic), JFFS2_MAGIC_BITMASK); | ||
625 | return; | ||
626 | } | ||
627 | |||
628 | switch(je16_to_cpu(node.u.nodetype)) { | ||
629 | |||
630 | case JFFS2_NODETYPE_INODE: | ||
631 | |||
632 | printk(JFFS2_DBG_LVL "the node is inode node\n"); | ||
633 | printk(JFFS2_DBG_LVL "ino:\t%#08x\n", | ||
634 | je32_to_cpu(node.i.ino)); | ||
635 | printk(JFFS2_DBG_LVL "version:\t%#08x\n", | ||
636 | je32_to_cpu(node.i.version)); | ||
637 | printk(JFFS2_DBG_LVL "mode:\t%#08x\n", | ||
638 | node.i.mode.m); | ||
639 | printk(JFFS2_DBG_LVL "uid:\t%#04x\n", | ||
640 | je16_to_cpu(node.i.uid)); | ||
641 | printk(JFFS2_DBG_LVL "gid:\t%#04x\n", | ||
642 | je16_to_cpu(node.i.gid)); | ||
643 | printk(JFFS2_DBG_LVL "isize:\t%#08x\n", | ||
644 | je32_to_cpu(node.i.isize)); | ||
645 | printk(JFFS2_DBG_LVL "atime:\t%#08x\n", | ||
646 | je32_to_cpu(node.i.atime)); | ||
647 | printk(JFFS2_DBG_LVL "mtime:\t%#08x\n", | ||
648 | je32_to_cpu(node.i.mtime)); | ||
649 | printk(JFFS2_DBG_LVL "ctime:\t%#08x\n", | ||
650 | je32_to_cpu(node.i.ctime)); | ||
651 | printk(JFFS2_DBG_LVL "offset:\t%#08x\n", | ||
652 | je32_to_cpu(node.i.offset)); | ||
653 | printk(JFFS2_DBG_LVL "csize:\t%#08x\n", | ||
654 | je32_to_cpu(node.i.csize)); | ||
655 | printk(JFFS2_DBG_LVL "dsize:\t%#08x\n", | ||
656 | je32_to_cpu(node.i.dsize)); | ||
657 | printk(JFFS2_DBG_LVL "compr:\t%#02x\n", | ||
658 | node.i.compr); | ||
659 | printk(JFFS2_DBG_LVL "usercompr:\t%#02x\n", | ||
660 | node.i.usercompr); | ||
661 | printk(JFFS2_DBG_LVL "flags:\t%#04x\n", | ||
662 | je16_to_cpu(node.i.flags)); | ||
663 | printk(JFFS2_DBG_LVL "data_crc:\t%#08x\n", | ||
664 | je32_to_cpu(node.i.data_crc)); | ||
665 | printk(JFFS2_DBG_LVL "node_crc:\t%#08x\n", | ||
666 | je32_to_cpu(node.i.node_crc)); | ||
667 | crc = crc32(0, &node.i, sizeof(node.i) - 8); | ||
668 | if (crc != je32_to_cpu(node.i.node_crc)) { | ||
669 | JFFS2_ERROR("wrong node header CRC.\n"); | ||
670 | return; | ||
671 | } | ||
672 | break; | ||
673 | |||
674 | case JFFS2_NODETYPE_DIRENT: | ||
675 | |||
676 | printk(JFFS2_DBG_LVL "the node is dirent node\n"); | ||
677 | printk(JFFS2_DBG_LVL "pino:\t%#08x\n", | ||
678 | je32_to_cpu(node.d.pino)); | ||
679 | printk(JFFS2_DBG_LVL "version:\t%#08x\n", | ||
680 | je32_to_cpu(node.d.version)); | ||
681 | printk(JFFS2_DBG_LVL "ino:\t%#08x\n", | ||
682 | je32_to_cpu(node.d.ino)); | ||
683 | printk(JFFS2_DBG_LVL "mctime:\t%#08x\n", | ||
684 | je32_to_cpu(node.d.mctime)); | ||
685 | printk(JFFS2_DBG_LVL "nsize:\t%#02x\n", | ||
686 | node.d.nsize); | ||
687 | printk(JFFS2_DBG_LVL "type:\t%#02x\n", | ||
688 | node.d.type); | ||
689 | printk(JFFS2_DBG_LVL "node_crc:\t%#08x\n", | ||
690 | je32_to_cpu(node.d.node_crc)); | ||
691 | printk(JFFS2_DBG_LVL "name_crc:\t%#08x\n", | ||
692 | je32_to_cpu(node.d.name_crc)); | ||
693 | |||
694 | node.d.name[node.d.nsize] = '\0'; | ||
695 | printk(JFFS2_DBG_LVL "name:\t\"%s\"\n", node.d.name); | ||
696 | |||
697 | crc = crc32(0, &node.d, sizeof(node.d) - 8); | ||
698 | if (crc != je32_to_cpu(node.d.node_crc)) { | ||
699 | JFFS2_ERROR("wrong node header CRC.\n"); | ||
700 | return; | ||
490 | } | 701 | } |
702 | break; | ||
491 | 703 | ||
492 | i += JFFS3_BUFDUMP_BYTES_PER_LINE; | 704 | default: |
705 | printk(JFFS2_DBG_LVL "node type is unknown\n"); | ||
706 | break; | ||
493 | } | 707 | } |
494 | } | 708 | } |
495 | #endif /* JFFS2_PARANOIA_CHECKS || CONFIG_JFFS2_FS_DEBUG > 0 */ | 709 | #endif /* JFFS2_DBG_DUMPS || JFFS2_DBG_PARANOIA_CHECKS */ |