[Parted-commits] GNU Parted Official Repository: Changes to 'master'
Jim Meyering
meyering at alioth.debian.org
Mon May 14 10:08:20 UTC 2007
parted/parted.c | 5 ++++-
tests/t2000-mkfs.sh | 38 ++++++++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 1 deletion(-)
New commits:
commit 73240b98d00154cd62636f0f3054d4c8301c36a6
Author: Flavio Leitner <flavio.leitner at gmail.com>
Date: Mon May 14 12:04:18 2007 +0200
Fix exception handling in mkpart and mkpartfs
Parted mkpart and mkpartfs commands does:
...
ped_exception_fetch_all();
if (!ped_disk_add_partition (disk, part, final_constraint)) {
ped_exception_leave_all();
...
}
...
In mkpart if the ped_disk_add_partition() returns true it skips
ped_exception_leave_all() leaving ex_fetch_count = 1.
In mkpartfs if the ped_disk_add_partition() returns false it will
call ped_exception_leave_all() leaving ex_fetch_count negative.
The wrong count in ex_fetch_count will prevent next commands to
correctly handle exceptions, failing to prompt users for example.
Note: test script t2000-mkfs.sh improved to verify against this issue.
Signed-off-by: Flavio Leitner <flavio.leitner at gmail.com>
Signed-off-by: Jim Meyering <jim at meyering.net>
diff --git a/parted/parted.c b/parted/parted.c
index c7b3e22..202558a 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -784,6 +784,8 @@ do_mkpart (PedDevice** dev)
} else {
goto error_remove_part;
}
+ } else {
+ ped_exception_leave_all();
}
ped_exception_catch();
@@ -952,9 +954,10 @@ do_mkpartfs (PedDevice** dev)
} else {
goto error_remove_part;
}
+ } else {
+ ped_exception_leave_all();
}
ped_exception_catch();
- ped_exception_leave_all();
/* set LBA flag automatically if available */
if (ped_partition_is_flag_available (part, PED_PARTITION_LBA))
diff --git a/tests/t2000-mkfs.sh b/tests/t2000-mkfs.sh
index 14140f6..fb42f7a 100755
--- a/tests/t2000-mkfs.sh
+++ b/tests/t2000-mkfs.sh
@@ -42,4 +42,42 @@ test_expect_success \
test_expect_success 'expect no output' '$compare out /dev/null'
+N=10M
+test_expect_success \
+ 'create a file large enough to hold a fat32 file system' \
+ 'dd if=/dev/zero of=$dev bs=$N count=1 2> /dev/null'
+
+test_expect_success \
+ 'label the test disk' \
+ 'parted -s $dev mklabel msdos > out 2>&1'
+test_expect_success 'expect no output' '$compare out /dev/null'
+
+# test if can create a partition and a filesystem in the same session.
+fail=0
+cat <<EOF >in || fail=1
+mkpart
+primary
+ext2
+0
+10
+mkfs
+No
+quit
+EOF
+test_expect_success 'create input file' 'test $fail = 0'
+
+test_expect_success \
+ 'create a partition and a filesystem in the same session' \
+ 'parted ---pretend-input-tty $dev < in > out 2>&1'
+
+test_expect_success \
+ 'normalize the actual output' \
+ 'sed -n "s/.*\(Warning: The existing.*\)$/\1/p" out > out2'
+
+test_expect_success \
+ 'check for expected prompt' \
+ 'echo "Warning: The existing file system will be destroyed and all" \
+ "data on the partition will be lost. Do you want to continue?" > exp &&
+ $compare out2 exp'
+
test_done
More information about the Parted-commits
mailing list