From: Hongbo Li <lihongbo22@huawei.com>
To: <kent.overstreet@linux.dev>, <bfoster@redhat.com>
Cc: <linux-bcachefs@vger.kernel.org>, <ruanjinjie@huawei.com>,
<lihongbo22@huawei.com>
Subject: [PATCH v2] bcachefs: intercept mountoption value for bool type
Date: Fri, 1 Mar 2024 14:38:33 +0800 [thread overview]
Message-ID: <20240301063833.1933506-1-lihongbo22@huawei.com> (raw)
For mount option with bool type, the value must be 0 or 1 (See
bch2_opt_parse). But this seems does not well intercepted cause
for other value(like 2...), it returns the unexpect return code
with error message printed.
Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
v2:
- refine code by adding private error code for non-bool option
v1: https://lore.kernel.org/linux-bcachefs/6606c887-7bf3-435a-ac6c-5008115607ae@huawei.com/T/#t
---
fs/bcachefs/errcode.h | 1 +
fs/bcachefs/opts.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/bcachefs/errcode.h b/fs/bcachefs/errcode.h
index a8f1a3976305..47bafbd7707a 100644
--- a/fs/bcachefs/errcode.h
+++ b/fs/bcachefs/errcode.h
@@ -8,6 +8,7 @@
x(EINVAL, mount_option) \
x(BCH_ERR_mount_option, option_name) \
x(BCH_ERR_mount_option, option_value) \
+ x(BCH_ERR_mount_option, option_not_bool) \
x(ENOMEM, ENOMEM_stripe_buf) \
x(ENOMEM, ENOMEM_replicas_table) \
x(ENOMEM, ENOMEM_cpu_replicas) \
diff --git a/fs/bcachefs/opts.c b/fs/bcachefs/opts.c
index 1db11c15b2b9..08ea0cfc4aef 100644
--- a/fs/bcachefs/opts.c
+++ b/fs/bcachefs/opts.c
@@ -314,7 +314,7 @@ int bch2_opt_parse(struct bch_fs *c,
if (ret < 0 || (*res != 0 && *res != 1)) {
if (err)
prt_printf(err, "%s: must be bool", opt->attr.name);
- return ret;
+ return ret < 0 ? ret : -BCH_ERR_option_not_bool;
}
break;
case BCH_OPT_UINT:
--
2.34.1
reply other threads:[~2024-03-01 6:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240301063833.1933506-1-lihongbo22@huawei.com \
--to=lihongbo22@huawei.com \
--cc=bfoster@redhat.com \
--cc=kent.overstreet@linux.dev \
--cc=linux-bcachefs@vger.kernel.org \
--cc=ruanjinjie@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).