]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libuuid: add helper to set version and variant in uuid_t
authorThomas Weißschuh <thomas@t-8ch.de>
Tue, 21 May 2024 16:41:59 +0000 (18:41 +0200)
committerThomas Weißschuh <thomas@t-8ch.de>
Tue, 21 May 2024 16:41:59 +0000 (18:41 +0200)
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
libuuid/src/gen_uuid.c

index e80e371c47371b24c55de36475db77148702852e..24b4b0ddeea3c2e4febfcdbf15c820d4e1f511ae 100644 (file)
@@ -576,6 +576,13 @@ int __uuid_generate_time_cont(uuid_t out, int *num, uint32_t cont_offset)
 #define CS_MAX         (1<<18)
 #define CS_FACTOR      2
 
+static void __uuid_set_variant_and_version(uuid_t uuid, int version)
+{
+       uuid[6] = (uuid[6] & UUID_TYPE_MASK) | version << UUID_TYPE_SHIFT;
+       /* only DCE is supported */
+       uuid[8] = (uuid[10] & 0x3F) | 0x80;
+}
+
 /*
  * Generate time-based UUID and store it to @out
  *