1
#! /bin/sh /usr/share/dpatch/dpatch-run
2
## 04_generate-uuids.dpatch by Luke Yelavich <themuso@ubuntu.com>
4
## All lines beginning with `## DP:' are a description of the patch.
5
## DP: Generate UUIDs with DMRAID prefix.
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
13
#include "devmapper.h"
15
+#include <linux/dm-ioctl.h>
17
/* Make up a dm path. */
18
char *mkdm_path(struct lib_context *lc, const char *name)
21
return handle_table(lc, NULL, table, get_target_list());
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) {
30
+ /* Clear garbage data from uuid string */
31
+ memset(uuid, 0, uuid_len);
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);
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)
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];
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);
55
ret = parse_table(lc, dmt, table);
58
- ret = dm_task_run(dmt);
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);
70
/* Create a mapped device. */
71
int dm_create(struct lib_context *lc, struct raid_set *rs, char *table)