Bug#497110: boot loader installation failed when dmraid=true
On Saturday 06 September 2008, Frans Pop wrote:
> At first glance the patch also needs some cleanup. The .gitignore
> changes look like they are just noise and the actual changes are not
> really consistent regarding whitespace for example.
Here's a cleaned-up version.
diff -u parted-1.8.8.git.2008.03.24/debian/changelog parted-1.8.8.git.2008.03.24/debian/changelog
--- parted-1.8.8.git.2008.03.24/debian/changelog
+++ parted-1.8.8.git.2008.03.24/debian/changelog
@@ -1,3 +1,15 @@
+parted (1.8.8.git.2008.03.24-9.1) unstable; urgency=low
+
+ * Non-maintainer upload.
+ * Merge from Ubuntu: debian/patches/parted-dmraid.dpatch: Patch to educate
+ libparted about dmraid arrays, which use device mapper. Libparted was
+ naming new partition nodes incorrectly, and not setting the UUIDs for
+ dmraid device nodes. (Closes: #497110)
+ * debian/patches/parted-dmraid.dpatch: Make sure that partition nodes for
+ dmraid devices are probed
+
+ -- Giuseppe Iuculano <giuseppe@iuculano.it> Sat, 06 Sep 2008 15:02:11 +0200
+
parted (1.8.8.git.2008.03.24-9) unstable; urgency=low
[ Otavio Salvador ]
diff -u parted-1.8.8.git.2008.03.24/debian/patches/00list parted-1.8.8.git.2008.03.24/debian/patches/00list
--- parted-1.8.8.git.2008.03.24/debian/patches/00list
+++ parted-1.8.8.git.2008.03.24/debian/patches/00list
@@ -5,6 +5,7 @@
# Patch susceptible to be merged upstream
devfs
#kfreebsd-gnu
+parted-dmraid
# Will also stay debian specific, but depends on some of the above :/
sparc-fix-raid
only in patch2:
unchanged:
--- parted-1.8.8.git.2008.03.24.orig/debian/patches/parted-dmraid.dpatch
+++ parted-1.8.8.git.2008.03.24/debian/patches/parted-dmraid.dpatch
@@ -0,0 +1,161 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## parted-dmraid.dpatch by Luke Yelavich <themuso@ubuntu.com>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Patch to ensure that device mapper devices for dmraid arrays do not
+## DP: have extra nodes created needlessly, as well as making sure that
+## DP: partition nodes for dmraid devices are not probed.
+
+@DPATCH@
+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
+--- parted-1.8.8.git.2008.03.24~/libparted/arch/linux.c 2006-05-08 20:08:37.000000000 +0200
++++ parted-1.8.8.git.2008.03.24/libparted/arch/linux.c 2008-09-06 14:59:13.000000000 +0200
+@@ -263,6 +263,10 @@
+
+ static char* _device_get_part_path (PedDevice* dev, int num);
+ static int _partition_is_mounted_by_path (const char* path);
++#ifdef ENABLE_DEVICE_MAPPER
++static int _is_dmraid_device (char* devpath);
++static int _is_dmraid_major (char* devpath);
++#endif
+
+ static int
+ _is_ide_major (int major)
+@@ -456,7 +460,7 @@
+ continue;
+
+ if (_is_dm_major(major(st.st_rdev)))
+- _ped_device_probe (buf);
++ _ped_device_probe (buf);
+ }
+ closedir (mapper_dir);
+
+@@ -2056,6 +2060,11 @@
+ * a pure userpace (udev) decision! */
+ snprintf (result, result_len, "%s-part%d", dev->path, num);
+ #endif
++#ifdef ENABLE_DEVICE_MAPPER
++ } else if (dev->type == PED_DEVICE_DM && _is_dmraid_device (dev->path)) {
++ snprintf (result, result_len, "%s%d", dev->path, num);
++#endif
++
+ } else if (dev->type == PED_DEVICE_DAC960
+ || dev->type == PED_DEVICE_CPQARRAY
+ || dev->type == PED_DEVICE_ATARAID
+@@ -2410,6 +2419,8 @@
+ char* vol_name = NULL;
+ char* dev_name = NULL;
+ char* params = NULL;
++ char* dm_uuid = NULL;
++ int uuid_len;
+
+ dev_name = _device_get_part_path (disk->dev, part->num);
+ if (!dev_name)
+@@ -2440,6 +2451,12 @@
+ dm_task_set_name (task, vol_name);
+ dm_task_add_target (task, 0, part->geom.length,
+ "linear", params);
++ if (_is_dmraid_device (disk->dev->path)) {
++ uuid_len = (strlen (vol_name) + 8);
++ dm_uuid = (char*) ped_malloc (uuid_len);
++ snprintf(dm_uuid, uuid_len, "DMRAID-%s", vol_name);
++ dm_task_set_uuid(task, dm_uuid);
++ }
+ rc = dm_task_run(task);
+ if (rc >= 0) {
+ //printf("0 %ld linear %s\n", part->geom.length, params);
+@@ -2447,6 +2464,8 @@
+ dm_task_destroy(task);
+ free(params);
+ free(vol_name);
++ if (dm_uuid)
++ ped_free(dm_uuid);
+ return 1;
+ } else {
+ _dm_remove_map_name(vol_name);
+@@ -2484,6 +2503,85 @@
+ }
+ return rc;
+ }
++
++/* Checks whether the given device-mapper device is part of a dmraid array,
++ * by checking for the string "DMRAID-" at the start of the UUID.
++ */
++static int
++_is_dmraid_device (char* devpath)
++{
++ struct dm_task* task = NULL;
++ int rc = 0;
++ const char* dmraid_uuid;
++ char* dm_name = NULL;
++
++ dm_name = strrchr (devpath, '/');
++ if (dm_name && *dm_name && *(++dm_name))
++ dm_name = strdup (dm_name);
++ else
++ dm_name = strdup (devpath);
++ if (!dm_name)
++ return 0;
++
++ task = dm_task_create(DM_DEVICE_DEPS);
++ if (!task)
++ return 0;
++
++ dm_task_set_name(task, dm_name);
++ rc = dm_task_run(task);
++ if (rc < 0) {
++ rc = 0;
++ goto err;
++ }
++ rc = 0;
++
++ dmraid_uuid = dm_task_get_uuid(task);
++ if (strncmp (dmraid_uuid, "DMRAID-", 7) == 0) {
++ rc = 1;
++ }
++
++err:
++ free (dm_name);
++ dm_task_destroy(task);
++ return rc;
++}
++
++/* Checks whether the given dmraid device node is a partition node, or the
++ * master node. This is done by checking the /sys/block directory for the node
++ * in question, to determine whether it is a slave of another device-mapper
++ * device. The node should be confirmed as a dmraid device by calling
++ * _is_dmraid_device first.
++ */
++static int
++_is_dmraid_major(char* devpath)
++{
++ DIR* sysfs_dir;
++ struct dirent* dent;
++ char dmraid_devpath [32];
++ struct stat st;
++
++ if (stat (devpath, &st) != 0)
++ return 0;
++
++ snprintf(dmraid_devpath, 32, "/sys/block/dm-%d/slaves", minor(st.st_rdev));
++
++ sysfs_dir = opendir (dmraid_devpath);
++ if (!sysfs_dir)
++ return 0;
++
++ while ((dent = readdir (sysfs_dir))) {
++ if (strcmp (dent->d_name, ".") == 0 ||
++ strcmp (dent->d_name, "..") == 0)
++ continue;
++
++ if (strncmp(dent->d_name, "dm-", 3) == 0)
++ return 0;
++ }
++ closedir (sysfs_dir);
++
++ return 1;
++}
++
+ #endif
+
+ static int
Reply to: