From: Hannes Reinecke Date: Fri, 7 May 2021 13:49:59 +0000 (+0200) Subject: tree: Move structures to private.h X-Git-Tag: v1.0-rc0~124^2~10 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=f2828b3e34d23356f19d227631c1c579138386c8;p=users%2Fsagi%2Flibnvme.git tree: Move structures to private.h Move generic structures to private.h to avoid having to duplicate definitions in the SWIG interface file. Signed-off-by: Hannes Reinecke --- diff --git a/src/nvme/fabrics.c b/src/nvme/fabrics.c index fb614aac..8b415cf4 100644 --- a/src/nvme/fabrics.c +++ b/src/nvme/fabrics.c @@ -27,6 +27,7 @@ #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 #include #include "fabrics.h" diff --git a/src/nvme/json.c b/src/nvme/json.c index d4f2644c..da4f18d3 100644 --- a/src/nvme/json.c +++ b/src/nvme/json.c @@ -13,7 +13,6 @@ #include #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)) diff --git a/src/nvme/private.h b/src/nvme/private.h index 70b38d45..fbda6e22 100644 --- a/src/nvme/private.h +++ b/src/nvme/private.h @@ -13,6 +13,107 @@ extern const char *nvme_ctrl_sysfs_dir; 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); diff --git a/src/nvme/tree.c b/src/nvme/tree.c index 9bd3a14d..777ee9d1 100644 --- a/src/nvme/tree.c +++ b/src/nvme/tree.c @@ -41,107 +41,6 @@ static int nvme_subsystem_scan_ctrl(struct nvme_subsystem *s, char *name); 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)