diff options
-rw-r--r-- | discover/boot.c | 8 | ||||
-rw-r--r-- | discover/platform-powerpc.c | 13 | ||||
-rw-r--r-- | discover/platform.c | 2 | ||||
-rw-r--r-- | lib/pb-config/pb-config.c | 1 | ||||
-rw-r--r-- | lib/pb-protocol/pb-protocol.c | 7 | ||||
-rw-r--r-- | lib/types/types.h | 1 | ||||
-rw-r--r-- | ui/ncurses/nc-config.c | 27 | ||||
-rw-r--r-- | utils/Makefile.am | 3 | ||||
-rw-r--r-- | utils/hooks/30-add-offb.c | 5 | ||||
-rwxr-xr-x | utils/hooks/80-set-stdout | 23 |
10 files changed, 48 insertions, 42 deletions
diff --git a/discover/boot.c b/discover/boot.c index 0732a50..dc6da7d 100644 --- a/discover/boot.c +++ b/discover/boot.c @@ -517,7 +517,7 @@ struct boot_task *boot(void *ctx, struct discover_boot_option *opt, struct pb_url *image = NULL, *initrd = NULL, *dtb = NULL; struct pb_url *image_sig = NULL, *initrd_sig = NULL, *dtb_sig = NULL, *cmdline_sig = NULL; - const struct config *config; + const struct config *config = config_get(); struct boot_task *boot_task; const char *boot_desc; int rc; @@ -574,12 +574,10 @@ struct boot_task *boot(void *ctx, struct discover_boot_option *opt, boot_task->args = NULL; } - if (cmd && cmd->console) + if (cmd && cmd->console && !config->manual_console) boot_task->boot_console = talloc_strdup(boot_task, cmd->console); - else { - config = config_get(); + else boot_task->boot_console = config ? config->boot_console : NULL; - } if (boot_task->verify_signature || boot_task->decrypt_files) { if (cmd && cmd->args_sig_file) { diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c index 57618c3..a4b13e4 100644 --- a/discover/platform-powerpc.c +++ b/discover/platform-powerpc.c @@ -59,7 +59,7 @@ static const char *known_params[] = { "petitboot,debug?", "petitboot,write?", "petitboot,snapshots?", - "petitboot,tty", + "petitboot,console", NULL, }; @@ -567,9 +567,12 @@ static void populate_config(struct platform_powerpc *platform, if (val) config->disable_snapshots = !strcmp(val, "false"); - val = get_param(platform, "petitboot,tty"); + val = get_param(platform, "petitboot,console"); if (val) config->boot_console = talloc_strdup(config, val); + /* If a full path is already set we don't want to override it */ + config->manual_console = config->boot_console && + !strchr(config->boot_console, '['); } static char *iface_config_str(void *ctx, struct interface_config *config) @@ -746,8 +749,10 @@ static int update_config(struct platform_powerpc *platform, val = config->allow_writes ? "true" : "false"; update_string_config(platform, "petitboot,write?", val); - val = config->boot_console ?: ""; - update_string_config(platform, "petitboot,tty", val); + if (!config->manual_console) { + val = config->boot_console ?: ""; + update_string_config(platform, "petitboot,console", val); + } update_network_config(platform, config); diff --git a/discover/platform.c b/discover/platform.c index 95a905d..93cd057 100644 --- a/discover/platform.c +++ b/discover/platform.c @@ -84,6 +84,8 @@ static void dump_config(struct config *config) pb_log(" Default UI to boot on: %s\n", config->boot_console ?: "none set"); + if (config->manual_console) + pb_log(" (Manually set)\n"); pb_log(" language: %s\n", config->lang ?: ""); diff --git a/lib/pb-config/pb-config.c b/lib/pb-config/pb-config.c index 86f14c9..2f9af28 100644 --- a/lib/pb-config/pb-config.c +++ b/lib/pb-config/pb-config.c @@ -92,6 +92,7 @@ struct config *config_copy(void *ctx, const struct config *src) if (src->boot_console) dest->boot_console = talloc_strdup(dest, src->boot_console); + dest->manual_console = src->manual_console; if (src->lang && strlen(src->lang)) dest->lang = talloc_strdup(dest, src->lang); diff --git a/lib/pb-protocol/pb-protocol.c b/lib/pb-protocol/pb-protocol.c index 0d83bde..47d04a3 100644 --- a/lib/pb-protocol/pb-protocol.c +++ b/lib/pb-protocol/pb-protocol.c @@ -323,6 +323,7 @@ int pb_protocol_config_len(const struct config *config) len += 4 + optional_strlen(config->consoles[i]); len += 4 + optional_strlen(config->boot_console); + len += 4; /* manual_console */ len += 4 + optional_strlen(config->lang); @@ -579,6 +580,8 @@ int pb_protocol_serialise_config(const struct config *config, pos += pb_protocol_serialise_string(pos, config->consoles[i]); pos += pb_protocol_serialise_string(pos, config->boot_console); + *(uint32_t *)pos = config->manual_console; + pos += 4; pos += pb_protocol_serialise_string(pos, config->lang); @@ -1124,6 +1127,10 @@ int pb_protocol_deserialise_config(struct config *config, config->boot_console = str; + if (read_u32(&pos, &len, &tmp)) + goto out; + config->manual_console = !!tmp; + if (read_string(config, &pos, &len, &str)) goto out; diff --git a/lib/types/types.h b/lib/types/types.h index b7430f4..31922d0 100644 --- a/lib/types/types.h +++ b/lib/types/types.h @@ -164,6 +164,7 @@ struct config { bool allow_writes; char *boot_console; + bool manual_console; char *lang; /* not user-settable */ diff --git a/ui/ncurses/nc-config.c b/ui/ncurses/nc-config.c index c668bde..1bc77e8 100644 --- a/ui/ncurses/nc-config.c +++ b/ui/ncurses/nc-config.c @@ -111,6 +111,7 @@ struct config_screen { struct nc_widget_select *allow_write_f; struct nc_widget_label *boot_console_l; struct nc_widget_select *boot_console_f; + struct nc_widget_label *manual_console_l; struct nc_widget_label *current_console_l; struct nc_widget_label *net_override_l; @@ -338,7 +339,7 @@ static int screen_process_form(struct config_screen *screen) if (allow_write != config->allow_writes) config->allow_writes = allow_write; - if (config->n_consoles) { + if (config->n_consoles && !config->manual_console) { idx = widget_select_get_value(screen->widgets.boot_console_f); if (!config->boot_console) { config->boot_console = talloc_strdup(config, @@ -592,7 +593,15 @@ static void config_screen_layout_widgets(struct config_screen *screen) y += 1; - if (widget_height(widget_select_base(screen->widgets.boot_console_f))) { + if (screen->widgets.manual_console_l) { + layout_pair(screen, y++, screen->widgets.boot_console_l, + widget_label_base(screen->widgets.manual_console_l)); + widget_move(widget_label_base(screen->widgets.current_console_l), + y, screen->field_x); + widget_set_visible(widget_select_base( + screen->widgets.boot_console_f), false); + y += 2; + } else if (widget_height(widget_select_base(screen->widgets.boot_console_f))) { layout_pair(screen, y, screen->widgets.boot_console_l, widget_select_base(screen->widgets.boot_console_f)); y += widget_height(widget_select_base(screen->widgets.boot_console_f)); @@ -785,7 +794,7 @@ 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, *tty; + char *str, *ip, *mask, *gw, *url, *tty, *label; enum net_conf_type type; unsigned int i; int add_len, clear_len, any_len, min_len = 20; @@ -841,7 +850,6 @@ static void config_screen_setup_widgets(struct config_screen *screen, for (i = 0; i < sysinfo->n_blockdevs; i++) { struct blockdev_info *bd = sysinfo->blockdevs[i]; - char *label; label = talloc_asprintf(screen, _("disk: %s [uuid: %s]"), bd->name, bd->uuid); @@ -851,7 +859,7 @@ static void config_screen_setup_widgets(struct config_screen *screen, for (i = 0; i < sysinfo->n_interfaces; i++) { struct interface_info *info = sysinfo->interfaces[i]; - char *label, mac[20]; + char mac[20]; mac_str(info->hwaddr, info->hwaddr_size, mac, sizeof(mac)); @@ -862,7 +870,6 @@ static void config_screen_setup_widgets(struct config_screen *screen, } for (i = DEVICE_TYPE_NETWORK; i < DEVICE_TYPE_UNKNOWN; i++) { - char *label; if (i == DEVICE_TYPE_ANY) label = talloc_asprintf(screen, _("Any Device")); @@ -903,7 +910,7 @@ static void config_screen_setup_widgets(struct config_screen *screen, widget_textbox_set_validator_integer(screen->widgets.timeout_f, 0, 999); if (config->ipmi_bootdev) { - char *label = talloc_asprintf(screen, + label = talloc_asprintf(screen, _("%s IPMI boot option: %s"), config->ipmi_bootdev_persistent ? "Persistent" : "Temporary", @@ -1051,6 +1058,12 @@ static void config_screen_setup_widgets(struct config_screen *screen, config->consoles[i], found); } + if (config->manual_console) { + label = talloc_asprintf(screen, _("Manually set: '%s'"), + config->boot_console); + screen->widgets.manual_console_l = widget_new_label(set, 0, 0, label); + } + tty = talloc_asprintf(screen, _("Current interface: %s"), ttyname(STDIN_FILENO)); screen->widgets.current_console_l = widget_new_label(set, 0 , 0, tty); diff --git a/utils/Makefile.am b/utils/Makefile.am index 2bbfb9c..453fdbd 100644 --- a/utils/Makefile.am +++ b/utils/Makefile.am @@ -34,5 +34,4 @@ dist_pkgdata_DATA = \ utils/logrotate.conf \ utils/hooks/01-create-default-dtb \ utils/hooks/20-update-dtb-sample \ - utils/hooks/90-sort-dtb \ - utils/hooks/80-set-stdout + utils/hooks/90-sort-dtb diff --git a/utils/hooks/30-add-offb.c b/utils/hooks/30-add-offb.c index eca9d13..aff3844 100644 --- a/utils/hooks/30-add-offb.c +++ b/utils/hooks/30-add-offb.c @@ -512,7 +512,10 @@ static int set_stdout(struct offb_ctx *ctx) return 0; } - if (strstr(boot_console, "tty") != NULL) { + if (strncmp(boot_console, "/dev/", strlen("/dev/")) != 0) { + /* We already have the full path */ + stdout_path = talloc_strdup(ctx, boot_console); + } else if (strstr(boot_console, "tty") != NULL) { fprintf(stderr, "TTY recognised: %s\n", boot_console); stdout_path = get_vga_path(ctx); } else { diff --git a/utils/hooks/80-set-stdout b/utils/hooks/80-set-stdout deleted file mode 100755 index 92ff030..0000000 --- a/utils/hooks/80-set-stdout +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh - -# Hook to set the linux,stdout-path property from an nvram property -# (named $nvram_prop). - -nvram_prop=petitboot,console - -# we need to be using a dtb -[ -n "$boot_dtb" ] || exit - -console=$(nvram --print-config="$nvram_prop") - -[ $? = 0 -a -n "$console" ] || exit - -dtb_in=$boot_dtb -dtb_out=$(mktemp) - -( - dtc -I dtb -O dts $dtb_in - echo '/ { chosen { linux,stdout-path = "'$console'"; }; }; ' -) | dtc -I dts -O dtb -o $dtb_out - -[ $? = 0 ] && mv $dtb_out $dtb_in |