[parted-devel] [PATCH 1/2] Add nonfs partition type 0xda (#1263835)

Brian C. Lane bcl at redhat.com
Wed Sep 30 23:06:58 UTC 2015


mdraid arrays with metadata >= 1.0 should not use the raid (0xfd)
autoassemble type, this adds a new partition type that can be used
without triggering side effects.

This adds support for the nonfs flag to the msdos partition table, and
the PED_PARTITION_NONFS flag.
---
 include/parted/disk.in.h |  5 +++--
 libparted/disk.c         |  2 ++
 libparted/labels/dos.c   | 21 +++++++++++++++++++++
 3 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/include/parted/disk.in.h b/include/parted/disk.in.h
index 58d49f0..b06e69d 100644
--- a/include/parted/disk.in.h
+++ b/include/parted/disk.in.h
@@ -75,10 +75,11 @@ enum _PedPartitionFlag {
         PED_PARTITION_LEGACY_BOOT=15,
         PED_PARTITION_MSFT_DATA=16,
         PED_PARTITION_IRST=17,
-        PED_PARTITION_ESP=18
+        PED_PARTITION_ESP=18,
+        PED_PARTITION_NONFS=19
 };
 #define PED_PARTITION_FIRST_FLAG        PED_PARTITION_BOOT
-#define PED_PARTITION_LAST_FLAG         PED_PARTITION_ESP
+#define PED_PARTITION_LAST_FLAG         PED_PARTITION_NONFS
 
 enum _PedDiskTypeFeature {
         PED_DISK_TYPE_EXTENDED=1,       /**< supports extended partitions */
diff --git a/libparted/disk.c b/libparted/disk.c
index fe82f44..e1911bf 100644
--- a/libparted/disk.c
+++ b/libparted/disk.c
@@ -2406,6 +2406,8 @@ ped_partition_flag_get_name (PedPartitionFlag flag)
                 return N_("irst");
         case PED_PARTITION_ESP:
                 return N_("esp");
+        case PED_PARTITION_NONFS:
+                return N_("nonfs");
 
 	default:
 		ped_exception_throw (
diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
index fa53020..fa1571a 100644
--- a/libparted/labels/dos.c
+++ b/libparted/labels/dos.c
@@ -90,6 +90,7 @@ static const char MBR_BOOT_CODE[] = {
 #define PARTITION_LINUX_LVM	0x8e
 #define PARTITION_HFS		0xaf
 #define PARTITION_SUN_UFS	0xbf
+#define PARTITION_NONFS		0xda
 #define PARTITION_DELL_DIAG	0xde
 #define PARTITION_GPT		0xee
 #define PARTITION_ESP		0xef
@@ -163,6 +164,7 @@ typedef struct {
 	int		diag;
 	int		irst;
 	int		esp;
+        int		nonfs;
 	OrigState*	orig;			/* used for CHS stuff */
 } DosPartitionData;
 
@@ -959,6 +961,7 @@ raw_part_parse (const PedDisk* disk, const DosRawPartition* raw_part,
 	dos_data->prep = raw_part->type == PARTITION_PREP;
 	dos_data->irst = raw_part->type == PARTITION_IRST;
 	dos_data->esp = raw_part->type == PARTITION_ESP;
+	dos_data->nonfs = raw_part->type == PARTITION_NONFS;
 	dos_data->orig = ped_malloc (sizeof (OrigState));
 	if (!dos_data->orig) {
 		ped_partition_destroy (part);
@@ -1353,6 +1356,7 @@ msdos_partition_new (const PedDisk* disk, PedPartitionType part_type,
 		dos_data->prep = 0;
 		dos_data->irst = 0;
 		dos_data->esp = 0;
+                dos_data->nonfs = 0;
 	} else {
 		part->disk_specific = NULL;
 	}
@@ -1390,6 +1394,7 @@ msdos_partition_duplicate (const PedPartition* part)
 	new_dos_data->prep = old_dos_data->prep;
 	new_dos_data->irst = old_dos_data->irst;
 	new_dos_data->esp = old_dos_data->esp;
+	new_dos_data->nonfs = old_dos_data->nonfs;
 
 	if (old_dos_data->orig) {
 		new_dos_data->orig = ped_malloc (sizeof (OrigState));
@@ -1440,6 +1445,7 @@ msdos_partition_set_system (PedPartition* part,
 		dos_data->prep = 0;
 		dos_data->irst = 0;
 		dos_data->esp = 0;
+		dos_data->nonfs = 0;
 		if (dos_data->lba)
 			dos_data->system = PARTITION_EXT_LBA;
 		else
@@ -1480,6 +1486,10 @@ msdos_partition_set_system (PedPartition* part,
 		dos_data->system = PARTITION_ESP;
 		return 1;
 	}
+	if (dos_data->nonfs) {
+		dos_data->system = PARTITION_NONFS;
+		return 1;
+	}
 
 	if (!fs_type)
 		dos_data->system = PARTITION_LINUX;
@@ -1518,6 +1528,7 @@ clear_flags (DosPartitionData *dos_data)
   dos_data->prep = 0;
   dos_data->irst = 0;
   dos_data->esp = 0;
+  dos_data->nonfs = 0;
   dos_data->raid = 0;
 }
 
@@ -1608,6 +1619,12 @@ msdos_partition_set_flag (PedPartition* part,
 		dos_data->esp = state;
 		return ped_partition_set_system (part, part->fs_type);
 
+	case PED_PARTITION_NONFS:
+		if (state)
+			clear_flags (dos_data);
+		dos_data->nonfs = state;
+		return ped_partition_set_system (part, part->fs_type);
+
 	default:
 		return 0;
 	}
@@ -1656,6 +1673,9 @@ msdos_partition_get_flag (const PedPartition* part, PedPartitionFlag flag)
 	case PED_PARTITION_ESP:
 		return dos_data->esp;
 
+	case PED_PARTITION_NONFS:
+		return dos_data->nonfs;
+
 	default:
 		return 0;
 	}
@@ -1680,6 +1700,7 @@ msdos_partition_is_flag_available (const PedPartition* part,
 	case PED_PARTITION_PREP:
 	case PED_PARTITION_IRST:
 	case PED_PARTITION_ESP:
+	case PED_PARTITION_NONFS:
 	case PED_PARTITION_DIAG:
 		return 1;
 
-- 
2.4.3




More information about the parted-devel mailing list