1
0
Fork 0

ext4: make mount option parsing loop more logical

The loop looking for correct mount option entry is more logical if it is
written rewritten as an empty loop looking for correct option entry and then
code handling the option. It also saves one level of indentation for a lot of
code so we can join a couple of split lines.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
hifive-unleashed-5.1
Jan Kara 2013-02-02 23:09:36 -05:00 committed by Theodore Ts'o
parent 0efb3b2300
commit 5f3633e36b
1 changed files with 122 additions and 126 deletions

View File

@ -1508,8 +1508,7 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
case Opt_sb:
return 1; /* handled by get_sb_block() */
case Opt_removed:
ext4_msg(sb, KERN_WARNING,
"Ignoring removed %s option", opt);
ext4_msg(sb, KERN_WARNING, "Ignoring removed %s option", opt);
return 1;
case Opt_abort:
sbi->s_mount_flags |= EXT4_MF_FS_ABORTED;
@ -1519,9 +1518,16 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
return 1;
}
for (m = ext4_mount_opts; m->token != Opt_err; m++) {
if (token != m->token)
continue;
for (m = ext4_mount_opts; m->token != Opt_err; m++)
if (token == m->token)
break;
if (m->token == Opt_err) {
ext4_msg(sb, KERN_ERR, "Unrecognized mount option \"%s\" "
"or missing value", opt);
return -1;
}
if (args->from && match_int(args, &arg))
return -1;
if (args->from && (m->flags & MOPT_GTE0) && (arg < 0))
@ -1552,8 +1558,7 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
if (arg > (1 << 30))
return -1;
if (arg && !is_power_of_2(arg)) {
ext4_msg(sb, KERN_ERR,
"EXT4-fs: inode_readahead_blks"
ext4_msg(sb, KERN_ERR, "EXT4-fs: inode_readahead_blks"
" must be a power of 2");
return -1;
}
@ -1570,16 +1575,14 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
} else if (token == Opt_resuid) {
uid = make_kuid(current_user_ns(), arg);
if (!uid_valid(uid)) {
ext4_msg(sb, KERN_ERR,
"Invalid uid value %d", arg);
ext4_msg(sb, KERN_ERR, "Invalid uid value %d", arg);
return -1;
}
sbi->s_resuid = uid;
} else if (token == Opt_resgid) {
gid = make_kgid(current_user_ns(), arg);
if (!gid_valid(gid)) {
ext4_msg(sb, KERN_ERR,
"Invalid gid value %d", arg);
ext4_msg(sb, KERN_ERR, "Invalid gid value %d", arg);
return -1;
}
sbi->s_resgid = gid;
@ -1592,8 +1595,7 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
*journal_devnum = arg;
} else if (token == Opt_journal_ioprio) {
if (arg > 7) {
ext4_msg(sb, KERN_ERR,
"Invalid journal IO priority"
ext4_msg(sb, KERN_ERR, "Invalid journal IO priority"
" (must be 0-7)");
return -1;
}
@ -1603,8 +1605,7 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
if (is_remount) {
if (!sbi->s_journal)
ext4_msg(sb, KERN_WARNING, "Remounting file system with no journal so ignoring journalled data option");
else if (test_opt(sb, DATA_FLAGS) !=
m->mount_opt) {
else if (test_opt(sb, DATA_FLAGS) != m->mount_opt) {
ext4_msg(sb, KERN_ERR,
"Cannot change data mode on remount");
return -1;
@ -1617,9 +1618,8 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
} else if (m->flags & MOPT_QFMT) {
if (sb_any_quota_loaded(sb) &&
sbi->s_jquota_fmt != m->mount_opt) {
ext4_msg(sb, KERN_ERR, "Cannot "
"change journaled quota options "
"when quota turned on");
ext4_msg(sb, KERN_ERR, "Cannot change journaled "
"quota options when quota turned on");
return -1;
}
sbi->s_jquota_fmt = m->mount_opt;
@ -1641,10 +1641,6 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
sbi->s_mount_opt &= ~m->mount_opt;
}
return 1;
}
ext4_msg(sb, KERN_ERR, "Unrecognized mount option \"%s\" "
"or missing value", opt);
return -1;
}
static int parse_options(char *options, struct super_block *sb,