2 * uuid.c -- utility routines for manipulating UUID's.
7 #include <ext2fs/ext2_types.h>
14 __u16 time_hi_and_version;
19 /* Returns 1 if the uuid is the NULL uuid */
20 int e2p_is_null_uuid(void *uu)
25 for (i=0, cp = uu; i < 16; i++)
31 static void e2p_unpack_uuid(void *in, struct uuid *uu)
37 tmp = (tmp << 8) | *ptr++;
38 tmp = (tmp << 8) | *ptr++;
39 tmp = (tmp << 8) | *ptr++;
43 tmp = (tmp << 8) | *ptr++;
47 tmp = (tmp << 8) | *ptr++;
48 uu->time_hi_and_version = tmp;
51 tmp = (tmp << 8) | *ptr++;
54 memcpy(uu->node, ptr, 6);
57 void e2p_uuid_to_str(void *uu, char *out)
61 e2p_unpack_uuid(uu, &uuid);
63 "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
64 uuid.time_low, uuid.time_mid, uuid.time_hi_and_version,
65 uuid.clock_seq >> 8, uuid.clock_seq & 0xFF,
66 uuid.node[0], uuid.node[1], uuid.node[2],
67 uuid.node[3], uuid.node[4], uuid.node[5]);
70 const char *e2p_uuid2str(void *uu)
74 if (e2p_is_null_uuid(uu))
76 e2p_uuid_to_str(uu, buf);