summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2008-10-01 18:50:43 -0700
committerDan Williams <dan.j.williams@intel.com>2008-10-15 14:26:51 -0700
commit9968e376a17dd6d815473f05843b1f257b2babd5 (patch)
tree00cc0d56033b168f575ccfb15f5ebd9e6accb010 /util.c
parent695154b2e7f975527f8f3f9591f0a21474bfe1b1 (diff)
fname_as_uuid: print uuids msb first
The sha1 routines store the uuids in little endian byte-order, so always print from msb to lsb. This allows imsm containers to be assembled with -As. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'util.c')
-rw-r--r--util.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/util.c b/util.c
index 653796f1..4c049423 100644
--- a/util.c
+++ b/util.c
@@ -271,17 +271,21 @@ void copy_uuid(void *a, int b[4], int swapuuid)
char *fname_from_uuid(struct supertype *st, struct mdinfo *info, char *buf, char sep)
{
- int i;
+ 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<16; i++) {
- if (i && (i&3)==0)
+ for (i = 0; i < 4; i++) {
+ id = uuid[i];
+ if (i)
*c++ = sep;
- sprintf(c,"%02x", (unsigned char)uuid[i]);
- c+= 2;
+ for (j = 3; j >= 0; j--) {
+ sprintf(c,"%02x", (unsigned char) uuid[j+4*i]);
+ c+= 2;
+ }
}
return buf;
}