Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions fabrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

#include <libnvme.h>

#ifdef HAVE_LIBKMOD
#ifdef NVME_HAVE_LIBKMOD
#include <libkmod.h>
#endif

Expand Down Expand Up @@ -515,7 +515,7 @@ static int nvme_read_config_checked(struct libnvme_global_ctx *ctx,

static void load_nvme_fabrics_module(void)
{
#ifdef HAVE_LIBKMOD
#ifdef NVME_HAVE_LIBKMOD
struct kmod_ctx *ctx;
struct kmod_module *mod;
int err, state;
Expand Down
4 changes: 2 additions & 2 deletions libnvme/src/nvme/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <string.h>
#include <unistd.h>

#if HAVE_SYS_RANDOM
#if NVME_HAVE_SYS_RANDOM
#include <sys/random.h>
#endif
#include <sys/param.h>
Expand Down Expand Up @@ -662,7 +662,7 @@ static int derive_psk_digest(struct libnvme_global_ctx *ctx,
static ssize_t getrandom_bytes(void *buf, size_t buflen)
{
ssize_t result;
#if HAVE_SYS_RANDOM
#if NVME_HAVE_SYS_RANDOM
result = getrandom(buf, buflen, GRND_NONBLOCK);
#else
__cleanup_fd int fd = -1;
Expand Down
2 changes: 1 addition & 1 deletion libnvme/src/nvme/mi-mctp.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <sys/types.h>
#include <sys/uio.h>

#if HAVE_LINUX_MCTP_H
#if NVME_HAVE_LINUX_MCTP_H
#include <linux/mctp.h>
#else
#include "nvme/mi-mctp-compat.h"
Expand Down
8 changes: 4 additions & 4 deletions libnvme/src/nvme/private-fabrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
#pragma once

#if defined(HAVE_NETDB) || defined(CONFIG_FABRICS)
#if defined(NVME_HAVE_NETDB) || defined(CONFIG_FABRICS)
#include <ifaddrs.h>
#endif

Expand Down Expand Up @@ -139,7 +139,7 @@ static inline __u16 libnvmf_exat_size(size_t val_len)
return (__u16)(sizeof(struct nvmf_ext_attr) + libnvmf_exat_len(val_len));
}

#if defined(HAVE_NETDB) || defined(CONFIG_FABRICS)
#if defined(NVME_HAVE_NETDB) || defined(CONFIG_FABRICS)
/**
* libnvmf_getifaddrs - Cached wrapper around getifaddrs()
* @ctx: pointer to the global context
Expand All @@ -153,7 +153,7 @@ static inline __u16 libnvmf_exat_size(size_t val_len)
* Return: Pointer to I/F data, NULL on error (with errno set).
*/
const struct ifaddrs *libnvmf_getifaddrs(struct libnvme_global_ctx *ctx);
#endif /* HAVE_NETDB || CONFIG_FABRICS */
#endif /* NVME_HAVE_NETDB || CONFIG_FABRICS */

/**
* struct candidate_args - Parameters used to match an existing controller
Expand All @@ -174,7 +174,7 @@ struct candidate_args {
const char *subsysnqn;
const char *host_traddr;
const char *host_iface;
#if defined(HAVE_NETDB) || defined(CONFIG_FABRICS)
#if defined(NVME_HAVE_NETDB) || defined(CONFIG_FABRICS)
const struct ifaddrs *iface_list;
#endif
bool (*addreq)(const char *, const char *);
Expand Down
6 changes: 3 additions & 3 deletions libnvme/src/nvme/private.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <sys/types.h>
#include <string.h>

#if defined(HAVE_NETDB) || defined(CONFIG_FABRICS)
#if defined(NVME_HAVE_NETDB) || defined(CONFIG_FABRICS)
#include <ifaddrs.h>
#endif

Expand Down Expand Up @@ -545,7 +545,7 @@ static inline bool streqcase0(const char *s1, const char *s2)
*/
bool libnvme_ipaddrs_eq(const char *addr1, const char *addr2);

#if defined(HAVE_NETDB) || defined(CONFIG_FABRICS)
#if defined(NVME_HAVE_NETDB) || defined(CONFIG_FABRICS)
/**
* libnvme_iface_matching_addr - Get interface matching @addr
* @iface_list: Interface list returned by getifaddrs()
Expand Down Expand Up @@ -575,7 +575,7 @@ const char *libnvme_iface_matching_addr(const struct ifaddrs *iface_list,
*/
bool libnvme_iface_primary_addr_matches(const struct ifaddrs *iface_list,
const char *iface, const char *addr);
#endif /* HAVE_NETDB || CONFIG_FABRICS */
#endif /* NVME_HAVE_NETDB || CONFIG_FABRICS */

int hostname2traddr(struct libnvme_global_ctx *ctx, const char *traddr,
char **hostname);
Expand Down
22 changes: 11 additions & 11 deletions libnvme/src/nvme/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <string.h>
#include <unistd.h>

#if defined(HAVE_NETDB) || defined(CONFIG_FABRICS)
#if defined(NVME_HAVE_NETDB) || defined(CONFIG_FABRICS)
#include <ifaddrs.h>

#include <arpa/inet.h>
Expand All @@ -27,7 +27,7 @@
#include <sys/stat.h>
#include <sys/types.h>

#if HAVE_BCRYPT
#if NVME_HAVE_BCRYPT
#include <windows.h>
#include <bcrypt.h>
#endif
Expand Down Expand Up @@ -473,7 +473,7 @@ __libnvme_public const char *libnvme_strerror(int errnum)
return strerror(errnum);
}

#ifdef HAVE_NETDB
#ifdef NVME_HAVE_NETDB
static inline DEFINE_CLEANUP_FUNC(cleanup_addrinfo, struct addrinfo *,
freeaddrinfo)
#define __cleanup_addrinfo __cleanup(cleanup_addrinfo)
Expand Down Expand Up @@ -522,15 +522,15 @@ int hostname2traddr(struct libnvme_global_ctx *ctx, const char *traddr,

return 0;
}
#else /* HAVE_NETDB */
#else /* NVME_HAVE_NETDB */
int hostname2traddr(struct libnvme_global_ctx *ctx, const char *traddr, char **hostname)
{
libnvme_msg(ctx, LIBNVME_LOG_ERR, "No support for hostname IP address resolution; " \
"recompile with libnss support.\n");

return -ENOTSUP;
}
#endif /* HAVE_NETDB */
#endif /* NVME_HAVE_NETDB */

char *startswith(const char *s, const char *prefix)
{
Expand Down Expand Up @@ -635,7 +635,7 @@ __libnvme_public int libnvme_uuid_from_string(

static int random_bytes(void *buf, size_t buflen)
{
#if HAVE_BCRYPT
#if NVME_HAVE_BCRYPT
NTSTATUS status = BCryptGenRandom(NULL, buf, (ULONG)buflen,
BCRYPT_USE_SYSTEM_PREFERRED_RNG);

Expand Down Expand Up @@ -695,7 +695,7 @@ __libnvme_public int libnvme_find_uuid(struct nvme_id_uuid_list *uuid_list,
return -ENOENT;
}

#ifdef HAVE_NETDB
#ifdef NVME_HAVE_NETDB
static bool _nvme_ipaddrs_eq(struct sockaddr *addr1, struct sockaddr *addr2)
{
struct sockaddr_in *sockaddr_v4;
Expand Down Expand Up @@ -763,17 +763,17 @@ bool libnvme_ipaddrs_eq(const char *addr1, const char *addr2)
freeaddrinfo(info2);
return result;
}
#else /* HAVE_NETDB */
#else /* NVME_HAVE_NETDB */
bool libnvme_ipaddrs_eq(const char *addr1, const char *addr2)
{
libnvme_msg(NULL, LIBNVME_LOG_ERR, "no support for hostname ip address resolution; " \
"recompile with libnss support.\n");

return false;
}
#endif /* HAVE_NETDB */
#endif /* NVME_HAVE_NETDB */

#ifdef HAVE_NETDB
#ifdef NVME_HAVE_NETDB
const char *libnvme_iface_matching_addr(const struct ifaddrs *iface_list,
const char *addr)
{
Expand Down Expand Up @@ -851,7 +851,7 @@ bool libnvme_iface_primary_addr_matches(const struct ifaddrs *iface_list,
return false;
}

#endif /* HAVE_NETDB || CONFIG_FABRICS */
#endif /* NVME_HAVE_NETDB || CONFIG_FABRICS */

/* This used instead of basename() due to behavioral differences between
* the POSIX and the GNU version. This is the glibc implementation.
Expand Down
4 changes: 2 additions & 2 deletions libnvme/test/ioctl/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
mock_conf = configuration_data()

mock_conf.set(
'HAVE_GLIBC_IOCTL',
'NVME_HAVE_GLIBC_IOCTL',
cc.compiles(
'''#include <sys/ioctl.h>
int ioctl(int fd, unsigned long request, ...);
Expand All @@ -27,7 +27,7 @@ mock_ioctl = library(
libnvme_dep,
dl_dep,
],
c_args: ['-DHAVE_GLIBC_IOCTL=' + (mock_conf.get('HAVE_GLIBC_IOCTL') ? '1' : '0')],
c_args: ['-DNVME_HAVE_GLIBC_IOCTL=' + (mock_conf.get('NVME_HAVE_GLIBC_IOCTL') ? '1' : '0')],
)

# Add mock-ioctl to the LD_PRELOAD path so it overrides libc.
Expand Down
6 changes: 3 additions & 3 deletions libnvme/test/ioctl/mock.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void end_mock_cmds(void)
} \
})

#if defined(HAVE_GLIBC_IOCTL) && HAVE_GLIBC_IOCTL == 1
#if defined(NVME_HAVE_GLIBC_IOCTL) && NVME_HAVE_GLIBC_IOCTL == 1
typedef int (*ioctl_func_t)(libnvme_fd_t, unsigned long, void *);
int ioctl(libnvme_fd_t fd, unsigned long request, ...)
#else
Expand Down Expand Up @@ -154,11 +154,11 @@ int ioctl(libnvme_fd_t fd, int request, ...)
result64 = true;
break;
default:
#if HAVE_LIBC_LDSYM
#if NVME_HAVE_LIBC_LDSYM
real_ioctl = dlsym(RTLD_NEXT, "ioctl");
if (!real_ioctl)
fail("Error: dlsym failed to find original ioctl\n");
#elif defined(HAVE_GLIBC_IOCTL) && HAVE_GLIBC_IOCTL == 1
#elif defined(NVME_HAVE_GLIBC_IOCTL) && NVME_HAVE_GLIBC_IOCTL == 1
fprintf(stderr, "Warning: unhandled ioctl %lx\n", request);
return -ENOTTY;
#else
Expand Down
2 changes: 1 addition & 1 deletion libnvme/test/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ if want_fabrics
test('libnvme - fabrics', test_fabrics)
endif

if conf.get('HAVE_NETDB')
if conf.get('NVME_HAVE_NETDB')
mock_ifaddrs = library(
'mock-ifaddrs',
['mock-ifaddrs.c', ],
Expand Down
2 changes: 1 addition & 1 deletion libnvme/test/mi-mctp.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <sys/ioctl.h>
#include <sys/socket.h>

#if HAVE_LINUX_MCTP_H
#if NVME_HAVE_LINUX_MCTP_H
#include <linux/mctp.h>
#else
#include "nvme/mi-mctp-compat.h"
Expand Down
Loading
Loading