aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2/readinode.c
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2007-04-25 12:04:23 -0400
committerDavid Woodhouse <dwmw2@infradead.org>2007-04-25 12:04:23 -0400
commit61c4b23770d1b0cef7c06a23378ab544eb0c64b4 (patch)
treeb4cf1e784621d2f60a3494ded1d5852934107c22 /fs/jffs2/readinode.c
parentc00c310eac04a28d2143368ae988716792ed53ce (diff)
[JFFS2] Handle inodes with only a single metadata node with non-zero isize
This should never happen unless there's corruption on the medium and the actual data nodes go missing. But the failure mode (an oops when we assume the fragtree isn't empty and go looking for its last node) isn't useful. Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'fs/jffs2/readinode.c')
-rw-r--r--fs/jffs2/readinode.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c
index a42ffba2ed17..6aff38930b50 100644
--- a/fs/jffs2/readinode.c
+++ b/fs/jffs2/readinode.c
@@ -1132,7 +1132,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
1132 struct jffs2_raw_inode *latest_node) 1132 struct jffs2_raw_inode *latest_node)
1133{ 1133{
1134 struct jffs2_readinode_info rii; 1134 struct jffs2_readinode_info rii;
1135 uint32_t crc; 1135 uint32_t crc, new_size;
1136 size_t retlen; 1136 size_t retlen;
1137 int ret; 1137 int ret;
1138 1138
@@ -1233,7 +1233,12 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
1233 1233
1234 case S_IFREG: 1234 case S_IFREG:
1235 /* If it was a regular file, truncate it to the latest node's isize */ 1235 /* If it was a regular file, truncate it to the latest node's isize */
1236 jffs2_truncate_fragtree(c, &f->fragtree, je32_to_cpu(latest_node->isize)); 1236 new_size = jffs2_truncate_fragtree(c, &f->fragtree, je32_to_cpu(latest_node->isize));
1237 if (new_size != je32_to_cpu(latest_node->isize)) {
1238 JFFS2_WARNING("Truncating ino #%u to %d bytes failed because it only had %d bytes to start with!\n",
1239 f->inocache->ino, je32_to_cpu(latest_node->isize), new_size);
1240 latest_node->isize = cpu_to_je32(new_size);
1241 }
1237 break; 1242 break;
1238 1243
1239 case S_IFLNK: 1244 case S_IFLNK: