diff options
author | David Howells <dhowells@redhat.com> | 2008-02-07 03:15:45 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-07 11:42:28 -0500 |
commit | 2b7e5bcbd9e03f7236d2869f4261059074ea50a2 (patch) | |
tree | fcc75f21bf6a3a65ee28909919bf36f58d667720 /fs/qnx4 | |
parent | a1d4aebbfa91c55a6b0c629a9ccf6369be0c6e95 (diff) |
iget: stop QNX4 from using iget() and read_inode()
Stop the QNX4 filesystem from using iget() and read_inode(). Replace
qnx4_read_inode() with qnx4_iget(), and call that instead of iget().
qnx4_iget() then uses iget_locked() directly and returns a proper error code
instead of an inode in the event of an error.
qnx4_fill_super() returns any error incurred when getting the root inode
instead of EINVAL.
[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: David Howells <dhowells@redhat.com>
Cc: Anders Larsen <al@alarsen.net>
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/qnx4')
-rw-r--r-- | fs/qnx4/inode.c | 47 | ||||
-rw-r--r-- | fs/qnx4/namei.c | 8 |
2 files changed, 37 insertions, 18 deletions
diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c index 638bdb963213..b31ab78052b3 100644 --- a/fs/qnx4/inode.c +++ b/fs/qnx4/inode.c | |||
@@ -125,7 +125,6 @@ static int qnx4_write_inode(struct inode *inode, int unused) | |||
125 | static void qnx4_put_super(struct super_block *sb); | 125 | static void qnx4_put_super(struct super_block *sb); |
126 | static struct inode *qnx4_alloc_inode(struct super_block *sb); | 126 | static struct inode *qnx4_alloc_inode(struct super_block *sb); |
127 | static void qnx4_destroy_inode(struct inode *inode); | 127 | static void qnx4_destroy_inode(struct inode *inode); |
128 | static void qnx4_read_inode(struct inode *); | ||
129 | static int qnx4_remount(struct super_block *sb, int *flags, char *data); | 128 | static int qnx4_remount(struct super_block *sb, int *flags, char *data); |
130 | static int qnx4_statfs(struct dentry *, struct kstatfs *); | 129 | static int qnx4_statfs(struct dentry *, struct kstatfs *); |
131 | 130 | ||
@@ -133,7 +132,6 @@ static const struct super_operations qnx4_sops = | |||
133 | { | 132 | { |
134 | .alloc_inode = qnx4_alloc_inode, | 133 | .alloc_inode = qnx4_alloc_inode, |
135 | .destroy_inode = qnx4_destroy_inode, | 134 | .destroy_inode = qnx4_destroy_inode, |
136 | .read_inode = qnx4_read_inode, | ||
137 | .put_super = qnx4_put_super, | 135 | .put_super = qnx4_put_super, |
138 | .statfs = qnx4_statfs, | 136 | .statfs = qnx4_statfs, |
139 | .remount_fs = qnx4_remount, | 137 | .remount_fs = qnx4_remount, |
@@ -357,6 +355,7 @@ static int qnx4_fill_super(struct super_block *s, void *data, int silent) | |||
357 | struct inode *root; | 355 | struct inode *root; |
358 | const char *errmsg; | 356 | const char *errmsg; |
359 | struct qnx4_sb_info *qs; | 357 | struct qnx4_sb_info *qs; |
358 | int ret = -EINVAL; | ||
360 | 359 | ||
361 | qs = kzalloc(sizeof(struct qnx4_sb_info), GFP_KERNEL); | 360 | qs = kzalloc(sizeof(struct qnx4_sb_info), GFP_KERNEL); |
362 | if (!qs) | 361 | if (!qs) |
@@ -396,12 +395,14 @@ static int qnx4_fill_super(struct super_block *s, void *data, int silent) | |||
396 | } | 395 | } |
397 | 396 | ||
398 | /* does root not have inode number QNX4_ROOT_INO ?? */ | 397 | /* does root not have inode number QNX4_ROOT_INO ?? */ |
399 | root = iget(s, QNX4_ROOT_INO * QNX4_INODES_PER_BLOCK); | 398 | root = qnx4_iget(s, QNX4_ROOT_INO * QNX4_INODES_PER_BLOCK); |
400 | if (!root) { | 399 | if (IS_ERR(root)) { |
401 | printk("qnx4: get inode failed\n"); | 400 | printk("qnx4: get inode failed\n"); |
401 | ret = PTR_ERR(root); | ||
402 | goto out; | 402 | goto out; |
403 | } | 403 | } |
404 | 404 | ||
405 | ret = -ENOMEM; | ||
405 | s->s_root = d_alloc_root(root); | 406 | s->s_root = d_alloc_root(root); |
406 | if (s->s_root == NULL) | 407 | if (s->s_root == NULL) |
407 | goto outi; | 408 | goto outi; |
@@ -417,7 +418,7 @@ static int qnx4_fill_super(struct super_block *s, void *data, int silent) | |||
417 | outnobh: | 418 | outnobh: |
418 | kfree(qs); | 419 | kfree(qs); |
419 | s->s_fs_info = NULL; | 420 | s->s_fs_info = NULL; |
420 | return -EINVAL; | 421 | return ret; |
421 | } | 422 | } |
422 | 423 | ||
423 | static void qnx4_put_super(struct super_block *sb) | 424 | static void qnx4_put_super(struct super_block *sb) |
@@ -462,29 +463,38 @@ static const struct address_space_operations qnx4_aops = { | |||
462 | .bmap = qnx4_bmap | 463 | .bmap = qnx4_bmap |
463 | }; | 464 | }; |
464 | 465 | ||
465 | static void qnx4_read_inode(struct inode *inode) | 466 | struct inode *qnx4_iget(struct super_block *sb, unsigned long ino) |
466 | { | 467 | { |
467 | struct buffer_head *bh; | 468 | struct buffer_head *bh; |
468 | struct qnx4_inode_entry *raw_inode; | 469 | struct qnx4_inode_entry *raw_inode; |
469 | int block, ino; | 470 | int block; |
470 | struct super_block *sb = inode->i_sb; | 471 | struct qnx4_inode_entry *qnx4_inode; |
471 | struct qnx4_inode_entry *qnx4_inode = qnx4_raw_inode(inode); | 472 | struct inode *inode; |
472 | 473 | ||
473 | ino = inode->i_ino; | 474 | inode = iget_locked(sb, ino); |
475 | if (!inode) | ||
476 | return ERR_PTR(-ENOMEM); | ||
477 | if (!(inode->i_state & I_NEW)) | ||
478 | return inode; | ||
479 | |||
480 | qnx4_inode = qnx4_raw_inode(inode); | ||
474 | inode->i_mode = 0; | 481 | inode->i_mode = 0; |
475 | 482 | ||
476 | QNX4DEBUG(("Reading inode : [%d]\n", ino)); | 483 | QNX4DEBUG(("Reading inode : [%d]\n", ino)); |
477 | if (!ino) { | 484 | if (!ino) { |
478 | printk("qnx4: bad inode number on dev %s: %d is out of range\n", | 485 | printk(KERN_ERR "qnx4: bad inode number on dev %s: %lu is " |
486 | "out of range\n", | ||
479 | sb->s_id, ino); | 487 | sb->s_id, ino); |
480 | return; | 488 | iget_failed(inode); |
489 | return ERR_PTR(-EIO); | ||
481 | } | 490 | } |
482 | block = ino / QNX4_INODES_PER_BLOCK; | 491 | block = ino / QNX4_INODES_PER_BLOCK; |
483 | 492 | ||
484 | if (!(bh = sb_bread(sb, block))) { | 493 | if (!(bh = sb_bread(sb, block))) { |
485 | printk("qnx4: major problem: unable to read inode from dev " | 494 | printk("qnx4: major problem: unable to read inode from dev " |
486 | "%s\n", sb->s_id); | 495 | "%s\n", sb->s_id); |
487 | return; | 496 | iget_failed(inode); |
497 | return ERR_PTR(-EIO); | ||
488 | } | 498 | } |
489 | raw_inode = ((struct qnx4_inode_entry *) bh->b_data) + | 499 | raw_inode = ((struct qnx4_inode_entry *) bh->b_data) + |
490 | (ino % QNX4_INODES_PER_BLOCK); | 500 | (ino % QNX4_INODES_PER_BLOCK); |
@@ -515,9 +525,16 @@ static void qnx4_read_inode(struct inode *inode) | |||
515 | inode->i_op = &page_symlink_inode_operations; | 525 | inode->i_op = &page_symlink_inode_operations; |
516 | inode->i_mapping->a_ops = &qnx4_aops; | 526 | inode->i_mapping->a_ops = &qnx4_aops; |
517 | qnx4_i(inode)->mmu_private = inode->i_size; | 527 | qnx4_i(inode)->mmu_private = inode->i_size; |
518 | } else | 528 | } else { |
519 | printk("qnx4: bad inode %d on dev %s\n",ino,sb->s_id); | 529 | printk(KERN_ERR "qnx4: bad inode %lu on dev %s\n", |
530 | ino, sb->s_id); | ||
531 | iget_failed(inode); | ||
532 | brelse(bh); | ||
533 | return ERR_PTR(-EIO); | ||
534 | } | ||
520 | brelse(bh); | 535 | brelse(bh); |
536 | unlock_new_inode(inode); | ||
537 | return inode; | ||
521 | } | 538 | } |
522 | 539 | ||
523 | static struct kmem_cache *qnx4_inode_cachep; | 540 | static struct kmem_cache *qnx4_inode_cachep; |
diff --git a/fs/qnx4/namei.c b/fs/qnx4/namei.c index 733cdf01d645..775eed3a4085 100644 --- a/fs/qnx4/namei.c +++ b/fs/qnx4/namei.c | |||
@@ -128,10 +128,12 @@ struct dentry * qnx4_lookup(struct inode *dir, struct dentry *dentry, struct nam | |||
128 | } | 128 | } |
129 | brelse(bh); | 129 | brelse(bh); |
130 | 130 | ||
131 | if ((foundinode = iget(dir->i_sb, ino)) == NULL) { | 131 | foundinode = qnx4_iget(dir->i_sb, ino); |
132 | if (IS_ERR(foundinode)) { | ||
132 | unlock_kernel(); | 133 | unlock_kernel(); |
133 | QNX4DEBUG(("qnx4: lookup->iget -> NULL\n")); | 134 | QNX4DEBUG(("qnx4: lookup->iget -> error %ld\n", |
134 | return ERR_PTR(-EACCES); | 135 | PTR_ERR(foundinode))); |
136 | return ERR_CAST(foundinode); | ||
135 | } | 137 | } |
136 | out: | 138 | out: |
137 | unlock_kernel(); | 139 | unlock_kernel(); |