aboutsummaryrefslogtreecommitdiffstats
path: root/fs/romfs
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2008-02-07 03:15:46 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-07 11:42:28 -0500
commit78cc9120003d7847ef1abebb771a708c7ae51ffd (patch)
tree1e6f1d3360f934a557a7e46249a4da56035cf953 /fs/romfs
parent2b7e5bcbd9e03f7236d2869f4261059074ea50a2 (diff)
iget: stop ROMFS from using iget() and read_inode()
Stop the ROMFS filesystem from using iget() and read_inode(). Replace romfs_read_inode() with romfs_iget(), and call that instead of iget(). romfs_iget() then uses iget_locked() directly and returns a proper error code instead of an inode in the event of an error. romfs_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> 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/romfs')
-rw-r--r--fs/romfs/inode.c46
1 files changed, 32 insertions, 14 deletions
diff --git a/fs/romfs/inode.c b/fs/romfs/inode.c
index a49cf5b9a19..00b6f0a518c 100644
--- a/fs/romfs/inode.c
+++ b/fs/romfs/inode.c
@@ -84,6 +84,8 @@ struct romfs_inode_info {
84 struct inode vfs_inode; 84 struct inode vfs_inode;
85}; 85};
86 86
87static struct inode *romfs_iget(struct super_block *, unsigned long);
88
87/* instead of private superblock data */ 89/* instead of private superblock data */
88static inline unsigned long romfs_maxsize(struct super_block *sb) 90static inline unsigned long romfs_maxsize(struct super_block *sb)
89{ 91{
@@ -117,7 +119,7 @@ static int romfs_fill_super(struct super_block *s, void *data, int silent)
117 struct buffer_head *bh; 119 struct buffer_head *bh;
118 struct romfs_super_block *rsb; 120 struct romfs_super_block *rsb;
119 struct inode *root; 121 struct inode *root;
120 int sz; 122 int sz, ret = -EINVAL;
121 123
122 /* I would parse the options here, but there are none.. :) */ 124 /* I would parse the options here, but there are none.. :) */
123 125
@@ -157,10 +159,13 @@ static int romfs_fill_super(struct super_block *s, void *data, int silent)
157 & ROMFH_MASK; 159 & ROMFH_MASK;
158 160
159 s->s_op = &romfs_ops; 161 s->s_op = &romfs_ops;
160 root = iget(s, sz); 162 root = romfs_iget(s, sz);
161 if (!root) 163 if (IS_ERR(root)) {
164 ret = PTR_ERR(root);
162 goto out; 165 goto out;
166 }
163 167
168 ret = -ENOMEM;
164 s->s_root = d_alloc_root(root); 169 s->s_root = d_alloc_root(root);
165 if (!s->s_root) 170 if (!s->s_root)
166 goto outiput; 171 goto outiput;
@@ -173,7 +178,7 @@ outiput:
173out: 178out:
174 brelse(bh); 179 brelse(bh);
175outnobh: 180outnobh:
176 return -EINVAL; 181 return ret;
177} 182}
178 183
179/* That's simple too. */ 184/* That's simple too. */
@@ -389,8 +394,11 @@ romfs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
389 if ((be32_to_cpu(ri.next) & ROMFH_TYPE) == ROMFH_HRD) 394 if ((be32_to_cpu(ri.next) & ROMFH_TYPE) == ROMFH_HRD)
390 offset = be32_to_cpu(ri.spec) & ROMFH_MASK; 395 offset = be32_to_cpu(ri.spec) & ROMFH_MASK;
391 396
392 if ((inode = iget(dir->i_sb, offset))) 397 inode = romfs_iget(dir->i_sb, offset);
393 goto outi; 398 if (IS_ERR(inode)) {
399 res = PTR_ERR(inode);
400 goto out;
401 }
394 402
395 /* 403 /*
396 * it's a bit funky, _lookup needs to return an error code 404 * it's a bit funky, _lookup needs to return an error code
@@ -402,7 +410,7 @@ romfs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
402 */ 410 */
403 411
404out0: inode = NULL; 412out0: inode = NULL;
405outi: res = 0; 413 res = 0;
406 d_add (dentry, inode); 414 d_add (dentry, inode);
407 415
408out: unlock_kernel(); 416out: unlock_kernel();
@@ -478,20 +486,29 @@ static mode_t romfs_modemap[] =
478 S_IFBLK+0600, S_IFCHR+0600, S_IFSOCK+0644, S_IFIFO+0644 486 S_IFBLK+0600, S_IFCHR+0600, S_IFSOCK+0644, S_IFIFO+0644
479}; 487};
480 488
481static void 489static struct inode *
482romfs_read_inode(struct inode *i) 490romfs_iget(struct super_block *sb, unsigned long ino)
483{ 491{
484 int nextfh, ino; 492 int nextfh;
485 struct romfs_inode ri; 493 struct romfs_inode ri;
494 struct inode *i;
495
496 ino &= ROMFH_MASK;
497 i = iget_locked(sb, ino);
498 if (!i)
499 return ERR_PTR(-ENOMEM);
500 if (!(i->i_state & I_NEW))
501 return i;
486 502
487 ino = i->i_ino & ROMFH_MASK;
488 i->i_mode = 0; 503 i->i_mode = 0;
489 504
490 /* Loop for finding the real hard link */ 505 /* Loop for finding the real hard link */
491 for(;;) { 506 for(;;) {
492 if (romfs_copyfrom(i, &ri, ino, ROMFH_SIZE) <= 0) { 507 if (romfs_copyfrom(i, &ri, ino, ROMFH_SIZE) <= 0) {
493 printk("romfs: read error for inode 0x%x\n", ino); 508 printk(KERN_ERR "romfs: read error for inode 0x%lx\n",
494 return; 509 ino);
510 iget_failed(i);
511 return ERR_PTR(-EIO);
495 } 512 }
496 /* XXX: do romfs_checksum here too (with name) */ 513 /* XXX: do romfs_checksum here too (with name) */
497 514
@@ -548,6 +565,8 @@ romfs_read_inode(struct inode *i)
548 init_special_inode(i, ino, 565 init_special_inode(i, ino,
549 MKDEV(nextfh>>16,nextfh&0xffff)); 566 MKDEV(nextfh>>16,nextfh&0xffff));
550 } 567 }
568 unlock_new_inode(i);
569 return i;
551} 570}
552 571
553static struct kmem_cache * romfs_inode_cachep; 572static struct kmem_cache * romfs_inode_cachep;
@@ -599,7 +618,6 @@ static int romfs_remount(struct super_block *sb, int *flags, char *data)
599static const struct super_operations romfs_ops = { 618static const struct super_operations romfs_ops = {
600 .alloc_inode = romfs_alloc_inode, 619 .alloc_inode = romfs_alloc_inode,
601 .destroy_inode = romfs_destroy_inode, 620 .destroy_inode = romfs_destroy_inode,
602 .read_inode = romfs_read_inode,
603 .statfs = romfs_statfs, 621 .statfs = romfs_statfs,
604 .remount_fs = romfs_remount, 622 .remount_fs = romfs_remount,
605}; 623};