diff options
author | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2016-08-02 17:05:22 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-08-02 19:35:20 -0400 |
commit | a7d3f104da57eecb2b9881127d6bdf9abe7fde99 (patch) | |
tree | 58ff399301e8241f7262b78b8283917f9a445bfe /fs/nilfs2/super.c | |
parent | aceb4170bb2ba88c5327cc69b9c91a708c7f7046 (diff) |
nilfs2: refactor parser of snapshot mount option
Move parser of snapshot mount option to a separate function
nilfs_parse_snapshot_option(), replace simple_strtoull() with
kstrtoull() to avoid checkpatch.pl warning "WARNING: simple_strtoull is
obsolete, use kstrtoull instead", and refine the error message of the
parser.
Link: http://lkml.kernel.org/r/1464875891-5443-9-git-send-email-konishi.ryusuke@lab.ntt.co.jp
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/nilfs2/super.c')
-rw-r--r-- | fs/nilfs2/super.c | 53 |
1 files changed, 35 insertions, 18 deletions
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c index 33ba6f78de69..c95d369e90aa 100644 --- a/fs/nilfs2/super.c +++ b/fs/nilfs2/super.c | |||
@@ -1205,6 +1205,38 @@ struct nilfs_super_data { | |||
1205 | int flags; | 1205 | int flags; |
1206 | }; | 1206 | }; |
1207 | 1207 | ||
1208 | static int nilfs_parse_snapshot_option(const char *option, | ||
1209 | const substring_t *arg, | ||
1210 | struct nilfs_super_data *sd) | ||
1211 | { | ||
1212 | unsigned long long val; | ||
1213 | const char *msg = NULL; | ||
1214 | int err; | ||
1215 | |||
1216 | if (!(sd->flags & MS_RDONLY)) { | ||
1217 | msg = "read-only option is not specified"; | ||
1218 | goto parse_error; | ||
1219 | } | ||
1220 | |||
1221 | err = kstrtoull(arg->from, 0, &val); | ||
1222 | if (err) { | ||
1223 | if (err == -ERANGE) | ||
1224 | msg = "too large checkpoint number"; | ||
1225 | else | ||
1226 | msg = "malformed argument"; | ||
1227 | goto parse_error; | ||
1228 | } else if (val == 0) { | ||
1229 | msg = "invalid checkpoint number 0"; | ||
1230 | goto parse_error; | ||
1231 | } | ||
1232 | sd->cno = val; | ||
1233 | return 0; | ||
1234 | |||
1235 | parse_error: | ||
1236 | nilfs_msg(NULL, KERN_ERR, "invalid option \"%s\": %s", option, msg); | ||
1237 | return 1; | ||
1238 | } | ||
1239 | |||
1208 | /** | 1240 | /** |
1209 | * nilfs_identify - pre-read mount options needed to identify mount instance | 1241 | * nilfs_identify - pre-read mount options needed to identify mount instance |
1210 | * @data: mount options | 1242 | * @data: mount options |
@@ -1221,24 +1253,9 @@ static int nilfs_identify(char *data, struct nilfs_super_data *sd) | |||
1221 | p = strsep(&options, ","); | 1253 | p = strsep(&options, ","); |
1222 | if (p != NULL && *p) { | 1254 | if (p != NULL && *p) { |
1223 | token = match_token(p, tokens, args); | 1255 | token = match_token(p, tokens, args); |
1224 | if (token == Opt_snapshot) { | 1256 | if (token == Opt_snapshot) |
1225 | if (!(sd->flags & MS_RDONLY)) { | 1257 | ret = nilfs_parse_snapshot_option(p, &args[0], |
1226 | ret++; | 1258 | sd); |
1227 | } else { | ||
1228 | sd->cno = simple_strtoull(args[0].from, | ||
1229 | NULL, 0); | ||
1230 | /* | ||
1231 | * No need to see the end pointer; | ||
1232 | * match_token() has done syntax | ||
1233 | * checking. | ||
1234 | */ | ||
1235 | if (sd->cno == 0) | ||
1236 | ret++; | ||
1237 | } | ||
1238 | } | ||
1239 | if (ret) | ||
1240 | nilfs_msg(NULL, KERN_ERR, | ||
1241 | "invalid mount option: %s", p); | ||
1242 | } | 1259 | } |
1243 | if (!options) | 1260 | if (!options) |
1244 | break; | 1261 | break; |