common/rc: fix device size parser
PATCH 1/1 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 eol.
Signed-off-by Dennis Zhou <[email protected]>
--- common/rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
common/rc +1 -1
@@ -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 "$(_short_dev $1)\$" /proc/partitions | awk '{print $3}' } # Make sure we actually have dmesg checking set up.
Signature · 1 line
2.17.1
Quoted 19 lines · Dennis Zhou
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 argumentsSo, fix this by making grep check against eol.
Signed-off-by Dennis Zhou <[email protected]>--- common/rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)common/rc +0
-0
common/rc _get_available_space() · line 3586
Quoted 5 lines
common/rc +1
-1@@ -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 "$(_short_dev $1)\$" /proc/partitions | awk '{print $3}'
I changed it to use "grep -w", which seems simpler.
Thanks,
Eryu
Quoted 6 lines
common/rc +0
-0} # Make sure we actually have dmesg checking set up.Signature · 1 line
2.17.1