Commit 6f80dfe5 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Christoph Hellwig

hfsplus: fix option parsing during remount

hfsplus only actually uses the force option during remount, but it uses
the full option parser with a fake superblock to do so.  This means remount
will fail if any nls option is set (which happens frequently with older
mount tools), even if it is the same.

Fix this by adding a simpler version of the parser that only parses the force
option for remount.
Signed-off-by: default avatarChristoph Hellwig <hch@tuxera.com>
parent ff8b16d7
...@@ -362,6 +362,7 @@ ssize_t hfsplus_listxattr(struct dentry *dentry, char *buffer, size_t size); ...@@ -362,6 +362,7 @@ ssize_t hfsplus_listxattr(struct dentry *dentry, char *buffer, size_t size);
/* options.c */ /* options.c */
int hfsplus_parse_options(char *, struct hfsplus_sb_info *); int hfsplus_parse_options(char *, struct hfsplus_sb_info *);
int hfsplus_parse_options_remount(char *input, int *force);
void hfsplus_fill_defaults(struct hfsplus_sb_info *); void hfsplus_fill_defaults(struct hfsplus_sb_info *);
int hfsplus_show_options(struct seq_file *, struct vfsmount *); int hfsplus_show_options(struct seq_file *, struct vfsmount *);
......
...@@ -65,6 +65,32 @@ static inline int match_fourchar(substring_t *arg, u32 *result) ...@@ -65,6 +65,32 @@ static inline int match_fourchar(substring_t *arg, u32 *result)
return 0; return 0;
} }
int hfsplus_parse_options_remount(char *input, int *force)
{
char *p;
substring_t args[MAX_OPT_ARGS];
int token;
if (!input)
return 0;
while ((p = strsep(&input, ",")) != NULL) {
if (!*p)
continue;
token = match_token(p, tokens, args);
switch (token) {
case opt_force:
*force = 1;
break;
default:
break;
}
}
return 1;
}
/* Parse options from mount. Returns 0 on failure */ /* Parse options from mount. Returns 0 on failure */
/* input is the options passed to mount() as a string */ /* input is the options passed to mount() as a string */
int hfsplus_parse_options(char *input, struct hfsplus_sb_info *sbi) int hfsplus_parse_options(char *input, struct hfsplus_sb_info *sbi)
......
...@@ -263,11 +263,9 @@ static int hfsplus_remount(struct super_block *sb, int *flags, char *data) ...@@ -263,11 +263,9 @@ static int hfsplus_remount(struct super_block *sb, int *flags, char *data)
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; int force = 0;
memset(&sbi, 0, sizeof(struct hfsplus_sb_info)); if (!hfsplus_parse_options_remount(data, &force))
sbi.nls = HFSPLUS_SB(sb)->nls;
if (!hfsplus_parse_options(data, &sbi))
return -EINVAL; return -EINVAL;
if (!(vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_UNMNT))) { if (!(vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_UNMNT))) {
...@@ -275,7 +273,7 @@ static int hfsplus_remount(struct super_block *sb, int *flags, char *data) ...@@ -275,7 +273,7 @@ static int hfsplus_remount(struct super_block *sb, int *flags, char *data)
"running fsck.hfsplus is recommended. leaving read-only.\n"); "running fsck.hfsplus is recommended. leaving read-only.\n");
sb->s_flags |= MS_RDONLY; sb->s_flags |= MS_RDONLY;
*flags |= MS_RDONLY; *flags |= MS_RDONLY;
} else if (test_bit(HFSPLUS_SB_FORCE, &sbi.flags)) { } else if (force) {
/* nothing */ /* nothing */
} else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_SOFTLOCK)) { } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_SOFTLOCK)) {
printk(KERN_WARNING "hfs: filesystem is marked locked, leaving read-only.\n"); printk(KERN_WARNING "hfs: filesystem is marked locked, leaving read-only.\n");
......
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