]>
git.ipfire.org Git - thirdparty/mdadm.git/blob - uuid.c
2 * mdadm - manage Linux "md" devices aka RAID arrays.
4 * Copyright (C) 2001-2013 Neil Brown <neilb@suse.de>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * Email: <neilb@suse.de>
27 const int uuid_zero
[4] = { 0, 0, 0, 0 };
29 int same_uuid(int a
[4], int b
[4], int swapuuid
)
32 /* parse uuids are hostendian.
33 * uuid's from some superblocks are big-ending
34 * if there is a difference, we need to swap..
36 unsigned char *ac
= (unsigned char *)a
;
37 unsigned char *bc
= (unsigned char *)b
;
39 for (i
= 0; i
< 16; i
+= 4) {
40 if (ac
[i
+0] != bc
[i
+3] ||
57 void copy_uuid(void *a
, int b
[4], int swapuuid
)
60 /* parse uuids are hostendian.
61 * uuid's from some superblocks are big-ending
62 * if there is a difference, we need to swap..
64 unsigned char *ac
= (unsigned char *)a
;
65 unsigned char *bc
= (unsigned char *)b
;
67 for (i
= 0; i
< 16; i
+= 4) {
78 * Parse a 128 bit uuid in 4 integers
79 * format is 32 hexx nibbles with options :.<space> separator
80 * If not exactly 32 hex digits are found, return 0
83 int parse_uuid(char *str
, int uuid
[4])
85 int hit
= 0; /* number of Hex digIT */
88 for (i
= 0; i
< 4; i
++)
91 while ((c
= *str
++) != 0) {
93 if (c
>= '0' && c
<= '9')
95 else if (c
>= 'a' && c
<= 'f')
97 else if (c
>= 'A' && c
<= 'F')
99 else if (strchr(":. -", c
))