From a1c3d8f29fc3cf1b03d8e07d58c6ed902355775f Mon Sep 17 00:00:00 2001 From: Pascal Terjan Date: Fri, 12 Jun 2020 18:03:11 +0000 Subject: Make the NVME code more generic --- mdk-stage1/probing.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'mdk-stage1') diff --git a/mdk-stage1/probing.c b/mdk-stage1/probing.c index c140d2604..d97ecce69 100644 --- a/mdk-stage1/probing.c +++ b/mdk-stage1/probing.c @@ -905,13 +905,11 @@ void find_media(enum media_bus bus) } } /* ----------------------------------------------- */ - /* TODO: This code is generic for any block device, we should switch to only use it - * and add some support to check capabilities and type. - * The glob can not be changed before removing the rest of the code or disks would be listed twice. - * */ - log_message("looking for NVME"); + log_message("looking for other disks"); { glob_t globbuf; + // TODO: We should switch everything to here, and later switch to ignoring + // some types of disks (ram, loop, ...) rather than a list to accept. glob("/sys/block/nvme*", 0, NULL, &globbuf); for (int i = 0; i < globbuf.gl_pathc; i++) { @@ -924,7 +922,20 @@ void find_media(enum media_bus bus) name = strdup(path + 11); pathend = path + strlen(path); - strcpy(model, "Unknown NVME Disk"); + // Check if this device had been handled by other code + int exists = 0; + for (int j = 0; j < count; j++) { + if (!strcmp(name, tmp[j].name)) { + exists = 1; + break; + } + } + if (exists) { + free(name); + continue; + } + + strcpy(model, "Unknown Disk"); strcpy(pathend, "/device/vendor"); vendor_length = read_attribute(path, model); -- cgit v1.2.1