[image] Allow for images to be hidden from lists of all images

When invoking a kernel via the UEFI shim, the kernel (and potentially
also a helper binary such as GRUB) must be accessible via the virtual
filesystem exposed via EFI_SIMPLE_FILE_SYSTEM_PROTOCOL but must not be
present in the magic initrd constructed from all registered images.

Allow for images to be flagged as hidden, which will cause them to be
excluded from API-level lists of all images such as the virtual
filesystem directory contents, the magic initrd, or the Multiboot
module list.  Hidden images remain visible to iPXE commands including
"imgstat", which will show a "[HIDDEN]" flag for such images.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2023-05-04 14:21:42 +01:00
parent f93e6b712f
commit f9beb20e99
5 changed files with 39 additions and 19 deletions

View File

@@ -250,6 +250,10 @@ static size_t efi_file_read_initrd ( struct efi_file_reader *reader ) {
len = 0;
for_each_image ( image ) {
/* Skip hidden images */
if ( image->flags & IMAGE_HIDDEN )
continue;
/* Pad to alignment boundary */
pad_len = ( ( -reader->pos ) & ( INITRD_ALIGN - 1 ) );
if ( pad_len ) {
@@ -524,13 +528,21 @@ static EFI_STATUS efi_file_read_dir ( struct efi_file *file, UINTN *len,
/* Construct directory entries for image-backed files */
index = file->pos;
for_each_image ( image ) {
if ( index-- == 0 ) {
efi_file_image ( &entry, image );
efirc = efi_file_info ( &entry, len, data );
if ( efirc == 0 )
file->pos++;
return efirc;
}
/* Skip hidden images */
if ( image->flags & IMAGE_HIDDEN )
continue;
/* Skip preceding images */
if ( index-- )
continue;
/* Construct directory entry */
efi_file_image ( &entry, image );
efirc = efi_file_info ( &entry, len, data );
if ( efirc == 0 )
file->pos++;
return efirc;
}
/* No more entries */
@@ -1093,6 +1105,7 @@ int efi_file_install ( EFI_HANDLE handle ) {
EFI_DISK_IO_PROTOCOL *diskio;
void *interface;
} diskio;
struct image *image;
EFI_STATUS efirc;
int rc;
@@ -1156,9 +1169,12 @@ int efi_file_install ( EFI_HANDLE handle ) {
goto err_initrd_claim;
/* Install Linux initrd fixed device path file if non-empty */
if ( have_images() &&
( ( rc = efi_file_path_install ( &efi_file_initrd ) ) != 0 ) ) {
goto err_initrd_install;
for_each_image ( image ) {
if ( image->flags & IMAGE_HIDDEN )
continue;
if ( ( rc = efi_file_path_install ( &efi_file_initrd ) ) != 0 )
goto err_initrd_install;
break;
}
return 0;