Commit fc4fff82 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Christoph Hellwig

hfsplus: clean up hfsplus_iget

Add a new hfsplus_system_read_inode for reading the special system inodes
and streamline the fastpath iget code.
Signed-off-by: default avatarChristoph Hellwig <hch@tuxera.com>
parent 6af502de
...@@ -20,12 +20,42 @@ static void hfsplus_destroy_inode(struct inode *inode); ...@@ -20,12 +20,42 @@ static void hfsplus_destroy_inode(struct inode *inode);
#include "hfsplus_fs.h" #include "hfsplus_fs.h"
static int hfsplus_system_read_inode(struct inode *inode)
{
struct hfsplus_vh *vhdr = HFSPLUS_SB(inode->i_sb)->s_vhdr;
switch (inode->i_ino) {
case HFSPLUS_EXT_CNID:
hfsplus_inode_read_fork(inode, &vhdr->ext_file);
inode->i_mapping->a_ops = &hfsplus_btree_aops;
break;
case HFSPLUS_CAT_CNID:
hfsplus_inode_read_fork(inode, &vhdr->cat_file);
inode->i_mapping->a_ops = &hfsplus_btree_aops;
break;
case HFSPLUS_ALLOC_CNID:
hfsplus_inode_read_fork(inode, &vhdr->alloc_file);
inode->i_mapping->a_ops = &hfsplus_aops;
break;
case HFSPLUS_START_CNID:
hfsplus_inode_read_fork(inode, &vhdr->start_file);
break;
case HFSPLUS_ATTR_CNID:
hfsplus_inode_read_fork(inode, &vhdr->attr_file);
inode->i_mapping->a_ops = &hfsplus_btree_aops;
break;
default:
return -EIO;
}
return 0;
}
struct inode *hfsplus_iget(struct super_block *sb, unsigned long ino) struct inode *hfsplus_iget(struct super_block *sb, unsigned long ino)
{ {
struct hfs_find_data fd; struct hfs_find_data fd;
struct hfsplus_vh *vhdr;
struct inode *inode; struct inode *inode;
long err = -EIO; int err;
inode = iget_locked(sb, ino); inode = iget_locked(sb, ino);
if (!inode) if (!inode)
...@@ -39,51 +69,24 @@ struct inode *hfsplus_iget(struct super_block *sb, unsigned long ino) ...@@ -39,51 +69,24 @@ struct inode *hfsplus_iget(struct super_block *sb, unsigned long ino)
HFSPLUS_I(inode)->rsrc_inode = NULL; HFSPLUS_I(inode)->rsrc_inode = NULL;
atomic_set(&HFSPLUS_I(inode)->opencnt, 0); atomic_set(&HFSPLUS_I(inode)->opencnt, 0);
if (inode->i_ino >= HFSPLUS_FIRSTUSER_CNID) { if (inode->i_ino >= HFSPLUS_FIRSTUSER_CNID ||
read_inode: inode->i_ino == HFSPLUS_ROOT_CNID) {
hfs_find_init(HFSPLUS_SB(inode->i_sb)->cat_tree, &fd); hfs_find_init(HFSPLUS_SB(inode->i_sb)->cat_tree, &fd);
err = hfsplus_find_cat(inode->i_sb, inode->i_ino, &fd); err = hfsplus_find_cat(inode->i_sb, inode->i_ino, &fd);
if (!err) if (!err)
err = hfsplus_cat_read_inode(inode, &fd); err = hfsplus_cat_read_inode(inode, &fd);
hfs_find_exit(&fd); hfs_find_exit(&fd);
if (err) } else {
goto bad_inode; err = hfsplus_system_read_inode(inode);
goto done;
} }
vhdr = HFSPLUS_SB(inode->i_sb)->s_vhdr;
switch(inode->i_ino) { if (err) {
case HFSPLUS_ROOT_CNID: iget_failed(inode);
goto read_inode; return ERR_PTR(err);
case HFSPLUS_EXT_CNID:
hfsplus_inode_read_fork(inode, &vhdr->ext_file);
inode->i_mapping->a_ops = &hfsplus_btree_aops;
break;
case HFSPLUS_CAT_CNID:
hfsplus_inode_read_fork(inode, &vhdr->cat_file);
inode->i_mapping->a_ops = &hfsplus_btree_aops;
break;
case HFSPLUS_ALLOC_CNID:
hfsplus_inode_read_fork(inode, &vhdr->alloc_file);
inode->i_mapping->a_ops = &hfsplus_aops;
break;
case HFSPLUS_START_CNID:
hfsplus_inode_read_fork(inode, &vhdr->start_file);
break;
case HFSPLUS_ATTR_CNID:
hfsplus_inode_read_fork(inode, &vhdr->attr_file);
inode->i_mapping->a_ops = &hfsplus_btree_aops;
break;
default:
goto bad_inode;
} }
done:
unlock_new_inode(inode); unlock_new_inode(inode);
return inode; return inode;
bad_inode:
iget_failed(inode);
return ERR_PTR(err);
} }
static int hfsplus_write_inode(struct inode *inode, static int hfsplus_write_inode(struct inode *inode,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment