diff options
| -rw-r--r-- | fs/ubifs/debug.c | 56 | ||||
| -rw-r--r-- | fs/ubifs/debug.h | 6 | ||||
| -rw-r--r-- | fs/ubifs/tnc.c | 3 |
3 files changed, 60 insertions, 5 deletions
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c index c9609a63512e..4a2170dce0db 100644 --- a/fs/ubifs/debug.c +++ b/fs/ubifs/debug.c | |||
| @@ -91,6 +91,28 @@ static const char *get_key_type(int type) | |||
| 91 | } | 91 | } |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | static const char *get_dent_type(int type) | ||
| 95 | { | ||
| 96 | switch (type) { | ||
| 97 | case UBIFS_ITYPE_REG: | ||
| 98 | return "file"; | ||
| 99 | case UBIFS_ITYPE_DIR: | ||
| 100 | return "dir"; | ||
| 101 | case UBIFS_ITYPE_LNK: | ||
| 102 | return "symlink"; | ||
| 103 | case UBIFS_ITYPE_BLK: | ||
| 104 | return "blkdev"; | ||
| 105 | case UBIFS_ITYPE_CHR: | ||
| 106 | return "char dev"; | ||
| 107 | case UBIFS_ITYPE_FIFO: | ||
| 108 | return "fifo"; | ||
| 109 | case UBIFS_ITYPE_SOCK: | ||
| 110 | return "socket"; | ||
| 111 | default: | ||
| 112 | return "unknown/invalid type"; | ||
| 113 | } | ||
| 114 | } | ||
| 115 | |||
| 94 | static void sprintf_key(const struct ubifs_info *c, const union ubifs_key *key, | 116 | static void sprintf_key(const struct ubifs_info *c, const union ubifs_key *key, |
| 95 | char *buffer) | 117 | char *buffer) |
| 96 | { | 118 | { |
| @@ -234,9 +256,13 @@ static void dump_ch(const struct ubifs_ch *ch) | |||
| 234 | printk(KERN_DEBUG "\tlen %u\n", le32_to_cpu(ch->len)); | 256 | printk(KERN_DEBUG "\tlen %u\n", le32_to_cpu(ch->len)); |
| 235 | } | 257 | } |
| 236 | 258 | ||
| 237 | void dbg_dump_inode(const struct ubifs_info *c, const struct inode *inode) | 259 | void dbg_dump_inode(struct ubifs_info *c, const struct inode *inode) |
| 238 | { | 260 | { |
| 239 | const struct ubifs_inode *ui = ubifs_inode(inode); | 261 | const struct ubifs_inode *ui = ubifs_inode(inode); |
| 262 | struct qstr nm = { .name = NULL }; | ||
| 263 | union ubifs_key key; | ||
| 264 | struct ubifs_dent_node *dent, *pdent = NULL; | ||
| 265 | int count = 2; | ||
| 240 | 266 | ||
| 241 | printk(KERN_DEBUG "Dump in-memory inode:"); | 267 | printk(KERN_DEBUG "Dump in-memory inode:"); |
| 242 | printk(KERN_DEBUG "\tinode %lu\n", inode->i_ino); | 268 | printk(KERN_DEBUG "\tinode %lu\n", inode->i_ino); |
| @@ -270,6 +296,32 @@ void dbg_dump_inode(const struct ubifs_info *c, const struct inode *inode) | |||
| 270 | printk(KERN_DEBUG "\tlast_page_read %lu\n", ui->last_page_read); | 296 | printk(KERN_DEBUG "\tlast_page_read %lu\n", ui->last_page_read); |
| 271 | printk(KERN_DEBUG "\tread_in_a_row %lu\n", ui->read_in_a_row); | 297 | printk(KERN_DEBUG "\tread_in_a_row %lu\n", ui->read_in_a_row); |
| 272 | printk(KERN_DEBUG "\tdata_len %d\n", ui->data_len); | 298 | printk(KERN_DEBUG "\tdata_len %d\n", ui->data_len); |
| 299 | |||
| 300 | if (!S_ISDIR(inode->i_mode)) | ||
| 301 | return; | ||
| 302 | |||
| 303 | printk(KERN_DEBUG "List of directory entries:\n"); | ||
| 304 | ubifs_assert(!mutex_is_locked(&c->tnc_mutex)); | ||
| 305 | |||
| 306 | lowest_dent_key(c, &key, inode->i_ino); | ||
| 307 | while (1) { | ||
| 308 | dent = ubifs_tnc_next_ent(c, &key, &nm); | ||
| 309 | if (IS_ERR(dent)) { | ||
| 310 | if (PTR_ERR(dent) != -ENOENT) | ||
| 311 | printk(KERN_DEBUG "error %ld\n", PTR_ERR(dent)); | ||
| 312 | break; | ||
| 313 | } | ||
| 314 | |||
| 315 | printk(KERN_DEBUG "\t%d: %s (%s)\n", | ||
| 316 | count++, dent->name, get_dent_type(dent->type)); | ||
| 317 | |||
| 318 | nm.name = dent->name; | ||
| 319 | nm.len = le16_to_cpu(dent->nlen); | ||
| 320 | kfree(pdent); | ||
| 321 | pdent = dent; | ||
| 322 | key_read(c, &dent->key, &key); | ||
| 323 | } | ||
| 324 | kfree(pdent); | ||
| 273 | } | 325 | } |
| 274 | 326 | ||
| 275 | void dbg_dump_node(const struct ubifs_info *c, const void *node) | 327 | void dbg_dump_node(const struct ubifs_info *c, const void *node) |
| @@ -1167,12 +1219,14 @@ int dbg_check_dir_size(struct ubifs_info *c, const struct inode *dir) | |||
| 1167 | "but calculated size is %llu", dir->i_ino, | 1219 | "but calculated size is %llu", dir->i_ino, |
| 1168 | (unsigned long long)i_size_read(dir), | 1220 | (unsigned long long)i_size_read(dir), |
| 1169 | (unsigned long long)size); | 1221 | (unsigned long long)size); |
| 1222 | dbg_dump_inode(c, dir); | ||
| 1170 | dump_stack(); | 1223 | dump_stack(); |
| 1171 | return -EINVAL; | 1224 | return -EINVAL; |
| 1172 | } | 1225 | } |
| 1173 | if (dir->i_nlink != nlink) { | 1226 | if (dir->i_nlink != nlink) { |
| 1174 | ubifs_err("directory inode %lu has nlink %u, but calculated " | 1227 | ubifs_err("directory inode %lu has nlink %u, but calculated " |
| 1175 | "nlink is %u", dir->i_ino, dir->i_nlink, nlink); | 1228 | "nlink is %u", dir->i_ino, dir->i_nlink, nlink); |
| 1229 | dbg_dump_inode(c, dir); | ||
| 1176 | dump_stack(); | 1230 | dump_stack(); |
| 1177 | return -EINVAL; | 1231 | return -EINVAL; |
| 1178 | } | 1232 | } |
diff --git a/fs/ubifs/debug.h b/fs/ubifs/debug.h index b59c43a4149c..c6ad9ea15e3c 100644 --- a/fs/ubifs/debug.h +++ b/fs/ubifs/debug.h | |||
| @@ -214,7 +214,7 @@ const char *dbg_cstate(int cmt_state); | |||
| 214 | const char *dbg_jhead(int jhead); | 214 | const char *dbg_jhead(int jhead); |
| 215 | const char *dbg_get_key_dump(const struct ubifs_info *c, | 215 | const char *dbg_get_key_dump(const struct ubifs_info *c, |
| 216 | const union ubifs_key *key); | 216 | const union ubifs_key *key); |
| 217 | void dbg_dump_inode(const struct ubifs_info *c, const struct inode *inode); | 217 | void dbg_dump_inode(struct ubifs_info *c, const struct inode *inode); |
| 218 | void dbg_dump_node(const struct ubifs_info *c, const void *node); | 218 | void dbg_dump_node(const struct ubifs_info *c, const void *node); |
| 219 | void dbg_dump_lpt_node(const struct ubifs_info *c, void *node, int lnum, | 219 | void dbg_dump_lpt_node(const struct ubifs_info *c, void *node, int lnum, |
| 220 | int offs); | 220 | int offs); |
| @@ -364,7 +364,7 @@ static inline const char *dbg_jhead(int jhead) { return ""; } | |||
| 364 | static inline const char * | 364 | static inline const char * |
| 365 | dbg_get_key_dump(const struct ubifs_info *c, | 365 | dbg_get_key_dump(const struct ubifs_info *c, |
| 366 | const union ubifs_key *key) { return ""; } | 366 | const union ubifs_key *key) { return ""; } |
| 367 | static inline void dbg_dump_inode(const struct ubifs_info *c, | 367 | static inline void dbg_dump_inode(struct ubifs_info *c, |
| 368 | const struct inode *inode) { return; } | 368 | const struct inode *inode) { return; } |
| 369 | static inline void dbg_dump_node(const struct ubifs_info *c, | 369 | static inline void dbg_dump_node(const struct ubifs_info *c, |
| 370 | const void *node) { return; } | 370 | const void *node) { return; } |
| @@ -418,7 +418,7 @@ static inline int dbg_chk_lpt_sz(struct ubifs_info *c, | |||
| 418 | int action, int len) { return 0; } | 418 | int action, int len) { return 0; } |
| 419 | static inline int dbg_check_synced_i_size(struct inode *inode) { return 0; } | 419 | static inline int dbg_check_synced_i_size(struct inode *inode) { return 0; } |
| 420 | static inline int dbg_check_dir_size(struct ubifs_info *c, | 420 | static inline int dbg_check_dir_size(struct ubifs_info *c, |
| 421 | const struct inode *dir) { return 0; } | 421 | const struct inode *dir) { return 0; } |
| 422 | static inline int dbg_check_tnc(struct ubifs_info *c, int extra) { return 0; } | 422 | static inline int dbg_check_tnc(struct ubifs_info *c, int extra) { return 0; } |
| 423 | static inline int dbg_check_idx_size(struct ubifs_info *c, | 423 | static inline int dbg_check_idx_size(struct ubifs_info *c, |
| 424 | long long idx_size) { return 0; } | 424 | long long idx_size) { return 0; } |
diff --git a/fs/ubifs/tnc.c b/fs/ubifs/tnc.c index 91b4213dde84..48b6ee6fa848 100644 --- a/fs/ubifs/tnc.c +++ b/fs/ubifs/tnc.c | |||
| @@ -3337,9 +3337,10 @@ out_dump: | |||
| 3337 | ubifs_err("inode %lu has size %lld, but there are data at offset %lld " | 3337 | ubifs_err("inode %lu has size %lld, but there are data at offset %lld " |
| 3338 | "(data key %s)", (unsigned long)inode->i_ino, size, | 3338 | "(data key %s)", (unsigned long)inode->i_ino, size, |
| 3339 | ((loff_t)block) << UBIFS_BLOCK_SHIFT, DBGKEY(key)); | 3339 | ((loff_t)block) << UBIFS_BLOCK_SHIFT, DBGKEY(key)); |
| 3340 | mutex_unlock(&c->tnc_mutex); | ||
| 3340 | dbg_dump_inode(c, inode); | 3341 | dbg_dump_inode(c, inode); |
| 3341 | dbg_dump_stack(); | 3342 | dbg_dump_stack(); |
| 3342 | err = -EINVAL; | 3343 | return -EINVAL; |
| 3343 | 3344 | ||
| 3344 | out_unlock: | 3345 | out_unlock: |
| 3345 | mutex_unlock(&c->tnc_mutex); | 3346 | mutex_unlock(&c->tnc_mutex); |
