summaryrefslogtreecommitdiffstats
path: root/discover/device-handler.c
diff options
context:
space:
mode:
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>2017-10-10 13:24:48 +1100
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>2017-10-12 10:31:02 +1100
commitc62ae29ecbc248527a03578fa18e1b6b93506965 (patch)
tree18d20545a196522132e2812be2516f53bb6613f4 /discover/device-handler.c
parenteac7fc04e7ce07f6b1a6a0d19af86ae7f74ebc5e (diff)
downloadtalos-petitboot-c62ae29ecbc248527a03578fa18e1b6b93506965.tar.gz
talos-petitboot-c62ae29ecbc248527a03578fa18e1b6b93506965.zip
discover/device-handler: Fallback to device if snapshot fails to mountv1.6.1
In the event that a snapshot fails to mount, destroy it and fall back to the actual source device. While this loses the protection afforded by a snapshot it avoids users being greeted with an empty boot menu and unable to continue booting. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Diffstat (limited to 'discover/device-handler.c')
-rw-r--r--discover/device-handler.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/discover/device-handler.c b/discover/device-handler.c
index 4e1b3ca..8ad885f 100644
--- a/discover/device-handler.c
+++ b/discover/device-handler.c
@@ -1792,6 +1792,20 @@ static int mount_device(struct discover_device *dev)
rc = try_mount(device_path, dev->mount_path, fstype,
MS_RDONLY | MS_SILENT, dev->ramdisk);
+ /* If mount fails clean up any snapshot and try again */
+ if (rc && dev->ramdisk) {
+ pb_log("couldn't mount snapshot for %s: mount failed: %s\n",
+ device_path, strerror(errno));
+ pb_log("falling back to actual device\n");
+
+ devmapper_destroy_snapshot(dev);
+
+ device_path = get_device_path(dev);
+ pb_log("mounting device %s read-only\n", dev->device_path);
+ rc = try_mount(device_path, dev->mount_path, fstype,
+ MS_RDONLY | MS_SILENT, dev->ramdisk);
+ }
+
if (!rc) {
dev->mounted = true;
dev->mounted_rw = false;
@@ -1803,9 +1817,6 @@ static int mount_device(struct discover_device *dev)
pb_log("couldn't mount device %s: mount failed: %s\n",
device_path, strerror(errno));
- /* If mount fails clean up any snapshot */
- devmapper_destroy_snapshot(dev);
-
pb_rmdir_recursive(mount_base(), dev->mount_path);
err_free:
talloc_free(dev->mount_path);
OpenPOWER on IntegriCloud