Package: dmraid
Severity: wishlist
Version: 1.0.0.rc14-1
User: [EMAIL PROTECTED]
Usertags: origin-ubuntu ubuntu-patch hardy ubuntu

Since kernel 2.6.25, there has been some support for event handling and 
reporting in the kernel for dmraid. While other pieces are needed to fully make 
use of this mechanism, the attached patch makes sure dmraid properly works with 
the kernel dm driver's event handling. 

This patch is currently in the Ubuntu dmraid package, and therefore the 
attached patch is in dpatch format. It would be nice if this patch was in the 
Debian package, thereby reducing the delta between Ubuntu and Debian. 

Originally taken from Mandriva's dmraid package.

Luke
#! /bin/sh /usr/share/dpatch/dpatch-run
## 04_generate-uuids.dpatch by Luke Yelavich <[EMAIL PROTECTED]>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Generate UUIDs with DMRAID prefix.

@DPATCH@
diff -urNad dmraid-1.0.0.rc14-1ubuntu1~/1.0.0.rc14/lib/activate/devmapper.c 
dmraid-1.0.0.rc14-1ubuntu1/1.0.0.rc14/lib/activate/devmapper.c
--- dmraid-1.0.0.rc14-1ubuntu1~/1.0.0.rc14/lib/activate/devmapper.c     
2006-09-15 23:52:11.000000000 +1000
+++ dmraid-1.0.0.rc14-1ubuntu1/1.0.0.rc14/lib/activate/devmapper.c      
2008-07-08 14:10:06.000000000 +1000
@@ -21,6 +21,8 @@
 #include "internal.h"
 #include "devmapper.h"
 
+#include <linux/dm-ioctl.h>
+
 /* Make up a dm path. */
 char *mkdm_path(struct lib_context *lc, const char *name)
 {
@@ -147,24 +149,48 @@
        return handle_table(lc, NULL, table, get_target_list());
 }
 
+/* Build a UUID for a dmraid device 
+ * Return 1 for sucess; 0 for failure*/
+static int dmraid_uuid(struct lib_context *lc, struct raid_set *rs,
+                      char *uuid, uint uuid_len) {
+       int r;
+
+       /* Clear garbage data from uuid string */
+       memset(uuid, 0, uuid_len);
+
+       /* Create UUID string from subsystem prefix and RAID set name. */
+       r = snprintf(uuid, uuid_len, "DMRAID-%s", rs->name) < uuid_len;
+       return r < 0 ? 0 : (r < uuid_len);
+}
+
 /* Create a task, set its name and run it. */
 static int run_task(struct lib_context *lc, struct raid_set *rs,
                    char *table, int type)
 {
+       /* DM_UUID_LEN is defined in dm-ioctl.h as 129 characters;
+        * though not all 129 must be used (md uses just 16 from 
+        * a quick review of md.c. 
+        * We will be using: (len vol grp name)*/ 
+       char uuid[DM_UUID_LEN];
        int ret;
        struct dm_task *dmt;
 
        _init_dm();
-       ret = (dmt = dm_task_create(type)) && dm_task_set_name(dmt, rs->name);
+       ret = (dmt = dm_task_create(type)) &&
+             dm_task_set_name(dmt, rs->name);
        if (ret && table)
                ret = parse_table(lc, dmt, table);
 
-       if (ret)
-               ret = dm_task_run(dmt);
+       if (ret && 
+           DM_DEVICE_CREATE == type)
+               ret = dmraid_uuid(lc, rs, uuid, DM_UUID_LEN) &&
+                     dm_task_set_uuid(dmt, uuid) &&
+                     dm_task_run(dmt);
 
        _exit_dm(dmt);
        return ret;
 }
+       
 /* Create a mapped device. */
 int dm_create(struct lib_context *lc, struct raid_set *rs, char *table)
 {

Attachment: signature.asc
Description: Digital signature

Reply via email to