1
#! /bin/sh /usr/share/dpatch/dpatch-run
2
## parted-dmraid.dpatch by Luke Yelavich <themuso@ubuntu.com>
4
## All lines beginning with `## DP:' are a description of the patch.
5
## DP: Patch to ensure that device mapper devices for dmraid arrays do not
6
## DP: have extra nodes created needlessly.
9
diff -urNad parted-1.8.8.git.2008.03.24~/libparted/arch/linux.c parted-1.8.8.git.2008.03.24/libparted/arch/linux.c
10
--- parted-1.8.8.git.2008.03.24~/libparted/arch/linux.c 2008-08-15 09:39:18.000000000 +1000
11
+++ parted-1.8.8.git.2008.03.24/libparted/arch/linux.c 2008-08-15 09:41:02.000000000 +1000
14
static char* _device_get_part_path (PedDevice* dev, int num);
15
static int _partition_is_mounted_by_path (const char* path);
16
+#ifdef ENABLE_DEVICE_MAPPER
17
+static int _is_dmraid_device (char* devpath);
18
+static char* dmraid_device;
22
_is_ide_major (int major)
23
@@ -1996,6 +2000,10 @@
24
} else if (!strncmp (dev->path, "/dev/loop", 9)) {
25
/* Loop devices can only have one partition. */
26
strcpy (result, dev->path);
27
+#ifdef ENABLE_DEVICE_MAPPER
28
+ } else if (dev->type == PED_DEVICE_DM && _is_dmraid_device (dev->path)) {
29
+ snprintf (result, result_len, "%s%d", dev->path, num);
31
} else if (dev->type == PED_DEVICE_DAC960
32
|| dev->type == PED_DEVICE_CPQARRAY
33
|| dev->type == PED_DEVICE_ATARAID
35
char* vol_name = NULL;
36
char* dev_name = NULL;
38
+ char* dm_uuid = NULL;
41
if (!_has_partitions(disk))
43
@@ -2401,6 +2411,12 @@
44
dm_task_set_name (task, vol_name);
45
dm_task_add_target (task, 0, part->geom.length,
47
+ if (_is_dmraid_device (disk->dev->path)) {
48
+ uuid_len = (strlen (vol_name) + 8);
49
+ dm_uuid = (char*) ped_malloc (uuid_len);
50
+ snprintf(dm_uuid, uuid_len, "DMRAID-%s", vol_name);
51
+ dm_task_set_uuid(task, dm_uuid);
53
rc = dm_task_run(task);
55
//printf("0 %ld linear %s\n", part->geom.length, params);
57
dm_task_destroy(task);
64
_dm_remove_map_name(vol_name);
65
@@ -2443,6 +2461,60 @@
66
if (!_dm_add_partition (disk, part))
70
+ ped_free(dmraid_device);
75
+_is_dmraid_device (char* devpath)
77
+ struct dm_task* task = NULL;
79
+ const char* dmraid_uuid;
81
+ char* dm_name = NULL;
83
+ dm_name = strrchr (devpath, '/');
84
+ if (dm_name && *dm_name && *(++dm_name))
85
+ dm_name = strdup (dm_name);
87
+ dm_name = strdup (devpath);
91
+ dm_len = strlen(dm_name);
93
+ if (!dmraid_device) {
94
+ dmraid_device = (char*) ped_malloc(dm_len);
99
+ if (strcmp (dmraid_device, dm_name) == 0) {
103
+ task = dm_task_create(DM_DEVICE_DEPS);
107
+ dm_task_set_name(task, dm_name);
108
+ rc = dm_task_run(task);
115
+ dmraid_uuid = dm_task_get_uuid(task);
116
+ if (strncmp (dmraid_uuid, "DMRAID-", 8)) {
117
+ strcpy (dmraid_device, dm_name);
122
+ dm_task_destroy(task);