Implement efi_devpath_length

Return the total length, in bytes, of the device path (including the
terminating node at the end).

Sponsored by: Netflix
This commit is contained in:
Warner Losh 2018-07-23 20:36:50 +00:00
parent 13850b362f
commit c6c2a73c0c
2 changed files with 11 additions and 0 deletions

View File

@ -90,6 +90,7 @@ 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 *);
UINTN efi_devpath_length(EFI_DEVICE_PATH *);
int efi_status_to_errno(EFI_STATUS);
EFI_STATUS errno_to_efi_status(int errno);

View File

@ -219,3 +219,13 @@ efi_devpath_to_media_path(EFI_DEVICE_PATH *path)
}
return (NULL);
}
UINTN
efi_devpath_length(EFI_DEVICE_PATH *path)
{
EFI_DEVICE_PATH *start = path;
while (!IsDevicePathEnd(path))
path = NextDevicePathNode(path);
return ((UINTN)path - (UINTN)start) + DevicePathNodeLength(path);
}