summaryrefslogtreecommitdiffstats
path: root/discover
diff options
context:
space:
mode:
authorSamuel Mendoza-Jonas <sam.mj@au1.ibm.com>2015-08-21 15:18:48 +1000
committerSamuel Mendoza-Jonas <sam.mj@au1.ibm.com>2015-08-31 14:58:14 +1000
commit70907c3fc4b344d00ce900e6a536e9cc16a35216 (patch)
treed723cafda2c6f32675c9e1ff52c55bce283e4aa5 /discover
parent74ca9eaf3d0dd64560c3eaa132df2e854b51bcdd (diff)
downloadtalos-petitboot-70907c3fc4b344d00ce900e6a536e9cc16a35216.tar.gz
talos-petitboot-70907c3fc4b344d00ce900e6a536e9cc16a35216.zip
Recognise storage devices on USB bus
Users may want to prioritise USB-attached storage devices differently to other devices. Detect if a device is USB-attached and add a new device type to identify it. Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
Diffstat (limited to 'discover')
-rw-r--r--discover/device-handler.c1
-rw-r--r--discover/udev.c12
2 files changed, 10 insertions, 3 deletions
diff --git a/discover/device-handler.c b/discover/device-handler.c
index 4f7a7b7..9246f0d 100644
--- a/discover/device-handler.c
+++ b/discover/device-handler.c
@@ -457,6 +457,7 @@ struct {
} device_type_map[] = {
{ IPMI_BOOTDEV_NETWORK, DEVICE_TYPE_NETWORK },
{ IPMI_BOOTDEV_DISK, DEVICE_TYPE_DISK },
+ { IPMI_BOOTDEV_DISK, DEVICE_TYPE_USB },
{ IPMI_BOOTDEV_CDROM, DEVICE_TYPE_OPTICAL },
};
diff --git a/discover/udev.c b/discover/udev.c
index 87a3748..6cc718e 100644
--- a/discover/udev.c
+++ b/discover/udev.c
@@ -88,7 +88,7 @@ static int udev_handle_block_add(struct pb_udev *udev, struct udev_device *dev,
"LVM2_member",
NULL,
};
- bool cdrom;
+ bool cdrom, usb;
typestr = udev_device_get_devtype(dev);
if (!typestr) {
@@ -167,12 +167,18 @@ static int udev_handle_block_add(struct pb_udev *udev, struct udev_device *dev,
prop = udev_device_get_property_value(dev, "ID_FS_LABEL");
if (prop)
ddev->label = talloc_strdup(ddev, prop);
- ddev->device->type = cdrom ? DEVICE_TYPE_OPTICAL : DEVICE_TYPE_DISK;
+
+ usb = !!udev_device_get_property_value(dev, "ID_USB_DRIVER");
+ if (cdrom)
+ ddev->device->type = DEVICE_TYPE_OPTICAL;
+ else
+ ddev->device->type = usb ? DEVICE_TYPE_USB : DEVICE_TYPE_DISK;
udev_setup_device_params(dev, ddev);
/* Create a snapshot for all disks, unless it is an assembled RAID array */
- if (ddev->device->type == DEVICE_TYPE_DISK &&
+ if ((ddev->device->type == DEVICE_TYPE_DISK ||
+ ddev->device->type == DEVICE_TYPE_USB) &&
!udev_device_get_property_value(dev, "MD_LEVEL"))
devmapper_init_snapshot(udev->handler, ddev);
OpenPOWER on IntegriCloud