X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=discover%2Fdevice-handler.c;h=8ad885f68225c031efc6de9b0b9f570776a53662;hp=4e1b3ca77fc0f447bfd0febfdf66db22c7121ed6;hb=c916e133367688075f568fed390b625b9325c68b;hpb=b9b5fa357e5921eb752e62f7146339007d9f767f 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);