common/rc: fix device size parser

If you have multiple devices that share the same regex (eg dm-1, dm10),
then _get_device_size() can return "$size\n$size" which causes the
following error for btrfs/011.

    QA output created by 011
    ./common/rc: line 3084: [: too many arguments

So, fix this by making grep check against whole word.

Signed-off-by: Dennis Zhou <dennis@kernel.org>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
This commit is contained in:
Dennis Zhou
2019-12-11 12:18:30 -08:00
committed by Eryu Guan
parent b25cac5542
commit db6de9645d
+1 -1
View File
@@ -3583,7 +3583,7 @@ _get_available_space()
# return device size in kb
_get_device_size()
{
grep `_short_dev $1` /proc/partitions | awk '{print $3}'
grep -w `_short_dev $1` /proc/partitions | awk '{print $3}'
}
# Make sure we actually have dmesg checking set up.