summaryrefslogtreecommitdiffstats
path: root/lib/libefi
diff options
context:
space:
mode:
authortimor <[email protected]>2018-03-21 16:35:20 +0100
committerTony Hutter <[email protected]>2018-05-07 17:19:56 -0700
commit6e627cc46819aa7c5e612417866c4210a28359b1 (patch)
tree091d2424dba9bff6bb255a9bd38596181445bef8 /lib/libefi
parent3eb3a13628d3d58b0294e4e0c0e3b47483a4053e (diff)
Add support for nvme disk detection
This treats /dev/nvme.. devices the same way as /dev/sd... devices. The motivation behind this is that whole disk detection did not work on nvme SSDs without that, because it DKC_UNKNOWN was returned for such devices. Perhaps there should be a separate DKC_ type for this, but I don't know enough about the code to know the implications of that. Reviewed-by: Don Brady <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: timor <[email protected]> Closes #7304
Diffstat (limited to 'lib/libefi')
-rw-r--r--lib/libefi/rdwr_efi.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/libefi/rdwr_efi.c b/lib/libefi/rdwr_efi.c
index e9fb15ee2..7935047eb 100644
--- a/lib/libefi/rdwr_efi.c
+++ b/lib/libefi/rdwr_efi.c
@@ -300,6 +300,20 @@ efi_get_info(int fd, struct dk_cinfo *dki_info)
rval = sscanf(dev_path, "/dev/loop%[0-9]p%hu",
dki_info->dki_dname + 4,
&dki_info->dki_partition);
+ } else if ((strncmp(dev_path, "/dev/nvme", 9) == 0)) {
+ strcpy(dki_info->dki_cname, "nvme");
+ dki_info->dki_ctype = DKC_SCSI_CCS;
+ strcpy(dki_info->dki_dname, "nvme");
+ (void) sscanf(dev_path, "/dev/nvme%[0-9]",
+ dki_info->dki_dname + 4);
+ size_t controller_length = strlen(
+ dki_info->dki_dname);
+ strcpy(dki_info->dki_dname + controller_length,
+ "n");
+ rval = sscanf(dev_path,
+ "/dev/nvme%*[0-9]n%[0-9]p%hu",
+ dki_info->dki_dname + controller_length + 1,
+ &dki_info->dki_partition);
} else {
strcpy(dki_info->dki_dname, "unknown");
strcpy(dki_info->dki_cname, "unknown");