parted/clean-the-disk-information-when-commands-fail-in-int.patch
Marcus Meissner 5b97712c80 Accepting request 712877 from home:anicka:branches:Base:System
- port fixes for various bugs from upstream (bsc#1136245)
 - add: libparted-dasd-correct-the-offset-where-the-first-pa.patch
   4126d02, correct the offset where the first partition begins. 
   This patch implements libparted-dasd-do-not-use-first-tracks.patch 
 - remove: libparted-dasd-do-not-use-first-tracks.patch
 - add: parted-fix-crash-due-to-improper-partition-number-in.patch
   149f009, fix crash due to improper partition number input,
   changed call to strtol, use base 0 to fit our parted-type.patch
 - modify: parted-type.patch (removed ui.c part)
 - add: parted-check-the-name-of-partition-first-when-to-nam.patch
   d7a2ff1, check the name of partition first when to name a partition
 - add: libparted-dasd-add-test-cases-for-the-new-fdasd-func.patch 
   c11f5c0, 571e078, add test cases for the new fdasd functions
 - add: libparted-dasd-add-an-exception-for-changing-DASD-LD.patch
   ee2c0c2, add an exception for changing DASD-LDL partition table
 - add: libpartd-dasd-improve-flag-processing-for-DASD-LDL.patch
   1545d6d, improve flag processing for DASD-LDL
 - add: clean-the-disk-information-when-commands-fail-in-int.patch
   5a61f15, clean the disk information when commands fail in 
   interactive mode
 - add: parted-ui-remove-unneccesary-information-of-command.patch
   0b7946a, remove unneccesary information of command line
 - add: parted-fix-wrong-error-label-jump-in-mkpart.patch
   af150f6, fix wrong error label jump in mkpart
 - refresh: libparted-dasd-unify-vtoc-handling-for-cdl-ldl.patch
   4f25d54, unify vtoc handling for cdl/ldl
 - refresh: libparted-dasd-update-and-improve-fdasd-functions.patch
   db37c8c, update and improve fdasd functions
 - refresh: libparted-dasd-add-new-fdasd-functions.patch
   b9e1281, add new fdasd functions

OBS-URL: https://build.opensuse.org/request/show/712877
OBS-URL: https://build.opensuse.org/package/show/Base:System/parted?expand=0&rev=142
2019-07-08 12:12:35 +00:00

84 lines
3.2 KiB
Diff

From 5a61f15b7003cba73e6517ac22204bafd9a3cb8e Mon Sep 17 00:00:00 2001
From: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Date: Fri, 23 Dec 2016 06:53:38 +0100
Subject: [PATCH] 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>
---
parted/parted.c | 14 ++++++++++----
parted/ui.c | 8 +++++++-
2 files changed, 17 insertions(+), 5 deletions(-)
Index: parted-3.2/parted/parted.c
===================================================================
--- parted-3.2.orig/parted/parted.c
+++ parted-3.2/parted/parted.c
@@ -1501,8 +1501,12 @@ _rescue_add_partition (PedPartition* par
default: break;
}
- ped_partition_set_system (part, fs_type);
- ped_disk_commit (part->disk);
+ if (!ped_partition_set_system (part, fs_type))
+ return 0;
+
+ if (!ped_disk_commit (part->disk))
+ return 0;
+
return 1;
}
@@ -1727,8 +1731,10 @@ do_rm (PedDevice** dev, PedDisk** diskp)
if (!_partition_warn_busy (part, danger_if_busy))
goto error;
- ped_disk_delete_partition (*diskp, part);
- ped_disk_commit (*diskp);
+ if (!ped_disk_delete_partition (*diskp, part))
+ goto error;
+ if (!ped_disk_commit (*diskp))
+ goto error;
if ((*dev)->type != PED_DEVICE_FILE)
disk_is_modified = 1;
Index: parted-3.2/parted/ui.c
===================================================================
--- parted-3.2.orig/parted/ui.c
+++ parted-3.2/parted/ui.c
@@ -1614,8 +1614,14 @@ interactive_mode (PedDevice** dev, PedDi
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 ();
}