Implement efi_devpath_to_media_path

Takes a generic device path as its input. Scans through it to find the
first media_path node in it and returns a pointer to it. If none is
found, NULL is returned.

Sponsored by: Netflix
This commit is contained in:
Warner Losh 2018-07-23 20:36:25 +00:00
parent 03154ade2a
commit ee4e1d5807
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=336651
2 changed files with 17 additions and 0 deletions

View File

@ -88,6 +88,7 @@ bool efi_devpath_match(EFI_DEVICE_PATH *, EFI_DEVICE_PATH *);
bool efi_devpath_is_prefix(EFI_DEVICE_PATH *, EFI_DEVICE_PATH *);
CHAR16 *efi_devpath_name(EFI_DEVICE_PATH *);
void efi_free_devpath_name(CHAR16 *);
EFI_DEVICE_PATH *efi_devpath_to_media_path(EFI_DEVICE_PATH *);
int efi_status_to_errno(EFI_STATUS);
EFI_STATUS errno_to_efi_status(int errno);

View File

@ -195,3 +195,19 @@ efi_devpath_is_prefix(EFI_DEVICE_PATH *prefix, EFI_DEVICE_PATH *path)
}
return (true);
}
/*
* Skip over the 'prefix' part of path and return the part of the path
* that starts with the first node that's a MEDIA_DEVICE_PATH.
*/
EFI_DEVICE_PATH *
efi_devpath_to_media_path(EFI_DEVICE_PATH *path)
{
while (!IsDevicePathEnd(path)) {
if (DevicePathType(path) == MEDIA_DEVICE_PATH)
return (path);
path = NextDevicePathNode(path);
}
return (NULL);
}