summaryrefslogtreecommitdiff
path: root/disk
diff options
context:
space:
mode:
Diffstat (limited to 'disk')
-rw-r--r--disk/part.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/disk/part.c b/disk/part.c
index f0afd89..ed6bbe2 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -443,6 +443,28 @@ int get_partition_info(block_dev_desc_t *dev_desc, int part
return -1;
}
+int get_device(const char *ifname, const char *dev_str,
+ block_dev_desc_t **dev_desc)
+{
+ char *ep;
+ int dev;
+
+ dev = simple_strtoul(dev_str, &ep, 16);
+ if (*ep) {
+ printf("** Bad device specification %s %s **\n",
+ ifname, dev_str);
+ return -1;
+ }
+
+ *dev_desc = get_dev(ifname, dev);
+ if (!(*dev_desc) || ((*dev_desc)->type == DEV_TYPE_UNKNOWN)) {
+ printf("** Bad device %s %s **\n", ifname, dev_str);
+ return -1;
+ }
+
+ return dev;
+}
+
int get_device_and_partition(const char *ifname, const char *dev_str,
block_dev_desc_t **dev_desc,
disk_partition_t *info)