[parted-devel] [PATCH] libparted/dasd: improve lvm/raid flag handling for DASD-CDL
Wang Dong
dongdwdw at linux.vnet.ibm.com
Fri Mar 24 02:11:11 UTC 2017
From: André Wild <wild at linux.vnet.ibm.com>
This commit corrects the reading of lvm/raid flags on DASD/CDL formatted
disks. Previously, users were not able to see what was the actual flags
stored on the disk. Also, warn users in interactive mode about existing
file systems when setting the lvm/raid flag. In script mode, this
warning is ignored.
Signed-off-by: André Wild <wild at linux.vnet.ibm.com>
Signed-off-by: Wang Dong <dongdwdw at linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner at linux.vnet.ibm.com>
---
libparted/labels/dasd.c | 33 +++++++++++++++++++++------------
1 file changed, 21 insertions(+), 12 deletions(-)
diff --git a/libparted/labels/dasd.c b/libparted/labels/dasd.c
index a8849a9..c61e014 100644
--- a/libparted/labels/dasd.c
+++ b/libparted/labels/dasd.c
@@ -446,18 +446,9 @@ dasd_read (PedDisk* disk)
}
dasd_data = part->disk_specific;
-
- if ((strncmp(PART_TYPE_RAID, str, 6) == 0) &&
- (ped_file_system_probe(&part->geom) == NULL))
- ped_partition_set_flag(part, PED_PARTITION_RAID, 1);
- else
- ped_partition_set_flag(part, PED_PARTITION_RAID, 0);
-
- if ((strncmp(PART_TYPE_LVM, str, 6) == 0) &&
- (ped_file_system_probe(&part->geom) == NULL))
- ped_partition_set_flag(part, PED_PARTITION_LVM, 1);
- else
- ped_partition_set_flag(part, PED_PARTITION_LVM, 0);
+ dasd_data->raid = !strncmp(PART_TYPE_RAID, str, 6);
+ dasd_data->lvm = !strncmp(PART_TYPE_LVM, str, 6);
+ dasd_partition_set_system(part, part->fs_type);
if (strncmp(PART_TYPE_SWAP, str, 6) == 0) {
fs = ped_file_system_probe(&part->geom);
@@ -743,6 +734,24 @@ dasd_partition_set_flag (PedPartition* part, PedPartitionFlag flag, int state)
switch (flag) {
case PED_PARTITION_RAID:
+ case PED_PARTITION_LVM:
+ if (!state)
+ break;
+ if (!ped_file_system_probe(&part->geom))
+ break;
+ if (ped_exception_throw (PED_EXCEPTION_WARNING,
+ PED_EXCEPTION_YES_NO,
+ _("Setting %s for this partition might render any existing file system unusable.\n"
+ "Are you sure you want to proceed?"),
+ ped_partition_flag_get_name (flag))
+ == PED_EXCEPTION_NO)
+ return 0;
+ default:
+ break;
+ }
+
+ switch (flag) {
+ case PED_PARTITION_RAID:
if (state)
dasd_data->lvm = 0;
dasd_data->raid = state;
--
2.8.4
More information about the parted-devel
mailing list