The blacklisting of md devices in
http://git.debian.org/?p=parted/parted.git;a=commit;h=f94e08bdb4ba0fa1b9fd35509e04c2d9ee84ff80
breaks RAID support in the Debian installer, because we're expecting to
be able to walk all devices libparted knows about and find /dev/md0 etc.
after setting up arrays. While we don't actually want to attempt to put
partition tables on these devices, it's still useful to have libparted
recognise these devices; there are things it can do other than creating
partition tables ...

How about this patch instead (against next, but should be pretty close
to master as well)? We use "loop" labels as fake partition tables for
things that are essentially just a single filesystem directly on a
disk-like block device, so it makes sense never to apply partition table
changes to those.

Thanks,

-- 
Colin Watson                                       [[email protected]]
>From 936f5605af5b915b1a19d21c239a8b0c8d60e227 Mon Sep 17 00:00:00 2001
From: Colin Watson <[email protected]>
Date: Fri, 24 Jul 2009 12:43:42 +0100
Subject: [PATCH] Recognise md devices again, but understand that they can't be partitioned

* libparted/arch/linux.c (_skip_entry): Don't skip "md" devices.
(_has_partitions): New function; "loop" labels can't be partitioned.
(_blkpg_add_partition, _blkpg_remove_partition, _dm_add_partition,
_have_blkpg): Don't attempt to apply partition table changes to
unpartitionable devices.
---
 libparted/arch/linux.c |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 5699197..f875581 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -1985,7 +1985,6 @@ _skip_entry (const char *name)
 		{ ".",		sizeof (".") - 1	},
 		{ "..",		sizeof ("..") - 1	},
 		{ "dm-",	sizeof ("dm-") - 1	},
-		{ "md",		sizeof ("md") - 1	},
 		{ "loop",	sizeof ("loop") - 1	},
 		{ "ram",	sizeof ("ram") - 1	},
 		{ 0, 0 },
@@ -2180,6 +2179,18 @@ _partition_is_mounted (const PedPartition *part)
 }
 
 static int
+_has_partitions (const PedDisk* disk)
+{
+        PED_ASSERT(disk != NULL, return 0);
+
+        /* Some devices can't be partitioned. */
+        if (!strcmp (disk->type->name, "loop"))
+                return 0;
+
+        return 1;
+}
+
+static int
 linux_partition_is_busy (const PedPartition* part)
 {
         PedPartition*   walk;
@@ -2222,6 +2233,9 @@ _blkpg_add_partition (PedDisk* disk, const PedPartition *part)
         PED_ASSERT(disk->dev->sector_size % PED_SECTOR_SIZE_DEFAULT == 0,
                    return 0);
 
+        if (!_has_partitions (disk))
+                return 0;
+
         if (ped_disk_type_check_feature (disk->type,
                                          PED_DISK_TYPE_PARTITION_NAME))
                 vol_name = ped_partition_get_name (part);
@@ -2270,6 +2284,9 @@ _blkpg_remove_partition (PedDisk* disk, int n)
 {
         struct blkpg_partition  linux_part;
 
+        if (!_has_partitions (disk))
+                return 0;
+
         memset (&linux_part, 0, sizeof (linux_part));
         linux_part.pno = n;
         return _blkpg_part_command (disk->dev, &linux_part,
@@ -2503,6 +2520,9 @@ _dm_add_partition (PedDisk* disk, PedPartition* part)
         char*           dev_name = NULL;
         char*           params = NULL;
 
+        if (!_has_partitions(disk))
+                return 0;
+
         dev_name = _device_get_part_path (disk->dev, part->num);
         if (!dev_name)
                 return 0;
@@ -2624,6 +2644,9 @@ _have_blkpg ()
 static int
 linux_disk_commit (PedDisk* disk)
 {
+       if (!_has_partitions (disk))
+               return 1;
+
 #ifdef ENABLE_DEVICE_MAPPER
         if (disk->dev->type == PED_DEVICE_DM)
                 return _dm_reread_part_table (disk);
-- 
1.6.3.3

_______________________________________________
parted-devel mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/parted-devel

Reply via email to