info.dev = dev;
info.bflow = bflow;
ret = pxe_setup_ctx(&ctx, &cmdtp, extlinux_getfile, &info, true,
- bflow->fname, false);
+ bflow->fname, false, false);
if (ret)
return log_msg_ret("ctx", -EINVAL);
info.bflow = bflow;
info.cmdtp = &cmdtp;
ret = pxe_setup_ctx(ctx, &cmdtp, extlinux_pxe_getfile, &info, false,
- bflow->subdir, false);
+ bflow->subdir, false, false);
if (ret)
return log_msg_ret("ctx", -EINVAL);
buf = map_sysmem(menucfg, 0);
r = parse_pxefile_top(ctx, buf, menucfg, cfg, 1);
+
+ if (ctx->use_fallback) {
+ if (cfg->fallback_label) {
+ printf("Setting use of fallback\n");
+ cfg->default_label = cfg->fallback_label;
+ } else {
+ printf("Selected fallback option, but not set\n");
+ }
+ }
+
unmap_sysmem(buf);
if (r < 0) {
destroy_pxe_menu(cfg);
int pxe_setup_ctx(struct pxe_context *ctx, struct cmd_tbl *cmdtp,
pxe_getfile_func getfile, void *userdata,
- bool allow_abs_path, const char *bootfile, bool use_ipv6)
+ bool allow_abs_path, const char *bootfile, bool use_ipv6,
+ bool use_fallback)
{
const char *last_slash;
size_t path_len = 0;
ctx->userdata = userdata;
ctx->allow_abs_path = allow_abs_path;
ctx->use_ipv6 = use_ipv6;
+ ctx->use_fallback = use_fallback;
/* figure out the boot directory, if there is one */
if (bootfile && strlen(bootfile) >= MAX_TFTP_PATH_LEN)
int i;
if (pxe_setup_ctx(&ctx, cmdtp, do_get_tftp, NULL, false,
- env_get("bootfile"), use_ipv6))
+ env_get("bootfile"), use_ipv6, false))
return -ENOMEM;
if (IS_ENABLED(CONFIG_BOOTP_PXE_DHCP_OPTION) &&
}
if (pxe_setup_ctx(&ctx, cmdtp, do_get_tftp, NULL, false,
- env_get("bootfile"), use_ipv6)) {
+ env_get("bootfile"), use_ipv6, false)) {
printf("Out of memory\n");
return CMD_RET_FAILURE;
}
}
if (pxe_setup_ctx(&ctx, cmdtp, sysboot_read_file, &info, true,
- filename, false)) {
+ filename, false, false)) {
printf("Out of memory\n");
return CMD_RET_FAILURE;
}
* allocated
* @pxe_file_size: Size of the PXE file
* @use_ipv6: TRUE : use IPv6 addressing, FALSE : use IPv4 addressing
+ * @use_fallback: TRUE : use "fallback" option as default, FALSE : use
+ * "default" option as default
*/
struct pxe_context {
struct cmd_tbl *cmdtp;
char *bootdir;
ulong pxe_file_size;
bool use_ipv6;
+ bool use_fallback;
};
/**
* none
* @use_ipv6: TRUE : use IPv6 addressing
* FALSE : use IPv4 addressing
+ * @use_fallback: TRUE : Use "fallback" option instead of "default" should no
+ * other choice be selected
+ * FALSE : Use "default" option should no other choice be
+ * selected
* Return: 0 if OK, -ENOMEM if out of memory, -E2BIG if bootfile is larger than
* MAX_TFTP_PATH_LEN bytes
*/
int pxe_setup_ctx(struct pxe_context *ctx, struct cmd_tbl *cmdtp,
pxe_getfile_func getfile, void *userdata,
- bool allow_abs_path, const char *bootfile, bool use_ipv6);
+ bool allow_abs_path, const char *bootfile, bool use_ipv6,
+ bool use_fallback);
/**
* pxe_destroy_ctx() - Destroy a PXE context