util/uuid: use libc uuid functions on freebsd
Remove libuuid usage on FreeBSD and add dedicated implementation of spdk_uuid API using functions from the standard library. Fixes: #2878 Change-Id: Ie49ccb2842acad6064bffd789e4f64b7365b6e5c Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16558 Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
parent
96073478de
commit
19572e5b20
@ -13,7 +13,10 @@ C_SRCS = base64.c bit_array.c cpuset.c crc16.c crc32.c crc32c.c crc32_ieee.c \
|
|||||||
dif.c fd.c file.c hexlify.c iov.c math.c pipe.c strerror_tls.c string.c uuid.c \
|
dif.c fd.c file.c hexlify.c iov.c math.c pipe.c strerror_tls.c string.c uuid.c \
|
||||||
fd_group.c xor.c zipf.c
|
fd_group.c xor.c zipf.c
|
||||||
LIBNAME = util
|
LIBNAME = util
|
||||||
|
|
||||||
|
ifneq ($(OS),FreeBSD)
|
||||||
LOCAL_SYS_LIBS = -luuid
|
LOCAL_SYS_LIBS = -luuid
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_ISAL), y)
|
ifeq ($(CONFIG_ISAL), y)
|
||||||
LOCAL_SYS_LIBS += -L$(ISAL_DIR)/.libs -lisal
|
LOCAL_SYS_LIBS += -L$(ISAL_DIR)/.libs -lisal
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
#include "spdk/uuid.h"
|
#include "spdk/uuid.h"
|
||||||
|
|
||||||
|
#ifndef __FreeBSD__
|
||||||
|
|
||||||
#include <uuid/uuid.h>
|
#include <uuid/uuid.h>
|
||||||
|
|
||||||
SPDK_STATIC_ASSERT(sizeof(struct spdk_uuid) == sizeof(uuid_t), "Size mismatch");
|
SPDK_STATIC_ASSERT(sizeof(struct spdk_uuid) == sizeof(uuid_t), "Size mismatch");
|
||||||
@ -43,3 +45,61 @@ spdk_uuid_copy(struct spdk_uuid *dst, const struct spdk_uuid *src)
|
|||||||
{
|
{
|
||||||
uuid_copy((void *)dst, (void *)src);
|
uuid_copy((void *)dst, (void *)src);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#include <uuid.h>
|
||||||
|
|
||||||
|
SPDK_STATIC_ASSERT(sizeof(struct spdk_uuid) == sizeof(uuid_t), "Size mismatch");
|
||||||
|
|
||||||
|
int
|
||||||
|
spdk_uuid_parse(struct spdk_uuid *uuid, const char *uuid_str)
|
||||||
|
{
|
||||||
|
uint32_t status;
|
||||||
|
|
||||||
|
uuid_from_string(uuid_str, (uuid_t *)uuid, &status);
|
||||||
|
|
||||||
|
return status == 0 ? 0 : -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
spdk_uuid_fmt_lower(char *uuid_str, size_t uuid_str_size, const struct spdk_uuid *uuid)
|
||||||
|
{
|
||||||
|
uint32_t status;
|
||||||
|
char *str;
|
||||||
|
|
||||||
|
if (uuid_str_size < SPDK_UUID_STRING_LEN) {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
uuid_to_string((const uuid_t *)uuid, &str, &status);
|
||||||
|
|
||||||
|
if (status == uuid_s_no_memory) {
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(uuid_str, uuid_str_size, "%s", str);
|
||||||
|
free(str);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
spdk_uuid_compare(const struct spdk_uuid *u1, const struct spdk_uuid *u2)
|
||||||
|
{
|
||||||
|
return uuid_compare((const uuid_t *)u1, (const uuid_t *)u2, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
spdk_uuid_generate(struct spdk_uuid *uuid)
|
||||||
|
{
|
||||||
|
uuid_create((uuid_t *)uuid, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
spdk_uuid_copy(struct spdk_uuid *dst, const struct spdk_uuid *src)
|
||||||
|
{
|
||||||
|
memcpy(dst, src, sizeof(*dst));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -338,7 +338,9 @@ CFLAGS += $(COMMON_CFLAGS) -Wno-pointer-sign -Wstrict-prototypes -Wold-style-d
|
|||||||
CXXFLAGS += $(COMMON_CFLAGS) -std=c++11
|
CXXFLAGS += $(COMMON_CFLAGS) -std=c++11
|
||||||
|
|
||||||
SYS_LIBS += -lrt
|
SYS_LIBS += -lrt
|
||||||
|
ifneq ($(OS),FreeBSD)
|
||||||
SYS_LIBS += -luuid
|
SYS_LIBS += -luuid
|
||||||
|
endif
|
||||||
SYS_LIBS += -lssl
|
SYS_LIBS += -lssl
|
||||||
SYS_LIBS += -lcrypto
|
SYS_LIBS += -lcrypto
|
||||||
SYS_LIBS += -lm
|
SYS_LIBS += -lm
|
||||||
|
@ -4,15 +4,13 @@
|
|||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Minimal install
|
# Minimal install
|
||||||
pkg install -y gmake cunit openssl git bash misc/e2fsprogs-libuuid python \
|
pkg install -y gmake cunit openssl git bash python ncurses ninja meson
|
||||||
ncurses ninja meson
|
|
||||||
pkg install -g -y "py*-pyelftools-*" "py*-pandas"
|
pkg install -g -y "py*-pyelftools-*" "py*-pandas"
|
||||||
# Additional dependencies for ISA-L used in compression
|
# Additional dependencies for ISA-L used in compression
|
||||||
pkg install -y autoconf automake libtool help2man
|
pkg install -y autoconf automake libtool help2man
|
||||||
if [[ $INSTALL_DEV_TOOLS == "true" ]]; then
|
if [[ $INSTALL_DEV_TOOLS == "true" ]]; then
|
||||||
# Tools for developers
|
# Tools for developers
|
||||||
pkg install -y devel/astyle bash \
|
pkg install -y devel/astyle bash sysutils/sg3_utils nasm \
|
||||||
misc/e2fsprogs-libuuid sysutils/sg3_utils nasm \
|
|
||||||
bash-completion ruby devel/ruby-gems
|
bash-completion ruby devel/ruby-gems
|
||||||
pkg install -g -y "py*-pycodestyle"
|
pkg install -g -y "py*-pycodestyle"
|
||||||
# ruby and ruby-gems are not preinstalled on FreeBSD but are needed to
|
# ruby and ruby-gems are not preinstalled on FreeBSD but are needed to
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
#include "spdk/bdev_module.h"
|
#include "spdk/bdev_module.h"
|
||||||
#include "nvmf/subsystem.c"
|
#include "nvmf/subsystem.c"
|
||||||
#include <uuid/uuid.h>
|
|
||||||
|
|
||||||
SPDK_LOG_REGISTER_COMPONENT(nvmf)
|
SPDK_LOG_REGISTER_COMPONENT(nvmf)
|
||||||
|
|
||||||
@ -1593,7 +1592,7 @@ test_nvmf_valid_nqn(void)
|
|||||||
struct spdk_uuid s_uuid = {};
|
struct spdk_uuid s_uuid = {};
|
||||||
|
|
||||||
spdk_uuid_generate(&s_uuid);
|
spdk_uuid_generate(&s_uuid);
|
||||||
uuid_unparse((void *)&s_uuid, uuid);
|
spdk_uuid_fmt_lower(uuid, sizeof(uuid), &s_uuid);
|
||||||
|
|
||||||
/* discovery nqn */
|
/* discovery nqn */
|
||||||
snprintf(nqn, sizeof(nqn), "%s", SPDK_NVMF_DISCOVERY_NQN);
|
snprintf(nqn, sizeof(nqn), "%s", SPDK_NVMF_DISCOVERY_NQN);
|
||||||
@ -1659,13 +1658,13 @@ test_nvmf_ns_reservation_restore(void)
|
|||||||
|
|
||||||
/* Generate and prepare uuids, make sure bdev and info uuid are the same */
|
/* Generate and prepare uuids, make sure bdev and info uuid are the same */
|
||||||
spdk_uuid_generate(&s_uuid);
|
spdk_uuid_generate(&s_uuid);
|
||||||
uuid_unparse((void *)&s_uuid, uuid);
|
spdk_uuid_fmt_lower(uuid, sizeof(uuid), &s_uuid);
|
||||||
snprintf(info.holder_uuid, SPDK_UUID_STRING_LEN, "%s", uuid);
|
snprintf(info.holder_uuid, SPDK_UUID_STRING_LEN, "%s", uuid);
|
||||||
snprintf(info.bdev_uuid, SPDK_UUID_STRING_LEN, "%s", uuid);
|
snprintf(info.bdev_uuid, SPDK_UUID_STRING_LEN, "%s", uuid);
|
||||||
snprintf(info.registrants[0].host_uuid, SPDK_UUID_STRING_LEN, "%s", uuid);
|
snprintf(info.registrants[0].host_uuid, SPDK_UUID_STRING_LEN, "%s", uuid);
|
||||||
spdk_uuid_copy(&bdev.uuid, &s_uuid);
|
spdk_uuid_copy(&bdev.uuid, &s_uuid);
|
||||||
spdk_uuid_generate(&s_uuid);
|
spdk_uuid_generate(&s_uuid);
|
||||||
uuid_unparse((void *)&s_uuid, uuid);
|
spdk_uuid_fmt_lower(uuid, sizeof(uuid), &s_uuid);
|
||||||
snprintf(info.registrants[1].host_uuid, SPDK_UUID_STRING_LEN, "%s", uuid);
|
snprintf(info.registrants[1].host_uuid, SPDK_UUID_STRING_LEN, "%s", uuid);
|
||||||
|
|
||||||
/* info->rkey not exist in registrants */
|
/* info->rkey not exist in registrants */
|
||||||
@ -1695,7 +1694,7 @@ test_nvmf_ns_reservation_restore(void)
|
|||||||
|
|
||||||
/* Existing bdev UUID is different with configuration */
|
/* Existing bdev UUID is different with configuration */
|
||||||
spdk_uuid_generate(&s_uuid);
|
spdk_uuid_generate(&s_uuid);
|
||||||
uuid_unparse((void *)&s_uuid, uuid);
|
spdk_uuid_fmt_lower(uuid, sizeof(uuid), &s_uuid);
|
||||||
snprintf(info.bdev_uuid, SPDK_UUID_STRING_LEN, "%s", uuid);
|
snprintf(info.bdev_uuid, SPDK_UUID_STRING_LEN, "%s", uuid);
|
||||||
spdk_uuid_generate(&s_uuid);
|
spdk_uuid_generate(&s_uuid);
|
||||||
spdk_uuid_copy(&bdev.uuid, &s_uuid);
|
spdk_uuid_copy(&bdev.uuid, &s_uuid);
|
||||||
|
Loading…
Reference in New Issue
Block a user