Use 'consoles' instead of 'tty' to refer to interfaces
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>
Tue, 9 Aug 2016 06:01:49 +0000 (16:01 +1000)
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>
Thu, 8 Sep 2016 04:26:27 +0000 (14:26 +1000)
'Console' is more readily understandable and technically more correct
than 'tty' for referring to the interfaces that Petitboot starts a UI on.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
discover/boot.c
discover/boot.h
discover/platform-powerpc.c
discover/platform.c
lib/pb-config/pb-config.c
lib/pb-protocol/pb-protocol.c
lib/types/types.h
ui/common/discover-client.c
ui/ncurses/nc-config.c
utils/hooks/30-add-offb.c

index c25627d0a9bd83ec4162a788e53a44f811a49f72..0732a50aea0318fce5f2fc5225716b50c8350776 100644 (file)
@@ -220,7 +220,7 @@ static void boot_hook_setenv(struct boot_task *task)
        unsetenv("boot_initrd");
        unsetenv("boot_dtb");
        unsetenv("boot_args");
-       unsetenv("boot_tty");
+       unsetenv("boot_console");
 
        setenv("boot_image", task->local_image, 1);
        if (task->local_initrd)
@@ -229,8 +229,8 @@ static void boot_hook_setenv(struct boot_task *task)
                setenv("boot_dtb", task->local_dtb, 1);
        if (task->args)
                setenv("boot_args", task->args, 1);
-       if (task->boot_tty)
-               setenv("boot_tty", task->boot_tty, 1);
+       if (task->boot_console)
+               setenv("boot_console", task->boot_console, 1);
 }
 
 static int hook_filter(const struct dirent *dirent)
@@ -574,11 +574,11 @@ struct boot_task *boot(void *ctx, struct discover_boot_option *opt,
                boot_task->args = NULL;
        }
 
