All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] EXT2FS: fix inode size for ext2fs rev#0
@ 2009-11-22 13:13 Michael Brandt
  2009-11-25  2:53 ` Dan Christensen
  2009-12-04 23:46 ` Wolfgang Denk
  0 siblings, 2 replies; 3+ messages in thread
From: Michael Brandt @ 2009-11-22 13:13 UTC (permalink / raw)
  To: u-boot

From: Michael Brandt <Michael.Brandt@emsyso.de>

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"
This fix checks for rev 0 and uses then 128 bytes as inode size.

Signed-off-by: Michael Brandt <Michael.Brandt@emsyso.de>
---
 fs/ext2/ext2fs.c |   20 +++++++++++++-------
 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;
-- 
1.6.2.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] EXT2FS: fix inode size for ext2fs rev#0
  2009-11-22 13:13 [U-Boot] [PATCH] EXT2FS: fix inode size for ext2fs rev#0 Michael Brandt
@ 2009-11-25  2:53 ` Dan Christensen
  2009-12-04 23:46 ` Wolfgang Denk
  1 sibling, 0 replies; 3+ messages in thread
From: Dan Christensen @ 2009-11-25  2:53 UTC (permalink / raw)
  To: u-boot

I tested this patch and it resolved the problems I was having with
EXT2 filesystems on my SD card.

On Sun, Nov 22, 2009 at 7:13 AM, Michael Brandt
<Michael.Brandt@emsyso.de> wrote:
> From: Michael Brandt <Michael.Brandt@emsyso.de>
>
> 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"
> This fix checks for rev 0 and uses then 128 bytes as inode size.
>
> Signed-off-by: Michael Brandt <Michael.Brandt@emsyso.de>

Thanks!
Dan

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] EXT2FS: fix inode size for ext2fs rev#0
  2009-11-22 13:13 [U-Boot] [PATCH] EXT2FS: fix inode size for ext2fs rev#0 Michael Brandt
  2009-11-25  2:53 ` Dan Christensen
@ 2009-12-04 23:46 ` Wolfgang Denk
  1 sibling, 0 replies; 3+ messages in thread
From: Wolfgang Denk @ 2009-12-04 23:46 UTC (permalink / raw)
  To: u-boot

Dear Michael Brandt,

In message <4B0938F7.8080402@emsyso.de> you wrote:
> From: Michael Brandt <Michael.Brandt@emsyso.de>
> 
> 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"
> This fix checks for rev 0 and uses then 128 bytes as inode size.
> 
> Signed-off-by: Michael Brandt <Michael.Brandt@emsyso.de>
> ---
>  fs/ext2/ext2fs.c |   20 +++++++++++++-------
>  1 files changed, 13 insertions(+), 7 deletions(-)

Tested on TQM5200S.

Applied to "master", thanks.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
After a time, you may find that "having" is not so pleasing a thing,
after all, as "wanting."  It is not logical, but it is often true.
	-- Spock, "Amok Time", stardate 3372.7

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-12-04 23:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-22 13:13 [U-Boot] [PATCH] EXT2FS: fix inode size for ext2fs rev#0 Michael Brandt
2009-11-25  2:53 ` Dan Christensen
2009-12-04 23:46 ` Wolfgang Denk

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.