summaryrefslogtreecommitdiffstats
path: root/util.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2008-09-18 16:08:10 +1000
committerNeilBrown <neilb@suse.de>2008-09-18 16:08:10 +1000
commitd7288ddc3a06a0912f5f0a3f23ccca76a66ff332 (patch)
treecd9b208c1048a3b3c2e283379b9c2b4037eb08b3 /util.c
parent51006d85865f8fd1bb495bfc37fb83414117f149 (diff)
downloadmdadm-d7288ddc3a06a0912f5f0a3f23ccca76a66ff332.tar.gz
mdadm-d7288ddc3a06a0912f5f0a3f23ccca76a66ff332.tar.xz
mdadm-d7288ddc3a06a0912f5f0a3f23ccca76a66ff332.zip
Use uuid as /dev name when assembling array of uncertain origin.
If we aren't sure that the array belongs to 'this' host, use the uuid to choose a name to avoid any conflict.
Diffstat (limited to 'util.c')
-rw-r--r--util.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/util.c b/util.c
index b63251f..b65d2ad 100644
--- a/util.c
+++ b/util.c
@@ -269,6 +269,25 @@ void copy_uuid(void *a, int b[4], int swapuuid)
memcpy(a, b, 16);
}
+char *fname_from_uuid(struct supertype *st, struct mdinfo *info, char *buf)
+{
+ int i;
+ char uuid[16];
+ char *c = buf;
+ strcpy(c, "UUID-");
+ c += strlen(c);
+ copy_uuid(uuid, info->uuid, st->ss->swapuuid);
+ for (i=0; i<16; i++) {
+ if (i && (i&3)==0) {
+ strcpy(c, "-");
+ c++;
+ }
+ sprintf(c,"%02x", (unsigned char)uuid[i]);
+ c+= 2;
+ }
+ return buf;
+}
+
#ifndef MDASSEMBLE
int check_ext2(int fd, char *name)
{