parted 1.8.7 (git trunk seems to be the same)

The comparison of fs_type->name to "linux-swap" no longer catches Linux
swap partitions as they're called either "linux-swap(new)" or
"linux-swap(old)".  This means, at least in the DOS label code, creating
Linux swap partitions results in the system (type) byte in the partition
table defaulting to "0x83" (Linux) rather than "0x82" (Linux Swap).

I've fixed this by performing a match on the first ten characters of the
fs_type->name variable ("linux-swap" is ten characters long).

Find attached a patch for the following labels: bsd, dasd, dos, mac, rdb
and sun.  From what I can tell, the other labels either don't handle
Linux swap partitions or don't need to be changed (e.g. gpt simply looks
for a substring of "swap").

Cheers,

Kenny.

--
Desktop Services, IS Infrastructure, The University of Edinburgh


--- bsd.c.orig	Wed Apr 18 22:12:10 2007
+++ bsd.c	Wed Jul 25 12:21:55 2007
@@ -441,7 +441,7 @@
 
 	if (!fs_type)
 		bsd_data->type = 0x8;
-	else if (!strcmp (fs_type->name, "linux-swap"))
+	else if (!strncmp (fs_type->name, "linux-swap", 10))
 		bsd_data->type = 0x1;
 	else
 		bsd_data->type = 0x8;
--- dasd.c.orig	Wed Jul 25 12:26:05 2007
+++ dasd.c	Wed Jul 25 12:32:24 2007
@@ -809,7 +809,7 @@
 	if (!fs_type) {
 		dasd_data->system = PARTITION_LINUX;
         PDEBUG;
-	} else if (!strcmp (fs_type->name, "linux-swap")) {
+	} else if (!strncmp (fs_type->name, "linux-swap", 10)) {
 		dasd_data->system = PARTITION_LINUX_SWAP;
         PDEBUG;
 	} else {
--- dos.c.orig	Wed May  9 21:40:16 2007
+++ dos.c	Wed Jul 25 12:22:59 2007
@@ -1286,7 +1286,7 @@
 		dos_data->system |= dos_data->hidden ? PART_FLAG_HIDDEN : 0;
 	} else if (!strcmp (fs_type->name, "sun-ufs"))
 		dos_data->system = PARTITION_SUN_UFS;
-	else if (!strcmp (fs_type->name, "linux-swap"))
+	else if (!strncmp (fs_type->name, "linux-swap", 10))
 		dos_data->system = PARTITION_LINUX_SWAP;
 	else
 		dos_data->system = PARTITION_LINUX;
--- mac.c.orig	Wed Jul 25 12:23:19 2007
+++ mac.c	Wed Jul 25 12:23:31 2007
@@ -1188,7 +1188,7 @@
 
 	part->fs_type = fs_type;
 
-	if (fs_type && !strcmp (fs_type->name, "linux-swap"))
+	if (fs_type && !strncmp (fs_type->name, "linux-swap", 10))
 		ped_partition_set_flag (part, PED_PARTITION_SWAP, 1);
 
 	if (mac_data->is_boot) {
--- rdb.c.orig	Wed Jul 25 12:23:56 2007
+++ rdb.c	Wed Jul 25 12:24:15 2007
@@ -886,7 +886,7 @@
 		partition->de_DosType = PED_CPU_TO_BE32(0x4c4e5800); /* 'LNX\0' */
 	else if (!strcmp (fs_type->name, "ext3"))
 		partition->de_DosType = PED_CPU_TO_BE32(0x45585403); /* 'EXT\3' */
-	else if (!strcmp (fs_type->name, "linux-swap"))
+	else if (!strncmp (fs_type->name, "linux-swap", 10))
 		partition->de_DosType = PED_CPU_TO_BE32(0x53575000); /* 'SWP\0' */
 	else if (!strcmp (fs_type->name, "fat16"))
 		partition->de_DosType = PED_CPU_TO_BE32(0x46415400); /* 'FAT\0' */
--- sun.c.orig	Wed Jul 25 12:23:46 2007
+++ sun.c	Wed Jul 25 12:24:37 2007
@@ -548,7 +548,7 @@
 
 	sun_data->type = 0x83;
 	if (fs_type) {
-		if (!strcmp (fs_type->name, "linux-swap"))
+		if (!strncmp (fs_type->name, "linux-swap", 10))
 			sun_data->type = 0x82;
 		else if (!strcmp (fs_type->name, "ufs"))
 			sun_data->type = 0x6;
_______________________________________________
bug-parted mailing list
bug-parted@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-parted

Reply via email to