Skip to content

Commit 4688840

Browse files
Cleaned up remaining MI and Fabrics stubs and compatibility and removed platform/types.h (#96)
Recent upstream changes removed the need for platform/types.h and made MI and Fabrics only compile if supported, which they aren't on windows. Cleaning up our Windows support based on these changes. - Removed platform/types.h - Removed platform/includes.h support that is no longer needed - Removed functionality only used by MI and fabrics - Removed endian and log support that is not needed due to upstream refactoring - Removed MI and Fabrics stubs - Restored nbft.c to match master since it only builds with fabrics
1 parent f54abc6 commit 4688840

8 files changed

Lines changed: 6 additions & 262 deletions

File tree

libnvme/src/meson.build

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ install_headers([
198198
'platform/includes.h',
199199
'platform/linux.h',
200200
'platform/windows.h',
201-
'platform/types.h'
202201
],
203202
subdir: 'platform',
204203
install_mode: mode,

libnvme/src/nvme/nbft.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <stdio.h>
1111
#include <stdlib.h>
1212

13-
#include <platform/includes.h>
13+
#include <arpa/inet.h>
1414

1515
#include <ccan/endian/endian.h>
1616

@@ -36,7 +36,7 @@ static void format_ip_addr(char *buf, size_t buflen, __u8 *addr)
3636
memcpy(&addr_ipv6, addr, sizeof(addr_ipv6));
3737
if (IN6_IS_ADDR_V4MAPPED(&addr_ipv6))
3838
/* ipv4 */
39-
inet_ntop(AF_INET, ipv4_from_in6_addr(addr_ipv6), buf, buflen);
39+
inet_ntop(AF_INET, &addr_ipv6.s6_addr32[3], buf, buflen);
4040
else
4141
/* ipv6 */
4242
inet_ntop(AF_INET6, &addr_ipv6, buf, buflen);
@@ -102,9 +102,9 @@ static int __get_heap_obj(struct libnvme_global_ctx *ctx,
102102
if (strnlen(*output, le16_to_cpu(obj.length) + 1) <
103103
le16_to_cpu(obj.length)) {
104104
libnvme_msg(ctx, LIBNVME_LOG_DEBUG,
105-
"file %s: string '%s' in descriptor '%s' is shorter (%u) than specified length (%u)\n",
105+
"file %s: string '%s' in descriptor '%s' is shorter (%zd) than specified length (%d)\n",
106106
filename, fieldname, descriptorname,
107-
(unsigned int)strnlen(*output, le16_to_cpu(obj.length) + 1),
107+
strnlen(*output, le16_to_cpu(obj.length) + 1),
108108
le16_to_cpu(obj.length));
109109
} else if (strnlen(*output, le16_to_cpu(obj.length) + 1) >
110110
le16_to_cpu(obj.length)) {

libnvme/src/nvme/windows-stubs.c

Lines changed: 2 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Copyright (c) 2025 Micron Technology, Inc.
55
*
66
* Windows stub implementations for Linux-specific functionality
7-
* that is excluded from the Windows build (fabrics, MI, tree, filters, etc.)
7+
* that is excluded from the Windows build (tree, filters, etc.)
88
*/
99

1010
#include <errno.h>
@@ -447,14 +447,6 @@ __public libnvme_path_t libnvme_namespace_next_path(libnvme_ns_t ns, libnvme_pat
447447
return NULL;
448448
}
449449

450-
/* MI status string (mi.c) */
451-
__public const char *libnvme_mi_status_to_string(int status)
452-
{
453-
stub_log(__func__);
454-
(void)status;
455-
return "MI not supported on Windows";
456-
}
457-
458450
/*
459451
* Linux keyring and TLS key management stubs (linux.c)
460452
* These are used by nvme-cli security commands
@@ -643,7 +635,7 @@ __public int libnvme_create_raw_secret(struct libnvme_global_ctx *ctx,
643635
return -ENOTSUP;
644636
}
645637

646-
/* Hostnqn generation (fabrics.c) */
638+
/* Hostnqn generation */
647639
__public char *libnvme_generate_hostnqn(void)
648640
{
649641
stub_log(__func__);
@@ -658,86 +650,3 @@ __public int libnvme_path_get_queue_depth(struct libnvme_path *p)
658650
(void)p;
659651
return 0;
660652
}
661-
662-
/* Fabrics string conversion functions (fabrics.c) */
663-
__public const char *libnvmf_trtype_str(__u8 trtype)
664-
{
665-
stub_log(__func__);
666-
(void)trtype;
667-
return "unknown";
668-
}
669-
670-
__public const char *libnvmf_eflags_str(__u16 eflags)
671-
{
672-
stub_log(__func__);
673-
(void)eflags;
674-
return "unknown";
675-
}
676-
677-
__public const char *libnvmf_sectype_str(__u8 sectype)
678-
{
679-
stub_log(__func__);
680-
(void)sectype;
681-
return "unknown";
682-
}
683-
684-
__public const char *libnvmf_cms_str(__u8 cms)
685-
{
686-
stub_log(__func__);
687-
(void)cms;
688-
return "unknown";
689-
}
690-
691-
__public const char *libnvmf_qptype_str(__u8 qptype)
692-
{
693-
stub_log(__func__);
694-
(void)qptype;
695-
return "unknown";
696-
}
697-
698-
__public const char *libnvmf_prtype_str(__u8 prtype)
699-
{
700-
stub_log(__func__);
701-
(void)prtype;
702-
return "unknown";
703-
}
704-
705-
__public const char *libnvmf_adrfam_str(__u8 adrfam)
706-
{
707-
stub_log(__func__);
708-
(void)adrfam;
709-
return "unknown";
710-
}
711-
712-
__public const char *libnvmf_subtype_str(__u8 subtype)
713-
{
714-
stub_log(__func__);
715-
(void)subtype;
716-
return "unknown";
717-
}
718-
719-
__public const char *libnvmf_treq_str(__u8 treq)
720-
{
721-
stub_log(__func__);
722-
(void)treq;
723-
return "unknown";
724-
}
725-
726-
/* NBFT functions (nbft.c) */
727-
__public int libnvmf_nbft_read_files(struct libnvme_global_ctx *ctx, char *path,
728-
struct nbft_file_entry **nbft_list)
729-
{
730-
stub_log(__func__);
731-
(void)ctx;
732-
(void)path;
733-
(void)nbft_list;
734-
errno = ENOTSUP;
735-
return -1;
736-
}
737-
738-
__public void libnvmf_nbft_free(struct libnvme_global_ctx *ctx, struct nbft_file_entry *head)
739-
{
740-
stub_log(__func__);
741-
(void)ctx;
742-
(void)head;
743-
}

libnvme/src/platform/includes.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
#pragma once
1010

11-
#include "platform/types.h"
12-
1311
/* Platform-specific includes */
1412
#ifdef _WIN32
1513
#include "platform/windows.h"

libnvme/src/platform/linux.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
#include <netdb.h>
3131
#include <netinet/in.h>
3232

33-
/* Extract IPv4 from IPv6 mapped address */
34-
#define ipv4_from_in6_addr(addr) &(addr.s6_addr32[3])
3533

3634
typedef int libnvme_fd_t;
3735
#define TEST_FD 0xFD

libnvme/src/platform/types.h

Lines changed: 0 additions & 44 deletions
This file was deleted.

libnvme/src/platform/windows.h

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -45,52 +45,6 @@ static inline void libnvme_init(void)
4545
}
4646

4747

48-
/* endian.h compatibility */
49-
50-
#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
51-
#define htobe16(x) (x)
52-
#define htobe32(x) (x)
53-
#define htobe64(x) (x)
54-
#define htole16(x) __builtin_bswap16(x)
55-
#define htole32(x) __builtin_bswap32(x)
56-
#define htole64(x) __builtin_bswap64(x)
57-
#define le16toh(x) __builtin_bswap16(x)
58-
#define le32toh(x) __builtin_bswap32(x)
59-
#define le64toh(x) __builtin_bswap64(x)
60-
#else
61-
/* Little-endian (most common case for Windows) */
62-
#define htobe16(x) __builtin_bswap16(x)
63-
#define htobe32(x) __builtin_bswap32(x)
64-
#define htobe64(x) __builtin_bswap64(x)
65-
#define htole16(x) (x)
66-
#define htole32(x) (x)
67-
#define htole64(x) (x)
68-
#define le16toh(x) (x)
69-
#define le32toh(x) (x)
70-
#define le64toh(x) (x)
71-
#endif
72-
73-
74-
/* syslog.h compatibility */
75-
76-
#define LOG_EMERG 0
77-
#define LOG_ALERT 1
78-
#define LOG_CRIT 2
79-
#define LOG_ERR 3
80-
#define LOG_WARNING 4
81-
#define LOG_NOTICE 5
82-
#define LOG_INFO 6
83-
#define LOG_DEBUG 7
84-
static inline void syslog(int priority, const char *format, ...) { (void)priority; (void)format; }
85-
static inline void openlog(const char *ident, int option, int facility) { (void)ident; (void)option; (void)facility; }
86-
static inline void closelog(void) { }
87-
88-
89-
/* poll.h compatibility (winsock2.h provides additional compatibility) */
90-
91-
typedef unsigned long nfds_t;
92-
93-
9448
/* sys/param.h compatibility */
9549

9650
#define MIN(a, b) ((a) < (b) ? (a) : (b))
@@ -106,27 +60,6 @@ typedef unsigned long nfds_t;
10660
#define ENAVAIL 119
10761

10862

109-
/* socket.h compatibility */
110-
111-
struct msghdr {
112-
void *msg_name;
113-
socklen_t msg_namelen;
114-
struct iovec *msg_iov;
115-
size_t msg_iovlen;
116-
void *msg_control;
117-
size_t msg_controllen;
118-
int msg_flags;
119-
};
120-
121-
struct iovec {
122-
void *iov_base;
123-
size_t iov_len;
124-
};
125-
126-
/* Extract IPv4 from IPv6 mapped address (in6_addr) */
127-
#define ipv4_from_in6_addr(addr) &(addr.u.Byte[12])
128-
129-
13063
/* ifaddrs.h compatibility */
13164

13265
struct ifaddrs {

windows-stubs.c

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -9,55 +9,6 @@
99
#ifdef _WIN32
1010

1111
#include <stdio.h>
12-
#include <stdbool.h>
13-
14-
/* ========== NVMe Fabrics Command Stubs ========== */
15-
/*
16-
* NVMe over Fabrics is not currently supported on Windows.
17-
* These stubs provide error messages when users attempt to use fabrics commands.
18-
*/
19-
20-
int fabrics_discovery(const char *desc, int argc, char **argv, bool connect)
21-
{
22-
(void)desc; (void)argc; (void)argv; (void)connect;
23-
fprintf(stderr, "NVMe fabrics discovery is not supported on Windows\n");
24-
return -1;
25-
}
26-
27-
int fabrics_connect(const char *desc, int argc, char **argv)
28-
{
29-
(void)desc; (void)argc; (void)argv;
30-
fprintf(stderr, "NVMe fabrics connect is not supported on Windows\n");
31-
return -1;
32-
}
33-
34-
int fabrics_disconnect(const char *desc, int argc, char **argv)
35-
{
36-
(void)desc; (void)argc; (void)argv;
37-
fprintf(stderr, "NVMe fabrics disconnect is not supported on Windows\n");
38-
return -1;
39-
}
40-
41-
int fabrics_disconnect_all(const char *desc, int argc, char **argv)
42-
{
43-
(void)desc; (void)argc; (void)argv;
44-
fprintf(stderr, "NVMe fabrics disconnect-all is not supported on Windows\n");
45-
return -1;
46-
}
47-
48-
int fabrics_config(const char *desc, int argc, char **argv)
49-
{
50-
(void)desc; (void)argc; (void)argv;
51-
fprintf(stderr, "NVMe fabrics config is not supported on Windows\n");
52-
return -1;
53-
}
54-
55-
int fabrics_dim(const char *desc, int argc, char **argv)
56-
{
57-
(void)desc; (void)argc; (void)argv;
58-
fprintf(stderr, "NVMe fabrics DIM is not supported on Windows\n");
59-
return -1;
60-
}
6112

6213
/* ========== NVMe RPMB Command Stubs ========== */
6314
/*

0 commit comments

Comments
 (0)