-       if (cmd && cmd->tty)
-               boot_task->boot_tty = talloc_strdup(boot_task, cmd->tty);
+       if (cmd && cmd->console)
+               boot_task->boot_console = talloc_strdup(boot_task, cmd->console);
        else {
                config = config_get();
-               boot_task->boot_tty = config ? config->boot_tty : NULL;
+               boot_task->boot_console = config ? config->boot_console : NULL;
        }
 
        if (boot_task->verify_signature || boot_task->decrypt_files) {
index 2d99b7fb58a5e9de1eedb8444c57bbff4020842f..0f2734133bc80c9d43cec55c5c1d4461f6cdfe5b 100644 (file)
@@ -26,7 +26,7 @@ struct boot_task {
        char *local_initrd_override;
        char *local_dtb_override;
        const char *args;
-       const char *boot_tty;
+       const char *boot_console;
        boot_status_fn status_fn;
        void *status_arg;
        bool dry_run;
index 2b89121264e4c11e02856c8d7861c1e20dbf53bf..57618c3592bc5922c395de72e0fb6b9a411a5cf6 100644 (file)
@@ -569,7 +569,7 @@ static void populate_config(struct platform_powerpc *platform,
 
        val = get_param(platform, "petitboot,tty");
        if (val)
-               config->boot_tty = talloc_strdup(config, val);
+               config->boot_console = talloc_strdup(config, val);
 }
 
 static char *iface_config_str(void *ctx, struct interface_config *config)
@@ -746,7 +746,7 @@ static int update_config(struct platform_powerpc *platform,
                val = config->allow_writes ? "true" : "false";
        update_string_config(platform, "petitboot,write?", val);
 
-       val = config->boot_tty ?: "";
+       val = config->boot_console ?: "";
        update_string_config(platform, "petitboot,tty", val);
 
        update_network_config(platform, config);
@@ -1239,32 +1239,32 @@ static void get_active_consoles(struct config *config)
        struct stat sbuf;
        char *fsp_prop = NULL;
 
-       config->n_tty = 2;
-       config->tty_list = talloc_array(config, char *, config->n_tty);
-       if (!config->tty_list)
+       config->n_consoles = 2;
+       config->consoles = talloc_array(config, char *, config->n_consoles);
+       if (!config->consoles)
                goto err;
 
-       config->tty_list[0] = talloc_asprintf(config->tty_list,
+       config->consoles[0] = talloc_asprintf(config->consoles,
                                        "/dev/hvc0 [IPMI / Serial]");
-       config->tty_list[1] = talloc_asprintf(config->tty_list,
+       config->consoles[1] = talloc_asprintf(config->consoles,
                                        "/dev/tty1 [VGA]");
 
        fsp_prop = talloc_asprintf(config, "%sfsps", devtree_dir);
        if (stat(fsp_prop, &sbuf) == 0) {
                /* FSP based machines also have a separate serial console */
-               config->tty_list = talloc_realloc(config, config->tty_list,
-                                               char *, config->n_tty + 1);
-               if (!config->tty_list)
+               config->consoles = talloc_realloc(config, config->consoles,
+                                               char *, config->n_consoles + 1);
+               if (!config->consoles)
                        goto err;
-               config->tty_list[config->n_tty++] = talloc_asprintf(
-                                               config->tty_list,
+               config->consoles[config->n_consoles++] = talloc_asprintf(
+                                               config->consoles,
                                                "/dev/hvc1 [Serial]");
        }
 
        return;
 err:
-       config->n_tty = 0;
-       pb_log("Failed to allocate memory for tty_list\n");
+       config->n_consoles = 0;
+       pb_log("Failed to allocate memory for consoles\n");
 }
 
 static int load_config(struct platform *p, struct config *config)
index 254da979b41e2cc8157ba39f0ad9734979d43498..95a905d6ec82eac746c1bd6d38f928d34c4f4aa1 100644 (file)
@@ -83,7 +83,7 @@ static void dump_config(struct config *config)
                        config->allow_writes ? "yes" : "no");
 
        pb_log("  Default UI to boot on: %s\n",
-               config->boot_tty ?: "none set");
+               config->boot_console ?: "none set");
 
 
        pb_log(" language: %s\n", config->lang ?: "");
@@ -123,9 +123,9 @@ void config_set_defaults(struct config *config)
        config->allow_writes = true;
        config->disable_snapshots = false;
 
-       config->n_tty = 0;
-       config->tty_list = NULL;
-       config->boot_tty = NULL;
+       config->n_consoles = 0;
+       config->consoles = NULL;
+       config->boot_console = NULL;
 
        config->n_autoboot_opts = 2;
        config->autoboot_opts = talloc_array(config, struct autoboot_option,
index 581d70f08cb8f65a4c680e77e7512366fc640e7a..86f14c9082baddb9e7bce67fc62f764a76b34f4b 100644 (file)
@@ -83,15 +83,15 @@ struct config *config_copy(void *ctx, const struct config *src)
 
        dest->allow_writes = src->allow_writes;
 
-       dest->n_tty = src->n_tty;
-       if (src->tty_list)
-               dest->tty_list = talloc_array(dest, char *, src->n_tty);
-       for (i = 0; i < src->n_tty && src->n_tty; i++)
-               dest->tty_list[i] = talloc_strdup(dest->tty_list,
-                                               src->tty_list[i]);
-
-       if (src->boot_tty)
-               dest->boot_tty = talloc_strdup(dest, src->boot_tty);
+       dest->n_consoles = src->n_consoles;
+       if (src->consoles)
+               dest->consoles = talloc_array(dest, char *, src->n_consoles);
+       for (i = 0; i < src->n_consoles && src->n_consoles; i++)
+               dest->consoles[i] = talloc_strdup(dest->consoles,
+                                               src->consoles[i]);
+
+       if (src->boot_console)
+               dest->boot_console = talloc_strdup(dest, src->boot_console);
 
        if (src->lang && strlen(src->lang))
                dest->lang = talloc_strdup(dest, src->lang);
index 706aec9786169af697c0488f535a2730c95269db..0d83bde0d11fca8f7b4902755cfa13e458a6277f 100644 (file)
@@ -212,7 +212,7 @@ int pb_protocol_boot_len(const struct boot_command *boot)
                4 + optional_strlen(boot->dtb_file) +
                4 + optional_strlen(boot->boot_args) +
                4 + optional_strlen(boot->args_sig_file) +
-               4 + optional_strlen(boot->tty);
+               4 + optional_strlen(boot->console);
 }
 
 int pb_protocol_boot_status_len(const struct boot_status *status)
@@ -318,11 +318,11 @@ int pb_protocol_config_len(const struct config *config)
 
        len += 4; /* allow_writes */
 
-       len += 4; /* n_tty */
-       for (i = 0; i < config->n_tty; i++)
-               len += 4 + optional_strlen(config->tty_list[i]);
+       len += 4; /* n_consoles */
+       for (i = 0; i < config->n_consoles; i++)
+               len += 4 + optional_strlen(config->consoles[i]);
 
-       len += 4 + optional_strlen(config->boot_tty);
+       len += 4 + optional_strlen(config->boot_console);
 
        len += 4 + optional_strlen(config->lang);
 
@@ -389,7 +389,7 @@ int pb_protocol_serialise_boot_command(const struct boot_command *boot,
        pos += pb_protocol_serialise_string(pos, boot->dtb_file);
        pos += pb_protocol_serialise_string(pos, boot->boot_args);
        pos += pb_protocol_serialise_string(pos, boot->args_sig_file);
-       pos += pb_protocol_serialise_string(pos, boot->tty);
+       pos += pb_protocol_serialise_string(pos, boot->console);
 
        assert(pos <= buf + buf_len);
        (void)buf_len;
@@ -573,12 +573,12 @@ int pb_protocol_serialise_config(const struct config *config,
        *(uint32_t *)pos = config->allow_writes;
        pos += 4;
 
-       *(uint32_t *)pos = __cpu_to_be32(config->n_tty);
+       *(uint32_t *)pos = __cpu_to_be32(config->n_consoles);
        pos += 4;
-       for (i = 0; i < config->n_tty; i++)
-               pos += pb_protocol_serialise_string(pos, config->tty_list[i]);
+       for (i = 0; i < config->n_consoles; i++)
+               pos += pb_protocol_serialise_string(pos, config->consoles[i]);
 
-       pos += pb_protocol_serialise_string(pos, config->boot_tty);
+       pos += pb_protocol_serialise_string(pos, config->boot_console);
 
        pos += pb_protocol_serialise_string(pos, config->lang);
 
@@ -803,7 +803,7 @@ int pb_protocol_deserialise_boot_command(struct boot_command *cmd,
        if (read_string(cmd, &pos, &len, &cmd->args_sig_file))
                goto out;
 
-       if (read_string(cmd, &pos, &len, &cmd->tty))
+       if (read_string(cmd, &pos, &len, &cmd->console))
                goto out;
 
        rc = 0;
@@ -1109,20 +1109,20 @@ int pb_protocol_deserialise_config(struct config *config,
                goto out;
        config->allow_writes = !!tmp;
 
-       if (read_u32(&pos, &len, &config->n_tty))
+       if (read_u32(&pos, &len, &config->n_consoles))
                goto out;
 
-       config->tty_list = talloc_array(config, char *, config->n_tty);
-       for (i = 0; i < config->n_tty; i++) {
-               if (read_string(config->tty_list, &pos, &len, &str))
+       config->consoles = talloc_array(config, char *, config->n_consoles);
+       for (i = 0; i < config->n_consoles; i++) {
+               if (read_string(config->consoles, &pos, &len, &str))
                        goto out;
-               config->tty_list[i] = str;
+               config->consoles[i] = str;
        }
 
        if (read_string(config, &pos, &len, &str))
                goto out;
 
-       config->boot_tty = str;
+       config->boot_console = str;
 
        if (read_string(config, &pos, &len, &str))
                goto out;
index 7b9269b1899905cb250feaaf2fb1a365b21a0f6d..b7430f4910f6d5e6a97363aa5844b2064c872079 100644 (file)
@@ -67,7 +67,7 @@ struct boot_command {
        char *dtb_file;
        char *boot_args;
        char *args_sig_file;
-       char *tty;
+       char *console;
 };
 
 struct boot_status {
@@ -163,12 +163,12 @@ struct config {
 
        bool                    allow_writes;
 
-       char                    *boot_tty;
+       char                    *boot_console;
        char                    *lang;
 
        /* not user-settable */
-       unsigned int            n_tty;
-       char                    **tty_list;
+       unsigned int            n_consoles;
+       char                    **consoles;
        bool                    disable_snapshots;
        bool                    safe_mode;
        bool                    debug;
index 5dbd99bee70f19d3141d045b85bd12fcf728db26..27bba329dbf0478b273139ab76eb97d33bd22ff6 100644 (file)
@@ -313,7 +313,7 @@ static void create_boot_command(struct boot_command *command,
        command->dtb_file = data->dtb;
        command->boot_args = data->args;
        command->args_sig_file = data->args_sig_file;
-       command->tty = ttyname(STDIN_FILENO);
+       command->console = ttyname(STDIN_FILENO);
 }
 
 int discover_client_boot(struct discover_client *client,
index fbba943e3f178f0e194215f647a984f88d668cb4..c668bde12ae0255ceba9a73d4034abccc0b04cf1 100644 (file)
@@ -33,7 +33,7 @@
 #include "nc-config.h"
 #include "nc-widgets.h"
 
-#define N_FIELDS       43
+#define N_FIELDS       44
 
 extern struct help_text config_help_text;
 
@@ -109,9 +109,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          *boot_console_l;
+               struct nc_widget_select         *boot_console_f;
+               struct nc_widget_label          *current_console_l;
 
                struct nc_widget_label          *net_override_l;
                struct nc_widget_label          *safe_mode;
@@ -201,8 +201,8 @@ static int screen_process_form(struct config_screen *screen)
        bool allow_write, autoboot;
        char *str, *end;
        struct config *config;
-       int i, n_boot_opts, rc, idx;
-       unsigned int *order, tty;
+       int i, n_boot_opts, rc;
+       unsigned int *order, idx;
        char mac[20];
 
        config = config_copy(screen, screen->cui->config);
@@ -338,16 +338,16 @@ 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]);
+       if (config->n_consoles) {
+               idx = widget_select_get_value(screen->widgets.boot_console_f);
+               if (!config->boot_console) {
+                       config->boot_console = talloc_strdup(config,
+                                                       config->consoles[idx]);
+               } else if (strncmp(config->boot_console, config->consoles[idx],
+                               strlen(config->boot_console)) != 0) {
+                       talloc_free(config->boot_console);
+                       config->boot_console = talloc_strdup(config,
+                                                       config->consoles[idx]);
                }
        }
 
@@ -592,20 +592,20 @@ 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),
+       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));
+               widget_move(widget_label_base(screen->widgets.current_console_l),
                        y, screen->field_x);
                y += 2;
        } else {
                widget_set_visible(widget_label_base(
-                                       screen->widgets.boot_tty_l), false);
+                                       screen->widgets.boot_console_l), false);
                widget_set_visible(widget_select_base(
-                                       screen->widgets.boot_tty_f), false);
+                                       screen->widgets.boot_console_f), false);
                widget_set_visible(widget_label_base(
-                                       screen->widgets.current_tty_l), false);
+                                       screen->widgets.current_console_l), false);
        }
 
        if (screen->net_override) {
@@ -1038,22 +1038,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,
+       screen->widgets.boot_console_l = widget_new_label(set, 0, 0,
+                       _("Boot console:"));
+       screen->widgets.boot_console_f = widget_new_select(set, 0, 0,
                                                COLS - screen->field_x - 1);
 
-       for (i = 0; i < config->n_tty; i++){
-               found = config->boot_tty &&
-                       strncmp(config->boot_tty, config->tty_list[i],
-                               strlen(config->boot_tty)) == 0;
-               widget_select_add_option(screen->widgets.boot_tty_f, i,
-                                       config->tty_list[i], found);
+       for (i = 0; i < config->n_consoles; i++){
+               found = config->boot_console &&
+                       strncmp(config->boot_console, config->consoles[i],
+                               strlen(config->boot_console)) == 0;
+               widget_select_add_option(screen->widgets.boot_console_f, i,
+                                       config->consoles[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.current_console_l = widget_new_label(set, 0 , 0, tty);
 
        screen->widgets.ok_b = widget_new_button(set, 0, 0, 10, _("OK"),
                        ok_click, screen);
index e5947ca6e931d134f36d564c98c66d06b468e802..eca9d133520da3a41282de4bbb971c95e428375c 100644 (file)
@@ -500,40 +500,43 @@ static char *get_vga_path(struct offb_ctx *ctx)
 
 static int set_stdout(struct offb_ctx *ctx)
 {
-       const char *boot_tty, *ptr;
+       const char *boot_console, *ptr;
        long unsigned int termno;
        const fdt32_t *prop;
        int node, prop_len;
        char *stdout_path;
 
-       boot_tty = getenv("boot_tty");
-       if (!boot_tty) {
-               fprintf(stderr, "boot_tty not set, using default stdout for boot\n");
+       boot_console = getenv("boot_console");
+       if (!boot_console) {
+               fprintf(stderr, "boot_console not set, using default stdout for boot\n");
                return 0;
        }
 
-       if (strstr(boot_tty, "tty") != NULL) {
-               fprintf(stderr, "TTY recognised: %s\n", boot_tty);
+       if (strstr(boot_console, "tty") != NULL) {
+               fprintf(stderr, "TTY recognised: %s\n", boot_console);
                stdout_path = get_vga_path(ctx);
        } else {
-               ptr = strstr(boot_tty, "hvc");
+               ptr = strstr(boot_console, "hvc");
                if (!ptr || strlen(ptr) <= strlen("hvc")) {
-                       fprintf(stderr, "Unrecognised console: %s\n", boot_tty);
+                       fprintf(stderr, "Unrecognised console: %s\n",
+                                       boot_console);
                        return 0;
                }
                ptr += strlen("hvc");
                errno = 0;
                termno = strtoul(ptr, NULL, 0);
                if (errno) {
-                       fprintf(stderr, "Couldn't parse termno from %s\n", boot_tty);
+                       fprintf(stderr, "Couldn't parse termno from %s\n",
+                                       boot_console);
                        return 0;
                }
-               fprintf(stderr, "HVC recognised: %s\n", boot_tty);
+               fprintf(stderr, "HVC recognised: %s\n", boot_console);
                stdout_path = get_hvc_path(ctx, termno);
        }
 
        if (!stdout_path) {
-               fprintf(stderr, "Couldn't parse %s into a path\n", boot_tty);
+               fprintf(stderr, "Couldn't parse %s into a path\n",
+                               boot_console);
                return -1;
        }