[parted-devel] [PATCH] Add support for Linux software RAID arrays (mdraid)

Petr Uzel petr.uzel at suse.cz
Fri Apr 16 08:01:29 UTC 2010


Recognize MD devices, so "parted -s /dev/md0 print" now prints
"Model: Linux Software RAID Array (md)" instead of
"Model: Unknown (unknown)".

* include/parted/device.h(PedDeviceType): Add PED_DEVICE_MD.
* libparted/arch/linux.c(MD_MAJOR): New define.
* libparted/arch/linux.c(_device_probe_type): Recognize MD array.
* libparted/arch/linux.c(linux_new): Handle MD array.
* parted/parted.c(do_print): Add "md" to the list of available
  transports.
* NEWS (New features): Mention it.
---
 NEWS                    |    2 ++
 include/parted/device.h |    3 ++-
 libparted/arch/linux.c  |    8 ++++++++
 parted/parted.c         |    3 ++-
 4 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index 8e678db..c5c2182 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,8 @@ GNU parted NEWS                                    -*- outline -*-
 
   parted now recognizes ATA over Ethernet (AoE) devices
 
+  parted now recognizes Linux Software RAID Arrays
+
 ** Bug fixes
 
   When libparted deferenced a /dev/mapper/foo symlink, it would keep the
diff --git a/include/parted/device.h b/include/parted/device.h
index bfeafed..5ca3f12 100644
--- a/include/parted/device.h
+++ b/include/parted/device.h
@@ -47,7 +47,8 @@ typedef enum {
         PED_DEVICE_XVD          = 13,
         PED_DEVICE_SDMMC        = 14,
         PED_DEVICE_VIRTBLK      = 15,
-        PED_DEVICE_AOE          = 16
+        PED_DEVICE_AOE          = 16,
+        PED_DEVICE_MD           = 17
 } PedDeviceType;
 
 typedef struct _PedDevice PedDevice;
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index c75cf9e..85cf813 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -255,6 +255,7 @@ struct blkdev_ioctl_param {
 #define XVD_MAJOR               202
 #define SDMMC_MAJOR             179
 #define LOOP_MAJOR              7
+#define MD_MAJOR                9
 
 #define SCSI_BLK_MAJOR(M) (                                             \
                 (M) == SCSI_DISK0_MAJOR                                 \
@@ -574,6 +575,8 @@ _device_probe_type (PedDevice* dev)
                 dev->type = PED_DEVICE_VIRTBLK;
         } else if (dev_major == LOOP_MAJOR) {
                 dev->type = PED_DEVICE_FILE;
+        } else if (dev_major == MD_MAJOR) {
+                dev->type = PED_DEVICE_MD;
         } else {
                 dev->type = PED_DEVICE_UNKNOWN;
         }
@@ -1381,6 +1384,11 @@ linux_new (const char* path)
                         goto error_free_arch_specific;
                 break;
 
+        case PED_DEVICE_MD:
+                if (!init_generic(dev, _("Linux Software RAID Array")))
+                        goto error_free_arch_specific;
+                break;
+
         default:
                 ped_exception_throw (PED_EXCEPTION_NO_FEATURE,
                                 PED_EXCEPTION_CANCEL,
diff --git a/parted/parted.c b/parted/parted.c
index ae6fd6f..cd1189c 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -1396,7 +1396,8 @@ do_print (PedDevice** dev)
         const char *const transport[] = {"unknown", "scsi", "ide", "dac960",
                                          "cpqarray", "file", "ataraid", "i2o",
                                          "ubd", "dasd", "viodasd", "sx8", "dm",
-                                         "xvd", "sd/mmc", "virtblk", "aoe"};
+                                         "xvd", "sd/mmc", "virtblk", "aoe",
+                                         "md"};
         char*           peek_word;
         char*           start;
         char*           end;
-- 
1.6.4.2


Petr

--
Petr Uzel, openSUSE Boosters Team
IRC: ptr_uzl @ freenode



More information about the parted-devel mailing list