From 2ff615b2bf2bcbff90fe7b79de0eceee365a7a5a Mon Sep 17 00:00:00 2001 From: Richard Elling Date: Wed, 5 Jun 2019 16:13:57 -0700 Subject: Fix logic error in setpartition function Reviewed by: John Kennedy Reviewed-by: Giuseppe Di Natale Reviewed-by: Tony Hutter Reviewed-by: Brian Behlendorf Signed-off-by: Richard Elling Closes #8839 --- tests/zfs-tests/include/libtest.shlib | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'tests/zfs-tests/include') diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib index 57d0880cc..b3893c2c3 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -861,7 +861,8 @@ function zero_partitions # # best to retire this interface and replace it with something more flexible. # At the moment a best effort is made. # -function set_partition # +# arguments: +function set_partition { typeset -i slicenum=$1 typeset start=$2 @@ -872,6 +873,7 @@ function set_partition # /dev/null + parted $disk -s -- print 1 >/dev/null typeset ret_val=$? if [[ $slicenum -eq 0 || $ret_val -ne 0 ]]; then - parted $DEV_DSKDIR/$disk -s -- mklabel gpt + parted $disk -s -- mklabel gpt if [[ $? -ne 0 ]]; then log_note "Failed to create GPT partition table on $disk" return 1 @@ -899,20 +901,21 @@ function set_partition # /dev/null - block_device_wait + blockdev --rereadpt $disk 2>/dev/null + block_device_wait $disk else if [[ -z $slicenum || -z $size || -z $disk ]]; then log_fail "The slice, size or disk name is unspecified." @@ -932,9 +935,10 @@ function set_partition # > $format_file format -e -s -d $disk -f $format_file + typeset ret_val=$? + rm -f $format_file fi - typeset ret_val=$? rm -f $format_file if [[ $ret_val -ne 0 ]]; then log_note "Unable to format $disk slice $slicenum to $size" -- cgit v1.2.3