diff options
author | Warner Losh <imp@FreeBSD.org> | 2019-06-04 18:36:07 +0000 |
---|---|---|
committer | Warner Losh <imp@FreeBSD.org> | 2019-06-04 18:36:07 +0000 |
commit | 83ffeb8b520559bf9055658f030b63c0372c76f7 (patch) | |
tree | 9a0cc0b391309624a4882e9291b6a292e6931227 /stand/efi | |
parent | bc589b723e7838634c32548cdff2150c5cf20fed (diff) |
Introduce efi_devpath_same_disk
This is like efi_devpath_match, but allows differing device media
paths. Those just specify the partition information.
Differential Revision: https://reviews.freebsd.org/D20513
Notes
Notes:
svn path=/head/; revision=348658
Diffstat (limited to 'stand/efi')
-rw-r--r-- | stand/efi/include/efilib.h | 1 | ||||
-rw-r--r-- | stand/efi/libefi/devpath.c | 28 |
2 files changed, 27 insertions, 2 deletions
diff --git a/stand/efi/include/efilib.h b/stand/efi/include/efilib.h index 154e73af5f5d..91fa294965a3 100644 --- a/stand/efi/include/efilib.h +++ b/stand/efi/include/efilib.h @@ -90,6 +90,7 @@ bool efi_devpath_match_node(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 *); +bool efi_devpath_same_disk(EFI_DEVICE_PATH *, EFI_DEVICE_PATH *); EFI_DEVICE_PATH *efi_devpath_to_media_path(EFI_DEVICE_PATH *); UINTN efi_devpath_length(EFI_DEVICE_PATH *); EFI_DEVICE_PATH *efi_name_to_devpath(const char *path); diff --git a/stand/efi/libefi/devpath.c b/stand/efi/libefi/devpath.c index 44da1b3b6738..a61a4add6827 100644 --- a/stand/efi/libefi/devpath.c +++ b/stand/efi/libefi/devpath.c @@ -197,14 +197,19 @@ efi_devpath_match_node(EFI_DEVICE_PATH *devpath1, EFI_DEVICE_PATH *devpath2) return (true); } -bool -efi_devpath_match(EFI_DEVICE_PATH *devpath1, EFI_DEVICE_PATH *devpath2) +static bool +_efi_devpath_match(EFI_DEVICE_PATH *devpath1, EFI_DEVICE_PATH *devpath2, + bool ignore_media) { if (devpath1 == NULL || devpath2 == NULL) return (false); while (true) { + if (ignore_media && + IsDevicePathType(devpath1, MEDIA_DEVICE_PATH) && + IsDevicePathType(devpath2, MEDIA_DEVICE_PATH)) + return (true); if (!efi_devpath_match_node(devpath1, devpath2)) return false; if (IsDevicePathEnd(devpath1)) @@ -214,6 +219,25 @@ efi_devpath_match(EFI_DEVICE_PATH *devpath1, EFI_DEVICE_PATH *devpath2) } 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 efi_devpath_is_prefix(EFI_DEVICE_PATH *prefix, EFI_DEVICE_PATH *path) |