Author: imp Date: Mon Jul 23 20:36:54 2018 New Revision: 336655 URL: https://svnweb.freebsd.org/changeset/base/336655
Log: Implement efiblk_get_pdinfo_by_device_path Lookup a block device by it's device path. We use a 'loose' lookup whereby we scan forward to the first Media Path portion of the device path, then look at all our handles for one whose first Media Path matches. This will also work if the device path pointed to has a following file path (or paths) as that's ignored. It assumes that there's only one media path node that describes the entire device, which is true as of the latest UEFI spec (2.7 Errata A) as far as I've been able to determine. Sponsored by: Netflix Modified: head/stand/efi/include/efilib.h head/stand/efi/libefi/efipart.c Modified: head/stand/efi/include/efilib.h ============================================================================== --- head/stand/efi/include/efilib.h Mon Jul 23 20:36:50 2018 (r336654) +++ head/stand/efi/include/efilib.h Mon Jul 23 20:36:54 2018 (r336655) @@ -66,6 +66,7 @@ typedef struct pdinfo pdinfo_list_t *efiblk_get_pdinfo_list(struct devsw *dev); pdinfo_t *efiblk_get_pdinfo(struct devdesc *dev); pdinfo_t *efiblk_get_pdinfo_by_handle(EFI_HANDLE h); +pdinfo_t *efiblk_get_pdinfo_by_device_path(EFI_DEVICE_PATH *path); void *efi_get_table(EFI_GUID *tbl); Modified: head/stand/efi/libefi/efipart.c ============================================================================== --- head/stand/efi/libefi/efipart.c Mon Jul 23 20:36:50 2018 (r336654) +++ head/stand/efi/libefi/efipart.c Mon Jul 23 20:36:54 2018 (r336655) @@ -137,6 +137,28 @@ efiblk_get_pdinfo(struct devdesc *dev) return (pd); } +pdinfo_t * +efiblk_get_pdinfo_by_device_path(EFI_DEVICE_PATH *path) +{ + unsigned i; + EFI_DEVICE_PATH *media, *devpath; + EFI_HANDLE h; + + media = efi_devpath_to_media_path(path); + if (media == NULL) + return (NULL); + for (i = 0; i < efipart_nhandles; i++) { + h = efipart_handles[i]; + devpath = efi_lookup_devpath(h); + if (devpath == NULL) + continue; + if (!efi_devpath_match_node(media, efi_devpath_to_media_path(devpath))) + continue; + return (efiblk_get_pdinfo_by_handle(h)); + } + return (NULL); +} + static bool same_handle(pdinfo_t *pd, EFI_HANDLE h) { _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"