uuid.c (c25141062a82ae8bddced1b3ce2b57a1c0efabe0) | uuid.c (d063623b6ae7c326d21a2713dd38cab15d794c1c) |
---|---|
1/* 2 * Unified UUID/GUID definition 3 * 4 * Copyright (C) 2009, 2016 Intel Corp. 5 * Huang Ying <ying.huang@intel.com> 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License version --- 15 unchanged lines hidden (view full) --- 24const guid_t guid_null; 25EXPORT_SYMBOL(guid_null); 26const uuid_t uuid_null; 27EXPORT_SYMBOL(uuid_null); 28 29const u8 guid_index[16] = {3,2,1,0,5,4,7,6,8,9,10,11,12,13,14,15}; 30const u8 uuid_index[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; 31 | 1/* 2 * Unified UUID/GUID definition 3 * 4 * Copyright (C) 2009, 2016 Intel Corp. 5 * Huang Ying <ying.huang@intel.com> 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License version --- 15 unchanged lines hidden (view full) --- 24const guid_t guid_null; 25EXPORT_SYMBOL(guid_null); 26const uuid_t uuid_null; 27EXPORT_SYMBOL(uuid_null); 28 29const u8 guid_index[16] = {3,2,1,0,5,4,7,6,8,9,10,11,12,13,14,15}; 30const u8 uuid_index[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; 31 |
32/*************************************************************** | 32/** 33 * generate_random_uuid - generate a random UUID 34 * @uuid: where to put the generated UUID 35 * |
33 * Random UUID interface 34 * | 36 * Random UUID interface 37 * |
35 * Used here for a Boot ID, but can be useful for other kernel 36 * drivers. 37 ***************************************************************/ 38 39/* 40 * Generate random UUID | 38 * Used to create a Boot ID or a filesystem UUID/GUID, but can be 39 * useful for other kernel drivers. |
41 */ 42void generate_random_uuid(unsigned char uuid[16]) 43{ 44 get_random_bytes(uuid, 16); 45 /* Set UUID version to 4 --- truly random generation */ 46 uuid[6] = (uuid[6] & 0x0F) | 0x40; 47 /* Set the UUID variant to DCE */ 48 uuid[8] = (uuid[8] & 0x3F) | 0x80; --- 19 unchanged lines hidden (view full) --- 68{ 69 __uuid_gen_common(bu->b); 70 /* version 4 : random generation */ 71 bu->b[6] = (bu->b[6] & 0x0F) | 0x40; 72} 73EXPORT_SYMBOL_GPL(uuid_gen); 74 75/** | 40 */ 41void generate_random_uuid(unsigned char uuid[16]) 42{ 43 get_random_bytes(uuid, 16); 44 /* Set UUID version to 4 --- truly random generation */ 45 uuid[6] = (uuid[6] & 0x0F) | 0x40; 46 /* Set the UUID variant to DCE */ 47 uuid[8] = (uuid[8] & 0x3F) | 0x80; --- 19 unchanged lines hidden (view full) --- 67{ 68 __uuid_gen_common(bu->b); 69 /* version 4 : random generation */ 70 bu->b[6] = (bu->b[6] & 0x0F) | 0x40; 71} 72EXPORT_SYMBOL_GPL(uuid_gen); 73 74/** |
76 * uuid_is_valid - checks if UUID string valid 77 * @uuid: UUID string to check 78 * 79 * Description: 80 * It checks if the UUID string is following the format: 81 * xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 82 * where x is a hex digit. 83 * 84 * Return: true if input is valid UUID string. 85 */ | 75 * uuid_is_valid - checks if a UUID string is valid 76 * @uuid: UUID string to check 77 * 78 * Description: 79 * It checks if the UUID string is following the format: 80 * xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 81 * 82 * where x is a hex digit. 83 * 84 * Return: true if input is valid UUID string. 85 */ |
86bool uuid_is_valid(const char *uuid) 87{ 88 unsigned int i; 89 90 for (i = 0; i < UUID_STRING_LEN; i++) { 91 if (i == 8 || i == 13 || i == 18 || i == 23) { 92 if (uuid[i] != '-') 93 return false; --- 38 unchanged lines hidden --- | 86bool uuid_is_valid(const char *uuid) 87{ 88 unsigned int i; 89 90 for (i = 0; i < UUID_STRING_LEN; i++) { 91 if (i == 8 || i == 13 || i == 18 || i == 23) { 92 if (uuid[i] != '-') 93 return false; --- 38 unchanged lines hidden --- |