* pb_run_kexec - Run kexec with the supplied boot options.
*/
-int pb_run_kexec(const struct pb_kexec_data *kd, int dry_run)
+int pb_run_kexec(const struct pb_boot_data *bd, int dry_run)
{
int result;
char *l_image = NULL;
unsigned int clean_image = 0;
unsigned int clean_initrd = 0;
- pb_log("%s: image: '%s'\n", __func__, kd->image);
- pb_log("%s: initrd: '%s'\n", __func__, kd->initrd);
- pb_log("%s: args: '%s'\n", __func__, kd->args);
+ pb_log("%s: image: '%s'\n", __func__, bd->image);
+ pb_log("%s: initrd: '%s'\n", __func__, bd->initrd);
+ pb_log("%s: args: '%s'\n", __func__, bd->args);
result = -1;
- if (kd->image) {
- l_image = pb_load_file(NULL, kd->image, &clean_image);
+ if (bd->image) {
+ l_image = pb_load_file(NULL, bd->image, &clean_image);
if (!l_image)
goto no_load;
}
- if (kd->initrd) {
- l_initrd = pb_load_file(NULL, kd->initrd, &clean_initrd);
+ if (bd->initrd) {
+ l_initrd = pb_load_file(NULL, bd->initrd, &clean_initrd);
if (!l_initrd)
goto no_load;
}
if (!l_image && !l_initrd)
goto no_load;
- result = kexec_load(l_image, l_initrd, kd->args, dry_run);
+ result = kexec_load(l_image, l_initrd, bd->args, dry_run);
no_load:
if (clean_image)
#include <signal.h>
-struct pb_kexec_data {
+struct pb_boot_data {
char *image;
char *initrd;
char *args;
};
-int pb_run_kexec(const struct pb_kexec_data *kd, int dry_run);
+int pb_run_kexec(const struct pb_boot_data *bd, int dry_run);
int pb_start_daemon(void);
unsigned int pb_elf_hash(const char *str);
struct pb_opt_data {
const char *name;
- struct pb_kexec_data *kd;
+ struct pb_boot_data *bd;
/* optional data */
const struct device *dev;
assert(pb->cui->current == &pb->cui->main->scr);
- return pb_run_kexec(cod->kd, pb->cui->dry_run);
+ return pb_run_kexec(cod->bd, pb->cui->dry_run);
}
/**
return start;
}
-static struct pb_kexec_data *boot_editor_prepare_data(
+static struct pb_boot_data *boot_editor_prepare_data(
struct boot_editor *boot_editor)
{
- struct pb_kexec_data *kd;
+ struct pb_boot_data *bd;
char *s;
- kd = talloc(boot_editor, struct pb_kexec_data);
+ bd = talloc(boot_editor, struct pb_boot_data);
- if (!kd)
+ if (!bd)
return NULL;
s = boot_editor_chomp(field_buffer(boot_editor->fields[0], 0));
- kd->image = *s ? talloc_strdup(kd, s) : NULL;
+ bd->image = *s ? talloc_strdup(bd, s) : NULL;
s = boot_editor_chomp(field_buffer(boot_editor->fields[1], 0));
- kd->initrd = *s ? talloc_strdup(kd, s) : NULL;
+ bd->initrd = *s ? talloc_strdup(bd, s) : NULL;
s = boot_editor_chomp(field_buffer(boot_editor->fields[2], 0));
- kd->args = *s ? talloc_strdup(kd, s) : NULL;
+ bd->args = *s ? talloc_strdup(bd, s) : NULL;
- return kd;
+ return bd;
}
/**
static void boot_editor_process_key(struct nc_scr *scr)
{
struct boot_editor *boot_editor = boot_editor_from_scr(scr);
- struct pb_kexec_data *kd;
+ struct pb_boot_data *bd;
while (1) {
int c = getch();
case '\n':
case '\r':
form_driver(boot_editor->ncf, REQ_VALIDATION);
- kd = boot_editor_prepare_data(boot_editor);
+ bd = boot_editor_prepare_data(boot_editor);
boot_editor->on_exit(boot_editor,
- boot_editor_update, kd);
+ boot_editor_update, bd);
nc_flush_keys();
return;
}
struct boot_editor *boot_editor_init(void *ui_ctx,
- const struct pb_kexec_data *kd,
+ const struct pb_boot_data *bd,
void (*on_exit)(struct boot_editor *,
enum boot_editor_result,
- struct pb_kexec_data *))
+ struct pb_boot_data *))
{
struct boot_editor *boot_editor;
- pb_log("%s: image: '%s'\n", __func__, kd->image);
- pb_log("%s: initrd: '%s'\n", __func__, kd->initrd);
- pb_log("%s: args: '%s'\n", __func__, kd->args);
+ pb_log("%s: image: '%s'\n", __func__, bd->image);
+ pb_log("%s: initrd: '%s'\n", __func__, bd->initrd);
+ pb_log("%s: args: '%s'\n", __func__, bd->args);
assert(on_exit);
boot_editor->fields = talloc_array(boot_editor, FIELD *, 7);
- boot_editor->fields[0] = boot_editor_setup_field(0, 9, kd->image);
- boot_editor->fields[1] = boot_editor_setup_field(1, 9, kd->initrd);
- boot_editor->fields[2] = boot_editor_setup_field(2, 9, kd->args);
+ boot_editor->fields[0] = boot_editor_setup_field(0, 9, bd->image);
+ boot_editor->fields[1] = boot_editor_setup_field(1, 9, bd->initrd);
+ boot_editor->fields[2] = boot_editor_setup_field(2, 9, bd->args);
boot_editor->fields[3] = boot_editor_setup_label(0, 1, "image:");
boot_editor->fields[4] = boot_editor_setup_label(1, 1, "initrd:");
boot_editor->fields[5] = boot_editor_setup_label(2, 1, "args:");
enum boot_editor_attr_cursor attr_cursor;
void (*on_exit)(struct boot_editor *boot_editor,
enum boot_editor_result result,
- struct pb_kexec_data *kd);
+ struct pb_boot_data *bd);
};
struct boot_editor *boot_editor_init(void *ui_ctx,
- const struct pb_kexec_data *kd,
+ const struct pb_boot_data *bd,
void (*on_exit)(struct boot_editor *,
enum boot_editor_result,
- struct pb_kexec_data *));
+ struct pb_boot_data *));
#endif
char *name;
assert(cod->name);
- assert(cod->kd);
+ assert(cod->bd);
name = talloc_asprintf(i, "%s:", cod->name);
- if (cod->kd->image)
- name = talloc_asprintf_append(name, " %s", cod->kd->image);
+ if (cod->bd->image)
+ name = talloc_asprintf_append(name, " %s", cod->bd->image);
- if (cod->kd->initrd)
+ if (cod->bd->initrd)
name = talloc_asprintf_append(name, " initrd=%s",
- cod->kd->initrd);
+ cod->bd->initrd);
- if (cod->kd->args)
- name = talloc_asprintf_append(name, " %s", cod->kd->args);
+ if (cod->bd->args)
+ name = talloc_asprintf_append(name, " %s", cod->bd->args);
DBGS("@%s@\n", name);
return name;
sleep(cui->dry_run ? 1 : 60);
}
- pb_log("%s: failed: %s\n", __func__, cod->kd->image);
- nc_scr_status_printf(cui->current, "Failed: kexec %s", cod->kd->image);
+ pb_log("%s: failed: %s\n", __func__, cod->bd->image);
+ nc_scr_status_printf(cui->current, "Failed: kexec %s", cod->bd->image);
return 0;
}
*/
static void cui_boot_editor_on_exit(struct boot_editor *boot_editor, enum boot_editor_result boot_editor_result,
- struct pb_kexec_data *kd)
+ struct pb_boot_data *bd)
{
struct cui *cui = cui_from_arg(boot_editor->scr.ui_ctx);
struct cui_opt_data *cod = cod_from_item(i);
char *name;
- assert(kd);
+ assert(bd);
- talloc_steal(i, kd);
- talloc_free(cod->kd);
- cod->kd = kd;
+ talloc_steal(i, bd);
+ talloc_free(cod->bd);
+ cod->bd = bd;
name = cui_make_item_name(i, cod);
pmenu_item_replace(i, name);
set_current_item(cui->main->ncm, i->nci);
pb_log("%s: updating opt '%s'\n", __func__, cod->name);
- pb_log(" image '%s'\n", cod->kd->image);
- pb_log(" initrd '%s'\n", cod->kd->initrd);
- pb_log(" args '%s'\n", cod->kd->args);
+ pb_log(" image '%s'\n", cod->bd->image);
+ pb_log(" initrd '%s'\n", cod->bd->initrd);
+ pb_log(" args '%s'\n", cod->bd->args);
}
cui_set_current(cui, &cui->main->scr);
struct cui_opt_data *cod = cod_from_item(item);
struct boot_editor *boot_editor;
- boot_editor = boot_editor_init(cui, cod->kd, cui_boot_editor_on_exit);
+ boot_editor = boot_editor_init(cui, cod->bd, cui_boot_editor_on_exit);
cui_set_current(cui, &boot_editor->scr);
return 0;
i->data = cod = talloc_zero(i, struct cui_opt_data);
cod->name = talloc_asprintf(i, "User item %u:", insert_pt);
- cod->kd = talloc_zero(i, struct pb_kexec_data);
+ cod->bd = talloc_zero(i, struct pb_boot_data);
pmenu_item_setup(menu, i, insert_pt, talloc_strdup(i, cod->name));
cod->opt = opt;
cod->opt_hash = pb_opt_hash(dev, opt);
cod->name = opt->name;
- cod->kd = talloc(i, struct pb_kexec_data);
+ cod->bd = talloc(i, struct pb_boot_data);
- cod->kd->image = talloc_strdup(cod->kd, opt->boot_image_file);
- cod->kd->initrd = talloc_strdup(cod->kd, opt->initrd_file);
- cod->kd->args = talloc_strdup(cod->kd, opt->boot_args);
+ cod->bd->image = talloc_strdup(cod->bd, opt->boot_image_file);
+ cod->bd->initrd = talloc_strdup(cod->bd, opt->initrd_file);
+ cod->bd->args = talloc_strdup(cod->bd, opt->boot_args);
name = cui_make_item_name(i, cod);
pmenu_item_setup(cui->main, i, insert_pt, name);
insert_pt++;
pb_log("%s: adding opt '%s'\n", __func__, cod->name);
- pb_log(" image '%s'\n", cod->kd->image);
- pb_log(" initrd '%s'\n", cod->kd->initrd);
- pb_log(" args '%s'\n", cod->kd->args);
+ pb_log(" image '%s'\n", cod->bd->image);
+ pb_log(" initrd '%s'\n", cod->bd->initrd);
+ pb_log(" args '%s'\n", cod->bd->args);
/* If this is the default_item select it and start timer. */
struct cui_opt_data {
const char *name;
- struct pb_kexec_data *kd;
+ struct pb_boot_data *bd;
/* optional data */
const struct device *dev;
/* Add a default kernel video mode. */
- if (!cod->kd->args) {
+ if (!cod->bd->args) {
altered_args = 1;
orig_args = NULL;
- cod->kd->args = talloc_asprintf(NULL, "video=ps3fb:mode:%u",
+ cod->bd->args = talloc_asprintf(NULL, "video=ps3fb:mode:%u",
(unsigned int)ps3->values.video_mode);
- } else if (!strstr(cod->kd->args, "video=")) {
+ } else if (!strstr(cod->bd->args, "video=")) {
altered_args = 1;
- orig_args = cod->kd->args;
- cod->kd->args = talloc_asprintf(NULL, "%s video=ps3fb:mode:%u",
+ orig_args = cod->bd->args;
+ cod->bd->args = talloc_asprintf(NULL, "%s video=ps3fb:mode:%u",
orig_args, (unsigned int)ps3->values.video_mode);
} else
altered_args = 0;
- result = pb_run_kexec(cod->kd, ps3->cui->dry_run);
+ result = pb_run_kexec(cod->bd, ps3->cui->dry_run);
if (altered_args) {
- talloc_free(cod->kd->args);
- cod->kd->args = orig_args;
+ talloc_free(cod->bd->args);
+ cod->bd->args = orig_args;
}
return result;
pb_log("%s: %s\n", __func__, opt_data->name);
- result = pb_run_kexec(opt_data->kd, client->dry_run);
+ result = pb_run_kexec(opt_data->bd, client->dry_run);
return result;
}
sleep(item->pbt_client->dry_run ? 1 : 60);
}
- pb_log("%s: failed: %s\n", __func__, opt_data->kd->image);
+ pb_log("%s: failed: %s\n", __func__, opt_data->bd->image);
pbt_frame_status_printf(&item->pbt_client->frame, "Failed: kexec %s",
- opt_data->kd->image);
+ opt_data->bd->image);
return 0;
}
i->data = opt_data = talloc(i, struct pb_opt_data);
opt_data->name = opt->name;
- opt_data->kd = talloc(i, struct pb_kexec_data);
- opt_data->kd->image = talloc_strdup(opt_data->kd,
+ opt_data->bd = talloc(i, struct pb_boot_data);
+ opt_data->bd->image = talloc_strdup(opt_data->bd,
opt->boot_image_file);
- opt_data->kd->initrd = talloc_strdup(opt_data->kd,
+ opt_data->bd->initrd = talloc_strdup(opt_data->bd,
opt->initrd_file);
- opt_data->kd->args = talloc_strdup(opt_data->kd,
+ opt_data->bd->args = talloc_strdup(opt_data->bd,
opt->boot_args);
opt_data->dev = dev;
opt_data->opt = opt;