diff options
-rw-r--r-- | usr/src/boot/sys/boot/efi/include/efilib.h | 1 | ||||
-rw-r--r-- | usr/src/boot/sys/boot/efi/libefi/devpath.c | 31 |
2 files changed, 31 insertions, 1 deletions
diff --git a/usr/src/boot/sys/boot/efi/include/efilib.h b/usr/src/boot/sys/boot/efi/include/efilib.h index e5eadf6a5d..180757c9e5 100644 --- a/usr/src/boot/sys/boot/efi/include/efilib.h +++ b/usr/src/boot/sys/boot/efi/include/efilib.h @@ -74,6 +74,7 @@ EFI_HANDLE efi_devpath_handle(EFI_DEVICE_PATH *); EFI_DEVICE_PATH *efi_devpath_last_node(EFI_DEVICE_PATH *); EFI_DEVICE_PATH *efi_devpath_trim(EFI_DEVICE_PATH *); 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 *); diff --git a/usr/src/boot/sys/boot/efi/libefi/devpath.c b/usr/src/boot/sys/boot/efi/libefi/devpath.c index ab56d97a9a..86172ba093 100644 --- a/usr/src/boot/sys/boot/efi/libefi/devpath.c +++ b/usr/src/boot/sys/boot/efi/libefi/devpath.c @@ -141,7 +141,7 @@ efi_devpath_handle(EFI_DEVICE_PATH *devpath) bool efi_devpath_match(EFI_DEVICE_PATH *devpath1, EFI_DEVICE_PATH *devpath2) { - size_t len; + size_t len; if (devpath1 == NULL || devpath2 == NULL) return (false); @@ -165,3 +165,32 @@ efi_devpath_match(EFI_DEVICE_PATH *devpath1, EFI_DEVICE_PATH *devpath2) } return (true); } + +bool +efi_devpath_is_prefix(EFI_DEVICE_PATH *prefix, EFI_DEVICE_PATH *path) +{ + size_t len; + + if (prefix == NULL || path == NULL) + return (false); + + while (1) { + if (IsDevicePathEnd(prefix)) + break; + + if (DevicePathType(prefix) != DevicePathType(path) || + DevicePathSubType(prefix) != DevicePathSubType(path)) + return (false); + + len = DevicePathNodeLength(prefix); + if (len != DevicePathNodeLength(path)) + return (false); + + if (memcmp(prefix, path, len) != 0) + return (false); + + prefix = NextDevicePathNode(prefix); + path = NextDevicePathNode(path); + } + return (true); +} |