#include <linux/slab.h>
#include <linux/version.h>
#include <linux/vfs.h>
+#include <linux/nls.h>
static struct inode *hfsplus_alloc_inode(struct super_block *sb);
static void hfsplus_destroy_inode(struct inode *inode);
make_bad_inode(inode);
}
-int hfsplus_write_inode(struct inode *inode, int unused)
+static int hfsplus_write_inode(struct inode *inode, int unused)
{
struct hfsplus_vh *vhdr;
int ret = 0;
static void hfsplus_put_super(struct super_block *sb)
{
dprint(DBG_SUPER, "hfsplus_put_super\n");
- if (!(sb->s_flags & MS_RDONLY)) {
+ if (!sb->s_fs_info)
+ return;
+ if (!(sb->s_flags & MS_RDONLY) && HFSPLUS_SB(sb).s_vhdr) {
struct hfsplus_vh *vhdr = HFSPLUS_SB(sb).s_vhdr;
vhdr->modify_date = hfsp_now2mt();
iput(HFSPLUS_SB(sb).alloc_file);
iput(HFSPLUS_SB(sb).hidden_dir);
brelse(HFSPLUS_SB(sb).s_vhbh);
+ if (HFSPLUS_SB(sb).nls)
+ unload_nls(HFSPLUS_SB(sb).nls);
+ kfree(sb->s_fs_info);
+ sb->s_fs_info = NULL;
}
static int hfsplus_statfs(struct super_block *sb, struct kstatfs *buf)
return 0;
}
-int hfsplus_remount(struct super_block *sb, int *flags, char *data)
+static int hfsplus_remount(struct super_block *sb, int *flags, char *data)
{
if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
return 0;
struct hfs_find_data fd;
struct inode *root;
struct qstr str;
+ struct nls_table *nls = NULL;
int err = -EINVAL;
sbi = kmalloc(sizeof(struct hfsplus_sb_info), GFP_KERNEL);
- if (!sbi) {
- err = -ENOMEM;
- goto out2;
- }
+ if (!sbi)
+ return -ENOMEM;
+
memset(sbi, 0, sizeof(HFSPLUS_SB(sb)));
sb->s_fs_info = sbi;
INIT_HLIST_HEAD(&sbi->rsrc_inodes);
if (!silent)
printk("HFS+-fs: unable to parse mount options\n");
err = -EINVAL;
- goto out2;
+ goto cleanup;
+ }
+
+ /* temporarily use utf8 to correctly find the hidden dir below */
+ nls = sbi->nls;
+ sbi->nls = load_nls("utf8");
+ if (!nls) {
+ printk("HFS+: unable to load nls for utf8\n");
+ err = -EINVAL;
+ goto cleanup;
}
/* Grab the volume header */
if (!silent)
printk("HFS+-fs: unable to find HFS+ superblock\n");
err = -EINVAL;
- goto out2;
+ goto cleanup;
}
vhdr = HFSPLUS_SB(sb).s_vhdr;
str.len = sizeof(HFSP_HIDDENDIR_NAME) - 1;
str.name = HFSP_HIDDENDIR_NAME;
hfs_find_init(HFSPLUS_SB(sb).cat_tree, &fd);
- hfsplus_cat_build_key(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))) {
hfs_find_exit(&fd);
if (entry.type != cpu_to_be16(HFSPLUS_FOLDER))
mark_inode_dirty(HFSPLUS_SB(sb).hidden_dir);
}
out:
+ unload_nls(sbi->nls);
+ sbi->nls = nls;
return 0;
cleanup:
hfsplus_put_super(sb);
-out2:
+ if (nls)
+ unload_nls(nls);
return err;
}