huawei: filter out the partition disks
PATCH 1/1 huawei: filter out the partition disks
When using "nvme huawei list" command, if the current disk has partitions, disk partitions will be displayed. This is not expected!
So filter out the disk partitions through disk name.
--- plugins/huawei/huawei-nvme.c | 4 ++++ 1 file changed, 4 insertions(+)
plugins/huawei/huawei-nvme.c +4 -0
@@ -296,6 +296,8 @@ static int huawei_list(int argc, char **argv, struct command *command,unsigned int i, n, fd, ret;unsigned int huawei_num =0 ;int fmt; +int ctrl, ns, part; +const char *desc ="Retrieve basic information for the given huawei device" ;struct config {char *output_format;
@@ -326,6 +328,8 @@ static int huawei_list(int argc, char **argv, struct command *command, }for (i =0 ; i < n; i++) { +if (sscanf (devices[i]->d_name,"nvme%dn%dp%d" , &ctrl, &ns, &part) ==3 ) +continue ;snprintf (path,sizeof (path),"/dev/%s" , devices[i]->d_name); fd =open (path,O_RDONLY ); ret =huawei_get_nvme_info (fd, &list_items[huawei_num], path);
Signature · 1 line
2.21.0.windows.1
ping
Quoted 31 lines · chengjike
When using "nvme huawei list" command, if the current disk has partitions, disk partitions will be displayed. This is not expected!
So filter out the disk partitions through disk name.Signed-off-by chengjike <[email protected]>--- plugins/huawei/huawei-nvme.c | 4 ++++ 1 file changed, 4 insertions(+)plugins/huawei/huawei-nvme.c +4
-0@@ -296,6 +296,8 @@ static int huawei_list(int argc, char **argv, struct command *command,unsigned int i, n, fd, ret;unsigned int huawei_num =0 ;int fmt; +int ctrl, ns, part; +const char *desc ="Retrieve basic information for the given huawei device" ;struct config {char *output_format;@@ -326,6 +328,8 @@ static int huawei_list(int argc, char **argv, struct command *command, }for (i =0 ; i < n; i++) { +if (sscanf (devices[i]->d_name,"nvme%dn%dp%d" , &ctrl, &ns, &part) ==3 ) +continue ;snprintf (path,sizeof (path),"/dev/%s" , devices[i]->d_name); fd =open (path,O_RDONLY ); ret =huawei_get_nvme_info (fd, &list_items[huawei_num], path);
Quoted 4 lines · chengjike
When using "nvme huawei list" command, if the current disk has partitions, disk partitions will be displayed. This is not expected!
So filter out the disk partitions through disk name.
Is this specific to the Huawei or generic to all the vendors ?
Quoted 8 lines · Chaitanya Kulkarni
Quoted 4 lines · chengjike
When using "nvme huawei list" command, if the current disk has partitions, disk partitions will be displayed. This is not expected!
So filter out the disk partitions through disk name.Is this specific to the Huawei or generic to all the vendors ?
This is a fix patch for huawei, and other vendors don't have this problem.
When the following patch is merged(when replace huawei_scan_dev_filter with scan_dev_filter, the codes of partition filtering are deleted), it has this issue.
nvme-cli: Code reorg
commit: a3b3e93286a30852b7973a524b47ef35d42aa6cf