1 /* vi: set sw=4 ts=4: */
3 * uuid.c -- utility routines for manipulating UUID's.
8 #include "../ext2fs/ext2_types.h"
15 __u16 time_hi_and_version;
20 /* Returns 1 if the uuid is the NULL uuid */
21 int e2p_is_null_uuid(void *uu)
26 for (i=0, cp = uu; i < 16; i++)
32 static void e2p_unpack_uuid(void *in, struct uuid *uu)
38 tmp = (tmp << 8) | *ptr++;
39 tmp = (tmp << 8) | *ptr++;
40 tmp = (tmp << 8) | *ptr++;
44 tmp = (tmp << 8) | *ptr++;
48 tmp = (tmp << 8) | *ptr++;
49 uu->time_hi_and_version = tmp;
52 tmp = (tmp << 8) | *ptr++;
55 memcpy(uu->node, ptr, 6);
58 void e2p_uuid_to_str(void *uu, char *out)
62 e2p_unpack_uuid(uu, &uuid);
64 "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
65 uuid.time_low, uuid.time_mid, uuid.time_hi_and_version,
66 uuid.clock_seq >> 8, uuid.clock_seq & 0xFF,
67 uuid.node[0], uuid.node[1], uuid.node[2],
68 uuid.node[3], uuid.node[4], uuid.node[5]);
71 const char *e2p_uuid2str(void *uu)
74 if (e2p_is_null_uuid(uu))
76 e2p_uuid_to_str(uu, buf);