From patchwork Wed Jun 8 06:28:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Mendoza-Jonas X-Patchwork-Id: 631985 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rPdnB09f2z9sCg for ; Wed, 8 Jun 2016 16:29:02 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b=LsE+ZjtX; dkim-atps=neutral Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3rPdn965kRzDqHH for ; Wed, 8 Jun 2016 16:29:01 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b=LsE+ZjtX; dkim-atps=neutral X-Original-To: petitboot@lists.ozlabs.org Delivered-To: petitboot@lists.ozlabs.org Received: from mendozajonas.com (mendozajonas.com [188.166.185.233]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3rPdmf6CJ1zDq5v for ; Wed, 8 Jun 2016 16:28:34 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b=LsE+ZjtX; dkim-atps=neutral Received: from skellige.ozlabs.ibm.com (unknown [122.99.82.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: sam@mendozajonas.com) by mendozajonas.com (Postfix) with ESMTPSA id 221471442E6 for ; Wed, 8 Jun 2016 14:28:27 +0800 (SGT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mendozajonas.com; s=mail; t=1465367308; bh=GQvsXfyE9SLK7Spc8xMjpqybyZa7Vu53eYWNG3HD0c0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=LsE+ZjtXl0BHKWsa9gHzedqQhQd6N0OpTvY2uIgt80b1GSThIlQhHD6xQhpUzgjTr m6GdwtGL7Sv0/cbqnwRQwuHDDqWAp+XUfv6/ro5AhStHY1EEnuvXavdLaXgjw7Xfso Eiy+U+AZRABfHOBq4BUYHXI2YgVeaDdLWJB0oSjQ= From: Samuel Mendoza-Jonas To: petitboot@lists.ozlabs.org Subject: [PATCH 5/6] ui/ncurses: List available consoles in nc-config Date: Wed, 8 Jun 2016 16:28:11 +1000 Message-Id: <20160608062812.14480-6-sam@mendozajonas.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20160608062812.14480-1-sam@mendozajonas.com> References: <20160608062812.14480-1-sam@mendozajonas.com> X-BeenThere: petitboot@lists.ozlabs.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Petitboot bootloader development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" Include a list of available consoles as specified by the discover server in nc-config from which the user can select a default. The selected console specifies the which console to be set as the primary console when a kernel is kexec'd. Signed-off-by: Samuel Mendoza-Jonas --- ui/ncurses/nc-config.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/ui/ncurses/nc-config.c b/ui/ncurses/nc-config.c index 66ca7a4..724fcae 100644 --- a/ui/ncurses/nc-config.c +++ b/ui/ncurses/nc-config.c @@ -33,7 +33,7 @@ #include "nc-config.h" #include "nc-widgets.h" -#define N_FIELDS 39 +#define N_FIELDS 42 extern struct help_text config_help_text; @@ -108,6 +108,9 @@ struct config_screen { struct nc_widget_label *allow_write_l; struct nc_widget_select *allow_write_f; + struct nc_widget_label *boot_tty_l; + struct nc_widget_select *boot_tty_f; + struct nc_widget_label *current_tty_l; struct nc_widget_label *safe_mode; struct nc_widget_button *ok_b; @@ -197,7 +200,7 @@ static int screen_process_form(struct config_screen *screen) char *str, *end; struct config *config; int i, n_boot_opts, rc, idx; - unsigned int *order; + unsigned int *order, tty; char mac[20]; config = config_copy(screen, screen->cui->config); @@ -333,6 +336,19 @@ static int screen_process_form(struct config_screen *screen) if (allow_write != config->allow_writes) config->allow_writes = allow_write; + if (config->n_tty) { + tty = widget_select_get_value(screen->widgets.boot_tty_f); + if (!config->boot_tty) { + config->boot_tty = talloc_strdup(config, + config->tty_list[tty]); + } else if (strncmp(config->boot_tty, config->tty_list[tty], + strlen(config->boot_tty)) != 0) { + talloc_free(config->boot_tty); + config->boot_tty = talloc_strdup(config, + config->tty_list[tty]); + } + } + config->safe_mode = false; rc = cui_send_config(screen->cui, config); talloc_free(config); @@ -579,6 +595,22 @@ static void config_screen_layout_widgets(struct config_screen *screen) y += 1; + if (widget_height(widget_select_base(screen->widgets.boot_tty_f))) { + layout_pair(screen, y, screen->widgets.boot_tty_l, + widget_select_base(screen->widgets.boot_tty_f)); + y += widget_height(widget_select_base(screen->widgets.boot_tty_f)); + widget_move(widget_label_base(screen->widgets.current_tty_l), + y, screen->field_x); + y += 2; + } else { + widget_set_visible(widget_label_base( + screen->widgets.boot_tty_l), false); + widget_set_visible(widget_select_base( + screen->widgets.boot_tty_f), false); + widget_set_visible(widget_label_base( + screen->widgets.current_tty_l), false); + } + widget_move(widget_button_base(screen->widgets.ok_b), y, screen->field_x); widget_move(widget_button_base(screen->widgets.help_b), @@ -740,10 +772,11 @@ static void config_screen_setup_widgets(struct config_screen *screen, { struct nc_widgetset *set = screen->widgetset; struct interface_config *ifcfg; - char *str, *ip, *mask, *gw, *url; + char *str, *ip, *mask, *gw, *url, *tty; enum net_conf_type type; unsigned int i; int add_len, clear_len, any_len, min_len = 20; + bool found; build_assert(sizeof(screen->widgets) / sizeof(struct widget *) == N_FIELDS); @@ -986,6 +1019,22 @@ static void config_screen_setup_widgets(struct config_screen *screen, _("Allow bootloader scripts to modify disks"), config->allow_writes); + screen->widgets.boot_tty_l = widget_new_label(set, 0, 0, + _("Default tty:")); + screen->widgets.boot_tty_f = widget_new_select(set, 0, 0, + COLS - screen->field_x - 1); + + for (i = 0; i < config->n_tty; i++){ + found = strncmp(config->tty_list[i], config->boot_tty, + strlen(config->tty_list[i])) == 0; + widget_select_add_option(screen->widgets.boot_tty_f, i, + config->tty_list[i], found); + } + + tty = talloc_asprintf(screen, _("Current interface: %s"), + ttyname(STDIN_FILENO)); + screen->widgets.current_tty_l = widget_new_label(set, 0 , 0, tty); + screen->widgets.ok_b = widget_new_button(set, 0, 0, 10, _("OK"), ok_click, screen); screen->widgets.help_b = widget_new_button(set, 0, 0, 10, _("Help"),