Patchwork [08/10] blockdev: New drive_get_by_index()

login
register
mail settings
Submitter Markus Armbruster
Date Jan. 27, 2011, 12:29 p.m.
Message ID <1296131356-27257-9-git-send-email-armbru@redhat.com>
Download mbox | patch
Permalink /patch/80661/
State New
Headers show

Comments

Markus Armbruster - Jan. 27, 2011, 12:29 p.m.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 blockdev.c |    7 +++++++
 blockdev.h |    1 +
 2 files changed, 8 insertions(+), 0 deletions(-)

Patch

diff --git a/blockdev.c b/blockdev.c
index 4d8bb3d..08c9d7e 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -116,6 +116,13 @@  DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit)
     return NULL;
 }
 
+DriveInfo *drive_get_by_index(BlockInterfaceType type, int index)
+{
+    return drive_get(type,
+                     drive_index_to_bus_id(type, index),
+                     drive_index_to_unit_id(type, index));
+}
+
 int drive_get_max_bus(BlockInterfaceType type)
 {
     int max_bus;
diff --git a/blockdev.h b/blockdev.h
index e29fa5e..2d518c5 100644
--- a/blockdev.h
+++ b/blockdev.h
@@ -42,6 +42,7 @@  struct DriveInfo {
 #define MAX_SCSI_DEVS	255
 
 DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit);
+DriveInfo *drive_get_by_index(BlockInterfaceType type, int index);
 int drive_get_max_bus(BlockInterfaceType type);
 DriveInfo *drive_get_next(BlockInterfaceType type);
 void drive_uninit(DriveInfo *dinfo);