2 * Public include file for the UUID library
4 * Copyright (C) 2007 Cluster File System
7 #define DEBUG_SUBSYSTEM S_CLASS
10 # include <liblustre.h>
12 # include <libcfs/kp30.h>
15 #include <obd_support.h>
16 #include <obd_class.h>
19 static inline __u32 consume(int nob, __u8 **ptr)
23 LASSERT(nob <= sizeof value);
25 for (value = 0; nob > 0; --nob)
26 value = (value << 8) | *((*ptr)++);
30 #define CONSUME(val, ptr) (val) = consume(sizeof(val), (ptr))
32 static void uuid_unpack(class_uuid_t in, __u16 *uu, int nr)
36 LASSERT(nr * sizeof *uu == sizeof(class_uuid_t));
39 CONSUME(uu[nr], &ptr);
42 void class_uuid_unparse(class_uuid_t uu, struct obd_uuid *out)
44 /* uu as an array of __u16's */
45 __u16 uuid[sizeof(class_uuid_t) / sizeof(__u16)];
47 CLASSERT(ARRAY_SIZE(uuid) == 8);
49 uuid_unpack(uu, uuid, ARRAY_SIZE(uuid));
50 sprintf(out->uuid, "%04x%04x-%04x-%04x-%04x-%04x%04x%04x",
51 uuid[0], uuid[1], uuid[2], uuid[3],
52 uuid[4], uuid[5], uuid[6], uuid[7]);