@@ 42,19 42,17 @@ klapki::context::context klapki::context::context::derive(const config & cfg, st
const auto efi_opt = reinterpret_cast<efi_load_option *>(bent->second.load_option.get());
const ssize_t efi_opt_len = bent->second.load_option_len;
if(!efi_loadopt_is_valid(efi_opt, efi_opt_len)) {
- fmt::print(stderr, "Entry {:04X} not a valid EFI Load Option. Dropping.\n", went.bootnum_hint);
- // TODO: drop this from the state entirely
+ fmt::print(stderr, "Entry {:04X} not a valid EFI Load Option. Abandoning.\n", went.bootnum_hint);
continue;
}
const auto dp = efi_loadopt_path(efi_opt, efi_opt_len);
if(dp->type != EFIDP_MEDIA_TYPE) {
- fmt::print(stderr, "Entry {:04X} not Media Device Path. Dropping.\n", went.bootnum_hint);
- // TODO: drop this from the state entirely
+ fmt::print(stderr, "Entry {:04X} not Media Device Path. Abandoning.\n", went.bootnum_hint);
continue;
}
if(dp->subtype != EFIDP_MEDIA_HD) {
- fmt::print(stderr, "Entry {:04X} not Media Device Path HD. Dropping.\n", went.bootnum_hint);
+ fmt::print(stderr, "Entry {:04X} not Media Device Path HD. Abandoning.\n", went.bootnum_hint);
continue;
}
@@ 63,26 61,21 @@ klapki::context::context klapki::context::context::derive(const config & cfg, st
klapki::context::detail::print_devpath(dp, efi_opt_len);
}
- // We're assuming all we have is HD+file for now, and dog help me
const efidp_data * file;
switch(efidp_next_node(dp, &file)) {
case -1:
- fmt::print(stderr, "Entry {:04X}: second (file) node: {}. Dropping.\n", went.bootnum_hint, strerror(errno));
- // TODO: drop this from the state entirely
+ fmt::print(stderr, "Entry {:04X}: second (file) node: {}. Abandoning.\n", went.bootnum_hint, strerror(errno));
continue;
case 0:
- fmt::print(stderr, "Entry {:04X}: second (file) node doesn't exist. Dropping.\n", went.bootnum_hint);
- // TODO: drop this from the state entirely
+ fmt::print(stderr, "Entry {:04X}: second (file) node doesn't exist. Abandoning.\n", went.bootnum_hint);
continue;
case 1: {
if(file->type != EFIDP_MEDIA_TYPE) {
- fmt::print(stderr, "Entry {:04X} file not Media Device Path. Dropping.\n", went.bootnum_hint);
- // TODO: drop this from the state entirely
+ fmt::print(stderr, "Entry {:04X} file not Media Device Path. Abandoning.\n", went.bootnum_hint);
continue;
}
if(file->subtype != EFIDP_MEDIA_FILE) {
- fmt::print(stderr, "Entry {:04X} file not Media Device Path File. Dropping.\n", went.bootnum_hint);
- // TODO: drop this from the state entirely
+ fmt::print(stderr, "Entry {:04X} file not Media Device Path File. Abandoning.\n", went.bootnum_hint);
continue;
}
@@ 100,7 93,23 @@ klapki::context::context klapki::context::context::derive(const config & cfg, st
__builtin_unreachable();
}
- // TODO: verify this is the last path entry
+ const efidp_data * final_node;
+ switch(efidp_next_node(file, &final_node)) {
+ case -1:
+ fmt::print(stderr, "Entry {:04X}: third (final) node: {}. Abandoning.\n", went.bootnum_hint, strerror(errno));
+ continue;
+ case 0:
+ fmt::print(stderr, "Entry {:04X}: third (final) node doesn't exist. Abandoning.\n", went.bootnum_hint);
+ continue;
+ case 1: {
+ if(final_node->type != EFIDP_END_TYPE || final_node->subtype != EFIDP_END_ENTIRE) {
+ fmt::print(stderr, "Entry {:04X} final node not End Type End Entire. Abandoning.\n", went.bootnum_hint);
+ continue;
+ }
+ } break;
+ default:
+ __builtin_unreachable();
+ }
if(cfg.verbose)
fmt::print("Entry {:04X}: [\"{}\", \"{}\"]\n", went.bootnum_hint, kern.image_path.first, kern.image_path.second);
@@ 129,7 138,7 @@ klapki::context::context klapki::context::context::derive(const config & cfg, st
}
}
- // TODO: this might mangle ws
+ // This mangles ws but it's for informational purposes only — we get the freshest one during wisen() anyway
kern.cmdline += arg;
kern.cmdline += ' ';