diff options
Diffstat (limited to 'fs/bfs')
| -rw-r--r-- | fs/bfs/bfs.h | 2 | ||||
| -rw-r--r-- | fs/bfs/dir.c | 6 | ||||
| -rw-r--r-- | fs/bfs/inode.c | 32 |
3 files changed, 27 insertions, 13 deletions
diff --git a/fs/bfs/bfs.h b/fs/bfs/bfs.h index ac7a8b1d6c3..71faf4d2390 100644 --- a/fs/bfs/bfs.h +++ b/fs/bfs/bfs.h | |||
| @@ -44,6 +44,8 @@ static inline struct bfs_inode_info *BFS_I(struct inode *inode) | |||
| 44 | #define printf(format, args...) \ | 44 | #define printf(format, args...) \ |
| 45 | printk(KERN_ERR "BFS-fs: %s(): " format, __FUNCTION__, ## args) | 45 | printk(KERN_ERR "BFS-fs: %s(): " format, __FUNCTION__, ## args) |
| 46 | 46 | ||
| 47 | /* inode.c */ | ||
| 48 | extern struct inode *bfs_iget(struct super_block *sb, unsigned long ino); | ||
| 47 | 49 | ||
| 48 | /* file.c */ | 50 | /* file.c */ |
| 49 | extern const struct inode_operations bfs_file_inops; | 51 | extern const struct inode_operations bfs_file_inops; |
diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c index 1fd056d0fc3..034950cb3cb 100644 --- a/fs/bfs/dir.c +++ b/fs/bfs/dir.c | |||
| @@ -148,10 +148,10 @@ static struct dentry *bfs_lookup(struct inode *dir, struct dentry *dentry, | |||
| 148 | if (bh) { | 148 | if (bh) { |
| 149 | unsigned long ino = (unsigned long)le16_to_cpu(de->ino); | 149 | unsigned long ino = (unsigned long)le16_to_cpu(de->ino); |
| 150 | brelse(bh); | 150 | brelse(bh); |
| 151 | inode = iget(dir->i_sb, ino); | 151 | inode = bfs_iget(dir->i_sb, ino); |
| 152 | if (!inode) { | 152 | if (IS_ERR(inode)) { |
| 153 | unlock_kernel(); | 153 | unlock_kernel(); |
| 154 | return ERR_PTR(-EACCES); | 154 | return ERR_CAST(inode); |
| 155 | } | 155 | } |
| 156 | } | 156 | } |
| 157 | unlock_kernel(); | 157 | unlock_kernel(); |
diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c index a64a71d444f..8db623838b5 100644 --- a/fs/bfs/inode.c +++ b/fs/bfs/inode.c | |||
| @@ -32,17 +32,22 @@ MODULE_LICENSE("GPL"); | |||
| 32 | 32 | ||
| 33 | void dump_imap(const char *prefix, struct super_block *s); | 33 | void dump_imap(const char *prefix, struct super_block *s); |
| 34 | 34 | ||
| 35 | static void bfs_read_inode(struct inode *inode) | 35 | struct inode *bfs_iget(struct super_block *sb, unsigned long ino) |
| 36 | { | 36 | { |
| 37 | unsigned long ino = inode->i_ino; | ||
| 38 | struct bfs_inode *di; | 37 | struct bfs_inode *di; |
| 38 | struct inode *inode; | ||
| 39 | struct buffer_head *bh; | 39 | struct buffer_head *bh; |
| 40 | int block, off; | 40 | int block, off; |
| 41 | 41 | ||
| 42 | inode = iget_locked(sb, ino); | ||
| 43 | if (IS_ERR(inode)) | ||
| 44 | return ERR_PTR(-ENOMEM); | ||
| 45 | if (!(inode->i_state & I_NEW)) | ||
| 46 | return inode; | ||
| 47 | |||
| 42 | if ((ino < BFS_ROOT_INO) || (ino > BFS_SB(inode->i_sb)->si_lasti)) { | 48 | if ((ino < BFS_ROOT_INO) || (ino > BFS_SB(inode->i_sb)->si_lasti)) { |
| 43 | printf("Bad inode number %s:%08lx\n", inode->i_sb->s_id, ino); | 49 | printf("Bad inode number %s:%08lx\n", inode->i_sb->s_id, ino); |
| 44 | make_bad_inode(inode); | 50 | goto error; |
| 45 | return; | ||
| 46 | } | 51 | } |
| 47 | 52 | ||
| 48 | block = (ino - BFS_ROOT_INO) / BFS_INODES_PER_BLOCK + 1; | 53 | block = (ino - BFS_ROOT_INO) / BFS_INODES_PER_BLOCK + 1; |
| @@ -50,8 +55,7 @@ static void bfs_read_inode(struct inode *inode) | |||
| 50 | if (!bh) { | 55 | if (!bh) { |
| 51 | printf("Unable to read inode %s:%08lx\n", inode->i_sb->s_id, | 56 | printf("Unable to read inode %s:%08lx\n", inode->i_sb->s_id, |
| 52 | ino); | 57 | ino); |
| 53 | make_bad_inode(inode); | 58 | goto error; |
| 54 | return; | ||
| 55 | } | 59 | } |
| 56 | 60 | ||
| 57 | off = (ino - BFS_ROOT_INO) % BFS_INODES_PER_BLOCK; | 61 | off = (ino - BFS_ROOT_INO) % BFS_INODES_PER_BLOCK; |
| @@ -85,6 +89,12 @@ static void bfs_read_inode(struct inode *inode) | |||
| 85 | inode->i_ctime.tv_nsec = 0; | 89 | inode->i_ctime.tv_nsec = 0; |
| 86 | 90 | ||
| 87 | brelse(bh); | 91 | brelse(bh); |
| 92 | unlock_new_inode(inode); | ||
| 93 | return inode; | ||
| 94 | |||
| 95 | error: | ||
| 96 | iget_failed(inode); | ||
| 97 | return ERR_PTR(-EIO); | ||
| 88 | } | 98 | } |
| 89 | 99 | ||
| 90 | static int bfs_write_inode(struct inode *inode, int unused) | 100 | static int bfs_write_inode(struct inode *inode, int unused) |
| @@ -276,7 +286,6 @@ static void destroy_inodecache(void) | |||
| 276 | static const struct super_operations bfs_sops = { | 286 | static const struct super_operations bfs_sops = { |
| 277 | .alloc_inode = bfs_alloc_inode, | 287 | .alloc_inode = bfs_alloc_inode, |
| 278 | .destroy_inode = bfs_destroy_inode, | 288 | .destroy_inode = bfs_destroy_inode, |
| 279 | .read_inode = bfs_read_inode, | ||
| 280 | .write_inode = bfs_write_inode, | 289 | .write_inode = bfs_write_inode, |
| 281 | .delete_inode = bfs_delete_inode, | 290 | .delete_inode = bfs_delete_inode, |
| 282 | .put_super = bfs_put_super, | 291 | .put_super = bfs_put_super, |
| @@ -312,6 +321,7 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent) | |||
| 312 | struct inode *inode; | 321 | struct inode *inode; |
| 313 | unsigned i, imap_len; | 322 | unsigned i, imap_len; |
| 314 | struct bfs_sb_info *info; | 323 | struct bfs_sb_info *info; |
| 324 | long ret = -EINVAL; | ||
| 315 | 325 | ||
| 316 | info = kzalloc(sizeof(*info), GFP_KERNEL); | 326 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
| 317 | if (!info) | 327 | if (!info) |
| @@ -346,14 +356,16 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent) | |||
| 346 | set_bit(i, info->si_imap); | 356 | set_bit(i, info->si_imap); |
| 347 | 357 | ||
| 348 | s->s_op = &bfs_sops; | 358 | s->s_op = &bfs_sops; |
| 349 | inode = iget(s, BFS_ROOT_INO); | 359 | inode = bfs_iget(s, BFS_ROOT_INO); |
| 350 | if (!inode) { | 360 | if (IS_ERR(inode)) { |
| 361 | ret = PTR_ERR(inode); | ||
| 351 | kfree(info->si_imap); | 362 | kfree(info->si_imap); |
| 352 | goto out; | 363 | goto out; |
| 353 | } | 364 | } |
| 354 | s->s_root = d_alloc_root(inode); | 365 | s->s_root = d_alloc_root(inode); |
| 355 | if (!s->s_root) { | 366 | if (!s->s_root) { |
| 356 | iput(inode); | 367 | iput(inode); |
| 368 | ret = -ENOMEM; | ||
| 357 | kfree(info->si_imap); | 369 | kfree(info->si_imap); |
| 358 | goto out; | 370 | goto out; |
| 359 | } | 371 | } |
| @@ -404,7 +416,7 @@ out: | |||
| 404 | brelse(bh); | 416 | brelse(bh); |
| 405 | kfree(info); | 417 | kfree(info); |
| 406 | s->s_fs_info = NULL; | 418 | s->s_fs_info = NULL; |
| 407 | return -EINVAL; | 419 | return ret; |
| 408 | } | 420 | } |
| 409 | 421 | ||
| 410 | static int bfs_get_sb(struct file_system_type *fs_type, | 422 | static int bfs_get_sb(struct file_system_type *fs_type, |
