From: Bernd Schubert <bernd.schubert@fastmail.fm>
To: Joanne Koong <joannelkoong@gmail.com>,
miklos@szeredi.hu, linux-fsdevel@vger.kernel.org
Cc: josef@toxicpanda.com, jefflexu@linux.alibaba.com,
laoar.shao@gmail.com, kernel-team@meta.com
Subject: Re: [PATCH v8 1/3] fs_parser: add fsparam_u16 helper
Date: Tue, 29 Oct 2024 21:58:15 +0100 [thread overview]
Message-ID: <676b106a-d60f-46fc-848c-dd67a6e2d36e@fastmail.fm> (raw)
In-Reply-To: <20241011191320.91592-2-joannelkoong@gmail.com>
On 10/11/24 21:13, Joanne Koong wrote:
> Add a fsparam helper for unsigned 16 bit values.
>
> Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
> ---
> fs/fs_parser.c | 14 ++++++++++++++
> include/linux/fs_parser.h | 9 ++++++---
> 2 files changed, 20 insertions(+), 3 deletions(-)
>
> diff --git a/fs/fs_parser.c b/fs/fs_parser.c
> index 24727ec34e5a..0e06f9618c89 100644
> --- a/fs/fs_parser.c
> +++ b/fs/fs_parser.c
> @@ -210,6 +210,20 @@ int fs_param_is_bool(struct p_log *log, const struct fs_parameter_spec *p,
> }
> EXPORT_SYMBOL(fs_param_is_bool);
>
> +int fs_param_is_u16(struct p_log *log, const struct fs_parameter_spec *p,
> + struct fs_parameter *param, struct fs_parse_result *result)
> +{
> + int base = (unsigned long)p->data;
> + if (param->type != fs_value_is_string)
> + return fs_param_bad_value(log, param);
> + if (!*param->string && (p->flags & fs_param_can_be_empty))
> + return 0;
> + if (kstrtou16(param->string, base, &result->uint_16) < 0)
> + return fs_param_bad_value(log, param);
> + return 0;
> +}
> +EXPORT_SYMBOL(fs_param_is_u16);
> +
> int fs_param_is_u32(struct p_log *log, const struct fs_parameter_spec *p,
> struct fs_parameter *param, struct fs_parse_result *result)
> {
> diff --git a/include/linux/fs_parser.h b/include/linux/fs_parser.h
> index 6cf713a7e6c6..1c940756300c 100644
> --- a/include/linux/fs_parser.h
> +++ b/include/linux/fs_parser.h
> @@ -26,9 +26,10 @@ typedef int fs_param_type(struct p_log *,
> /*
> * The type of parameter expected.
> */
> -fs_param_type fs_param_is_bool, fs_param_is_u32, fs_param_is_s32, fs_param_is_u64,
> - fs_param_is_enum, fs_param_is_string, fs_param_is_blob, fs_param_is_blockdev,
> - fs_param_is_path, fs_param_is_fd, fs_param_is_uid, fs_param_is_gid;
> +fs_param_type fs_param_is_bool, fs_param_is_u16, fs_param_is_u32, fs_param_is_s32,
> + fs_param_is_u64, fs_param_is_enum, fs_param_is_string, fs_param_is_blob,
> + fs_param_is_blockdev, fs_param_is_path, fs_param_is_fd, fs_param_is_uid,
> + fs_param_is_gid;
>
> /*
> * Specification of the type of value a parameter wants.
> @@ -55,6 +56,7 @@ struct fs_parse_result {
> union {
> bool boolean; /* For spec_bool */
> int int_32; /* For spec_s32/spec_enum */
> + u16 uint_16; /* For spec_u16 *
> unsigned int uint_32; /* For spec_u32{,_octal,_hex}/spec_enum */
Given fs_param_is_u16() has "int base = (unsigned long)p->data;",
shouldn't the comment also mention ",_octal,_hex}/spec_enum"?
Or should the function get slightly modified to always use a base of 10?
Or 0 with auto detection as for fs_param_is_u64()?
> u64 uint_64; /* For spec_u64 */
> kuid_t uid;
> @@ -119,6 +121,7 @@ static inline bool fs_validate_description(const char *name,
> #define fsparam_flag_no(NAME, OPT) \
> __fsparam(NULL, NAME, OPT, fs_param_neg_with_no, NULL)
> #define fsparam_bool(NAME, OPT) __fsparam(fs_param_is_bool, NAME, OPT, 0, NULL)
> +#define fsparam_u16(NAME, OPT) __fsparam(fs_param_is_u16, NAME, OPT, 0, NULL)
> #define fsparam_u32(NAME, OPT) __fsparam(fs_param_is_u32, NAME, OPT, 0, NULL)
> #define fsparam_u32oct(NAME, OPT) \
> __fsparam(fs_param_is_u32, NAME, OPT, 0, (void *)8)
Reviewed-by: Bernd Schubert <bschubert@ddn.com>
next prev parent reply other threads:[~2024-10-29 20:58 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-11 19:13 [PATCH v8 0/3] fuse: add kernel-enforced request timeout option Joanne Koong
2024-10-11 19:13 ` [PATCH v8 1/3] fs_parser: add fsparam_u16 helper Joanne Koong
2024-10-29 20:58 ` Bernd Schubert [this message]
2024-10-30 16:28 ` Joanne Koong
2024-10-11 19:13 ` [PATCH v8 2/3] fuse: add optional kernel-enforced timeout for requests Joanne Koong
2024-10-29 19:17 ` Bernd Schubert
2024-10-30 17:21 ` Joanne Koong
2024-10-30 17:50 ` Bernd Schubert
2024-10-11 19:13 ` [PATCH v8 3/3] fuse: add default_request_timeout and max_request_timeout sysctls Joanne Koong
2024-10-29 19:40 ` Bernd Schubert
2024-10-30 17:32 ` Joanne Koong
2024-10-24 16:19 ` [PATCH v8 0/3] fuse: add kernel-enforced request timeout option Joanne Koong
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=676b106a-d60f-46fc-848c-dd67a6e2d36e@fastmail.fm \
--to=bernd.schubert@fastmail.fm \
--cc=jefflexu@linux.alibaba.com \
--cc=joannelkoong@gmail.com \
--cc=josef@toxicpanda.com \
--cc=kernel-team@meta.com \
--cc=laoar.shao@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=miklos@szeredi.hu \
/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 NNTP newsgroup(s).