+ boot(handler, opt, cmd, handler->dry_run, boot_status, handler);
+}
+
+void device_handler_cancel_default(struct device_handler *handler)
+{
+ struct boot_status status;
+
+ if (handler->timeout_waiter)
+ waiter_remove(handler->timeout_waiter);
+
+ handler->timeout_waiter = NULL;
+ handler->autoboot_enabled = false;
+
+ /* we only send status if we had a default boot option queued */
+ if (!handler->default_boot_option)
+ return;
+
+ pb_log("Cancelling default boot option\n");
+
+ handler->default_boot_option = NULL;
+
+ status.type = BOOT_STATUS_INFO;
+ status.progress = -1;
+ status.detail = NULL;
+ status.message = "Default boot cancelled";
+
+ discover_server_notify_boot_status(handler->server, &status);
+}
+
+#ifndef PETITBOOT_TEST
+static int mount_device(struct discover_device *dev)
+{
+ int rc;
+
+ if (!dev->device_path)
+ return -1;
+
+ if (!dev->mount_path)
+ dev->mount_path = join_paths(dev, mount_base(),
+ dev->device_path);
+
+ if (pb_mkdir_recursive(dev->mount_path))
+ pb_log("couldn't create mount directory %s: %s\n",
+ dev->mount_path, strerror(errno));
+
+ rc = process_run_simple(dev, pb_system_apps.mount,
+ dev->device_path, dev->mount_path,
+ "-o", "ro", NULL);
+
+ if (!rc)
+ return 0;
+
+ /* Retry mount without ro option. */
+ rc = process_run_simple(dev, pb_system_apps.mount,
+ dev->device_path, dev->mount_path, NULL);
+
+ if (!rc)
+ return 0;
+
+ pb_rmdir_recursive(mount_base(), dev->mount_path);
+ return -1;
+}
+
+static int umount_device(struct discover_device *dev)
+{
+ int status;
+
+ if (!dev->mount_path)
+ return 0;
+
+ status = process_run_simple(dev, pb_system_apps.umount,
+ dev->mount_path, NULL);
+
+ if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
+ return -1;
+
+ pb_rmdir_recursive(mount_base(), dev->mount_path);
+
+ return 0;
+}
+#else
+
+static int umount_device(struct discover_device *dev __attribute__((unused)))
+{
+ return 0;