[PATCH] Add uuid to dmraid tables

Hannes Reinecke <[email protected]>
Newsgroups gmane.linux.ataraid
Message-ID <[email protected]>
Hi Heinz,

by convention most programs add a UUID to the device-mapper table
they/ve created. This allows of the intended usage of the table.

This patch adds the generation of UUIDs to dmraid. Tables UUIDs are
prefixed with 'dmraid-'.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke			[email protected]
SuSE Linux Products GmbH		S390 & zSeries
Maxfeldstraße 5				+49 911 74053 688
90409 Nürnberg				http://www.suse.de

_______________________________________________
Ataraid-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/ataraid-list
dmraid_add_uuid.patch (text/x-patch, 1.4 KB)
diff -pur 1.0.0.rc11.orig/lib/activate/devmapper.c 1.0.0.rc11/lib/activate/devmapper.c
--- 1.0.0.rc11.orig/lib/activate/devmapper.c	2006-03-29 15:18:43.000000000 +0200
+++ 1.0.0.rc11/lib/activate/devmapper.c	2006-08-28 12:55:32.000000000 +0200
@@ -153,12 +153,20 @@ int dm_create(struct lib_context *lc, st
 {
 	int ret = 0;
 	struct dm_task *dmt;
+	char *uuid;
+
+	/* Generate UUID */
+	uuid = malloc(strlen(rs->name) + UUID_PREFIX_LEN + 1);
+	if (!uuid) return 1;
+
+	sprintf(uuid,UUID_PREFIX "%s",rs->name);
 
 	_init_dm();
 
 	/* Create <dev_name> */
 	ret = (dmt = dm_task_create(DM_DEVICE_CREATE)) &&
 	       dm_task_set_name(dmt, rs->name) &&
+	       dm_task_set_uuid(dmt, uuid) &&
 	       parse_table(lc, dmt, table) &&
 	       dm_task_run(dmt);
 
@@ -171,6 +179,8 @@ int dm_create(struct lib_context *lc, st
 
 	_exit_dm(dmt);
 
+	free(uuid);
+
 	return ret;
 }
 
diff -pur 1.0.0.rc11.orig/lib/activate/devmapper.h 1.0.0.rc11/lib/activate/devmapper.h
--- 1.0.0.rc11.orig/lib/activate/devmapper.h	2005-05-23 14:39:55.000000000 +0200
+++ 1.0.0.rc11/lib/activate/devmapper.h	2006-08-28 12:55:01.000000000 +0200
@@ -8,6 +8,9 @@
 #ifndef _DEVMAPPER_H_
 #define _DEVMAPPER_H
 
+#define UUID_PREFIX "dmraid-"
+#define UUID_PREFIX_LEN 7
+
 char *mkdm_path(struct lib_context *lc, const char *name);
 int dm_create(struct lib_context *lc, struct raid_set *rs, char *table);
 int dm_remove(struct lib_context *lc, struct raid_set *rs);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.