summaryrefslogtreecommitdiffstats
path: root/fs/nilfs2
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2016-08-02 14:05:22 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2016-08-02 19:35:20 -0400
commita7d3f104da57eecb2b9881127d6bdf9abe7fde99 (patch)
tree58ff399301e8241f7262b78b8283917f9a445bfe /fs/nilfs2
parentaceb4170bb2ba88c5327cc69b9c91a708c7f7046 (diff)
downloadop-kernel-dev-a7d3f104da57eecb2b9881127d6bdf9abe7fde99.zip
op-kernel-dev-a7d3f104da57eecb2b9881127d6bdf9abe7fde99.tar.gz
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')
-rw-r--r--fs/nilfs2/super.c53
1 files changed, 35 insertions, 18 deletions
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index 33ba6f7..c95d369 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -1205,6 +1205,38 @@ struct nilfs_super_data {
int flags;
};
+static int nilfs_parse_snapshot_option(const char *option,
+ const substring_t *arg,
+ struct nilfs_super_data *sd)
+{
+ unsigned long long val;
+ const char *msg = NULL;
+ int err;
+
+ if (!(sd->flags & MS_RDONLY)) {
+ msg = "read-only option is not specified";
+ goto parse_error;
+ }
+
+ err = kstrtoull(arg->from, 0, &val);
+ if (err) {
+ if (err == -ERANGE)
+ msg = "too large checkpoint number";
+ else
+ msg = "malformed argument";
+ goto parse_error;
+ } else if (val == 0) {
+ msg = "invalid checkpoint number 0";
+ goto parse_error;
+ }
+ sd->cno = val;
+ return 0;
+
+parse_error:
+ nilfs_msg(NULL, KERN_ERR, "invalid option \"%s\": %s", option, msg);
+ return 1;
+}
+
/**
* nilfs_identify - pre-read mount options needed to identify mount instance
* @data: mount options
@@ -1221,24 +1253,9 @@ static int nilfs_identify(char *data, struct nilfs_super_data *sd)
p = strsep(&options, ",");
if (p != NULL && *p) {
token = match_token(p, tokens, args);
- if (token == Opt_snapshot) {
- if (!(sd->flags & MS_RDONLY)) {
- ret++;
- } else {
- sd->cno = simple_strtoull(args[0].from,
- NULL, 0);
- /*
- * No need to see the end pointer;
- * match_token() has done syntax
- * checking.
- */
- if (sd->cno == 0)
- ret++;
- }
- }
- if (ret)
- nilfs_msg(NULL, KERN_ERR,
- "invalid mount option: %s", p);
+ if (token == Opt_snapshot)
+ ret = nilfs_parse_snapshot_option(p, &args[0],
+ sd);
}
if (!options)
break;
OpenPOWER on IntegriCloud