#define NVME_HOSTNQN_ID SD_ID128_MAKE(c7,f4,61,81,12,be,49,32,8c,83,10,6f,9d,dd,d8,6b)
#endif
+#include <ccan/list/list.h>
#include <ccan/array_size/array_size.h>
#include "fabrics.h"
#include <json-c/json.h>
#include "fabrics.h"
-#include "private.h"
#define json_object_add_value_string(o, k, v) \
json_object_object_add(o, k, json_object_new_string(v))
extern const char *nvme_subsys_sysfs_dir;
extern const char *nvme_ns_sysfs_dir;
+struct nvme_path {
+ struct list_node entry;
+ struct list_node nentry;
+
+ struct nvme_ctrl *c;
+ struct nvme_ns *n;
+
+ char *name;
+ char *sysfs_dir;
+ char *ana_state;
+ int grpid;
+};
+
+struct nvme_ns {
+ struct list_node entry;
+ struct list_head paths;
+
+ struct nvme_subsystem *s;
+ struct nvme_ctrl *c;
+
+ int fd;
+ __u32 nsid;
+ char *name;
+ char *sysfs_dir;
+
+ int lba_shift;
+ int lba_size;
+ int meta_size;
+ uint64_t lba_count;
+ uint64_t lba_util;
+
+ uint8_t eui64[8];
+ uint8_t nguid[16];
+#ifdef CONFIG_LIBUUID
+ uuid_t uuid;
+#else
+ uint8_t uuid[16];
+#endif
+ enum nvme_csi csi;
+};
+
+struct nvme_ctrl {
+ struct list_node entry;
+ struct list_head paths;
+ struct list_head namespaces;
+
+ struct nvme_subsystem *s;
+
+ int fd;
+ char *name;
+ char *sysfs_dir;
+ char *address;
+ char *firmware;
+ char *model;
+ char *state;
+ char *numa_node;
+ char *queue_count;
+ char *serial;
+ char *sqsize;
+ char *hostnqn;
+ char *hostid;
+ char *transport;
+ char *subsysnqn;
+ char *traddr;
+ char *trsvcid;
+ char *host_traddr;
+ char *host_iface;
+ bool discovered;
+ bool persistent;
+ struct nvme_fabrics_config cfg;
+};
+
+struct nvme_subsystem {
+ struct list_node entry;
+ struct list_head ctrls;
+ struct list_head namespaces;
+ struct nvme_host *h;
+
+ char *name;
+ char *sysfs_dir;
+ char *subsysnqn;
+ char *model;
+ char *serial;
+ char *firmware;
+};
+
+struct nvme_host {
+ struct list_node entry;
+ struct list_head subsystems;
+ struct nvme_root *r;
+
+ char *hostnqn;
+ char *hostid;
+};
+
+struct nvme_root {
+ char *config_file;
+ struct list_head hosts;
+ bool modified;
+};
+
int nvme_set_attr(const char *dir, const char *attr, const char *value);
void json_read_config(nvme_root_t r, const char *config_file);
static int nvme_ctrl_scan_namespace(struct nvme_ctrl *c, char *name);
static int nvme_ctrl_scan_path(struct nvme_ctrl *c, char *name);
-struct nvme_path {
- struct list_node entry;
- struct list_node nentry;
-
- struct nvme_ctrl *c;
- struct nvme_ns *n;
-
- char *name;
- char *sysfs_dir;
- char *ana_state;
- int grpid;
-};
-
-struct nvme_ns {
- struct list_node entry;
- struct list_head paths;
-
- struct nvme_subsystem *s;
- struct nvme_ctrl *c;
-
- int fd;
- __u32 nsid;
- char *name;
- char *sysfs_dir;
-
- int lba_shift;
- int lba_size;
- int meta_size;
- uint64_t lba_count;
- uint64_t lba_util;
-
- uint8_t eui64[8];
- uint8_t nguid[16];
-#ifdef CONFIG_LIBUUID
- uuid_t uuid;
-#else
- uint8_t uuid[16];
-#endif
- enum nvme_csi csi;
-};
-
-struct nvme_ctrl {
- struct list_node entry;
- struct list_head paths;
- struct list_head namespaces;
-
- struct nvme_subsystem *s;
-
- int fd;
- char *name;
- char *sysfs_dir;
- char *address;
- char *firmware;
- char *model;
- char *state;
- char *numa_node;
- char *queue_count;
- char *serial;
- char *sqsize;
- char *hostnqn;
- char *hostid;
- char *transport;
- char *subsysnqn;
- char *traddr;
- char *trsvcid;
- char *host_traddr;
- char *host_iface;
- bool discovered;
- bool persistent;
- struct nvme_fabrics_config cfg;
-};
-
-struct nvme_subsystem {
- struct list_node entry;
- struct list_head ctrls;
- struct list_head namespaces;
- struct nvme_host *h;
-
- char *name;
- char *sysfs_dir;
- char *subsysnqn;
- char *model;
- char *serial;
- char *firmware;
-};
-
-struct nvme_host {
- struct list_node entry;
- struct list_head subsystems;
- struct nvme_root *r;
-
- char *hostnqn;
- char *hostid;
-};
-
-struct nvme_root {
- char *config_file;
- struct list_head hosts;
- bool modified;
-};
-
static inline void nvme_free_dirents(struct dirent **d, int i)
{
while (i-- > 0)