diff options
Diffstat (limited to 'fs/ext2/super.c')
-rw-r--r-- | fs/ext2/super.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 1ba18b72d43a..22f1010bf79f 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c | |||
@@ -296,7 +296,6 @@ static ssize_t ext2_quota_write(struct super_block *sb, int type, const char *da | |||
296 | static const struct super_operations ext2_sops = { | 296 | static const struct super_operations ext2_sops = { |
297 | .alloc_inode = ext2_alloc_inode, | 297 | .alloc_inode = ext2_alloc_inode, |
298 | .destroy_inode = ext2_destroy_inode, | 298 | .destroy_inode = ext2_destroy_inode, |
299 | .read_inode = ext2_read_inode, | ||
300 | .write_inode = ext2_write_inode, | 299 | .write_inode = ext2_write_inode, |
301 | .delete_inode = ext2_delete_inode, | 300 | .delete_inode = ext2_delete_inode, |
302 | .put_super = ext2_put_super, | 301 | .put_super = ext2_put_super, |
@@ -326,11 +325,10 @@ static struct inode *ext2_nfs_get_inode(struct super_block *sb, | |||
326 | * it might be "neater" to call ext2_get_inode first and check | 325 | * it might be "neater" to call ext2_get_inode first and check |
327 | * if the inode is valid..... | 326 | * if the inode is valid..... |
328 | */ | 327 | */ |
329 | inode = iget(sb, ino); | 328 | inode = ext2_iget(sb, ino); |
330 | if (inode == NULL) | 329 | if (IS_ERR(inode)) |
331 | return ERR_PTR(-ENOMEM); | 330 | return ERR_CAST(inode); |
332 | if (is_bad_inode(inode) || | 331 | if (generation && inode->i_generation != generation) { |
333 | (generation && inode->i_generation != generation)) { | ||
334 | /* we didn't find the right inode.. */ | 332 | /* we didn't find the right inode.. */ |
335 | iput(inode); | 333 | iput(inode); |
336 | return ERR_PTR(-ESTALE); | 334 | return ERR_PTR(-ESTALE); |
@@ -746,6 +744,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
746 | unsigned long logic_sb_block; | 744 | unsigned long logic_sb_block; |
747 | unsigned long offset = 0; | 745 | unsigned long offset = 0; |
748 | unsigned long def_mount_opts; | 746 | unsigned long def_mount_opts; |
747 | long ret = -EINVAL; | ||
749 | int blocksize = BLOCK_SIZE; | 748 | int blocksize = BLOCK_SIZE; |
750 | int db_count; | 749 | int db_count; |
751 | int i, j; | 750 | int i, j; |
@@ -1041,19 +1040,24 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
1041 | sb->s_op = &ext2_sops; | 1040 | sb->s_op = &ext2_sops; |
1042 | sb->s_export_op = &ext2_export_ops; | 1041 | sb->s_export_op = &ext2_export_ops; |
1043 | sb->s_xattr = ext2_xattr_handlers; | 1042 | sb->s_xattr = ext2_xattr_handlers; |
1044 | root = iget(sb, EXT2_ROOT_INO); | 1043 | root = ext2_iget(sb, EXT2_ROOT_INO); |
1045 | sb->s_root = d_alloc_root(root); | 1044 | if (IS_ERR(root)) { |
1046 | if (!sb->s_root) { | 1045 | ret = PTR_ERR(root); |
1047 | iput(root); | ||
1048 | printk(KERN_ERR "EXT2-fs: get root inode failed\n"); | ||
1049 | goto failed_mount3; | 1046 | goto failed_mount3; |
1050 | } | 1047 | } |
1051 | if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { | 1048 | if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { |
1052 | dput(sb->s_root); | 1049 | iput(root); |
1053 | sb->s_root = NULL; | ||
1054 | printk(KERN_ERR "EXT2-fs: corrupt root inode, run e2fsck\n"); | 1050 | printk(KERN_ERR "EXT2-fs: corrupt root inode, run e2fsck\n"); |
1055 | goto failed_mount3; | 1051 | goto failed_mount3; |
1056 | } | 1052 | } |
1053 | |||
1054 | sb->s_root = d_alloc_root(root); | ||
1055 | if (!sb->s_root) { | ||
1056 | iput(root); | ||
1057 | printk(KERN_ERR "EXT2-fs: get root inode failed\n"); | ||
1058 | ret = -ENOMEM; | ||
1059 | goto failed_mount3; | ||
1060 | } | ||
1057 | if (EXT2_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL)) | 1061 | if (EXT2_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL)) |
1058 | ext2_warning(sb, __FUNCTION__, | 1062 | ext2_warning(sb, __FUNCTION__, |
1059 | "mounting ext3 filesystem as ext2"); | 1063 | "mounting ext3 filesystem as ext2"); |
@@ -1080,7 +1084,7 @@ failed_mount: | |||
1080 | failed_sbi: | 1084 | failed_sbi: |
1081 | sb->s_fs_info = NULL; | 1085 | sb->s_fs_info = NULL; |
1082 | kfree(sbi); | 1086 | kfree(sbi); |
1083 | return -EINVAL; | 1087 | return ret; |
1084 | } | 1088 | } |
1085 | 1089 | ||
1086 | static void ext2_commit_super (struct super_block * sb, | 1090 | static void ext2_commit_super (struct super_block * sb, |