summaryrefslogtreecommitdiff
path: root/parted/ui.c
diff options
context:
space:
mode:
authorWang Dong <dongdwdw@linux.vnet.ibm.com>2016-12-23 06:53:38 +0100
committerBrian C. Lane <bcl@redhat.com>2017-05-01 15:03:31 -0700
commit5a61f15b7003cba73e6517ac22204bafd9a3cb8e (patch)
tree44e9d2a5e1c2b5fd2ac6e86f66c550255c12effd /parted/ui.c
parentaf150f6764a08eae4b4cf448c392259c067a1523 (diff)
downloadparted-5a61f15b7003cba73e6517ac22204bafd9a3cb8e.tar.gz
clean the disk information when commands fail in interactive mode.
parted always reads disk information to memory before any operations. The disk that user operates is actually a copy of real one in memory. When the information in memory is changed, it will commit the memory to device to update the disk information. Once the disk information is read, parted will never re-read it again unless another device is loaded or the device is re-read. Above work has been done in commit 7eac058 (parted: don't reload partition table on every command) Each command of parted always commits the memory when it succeeds. Then the disk information on device and in memory are the same. But when it fails, they might be different. User will be confused by this, and sometimes get undesired result with the contaminated memory. This memory should be cleaned if some command fails. Then the command followed will re-read the disk. Signed-off-by: Wang Dong <dongdwdw@linux.vnet.ibm.com> Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Diffstat (limited to 'parted/ui.c')
-rw-r--r--parted/ui.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/parted/ui.c b/parted/ui.c
index 5d76c20..af0539c 100644
--- a/parted/ui.c
+++ b/parted/ui.c
@@ -1612,8 +1612,14 @@ interactive_mode (PedDevice** dev, PedDisk** disk, Command* cmd_list[])
cmd = command_get (commands, word);
free (word);
if (cmd) {
- if (!command_run (cmd, dev, disk))
+ if (!command_run (cmd, dev, disk)) {
command_line_flush ();
+
+ if (*disk) {
+ ped_disk_destroy (*disk);
+ *disk = 0;
+ }
+ }
} else
print_commands_help ();
}