summaryrefslogtreecommitdiffstats
path: root/src/interface/efi/efi_block.c
diff options
context:
space:
mode:
authorMichael Brown2024-03-06 09:55:55 +0100
committerMichael Brown2024-03-06 17:11:29 +0100
commitcea22d76e4cfdbd2d5a3a29bd541346710760457 (patch)
tree989f3ba4e8c9a604ecf060ce5aa5ce53dd526cca /src/interface/efi/efi_block.c
parent[efi] Add efi_path_guid() utility function (diff)
downloadipxe-cea22d76e4cfdbd2d5a3a29bd541346710760457.tar.gz
ipxe-cea22d76e4cfdbd2d5a3a29bd541346710760457.tar.xz
ipxe-cea22d76e4cfdbd2d5a3a29bd541346710760457.zip
[block] Allow SAN boot device to be identified by UUID
Add a "--uuid" option which may be used to specify a boot device UUID, to be matched against the GPT partition GUID. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/interface/efi/efi_block.c')
-rw-r--r--src/interface/efi/efi_block.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/interface/efi/efi_block.c b/src/interface/efi/efi_block.c
index e81d6bb7..f5b913f1 100644
--- a/src/interface/efi/efi_block.c
+++ b/src/interface/efi/efi_block.c
@@ -597,6 +597,7 @@ static int efi_block_match ( unsigned int drive, EFI_HANDLE handle,
EFI_DEVICE_PATH_PROTOCOL *path;
void *interface;
} u;
+ union uuid guid;
EFI_STATUS efirc;
int rc;
@@ -623,6 +624,21 @@ static int efi_block_match ( unsigned int drive, EFI_HANDLE handle,
DBGC ( drive, "EFIBLK %#02x contains filesystem %s\n",
drive, efi_devpath_text ( u.path ) );
+ /* Check if filesystem matches GUID, if applicable */
+ if ( config->uuid ) {
+ if ( ( rc = efi_path_guid ( u.path, &guid ) ) != 0 ) {
+ DBGC ( drive, "EFIBLK %#02x could not determine GUID: "
+ "%s\n", drive, strerror ( rc ) );
+ goto err_no_guid;
+ }
+ if ( memcmp ( config->uuid, &guid, sizeof ( guid ) ) != 0 ) {
+ DBGC ( drive, "EFIBLK %#02x has wrong GUID %s\n",
+ drive, uuid_ntoa ( &guid ) );
+ rc = -ENOENT;
+ goto err_wrong_guid;
+ }
+ }
+
/* Check if filesystem contains boot filename */
if ( ( rc = efi_block_filename ( drive, handle,
config->filename ) ) != 0 ) {
@@ -633,6 +649,8 @@ static int efi_block_match ( unsigned int drive, EFI_HANDLE handle,
rc = 0;
err_filename:
+ err_wrong_guid:
+ err_no_guid:
err_not_child:
bs->CloseProtocol ( handle, protocol, efi_image_handle, handle );
err_open: