]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - util.c
fname_as_uuid: print uuids msb first
[thirdparty/mdadm.git] / util.c
diff --git a/util.c b/util.c
index b63251f4df166a29625981ecb5c021fca90b6459..4c0494236dfd6a97bf0d838d083346cf95c467ae 100644 (file)
--- a/util.c
+++ b/util.c
@@ -269,6 +269,27 @@ 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, char sep)
+{
+       int i, j;
+       int id;
+       char uuid[16];
+       char *c = buf;
+       strcpy(c, "UUID-");
+       c += strlen(c);
+       copy_uuid(uuid, info->uuid, st->ss->swapuuid);
+       for (i = 0; i < 4; i++) {
+               id = uuid[i];
+               if (i)
+                       *c++ = sep;
+               for (j = 3; j >= 0; j--) {
+                       sprintf(c,"%02x", (unsigned char) uuid[j+4*i]);
+                       c+= 2;
+               }
+       }
+       return buf;
+}
+
 #ifndef MDASSEMBLE
 int check_ext2(int fd, char *name)
 {