summaryrefslogtreecommitdiffstats
path: root/plugins/huawei/huawei-nvme.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/huawei/huawei-nvme.c')
-rw-r--r--plugins/huawei/huawei-nvme.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/plugins/huawei/huawei-nvme.c b/plugins/huawei/huawei-nvme.c
index b39d861..116025b 100644
--- a/plugins/huawei/huawei-nvme.c
+++ b/plugins/huawei/huawei-nvme.c
@@ -26,16 +26,12 @@
#include <sys/stat.h>
-#include "linux/nvme_ioctl.h"
-
+#include "common.h"
#include "nvme.h"
-#include "nvme-print.h"
-#include "nvme-ioctl.h"
+#include "libnvme.h"
#include "plugin.h"
-#include "argconfig.h"
-#include "suffix.h"
-#include <sys/ioctl.h>
+#include "util/suffix.h"
#define CREATE_CMD
#include "huawei-nvme.h"
@@ -50,7 +46,7 @@
struct huawei_list_item {
char node[1024];
struct nvme_id_ctrl ctrl;
- int nsid;
+ unsigned nsid;
struct nvme_id_ns ns;
unsigned block;
char ns_name[NS_NAME_LEN];
@@ -87,8 +83,8 @@ static int huawei_get_nvme_info(int fd, struct huawei_list_item *item, const cha
}
item->huawei_device = true;
- item->nsid = nvme_get_nsid(fd);
- err = nvme_identify_ns(fd, item->nsid, 0, &item->ns);
+ err = nvme_get_nsid(fd, &item->nsid);
+ err = nvme_identify_ns(fd, item->nsid, &item->ns);
if (err)
return err;
@@ -211,7 +207,9 @@ static void huawei_print_list_head(struct huawei_list_element_len element_len)
static void huawei_print_list_item(struct huawei_list_item list_item,
struct huawei_list_element_len element_len)
{
- long long int lba = 1 << list_item.ns.lbaf[(list_item.ns.flbas & 0x0f)].ds;
+ __u8 lba_index;
+ nvme_id_ns_flbas_to_lbaf_inuse(list_item.ns.flbas, &lba_index);
+ long long int lba = 1 << list_item.ns.lbaf[lba_index].ds;
double nsze = le64_to_cpu(list_item.ns.nsze) * lba;
double nuse = le64_to_cpu(list_item.ns.nuse) * lba;
@@ -320,7 +318,7 @@ static int huawei_list(int argc, char **argv, struct command *command,
if (fmt != JSON && fmt != NORMAL)
return -EINVAL;
- n = scandir("/dev", &devices, scan_namespace_filter, alphasort);
+ n = scandir("/dev", &devices, nvme_namespace_filter, alphasort);
if (n <= 0)
return n;