mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-21 06:01:23 +00:00
lib/uuid.c: introduce a few more generic helpers
There are new helpers in this patch: uuid_is_valid checks if a UUID is valid uuid_be_to_bin converts from string to binary (big endian) uuid_le_to_bin converts from string to binary (little endian) They will be used in future, i.e. in the following patches in the series. This also moves the indices arrays to lib/uuid.c to be shared accross modules. [andriy.shevchenko@linux.intel.com: fix typo] Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Matt Fleming <matt@codeblueprint.co.uk> Cc: Dmitry Kasatkin <dmitry.kasatkin@gmail.com> Cc: Mimi Zohar <zohar@linux.vnet.ibm.com> Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk> Cc: Arnd Bergmann <arnd@arndb.de> Cc: "Theodore Ts'o" <tytso@mit.edu> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Jens Axboe <axboe@kernel.dk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
8da4b8c48e
commit
2b1b0d6670
3 changed files with 82 additions and 5 deletions
|
@ -30,6 +30,7 @@
|
|||
#include <linux/ioport.h>
|
||||
#include <linux/dcache.h>
|
||||
#include <linux/cred.h>
|
||||
#include <linux/uuid.h>
|
||||
#include <net/addrconf.h>
|
||||
#ifdef CONFIG_BLOCK
|
||||
#include <linux/blkdev.h>
|
||||
|
@ -1304,19 +1305,17 @@ static noinline_for_stack
|
|||
char *uuid_string(char *buf, char *end, const u8 *addr,
|
||||
struct printf_spec spec, const char *fmt)
|
||||
{
|
||||
char uuid[sizeof("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")];
|
||||
char uuid[UUID_STRING_LEN + 1];
|
||||
char *p = uuid;
|
||||
int i;
|
||||
static const u8 be[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
|
||||
static const u8 le[16] = {3,2,1,0,5,4,7,6,8,9,10,11,12,13,14,15};
|
||||
const u8 *index = be;
|
||||
const u8 *index = uuid_be_index;
|
||||
bool uc = false;
|
||||
|
||||
switch (*(++fmt)) {
|
||||
case 'L':
|
||||
uc = true; /* fall-through */
|
||||
case 'l':
|
||||
index = le;
|
||||
index = uuid_le_index;
|
||||
break;
|
||||
case 'B':
|
||||
uc = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue