summaryrefslogtreecommitdiffstats
path: root/discover/udev.c
diff options
context:
space:
mode:
authorSamuel Mendoza-Jonas <sam.mj@au1.ibm.com>2015-05-13 17:06:01 +1000
committerSamuel Mendoza-Jonas <sam.mj@au1.ibm.com>2015-08-06 14:08:30 +1000
commit79bfd11f662fcf46bd4ae58a0aab993cbe158dbe (patch)
treee8b2b44b64c59c5573559314d985b0d0e0c7a414 /discover/udev.c
parent754c0737db6b7337f1d3b40e6e52d9c3abec954f (diff)
downloadtalos-petitboot-79bfd11f662fcf46bd4ae58a0aab993cbe158dbe.tar.gz
talos-petitboot-79bfd11f662fcf46bd4ae58a0aab993cbe158dbe.zip
discover: Mount snapshots for all eligible disk devices
Device-mapper snapshots are created for all disk devices prior to being mounted. If explicit writes are made to the snapshot they are merged back to the disk once write access is released. Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
Diffstat (limited to 'discover/udev.c')
-rw-r--r--discover/udev.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/discover/udev.c b/discover/udev.c
index 6ccb8d4..75393d5 100644
--- a/discover/udev.c
+++ b/discover/udev.c
@@ -25,6 +25,7 @@
#include "pb-discover.h"
#include "device-handler.h"
#include "cdrom.h"
+#include "devmapper.h"
/* We set a default monitor buffer size, as we may not process monitor
* events while performing device discvoery. systemd uses a 128M buffer, so
@@ -94,12 +95,16 @@ static int udev_handle_block_add(struct pb_udev *udev, struct udev_device *dev,
node = udev_device_get_devnode(dev);
path = udev_device_get_devpath(dev);
- if (path && (strstr(path, "virtual/block/loop")
- || strstr(path, "virtual/block/ram"))) {
+ if (path && strstr(path, "virtual/block/loop")) {
pb_log("SKIP: %s: ignored (path=%s)\n", name, path);
return 0;
}
+ if (path && strstr(path, "virtual/block/ram")) {
+ device_handler_add_ramdisk(udev->handler, node);
+ return 0;
+ }
+
cdrom = node && !!udev_device_get_property_value(dev, "ID_CDROM");
if (cdrom) {
/* CDROMs require a little initialisation, to get
@@ -111,6 +116,14 @@ static int udev_handle_block_add(struct pb_udev *udev, struct udev_device *dev,
}
}
+ /* If our environment's udev can recognise them explictly skip any
+ * device mapper devices we encounter */
+ const char *devname = udev_device_get_property_value(dev, "DM_NAME");
+ if (devname) {
+ pb_log("SKIP: dm-device %s\n", devname);
+ return 0;
+ }
+
type = udev_device_get_property_value(dev, "ID_FS_TYPE");
if (!type) {
pb_log("SKIP: %s: no ID_FS_TYPE property\n", name);
@@ -142,6 +155,9 @@ static int udev_handle_block_add(struct pb_udev *udev, struct udev_device *dev,
udev_setup_device_params(dev, ddev);
+ if (ddev->device->type == DEVICE_TYPE_DISK)
+ devmapper_init_snapshot(udev->handler, ddev);
+
device_handler_discover(udev->handler, ddev);
return 0;
OpenPOWER on IntegriCloud