mpc83xx: cosmetic: MERGERBOX.h checkpatch compliance
[oweals/u-boot.git] / fs / ext2 / ext2fs.c
index d54f60b30b9397f6955b9c26df98eeb1f2cd6675..e119e1388fdde57a7f82cc35317ba8abb33cc658 100644 (file)
@@ -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
@@ -367,7 +364,7 @@ static int ext2fs_read_block (ext2fs_node_t node, int fileblock) {
                        indir2_size = blksz;
                }
                if ((__le32_to_cpu (indir1_block[rblock / perblock]) <<
-                    log2_blksz) != indir1_blkno) {
+                    log2_blksz) != indir2_blkno) {
                        status = ext2fs_devread (__le32_to_cpu(indir1_block[rblock / perblock]) << log2_blksz,
                                                 0, blksz,
                                                 (char *) indir2_block);
@@ -752,7 +749,7 @@ int ext2fs_find_file
 }
 
 
-int ext2fs_ls (char *dirname) {
+int ext2fs_ls (const char *dirname) {
        ext2fs_node_t dirnode;
        int status;
 
@@ -772,7 +769,7 @@ int ext2fs_ls (char *dirname) {
 }
 
 
-int ext2fs_open (char *filename) {
+int ext2fs_open (const char *filename) {
        ext2fs_node_t fdiro = NULL;
        int status;
        int len;
@@ -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;