diff mbox series

vfs: Handle fs_param_neg_with_empty

Message ID 157122227425.17182.1135743644487819585.stgit@warthog.procyon.org.uk (mailing list archive)
State New, archived
Headers show
Series vfs: Handle fs_param_neg_with_empty | expand

Commit Message

David Howells Oct. 16, 2019, 10:37 a.m. UTC
Make fs_param_neg_with_empty work.  It says that a parameter with no value
or and empty value should be marked as negated.

This is intended for use with ext4, which hadn't yet been converted.

Fixes: 31d921c7fb96 ("vfs: Add configuration parser helpers")
Reported-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: David Howells <dhowells@redhat.com>
---

 fs/fs_parser.c |    5 +++++
 1 file changed, 5 insertions(+)

Comments

Lukas Czerner Oct. 16, 2019, 1:42 p.m. UTC | #1
On Wed, Oct 16, 2019 at 11:37:54AM +0100, David Howells wrote:
> Make fs_param_neg_with_empty work.  It says that a parameter with no value
> or and empty value should be marked as negated.
> 
> This is intended for use with ext4, which hadn't yet been converted.

Hi David,

thanks for the fix, this seems to be working fine for me. However this
will only work for fs_param_is_string, not anything else. I do not need
anything else, but unless you want to make it work for all the value types
some changes in documentation might be needed as well.

Thanks!
-Lukas

> 
> Fixes: 31d921c7fb96 ("vfs: Add configuration parser helpers")
> Reported-by: Lukas Czerner <lczerner@redhat.com>
> Signed-off-by: David Howells <dhowells@redhat.com>
> ---
> 
>  fs/fs_parser.c |    5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/fs/fs_parser.c b/fs/fs_parser.c
> index d1930adce68d..f95997a76738 100644
> --- a/fs/fs_parser.c
> +++ b/fs/fs_parser.c
> @@ -129,6 +129,11 @@ int fs_parse(struct fs_context *fc,
>  	case fs_param_is_string:
>  		if (param->type != fs_value_is_string)
>  			goto bad_value;
> +		if ((p->flags & fs_param_neg_with_empty) &&
> +		    (!result->has_value || !param->string[0])) {
> +			result->negated = true;
> +			goto okay;
> +		}
>  		if (!result->has_value) {
>  			if (p->flags & fs_param_v_optional)
>  				goto okay;
>
diff mbox series

Patch

diff --git a/fs/fs_parser.c b/fs/fs_parser.c
index d1930adce68d..f95997a76738 100644
--- a/fs/fs_parser.c
+++ b/fs/fs_parser.c
@@ -129,6 +129,11 @@  int fs_parse(struct fs_context *fc,
 	case fs_param_is_string:
 		if (param->type != fs_value_is_string)
 			goto bad_value;
+		if ((p->flags & fs_param_neg_with_empty) &&
+		    (!result->has_value || !param->string[0])) {
+			result->negated = true;
+			goto okay;
+		}
 		if (!result->has_value) {
 			if (p->flags & fs_param_v_optional)
 				goto okay;