diff options
author | Phillip Susi <psusi@ubuntu.com> | 2011-11-30 13:13:58 -0500 |
---|---|---|
committer | Phillip Susi <psusi@ubuntu.com> | 2014-06-15 15:16:30 -0400 |
commit | f46146a15bf45478569c1d364661d3d54f8e3a1a (patch) | |
tree | 7d4863d838cad9a6dd2a72c676584330f3c67bd4 | |
parent | f09ca967a0bc443b869a6fad5b5ffe8e95c3fe9a (diff) | |
download | parted-f46146a15bf45478569c1d364661d3d54f8e3a1a.tar.gz |
parted: make _partition_warn_busy actually a warning instead of an error
This function was throwing a PED_EXCEPTION_ERROR with only the
PED_EXCEPTION_CANCEL option. Converted to a PED_EXCEPTION_WARNING
with the option to continue anyhow.
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | parted/parted.c | 17 | ||||
-rwxr-xr-x | tests/t1101-busy-partition.sh | 2 | ||||
-rw-r--r-- | tests/t1102-loop-label.sh | 3 | ||||
-rw-r--r-- | tests/t9041-undetected-in-use-16th-partition.sh | 4 |
5 files changed, 17 insertions, 12 deletions
@@ -134,6 +134,9 @@ GNU parted NEWS -*- outline -*- ** Changes in behavior + When attempting to manipulate a mounted partition, parted now issues + a warning that you can choose to ignore, instead of an error. + When creating a loop label, it automatically comes with a partition using the whole disk. diff --git a/parted/parted.c b/parted/parted.c index a36ca28..ec9e04e 100644 --- a/parted/parted.c +++ b/parted/parted.c @@ -224,14 +224,17 @@ _partition_warn_busy (PedPartition* part) if (ped_partition_is_busy (part)) { path = ped_partition_get_path (part); - ped_exception_throw ( - PED_EXCEPTION_ERROR, - PED_EXCEPTION_CANCEL, - _("Partition %s is being used. You must unmount it " - "before you modify it with Parted."), - path); + if (ped_exception_throw ( + PED_EXCEPTION_WARNING, + PED_EXCEPTION_YES_NO, + _("Partition %s is being used. Are you sure you " \ + "want to continue?"), + path) != PED_EXCEPTION_YES) + { + free (path); + return 0; + } free (path); - return 0; } return 1; } diff --git a/tests/t1101-busy-partition.sh b/tests/t1101-busy-partition.sh index eb3fac6..ad091f7 100755 --- a/tests/t1101-busy-partition.sh +++ b/tests/t1101-busy-partition.sh @@ -29,7 +29,7 @@ scsi_debug_setup_ dev_size_mb=80 > dev-name || dev=$(cat dev-name) cat <<EOF > exp-error || framework_failure -Error: Partition ${dev}2 is being used. You must unmount it before you modify it with Parted. +Warning: Partition ${dev}2 is being used. Are you sure you want to continue? EOF parted -s "$dev" mklabel msdos > out 2>&1 || fail=1 diff --git a/tests/t1102-loop-label.sh b/tests/t1102-loop-label.sh index c6574c2..9752002 100644 --- a/tests/t1102-loop-label.sh +++ b/tests/t1102-loop-label.sh @@ -73,8 +73,7 @@ compare exp out || fail=1 # make sure partition busy check works ( mklabel checks whole disk ) parted -s "$dev" rm 1 > out 2>&1; test $? = 1 || fail=1 # create expected output file -echo "Error: Partition $dev is being used. You must unmount it before you modify \ -it with Parted." > exp +echo "Warning: Partition ${dev} is being used. Are you sure you want to continue?" > exp compare exp out || fail=1 umount "$mount_point" diff --git a/tests/t9041-undetected-in-use-16th-partition.sh b/tests/t9041-undetected-in-use-16th-partition.sh index b763e91..edaae1b 100644 --- a/tests/t9041-undetected-in-use-16th-partition.sh +++ b/tests/t9041-undetected-in-use-16th-partition.sh @@ -87,8 +87,8 @@ for part_dev in $partitions; do # Removal of mounted partition must fail. parted -s $scsi_dev rm $n > out 2>&1 && fail=1 - echo "Error: Partition $part_dev is being used." \ - 'You must unmount it before you modify it with Parted.' \ + echo "Warning: Partition $part_dev is being used." \ + 'Are you sure you want to continue?' \ > exp-error || framework_failure_ # expect error |