aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/ufs/inode.c34
-rw-r--r--fs/ufs/namei.c6
-rw-r--r--fs/ufs/super.c14
-rw-r--r--fs/ufs/ufs.h2
4 files changed, 33 insertions, 23 deletions
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
index 4320782761ae..489f26bc26d9 100644
--- a/fs/ufs/inode.c
+++ b/fs/ufs/inode.c
@@ -714,26 +714,30 @@ static int ufs2_read_inode(struct inode *inode, struct ufs2_inode *ufs2_inode)
714 return 0; 714 return 0;
715} 715}
716 716
717void ufs_read_inode(struct inode * inode) 717struct inode *ufs_iget(struct super_block *sb, unsigned long ino)
718{ 718{
719 struct ufs_inode_info *ufsi = UFS_I(inode); 719 struct ufs_inode_info *ufsi;
720 struct super_block * sb; 720 struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi;
721 struct ufs_sb_private_info * uspi;
722 struct buffer_head * bh; 721 struct buffer_head * bh;
722 struct inode *inode;
723 int err; 723 int err;
724 724
725 UFSD("ENTER, ino %lu\n", inode->i_ino); 725 UFSD("ENTER, ino %lu\n", ino);
726
727 sb = inode->i_sb;
728 uspi = UFS_SB(sb)->s_uspi;
729 726
730 if (inode->i_ino < UFS_ROOTINO || 727 if (ino < UFS_ROOTINO || ino > (uspi->s_ncg * uspi->s_ipg)) {
731 inode->i_ino > (uspi->s_ncg * uspi->s_ipg)) {
732 ufs_warning(sb, "ufs_read_inode", "bad inode number (%lu)\n", 728 ufs_warning(sb, "ufs_read_inode", "bad inode number (%lu)\n",
733 inode->i_ino); 729 ino);
734 goto bad_inode; 730 return ERR_PTR(-EIO);
735 } 731 }
736 732
733 inode = iget_locked(sb, ino);
734 if (!inode)
735 return ERR_PTR(-ENOMEM);
736 if (!(inode->i_state & I_NEW))
737 return inode;
738
739 ufsi = UFS_I(inode);
740
737 bh = sb_bread(sb, uspi->s_sbbase + ufs_inotofsba(inode->i_ino)); 741 bh = sb_bread(sb, uspi->s_sbbase + ufs_inotofsba(inode->i_ino));
738 if (!bh) { 742 if (!bh) {
739 ufs_warning(sb, "ufs_read_inode", "unable to read inode %lu\n", 743 ufs_warning(sb, "ufs_read_inode", "unable to read inode %lu\n",
@@ -765,10 +769,12 @@ void ufs_read_inode(struct inode * inode)
765 brelse(bh); 769 brelse(bh);
766 770
767 UFSD("EXIT\n"); 771 UFSD("EXIT\n");
768 return; 772 unlock_new_inode(inode);
773 return inode;
769 774
770bad_inode: 775bad_inode:
771 make_bad_inode(inode); 776 iget_failed(inode);
777 return ERR_PTR(-EIO);
772} 778}
773 779
774static void ufs1_update_inode(struct inode *inode, struct ufs_inode *ufs_inode) 780static void ufs1_update_inode(struct inode *inode, struct ufs_inode *ufs_inode)
diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c
index d8bfbee2fe2b..747a4de6c695 100644
--- a/fs/ufs/namei.c
+++ b/fs/ufs/namei.c
@@ -57,10 +57,10 @@ static struct dentry *ufs_lookup(struct inode * dir, struct dentry *dentry, stru
57 lock_kernel(); 57 lock_kernel();
58 ino = ufs_inode_by_name(dir, dentry); 58 ino = ufs_inode_by_name(dir, dentry);
59 if (ino) { 59 if (ino) {
60 inode = iget(dir->i_sb, ino); 60 inode = ufs_iget(dir->i_sb, ino);
61 if (!inode) { 61 if (IS_ERR(inode)) {
62 unlock_kernel(); 62 unlock_kernel();
63 return ERR_PTR(-EACCES); 63 return ERR_CAST(inode);
64 } 64 }
65 } 65 }
66 unlock_kernel(); 66 unlock_kernel();
diff --git a/fs/ufs/super.c b/fs/ufs/super.c
index 0072cb33ebec..73deff475e63 100644
--- a/fs/ufs/super.c
+++ b/fs/ufs/super.c
@@ -633,6 +633,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent)
633 unsigned block_size, super_block_size; 633 unsigned block_size, super_block_size;
634 unsigned flags; 634 unsigned flags;
635 unsigned super_block_offset; 635 unsigned super_block_offset;
636 int ret = -EINVAL;
636 637
637 uspi = NULL; 638 uspi = NULL;
638 ubh = NULL; 639 ubh = NULL;
@@ -1065,12 +1066,16 @@ magic_found:
1065 uspi->s_maxsymlinklen = 1066 uspi->s_maxsymlinklen =
1066 fs32_to_cpu(sb, usb3->fs_un2.fs_44.fs_maxsymlinklen); 1067 fs32_to_cpu(sb, usb3->fs_un2.fs_44.fs_maxsymlinklen);
1067 1068
1068 inode = iget(sb, UFS_ROOTINO); 1069 inode = ufs_iget(sb, UFS_ROOTINO);
1069 if (!inode || is_bad_inode(inode)) 1070 if (IS_ERR(inode)) {
1071 ret = PTR_ERR(inode);
1070 goto failed; 1072 goto failed;
1073 }
1071 sb->s_root = d_alloc_root(inode); 1074 sb->s_root = d_alloc_root(inode);
1072 if (!sb->s_root) 1075 if (!sb->s_root) {
1076 ret = -ENOMEM;
1073 goto dalloc_failed; 1077 goto dalloc_failed;
1078 }
1074 1079
1075 ufs_setup_cstotal(sb); 1080 ufs_setup_cstotal(sb);
1076 /* 1081 /*
@@ -1092,7 +1097,7 @@ failed:
1092 kfree(sbi); 1097 kfree(sbi);
1093 sb->s_fs_info = NULL; 1098 sb->s_fs_info = NULL;
1094 UFSD("EXIT (FAILED)\n"); 1099 UFSD("EXIT (FAILED)\n");
1095 return -EINVAL; 1100 return ret;
1096 1101
1097failed_nomem: 1102failed_nomem:
1098 UFSD("EXIT (NOMEM)\n"); 1103 UFSD("EXIT (NOMEM)\n");
@@ -1326,7 +1331,6 @@ static ssize_t ufs_quota_write(struct super_block *, int, const char *, size_t,
1326static const struct super_operations ufs_super_ops = { 1331static const struct super_operations ufs_super_ops = {
1327 .alloc_inode = ufs_alloc_inode, 1332 .alloc_inode = ufs_alloc_inode,
1328 .destroy_inode = ufs_destroy_inode, 1333 .destroy_inode = ufs_destroy_inode,
1329 .read_inode = ufs_read_inode,
1330 .write_inode = ufs_write_inode, 1334 .write_inode = ufs_write_inode,
1331 .delete_inode = ufs_delete_inode, 1335 .delete_inode = ufs_delete_inode,
1332 .put_super = ufs_put_super, 1336 .put_super = ufs_put_super,
diff --git a/fs/ufs/ufs.h b/fs/ufs/ufs.h
index 7faa4cd71a27..fcb9231bb9ed 100644
--- a/fs/ufs/ufs.h
+++ b/fs/ufs/ufs.h
@@ -106,7 +106,7 @@ extern void ufs_free_inode (struct inode *inode);
106extern struct inode * ufs_new_inode (struct inode *, int); 106extern struct inode * ufs_new_inode (struct inode *, int);
107 107
108/* inode.c */ 108/* inode.c */
109extern void ufs_read_inode (struct inode *); 109extern struct inode *ufs_iget(struct super_block *, unsigned long);
110extern void ufs_put_inode (struct inode *); 110extern void ufs_put_inode (struct inode *);
111extern int ufs_write_inode (struct inode *, int); 111extern int ufs_write_inode (struct inode *, int);
112extern int ufs_sync_inode (struct inode *); 112extern int ufs_sync_inode (struct inode *);