Revert r322941: Eliminate redundant device matching functions
Turns out, they are subtly different. I'll refactor anew in the future if it's worth it then. Sponsored by: Netflix Reported by: Tomoaki AOKI-san
This commit is contained in:
parent
3dcd9d784a
commit
d419d89ec9
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=323131
@ -108,6 +108,53 @@ efi_setenv_freebsd_wcs(const char *varname, CHAR16 *valstr)
|
||||
return (rv);
|
||||
}
|
||||
|
||||
/*
|
||||
* nodes_match returns TRUE if the imgpath isn't NULL and the nodes match,
|
||||
* FALSE otherwise.
|
||||
*/
|
||||
static BOOLEAN
|
||||
nodes_match(EFI_DEVICE_PATH *imgpath, EFI_DEVICE_PATH *devpath)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
if (imgpath == NULL || imgpath->Type != devpath->Type ||
|
||||
imgpath->SubType != devpath->SubType)
|
||||
return (FALSE);
|
||||
|
||||
len = DevicePathNodeLength(imgpath);
|
||||
if (len != DevicePathNodeLength(devpath))
|
||||
return (FALSE);
|
||||
|
||||
return (memcmp(imgpath, devpath, (size_t)len) == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* device_paths_match returns TRUE if the imgpath isn't NULL and all nodes
|
||||
* in imgpath and devpath match up to their respective occurrences of a
|
||||
* media node, FALSE otherwise.
|
||||
*/
|
||||
static BOOLEAN
|
||||
device_paths_match(EFI_DEVICE_PATH *imgpath, EFI_DEVICE_PATH *devpath)
|
||||
{
|
||||
|
||||
if (imgpath == NULL)
|
||||
return (FALSE);
|
||||
|
||||
while (!IsDevicePathEnd(imgpath) && !IsDevicePathEnd(devpath)) {
|
||||
if (IsDevicePathType(imgpath, MEDIA_DEVICE_PATH) &&
|
||||
IsDevicePathType(devpath, MEDIA_DEVICE_PATH))
|
||||
return (TRUE);
|
||||
|
||||
if (!nodes_match(imgpath, devpath))
|
||||
return (FALSE);
|
||||
|
||||
imgpath = NextDevicePathNode(imgpath);
|
||||
devpath = NextDevicePathNode(devpath);
|
||||
}
|
||||
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
* devpath_last returns the last non-path end node in devpath.
|
||||
*/
|
||||
@ -304,7 +351,7 @@ probe_handle(EFI_HANDLE h, EFI_DEVICE_PATH *imgpath, BOOLEAN *preferred)
|
||||
if (!blkio->Media->LogicalPartition)
|
||||
return (EFI_UNSUPPORTED);
|
||||
|
||||
*preferred = efi_devpath_match(imgpath, devpath);
|
||||
*preferred = device_paths_match(imgpath, devpath);
|
||||
|
||||
/* Run through each module, see if it can load this partition */
|
||||
for (i = 0; i < NUM_BOOT_MODULES; i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user