From: Anand Jain <anand.jain@oracle.com>
To: Josef Bacik <josef@toxicpanda.com>, linux-btrfs@vger.kernel.org
Cc: dsterba@suse.com
Subject: Re: [PATCH v8 1/3] btrfs: add btrfs_strmatch helper
Date: Thu, 22 Oct 2020 15:40:58 +0800 [thread overview]
Message-ID: <a4cb483a-578f-0fd5-e65f-9b76f9f2fb7f@oracle.com> (raw)
In-Reply-To: <e599667f-af00-7cbf-65c8-fb1151e66411@toxicpanda.com>
On 21/10/20 10:44 pm, Josef Bacik wrote:
> On 10/20/20 10:02 AM, Anand Jain wrote:
>> Add a generic helper to match the golden-string in the given-string,
>> and ignore the leading and trailing whitespaces if any.
>>
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> Suggested-by: David Sterba <dsterba@suse.com>
>> ---
>> v5: born
>>
>> fs/btrfs/sysfs.c | 23 +++++++++++++++++++++++
>> 1 file changed, 23 insertions(+)
>>
>> diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
>> index 8424f5d0e5ed..eb0b2bfcce67 100644
>> --- a/fs/btrfs/sysfs.c
>> +++ b/fs/btrfs/sysfs.c
>> @@ -863,6 +863,29 @@ static ssize_t btrfs_generation_show(struct
>> kobject *kobj,
>> }
>> BTRFS_ATTR(, generation, btrfs_generation_show);
>> +/*
>> + * Match the %golden in the %given. Ignore the leading and trailing
>> whitespaces
>> + * if any.
>> + */
>> +static int btrfs_strmatch(const char *given, const char *golden)
>> +{
>> + size_t len = strlen(golden);
>> + char *stripped;
>> +
>> + /* strip leading whitespace */
>> + stripped = skip_spaces(given);
>> +
>> + if (strncmp(stripped, golden, len) == 0) {
>> + /* strip trailing whitespace */
>> + if (strlen(skip_spaces(stripped + len)))
>> + return -EINVAL;
>
> if ((strncmp(stripped, golden, len) == 0) &&
> (strlen(skip_spaces(stripped + len)) == 0))
> return 0;
fixed in v9 as well.
Thanks, Anand
>
> Thanks,
>
> Josef
next prev parent reply other threads:[~2020-10-22 7:41 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-20 14:02 [PATCH v8 0/3] readmirror feature (read_policy sysfs and Anand Jain
2020-10-20 14:02 ` [PATCH v8 1/3] btrfs: add btrfs_strmatch helper Anand Jain
2020-10-21 14:44 ` Josef Bacik
2020-10-22 7:40 ` Anand Jain [this message]
2020-10-20 14:02 ` [PATCH v8 2/3] btrfs: create read policy framework Anand Jain
2020-10-21 14:46 ` Josef Bacik
2020-10-20 14:02 ` [PATCH v8 3/3] btrfs: create read policy sysfs attribute, pid Anand Jain
2020-10-21 14:42 ` Josef Bacik
2020-10-22 7:40 ` Anand Jain
2020-10-20 14:22 ` [PATCH v8 0/3] readmirror feature (read_policy sysfs and in-memory only approach) Anand Jain
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=a4cb483a-578f-0fd5-e65f-9b76f9f2fb7f@oracle.com \
--to=anand.jain@oracle.com \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
/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