From 5094354c390d755ff49f9b5d7510286ba176c6cc Mon Sep 17 00:00:00 2001 From: Alexander Egorenkov Date: Wed, 18 Aug 2021 08:25:25 +0200 Subject: [PATCH] zipl: Implement helper function disk_is_nvme() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The new function disk_is_nvme() is a convenience function that indicates whether the given path to a device file represents a NVMe disk. Signed-off-by: Alexander Egorenkov Reviewed-by: Marc Hartmayer Acked-by: Stefan Haberland Acked-by: Alexander Gordeev Signed-off-by: Jan Höppner --- zipl/include/disk.h | 1 + zipl/src/disk.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/zipl/include/disk.h b/zipl/include/disk.h index 4280aa7c..bb7f9f82 100644 --- a/zipl/include/disk.h +++ b/zipl/include/disk.h @@ -102,6 +102,7 @@ int disk_get_info(const char* device, struct job_target_data* target, struct disk_info** info); int disk_is_tape(const char* device); int disk_is_scsi(const char* device, struct job_target_data* target); +int disk_is_nvme(const char* device, struct job_target_data* target); int disk_get_info_from_file(const char* filename, struct job_target_data* target, struct disk_info** info); diff --git a/zipl/src/disk.c b/zipl/src/disk.c index 52e55286..144f3b94 100644 --- a/zipl/src/disk.c +++ b/zipl/src/disk.c @@ -508,6 +508,20 @@ disk_is_scsi(const char* device, struct job_target_data* target) return rc; } +int +disk_is_nvme(const char* device, struct job_target_data* target) +{ + struct disk_info* info; + int rc = 0; + + if (disk_get_info(device, target, &info) == -1) + return 0; + if (info->type == disk_type_scsi && info->is_nvme) + rc = 1; + disk_free_info(info); + return rc; +} + int disk_get_info_from_file(const char* filename, struct job_target_data* target, struct disk_info** info)