~psusi/ubuntu/precise/dmraid/fix-gpt

« back to all changes in this revision

Viewing changes to debian/patches/04_generate-uuids.dpatch

  • Committer: Bazaar Package Importer
  • Author(s): Giuseppe Iuculano, 6af052c
  • Date: 2009-03-25 22:34:59 UTC
  • mfrom: (2.1.9 sid)
  • mto: (2.4.1 squeeze)
  • mto: This revision was merged to the branch mainline in revision 39.
  • Revision ID: james.westby@ubuntu.com-20090325223459-y54f0rmxem7htn6r
Tags: 1.0.0.rc15-6
[6af052c] Remove 15_isw_incorrect_status_fix.patch, it causes a
segfault. (Closes: #521104)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /bin/sh /usr/share/dpatch/dpatch-run
2
 
## 04_generate-uuids.dpatch by Luke Yelavich <themuso@ubuntu.com>
3
 
##
4
 
## All lines beginning with `## DP:' are a description of the patch.
5
 
## DP: Generate UUIDs with DMRAID prefix.
6
 
 
7
 
@DPATCH@
8
 
diff -urNad dmraid.git~/1.0.0.rc14/lib/activate/devmapper.c dmraid.git/1.0.0.rc14/lib/activate/devmapper.c
9
 
--- dmraid.git~/1.0.0.rc14/lib/activate/devmapper.c     2009-01-23 16:48:44.000000000 +0100
10
 
+++ dmraid.git/1.0.0.rc14/lib/activate/devmapper.c      2009-01-23 18:08:44.000000000 +0100
11
 
@@ -21,6 +21,8 @@
12
 
 #include "internal.h"
13
 
 #include "devmapper.h"
14
 
 
15
 
+#include <linux/dm-ioctl.h>
16
 
+
17
 
 /* Make up a dm path. */
18
 
 char *mkdm_path(struct lib_context *lc, const char *name)
19
 
 {
20
 
@@ -147,24 +149,49 @@
21
 
        return handle_table(lc, NULL, table, get_target_list());
22
 
 }
23
 
 
24
 
+/* Build a UUID for a dmraid device 
25
 
+ * Return 1 for sucess; 0 for failure*/
26
 
+static int dmraid_uuid(struct lib_context *lc, struct raid_set *rs,
27
 
+                      char *uuid, uint uuid_len) {
28
 
+       int r;
29
 
+
30
 
+       /* Clear garbage data from uuid string */
31
 
+       memset(uuid, 0, uuid_len);
32
 
+
33
 
+       /* Create UUID string from subsystem prefix and RAID set name. */
34
 
+       r = snprintf(uuid, uuid_len, "DMRAID-%s", rs->name) < uuid_len;
35
 
+       return r < 0 ? 0 : (r < uuid_len);
36
 
+}
37
 
+
38
 
 /* Create a task, set its name and run it. */
39
 
 static int run_task(struct lib_context *lc, struct raid_set *rs,
40
 
                    char *table, int type)
41
 
 {
42
 
+       /* DM_UUID_LEN is defined in dm-ioctl.h as 129 characters;
43
 
+        * though not all 129 must be used (md uses just 16 from 
44
 
+        * a quick review of md.c. 
45
 
+        * We will be using: (len vol grp name)*/ 
46
 
+       char uuid[DM_UUID_LEN];
47
 
        int ret;
48
 
        struct dm_task *dmt;
49
 
 
50
 
        _init_dm();
51
 
-       ret = (dmt = dm_task_create(type)) && dm_task_set_name(dmt, rs->name);
52
 
+       ret = (dmt = dm_task_create(type)) &&
53
 
+             dm_task_set_name(dmt, rs->name);
54
 
        if (ret && table)
55
 
                ret = parse_table(lc, dmt, table);
56
 
 
57
 
-       if (ret)
58
 
-               ret = dm_task_run(dmt);
59
 
+       if (ret) { 
60
 
+           if (DM_DEVICE_CREATE == type &&
61
 
+               dmraid_uuid(lc, rs, uuid, DM_UUID_LEN))
62
 
+                       dm_task_set_uuid(dmt, uuid);
63
 
+           ret = dm_task_run(dmt);
64
 
+       }
65
 
 
66
 
        _exit_dm(dmt);
67
 
        return ret;
68
 
 }
69
 
+       
70
 
 /* Create a mapped device. */
71
 
 int dm_create(struct lib_context *lc, struct raid_set *rs, char *table)
72
 
 {