Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-15-SP3:Update
mdadm.22955
0084-uuid.c-split-uuid-stuffs-from-util.c.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0084-uuid.c-split-uuid-stuffs-from-util.c.patch of Package mdadm.22955
From f4c8a605d2467c0ed25fcba5d27dd56540660e55 Mon Sep 17 00:00:00 2001 From: Guoqing Jiang <guoqing.jiang@cloud.ionos.com> Date: Mon, 18 May 2020 23:53:35 +0200 Subject: [PATCH 79/89] uuid.c: split uuid stuffs from util.c Git-commit: f4c8a605d2467c0ed25fcba5d27dd56540660e55 Patch-mainline: mdadm-4.1+ References: jsc#SLE-13700 Currently, 'make raid6check' is build broken since commit b06815989 ("mdadm: load default sysfs attributes after assemblation"). /usr/bin/ld: sysfs.o: in function `sysfsline': sysfs.c:(.text+0x2707): undefined reference to `parse_uuid' /usr/bin/ld: sysfs.c:(.text+0x271a): undefined reference to `uuid_zero' /usr/bin/ld: sysfs.c:(.text+0x2721): undefined reference to `uuid_zero' Apparently, the compile of mdadm or raid6check are coupled with uuid functions inside util.c. However, we can't just add util.o to CHECK_OBJS which raid6check is needed, because it caused other worse problems. So, let's introduce a uuid.c file which is indenpended file to fix the problem, all the contents are splitted from util.c. Signed-off-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com> Signed-off-by: Coly Li <colyli@suse.de> --- Makefile | 6 +-- util.c | 87 ------------------------------------------ uuid.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+), 90 deletions(-) create mode 100644 uuid.c diff --git a/Makefile b/Makefile index 0a20b75..15d05d1 100644 --- a/Makefile +++ b/Makefile @@ -140,7 +140,7 @@ else ECHO=: endif -OBJS = mdadm.o config.o policy.o mdstat.o ReadMe.o util.o maps.o lib.o \ +OBJS = mdadm.o config.o policy.o mdstat.o ReadMe.o uuid.o util.o maps.o lib.o \ Manage.o Assemble.o Build.o \ Create.o Detail.o Examine.o Grow.o Monitor.o dlink.o Kill.o Query.o \ Incremental.o Dump.o \ @@ -149,13 +149,13 @@ OBJS = mdadm.o config.o policy.o mdstat.o ReadMe.o util.o maps.o lib.o \ restripe.o sysfs.o sha1.o mapfile.o crc32.o sg_io.o msg.o xmalloc.o \ platform-intel.o probe_roms.o crc32c.o -CHECK_OBJS = restripe.o sysfs.o maps.o lib.o xmalloc.o dlink.o +CHECK_OBJS = restripe.o uuid.o sysfs.o maps.o lib.o xmalloc.o dlink.o SRCS = $(patsubst %.o,%.c,$(OBJS)) INCL = mdadm.h part.h bitmap.h -MON_OBJS = mdmon.o monitor.o managemon.o util.o maps.o mdstat.o sysfs.o \ +MON_OBJS = mdmon.o monitor.o managemon.o uuid.o util.o maps.o mdstat.o sysfs.o \ policy.o lib.o \ Kill.o sg_io.o dlink.o ReadMe.o super-intel.o \ super-mbr.o super-gpt.o \ diff --git a/util.c b/util.c index 07f9dc3..579dd42 100644 --- a/util.c +++ b/util.c @@ -306,43 +306,6 @@ int md_get_disk_info(int fd, struct mdu_disk_info_s *disk) return ioctl(fd, GET_DISK_INFO, disk); } -/* - * Parse a 128 bit uuid in 4 integers - * format is 32 hexx nibbles with options :.<space> separator - * If not exactly 32 hex digits are found, return 0 - * else return 1 - */ -int parse_uuid(char *str, int uuid[4]) -{ - int hit = 0; /* number of Hex digIT */ - int i; - char c; - for (i = 0; i < 4; i++) - uuid[i] = 0; - - while ((c = *str++) != 0) { - int n; - if (c >= '0' && c <= '9') - n = c-'0'; - else if (c >= 'a' && c <= 'f') - n = 10 + c - 'a'; - else if (c >= 'A' && c <= 'F') - n = 10 + c - 'A'; - else if (strchr(":. -", c)) - continue; - else return 0; - - if (hit<32) { - uuid[hit/8] <<= 4; - uuid[hit/8] += n; - } - hit++; - } - if (hit == 32) - return 1; - return 0; -} - int get_linux_version() { struct utsname name; @@ -611,56 +574,6 @@ int enough(int level, int raid_disks, int layout, int clean, char *avail) } } -const int uuid_zero[4] = { 0, 0, 0, 0 }; - -int same_uuid(int a[4], int b[4], int swapuuid) -{ - if (swapuuid) { - /* parse uuids are hostendian. - * uuid's from some superblocks are big-ending - * if there is a difference, we need to swap.. - */ - unsigned char *ac = (unsigned char *)a; - unsigned char *bc = (unsigned char *)b; - int i; - for (i = 0; i < 16; i += 4) { - if (ac[i+0] != bc[i+3] || - ac[i+1] != bc[i+2] || - ac[i+2] != bc[i+1] || - ac[i+3] != bc[i+0]) - return 0; - } - return 1; - } else { - if (a[0]==b[0] && - a[1]==b[1] && - a[2]==b[2] && - a[3]==b[3]) - return 1; - return 0; - } -} - -void copy_uuid(void *a, int b[4], int swapuuid) -{ - if (swapuuid) { - /* parse uuids are hostendian. - * uuid's from some superblocks are big-ending - * if there is a difference, we need to swap.. - */ - unsigned char *ac = (unsigned char *)a; - unsigned char *bc = (unsigned char *)b; - int i; - for (i = 0; i < 16; i += 4) { - ac[i+0] = bc[i+3]; - ac[i+1] = bc[i+2]; - ac[i+2] = bc[i+1]; - ac[i+3] = bc[i+0]; - } - } else - memcpy(a, b, 16); -} - char *__fname_from_uuid(int id[4], int swap, char *buf, char sep) { int i, j; diff --git a/uuid.c b/uuid.c new file mode 100644 index 0000000..94b5abd --- /dev/null +++ b/uuid.c @@ -0,0 +1,112 @@ +/* + * mdadm - manage Linux "md" devices aka RAID arrays. + * + * Copyright (C) 2001-2013 Neil Brown <neilb@suse.de> + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Neil Brown + * Email: <neilb@suse.de> + */ + +#include <string.h> + +const int uuid_zero[4] = { 0, 0, 0, 0 }; + +int same_uuid(int a[4], int b[4], int swapuuid) +{ + if (swapuuid) { + /* parse uuids are hostendian. + * uuid's from some superblocks are big-ending + * if there is a difference, we need to swap.. + */ + unsigned char *ac = (unsigned char *)a; + unsigned char *bc = (unsigned char *)b; + int i; + for (i = 0; i < 16; i += 4) { + if (ac[i+0] != bc[i+3] || + ac[i+1] != bc[i+2] || + ac[i+2] != bc[i+1] || + ac[i+3] != bc[i+0]) + return 0; + } + return 1; + } else { + if (a[0]==b[0] && + a[1]==b[1] && + a[2]==b[2] && + a[3]==b[3]) + return 1; + return 0; + } +} + +void copy_uuid(void *a, int b[4], int swapuuid) +{ + if (swapuuid) { + /* parse uuids are hostendian. + * uuid's from some superblocks are big-ending + * if there is a difference, we need to swap.. + */ + unsigned char *ac = (unsigned char *)a; + unsigned char *bc = (unsigned char *)b; + int i; + for (i = 0; i < 16; i += 4) { + ac[i+0] = bc[i+3]; + ac[i+1] = bc[i+2]; + ac[i+2] = bc[i+1]; + ac[i+3] = bc[i+0]; + } + } else + memcpy(a, b, 16); +} + +/* + * Parse a 128 bit uuid in 4 integers + * format is 32 hexx nibbles with options :.<space> separator + * If not exactly 32 hex digits are found, return 0 + * else return 1 + */ +int parse_uuid(char *str, int uuid[4]) +{ + int hit = 0; /* number of Hex digIT */ + int i; + char c; + for (i = 0; i < 4; i++) + uuid[i] = 0; + + while ((c = *str++) != 0) { + int n; + if (c >= '0' && c <= '9') + n = c-'0'; + else if (c >= 'a' && c <= 'f') + n = 10 + c - 'a'; + else if (c >= 'A' && c <= 'F') + n = 10 + c - 'A'; + else if (strchr(":. -", c)) + continue; + else return 0; + + if (hit<32) { + uuid[hit/8] <<= 4; + uuid[hit/8] += n; + } + hit++; + } + if (hit == 32) + return 1; + return 0; +} -- 2.26.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor