Вы можете использовать оболочку sub -.
(
set …
do stuff
)
Other stuff, that set does not apply to
TL;DR:
Binary data buffer that is passed to the loaded image.
Подробное описание процесса поиска
исходный код efibootmgr содержит функцию, которая выводит переменные загрузки EFI (файл efibootmgr.c):
static void
show_vars(const char *prefix)
{
list_t *pos;
var_entry_t *boot;
const unsigned char *description;
efi_load_option *load_option;
list_for_each(pos, &entry_list) {
boot = list_entry(pos, var_entry_t, list);
load_option = (efi_load_option *)boot->data;
description = efi_loadopt_desc(load_option, boot->data_size);
if (boot->name)
printf("%s", boot->name);
else
printf("%s%04X", prefix, boot->num);
printf("%c ", (efi_loadopt_attrs(load_option)
⁞ & LOAD_OPTION_ACTIVE) ? '*' : ' ');
printf("%s", description);
show_var_path(load_option, boot->data_size);
fflush(stdout);
}
}
Интерес представляет строка
description = efi_loadopt_desc(load_option, boot->data_size);
Итак, нам нужно найти функцию efi_loadopt_desc
. Он не содержится в самом efibootmgr. Поиск включаемых файлов в /usr/include дает:
$ grep -ri efi_loadopt_desc /usr/include
/usr/include/efivar/efiboot-loadopt.h:extern const unsigned char * efi_loadopt_desc(efi_load_option *opt,
Если мы заглянем внутрь файла /usr/include/efivar/efiboot, -будет указано, что loadopt.h:
/*
* libefiboot - library for the manipulation of EFI boot variables
* Copyright 2012-2015 Red Hat, Inc.
* Copyright (C) 2001 Dell Computer Corporation <Matt_Domsch@dell.com>
*
...
*/
Дальнейшее исследование приводит к репозиторию efivar , который содержит функцию efi_loadopt_desc
внутри файла src/loadopt.c. Там он просто возвращает opt->description
полеstruct efi_load_option_s
:
last_desc = ucs2_to_utf8(opt->description, limit);
Эта структура определяется как
typedef struct efi_load_option_s {
uint32_t attributes;
uint16_t file_path_list_length;
uint16_t description[];
// uint8_t file_path_list[];
// uint8_t optional_data[];
} PACKED efi_load_option;
Таким образом, часть, которая выводится после пути к файлу опций загрузки, называется «необязательными данными». Дальнейшее исследование приводит к файлу src/efivarfs.c
и функции efivarfs_get_variable
, которая показывает, что она читает файловую систему efivarfs (EFI var ), которая обычно находится в каталоге /sys/firmware/efi/efivarfs, и раскрывает ряд виртуальных "файлов". Файлы с именами, начинающимися с Boot000
, содержат информацию о параметрах загрузки, среди прочих данных, эти «необязательные данные», описывающие конкретную запись загрузки. Кажется, что «необязательные данные» загружаются только в том случае, если объединенная информация из имени загрузки, пути к файлу записи загрузки и «необязательных данных» не превышает opt_size
.
Дополнительная информация:
https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface#Services
Variable services
UEFI variables provide a way to store data, in particular non-volatile data. Some UEFI variables are shared between platform firmware and operating systems. Variable namespaces are identified by GUIDs, and variables are key/value pairs. For example, UEFI variables can be used to keep crash messages in NVRAM after a crash for the operating system to retrieve after a reboot.[45]
https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface#UEFI_booting
The boot configuration is defined by variables stored in NVRAM, including variables that indicate the file system paths to OS loaders or OS kernels.
Примечание:Спецификация UEFI говорит о «необязательных данных»:
https://uefi.org/specifications
https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf(стр. 72)
OptionalData
The remaining bytes in the load option descriptor are a binary data buffer that is passed to the loaded image. If the field is zero bytes long, a NULL pointer is passed to the loaded image. The number of bytes in OptionalData can be computed by subtracting the starting offset of OptionalData from total size in bytes of the EFI_LOAD_OPTION.