summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>2016-08-09 16:01:49 +1000
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>2016-09-08 14:26:27 +1000
commit9f42e56fc5968fcb34edfad017adb73960c2bb61 (patch)
tree1114b3ed7f7fe9b36e1176268e611e69ed31d1f0
parente4a641a6e3133158b003d19ee285cfc37164cb1f (diff)
downloadpetitboot-9f42e56fc5968fcb34edfad017adb73960c2bb61.zip
petitboot-9f42e56fc5968fcb34edfad017adb73960c2bb61.tar.gz
Use 'consoles' instead of 'tty' to refer to interfaces
'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>
-rw-r--r--discover/boot.c12
-rw-r--r--discover/boot.h2
-rw-r--r--discover/platform-powerpc.c28
-rw-r--r--discover/platform.c8
-rw-r--r--lib/pb-config/pb-config.c18
-rw-r--r--lib/pb-protocol/pb-protocol.c34
-rw-r--r--lib/types/types.h8
-rw-r--r--ui/common/discover-client.c2
-rw-r--r--ui/ncurses/nc-config.c68
-rw-r--r--utils/hooks/30-add-offb.c25
10 files changed, 104 insertions, 101 deletions
diff --git a/discover/boot.c b/discover/boot.c
index c25627d..0732a50 100644
--- a/discover/boot.c
+++ b/discover/boot.c
@@ -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) {
diff --git a/discover/boot.h b/discover/boot.h
index 2d99b7f..0f27341 100644
--- a/discover/boot.h
+++ b/discover/boot.h
@@ -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;
diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c
index 2b89121..57618c3 100644
--- a/discover/platform-powerpc.c
+++ b/discover/platform-powerpc.c
@@ -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)
diff --git a/discover/platform.c b/discover/platform.c
index 254da97..95a905d 100644
--- a/discover/platform.c
+++ b/discover/platform.c
@@ -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,
diff --git a/lib/pb-config/pb-config.c b/lib/pb-config/pb-config.c
index 581d70f..86f14c9 100644
--- a/lib/pb-config/pb-config.c
+++ b/lib/pb-config/pb-config.c
@@ -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);
diff --git a/lib/pb-protocol/pb-protocol.c b/lib/pb-protocol/pb-protocol.c
index 706aec9..0d83bde 100644
--- a/lib/pb-protocol/pb-protocol.c
+++ b/lib/pb-protocol/pb-protocol.c
@@ -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;
diff --git a/lib/types/types.h b/lib/types/types.h
index 7b9269b..b7430f4 100644
--- a/lib/types/types.h
+++ b/lib/types/types.h
@@ -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;
diff --git a/ui/common/discover-client.c b/ui/common/discover-client.c
index 5dbd99b..27bba32 100644
--- a/ui/common/discover-client.c
+++ b/ui/common/discover-client.c
@@ -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,
diff --git a/ui/ncurses/nc-config.c b/ui/ncurses/nc-config.c
index fbba943..c668bde 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 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);
diff --git a/utils/hooks/30-add-offb.c b/utils/hooks/30-add-offb.c
index e5947ca..eca9d13 100644
--- a/utils/hooks/30-add-offb.c
+++ b/utils/hooks/30-add-offb.c
@@ -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;
}
OpenPOWER on IntegriCloud