aboutsummaryrefslogtreecommitdiffstats
path: root/fs/befs/linuxvfs.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2008-02-07 03:15:31 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-07 11:42:27 -0500
commit96eb5419412fbc7f39fa45d987034c5d0e6e1202 (patch)
tree34a6ad2f777cb4f29ab5f2ca413dc9fef94d91bd /fs/befs/linuxvfs.c
parent62328a02399ea7f1b26b06d757abe67b9cf48193 (diff)
iget: stop BEFS from using iget() and read_inode()
Stop the BEFS filesystem from using iget() and read_inode(). Replace befs_read_inode() with befs_iget(), and call that instead of iget(). befs_iget() then uses iget_locked() directly and returns a proper error code instead of an inode in the event of an error. befs_fill_super() returns any error incurred when getting the root inode instead of EINVAL. Signed-off-by: David Howells <dhowells@redhat.com> Acked-by: Will Dyson <will_dyson@pobox.com> Acked-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/befs/linuxvfs.c')
-rw-r--r--fs/befs/linuxvfs.c39
1 files changed, 25 insertions, 14 deletions
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index b28a20e61b80..403fe661c144 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -35,7 +35,7 @@ static int befs_get_block(struct inode *, sector_t, struct buffer_head *, int);
35static int befs_readpage(struct file *file, struct page *page); 35static int befs_readpage(struct file *file, struct page *page);
36static sector_t befs_bmap(struct address_space *mapping, sector_t block); 36static sector_t befs_bmap(struct address_space *mapping, sector_t block);
37static struct dentry *befs_lookup(struct inode *, struct dentry *, struct nameidata *); 37static struct dentry *befs_lookup(struct inode *, struct dentry *, struct nameidata *);
38static void befs_read_inode(struct inode *ino); 38static struct inode *befs_iget(struct super_block *, unsigned long);
39static struct inode *befs_alloc_inode(struct super_block *sb); 39static struct inode *befs_alloc_inode(struct super_block *sb);
40static void befs_destroy_inode(struct inode *inode); 40static void befs_destroy_inode(struct inode *inode);
41static int befs_init_inodecache(void); 41static int befs_init_inodecache(void);
@@ -52,7 +52,6 @@ static int befs_statfs(struct dentry *, struct kstatfs *);
52static int parse_options(char *, befs_mount_options *); 52static int parse_options(char *, befs_mount_options *);
53 53
54static const struct super_operations befs_sops = { 54static const struct super_operations befs_sops = {
55 .read_inode = befs_read_inode, /* initialize & read inode */
56 .alloc_inode = befs_alloc_inode, /* allocate a new inode */ 55 .alloc_inode = befs_alloc_inode, /* allocate a new inode */
57 .destroy_inode = befs_destroy_inode, /* deallocate an inode */ 56 .destroy_inode = befs_destroy_inode, /* deallocate an inode */
58 .put_super = befs_put_super, /* uninit super */ 57 .put_super = befs_put_super, /* uninit super */
@@ -198,9 +197,9 @@ befs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
198 return ERR_PTR(-ENODATA); 197 return ERR_PTR(-ENODATA);
199 } 198 }
200 199
201 inode = iget(dir->i_sb, (ino_t) offset); 200 inode = befs_iget(dir->i_sb, (ino_t) offset);
202 if (!inode) 201 if (IS_ERR(inode))
203 return ERR_PTR(-EACCES); 202 return ERR_CAST(inode);
204 203
205 d_add(dentry, inode); 204 d_add(dentry, inode);
206 205
@@ -296,17 +295,23 @@ static void init_once(struct kmem_cache *cachep, void *foo)
296 inode_init_once(&bi->vfs_inode); 295 inode_init_once(&bi->vfs_inode);
297} 296}
298 297
299static void 298static struct inode *befs_iget(struct super_block *sb, unsigned long ino)
300befs_read_inode(struct inode *inode)
301{ 299{
302 struct buffer_head *bh = NULL; 300 struct buffer_head *bh = NULL;
303 befs_inode *raw_inode = NULL; 301 befs_inode *raw_inode = NULL;
304 302
305 struct super_block *sb = inode->i_sb;
306 befs_sb_info *befs_sb = BEFS_SB(sb); 303 befs_sb_info *befs_sb = BEFS_SB(sb);
307 befs_inode_info *befs_ino = NULL; 304 befs_inode_info *befs_ino = NULL;
305 struct inode *inode;
306 long ret = -EIO;
308 307
309 befs_debug(sb, "---> befs_read_inode() " "inode = %lu", inode->i_ino); 308 befs_debug(sb, "---> befs_read_inode() " "inode = %lu", ino);
309
310 inode = iget_locked(sb, ino);
311 if (IS_ERR(inode))
312 return inode;
313 if (!(inode->i_state & I_NEW))
314 return inode;
310 315
311 befs_ino = BEFS_I(inode); 316 befs_ino = BEFS_I(inode);
312 317
@@ -402,15 +407,16 @@ befs_read_inode(struct inode *inode)
402 407
403 brelse(bh); 408 brelse(bh);
404 befs_debug(sb, "<--- befs_read_inode()"); 409 befs_debug(sb, "<--- befs_read_inode()");
405 return; 410 unlock_new_inode(inode);
411 return inode;
406 412
407 unacquire_bh: 413 unacquire_bh:
408 brelse(bh); 414 brelse(bh);
409 415
410 unacquire_none: 416 unacquire_none:
411 make_bad_inode(inode); 417 iget_failed(inode);
412 befs_debug(sb, "<--- befs_read_inode() - Bad inode"); 418 befs_debug(sb, "<--- befs_read_inode() - Bad inode");
413 return; 419 return ERR_PTR(ret);
414} 420}
415 421
416/* Initialize the inode cache. Called at fs setup. 422/* Initialize the inode cache. Called at fs setup.
@@ -752,6 +758,7 @@ befs_fill_super(struct super_block *sb, void *data, int silent)
752 befs_sb_info *befs_sb; 758 befs_sb_info *befs_sb;
753 befs_super_block *disk_sb; 759 befs_super_block *disk_sb;
754 struct inode *root; 760 struct inode *root;
761 long ret = -EINVAL;
755 762
756 const unsigned long sb_block = 0; 763 const unsigned long sb_block = 0;
757 const off_t x86_sb_off = 512; 764 const off_t x86_sb_off = 512;
@@ -833,7 +840,11 @@ befs_fill_super(struct super_block *sb, void *data, int silent)
833 /* Set real blocksize of fs */ 840 /* Set real blocksize of fs */
834 sb_set_blocksize(sb, (ulong) befs_sb->block_size); 841 sb_set_blocksize(sb, (ulong) befs_sb->block_size);
835 sb->s_op = (struct super_operations *) &befs_sops; 842 sb->s_op = (struct super_operations *) &befs_sops;
836 root = iget(sb, iaddr2blockno(sb, &(befs_sb->root_dir))); 843 root = befs_iget(sb, iaddr2blockno(sb, &(befs_sb->root_dir)));
844 if (IS_ERR(root)) {
845 ret = PTR_ERR(root);
846 goto unacquire_priv_sbp;
847 }
837 sb->s_root = d_alloc_root(root); 848 sb->s_root = d_alloc_root(root);
838 if (!sb->s_root) { 849 if (!sb->s_root) {
839 iput(root); 850 iput(root);
@@ -868,7 +879,7 @@ befs_fill_super(struct super_block *sb, void *data, int silent)
868 879
869 unacquire_none: 880 unacquire_none:
870 sb->s_fs_info = NULL; 881 sb->s_fs_info = NULL;
871 return -EINVAL; 882 return ret;
872} 883}
873 884
874static int 885static int