static int cui_boot(struct pmenu_item *item) { int result; struct cui *cui = cui_from_item(item); struct cui_opt_data *cod = cod_from_item(item); assert(cui->current == &cui->main->scr); pb_debug("%s: %s\n", __func__, cod->name); nc_scr_status_printf(cui->current, _("Booting %s..."), cod->name); result = discover_client_boot(cui->client, NULL, cod->opt, cod->bd); if (result) { nc_scr_status_printf(cui->current, _("Failed: boot %s"), cod->bd->image); } return 0; }
struct boot_editor *boot_editor_init(struct cui *cui, struct pmenu_item *item, const struct system_info *sysinfo, void (*on_exit)(struct cui *cui, struct pmenu_item *item, struct pb_boot_data *bd)) { struct boot_editor *boot_editor; boot_editor = talloc_zero(cui, struct boot_editor); if (!boot_editor) return NULL; talloc_set_destructor(boot_editor, boot_editor_destructor); boot_editor->cui = cui; boot_editor->item = item; boot_editor->on_exit = on_exit; boot_editor->state = STATE_EDIT; boot_editor->need_redraw = false; boot_editor->need_update = false; int ncols1 = strncols(_("Device tree:")); int ncols2 = strncols(_("Boot arguments:")); boot_editor->label_x = 1; boot_editor->field_x = 2 + max(ncols1, ncols2); nc_scr_init(&boot_editor->scr, pb_boot_editor_sig, 0, cui, boot_editor_process_key, boot_editor_post, boot_editor_unpost, boot_editor_resize); boot_editor->scr.frame.ltitle = talloc_strdup(boot_editor, _("Petitboot Option Editor")); boot_editor->scr.frame.rtitle = NULL; boot_editor->scr.frame.help = talloc_strdup(boot_editor, _("tab=next, shift+tab=previous, x=exit, h=help")); nc_scr_frame_draw(&boot_editor->scr); if (item) { struct pb_boot_data *bd = cod_from_item(item)->bd; boot_editor->image = bd->image; boot_editor->initrd = bd->initrd; boot_editor->dtb = bd->dtb; boot_editor->args = bd->args; boot_editor_find_device(boot_editor, bd, sysinfo); } else { boot_editor->image = boot_editor->initrd = boot_editor->dtb = boot_editor->args = ""; } boot_editor->pad = newpad( pad_height(sysinfo ? sysinfo->n_blockdevs : 0), COLS); boot_editor_setup_widgets(boot_editor, sysinfo); boot_editor_layout_widgets(boot_editor); wrefresh(boot_editor->scr.main_ncw); return boot_editor; }