31 # include <linux/uuid.h> 33 # include <uuid/uuid.h> 36 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_LIB 47 generate_random_uuid((
unsigned char *)
u);
49 uuid_generate((
unsigned char *)
u);
64 for (
i = 0;
i < len; ++
i) {
86 if (
parse_hex(&str[0], 8, &h1) < 0 || str[8] !=
'-' ||
87 parse_hex(&str[9], 4, &h2) < 0 || str[13] !=
'-' ||
88 parse_hex(&str[14], 4, &h3) < 0 || str[18] !=
'-' ||
89 parse_hex(&str[19], 4, &h4) < 0 || str[23] !=
'-' ||
90 parse_hex(&str[24], 12, &h5) < 0 || str[36] !=
'\0') {
95 parse_hex(&str[20], 12, &h5) < 0 || str[32] !=
'\0') {
100 val->u_hi = h1 << 32 | h2 << 16 | h3;
101 val->u_lo = h4 << 48 | h5;
108 char *
buf,
size_t len)
110 static const char *
fmt =
"%08x-%04x-%04x-%04x-%012lx";
118 h1 =
val->u_hi >> 32;
119 h2 = (
val->u_hi >> 16) & 0xffff;
120 h3 =
val->u_hi & 0xffff;
121 h4 =
val->u_lo >> 48;
122 h5 =
val->u_lo & 0xffffffffffff;
123 sprintf(
buf,
fmt, h1, h2, h3, h4, h5);
151 #undef M0_TRACE_SUBSYSTEM struct m0_uint128 uuid[1000]
M0_INTERNAL void m0_uuid_generate(struct m0_uint128 *u)
#define M0_LOG(level,...)
M0_BASSERT(sizeof(struct m0_uint128)==sizeof(char[16]))
M0_INTERNAL int m0_uuid_parse(const char *str, struct m0_uint128 *val)
static int parse_hex(const char *str, int len, uint64_t *val)
return M0_ERR(-EOPNOTSUPP)
int m0_node_uuid_string_get(char buf[M0_UUID_STRLEN+1])
uint64_t m0_strtou64(const char *str, char **endptr, int base)
char * fmt(const char *format,...) __attribute__((format(printf
M0_INTERNAL void m0_uuid_format(const struct m0_uint128 *val, char *buf, size_t len)
int m0_node_uuid_init(void)
M0_INTERNAL struct m0_uint128 m0_node_uuid