[PATCH] [UNTESTED]
From: Christian Brauner
Date: Sat Mar 02 2024 - 12:54:35 EST
Signed-off-by: Christian Brauner <brauner@xxxxxxxxxx>
---
fs/ext4/super.c | 32 ++++++++++++++++++--------------
include/linux/fs_parser.h | 3 +++
2 files changed, 21 insertions(+), 14 deletions(-)
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index ebd97442d1d4..bd625f06ec0f 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1724,10 +1724,6 @@ static const struct constant_table ext4_param_dax[] = {
{}
};
-/* String parameter that allows empty argument */
-#define fsparam_string_empty(NAME, OPT) \
- __fsparam(fs_param_is_string, NAME, OPT, fs_param_can_be_empty, NULL)
-
/*
* Mount option specification
* We don't use fsparam_flag_no because of the way we set the
@@ -1768,10 +1764,8 @@ static const struct fs_parameter_spec ext4_param_specs[] = {
fsparam_enum ("data", Opt_data, ext4_param_data),
fsparam_enum ("data_err", Opt_data_err,
ext4_param_data_err),
- fsparam_string_empty
- ("usrjquota", Opt_usrjquota),
- fsparam_string_empty
- ("grpjquota", Opt_grpjquota),
+ fsparam_string_or_flag ("usrjquota", Opt_usrjquota),
+ fsparam_string_or_flag ("grpjquota", Opt_grpjquota),
fsparam_enum ("jqfmt", Opt_jqfmt, ext4_param_jqfmt),
fsparam_flag ("grpquota", Opt_grpquota),
fsparam_flag ("quota", Opt_quota),
@@ -2183,15 +2177,25 @@ static int ext4_parse_param(struct fs_context *fc, struct fs_parameter *param)
switch (token) {
#ifdef CONFIG_QUOTA
case Opt_usrjquota:
- if (!param->string)
- return unnote_qf_name(fc, USRQUOTA);
- else
+ if (param->type == fs_value_is_string) {
+ if (!*param->string)
+ return unnote_qf_name(fc, USRQUOTA);
+
return note_qf_name(fc, USRQUOTA, param);
+ }
+
+ // param->type == fs_value_is_flag
+ return note_qf_name(fc, USRQUOTA, param);
case Opt_grpjquota:
- if (!param->string)
- return unnote_qf_name(fc, GRPQUOTA);
- else
+ if (param->type == fs_value_is_string) {
+ if (!*param->string)
+ return unnote_qf_name(fc, GRPQUOTA);
+
return note_qf_name(fc, GRPQUOTA, param);
+ }
+
+ // param->type == fs_value_is_flag
+ return note_qf_name(fc, GRPQUOTA, param);
#endif
case Opt_sb:
if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE) {
diff --git a/include/linux/fs_parser.h b/include/linux/fs_parser.h
index 01542c4b87a2..4f45141bea95 100644
--- a/include/linux/fs_parser.h
+++ b/include/linux/fs_parser.h
@@ -131,5 +131,8 @@ static inline bool fs_validate_description(const char *name,
#define fsparam_bdev(NAME, OPT) __fsparam(fs_param_is_blockdev, NAME, OPT, 0, NULL)
#define fsparam_path(NAME, OPT) __fsparam(fs_param_is_path, NAME, OPT, 0, NULL)
#define fsparam_fd(NAME, OPT) __fsparam(fs_param_is_fd, NAME, OPT, 0, NULL)
+#define fsparam_string_or_flag(NAME, OPT) \
+ __fsparam(fs_param_is_string, NAME, OPT, fs_param_can_be_empty, NULL), \
+ fsparam_flag(NAME, OPT)
#endif /* _LINUX_FS_PARSER_H */
--
2.43.0