Changeset View
Changeset View
Standalone View
Standalone View
head/stand/efi/libefi/devpath.c
Show First 20 Lines • Show All 191 Lines • ▼ Show 20 Lines | efi_devpath_match_node(EFI_DEVICE_PATH *devpath1, EFI_DEVICE_PATH *devpath2) | ||||
len = DevicePathNodeLength(devpath1); | len = DevicePathNodeLength(devpath1); | ||||
if (len != DevicePathNodeLength(devpath2)) | if (len != DevicePathNodeLength(devpath2)) | ||||
return (false); | return (false); | ||||
if (memcmp(devpath1, devpath2, len) != 0) | if (memcmp(devpath1, devpath2, len) != 0) | ||||
return (false); | return (false); | ||||
return (true); | return (true); | ||||
} | } | ||||
bool | static bool | ||||
efi_devpath_match(EFI_DEVICE_PATH *devpath1, EFI_DEVICE_PATH *devpath2) | _efi_devpath_match(EFI_DEVICE_PATH *devpath1, EFI_DEVICE_PATH *devpath2, | ||||
bool ignore_media) | |||||
{ | { | ||||
if (devpath1 == NULL || devpath2 == NULL) | if (devpath1 == NULL || devpath2 == NULL) | ||||
return (false); | return (false); | ||||
while (true) { | while (true) { | ||||
if (ignore_media && | |||||
IsDevicePathType(devpath1, MEDIA_DEVICE_PATH) && | |||||
IsDevicePathType(devpath2, MEDIA_DEVICE_PATH)) | |||||
return (true); | |||||
if (!efi_devpath_match_node(devpath1, devpath2)) | if (!efi_devpath_match_node(devpath1, devpath2)) | ||||
return false; | return false; | ||||
if (IsDevicePathEnd(devpath1)) | if (IsDevicePathEnd(devpath1)) | ||||
break; | break; | ||||
devpath1 = NextDevicePathNode(devpath1); | devpath1 = NextDevicePathNode(devpath1); | ||||
devpath2 = NextDevicePathNode(devpath2); | devpath2 = NextDevicePathNode(devpath2); | ||||
} | } | ||||
return (true); | return (true); | ||||
} | |||||
/* | |||||
* Are two devpaths identical? | |||||
*/ | |||||
bool | |||||
efi_devpath_match(EFI_DEVICE_PATH *devpath1, EFI_DEVICE_PATH *devpath2) | |||||
{ | |||||
return _efi_devpath_match(devpath1, devpath2, false); | |||||
} | |||||
/* | |||||
* Like efi_devpath_match, but stops at when we hit the media device | |||||
* path node that specifies the partition information. If we match | |||||
* up to that point, then we're on the same disk. | |||||
*/ | |||||
bool | |||||
efi_devpath_same_disk(EFI_DEVICE_PATH *devpath1, EFI_DEVICE_PATH *devpath2) | |||||
{ | |||||
return _efi_devpath_match(devpath1, devpath2, true); | |||||
} | } | ||||
bool | bool | ||||
efi_devpath_is_prefix(EFI_DEVICE_PATH *prefix, EFI_DEVICE_PATH *path) | efi_devpath_is_prefix(EFI_DEVICE_PATH *prefix, EFI_DEVICE_PATH *path) | ||||
{ | { | ||||
size_t len; | size_t len; | ||||
if (prefix == NULL || path == NULL) | if (prefix == NULL || path == NULL) | ||||
▲ Show 20 Lines • Show All 70 Lines • Show Last 20 Lines |