diff options
Diffstat (limited to 'fs/minix')
-rw-r--r-- | fs/minix/inode.c | 43 | ||||
-rw-r--r-- | fs/minix/minix.h | 1 | ||||
-rw-r--r-- | fs/minix/namei.c | 7 |
3 files changed, 33 insertions, 18 deletions
diff --git a/fs/minix/inode.c b/fs/minix/inode.c index bf4cd316af81..84f6242ba6fc 100644 --- a/fs/minix/inode.c +++ b/fs/minix/inode.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include <linux/highuid.h> | 18 | #include <linux/highuid.h> |
19 | #include <linux/vfs.h> | 19 | #include <linux/vfs.h> |
20 | 20 | ||
21 | static void minix_read_inode(struct inode * inode); | ||
22 | static int minix_write_inode(struct inode * inode, int wait); | 21 | static int minix_write_inode(struct inode * inode, int wait); |
23 | static int minix_statfs(struct dentry *dentry, struct kstatfs *buf); | 22 | static int minix_statfs(struct dentry *dentry, struct kstatfs *buf); |
24 | static int minix_remount (struct super_block * sb, int * flags, char * data); | 23 | static int minix_remount (struct super_block * sb, int * flags, char * data); |
@@ -96,7 +95,6 @@ static void destroy_inodecache(void) | |||
96 | static const struct super_operations minix_sops = { | 95 | static const struct super_operations minix_sops = { |
97 | .alloc_inode = minix_alloc_inode, | 96 | .alloc_inode = minix_alloc_inode, |
98 | .destroy_inode = minix_destroy_inode, | 97 | .destroy_inode = minix_destroy_inode, |
99 | .read_inode = minix_read_inode, | ||
100 | .write_inode = minix_write_inode, | 98 | .write_inode = minix_write_inode, |
101 | .delete_inode = minix_delete_inode, | 99 | .delete_inode = minix_delete_inode, |
102 | .put_super = minix_put_super, | 100 | .put_super = minix_put_super, |
@@ -149,6 +147,7 @@ static int minix_fill_super(struct super_block *s, void *data, int silent) | |||
149 | unsigned long i, block; | 147 | unsigned long i, block; |
150 | struct inode *root_inode; | 148 | struct inode *root_inode; |
151 | struct minix_sb_info *sbi; | 149 | struct minix_sb_info *sbi; |
150 | int ret = -EINVAL; | ||
152 | 151 | ||
153 | sbi = kzalloc(sizeof(struct minix_sb_info), GFP_KERNEL); | 152 | sbi = kzalloc(sizeof(struct minix_sb_info), GFP_KERNEL); |
154 | if (!sbi) | 153 | if (!sbi) |
@@ -246,10 +245,13 @@ static int minix_fill_super(struct super_block *s, void *data, int silent) | |||
246 | 245 | ||
247 | /* set up enough so that it can read an inode */ | 246 | /* set up enough so that it can read an inode */ |
248 | s->s_op = &minix_sops; | 247 | s->s_op = &minix_sops; |
249 | root_inode = iget(s, MINIX_ROOT_INO); | 248 | root_inode = minix_iget(s, MINIX_ROOT_INO); |
250 | if (!root_inode || is_bad_inode(root_inode)) | 249 | if (IS_ERR(root_inode)) { |
250 | ret = PTR_ERR(root_inode); | ||
251 | goto out_no_root; | 251 | goto out_no_root; |
252 | } | ||
252 | 253 | ||
254 | ret = -ENOMEM; | ||
253 | s->s_root = d_alloc_root(root_inode); | 255 | s->s_root = d_alloc_root(root_inode); |
254 | if (!s->s_root) | 256 | if (!s->s_root) |
255 | goto out_iput; | 257 | goto out_iput; |
@@ -290,6 +292,7 @@ out_freemap: | |||
290 | goto out_release; | 292 | goto out_release; |
291 | 293 | ||
292 | out_no_map: | 294 | out_no_map: |
295 | ret = -ENOMEM; | ||
293 | if (!silent) | 296 | if (!silent) |
294 | printk("MINIX-fs: can't allocate map\n"); | 297 | printk("MINIX-fs: can't allocate map\n"); |
295 | goto out_release; | 298 | goto out_release; |
@@ -316,7 +319,7 @@ out_bad_sb: | |||
316 | out: | 319 | out: |
317 | s->s_fs_info = NULL; | 320 | s->s_fs_info = NULL; |
318 | kfree(sbi); | 321 | kfree(sbi); |
319 | return -EINVAL; | 322 | return ret; |
320 | } | 323 | } |
321 | 324 | ||
322 | static int minix_statfs(struct dentry *dentry, struct kstatfs *buf) | 325 | static int minix_statfs(struct dentry *dentry, struct kstatfs *buf) |
@@ -409,7 +412,7 @@ void minix_set_inode(struct inode *inode, dev_t rdev) | |||
409 | /* | 412 | /* |
410 | * The minix V1 function to read an inode. | 413 | * The minix V1 function to read an inode. |
411 | */ | 414 | */ |
412 | static void V1_minix_read_inode(struct inode * inode) | 415 | static struct inode *V1_minix_iget(struct inode *inode) |
413 | { | 416 | { |
414 | struct buffer_head * bh; | 417 | struct buffer_head * bh; |
415 | struct minix_inode * raw_inode; | 418 | struct minix_inode * raw_inode; |
@@ -418,8 +421,8 @@ static void V1_minix_read_inode(struct inode * inode) | |||
418 | 421 | ||
419 | raw_inode = minix_V1_raw_inode(inode->i_sb, inode->i_ino, &bh); | 422 | raw_inode = minix_V1_raw_inode(inode->i_sb, inode->i_ino, &bh); |
420 | if (!raw_inode) { | 423 | if (!raw_inode) { |
421 | make_bad_inode(inode); | 424 | iget_failed(inode); |
422 | return; | 425 | return ERR_PTR(-EIO); |
423 | } | 426 | } |
424 | inode->i_mode = raw_inode->i_mode; | 427 | inode->i_mode = raw_inode->i_mode; |
425 | inode->i_uid = (uid_t)raw_inode->i_uid; | 428 | inode->i_uid = (uid_t)raw_inode->i_uid; |
@@ -435,12 +438,14 @@ static void V1_minix_read_inode(struct inode * inode) | |||
435 | minix_inode->u.i1_data[i] = raw_inode->i_zone[i]; | 438 | minix_inode->u.i1_data[i] = raw_inode->i_zone[i]; |
436 | minix_set_inode(inode, old_decode_dev(raw_inode->i_zone[0])); | 439 | minix_set_inode(inode, old_decode_dev(raw_inode->i_zone[0])); |
437 | brelse(bh); | 440 | brelse(bh); |
441 | unlock_new_inode(inode); | ||
442 | return inode; | ||
438 | } | 443 | } |
439 | 444 | ||
440 | /* | 445 | /* |
441 | * The minix V2 function to read an inode. | 446 | * The minix V2 function to read an inode. |
442 | */ | 447 | */ |
443 | static void V2_minix_read_inode(struct inode * inode) | 448 | static struct inode *V2_minix_iget(struct inode *inode) |
444 | { | 449 | { |
445 | struct buffer_head * bh; | 450 | struct buffer_head * bh; |
446 | struct minix2_inode * raw_inode; | 451 | struct minix2_inode * raw_inode; |
@@ -449,8 +454,8 @@ static void V2_minix_read_inode(struct inode * inode) | |||
449 | 454 | ||
450 | raw_inode = minix_V2_raw_inode(inode->i_sb, inode->i_ino, &bh); | 455 | raw_inode = minix_V2_raw_inode(inode->i_sb, inode->i_ino, &bh); |
451 | if (!raw_inode) { | 456 | if (!raw_inode) { |
452 | make_bad_inode(inode); | 457 | iget_failed(inode); |
453 | return; | 458 | return ERR_PTR(-EIO); |
454 | } | 459 | } |
455 | inode->i_mode = raw_inode->i_mode; | 460 | inode->i_mode = raw_inode->i_mode; |
456 | inode->i_uid = (uid_t)raw_inode->i_uid; | 461 | inode->i_uid = (uid_t)raw_inode->i_uid; |
@@ -468,17 +473,27 @@ static void V2_minix_read_inode(struct inode * inode) | |||
468 | minix_inode->u.i2_data[i] = raw_inode->i_zone[i]; | 473 | minix_inode->u.i2_data[i] = raw_inode->i_zone[i]; |
469 | minix_set_inode(inode, old_decode_dev(raw_inode->i_zone[0])); | 474 | minix_set_inode(inode, old_decode_dev(raw_inode->i_zone[0])); |
470 | brelse(bh); | 475 | brelse(bh); |
476 | unlock_new_inode(inode); | ||
477 | return inode; | ||
471 | } | 478 | } |
472 | 479 | ||
473 | /* | 480 | /* |
474 | * The global function to read an inode. | 481 | * The global function to read an inode. |
475 | */ | 482 | */ |
476 | static void minix_read_inode(struct inode * inode) | 483 | struct inode *minix_iget(struct super_block *sb, unsigned long ino) |
477 | { | 484 | { |
485 | struct inode *inode; | ||
486 | |||
487 | inode = iget_locked(sb, ino); | ||
488 | if (!inode) | ||
489 | return ERR_PTR(-ENOMEM); | ||
490 | if (!(inode->i_state & I_NEW)) | ||
491 | return inode; | ||
492 | |||
478 | if (INODE_VERSION(inode) == MINIX_V1) | 493 | if (INODE_VERSION(inode) == MINIX_V1) |
479 | V1_minix_read_inode(inode); | 494 | return V1_minix_iget(inode); |
480 | else | 495 | else |
481 | V2_minix_read_inode(inode); | 496 | return V2_minix_iget(inode); |
482 | } | 497 | } |
483 | 498 | ||
484 | /* | 499 | /* |
diff --git a/fs/minix/minix.h b/fs/minix/minix.h index ac5d3a75cb0d..326edfe96108 100644 --- a/fs/minix/minix.h +++ b/fs/minix/minix.h | |||
@@ -45,6 +45,7 @@ struct minix_sb_info { | |||
45 | unsigned short s_version; | 45 | unsigned short s_version; |
46 | }; | 46 | }; |
47 | 47 | ||
48 | extern struct inode *minix_iget(struct super_block *, unsigned long); | ||
48 | extern struct minix_inode * minix_V1_raw_inode(struct super_block *, ino_t, struct buffer_head **); | 49 | extern struct minix_inode * minix_V1_raw_inode(struct super_block *, ino_t, struct buffer_head **); |
49 | extern struct minix2_inode * minix_V2_raw_inode(struct super_block *, ino_t, struct buffer_head **); | 50 | extern struct minix2_inode * minix_V2_raw_inode(struct super_block *, ino_t, struct buffer_head **); |
50 | extern struct inode * minix_new_inode(const struct inode * dir, int * error); | 51 | extern struct inode * minix_new_inode(const struct inode * dir, int * error); |
diff --git a/fs/minix/namei.c b/fs/minix/namei.c index f4aa7a939040..102241bc9c79 100644 --- a/fs/minix/namei.c +++ b/fs/minix/namei.c | |||
@@ -54,10 +54,9 @@ static struct dentry *minix_lookup(struct inode * dir, struct dentry *dentry, st | |||
54 | 54 | ||
55 | ino = minix_inode_by_name(dentry); | 55 | ino = minix_inode_by_name(dentry); |
56 | if (ino) { | 56 | if (ino) { |
57 | inode = iget(dir->i_sb, ino); | 57 | inode = minix_iget(dir->i_sb, ino); |
58 | 58 | if (IS_ERR(inode)) | |
59 | if (!inode) | 59 | return ERR_CAST(inode); |
60 | return ERR_PTR(-EACCES); | ||
61 | } | 60 | } |
62 | d_add(dentry, inode); | 61 | d_add(dentry, inode); |
63 | return NULL; | 62 | return NULL; |