[PATCH parted] Handle swap flag in msdos type labels

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: David Cantrell <dcantrell@xxxxxxxxxx>

Original patch by David Cantrell <dcantrell@xxxxxxxxxx>, I
(Hans de Goede <hdegoede@xxxxxxxxxx>) made the following changes:
-msdos_partition_is_flag_available() should return 1 for swap flag
-Only change the partition type to 82 when setting the swap flag
 on dos labels, not when resetting it
---
 libparted/labels/dos.c |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
index cc9e0e3..c3b4932 100644
--- a/libparted/labels/dos.c
+++ b/libparted/labels/dos.c
@@ -151,6 +151,7 @@ typedef struct {
 	int		lba;
 	int		palo;
 	int		prep;
+	int		swap;
 	OrigState*	orig;			/* used for CHS stuff */
 } DosPartitionData;
 
@@ -799,6 +800,7 @@ raw_part_parse (const PedDisk* disk, const DosRawPartition* raw_part,
 	dos_data->lba = raw_part_is_lba (raw_part);
 	dos_data->palo = raw_part->type == PARTITION_PALO;
 	dos_data->prep = raw_part->type == PARTITION_PREP;
+	dos_data->swap = raw_part->type == PARTITION_LINUX_SWAP;
 	dos_data->orig = ped_malloc (sizeof (OrigState));
 	if (!dos_data->orig) {
 		ped_partition_destroy (part);
@@ -1199,6 +1201,7 @@ msdos_partition_new (const PedDisk* disk, PedPartitionType part_type,
 		dos_data->lba = 0;
 		dos_data->palo = 0;
 		dos_data->prep = 0;
+		dos_data->swap = 0;
 	} else {
 		part->disk_specific = NULL;
 	}
@@ -1234,6 +1237,7 @@ msdos_partition_duplicate (const PedPartition* part)
 	new_dos_data->lba = old_dos_data->lba;
 	new_dos_data->palo = old_dos_data->palo;
 	new_dos_data->prep = old_dos_data->prep;
+	new_dos_data->swap = old_dos_data->swap;
 
 	if (old_dos_data->orig) {
 		new_dos_data->orig = ped_malloc (sizeof (OrigState));
@@ -1281,6 +1285,7 @@ msdos_partition_set_system (PedPartition* part,
 		dos_data->lvm = 0;
 		dos_data->palo = 0;
 		dos_data->prep = 0;
+		dos_data->swap = 0;
 		if (dos_data->lba)
 			dos_data->system = PARTITION_EXT_LBA;
 		else
@@ -1304,6 +1309,10 @@ msdos_partition_set_system (PedPartition* part,
 		dos_data->system = PARTITION_PREP;
 		return 1;
 	}
+	if (dos_data->swap) {
+		dos_data->system = PARTITION_LINUX_SWAP;
+		return 1;
+	}
 
 	if (!fs_type)
 		dos_data->system = PARTITION_LINUX;
@@ -1376,6 +1385,7 @@ msdos_partition_set_flag (PedPartition* part,
 			dos_data->lvm = 0;
 			dos_data->palo = 0;
 			dos_data->prep = 0;
+			dos_data->swap = 0;
 		}
 		dos_data->raid = state;
 		return ped_partition_set_system (part, part->fs_type);
@@ -1386,6 +1396,7 @@ msdos_partition_set_flag (PedPartition* part,
 			dos_data->raid = 0;
 			dos_data->palo = 0;
 			dos_data->prep = 0;
+			dos_data->swap = 0;
 		}
 		dos_data->lvm = state;
 		return ped_partition_set_system (part, part->fs_type);
@@ -1399,6 +1410,7 @@ msdos_partition_set_flag (PedPartition* part,
 			dos_data->hidden = 0;
 			dos_data->raid = 0;
 			dos_data->lvm = 0;
+			dos_data->swap = 0;
 		}
 		dos_data->palo = state;
 		return ped_partition_set_system (part, part->fs_type);
@@ -1408,10 +1420,23 @@ msdos_partition_set_flag (PedPartition* part,
 			dos_data->hidden = 0;
 			dos_data->raid = 0;
 			dos_data->lvm = 0;
+			dos_data->swap = 0;
+			dos_data->palo = 0;
 		}
 		dos_data->prep = state;
 		return ped_partition_set_system (part, part->fs_type);
 
+	case PED_PARTITION_SWAP:
+		if (state) {
+			dos_data->hidden = 0;
+			dos_data->raid = 0;
+			dos_data->lvm = 0;
+			dos_data->palo = 0;
+			dos_data->prep = 0;
+		}
+		dos_data->swap = state;
+		return ped_partition_set_system (part, part->fs_type);
+
 	default:
 		return 0;
 	}
@@ -1448,6 +1473,9 @@ msdos_partition_get_flag (const PedPartition* part, PedPartitionFlag flag)
 	case PED_PARTITION_PREP:
 		return dos_data->prep;
 
+	case PED_PARTITION_SWAP:
+		return dos_data->swap;
+
 	default:
 		return 0;
 	}
@@ -1465,6 +1493,7 @@ msdos_partition_is_flag_available (const PedPartition* part,
 	case PED_PARTITION_LBA:
 	case PED_PARTITION_PALO:
 	case PED_PARTITION_PREP:
+	case PED_PARTITION_SWAP:
 		return 1;
 
 	default:
-- 
1.6.5.rc2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux