aboutsummaryrefslogtreecommitdiffstats
path: root/fs/affs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/affs')
-rw-r--r--fs/affs/affs.h3
-rw-r--r--fs/affs/amigaffs.c6
-rw-r--r--fs/affs/inode.c20
-rw-r--r--fs/affs/namei.c10
-rw-r--r--fs/affs/super.c12
5 files changed, 32 insertions, 19 deletions
diff --git a/fs/affs/affs.h b/fs/affs/affs.h
index 232c69493683..d5bd497ab9cb 100644
--- a/fs/affs/affs.h
+++ b/fs/affs/affs.h
@@ -174,7 +174,8 @@ extern void affs_put_inode(struct inode *inode);
174extern void affs_drop_inode(struct inode *inode); 174extern void affs_drop_inode(struct inode *inode);
175extern void affs_delete_inode(struct inode *inode); 175extern void affs_delete_inode(struct inode *inode);
176extern void affs_clear_inode(struct inode *inode); 176extern void affs_clear_inode(struct inode *inode);
177extern void affs_read_inode(struct inode *inode); 177extern struct inode *affs_iget(struct super_block *sb,
178 unsigned long ino);
178extern int affs_write_inode(struct inode *inode, int); 179extern int affs_write_inode(struct inode *inode, int);
179extern int affs_add_entry(struct inode *dir, struct inode *inode, struct dentry *dentry, s32 type); 180extern int affs_add_entry(struct inode *dir, struct inode *inode, struct dentry *dentry, s32 type);
180 181
diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c
index f4de4b98004f..805573005de6 100644
--- a/fs/affs/amigaffs.c
+++ b/fs/affs/amigaffs.c
@@ -170,9 +170,11 @@ affs_remove_link(struct dentry *dentry)
170 if (!link_bh) 170 if (!link_bh)
171 goto done; 171 goto done;
172 172
173 dir = iget(sb, be32_to_cpu(AFFS_TAIL(sb, link_bh)->parent)); 173 dir = affs_iget(sb, be32_to_cpu(AFFS_TAIL(sb, link_bh)->parent));
174 if (!dir) 174 if (IS_ERR(dir)) {
175 retval = PTR_ERR(dir);
175 goto done; 176 goto done;
177 }
176 178
177 affs_lock_dir(dir); 179 affs_lock_dir(dir);
178 affs_fix_dcache(dentry, link_ino); 180 affs_fix_dcache(dentry, link_ino);
diff --git a/fs/affs/inode.c b/fs/affs/inode.c
index 4609a6c13fe9..27fe6cbe43ae 100644
--- a/fs/affs/inode.c
+++ b/fs/affs/inode.c
@@ -15,20 +15,25 @@
15extern const struct inode_operations affs_symlink_inode_operations; 15extern const struct inode_operations affs_symlink_inode_operations;
16extern struct timezone sys_tz; 16extern struct timezone sys_tz;
17 17
18void 18struct inode *affs_iget(struct super_block *sb, unsigned long ino)
19affs_read_inode(struct inode *inode)
20{ 19{
21 struct super_block *sb = inode->i_sb;
22 struct affs_sb_info *sbi = AFFS_SB(sb); 20 struct affs_sb_info *sbi = AFFS_SB(sb);
23 struct buffer_head *bh; 21 struct buffer_head *bh;
24 struct affs_head *head; 22 struct affs_head *head;
25 struct affs_tail *tail; 23 struct affs_tail *tail;
24 struct inode *inode;
26 u32 block; 25 u32 block;
27 u32 size; 26 u32 size;
28 u32 prot; 27 u32 prot;
29 u16 id; 28 u16 id;
30 29
31 pr_debug("AFFS: read_inode(%lu)\n",inode->i_ino); 30 inode = iget_locked(sb, ino);
31 if (!inode)
32 return ERR_PTR(-ENOMEM);
33 if (!(inode->i_state & I_NEW))
34 return inode;
35
36 pr_debug("AFFS: affs_iget(%lu)\n", inode->i_ino);
32 37
33 block = inode->i_ino; 38 block = inode->i_ino;
34 bh = affs_bread(sb, block); 39 bh = affs_bread(sb, block);
@@ -154,12 +159,13 @@ affs_read_inode(struct inode *inode)
154 sys_tz.tz_minuteswest * 60; 159 sys_tz.tz_minuteswest * 60;
155 inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec = inode->i_atime.tv_nsec = 0; 160 inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec = inode->i_atime.tv_nsec = 0;
156 affs_brelse(bh); 161 affs_brelse(bh);
157 return; 162 unlock_new_inode(inode);
163 return inode;
158 164
159bad_inode: 165bad_inode:
160 make_bad_inode(inode);
161 affs_brelse(bh); 166 affs_brelse(bh);
162 return; 167 iget_failed(inode);
168 return ERR_PTR(-EIO);
163} 169}
164 170
165int 171int
diff --git a/fs/affs/namei.c b/fs/affs/namei.c
index b407e9eea3fb..2218f1ee71ce 100644
--- a/fs/affs/namei.c
+++ b/fs/affs/namei.c
@@ -208,9 +208,8 @@ affs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
208 affs_lock_dir(dir); 208 affs_lock_dir(dir);
209 bh = affs_find_entry(dir, dentry); 209 bh = affs_find_entry(dir, dentry);
210 affs_unlock_dir(dir); 210 affs_unlock_dir(dir);
211 if (IS_ERR(bh)) { 211 if (IS_ERR(bh))
212 return ERR_CAST(bh); 212 return ERR_CAST(bh);
213 }
214 if (bh) { 213 if (bh) {
215 u32 ino = bh->b_blocknr; 214 u32 ino = bh->b_blocknr;
216 215
@@ -223,10 +222,9 @@ affs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
223 ino = be32_to_cpu(AFFS_TAIL(sb, bh)->original); 222 ino = be32_to_cpu(AFFS_TAIL(sb, bh)->original);
224 } 223 }
225 affs_brelse(bh); 224 affs_brelse(bh);
226 inode = iget(sb, ino); 225 inode = affs_iget(sb, ino);
227 if (!inode) { 226 if (IS_ERR(inode))
228 return ERR_PTR(-EACCES); 227 return ERR_PTR(PTR_ERR(inode));
229 }
230 } 228 }
231 dentry->d_op = AFFS_SB(sb)->s_flags & SF_INTL ? &affs_intl_dentry_operations : &affs_dentry_operations; 229 dentry->d_op = AFFS_SB(sb)->s_flags & SF_INTL ? &affs_intl_dentry_operations : &affs_dentry_operations;
232 d_add(dentry, inode); 230 d_add(dentry, inode);
diff --git a/fs/affs/super.c b/fs/affs/super.c
index b53e5d0ec65c..3c45d49c0d26 100644
--- a/fs/affs/super.c
+++ b/fs/affs/super.c
@@ -113,7 +113,6 @@ static void destroy_inodecache(void)
113static const struct super_operations affs_sops = { 113static const struct super_operations affs_sops = {
114 .alloc_inode = affs_alloc_inode, 114 .alloc_inode = affs_alloc_inode,
115 .destroy_inode = affs_destroy_inode, 115 .destroy_inode = affs_destroy_inode,
116 .read_inode = affs_read_inode,
117 .write_inode = affs_write_inode, 116 .write_inode = affs_write_inode,
118 .put_inode = affs_put_inode, 117 .put_inode = affs_put_inode,
119 .drop_inode = affs_drop_inode, 118 .drop_inode = affs_drop_inode,
@@ -271,6 +270,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)
271 unsigned long mount_flags; 270 unsigned long mount_flags;
272 int tmp_flags; /* fix remount prototype... */ 271 int tmp_flags; /* fix remount prototype... */
273 u8 sig[4]; 272 u8 sig[4];
273 int ret = -EINVAL;
274 274
275 pr_debug("AFFS: read_super(%s)\n",data ? (const char *)data : "no options"); 275 pr_debug("AFFS: read_super(%s)\n",data ? (const char *)data : "no options");
276 276
@@ -444,7 +444,12 @@ got_root:
444 444
445 /* set up enough so that it can read an inode */ 445 /* set up enough so that it can read an inode */
446 446
447 root_inode = iget(sb, root_block); 447 root_inode = affs_iget(sb, root_block);
448 if (IS_ERR(root_inode)) {
449 ret = PTR_ERR(root_inode);
450 goto out_error_noinode;
451 }
452
448 sb->s_root = d_alloc_root(root_inode); 453 sb->s_root = d_alloc_root(root_inode);
449 if (!sb->s_root) { 454 if (!sb->s_root) {
450 printk(KERN_ERR "AFFS: Get root inode failed\n"); 455 printk(KERN_ERR "AFFS: Get root inode failed\n");
@@ -461,12 +466,13 @@ got_root:
461out_error: 466out_error:
462 if (root_inode) 467 if (root_inode)
463 iput(root_inode); 468 iput(root_inode);
469out_error_noinode:
464 kfree(sbi->s_bitmap); 470 kfree(sbi->s_bitmap);
465 affs_brelse(root_bh); 471 affs_brelse(root_bh);
466 kfree(sbi->s_prefix); 472 kfree(sbi->s_prefix);
467 kfree(sbi); 473 kfree(sbi);
468 sb->s_fs_info = NULL; 474 sb->s_fs_info = NULL;
469 return -EINVAL; 475 return ret;
470} 476}
471 477
472static int 478static int