[Parted-commits] GNU Parted Official Repository: Changes to 'debian/master'

Otavio Salvador otavio at alioth.debian.org
Sat Sep 13 15:01:55 UTC 2008


 debian/changelog                    |    9 +
 debian/patches/00list               |    1 
 debian/patches/parted-dmraid.dpatch |  171 ++++++++++++++++++++++++++++++++++++
 3 files changed, 181 insertions(+)

New commits:
commit 4c35da9be3caf0b1c971bc01f9820ab4135cea7b
Author: Otavio Salvador <otavio at ossystems.com.br>
Date:   Sat Sep 13 11:51:14 2008 -0300

    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)
    
    This package has been prepared by Giuseppe Iuculano <giuseppe at iuculano.it>

diff --git a/debian/changelog b/debian/changelog
index f5a3985..ed1be0f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+parted (1.8.8.git.2008.03.24-10) unstable; urgency=low
+
+  * 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)
+
+ -- Giuseppe Iuculano <giuseppe at 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 --git a/debian/patches/00list b/debian/patches/00list
index 39acd74..977f09d 100644
--- a/debian/patches/00list
+++ b/debian/patches/00list
@@ -5,6 +5,7 @@ reiserfs-libname
 # 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
diff --git a/debian/patches/parted-dmraid.dpatch b/debian/patches/parted-dmraid.dpatch
new file mode 100644
index 0000000..23bcabc
--- /dev/null
+++ b/debian/patches/parted-dmraid.dpatch
@@ -0,0 +1,171 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## parted-dmraid.dpatch by Luke Yelavich <themuso at 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.
+
+ at 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 21:20:09.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)
+@@ -455,8 +459,16 @@
+                if (stat (buf, &st) != 0)
+                        continue;
+ 
+-               if (_is_dm_major(major(st.st_rdev)))
+-                       _ped_device_probe (buf);
++               if (_is_dm_major(major(st.st_rdev))) {
++                       if (_is_dmraid_device(buf)) {
++                               if (_is_dmraid_major(buf)) {
++                                       _ped_device_probe (buf);
++                               }
++                       } else {
++                               _ped_device_probe (buf);
++                       }
++               }
++
+        }
+        closedir (mapper_dir);
+ 
+@@ -2056,6 +2068,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 +2427,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 +2459,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 +2472,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 +2511,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



More information about the Parted-commits mailing list