mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-29 10:01:25 +00:00
hfsplus: fix HFSPLUS_SB calling convention
HFSPLUS_SB doesn't return a pointer to the hfsplus-specific superblock information like all other FOO_SB macros, but dereference the pointer in a way that made it look like a direct struct derefence. This only works as long as the HFSPLUS_SB macro is used directly and prevents us from keepig a local hfsplus_sb_info pointer. Fix the calling convention and introduce a local sbi variable in all functions that use it constantly. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
This commit is contained in:
parent
e753a62156
commit
dd73a01a30
13 changed files with 209 additions and 189 deletions
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
int hfsplus_block_allocate(struct super_block *sb, u32 size, u32 offset, u32 *max)
|
int hfsplus_block_allocate(struct super_block *sb, u32 size, u32 offset, u32 *max)
|
||||||
{
|
{
|
||||||
|
struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
|
||||||
struct page *page;
|
struct page *page;
|
||||||
struct address_space *mapping;
|
struct address_space *mapping;
|
||||||
__be32 *pptr, *curr, *end;
|
__be32 *pptr, *curr, *end;
|
||||||
|
@ -29,8 +30,8 @@ int hfsplus_block_allocate(struct super_block *sb, u32 size, u32 offset, u32 *ma
|
||||||
return size;
|
return size;
|
||||||
|
|
||||||
dprint(DBG_BITMAP, "block_allocate: %u,%u,%u\n", size, offset, len);
|
dprint(DBG_BITMAP, "block_allocate: %u,%u,%u\n", size, offset, len);
|
||||||
mutex_lock(&HFSPLUS_SB(sb).alloc_mutex);
|
mutex_lock(&sbi->alloc_mutex);
|
||||||
mapping = HFSPLUS_SB(sb).alloc_file->i_mapping;
|
mapping = sbi->alloc_file->i_mapping;
|
||||||
page = read_mapping_page(mapping, offset / PAGE_CACHE_BITS, NULL);
|
page = read_mapping_page(mapping, offset / PAGE_CACHE_BITS, NULL);
|
||||||
if (IS_ERR(page)) {
|
if (IS_ERR(page)) {
|
||||||
start = size;
|
start = size;
|
||||||
|
@ -150,16 +151,17 @@ done:
|
||||||
set_page_dirty(page);
|
set_page_dirty(page);
|
||||||
kunmap(page);
|
kunmap(page);
|
||||||
*max = offset + (curr - pptr) * 32 + i - start;
|
*max = offset + (curr - pptr) * 32 + i - start;
|
||||||
HFSPLUS_SB(sb).free_blocks -= *max;
|
sbi->free_blocks -= *max;
|
||||||
sb->s_dirt = 1;
|
sb->s_dirt = 1;
|
||||||
dprint(DBG_BITMAP, "-> %u,%u\n", start, *max);
|
dprint(DBG_BITMAP, "-> %u,%u\n", start, *max);
|
||||||
out:
|
out:
|
||||||
mutex_unlock(&HFSPLUS_SB(sb).alloc_mutex);
|
mutex_unlock(&sbi->alloc_mutex);
|
||||||
return start;
|
return start;
|
||||||
}
|
}
|
||||||
|
|
||||||
int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count)
|
int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count)
|
||||||
{
|
{
|
||||||
|
struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
|
||||||
struct page *page;
|
struct page *page;
|
||||||
struct address_space *mapping;
|
struct address_space *mapping;
|
||||||
__be32 *pptr, *curr, *end;
|
__be32 *pptr, *curr, *end;
|
||||||
|
@ -172,11 +174,11 @@ int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count)
|
||||||
|
|
||||||
dprint(DBG_BITMAP, "block_free: %u,%u\n", offset, count);
|
dprint(DBG_BITMAP, "block_free: %u,%u\n", offset, count);
|
||||||
/* are all of the bits in range? */
|
/* are all of the bits in range? */
|
||||||
if ((offset + count) > HFSPLUS_SB(sb).total_blocks)
|
if ((offset + count) > sbi->total_blocks)
|
||||||
return -2;
|
return -2;
|
||||||
|
|
||||||
mutex_lock(&HFSPLUS_SB(sb).alloc_mutex);
|
mutex_lock(&sbi->alloc_mutex);
|
||||||
mapping = HFSPLUS_SB(sb).alloc_file->i_mapping;
|
mapping = sbi->alloc_file->i_mapping;
|
||||||
pnr = offset / PAGE_CACHE_BITS;
|
pnr = offset / PAGE_CACHE_BITS;
|
||||||
page = read_mapping_page(mapping, pnr, NULL);
|
page = read_mapping_page(mapping, pnr, NULL);
|
||||||
pptr = kmap(page);
|
pptr = kmap(page);
|
||||||
|
@ -224,9 +226,9 @@ done:
|
||||||
out:
|
out:
|
||||||
set_page_dirty(page);
|
set_page_dirty(page);
|
||||||
kunmap(page);
|
kunmap(page);
|
||||||
HFSPLUS_SB(sb).free_blocks += len;
|
sbi->free_blocks += len;
|
||||||
sb->s_dirt = 1;
|
sb->s_dirt = 1;
|
||||||
mutex_unlock(&HFSPLUS_SB(sb).alloc_mutex);
|
mutex_unlock(&sbi->alloc_mutex);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,12 +61,12 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id)
|
||||||
if (id == HFSPLUS_EXT_CNID) {
|
if (id == HFSPLUS_EXT_CNID) {
|
||||||
tree->keycmp = hfsplus_ext_cmp_key;
|
tree->keycmp = hfsplus_ext_cmp_key;
|
||||||
} else if (id == HFSPLUS_CAT_CNID) {
|
} else if (id == HFSPLUS_CAT_CNID) {
|
||||||
if ((HFSPLUS_SB(sb).flags & HFSPLUS_SB_HFSX) &&
|
if ((HFSPLUS_SB(sb)->flags & HFSPLUS_SB_HFSX) &&
|
||||||
(head->key_type == HFSPLUS_KEY_BINARY))
|
(head->key_type == HFSPLUS_KEY_BINARY))
|
||||||
tree->keycmp = hfsplus_cat_bin_cmp_key;
|
tree->keycmp = hfsplus_cat_bin_cmp_key;
|
||||||
else {
|
else {
|
||||||
tree->keycmp = hfsplus_cat_case_cmp_key;
|
tree->keycmp = hfsplus_cat_case_cmp_key;
|
||||||
HFSPLUS_SB(sb).flags |= HFSPLUS_SB_CASEFOLD;
|
HFSPLUS_SB(sb)->flags |= HFSPLUS_SB_CASEFOLD;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
printk(KERN_ERR "hfs: unknown B*Tree requested\n");
|
printk(KERN_ERR "hfs: unknown B*Tree requested\n");
|
||||||
|
@ -200,9 +200,9 @@ struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree)
|
||||||
return ERR_PTR(res);
|
return ERR_PTR(res);
|
||||||
HFSPLUS_I(inode).phys_size = inode->i_size =
|
HFSPLUS_I(inode).phys_size = inode->i_size =
|
||||||
(loff_t)HFSPLUS_I(inode).alloc_blocks <<
|
(loff_t)HFSPLUS_I(inode).alloc_blocks <<
|
||||||
HFSPLUS_SB(tree->sb).alloc_blksz_shift;
|
HFSPLUS_SB(tree->sb)->alloc_blksz_shift;
|
||||||
HFSPLUS_I(inode).fs_blocks = HFSPLUS_I(inode).alloc_blocks <<
|
HFSPLUS_I(inode).fs_blocks = HFSPLUS_I(inode).alloc_blocks <<
|
||||||
HFSPLUS_SB(tree->sb).fs_shift;
|
HFSPLUS_SB(tree->sb)->fs_shift;
|
||||||
inode_set_bytes(inode, inode->i_size);
|
inode_set_bytes(inode, inode->i_size);
|
||||||
count = inode->i_size >> tree->node_size_shift;
|
count = inode->i_size >> tree->node_size_shift;
|
||||||
tree->free_nodes = count - tree->node_count;
|
tree->free_nodes = count - tree->node_count;
|
||||||
|
|
|
@ -86,6 +86,8 @@ static void hfsplus_set_perms(struct inode *inode, struct hfsplus_perm *perms)
|
||||||
|
|
||||||
static int hfsplus_cat_build_record(hfsplus_cat_entry *entry, u32 cnid, struct inode *inode)
|
static int hfsplus_cat_build_record(hfsplus_cat_entry *entry, u32 cnid, struct inode *inode)
|
||||||
{
|
{
|
||||||
|
struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode->i_sb);
|
||||||
|
|
||||||
if (S_ISDIR(inode->i_mode)) {
|
if (S_ISDIR(inode->i_mode)) {
|
||||||
struct hfsplus_cat_folder *folder;
|
struct hfsplus_cat_folder *folder;
|
||||||
|
|
||||||
|
@ -99,7 +101,7 @@ static int hfsplus_cat_build_record(hfsplus_cat_entry *entry, u32 cnid, struct i
|
||||||
folder->attribute_mod_date =
|
folder->attribute_mod_date =
|
||||||
folder->access_date = hfsp_now2mt();
|
folder->access_date = hfsp_now2mt();
|
||||||
hfsplus_set_perms(inode, &folder->permissions);
|
hfsplus_set_perms(inode, &folder->permissions);
|
||||||
if (inode == HFSPLUS_SB(inode->i_sb).hidden_dir)
|
if (inode == sbi->hidden_dir)
|
||||||
/* invisible and namelocked */
|
/* invisible and namelocked */
|
||||||
folder->user_info.frFlags = cpu_to_be16(0x5000);
|
folder->user_info.frFlags = cpu_to_be16(0x5000);
|
||||||
return sizeof(*folder);
|
return sizeof(*folder);
|
||||||
|
@ -122,8 +124,8 @@ static int hfsplus_cat_build_record(hfsplus_cat_entry *entry, u32 cnid, struct i
|
||||||
file->user_info.fdType = cpu_to_be32(HFSP_SYMLINK_TYPE);
|
file->user_info.fdType = cpu_to_be32(HFSP_SYMLINK_TYPE);
|
||||||
file->user_info.fdCreator = cpu_to_be32(HFSP_SYMLINK_CREATOR);
|
file->user_info.fdCreator = cpu_to_be32(HFSP_SYMLINK_CREATOR);
|
||||||
} else {
|
} else {
|
||||||
file->user_info.fdType = cpu_to_be32(HFSPLUS_SB(inode->i_sb).type);
|
file->user_info.fdType = cpu_to_be32(sbi->type);
|
||||||
file->user_info.fdCreator = cpu_to_be32(HFSPLUS_SB(inode->i_sb).creator);
|
file->user_info.fdCreator = cpu_to_be32(sbi->creator);
|
||||||
}
|
}
|
||||||
if ((file->permissions.rootflags | file->permissions.userflags) & HFSPLUS_FLG_IMMUTABLE)
|
if ((file->permissions.rootflags | file->permissions.userflags) & HFSPLUS_FLG_IMMUTABLE)
|
||||||
file->flags |= cpu_to_be16(HFSPLUS_FILE_LOCKED);
|
file->flags |= cpu_to_be16(HFSPLUS_FILE_LOCKED);
|
||||||
|
@ -131,7 +133,7 @@ static int hfsplus_cat_build_record(hfsplus_cat_entry *entry, u32 cnid, struct i
|
||||||
file->user_info.fdType = cpu_to_be32(HFSP_HARDLINK_TYPE);
|
file->user_info.fdType = cpu_to_be32(HFSP_HARDLINK_TYPE);
|
||||||
file->user_info.fdCreator = cpu_to_be32(HFSP_HFSPLUS_CREATOR);
|
file->user_info.fdCreator = cpu_to_be32(HFSP_HFSPLUS_CREATOR);
|
||||||
file->user_info.fdFlags = cpu_to_be16(0x100);
|
file->user_info.fdFlags = cpu_to_be16(0x100);
|
||||||
file->create_date = HFSPLUS_I(HFSPLUS_SB(inode->i_sb).hidden_dir).create_date;
|
file->create_date = HFSPLUS_I(sbi->hidden_dir).create_date;
|
||||||
file->permissions.dev = cpu_to_be32(HFSPLUS_I(inode).dev);
|
file->permissions.dev = cpu_to_be32(HFSPLUS_I(inode).dev);
|
||||||
}
|
}
|
||||||
return sizeof(*file);
|
return sizeof(*file);
|
||||||
|
@ -180,15 +182,14 @@ int hfsplus_find_cat(struct super_block *sb, u32 cnid,
|
||||||
|
|
||||||
int hfsplus_create_cat(u32 cnid, struct inode *dir, struct qstr *str, struct inode *inode)
|
int hfsplus_create_cat(u32 cnid, struct inode *dir, struct qstr *str, struct inode *inode)
|
||||||
{
|
{
|
||||||
|
struct super_block *sb = dir->i_sb;
|
||||||
struct hfs_find_data fd;
|
struct hfs_find_data fd;
|
||||||
struct super_block *sb;
|
|
||||||
hfsplus_cat_entry entry;
|
hfsplus_cat_entry entry;
|
||||||
int entry_size;
|
int entry_size;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
dprint(DBG_CAT_MOD, "create_cat: %s,%u(%d)\n", str->name, cnid, inode->i_nlink);
|
dprint(DBG_CAT_MOD, "create_cat: %s,%u(%d)\n", str->name, cnid, inode->i_nlink);
|
||||||
sb = dir->i_sb;
|
hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd);
|
||||||
hfs_find_init(HFSPLUS_SB(sb).cat_tree, &fd);
|
|
||||||
|
|
||||||
hfsplus_cat_build_key(sb, fd.search_key, cnid, NULL);
|
hfsplus_cat_build_key(sb, fd.search_key, cnid, NULL);
|
||||||
entry_size = hfsplus_fill_cat_thread(sb, &entry, S_ISDIR(inode->i_mode) ?
|
entry_size = hfsplus_fill_cat_thread(sb, &entry, S_ISDIR(inode->i_mode) ?
|
||||||
|
@ -234,7 +235,7 @@ err2:
|
||||||
|
|
||||||
int hfsplus_delete_cat(u32 cnid, struct inode *dir, struct qstr *str)
|
int hfsplus_delete_cat(u32 cnid, struct inode *dir, struct qstr *str)
|
||||||
{
|
{
|
||||||
struct super_block *sb;
|
struct super_block *sb = dir->i_sb;
|
||||||
struct hfs_find_data fd;
|
struct hfs_find_data fd;
|
||||||
struct hfsplus_fork_raw fork;
|
struct hfsplus_fork_raw fork;
|
||||||
struct list_head *pos;
|
struct list_head *pos;
|
||||||
|
@ -242,8 +243,7 @@ int hfsplus_delete_cat(u32 cnid, struct inode *dir, struct qstr *str)
|
||||||
u16 type;
|
u16 type;
|
||||||
|
|
||||||
dprint(DBG_CAT_MOD, "delete_cat: %s,%u\n", str ? str->name : NULL, cnid);
|
dprint(DBG_CAT_MOD, "delete_cat: %s,%u\n", str ? str->name : NULL, cnid);
|
||||||
sb = dir->i_sb;
|
hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd);
|
||||||
hfs_find_init(HFSPLUS_SB(sb).cat_tree, &fd);
|
|
||||||
|
|
||||||
if (!str) {
|
if (!str) {
|
||||||
int len;
|
int len;
|
||||||
|
@ -312,7 +312,7 @@ int hfsplus_rename_cat(u32 cnid,
|
||||||
struct inode *src_dir, struct qstr *src_name,
|
struct inode *src_dir, struct qstr *src_name,
|
||||||
struct inode *dst_dir, struct qstr *dst_name)
|
struct inode *dst_dir, struct qstr *dst_name)
|
||||||
{
|
{
|
||||||
struct super_block *sb;
|
struct super_block *sb = src_dir->i_sb;
|
||||||
struct hfs_find_data src_fd, dst_fd;
|
struct hfs_find_data src_fd, dst_fd;
|
||||||
hfsplus_cat_entry entry;
|
hfsplus_cat_entry entry;
|
||||||
int entry_size, type;
|
int entry_size, type;
|
||||||
|
@ -320,8 +320,7 @@ int hfsplus_rename_cat(u32 cnid,
|
||||||
|
|
||||||
dprint(DBG_CAT_MOD, "rename_cat: %u - %lu,%s - %lu,%s\n", cnid, src_dir->i_ino, src_name->name,
|
dprint(DBG_CAT_MOD, "rename_cat: %u - %lu,%s - %lu,%s\n", cnid, src_dir->i_ino, src_name->name,
|
||||||
dst_dir->i_ino, dst_name->name);
|
dst_dir->i_ino, dst_name->name);
|
||||||
sb = src_dir->i_sb;
|
hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &src_fd);
|
||||||
hfs_find_init(HFSPLUS_SB(sb).cat_tree, &src_fd);
|
|
||||||
dst_fd = src_fd;
|
dst_fd = src_fd;
|
||||||
|
|
||||||
/* find the old dir entry and read the data */
|
/* find the old dir entry and read the data */
|
||||||
|
|
|
@ -39,7 +39,7 @@ static struct dentry *hfsplus_lookup(struct inode *dir, struct dentry *dentry,
|
||||||
|
|
||||||
dentry->d_op = &hfsplus_dentry_operations;
|
dentry->d_op = &hfsplus_dentry_operations;
|
||||||
dentry->d_fsdata = NULL;
|
dentry->d_fsdata = NULL;
|
||||||
hfs_find_init(HFSPLUS_SB(sb).cat_tree, &fd);
|
hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd);
|
||||||
hfsplus_cat_build_key(sb, fd.search_key, dir->i_ino, &dentry->d_name);
|
hfsplus_cat_build_key(sb, fd.search_key, dir->i_ino, &dentry->d_name);
|
||||||
again:
|
again:
|
||||||
err = hfs_brec_read(&fd, &entry, sizeof(entry));
|
err = hfs_brec_read(&fd, &entry, sizeof(entry));
|
||||||
|
@ -68,9 +68,9 @@ again:
|
||||||
cnid = be32_to_cpu(entry.file.id);
|
cnid = be32_to_cpu(entry.file.id);
|
||||||
if (entry.file.user_info.fdType == cpu_to_be32(HFSP_HARDLINK_TYPE) &&
|
if (entry.file.user_info.fdType == cpu_to_be32(HFSP_HARDLINK_TYPE) &&
|
||||||
entry.file.user_info.fdCreator == cpu_to_be32(HFSP_HFSPLUS_CREATOR) &&
|
entry.file.user_info.fdCreator == cpu_to_be32(HFSP_HFSPLUS_CREATOR) &&
|
||||||
(entry.file.create_date == HFSPLUS_I(HFSPLUS_SB(sb).hidden_dir).create_date ||
|
(entry.file.create_date == HFSPLUS_I(HFSPLUS_SB(sb)->hidden_dir).create_date ||
|
||||||
entry.file.create_date == HFSPLUS_I(sb->s_root->d_inode).create_date) &&
|
entry.file.create_date == HFSPLUS_I(sb->s_root->d_inode).create_date) &&
|
||||||
HFSPLUS_SB(sb).hidden_dir) {
|
HFSPLUS_SB(sb)->hidden_dir) {
|
||||||
struct qstr str;
|
struct qstr str;
|
||||||
char name[32];
|
char name[32];
|
||||||
|
|
||||||
|
@ -86,7 +86,8 @@ again:
|
||||||
linkid = be32_to_cpu(entry.file.permissions.dev);
|
linkid = be32_to_cpu(entry.file.permissions.dev);
|
||||||
str.len = sprintf(name, "iNode%d", linkid);
|
str.len = sprintf(name, "iNode%d", linkid);
|
||||||
str.name = name;
|
str.name = name;
|
||||||
hfsplus_cat_build_key(sb, fd.search_key, HFSPLUS_SB(sb).hidden_dir->i_ino, &str);
|
hfsplus_cat_build_key(sb, fd.search_key,
|
||||||
|
HFSPLUS_SB(sb)->hidden_dir->i_ino, &str);
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
} else if (!dentry->d_fsdata)
|
} else if (!dentry->d_fsdata)
|
||||||
|
@ -124,7 +125,7 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
|
||||||
if (filp->f_pos >= inode->i_size)
|
if (filp->f_pos >= inode->i_size)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
hfs_find_init(HFSPLUS_SB(sb).cat_tree, &fd);
|
hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd);
|
||||||
hfsplus_cat_build_key(sb, fd.search_key, inode->i_ino, NULL);
|
hfsplus_cat_build_key(sb, fd.search_key, inode->i_ino, NULL);
|
||||||
err = hfs_brec_find(&fd);
|
err = hfs_brec_find(&fd);
|
||||||
if (err)
|
if (err)
|
||||||
|
@ -180,8 +181,9 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
|
||||||
err = -EIO;
|
err = -EIO;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (HFSPLUS_SB(sb).hidden_dir &&
|
if (HFSPLUS_SB(sb)->hidden_dir &&
|
||||||
HFSPLUS_SB(sb).hidden_dir->i_ino == be32_to_cpu(entry.folder.id))
|
HFSPLUS_SB(sb)->hidden_dir->i_ino ==
|
||||||
|
be32_to_cpu(entry.folder.id))
|
||||||
goto next;
|
goto next;
|
||||||
if (filldir(dirent, strbuf, len, filp->f_pos,
|
if (filldir(dirent, strbuf, len, filp->f_pos,
|
||||||
be32_to_cpu(entry.folder.id), DT_DIR))
|
be32_to_cpu(entry.folder.id), DT_DIR))
|
||||||
|
@ -260,7 +262,7 @@ static int hfsplus_create(struct inode *dir, struct dentry *dentry, int mode,
|
||||||
static int hfsplus_link(struct dentry *src_dentry, struct inode *dst_dir,
|
static int hfsplus_link(struct dentry *src_dentry, struct inode *dst_dir,
|
||||||
struct dentry *dst_dentry)
|
struct dentry *dst_dentry)
|
||||||
{
|
{
|
||||||
struct super_block *sb = dst_dir->i_sb;
|
struct hfsplus_sb_info *sbi = HFSPLUS_SB(dst_dir->i_sb);
|
||||||
struct inode *inode = src_dentry->d_inode;
|
struct inode *inode = src_dentry->d_inode;
|
||||||
struct inode *src_dir = src_dentry->d_parent->d_inode;
|
struct inode *src_dir = src_dentry->d_parent->d_inode;
|
||||||
struct qstr str;
|
struct qstr str;
|
||||||
|
@ -279,22 +281,22 @@ static int hfsplus_link(struct dentry *src_dentry, struct inode *dst_dir,
|
||||||
str.len = sprintf(name, "iNode%d", id);
|
str.len = sprintf(name, "iNode%d", id);
|
||||||
res = hfsplus_rename_cat(inode->i_ino,
|
res = hfsplus_rename_cat(inode->i_ino,
|
||||||
src_dir, &src_dentry->d_name,
|
src_dir, &src_dentry->d_name,
|
||||||
HFSPLUS_SB(sb).hidden_dir, &str);
|
sbi->hidden_dir, &str);
|
||||||
if (!res)
|
if (!res)
|
||||||
break;
|
break;
|
||||||
if (res != -EEXIST)
|
if (res != -EEXIST)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
HFSPLUS_I(inode).dev = id;
|
HFSPLUS_I(inode).dev = id;
|
||||||
cnid = HFSPLUS_SB(sb).next_cnid++;
|
cnid = sbi->next_cnid++;
|
||||||
src_dentry->d_fsdata = (void *)(unsigned long)cnid;
|
src_dentry->d_fsdata = (void *)(unsigned long)cnid;
|
||||||
res = hfsplus_create_cat(cnid, src_dir, &src_dentry->d_name, inode);
|
res = hfsplus_create_cat(cnid, src_dir, &src_dentry->d_name, inode);
|
||||||
if (res)
|
if (res)
|
||||||
/* panic? */
|
/* panic? */
|
||||||
return res;
|
return res;
|
||||||
HFSPLUS_SB(sb).file_count++;
|
sbi->file_count++;
|
||||||
}
|
}
|
||||||
cnid = HFSPLUS_SB(sb).next_cnid++;
|
cnid = sbi->next_cnid++;
|
||||||
res = hfsplus_create_cat(cnid, dst_dir, &dst_dentry->d_name, inode);
|
res = hfsplus_create_cat(cnid, dst_dir, &dst_dentry->d_name, inode);
|
||||||
if (res)
|
if (res)
|
||||||
return res;
|
return res;
|
||||||
|
@ -304,15 +306,15 @@ static int hfsplus_link(struct dentry *src_dentry, struct inode *dst_dir,
|
||||||
atomic_inc(&inode->i_count);
|
atomic_inc(&inode->i_count);
|
||||||
inode->i_ctime = CURRENT_TIME_SEC;
|
inode->i_ctime = CURRENT_TIME_SEC;
|
||||||
mark_inode_dirty(inode);
|
mark_inode_dirty(inode);
|
||||||
HFSPLUS_SB(sb).file_count++;
|
sbi->file_count++;
|
||||||
sb->s_dirt = 1;
|
dst_dir->i_sb->s_dirt = 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hfsplus_unlink(struct inode *dir, struct dentry *dentry)
|
static int hfsplus_unlink(struct inode *dir, struct dentry *dentry)
|
||||||
{
|
{
|
||||||
struct super_block *sb = dir->i_sb;
|
struct hfsplus_sb_info *sbi = HFSPLUS_SB(dir->i_sb);
|
||||||
struct inode *inode = dentry->d_inode;
|
struct inode *inode = dentry->d_inode;
|
||||||
struct qstr str;
|
struct qstr str;
|
||||||
char name[32];
|
char name[32];
|
||||||
|
@ -329,7 +331,7 @@ static int hfsplus_unlink(struct inode *dir, struct dentry *dentry)
|
||||||
str.len = sprintf(name, "temp%lu", inode->i_ino);
|
str.len = sprintf(name, "temp%lu", inode->i_ino);
|
||||||
res = hfsplus_rename_cat(inode->i_ino,
|
res = hfsplus_rename_cat(inode->i_ino,
|
||||||
dir, &dentry->d_name,
|
dir, &dentry->d_name,
|
||||||
HFSPLUS_SB(sb).hidden_dir, &str);
|
sbi->hidden_dir, &str);
|
||||||
if (!res)
|
if (!res)
|
||||||
inode->i_flags |= S_DEAD;
|
inode->i_flags |= S_DEAD;
|
||||||
return res;
|
return res;
|
||||||
|
@ -344,10 +346,10 @@ static int hfsplus_unlink(struct inode *dir, struct dentry *dentry)
|
||||||
clear_nlink(inode);
|
clear_nlink(inode);
|
||||||
if (!inode->i_nlink) {
|
if (!inode->i_nlink) {
|
||||||
if (inode->i_ino != cnid) {
|
if (inode->i_ino != cnid) {
|
||||||
HFSPLUS_SB(sb).file_count--;
|
sbi->file_count--;
|
||||||
if (!atomic_read(&HFSPLUS_I(inode).opencnt)) {
|
if (!atomic_read(&HFSPLUS_I(inode).opencnt)) {
|
||||||
res = hfsplus_delete_cat(inode->i_ino,
|
res = hfsplus_delete_cat(inode->i_ino,
|
||||||
HFSPLUS_SB(sb).hidden_dir,
|
sbi->hidden_dir,
|
||||||
NULL);
|
NULL);
|
||||||
if (!res)
|
if (!res)
|
||||||
hfsplus_delete_inode(inode);
|
hfsplus_delete_inode(inode);
|
||||||
|
@ -356,7 +358,7 @@ static int hfsplus_unlink(struct inode *dir, struct dentry *dentry)
|
||||||
} else
|
} else
|
||||||
hfsplus_delete_inode(inode);
|
hfsplus_delete_inode(inode);
|
||||||
} else
|
} else
|
||||||
HFSPLUS_SB(sb).file_count--;
|
sbi->file_count--;
|
||||||
inode->i_ctime = CURRENT_TIME_SEC;
|
inode->i_ctime = CURRENT_TIME_SEC;
|
||||||
mark_inode_dirty(inode);
|
mark_inode_dirty(inode);
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ void hfsplus_ext_write_extent(struct inode *inode)
|
||||||
if (HFSPLUS_I(inode).flags & HFSPLUS_FLG_EXT_DIRTY) {
|
if (HFSPLUS_I(inode).flags & HFSPLUS_FLG_EXT_DIRTY) {
|
||||||
struct hfs_find_data fd;
|
struct hfs_find_data fd;
|
||||||
|
|
||||||
hfs_find_init(HFSPLUS_SB(inode->i_sb).ext_tree, &fd);
|
hfs_find_init(HFSPLUS_SB(inode->i_sb)->ext_tree, &fd);
|
||||||
__hfsplus_ext_write_extent(inode, &fd);
|
__hfsplus_ext_write_extent(inode, &fd);
|
||||||
hfs_find_exit(&fd);
|
hfs_find_exit(&fd);
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,7 @@ static int hfsplus_ext_read_extent(struct inode *inode, u32 block)
|
||||||
block < HFSPLUS_I(inode).cached_start + HFSPLUS_I(inode).cached_blocks)
|
block < HFSPLUS_I(inode).cached_start + HFSPLUS_I(inode).cached_blocks)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
hfs_find_init(HFSPLUS_SB(inode->i_sb).ext_tree, &fd);
|
hfs_find_init(HFSPLUS_SB(inode->i_sb)->ext_tree, &fd);
|
||||||
res = __hfsplus_ext_cache_extent(&fd, inode, block);
|
res = __hfsplus_ext_cache_extent(&fd, inode, block);
|
||||||
hfs_find_exit(&fd);
|
hfs_find_exit(&fd);
|
||||||
return res;
|
return res;
|
||||||
|
@ -172,16 +172,15 @@ static int hfsplus_ext_read_extent(struct inode *inode, u32 block)
|
||||||
int hfsplus_get_block(struct inode *inode, sector_t iblock,
|
int hfsplus_get_block(struct inode *inode, sector_t iblock,
|
||||||
struct buffer_head *bh_result, int create)
|
struct buffer_head *bh_result, int create)
|
||||||
{
|
{
|
||||||
struct super_block *sb;
|
struct super_block *sb = inode->i_sb;
|
||||||
|
struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
|
||||||
int res = -EIO;
|
int res = -EIO;
|
||||||
u32 ablock, dblock, mask;
|
u32 ablock, dblock, mask;
|
||||||
int shift;
|
int shift;
|
||||||
|
|
||||||
sb = inode->i_sb;
|
|
||||||
|
|
||||||
/* Convert inode block to disk allocation block */
|
/* Convert inode block to disk allocation block */
|
||||||
shift = HFSPLUS_SB(sb).alloc_blksz_shift - sb->s_blocksize_bits;
|
shift = sbi->alloc_blksz_shift - sb->s_blocksize_bits;
|
||||||
ablock = iblock >> HFSPLUS_SB(sb).fs_shift;
|
ablock = iblock >> sbi->fs_shift;
|
||||||
|
|
||||||
if (iblock >= HFSPLUS_I(inode).fs_blocks) {
|
if (iblock >= HFSPLUS_I(inode).fs_blocks) {
|
||||||
if (iblock > HFSPLUS_I(inode).fs_blocks || !create)
|
if (iblock > HFSPLUS_I(inode).fs_blocks || !create)
|
||||||
|
@ -215,8 +214,8 @@ int hfsplus_get_block(struct inode *inode, sector_t iblock,
|
||||||
|
|
||||||
done:
|
done:
|
||||||
dprint(DBG_EXTENT, "get_block(%lu): %llu - %u\n", inode->i_ino, (long long)iblock, dblock);
|
dprint(DBG_EXTENT, "get_block(%lu): %llu - %u\n", inode->i_ino, (long long)iblock, dblock);
|
||||||
mask = (1 << HFSPLUS_SB(sb).fs_shift) - 1;
|
mask = (1 << sbi->fs_shift) - 1;
|
||||||
map_bh(bh_result, sb, (dblock << HFSPLUS_SB(sb).fs_shift) + HFSPLUS_SB(sb).blockoffset + (iblock & mask));
|
map_bh(bh_result, sb, (dblock << sbi->fs_shift) + sbi->blockoffset + (iblock & mask));
|
||||||
if (create) {
|
if (create) {
|
||||||
set_buffer_new(bh_result);
|
set_buffer_new(bh_result);
|
||||||
HFSPLUS_I(inode).phys_size += sb->s_blocksize;
|
HFSPLUS_I(inode).phys_size += sb->s_blocksize;
|
||||||
|
@ -327,7 +326,7 @@ int hfsplus_free_fork(struct super_block *sb, u32 cnid, struct hfsplus_fork_raw
|
||||||
if (total_blocks == blocks)
|
if (total_blocks == blocks)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
hfs_find_init(HFSPLUS_SB(sb).ext_tree, &fd);
|
hfs_find_init(HFSPLUS_SB(sb)->ext_tree, &fd);
|
||||||
do {
|
do {
|
||||||
res = __hfsplus_ext_read_extent(&fd, ext_entry, cnid,
|
res = __hfsplus_ext_read_extent(&fd, ext_entry, cnid,
|
||||||
total_blocks, type);
|
total_blocks, type);
|
||||||
|
@ -348,13 +347,16 @@ int hfsplus_free_fork(struct super_block *sb, u32 cnid, struct hfsplus_fork_raw
|
||||||
int hfsplus_file_extend(struct inode *inode)
|
int hfsplus_file_extend(struct inode *inode)
|
||||||
{
|
{
|
||||||
struct super_block *sb = inode->i_sb;
|
struct super_block *sb = inode->i_sb;
|
||||||
|
struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
|
||||||
u32 start, len, goal;
|
u32 start, len, goal;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
if (HFSPLUS_SB(sb).alloc_file->i_size * 8 < HFSPLUS_SB(sb).total_blocks - HFSPLUS_SB(sb).free_blocks + 8) {
|
if (sbi->alloc_file->i_size * 8 <
|
||||||
|
sbi->total_blocks - sbi->free_blocks + 8) {
|
||||||
// extend alloc file
|
// extend alloc file
|
||||||
printk(KERN_ERR "hfs: extend alloc file! (%Lu,%u,%u)\n", HFSPLUS_SB(sb).alloc_file->i_size * 8,
|
printk(KERN_ERR "hfs: extend alloc file! (%Lu,%u,%u)\n",
|
||||||
HFSPLUS_SB(sb).total_blocks, HFSPLUS_SB(sb).free_blocks);
|
sbi->alloc_file->i_size * 8,
|
||||||
|
sbi->total_blocks, sbi->free_blocks);
|
||||||
return -ENOSPC;
|
return -ENOSPC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,8 +371,8 @@ int hfsplus_file_extend(struct inode *inode)
|
||||||
}
|
}
|
||||||
|
|
||||||
len = HFSPLUS_I(inode).clump_blocks;
|
len = HFSPLUS_I(inode).clump_blocks;
|
||||||
start = hfsplus_block_allocate(sb, HFSPLUS_SB(sb).total_blocks, goal, &len);
|
start = hfsplus_block_allocate(sb, sbi->total_blocks, goal, &len);
|
||||||
if (start >= HFSPLUS_SB(sb).total_blocks) {
|
if (start >= sbi->total_blocks) {
|
||||||
start = hfsplus_block_allocate(sb, goal, 0, &len);
|
start = hfsplus_block_allocate(sb, goal, 0, &len);
|
||||||
if (start >= goal) {
|
if (start >= goal) {
|
||||||
res = -ENOSPC;
|
res = -ENOSPC;
|
||||||
|
@ -463,13 +465,14 @@ void hfsplus_file_truncate(struct inode *inode)
|
||||||
} else if (inode->i_size == HFSPLUS_I(inode).phys_size)
|
} else if (inode->i_size == HFSPLUS_I(inode).phys_size)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
blk_cnt = (inode->i_size + HFSPLUS_SB(sb).alloc_blksz - 1) >> HFSPLUS_SB(sb).alloc_blksz_shift;
|
blk_cnt = (inode->i_size + HFSPLUS_SB(sb)->alloc_blksz - 1) >>
|
||||||
|
HFSPLUS_SB(sb)->alloc_blksz_shift;
|
||||||
alloc_cnt = HFSPLUS_I(inode).alloc_blocks;
|
alloc_cnt = HFSPLUS_I(inode).alloc_blocks;
|
||||||
if (blk_cnt == alloc_cnt)
|
if (blk_cnt == alloc_cnt)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
mutex_lock(&HFSPLUS_I(inode).extents_lock);
|
mutex_lock(&HFSPLUS_I(inode).extents_lock);
|
||||||
hfs_find_init(HFSPLUS_SB(sb).ext_tree, &fd);
|
hfs_find_init(HFSPLUS_SB(sb)->ext_tree, &fd);
|
||||||
while (1) {
|
while (1) {
|
||||||
if (alloc_cnt == HFSPLUS_I(inode).first_blocks) {
|
if (alloc_cnt == HFSPLUS_I(inode).first_blocks) {
|
||||||
hfsplus_free_extents(sb, HFSPLUS_I(inode).first_extents,
|
hfsplus_free_extents(sb, HFSPLUS_I(inode).first_extents,
|
||||||
|
|
|
@ -375,17 +375,16 @@ int hfsplus_read_wrapper(struct super_block *);
|
||||||
int hfs_part_find(struct super_block *, sector_t *, sector_t *);
|
int hfs_part_find(struct super_block *, sector_t *, sector_t *);
|
||||||
|
|
||||||
/* access macros */
|
/* access macros */
|
||||||
/*
|
|
||||||
static inline struct hfsplus_sb_info *HFSPLUS_SB(struct super_block *sb)
|
static inline struct hfsplus_sb_info *HFSPLUS_SB(struct super_block *sb)
|
||||||
{
|
{
|
||||||
return sb->s_fs_info;
|
return sb->s_fs_info;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
static inline struct hfsplus_inode_info *HFSPLUS_I(struct inode *inode)
|
static inline struct hfsplus_inode_info *HFSPLUS_I(struct inode *inode)
|
||||||
{
|
{
|
||||||
return list_entry(inode, struct hfsplus_inode_info, vfs_inode);
|
return list_entry(inode, struct hfsplus_inode_info, vfs_inode);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
#define HFSPLUS_SB(super) (*(struct hfsplus_sb_info *)(super)->s_fs_info)
|
|
||||||
#define HFSPLUS_I(inode) (*list_entry(inode, struct hfsplus_inode_info, vfs_inode))
|
#define HFSPLUS_I(inode) (*list_entry(inode, struct hfsplus_inode_info, vfs_inode))
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
|
|
|
@ -62,13 +62,13 @@ static int hfsplus_releasepage(struct page *page, gfp_t mask)
|
||||||
|
|
||||||
switch (inode->i_ino) {
|
switch (inode->i_ino) {
|
||||||
case HFSPLUS_EXT_CNID:
|
case HFSPLUS_EXT_CNID:
|
||||||
tree = HFSPLUS_SB(sb).ext_tree;
|
tree = HFSPLUS_SB(sb)->ext_tree;
|
||||||
break;
|
break;
|
||||||
case HFSPLUS_CAT_CNID:
|
case HFSPLUS_CAT_CNID:
|
||||||
tree = HFSPLUS_SB(sb).cat_tree;
|
tree = HFSPLUS_SB(sb)->cat_tree;
|
||||||
break;
|
break;
|
||||||
case HFSPLUS_ATTR_CNID:
|
case HFSPLUS_ATTR_CNID:
|
||||||
tree = HFSPLUS_SB(sb).attr_tree;
|
tree = HFSPLUS_SB(sb)->attr_tree;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
BUG();
|
BUG();
|
||||||
|
@ -190,7 +190,7 @@ static struct dentry *hfsplus_file_lookup(struct inode *dir, struct dentry *dent
|
||||||
mutex_init(&HFSPLUS_I(inode).extents_lock);
|
mutex_init(&HFSPLUS_I(inode).extents_lock);
|
||||||
HFSPLUS_I(inode).flags = HFSPLUS_FLG_RSRC;
|
HFSPLUS_I(inode).flags = HFSPLUS_FLG_RSRC;
|
||||||
|
|
||||||
hfs_find_init(HFSPLUS_SB(sb).cat_tree, &fd);
|
hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd);
|
||||||
err = hfsplus_find_cat(sb, dir->i_ino, &fd);
|
err = hfsplus_find_cat(sb, dir->i_ino, &fd);
|
||||||
if (!err)
|
if (!err)
|
||||||
err = hfsplus_cat_read_inode(inode, &fd);
|
err = hfsplus_cat_read_inode(inode, &fd);
|
||||||
|
@ -202,7 +202,7 @@ static struct dentry *hfsplus_file_lookup(struct inode *dir, struct dentry *dent
|
||||||
HFSPLUS_I(inode).rsrc_inode = dir;
|
HFSPLUS_I(inode).rsrc_inode = dir;
|
||||||
HFSPLUS_I(dir).rsrc_inode = inode;
|
HFSPLUS_I(dir).rsrc_inode = inode;
|
||||||
igrab(dir);
|
igrab(dir);
|
||||||
hlist_add_head(&inode->i_hash, &HFSPLUS_SB(sb).rsrc_inodes);
|
hlist_add_head(&inode->i_hash, &HFSPLUS_SB(sb)->rsrc_inodes);
|
||||||
mark_inode_dirty(inode);
|
mark_inode_dirty(inode);
|
||||||
out:
|
out:
|
||||||
d_add(dentry, inode);
|
d_add(dentry, inode);
|
||||||
|
@ -211,26 +211,24 @@ out:
|
||||||
|
|
||||||
static void hfsplus_get_perms(struct inode *inode, struct hfsplus_perm *perms, int dir)
|
static void hfsplus_get_perms(struct inode *inode, struct hfsplus_perm *perms, int dir)
|
||||||
{
|
{
|
||||||
struct super_block *sb = inode->i_sb;
|
struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode->i_sb);
|
||||||
u16 mode;
|
u16 mode;
|
||||||
|
|
||||||
mode = be16_to_cpu(perms->mode);
|
mode = be16_to_cpu(perms->mode);
|
||||||
|
|
||||||
inode->i_uid = be32_to_cpu(perms->owner);
|
inode->i_uid = be32_to_cpu(perms->owner);
|
||||||
if (!inode->i_uid && !mode)
|
if (!inode->i_uid && !mode)
|
||||||
inode->i_uid = HFSPLUS_SB(sb).uid;
|
inode->i_uid = sbi->uid;
|
||||||
|
|
||||||
inode->i_gid = be32_to_cpu(perms->group);
|
inode->i_gid = be32_to_cpu(perms->group);
|
||||||
if (!inode->i_gid && !mode)
|
if (!inode->i_gid && !mode)
|
||||||
inode->i_gid = HFSPLUS_SB(sb).gid;
|
inode->i_gid = sbi->gid;
|
||||||
|
|
||||||
if (dir) {
|
if (dir) {
|
||||||
mode = mode ? (mode & S_IALLUGO) :
|
mode = mode ? (mode & S_IALLUGO) : (S_IRWXUGO & ~(sbi->umask));
|
||||||
(S_IRWXUGO & ~(HFSPLUS_SB(sb).umask));
|
|
||||||
mode |= S_IFDIR;
|
mode |= S_IFDIR;
|
||||||
} else if (!mode)
|
} else if (!mode)
|
||||||
mode = S_IFREG | ((S_IRUGO|S_IWUGO) &
|
mode = S_IFREG | ((S_IRUGO|S_IWUGO) & ~(sbi->umask));
|
||||||
~(HFSPLUS_SB(sb).umask));
|
|
||||||
inode->i_mode = mode;
|
inode->i_mode = mode;
|
||||||
|
|
||||||
HFSPLUS_I(inode).rootflags = perms->rootflags;
|
HFSPLUS_I(inode).rootflags = perms->rootflags;
|
||||||
|
@ -282,7 +280,8 @@ static int hfsplus_file_release(struct inode *inode, struct file *file)
|
||||||
mutex_lock(&inode->i_mutex);
|
mutex_lock(&inode->i_mutex);
|
||||||
hfsplus_file_truncate(inode);
|
hfsplus_file_truncate(inode);
|
||||||
if (inode->i_flags & S_DEAD) {
|
if (inode->i_flags & S_DEAD) {
|
||||||
hfsplus_delete_cat(inode->i_ino, HFSPLUS_SB(sb).hidden_dir, NULL);
|
hfsplus_delete_cat(inode->i_ino,
|
||||||
|
HFSPLUS_SB(sb)->hidden_dir, NULL);
|
||||||
hfsplus_delete_inode(inode);
|
hfsplus_delete_inode(inode);
|
||||||
}
|
}
|
||||||
mutex_unlock(&inode->i_mutex);
|
mutex_unlock(&inode->i_mutex);
|
||||||
|
@ -361,11 +360,13 @@ static const struct file_operations hfsplus_file_operations = {
|
||||||
|
|
||||||
struct inode *hfsplus_new_inode(struct super_block *sb, int mode)
|
struct inode *hfsplus_new_inode(struct super_block *sb, int mode)
|
||||||
{
|
{
|
||||||
|
struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
|
||||||
struct inode *inode = new_inode(sb);
|
struct inode *inode = new_inode(sb);
|
||||||
|
|
||||||
if (!inode)
|
if (!inode)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
inode->i_ino = HFSPLUS_SB(sb).next_cnid++;
|
inode->i_ino = sbi->next_cnid++;
|
||||||
inode->i_mode = mode;
|
inode->i_mode = mode;
|
||||||
inode->i_uid = current_fsuid();
|
inode->i_uid = current_fsuid();
|
||||||
inode->i_gid = current_fsgid();
|
inode->i_gid = current_fsgid();
|
||||||
|
@ -386,22 +387,22 @@ struct inode *hfsplus_new_inode(struct super_block *sb, int mode)
|
||||||
HFSPLUS_I(inode).rsrc_inode = NULL;
|
HFSPLUS_I(inode).rsrc_inode = NULL;
|
||||||
if (S_ISDIR(inode->i_mode)) {
|
if (S_ISDIR(inode->i_mode)) {
|
||||||
inode->i_size = 2;
|
inode->i_size = 2;
|
||||||
HFSPLUS_SB(sb).folder_count++;
|
sbi->folder_count++;
|
||||||
inode->i_op = &hfsplus_dir_inode_operations;
|
inode->i_op = &hfsplus_dir_inode_operations;
|
||||||
inode->i_fop = &hfsplus_dir_operations;
|
inode->i_fop = &hfsplus_dir_operations;
|
||||||
} else if (S_ISREG(inode->i_mode)) {
|
} else if (S_ISREG(inode->i_mode)) {
|
||||||
HFSPLUS_SB(sb).file_count++;
|
sbi->file_count++;
|
||||||
inode->i_op = &hfsplus_file_inode_operations;
|
inode->i_op = &hfsplus_file_inode_operations;
|
||||||
inode->i_fop = &hfsplus_file_operations;
|
inode->i_fop = &hfsplus_file_operations;
|
||||||
inode->i_mapping->a_ops = &hfsplus_aops;
|
inode->i_mapping->a_ops = &hfsplus_aops;
|
||||||
HFSPLUS_I(inode).clump_blocks = HFSPLUS_SB(sb).data_clump_blocks;
|
HFSPLUS_I(inode).clump_blocks = sbi->data_clump_blocks;
|
||||||
} else if (S_ISLNK(inode->i_mode)) {
|
} else if (S_ISLNK(inode->i_mode)) {
|
||||||
HFSPLUS_SB(sb).file_count++;
|
sbi->file_count++;
|
||||||
inode->i_op = &page_symlink_inode_operations;
|
inode->i_op = &page_symlink_inode_operations;
|
||||||
inode->i_mapping->a_ops = &hfsplus_aops;
|
inode->i_mapping->a_ops = &hfsplus_aops;
|
||||||
HFSPLUS_I(inode).clump_blocks = 1;
|
HFSPLUS_I(inode).clump_blocks = 1;
|
||||||
} else
|
} else
|
||||||
HFSPLUS_SB(sb).file_count++;
|
sbi->file_count++;
|
||||||
insert_inode_hash(inode);
|
insert_inode_hash(inode);
|
||||||
mark_inode_dirty(inode);
|
mark_inode_dirty(inode);
|
||||||
sb->s_dirt = 1;
|
sb->s_dirt = 1;
|
||||||
|
@ -414,11 +415,11 @@ void hfsplus_delete_inode(struct inode *inode)
|
||||||
struct super_block *sb = inode->i_sb;
|
struct super_block *sb = inode->i_sb;
|
||||||
|
|
||||||
if (S_ISDIR(inode->i_mode)) {
|
if (S_ISDIR(inode->i_mode)) {
|
||||||
HFSPLUS_SB(sb).folder_count--;
|
HFSPLUS_SB(sb)->folder_count--;
|
||||||
sb->s_dirt = 1;
|
sb->s_dirt = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
HFSPLUS_SB(sb).file_count--;
|
HFSPLUS_SB(sb)->file_count--;
|
||||||
if (S_ISREG(inode->i_mode)) {
|
if (S_ISREG(inode->i_mode)) {
|
||||||
if (!inode->i_nlink) {
|
if (!inode->i_nlink) {
|
||||||
inode->i_size = 0;
|
inode->i_size = 0;
|
||||||
|
@ -434,6 +435,7 @@ void hfsplus_delete_inode(struct inode *inode)
|
||||||
void hfsplus_inode_read_fork(struct inode *inode, struct hfsplus_fork_raw *fork)
|
void hfsplus_inode_read_fork(struct inode *inode, struct hfsplus_fork_raw *fork)
|
||||||
{
|
{
|
||||||
struct super_block *sb = inode->i_sb;
|
struct super_block *sb = inode->i_sb;
|
||||||
|
struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
|
||||||
u32 count;
|
u32 count;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -450,10 +452,13 @@ void hfsplus_inode_read_fork(struct inode *inode, struct hfsplus_fork_raw *fork)
|
||||||
inode->i_size = HFSPLUS_I(inode).phys_size = be64_to_cpu(fork->total_size);
|
inode->i_size = HFSPLUS_I(inode).phys_size = be64_to_cpu(fork->total_size);
|
||||||
HFSPLUS_I(inode).fs_blocks = (inode->i_size + sb->s_blocksize - 1) >> sb->s_blocksize_bits;
|
HFSPLUS_I(inode).fs_blocks = (inode->i_size + sb->s_blocksize - 1) >> sb->s_blocksize_bits;
|
||||||
inode_set_bytes(inode, HFSPLUS_I(inode).fs_blocks << sb->s_blocksize_bits);
|
inode_set_bytes(inode, HFSPLUS_I(inode).fs_blocks << sb->s_blocksize_bits);
|
||||||
HFSPLUS_I(inode).clump_blocks = be32_to_cpu(fork->clump_size) >> HFSPLUS_SB(sb).alloc_blksz_shift;
|
HFSPLUS_I(inode).clump_blocks =
|
||||||
if (!HFSPLUS_I(inode).clump_blocks)
|
be32_to_cpu(fork->clump_size) >> sbi->alloc_blksz_shift;
|
||||||
HFSPLUS_I(inode).clump_blocks = HFSPLUS_IS_RSRC(inode) ? HFSPLUS_SB(sb).rsrc_clump_blocks :
|
if (!HFSPLUS_I(inode).clump_blocks) {
|
||||||
HFSPLUS_SB(sb).data_clump_blocks;
|
HFSPLUS_I(inode).clump_blocks = HFSPLUS_IS_RSRC(inode) ?
|
||||||
|
sbi->rsrc_clump_blocks :
|
||||||
|
sbi->data_clump_blocks;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void hfsplus_inode_write_fork(struct inode *inode, struct hfsplus_fork_raw *fork)
|
void hfsplus_inode_write_fork(struct inode *inode, struct hfsplus_fork_raw *fork)
|
||||||
|
@ -538,7 +543,7 @@ int hfsplus_cat_write_inode(struct inode *inode)
|
||||||
if (!main_inode->i_nlink)
|
if (!main_inode->i_nlink)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (hfs_find_init(HFSPLUS_SB(main_inode->i_sb).cat_tree, &fd))
|
if (hfs_find_init(HFSPLUS_SB(main_inode->i_sb)->cat_tree, &fd))
|
||||||
/* panic? */
|
/* panic? */
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ int hfsplus_setxattr(struct dentry *dentry, const char *name,
|
||||||
if (!S_ISREG(inode->i_mode) || HFSPLUS_IS_RSRC(inode))
|
if (!S_ISREG(inode->i_mode) || HFSPLUS_IS_RSRC(inode))
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
res = hfs_find_init(HFSPLUS_SB(inode->i_sb).cat_tree, &fd);
|
res = hfs_find_init(HFSPLUS_SB(inode->i_sb)->cat_tree, &fd);
|
||||||
if (res)
|
if (res)
|
||||||
return res;
|
return res;
|
||||||
res = hfsplus_find_cat(inode->i_sb, inode->i_ino, &fd);
|
res = hfsplus_find_cat(inode->i_sb, inode->i_ino, &fd);
|
||||||
|
@ -169,7 +169,7 @@ ssize_t hfsplus_getxattr(struct dentry *dentry, const char *name,
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
if (size) {
|
if (size) {
|
||||||
res = hfs_find_init(HFSPLUS_SB(inode->i_sb).cat_tree, &fd);
|
res = hfs_find_init(HFSPLUS_SB(inode->i_sb)->cat_tree, &fd);
|
||||||
if (res)
|
if (res)
|
||||||
return res;
|
return res;
|
||||||
res = hfsplus_find_cat(inode->i_sb, inode->i_ino, &fd);
|
res = hfsplus_find_cat(inode->i_sb, inode->i_ino, &fd);
|
||||||
|
|
|
@ -171,7 +171,7 @@ done:
|
||||||
|
|
||||||
int hfsplus_show_options(struct seq_file *seq, struct vfsmount *mnt)
|
int hfsplus_show_options(struct seq_file *seq, struct vfsmount *mnt)
|
||||||
{
|
{
|
||||||
struct hfsplus_sb_info *sbi = &HFSPLUS_SB(mnt->mnt_sb);
|
struct hfsplus_sb_info *sbi = HFSPLUS_SB(mnt->mnt_sb);
|
||||||
|
|
||||||
if (sbi->creator != HFSPLUS_DEF_CR_TYPE)
|
if (sbi->creator != HFSPLUS_DEF_CR_TYPE)
|
||||||
seq_printf(seq, ",creator=%.4s", (char *)&sbi->creator);
|
seq_printf(seq, ",creator=%.4s", (char *)&sbi->creator);
|
||||||
|
|
|
@ -74,6 +74,7 @@ struct old_pmap {
|
||||||
int hfs_part_find(struct super_block *sb,
|
int hfs_part_find(struct super_block *sb,
|
||||||
sector_t *part_start, sector_t *part_size)
|
sector_t *part_start, sector_t *part_size)
|
||||||
{
|
{
|
||||||
|
struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
|
||||||
struct buffer_head *bh;
|
struct buffer_head *bh;
|
||||||
__be16 *data;
|
__be16 *data;
|
||||||
int i, size, res;
|
int i, size, res;
|
||||||
|
@ -95,7 +96,7 @@ int hfs_part_find(struct super_block *sb,
|
||||||
for (i = 0; i < size; p++, i++) {
|
for (i = 0; i < size; p++, i++) {
|
||||||
if (p->pdStart && p->pdSize &&
|
if (p->pdStart && p->pdSize &&
|
||||||
p->pdFSID == cpu_to_be32(0x54465331)/*"TFS1"*/ &&
|
p->pdFSID == cpu_to_be32(0x54465331)/*"TFS1"*/ &&
|
||||||
(HFSPLUS_SB(sb).part < 0 || HFSPLUS_SB(sb).part == i)) {
|
(sbi->part < 0 || sbi->part == i)) {
|
||||||
*part_start += be32_to_cpu(p->pdStart);
|
*part_start += be32_to_cpu(p->pdStart);
|
||||||
*part_size = be32_to_cpu(p->pdSize);
|
*part_size = be32_to_cpu(p->pdSize);
|
||||||
res = 0;
|
res = 0;
|
||||||
|
@ -111,7 +112,7 @@ int hfs_part_find(struct super_block *sb,
|
||||||
size = be32_to_cpu(pm->pmMapBlkCnt);
|
size = be32_to_cpu(pm->pmMapBlkCnt);
|
||||||
for (i = 0; i < size;) {
|
for (i = 0; i < size;) {
|
||||||
if (!memcmp(pm->pmPartType,"Apple_HFS", 9) &&
|
if (!memcmp(pm->pmPartType,"Apple_HFS", 9) &&
|
||||||
(HFSPLUS_SB(sb).part < 0 || HFSPLUS_SB(sb).part == i)) {
|
(sbi->part < 0 || sbi->part == i)) {
|
||||||
*part_start += be32_to_cpu(pm->pmPyPartStart);
|
*part_start += be32_to_cpu(pm->pmPyPartStart);
|
||||||
*part_size = be32_to_cpu(pm->pmPartBlkCnt);
|
*part_size = be32_to_cpu(pm->pmPartBlkCnt);
|
||||||
res = 0;
|
res = 0;
|
||||||
|
|
|
@ -41,7 +41,7 @@ struct inode *hfsplus_iget(struct super_block *sb, unsigned long ino)
|
||||||
|
|
||||||
if (inode->i_ino >= HFSPLUS_FIRSTUSER_CNID) {
|
if (inode->i_ino >= HFSPLUS_FIRSTUSER_CNID) {
|
||||||
read_inode:
|
read_inode:
|
||||||
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);
|
||||||
|
@ -50,7 +50,7 @@ struct inode *hfsplus_iget(struct super_block *sb, unsigned long ino)
|
||||||
goto bad_inode;
|
goto bad_inode;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
vhdr = HFSPLUS_SB(inode->i_sb).s_vhdr;
|
vhdr = HFSPLUS_SB(inode->i_sb)->s_vhdr;
|
||||||
switch(inode->i_ino) {
|
switch(inode->i_ino) {
|
||||||
case HFSPLUS_ROOT_CNID:
|
case HFSPLUS_ROOT_CNID:
|
||||||
goto read_inode;
|
goto read_inode;
|
||||||
|
@ -89,6 +89,7 @@ bad_inode:
|
||||||
static int hfsplus_write_inode(struct inode *inode,
|
static int hfsplus_write_inode(struct inode *inode,
|
||||||
struct writeback_control *wbc)
|
struct writeback_control *wbc)
|
||||||
{
|
{
|
||||||
|
struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode->i_sb);
|
||||||
struct hfsplus_vh *vhdr;
|
struct hfsplus_vh *vhdr;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
@ -97,48 +98,48 @@ static int hfsplus_write_inode(struct inode *inode,
|
||||||
if (inode->i_ino >= HFSPLUS_FIRSTUSER_CNID) {
|
if (inode->i_ino >= HFSPLUS_FIRSTUSER_CNID) {
|
||||||
return hfsplus_cat_write_inode(inode);
|
return hfsplus_cat_write_inode(inode);
|
||||||
}
|
}
|
||||||
vhdr = HFSPLUS_SB(inode->i_sb).s_vhdr;
|
vhdr = sbi->s_vhdr;
|
||||||
switch (inode->i_ino) {
|
switch (inode->i_ino) {
|
||||||
case HFSPLUS_ROOT_CNID:
|
case HFSPLUS_ROOT_CNID:
|
||||||
ret = hfsplus_cat_write_inode(inode);
|
ret = hfsplus_cat_write_inode(inode);
|
||||||
break;
|
break;
|
||||||
case HFSPLUS_EXT_CNID:
|
case HFSPLUS_EXT_CNID:
|
||||||
if (vhdr->ext_file.total_size != cpu_to_be64(inode->i_size)) {
|
if (vhdr->ext_file.total_size != cpu_to_be64(inode->i_size)) {
|
||||||
HFSPLUS_SB(inode->i_sb).flags |= HFSPLUS_SB_WRITEBACKUP;
|
sbi->flags |= HFSPLUS_SB_WRITEBACKUP;
|
||||||
inode->i_sb->s_dirt = 1;
|
inode->i_sb->s_dirt = 1;
|
||||||
}
|
}
|
||||||
hfsplus_inode_write_fork(inode, &vhdr->ext_file);
|
hfsplus_inode_write_fork(inode, &vhdr->ext_file);
|
||||||
hfs_btree_write(HFSPLUS_SB(inode->i_sb).ext_tree);
|
hfs_btree_write(sbi->ext_tree);
|
||||||
break;
|
break;
|
||||||
case HFSPLUS_CAT_CNID:
|
case HFSPLUS_CAT_CNID:
|
||||||
if (vhdr->cat_file.total_size != cpu_to_be64(inode->i_size)) {
|
if (vhdr->cat_file.total_size != cpu_to_be64(inode->i_size)) {
|
||||||
HFSPLUS_SB(inode->i_sb).flags |= HFSPLUS_SB_WRITEBACKUP;
|
sbi->flags |= HFSPLUS_SB_WRITEBACKUP;
|
||||||
inode->i_sb->s_dirt = 1;
|
inode->i_sb->s_dirt = 1;
|
||||||
}
|
}
|
||||||
hfsplus_inode_write_fork(inode, &vhdr->cat_file);
|
hfsplus_inode_write_fork(inode, &vhdr->cat_file);
|
||||||
hfs_btree_write(HFSPLUS_SB(inode->i_sb).cat_tree);
|
hfs_btree_write(sbi->cat_tree);
|
||||||
break;
|
break;
|
||||||
case HFSPLUS_ALLOC_CNID:
|
case HFSPLUS_ALLOC_CNID:
|
||||||
if (vhdr->alloc_file.total_size != cpu_to_be64(inode->i_size)) {
|
if (vhdr->alloc_file.total_size != cpu_to_be64(inode->i_size)) {
|
||||||
HFSPLUS_SB(inode->i_sb).flags |= HFSPLUS_SB_WRITEBACKUP;
|
sbi->flags |= HFSPLUS_SB_WRITEBACKUP;
|
||||||
inode->i_sb->s_dirt = 1;
|
inode->i_sb->s_dirt = 1;
|
||||||
}
|
}
|
||||||
hfsplus_inode_write_fork(inode, &vhdr->alloc_file);
|
hfsplus_inode_write_fork(inode, &vhdr->alloc_file);
|
||||||
break;
|
break;
|
||||||
case HFSPLUS_START_CNID:
|
case HFSPLUS_START_CNID:
|
||||||
if (vhdr->start_file.total_size != cpu_to_be64(inode->i_size)) {
|
if (vhdr->start_file.total_size != cpu_to_be64(inode->i_size)) {
|
||||||
HFSPLUS_SB(inode->i_sb).flags |= HFSPLUS_SB_WRITEBACKUP;
|
sbi->flags |= HFSPLUS_SB_WRITEBACKUP;
|
||||||
inode->i_sb->s_dirt = 1;
|
inode->i_sb->s_dirt = 1;
|
||||||
}
|
}
|
||||||
hfsplus_inode_write_fork(inode, &vhdr->start_file);
|
hfsplus_inode_write_fork(inode, &vhdr->start_file);
|
||||||
break;
|
break;
|
||||||
case HFSPLUS_ATTR_CNID:
|
case HFSPLUS_ATTR_CNID:
|
||||||
if (vhdr->attr_file.total_size != cpu_to_be64(inode->i_size)) {
|
if (vhdr->attr_file.total_size != cpu_to_be64(inode->i_size)) {
|
||||||
HFSPLUS_SB(inode->i_sb).flags |= HFSPLUS_SB_WRITEBACKUP;
|
sbi->flags |= HFSPLUS_SB_WRITEBACKUP;
|
||||||
inode->i_sb->s_dirt = 1;
|
inode->i_sb->s_dirt = 1;
|
||||||
}
|
}
|
||||||
hfsplus_inode_write_fork(inode, &vhdr->attr_file);
|
hfsplus_inode_write_fork(inode, &vhdr->attr_file);
|
||||||
hfs_btree_write(HFSPLUS_SB(inode->i_sb).attr_tree);
|
hfs_btree_write(sbi->attr_tree);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -157,44 +158,46 @@ static void hfsplus_evict_inode(struct inode *inode)
|
||||||
|
|
||||||
int hfsplus_sync_fs(struct super_block *sb, int wait)
|
int hfsplus_sync_fs(struct super_block *sb, int wait)
|
||||||
{
|
{
|
||||||
struct hfsplus_vh *vhdr = HFSPLUS_SB(sb).s_vhdr;
|
struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
|
||||||
|
struct hfsplus_vh *vhdr = sbi->s_vhdr;
|
||||||
|
|
||||||
dprint(DBG_SUPER, "hfsplus_write_super\n");
|
dprint(DBG_SUPER, "hfsplus_write_super\n");
|
||||||
|
|
||||||
mutex_lock(&HFSPLUS_SB(sb).alloc_mutex);
|
mutex_lock(&sbi->alloc_mutex);
|
||||||
sb->s_dirt = 0;
|
sb->s_dirt = 0;
|
||||||
|
|
||||||
vhdr->free_blocks = cpu_to_be32(HFSPLUS_SB(sb).free_blocks);
|
vhdr->free_blocks = cpu_to_be32(sbi->free_blocks);
|
||||||
vhdr->next_alloc = cpu_to_be32(HFSPLUS_SB(sb).next_alloc);
|
vhdr->next_alloc = cpu_to_be32(sbi->next_alloc);
|
||||||
vhdr->next_cnid = cpu_to_be32(HFSPLUS_SB(sb).next_cnid);
|
vhdr->next_cnid = cpu_to_be32(sbi->next_cnid);
|
||||||
vhdr->folder_count = cpu_to_be32(HFSPLUS_SB(sb).folder_count);
|
vhdr->folder_count = cpu_to_be32(sbi->folder_count);
|
||||||
vhdr->file_count = cpu_to_be32(HFSPLUS_SB(sb).file_count);
|
vhdr->file_count = cpu_to_be32(sbi->file_count);
|
||||||
|
|
||||||
mark_buffer_dirty(HFSPLUS_SB(sb).s_vhbh);
|
mark_buffer_dirty(sbi->s_vhbh);
|
||||||
if (HFSPLUS_SB(sb).flags & HFSPLUS_SB_WRITEBACKUP) {
|
if (sbi->flags & HFSPLUS_SB_WRITEBACKUP) {
|
||||||
if (HFSPLUS_SB(sb).sect_count) {
|
if (sbi->sect_count) {
|
||||||
struct buffer_head *bh;
|
struct buffer_head *bh;
|
||||||
u32 block, offset;
|
u32 block, offset;
|
||||||
|
|
||||||
block = HFSPLUS_SB(sb).blockoffset;
|
block = sbi->blockoffset;
|
||||||
block += (HFSPLUS_SB(sb).sect_count - 2) >> (sb->s_blocksize_bits - 9);
|
block += (sbi->sect_count - 2) >> (sb->s_blocksize_bits - 9);
|
||||||
offset = ((HFSPLUS_SB(sb).sect_count - 2) << 9) & (sb->s_blocksize - 1);
|
offset = ((sbi->sect_count - 2) << 9) & (sb->s_blocksize - 1);
|
||||||
printk(KERN_DEBUG "hfs: backup: %u,%u,%u,%u\n", HFSPLUS_SB(sb).blockoffset,
|
printk(KERN_DEBUG "hfs: backup: %u,%u,%u,%u\n",
|
||||||
HFSPLUS_SB(sb).sect_count, block, offset);
|
sbi->blockoffset, sbi->sect_count,
|
||||||
|
block, offset);
|
||||||
bh = sb_bread(sb, block);
|
bh = sb_bread(sb, block);
|
||||||
if (bh) {
|
if (bh) {
|
||||||
vhdr = (struct hfsplus_vh *)(bh->b_data + offset);
|
vhdr = (struct hfsplus_vh *)(bh->b_data + offset);
|
||||||
if (be16_to_cpu(vhdr->signature) == HFSPLUS_VOLHEAD_SIG) {
|
if (be16_to_cpu(vhdr->signature) == HFSPLUS_VOLHEAD_SIG) {
|
||||||
memcpy(vhdr, HFSPLUS_SB(sb).s_vhdr, sizeof(*vhdr));
|
memcpy(vhdr, sbi->s_vhdr, sizeof(*vhdr));
|
||||||
mark_buffer_dirty(bh);
|
mark_buffer_dirty(bh);
|
||||||
brelse(bh);
|
brelse(bh);
|
||||||
} else
|
} else
|
||||||
printk(KERN_WARNING "hfs: backup not found!\n");
|
printk(KERN_WARNING "hfs: backup not found!\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HFSPLUS_SB(sb).flags &= ~HFSPLUS_SB_WRITEBACKUP;
|
sbi->flags &= ~HFSPLUS_SB_WRITEBACKUP;
|
||||||
}
|
}
|
||||||
mutex_unlock(&HFSPLUS_SB(sb).alloc_mutex);
|
mutex_unlock(&sbi->alloc_mutex);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,28 +211,31 @@ static void hfsplus_write_super(struct super_block *sb)
|
||||||
|
|
||||||
static void hfsplus_put_super(struct super_block *sb)
|
static void hfsplus_put_super(struct super_block *sb)
|
||||||
{
|
{
|
||||||
|
struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
|
||||||
|
|
||||||
dprint(DBG_SUPER, "hfsplus_put_super\n");
|
dprint(DBG_SUPER, "hfsplus_put_super\n");
|
||||||
|
|
||||||
if (!sb->s_fs_info)
|
if (!sb->s_fs_info)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (sb->s_dirt)
|
if (sb->s_dirt)
|
||||||
hfsplus_write_super(sb);
|
hfsplus_write_super(sb);
|
||||||
if (!(sb->s_flags & MS_RDONLY) && HFSPLUS_SB(sb).s_vhdr) {
|
if (!(sb->s_flags & MS_RDONLY) && sbi->s_vhdr) {
|
||||||
struct hfsplus_vh *vhdr = HFSPLUS_SB(sb).s_vhdr;
|
struct hfsplus_vh *vhdr = sbi->s_vhdr;
|
||||||
|
|
||||||
vhdr->modify_date = hfsp_now2mt();
|
vhdr->modify_date = hfsp_now2mt();
|
||||||
vhdr->attributes |= cpu_to_be32(HFSPLUS_VOL_UNMNT);
|
vhdr->attributes |= cpu_to_be32(HFSPLUS_VOL_UNMNT);
|
||||||
vhdr->attributes &= cpu_to_be32(~HFSPLUS_VOL_INCNSTNT);
|
vhdr->attributes &= cpu_to_be32(~HFSPLUS_VOL_INCNSTNT);
|
||||||
mark_buffer_dirty(HFSPLUS_SB(sb).s_vhbh);
|
mark_buffer_dirty(sbi->s_vhbh);
|
||||||
sync_dirty_buffer(HFSPLUS_SB(sb).s_vhbh);
|
sync_dirty_buffer(sbi->s_vhbh);
|
||||||
}
|
}
|
||||||
|
|
||||||
hfs_btree_close(HFSPLUS_SB(sb).cat_tree);
|
hfs_btree_close(sbi->cat_tree);
|
||||||
hfs_btree_close(HFSPLUS_SB(sb).ext_tree);
|
hfs_btree_close(sbi->ext_tree);
|
||||||
iput(HFSPLUS_SB(sb).alloc_file);
|
iput(sbi->alloc_file);
|
||||||
iput(HFSPLUS_SB(sb).hidden_dir);
|
iput(sbi->hidden_dir);
|
||||||
brelse(HFSPLUS_SB(sb).s_vhbh);
|
brelse(sbi->s_vhbh);
|
||||||
unload_nls(HFSPLUS_SB(sb).nls);
|
unload_nls(sbi->nls);
|
||||||
kfree(sb->s_fs_info);
|
kfree(sb->s_fs_info);
|
||||||
sb->s_fs_info = NULL;
|
sb->s_fs_info = NULL;
|
||||||
}
|
}
|
||||||
|
@ -237,15 +243,16 @@ static void hfsplus_put_super(struct super_block *sb)
|
||||||
static int hfsplus_statfs(struct dentry *dentry, struct kstatfs *buf)
|
static int hfsplus_statfs(struct dentry *dentry, struct kstatfs *buf)
|
||||||
{
|
{
|
||||||
struct super_block *sb = dentry->d_sb;
|
struct super_block *sb = dentry->d_sb;
|
||||||
|
struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
|
||||||
u64 id = huge_encode_dev(sb->s_bdev->bd_dev);
|
u64 id = huge_encode_dev(sb->s_bdev->bd_dev);
|
||||||
|
|
||||||
buf->f_type = HFSPLUS_SUPER_MAGIC;
|
buf->f_type = HFSPLUS_SUPER_MAGIC;
|
||||||
buf->f_bsize = sb->s_blocksize;
|
buf->f_bsize = sb->s_blocksize;
|
||||||
buf->f_blocks = HFSPLUS_SB(sb).total_blocks << HFSPLUS_SB(sb).fs_shift;
|
buf->f_blocks = sbi->total_blocks << sbi->fs_shift;
|
||||||
buf->f_bfree = HFSPLUS_SB(sb).free_blocks << HFSPLUS_SB(sb).fs_shift;
|
buf->f_bfree = sbi->free_blocks << sbi->fs_shift;
|
||||||
buf->f_bavail = buf->f_bfree;
|
buf->f_bavail = buf->f_bfree;
|
||||||
buf->f_files = 0xFFFFFFFF;
|
buf->f_files = 0xFFFFFFFF;
|
||||||
buf->f_ffree = 0xFFFFFFFF - HFSPLUS_SB(sb).next_cnid;
|
buf->f_ffree = 0xFFFFFFFF - sbi->next_cnid;
|
||||||
buf->f_fsid.val[0] = (u32)id;
|
buf->f_fsid.val[0] = (u32)id;
|
||||||
buf->f_fsid.val[1] = (u32)(id >> 32);
|
buf->f_fsid.val[1] = (u32)(id >> 32);
|
||||||
buf->f_namelen = HFSPLUS_MAX_STRLEN;
|
buf->f_namelen = HFSPLUS_MAX_STRLEN;
|
||||||
|
@ -258,11 +265,11 @@ static int hfsplus_remount(struct super_block *sb, int *flags, char *data)
|
||||||
if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
|
if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
|
||||||
return 0;
|
return 0;
|
||||||
if (!(*flags & MS_RDONLY)) {
|
if (!(*flags & MS_RDONLY)) {
|
||||||
struct hfsplus_vh *vhdr = HFSPLUS_SB(sb).s_vhdr;
|
struct hfsplus_vh *vhdr = HFSPLUS_SB(sb)->s_vhdr;
|
||||||
struct hfsplus_sb_info sbi;
|
struct hfsplus_sb_info sbi;
|
||||||
|
|
||||||
memset(&sbi, 0, sizeof(struct hfsplus_sb_info));
|
memset(&sbi, 0, sizeof(struct hfsplus_sb_info));
|
||||||
sbi.nls = HFSPLUS_SB(sb).nls;
|
sbi.nls = HFSPLUS_SB(sb)->nls;
|
||||||
if (!hfsplus_parse_options(data, &sbi))
|
if (!hfsplus_parse_options(data, &sbi))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
@ -340,7 +347,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
|
||||||
err = -EINVAL;
|
err = -EINVAL;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
vhdr = HFSPLUS_SB(sb).s_vhdr;
|
vhdr = sbi->s_vhdr;
|
||||||
|
|
||||||
/* Copy parts of the volume header into the superblock */
|
/* Copy parts of the volume header into the superblock */
|
||||||
sb->s_magic = HFSPLUS_VOLHEAD_SIG;
|
sb->s_magic = HFSPLUS_VOLHEAD_SIG;
|
||||||
|
@ -349,18 +356,20 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
|
||||||
printk(KERN_ERR "hfs: wrong filesystem version\n");
|
printk(KERN_ERR "hfs: wrong filesystem version\n");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
HFSPLUS_SB(sb).total_blocks = be32_to_cpu(vhdr->total_blocks);
|
sbi->total_blocks = be32_to_cpu(vhdr->total_blocks);
|
||||||
HFSPLUS_SB(sb).free_blocks = be32_to_cpu(vhdr->free_blocks);
|
sbi->free_blocks = be32_to_cpu(vhdr->free_blocks);
|
||||||
HFSPLUS_SB(sb).next_alloc = be32_to_cpu(vhdr->next_alloc);
|
sbi->next_alloc = be32_to_cpu(vhdr->next_alloc);
|
||||||
HFSPLUS_SB(sb).next_cnid = be32_to_cpu(vhdr->next_cnid);
|
sbi->next_cnid = be32_to_cpu(vhdr->next_cnid);
|
||||||
HFSPLUS_SB(sb).file_count = be32_to_cpu(vhdr->file_count);
|
sbi->file_count = be32_to_cpu(vhdr->file_count);
|
||||||
HFSPLUS_SB(sb).folder_count = be32_to_cpu(vhdr->folder_count);
|
sbi->folder_count = be32_to_cpu(vhdr->folder_count);
|
||||||
HFSPLUS_SB(sb).data_clump_blocks = be32_to_cpu(vhdr->data_clump_sz) >> HFSPLUS_SB(sb).alloc_blksz_shift;
|
sbi->data_clump_blocks =
|
||||||
if (!HFSPLUS_SB(sb).data_clump_blocks)
|
be32_to_cpu(vhdr->data_clump_sz) >> sbi->alloc_blksz_shift;
|
||||||
HFSPLUS_SB(sb).data_clump_blocks = 1;
|
if (!sbi->data_clump_blocks)
|
||||||
HFSPLUS_SB(sb).rsrc_clump_blocks = be32_to_cpu(vhdr->rsrc_clump_sz) >> HFSPLUS_SB(sb).alloc_blksz_shift;
|
sbi->data_clump_blocks = 1;
|
||||||
if (!HFSPLUS_SB(sb).rsrc_clump_blocks)
|
sbi->rsrc_clump_blocks =
|
||||||
HFSPLUS_SB(sb).rsrc_clump_blocks = 1;
|
be32_to_cpu(vhdr->rsrc_clump_sz) >> sbi->alloc_blksz_shift;
|
||||||
|
if (!sbi->rsrc_clump_blocks)
|
||||||
|
sbi->rsrc_clump_blocks = 1;
|
||||||
|
|
||||||
/* Set up operations so we can load metadata */
|
/* Set up operations so we can load metadata */
|
||||||
sb->s_op = &hfsplus_sops;
|
sb->s_op = &hfsplus_sops;
|
||||||
|
@ -383,13 +392,13 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
|
||||||
sbi->flags &= ~HFSPLUS_SB_FORCE;
|
sbi->flags &= ~HFSPLUS_SB_FORCE;
|
||||||
|
|
||||||
/* Load metadata objects (B*Trees) */
|
/* Load metadata objects (B*Trees) */
|
||||||
HFSPLUS_SB(sb).ext_tree = hfs_btree_open(sb, HFSPLUS_EXT_CNID);
|
sbi->ext_tree = hfs_btree_open(sb, HFSPLUS_EXT_CNID);
|
||||||
if (!HFSPLUS_SB(sb).ext_tree) {
|
if (!sbi->ext_tree) {
|
||||||
printk(KERN_ERR "hfs: failed to load extents file\n");
|
printk(KERN_ERR "hfs: failed to load extents file\n");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
HFSPLUS_SB(sb).cat_tree = hfs_btree_open(sb, HFSPLUS_CAT_CNID);
|
sbi->cat_tree = hfs_btree_open(sb, HFSPLUS_CAT_CNID);
|
||||||
if (!HFSPLUS_SB(sb).cat_tree) {
|
if (!sbi->cat_tree) {
|
||||||
printk(KERN_ERR "hfs: failed to load catalog file\n");
|
printk(KERN_ERR "hfs: failed to load catalog file\n");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -400,7 +409,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
|
||||||
err = PTR_ERR(inode);
|
err = PTR_ERR(inode);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
HFSPLUS_SB(sb).alloc_file = inode;
|
sbi->alloc_file = inode;
|
||||||
|
|
||||||
/* Load the root directory */
|
/* Load the root directory */
|
||||||
root = hfsplus_iget(sb, HFSPLUS_ROOT_CNID);
|
root = hfsplus_iget(sb, HFSPLUS_ROOT_CNID);
|
||||||
|
@ -419,7 +428,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
|
||||||
|
|
||||||
str.len = sizeof(HFSP_HIDDENDIR_NAME) - 1;
|
str.len = sizeof(HFSP_HIDDENDIR_NAME) - 1;
|
||||||
str.name = HFSP_HIDDENDIR_NAME;
|
str.name = HFSP_HIDDENDIR_NAME;
|
||||||
hfs_find_init(HFSPLUS_SB(sb).cat_tree, &fd);
|
hfs_find_init(sbi->cat_tree, &fd);
|
||||||
hfsplus_cat_build_key(sb, fd.search_key, HFSPLUS_ROOT_CNID, &str);
|
hfsplus_cat_build_key(sb, fd.search_key, HFSPLUS_ROOT_CNID, &str);
|
||||||
if (!hfs_brec_read(&fd, &entry, sizeof(entry))) {
|
if (!hfs_brec_read(&fd, &entry, sizeof(entry))) {
|
||||||
hfs_find_exit(&fd);
|
hfs_find_exit(&fd);
|
||||||
|
@ -430,7 +439,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
|
||||||
err = PTR_ERR(inode);
|
err = PTR_ERR(inode);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
HFSPLUS_SB(sb).hidden_dir = inode;
|
sbi->hidden_dir = inode;
|
||||||
} else
|
} else
|
||||||
hfs_find_exit(&fd);
|
hfs_find_exit(&fd);
|
||||||
|
|
||||||
|
@ -445,15 +454,15 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
|
||||||
be32_add_cpu(&vhdr->write_count, 1);
|
be32_add_cpu(&vhdr->write_count, 1);
|
||||||
vhdr->attributes &= cpu_to_be32(~HFSPLUS_VOL_UNMNT);
|
vhdr->attributes &= cpu_to_be32(~HFSPLUS_VOL_UNMNT);
|
||||||
vhdr->attributes |= cpu_to_be32(HFSPLUS_VOL_INCNSTNT);
|
vhdr->attributes |= cpu_to_be32(HFSPLUS_VOL_INCNSTNT);
|
||||||
mark_buffer_dirty(HFSPLUS_SB(sb).s_vhbh);
|
mark_buffer_dirty(sbi->s_vhbh);
|
||||||
sync_dirty_buffer(HFSPLUS_SB(sb).s_vhbh);
|
sync_dirty_buffer(sbi->s_vhbh);
|
||||||
|
|
||||||
if (!HFSPLUS_SB(sb).hidden_dir) {
|
if (!sbi->hidden_dir) {
|
||||||
printk(KERN_DEBUG "hfs: create hidden dir...\n");
|
printk(KERN_DEBUG "hfs: create hidden dir...\n");
|
||||||
HFSPLUS_SB(sb).hidden_dir = hfsplus_new_inode(sb, S_IFDIR);
|
sbi->hidden_dir = hfsplus_new_inode(sb, S_IFDIR);
|
||||||
hfsplus_create_cat(HFSPLUS_SB(sb).hidden_dir->i_ino, sb->s_root->d_inode,
|
hfsplus_create_cat(sbi->hidden_dir->i_ino, sb->s_root->d_inode,
|
||||||
&str, HFSPLUS_SB(sb).hidden_dir);
|
&str, sbi->hidden_dir);
|
||||||
mark_inode_dirty(HFSPLUS_SB(sb).hidden_dir);
|
mark_inode_dirty(sbi->hidden_dir);
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
unload_nls(sbi->nls);
|
unload_nls(sbi->nls);
|
||||||
|
|
|
@ -121,7 +121,7 @@ static u16 *hfsplus_compose_lookup(u16 *p, u16 cc)
|
||||||
int hfsplus_uni2asc(struct super_block *sb, const struct hfsplus_unistr *ustr, char *astr, int *len_p)
|
int hfsplus_uni2asc(struct super_block *sb, const struct hfsplus_unistr *ustr, char *astr, int *len_p)
|
||||||
{
|
{
|
||||||
const hfsplus_unichr *ip;
|
const hfsplus_unichr *ip;
|
||||||
struct nls_table *nls = HFSPLUS_SB(sb).nls;
|
struct nls_table *nls = HFSPLUS_SB(sb)->nls;
|
||||||
u8 *op;
|
u8 *op;
|
||||||
u16 cc, c0, c1;
|
u16 cc, c0, c1;
|
||||||
u16 *ce1, *ce2;
|
u16 *ce1, *ce2;
|
||||||
|
@ -132,7 +132,7 @@ int hfsplus_uni2asc(struct super_block *sb, const struct hfsplus_unistr *ustr, c
|
||||||
ustrlen = be16_to_cpu(ustr->length);
|
ustrlen = be16_to_cpu(ustr->length);
|
||||||
len = *len_p;
|
len = *len_p;
|
||||||
ce1 = NULL;
|
ce1 = NULL;
|
||||||
compose = !(HFSPLUS_SB(sb).flags & HFSPLUS_SB_NODECOMPOSE);
|
compose = !(HFSPLUS_SB(sb)->flags & HFSPLUS_SB_NODECOMPOSE);
|
||||||
|
|
||||||
while (ustrlen > 0) {
|
while (ustrlen > 0) {
|
||||||
c0 = be16_to_cpu(*ip++);
|
c0 = be16_to_cpu(*ip++);
|
||||||
|
@ -246,7 +246,7 @@ out:
|
||||||
static inline int asc2unichar(struct super_block *sb, const char *astr, int len,
|
static inline int asc2unichar(struct super_block *sb, const char *astr, int len,
|
||||||
wchar_t *uc)
|
wchar_t *uc)
|
||||||
{
|
{
|
||||||
int size = HFSPLUS_SB(sb).nls->char2uni(astr, len, uc);
|
int size = HFSPLUS_SB(sb)->nls->char2uni(astr, len, uc);
|
||||||
if (size <= 0) {
|
if (size <= 0) {
|
||||||
*uc = '?';
|
*uc = '?';
|
||||||
size = 1;
|
size = 1;
|
||||||
|
@ -293,7 +293,7 @@ int hfsplus_asc2uni(struct super_block *sb, struct hfsplus_unistr *ustr,
|
||||||
u16 *dstr, outlen = 0;
|
u16 *dstr, outlen = 0;
|
||||||
wchar_t c;
|
wchar_t c;
|
||||||
|
|
||||||
decompose = !(HFSPLUS_SB(sb).flags & HFSPLUS_SB_NODECOMPOSE);
|
decompose = !(HFSPLUS_SB(sb)->flags & HFSPLUS_SB_NODECOMPOSE);
|
||||||
while (outlen < HFSPLUS_MAX_STRLEN && len > 0) {
|
while (outlen < HFSPLUS_MAX_STRLEN && len > 0) {
|
||||||
size = asc2unichar(sb, astr, len, &c);
|
size = asc2unichar(sb, astr, len, &c);
|
||||||
|
|
||||||
|
@ -330,8 +330,8 @@ int hfsplus_hash_dentry(struct dentry *dentry, struct qstr *str)
|
||||||
wchar_t c;
|
wchar_t c;
|
||||||
u16 c2;
|
u16 c2;
|
||||||
|
|
||||||
casefold = (HFSPLUS_SB(sb).flags & HFSPLUS_SB_CASEFOLD);
|
casefold = (HFSPLUS_SB(sb)->flags & HFSPLUS_SB_CASEFOLD);
|
||||||
decompose = !(HFSPLUS_SB(sb).flags & HFSPLUS_SB_NODECOMPOSE);
|
decompose = !(HFSPLUS_SB(sb)->flags & HFSPLUS_SB_NODECOMPOSE);
|
||||||
hash = init_name_hash();
|
hash = init_name_hash();
|
||||||
astr = str->name;
|
astr = str->name;
|
||||||
len = str->len;
|
len = str->len;
|
||||||
|
@ -373,8 +373,8 @@ int hfsplus_compare_dentry(struct dentry *dentry, struct qstr *s1, struct qstr *
|
||||||
u16 c1, c2;
|
u16 c1, c2;
|
||||||
wchar_t c;
|
wchar_t c;
|
||||||
|
|
||||||
casefold = (HFSPLUS_SB(sb).flags & HFSPLUS_SB_CASEFOLD);
|
casefold = (HFSPLUS_SB(sb)->flags & HFSPLUS_SB_CASEFOLD);
|
||||||
decompose = !(HFSPLUS_SB(sb).flags & HFSPLUS_SB_NODECOMPOSE);
|
decompose = !(HFSPLUS_SB(sb)->flags & HFSPLUS_SB_NODECOMPOSE);
|
||||||
astr1 = s1->name;
|
astr1 = s1->name;
|
||||||
len1 = s1->len;
|
len1 = s1->len;
|
||||||
astr2 = s2->name;
|
astr2 = s2->name;
|
||||||
|
|
|
@ -65,8 +65,8 @@ static int hfsplus_get_last_session(struct super_block *sb,
|
||||||
*start = 0;
|
*start = 0;
|
||||||
*size = sb->s_bdev->bd_inode->i_size >> 9;
|
*size = sb->s_bdev->bd_inode->i_size >> 9;
|
||||||
|
|
||||||
if (HFSPLUS_SB(sb).session >= 0) {
|
if (HFSPLUS_SB(sb)->session >= 0) {
|
||||||
te.cdte_track = HFSPLUS_SB(sb).session;
|
te.cdte_track = HFSPLUS_SB(sb)->session;
|
||||||
te.cdte_format = CDROM_LBA;
|
te.cdte_format = CDROM_LBA;
|
||||||
res = ioctl_by_bdev(sb->s_bdev, CDROMREADTOCENTRY, (unsigned long)&te);
|
res = ioctl_by_bdev(sb->s_bdev, CDROMREADTOCENTRY, (unsigned long)&te);
|
||||||
if (!res && (te.cdte_ctrl & CDROM_DATA_TRACK) == 4) {
|
if (!res && (te.cdte_ctrl & CDROM_DATA_TRACK) == 4) {
|
||||||
|
@ -87,6 +87,7 @@ static int hfsplus_get_last_session(struct super_block *sb,
|
||||||
/* Takes in super block, returns true if good data read */
|
/* Takes in super block, returns true if good data read */
|
||||||
int hfsplus_read_wrapper(struct super_block *sb)
|
int hfsplus_read_wrapper(struct super_block *sb)
|
||||||
{
|
{
|
||||||
|
struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
|
||||||
struct buffer_head *bh;
|
struct buffer_head *bh;
|
||||||
struct hfsplus_vh *vhdr;
|
struct hfsplus_vh *vhdr;
|
||||||
struct hfsplus_wd wd;
|
struct hfsplus_wd wd;
|
||||||
|
@ -122,7 +123,7 @@ int hfsplus_read_wrapper(struct super_block *sb)
|
||||||
if (vhdr->signature == cpu_to_be16(HFSPLUS_VOLHEAD_SIG))
|
if (vhdr->signature == cpu_to_be16(HFSPLUS_VOLHEAD_SIG))
|
||||||
break;
|
break;
|
||||||
if (vhdr->signature == cpu_to_be16(HFSPLUS_VOLHEAD_SIGX)) {
|
if (vhdr->signature == cpu_to_be16(HFSPLUS_VOLHEAD_SIGX)) {
|
||||||
HFSPLUS_SB(sb).flags |= HFSPLUS_SB_HFSX;
|
sbi->flags |= HFSPLUS_SB_HFSX;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
brelse(bh);
|
brelse(bh);
|
||||||
|
@ -143,11 +144,11 @@ int hfsplus_read_wrapper(struct super_block *sb)
|
||||||
if (blocksize < HFSPLUS_SECTOR_SIZE ||
|
if (blocksize < HFSPLUS_SECTOR_SIZE ||
|
||||||
((blocksize - 1) & blocksize))
|
((blocksize - 1) & blocksize))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
HFSPLUS_SB(sb).alloc_blksz = blocksize;
|
sbi->alloc_blksz = blocksize;
|
||||||
HFSPLUS_SB(sb).alloc_blksz_shift = 0;
|
sbi->alloc_blksz_shift = 0;
|
||||||
while ((blocksize >>= 1) != 0)
|
while ((blocksize >>= 1) != 0)
|
||||||
HFSPLUS_SB(sb).alloc_blksz_shift++;
|
sbi->alloc_blksz_shift++;
|
||||||
blocksize = min(HFSPLUS_SB(sb).alloc_blksz, (u32)PAGE_SIZE);
|
blocksize = min(sbi->alloc_blksz, (u32)PAGE_SIZE);
|
||||||
|
|
||||||
/* align block size to block offset */
|
/* align block size to block offset */
|
||||||
while (part_start & ((blocksize >> HFSPLUS_SECTOR_SHIFT) - 1))
|
while (part_start & ((blocksize >> HFSPLUS_SECTOR_SHIFT) - 1))
|
||||||
|
@ -158,23 +159,22 @@ int hfsplus_read_wrapper(struct super_block *sb)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
HFSPLUS_SB(sb).blockoffset = part_start >>
|
sbi->blockoffset =
|
||||||
(sb->s_blocksize_bits - HFSPLUS_SECTOR_SHIFT);
|
part_start >> (sb->s_blocksize_bits - HFSPLUS_SECTOR_SHIFT);
|
||||||
HFSPLUS_SB(sb).sect_count = part_size;
|
sbi->sect_count = part_size;
|
||||||
HFSPLUS_SB(sb).fs_shift = HFSPLUS_SB(sb).alloc_blksz_shift -
|
sbi->fs_shift = sbi->alloc_blksz_shift - sb->s_blocksize_bits;
|
||||||
sb->s_blocksize_bits;
|
|
||||||
|
|
||||||
bh = sb_bread512(sb, part_start + HFSPLUS_VOLHEAD_SECTOR, vhdr);
|
bh = sb_bread512(sb, part_start + HFSPLUS_VOLHEAD_SECTOR, vhdr);
|
||||||
if (!bh)
|
if (!bh)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
/* should still be the same... */
|
/* should still be the same... */
|
||||||
if (vhdr->signature != (HFSPLUS_SB(sb).flags & HFSPLUS_SB_HFSX ?
|
if (vhdr->signature != (sbi->flags & HFSPLUS_SB_HFSX ?
|
||||||
cpu_to_be16(HFSPLUS_VOLHEAD_SIGX) :
|
cpu_to_be16(HFSPLUS_VOLHEAD_SIGX) :
|
||||||
cpu_to_be16(HFSPLUS_VOLHEAD_SIG)))
|
cpu_to_be16(HFSPLUS_VOLHEAD_SIG)))
|
||||||
goto error;
|
goto error;
|
||||||
HFSPLUS_SB(sb).s_vhbh = bh;
|
sbi->s_vhbh = bh;
|
||||||
HFSPLUS_SB(sb).s_vhdr = vhdr;
|
sbi->s_vhdr = vhdr;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
error:
|
error:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue