@@ -35,7 +35,7 @@ static int befs_get_block(struct inode *, sector_t, struct buffer_head *, int);
35
35
static int befs_readpage (struct file * file , struct page * page );
36
36
static sector_t befs_bmap (struct address_space * mapping , sector_t block );
37
37
static struct dentry * befs_lookup (struct inode * , struct dentry * , struct nameidata * );
38
- static void befs_read_inode (struct inode * ino );
38
+ static struct inode * befs_iget (struct super_block * , unsigned long );
39
39
static struct inode * befs_alloc_inode (struct super_block * sb );
40
40
static void befs_destroy_inode (struct inode * inode );
41
41
static int befs_init_inodecache (void );
@@ -52,7 +52,6 @@ static int befs_statfs(struct dentry *, struct kstatfs *);
52
52
static int parse_options (char * , befs_mount_options * );
53
53
54
54
static const struct super_operations befs_sops = {
55
- .read_inode = befs_read_inode , /* initialize & read inode */
56
55
.alloc_inode = befs_alloc_inode , /* allocate a new inode */
57
56
.destroy_inode = befs_destroy_inode , /* deallocate an inode */
58
57
.put_super = befs_put_super , /* uninit super */
@@ -198,9 +197,9 @@ befs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
198
197
return ERR_PTR (- ENODATA );
199
198
}
200
199
201
- inode = iget (dir -> i_sb , (ino_t ) offset );
202
- if (! inode )
203
- return ERR_PTR ( - EACCES );
200
+ inode = befs_iget (dir -> i_sb , (ino_t ) offset );
201
+ if (IS_ERR ( inode ) )
202
+ return ERR_CAST ( inode );
204
203
205
204
d_add (dentry , inode );
206
205
@@ -296,17 +295,23 @@ static void init_once(struct kmem_cache *cachep, void *foo)
296
295
inode_init_once (& bi -> vfs_inode );
297
296
}
298
297
299
- static void
300
- befs_read_inode (struct inode * inode )
298
+ static struct inode * befs_iget (struct super_block * sb , unsigned long ino )
301
299
{
302
300
struct buffer_head * bh = NULL ;
303
301
befs_inode * raw_inode = NULL ;
304
302
305
- struct super_block * sb = inode -> i_sb ;
306
303
befs_sb_info * befs_sb = BEFS_SB (sb );
307
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
316
befs_ino = BEFS_I (inode );
312
317
@@ -402,15 +407,16 @@ befs_read_inode(struct inode *inode)
402
407
403
408
brelse (bh );
404
409
befs_debug (sb , "<--- befs_read_inode()" );
405
- return ;
410
+ unlock_new_inode (inode );
411
+ return inode ;
406
412
407
413
unacquire_bh :
408
414
brelse (bh );
409
415
410
416
unacquire_none :
411
- make_bad_inode (inode );
417
+ iget_failed (inode );
412
418
befs_debug (sb , "<--- befs_read_inode() - Bad inode" );
413
- return ;
419
+ return ERR_PTR ( ret ) ;
414
420
}
415
421
416
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
758
befs_sb_info * befs_sb ;
753
759
befs_super_block * disk_sb ;
754
760
struct inode * root ;
761
+ long ret = - EINVAL ;
755
762
756
763
const unsigned long sb_block = 0 ;
757
764
const off_t x86_sb_off = 512 ;
@@ -833,7 +840,11 @@ befs_fill_super(struct super_block *sb, void *data, int silent)
833
840
/* Set real blocksize of fs */
834
841
sb_set_blocksize (sb , (ulong ) befs_sb -> block_size );
835
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
848
sb -> s_root = d_alloc_root (root );
838
849
if (!sb -> s_root ) {
839
850
iput (root );
@@ -868,7 +879,7 @@ befs_fill_super(struct super_block *sb, void *data, int silent)
868
879
869
880
unacquire_none :
870
881
sb -> s_fs_info = NULL ;
871
- return - EINVAL ;
882
+ return ret ;
872
883
}
873
884
874
885
static int
0 commit comments