[coreboot] [FILO] r106 - trunk/filo/fs
svn at coreboot.org
svn at coreboot.org
Wed Sep 23 16:12:31 CEST 2009
Author: stuge
Date: 2009-09-23 16:12:31 +0200 (Wed, 23 Sep 2009)
New Revision: 106
Modified:
trunk/filo/fs/fsys_ext2fs.c
Log:
Fix EXT2_INODE_SIZE() for original format ext2 filesystems
This patch applies against r104 of filo and allows older versions of
ext2 file systems to be accessed. The problem with the current code is
that EXT2_INODE_SIZE() returns 0 for these file systems and the
EXT2_INODES_PER_BLOCK() uses that value in a calculation which causes a
div0 and sends the machine to reboot.
Below is a fix for that.
Signed-off-by: Daniel Mack <daniel at caiaq.de>
Acked-by: Peter Stuge <peter at stuge.se>
Modified: trunk/filo/fs/fsys_ext2fs.c
===================================================================
--- trunk/filo/fs/fsys_ext2fs.c 2009-08-27 22:52:37 UTC (rev 105)
+++ trunk/filo/fs/fsys_ext2fs.c 2009-09-23 14:12:31 UTC (rev 106)
@@ -253,10 +253,16 @@
((char *)((char *)DATABLOCK1 + EXT2_BLOCK_SIZE(SUPERBLOCK)))
/* linux/ext2_fs.h */
+#define EXT2_OLD_REV 0 /* The good old (original) format */
+#define EXT2_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */
+
+#define EXT2_OLD_INODE_SIZE 128
+
#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (__u32))
#define EXT2_ADDR_PER_BLOCK_BITS(s) (log2(EXT2_ADDR_PER_BLOCK(s)))
-#define EXT2_INODE_SIZE(s) (SUPERBLOCK->s_inode_size)
+#define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_OLD_REV) ? \
+ EXT2_OLD_INODE_SIZE : (s)->s_inode_size)
#define EXT2_INODES_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s)/EXT2_INODE_SIZE(s))
/* linux/ext2_fs.h */
@@ -287,6 +293,7 @@
printf(" b_free=%d\n", le32_to_cpu(s->s_free_blocks_count));
printf(" first=%d\n", le32_to_cpu(s->s_first_data_block));
printf(" log_b_size=%d, b_size=%d\n", le32_to_cpu(s->s_log_block_size), EXT2_BLOCK_SIZE(s));
+ printf(" inode_size=%d\n", le32_to_cpu(EXT2_INODE_SIZE(s)));
printf(" log_f_size=%d\n", le32_to_cpu(s->s_log_frag_size));
printf(" bpg=%d\n", le32_to_cpu(s->s_blocks_per_group));
printf(" fpg=%d\n", le32_to_cpu(s->s_frags_per_group));
More information about the coreboot
mailing list