summaryrefslogtreecommitdiff
path: root/fs/ext2
diff options
context:
space:
mode:
authorMichael Brandt <Michael.Brandt@emsyso.de>2009-11-22 14:13:27 +0100
committerWolfgang Denk <wd@denx.de>2009-12-05 00:46:10 +0100
commit270737acca21f3939f814de5dcf350a1c3d80d83 (patch)
tree0c29ea3b1826919b3eb8fbc747be509352683bf4 /fs/ext2
parentbcb324d68f7955c1136dafc944eb55db8ebaa601 (diff)
downloadu-boot-imx-270737acca21f3939f814de5dcf350a1c3d80d83.zip
u-boot-imx-270737acca21f3939f814de5dcf350a1c3d80d83.tar.gz
u-boot-imx-270737acca21f3939f814de5dcf350a1c3d80d83.tar.bz2
EXT2FS: fix inode size for ext2fs rev#0
extfs.c assumes that there is always a valid inode_size field in the superblock. But this is not true for ext2fs rev 0. Such ext2fs images are for instance generated by genext2fs. Symptoms on ARM machines are messages like: "raise: Signal # 8 caught"; on PowerPC "ext2ls" will print nothing. This fix checks for rev 0 and uses then 128 bytes as inode size. Signed-off-by: Michael Brandt <Michael.Brandt@emsyso.de> Tested on: TQM5200S Tested-by: Wolfgang Denk <wd@denx.de> Signed-off-by: Wolfgang Denk <wd@denx.de>
Diffstat (limited to 'fs/ext2')
-rw-r--r--fs/ext2/ext2fs.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/fs/ext2/ext2fs.c b/fs/ext2/ext2fs.c
index d54f60b..4b391d6 100644
--- a/fs/ext2/ext2fs.c
+++ b/fs/ext2/ext2fs.c
@@ -178,6 +178,7 @@ int indir1_blkno = -1;
uint32_t *indir2_block = NULL;
int indir2_size = 0;
int indir2_blkno = -1;
+static unsigned int inode_size;
static int ext2fs_blockgroup
@@ -212,7 +213,7 @@ static int ext2fs_read_inode
unsigned int blkoff;
#ifdef DEBUG
- printf ("ext2fs read inode %d\n", ino);
+ printf ("ext2fs read inode %d, inode_size %d\n", ino, inode_size);
#endif
/* It is easier to calculate if the first inode is 0. */
ino--;
@@ -222,16 +223,12 @@ static int ext2fs_read_inode
return (0);
}
- inodes_per_block = EXT2_BLOCK_SIZE(data) / __le16_to_cpu(sblock->inode_size);
-
-#ifdef DEBUG
- printf ("ext2fs read inode blkno %d blkoff %d\n", blkno, blkoff);
-#endif
+ inodes_per_block = EXT2_BLOCK_SIZE(data) / inode_size;
blkno = __le32_to_cpu (blkgrp.inode_table_id) +
(ino % __le32_to_cpu (sblock->inodes_per_group))
/ inodes_per_block;
- blkoff = (ino % inodes_per_block) * __le16_to_cpu (sblock->inode_size);
+ blkoff = (ino % inodes_per_block) * inode_size;
#ifdef DEBUG
printf ("ext2fs read inode blkno %d blkoff %d\n", blkno, blkoff);
#endif
@@ -863,6 +860,15 @@ int ext2fs_mount (unsigned part_length) {
if (__le16_to_cpu (data->sblock.magic) != EXT2_MAGIC) {
goto fail;
}
+ if (__le32_to_cpu(data->sblock.revision_level == 0)) {
+ inode_size = 128;
+ } else {
+ inode_size = __le16_to_cpu(data->sblock.inode_size);
+ }
+#ifdef DEBUG
+ printf("EXT2 rev %d, inode_size %d\n",
+ __le32_to_cpu(data->sblock.revision_level), inode_size);
+#endif
data->diropen.data = data;
data->diropen.ino = 2;
data->diropen.inode_read = 1;