From: Qu Wenruo <wqu@suse.com>
To: fstests@vger.kernel.org, linux-btrfs@vger.kernel.org
Cc: Josef Bacik <josef@toxicpanda.com>
Subject: [PATCH 1/3] fstests: btrfs: Use word mathcing for _btrfs_get_subvolid()
Date: Fri, 7 Feb 2020 09:59:40 +0800 [thread overview]
Message-ID: <20200207015942.9079-2-wqu@suse.com> (raw)
In-Reply-To: <20200207015942.9079-1-wqu@suse.com>
Current _btrfs_get_subvolid() can't handle the following case at all:
# btrfs subvol list $SCRATCH_MNT
ID 256 gen 9 top level 5 path subv1
ID 257 gen 7 top level 256 path subv1/subv2
ID 258 gen 8 top level 256 path subv1/subv3
ID 259 gen 9 top level 256 path subv1/subv4
If we call "_btrfs_get_subvolid $SCRATCH_MNT subv1" we will get a list
of all subvolumes, not the subvolid of subv1.
To address this problem, we go egrep to match $name which starts with a
space, and at the end of a line.
So that all other subvolumes won't hit.
Suggested-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
common/btrfs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/common/btrfs b/common/btrfs
index 19ac7cc4..85b33e4c 100644
--- a/common/btrfs
+++ b/common/btrfs
@@ -7,7 +7,7 @@ _btrfs_get_subvolid()
mnt=$1
name=$2
- $BTRFS_UTIL_PROG sub list $mnt | grep $name | awk '{ print $2 }'
+ $BTRFS_UTIL_PROG sub list $mnt | egrep "\s$name$" | awk '{ print $2 }'
}
# _require_btrfs_command <command> [<subcommand>|<option>]
--
2.23.0
next prev parent reply other threads:[~2020-02-07 1:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-07 1:59 [PATCH 0/3] fstests: btrfs/022 fixes Qu Wenruo
2020-02-07 1:59 ` Qu Wenruo [this message]
2020-02-07 2:09 ` [PATCH 1/3] fstests: btrfs: Use word mathcing for _btrfs_get_subvolid() Josef Bacik
2020-02-07 9:41 ` Nikolay Borisov
2020-02-07 10:02 ` Qu Wenruo
2020-02-07 11:07 ` Nikolay Borisov
2020-02-07 1:59 ` [PATCH 2/3] fstests: btrfs/022: Match qgroup id more correctly Qu Wenruo
2020-02-07 2:10 ` Josef Bacik
2020-02-07 9:46 ` Nikolay Borisov
2020-02-07 10:03 ` Qu Wenruo
2020-02-07 1:59 ` [PATCH 3/3] fstests: btrfs/022: Add debug output Qu Wenruo
2020-02-07 2:10 ` Josef Bacik
2020-02-07 9:48 ` Nikolay Borisov
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=20200207015942.9079-2-wqu@suse.com \
--to=wqu@suse.com \
--cc=fstests@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).