Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

uuid: rename uuid types

Our "little endian" UUID really is a Wintel GUID, so rename it and its
helpers such (guid_t). The big endian UUID is the only true one, so
give it the name uuid_t. The uuid_le and uuid_be names are retained for
now, but will hopefully go away soon. The exception to that are the _cmp
helpers that will be replaced by better primitives ASAP and thus don't
get the new names.

Also the _to_bin helpers are named to match the better named uuid_parse
routine in userspace.

Also remove the existing typedef in XFS that's now been superceeded by
the generic type name.

Signed-off-by: Christoph Hellwig <hch@lst.de>
[andy: also update the UUID_LE/UUID_BE macros including fallout]
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Signed-off-by: Christoph Hellwig <hch@lst.de>

+73 -62
-2
fs/xfs/xfs_linux.h
··· 39 39 typedef __u32 xfs_dev_t; 40 40 typedef __u32 xfs_nlink_t; 41 41 42 - typedef uuid_be uuid_t; 43 - 44 42 #include "xfs_types.h" 45 43 46 44 #include "kmem.h"
+32 -23
include/linux/uuid.h
··· 20 20 21 21 typedef struct { 22 22 __u8 b[16]; 23 - } uuid_be; 23 + } uuid_t; 24 24 25 - #define UUID_BE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \ 26 - ((uuid_be) \ 25 + #define UUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \ 26 + ((uuid_t) \ 27 27 {{ ((a) >> 24) & 0xff, ((a) >> 16) & 0xff, ((a) >> 8) & 0xff, (a) & 0xff, \ 28 28 ((b) >> 8) & 0xff, (b) & 0xff, \ 29 29 ((c) >> 8) & 0xff, (c) & 0xff, \ 30 30 (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }}) 31 - 32 - #define NULL_UUID_BE \ 33 - UUID_BE(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, \ 34 - 0x00, 0x00, 0x00, 0x00) 35 31 36 32 /* 37 33 * The length of a UUID string ("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") ··· 35 39 */ 36 40 #define UUID_STRING_LEN 36 37 41 38 - static inline int uuid_le_cmp(const uuid_le u1, const uuid_le u2) 39 - { 40 - return memcmp(&u1, &u2, sizeof(uuid_le)); 41 - } 42 - 43 - static inline int uuid_be_cmp(const uuid_be u1, const uuid_be u2) 44 - { 45 - return memcmp(&u1, &u2, sizeof(uuid_be)); 46 - } 47 - 48 42 void generate_random_uuid(unsigned char uuid[16]); 49 43 50 - extern void uuid_le_gen(uuid_le *u); 51 - extern void uuid_be_gen(uuid_be *u); 44 + extern void guid_gen(guid_t *u); 45 + extern void uuid_gen(uuid_t *u); 52 46 53 47 bool __must_check uuid_is_valid(const char *uuid); 54 48 55 - extern const u8 uuid_le_index[16]; 56 - extern const u8 uuid_be_index[16]; 49 + extern const u8 guid_index[16]; 50 + extern const u8 uuid_index[16]; 57 51 58 - int uuid_le_to_bin(const char *uuid, uuid_le *u); 59 - int uuid_be_to_bin(const char *uuid, uuid_be *u); 52 + int guid_parse(const char *uuid, guid_t *u); 53 + int uuid_parse(const char *uuid, uuid_t *u); 54 + 55 + /* backwards compatibility, don't use in new code */ 56 + typedef uuid_t uuid_be; 57 + #define UUID_BE(a, _b, c, d0, d1, d2, d3, d4, d5, d6, d7) \ 58 + UUID_INIT(a, _b, c, d0, d1, d2, d3, d4, d5, d6, d7) 59 + #define NULL_UUID_BE \ 60 + UUID_BE(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, \ 61 + 0x00, 0x00, 0x00, 0x00) 62 + 63 + #define uuid_le_gen(u) guid_gen(u) 64 + #define uuid_be_gen(u) uuid_gen(u) 65 + #define uuid_le_to_bin(guid, u) guid_parse(guid, u) 66 + #define uuid_be_to_bin(uuid, u) uuid_parse(uuid, u) 67 + 68 + static inline int uuid_le_cmp(const guid_t u1, const guid_t u2) 69 + { 70 + return memcmp(&u1, &u2, sizeof(guid_t)); 71 + } 72 + 73 + static inline int uuid_be_cmp(const uuid_t u1, const uuid_t u2) 74 + { 75 + return memcmp(&u1, &u2, sizeof(uuid_t)); 76 + } 60 77 61 78 #endif
+8 -4
include/uapi/linux/uuid.h
··· 22 22 23 23 typedef struct { 24 24 __u8 b[16]; 25 - } uuid_le; 25 + } guid_t; 26 26 27 - #define UUID_LE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \ 28 - ((uuid_le) \ 27 + #define GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \ 28 + ((guid_t) \ 29 29 {{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \ 30 30 (b) & 0xff, ((b) >> 8) & 0xff, \ 31 31 (c) & 0xff, ((c) >> 8) & 0xff, \ 32 32 (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }}) 33 33 34 + /* backwards compatibility, don't use in new code */ 35 + typedef guid_t uuid_le; 36 + #define UUID_LE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \ 37 + GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) 34 38 #define NULL_UUID_LE \ 35 39 UUID_LE(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, \ 36 - 0x00, 0x00, 0x00, 0x00) 40 + 0x00, 0x00, 0x00, 0x00) 37 41 38 42 #endif /* _UAPI_LINUX_UUID_H_ */
+16 -16
lib/test_uuid.c
··· 11 11 12 12 struct test_uuid_data { 13 13 const char *uuid; 14 - uuid_le le; 15 - uuid_be be; 14 + guid_t le; 15 + uuid_t be; 16 16 }; 17 17 18 18 static const struct test_uuid_data test_uuid_test_data[] = { 19 19 { 20 20 .uuid = "c33f4995-3701-450e-9fbf-206a2e98e576", 21 - .le = UUID_LE(0xc33f4995, 0x3701, 0x450e, 0x9f, 0xbf, 0x20, 0x6a, 0x2e, 0x98, 0xe5, 0x76), 22 - .be = UUID_BE(0xc33f4995, 0x3701, 0x450e, 0x9f, 0xbf, 0x20, 0x6a, 0x2e, 0x98, 0xe5, 0x76), 21 + .le = GUID_INIT(0xc33f4995, 0x3701, 0x450e, 0x9f, 0xbf, 0x20, 0x6a, 0x2e, 0x98, 0xe5, 0x76), 22 + .be = UUID_INIT(0xc33f4995, 0x3701, 0x450e, 0x9f, 0xbf, 0x20, 0x6a, 0x2e, 0x98, 0xe5, 0x76), 23 23 }, 24 24 { 25 25 .uuid = "64b4371c-77c1-48f9-8221-29f054fc023b", 26 - .le = UUID_LE(0x64b4371c, 0x77c1, 0x48f9, 0x82, 0x21, 0x29, 0xf0, 0x54, 0xfc, 0x02, 0x3b), 27 - .be = UUID_BE(0x64b4371c, 0x77c1, 0x48f9, 0x82, 0x21, 0x29, 0xf0, 0x54, 0xfc, 0x02, 0x3b), 26 + .le = GUID_INIT(0x64b4371c, 0x77c1, 0x48f9, 0x82, 0x21, 0x29, 0xf0, 0x54, 0xfc, 0x02, 0x3b), 27 + .be = UUID_INIT(0x64b4371c, 0x77c1, 0x48f9, 0x82, 0x21, 0x29, 0xf0, 0x54, 0xfc, 0x02, 0x3b), 28 28 }, 29 29 { 30 30 .uuid = "0cb4ddff-a545-4401-9d06-688af53e7f84", 31 - .le = UUID_LE(0x0cb4ddff, 0xa545, 0x4401, 0x9d, 0x06, 0x68, 0x8a, 0xf5, 0x3e, 0x7f, 0x84), 32 - .be = UUID_BE(0x0cb4ddff, 0xa545, 0x4401, 0x9d, 0x06, 0x68, 0x8a, 0xf5, 0x3e, 0x7f, 0x84), 31 + .le = GUID_INIT(0x0cb4ddff, 0xa545, 0x4401, 0x9d, 0x06, 0x68, 0x8a, 0xf5, 0x3e, 0x7f, 0x84), 32 + .be = UUID_INIT(0x0cb4ddff, 0xa545, 0x4401, 0x9d, 0x06, 0x68, 0x8a, 0xf5, 0x3e, 0x7f, 0x84), 33 33 }, 34 34 }; 35 35 ··· 61 61 62 62 static void __init test_uuid_test(const struct test_uuid_data *data) 63 63 { 64 - uuid_le le; 65 - uuid_be be; 64 + guid_t le; 65 + uuid_t be; 66 66 char buf[48]; 67 67 68 68 /* LE */ 69 69 total_tests++; 70 - if (uuid_le_to_bin(data->uuid, &le)) 70 + if (guid_parse(data->uuid, &le)) 71 71 test_uuid_failed("conversion", false, false, data->uuid, NULL); 72 72 73 73 total_tests++; ··· 78 78 79 79 /* BE */ 80 80 total_tests++; 81 - if (uuid_be_to_bin(data->uuid, &be)) 81 + if (uuid_parse(data->uuid, &be)) 82 82 test_uuid_failed("conversion", false, true, data->uuid, NULL); 83 83 84 84 total_tests++; ··· 90 90 91 91 static void __init test_uuid_wrong(const char *data) 92 92 { 93 - uuid_le le; 94 - uuid_be be; 93 + guid_t le; 94 + uuid_t be; 95 95 96 96 /* LE */ 97 97 total_tests++; 98 - if (!uuid_le_to_bin(data, &le)) 98 + if (!guid_parse(data, &le)) 99 99 test_uuid_failed("negative", true, false, data, NULL); 100 100 101 101 /* BE */ 102 102 total_tests++; 103 - if (!uuid_be_to_bin(data, &be)) 103 + if (!uuid_parse(data, &be)) 104 104 test_uuid_failed("negative", true, true, data, NULL); 105 105 } 106 106
+15 -15
lib/uuid.c
··· 21 21 #include <linux/uuid.h> 22 22 #include <linux/random.h> 23 23 24 - const u8 uuid_le_index[16] = {3,2,1,0,5,4,7,6,8,9,10,11,12,13,14,15}; 25 - EXPORT_SYMBOL(uuid_le_index); 26 - const u8 uuid_be_index[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; 27 - EXPORT_SYMBOL(uuid_be_index); 24 + const u8 guid_index[16] = {3,2,1,0,5,4,7,6,8,9,10,11,12,13,14,15}; 25 + EXPORT_SYMBOL(guid_index); 26 + const u8 uuid_index[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; 27 + EXPORT_SYMBOL(uuid_index); 28 28 29 29 /*************************************************************** 30 30 * Random UUID interface ··· 53 53 b[8] = (b[8] & 0x3F) | 0x80; 54 54 } 55 55 56 - void uuid_le_gen(uuid_le *lu) 56 + void guid_gen(guid_t *lu) 57 57 { 58 58 __uuid_gen_common(lu->b); 59 59 /* version 4 : random generation */ 60 60 lu->b[7] = (lu->b[7] & 0x0F) | 0x40; 61 61 } 62 - EXPORT_SYMBOL_GPL(uuid_le_gen); 62 + EXPORT_SYMBOL_GPL(guid_gen); 63 63 64 - void uuid_be_gen(uuid_be *bu) 64 + void uuid_gen(uuid_t *bu) 65 65 { 66 66 __uuid_gen_common(bu->b); 67 67 /* version 4 : random generation */ 68 68 bu->b[6] = (bu->b[6] & 0x0F) | 0x40; 69 69 } 70 - EXPORT_SYMBOL_GPL(uuid_be_gen); 70 + EXPORT_SYMBOL_GPL(uuid_gen); 71 71 72 72 /** 73 73 * uuid_is_valid - checks if UUID string valid ··· 97 97 } 98 98 EXPORT_SYMBOL(uuid_is_valid); 99 99 100 - static int __uuid_to_bin(const char *uuid, __u8 b[16], const u8 ei[16]) 100 + static int __uuid_parse(const char *uuid, __u8 b[16], const u8 ei[16]) 101 101 { 102 102 static const u8 si[16] = {0,2,4,6,9,11,14,16,19,21,24,26,28,30,32,34}; 103 103 unsigned int i; ··· 115 115 return 0; 116 116 } 117 117 118 - int uuid_le_to_bin(const char *uuid, uuid_le *u) 118 + int guid_parse(const char *uuid, guid_t *u) 119 119 { 120 - return __uuid_to_bin(uuid, u->b, uuid_le_index); 120 + return __uuid_parse(uuid, u->b, guid_index); 121 121 } 122 - EXPORT_SYMBOL(uuid_le_to_bin); 122 + EXPORT_SYMBOL(guid_parse); 123 123 124 - int uuid_be_to_bin(const char *uuid, uuid_be *u) 124 + int uuid_parse(const char *uuid, uuid_t *u) 125 125 { 126 - return __uuid_to_bin(uuid, u->b, uuid_be_index); 126 + return __uuid_parse(uuid, u->b, uuid_index); 127 127 } 128 - EXPORT_SYMBOL(uuid_be_to_bin); 128 + EXPORT_SYMBOL(uuid_parse);
+2 -2
lib/vsprintf.c
··· 1308 1308 char uuid[UUID_STRING_LEN + 1]; 1309 1309 char *p = uuid; 1310 1310 int i; 1311 - const u8 *index = uuid_be_index; 1311 + const u8 *index = uuid_index; 1312 1312 bool uc = false; 1313 1313 1314 1314 switch (*(++fmt)) { 1315 1315 case 'L': 1316 1316 uc = true; /* fall-through */ 1317 1317 case 'l': 1318 - index = uuid_le_index; 1318 + index = guid_index; 1319 1319 break; 1320 1320 case 'B': 1321 1321 uc = true;