Changeset View
Changeset View
Standalone View
Standalone View
sys/boot/efi/loader/main.c
Show First 20 Lines • Show All 798 Lines • ▼ Show 20 Lines | |||||
#ifdef EFI_ZFS_BOOT | #ifdef EFI_ZFS_BOOT | ||||
static void | static void | ||||
efi_zfs_probe(void) | efi_zfs_probe(void) | ||||
{ | { | ||||
pdinfo_list_t *hdi; | pdinfo_list_t *hdi; | ||||
pdinfo_t *hd, *pd = NULL; | pdinfo_t *hd, *pd = NULL; | ||||
EFI_GUID imgid = LOADED_IMAGE_PROTOCOL; | EFI_GUID imgid = LOADED_IMAGE_PROTOCOL; | ||||
EFI_LOADED_IMAGE *img; | EFI_LOADED_IMAGE *img; | ||||
EFI_HANDLE boot_disk = NULL; | |||||
char devname[SPECNAMELEN + 1]; | char devname[SPECNAMELEN + 1]; | ||||
uint64_t *guidp = NULL; | |||||
BS->HandleProtocol(IH, &imgid, (VOID**)&img); | BS->HandleProtocol(IH, &imgid, (VOID**)&img); | ||||
/* Find the handle for the boot disk. */ | |||||
hdi = efiblk_get_pdinfo_list(&efipart_hddev); | hdi = efiblk_get_pdinfo_list(&efipart_hddev); | ||||
STAILQ_FOREACH(hd, hdi, pd_link) { | |||||
STAILQ_FOREACH(pd, &hd->pd_part, pd_link) { | |||||
if (pd->pd_handle == img->DeviceHandle) | |||||
boot_disk = hd->pd_handle; | |||||
} | |||||
} | |||||
/* | /* | ||||
smh: Comment needs updating | |||||
* We provide non-NULL guid pointer if the disk was used for boot, | * Find the handle for the boot device. The boot1 did find the | ||||
* and reset after the first found pool. | * device with loader binary, now we need to search for the | ||||
* Technically this solution is not very correct, we assume the boot | * same device and if it is part of the zfs pool, we record the | ||||
* pool is the first pool on this disk. | * pool GUID for currdev setup. | ||||
*/ | */ | ||||
STAILQ_FOREACH(hd, hdi, pd_link) { | STAILQ_FOREACH(hd, hdi, pd_link) { | ||||
if (hd->pd_handle == boot_disk) | |||||
guidp = &pool_guid; | |||||
STAILQ_FOREACH(pd, &hd->pd_part, pd_link) { | STAILQ_FOREACH(pd, &hd->pd_part, pd_link) { | ||||
Done Inline ActionsThis logic is confusing why not just do: if (pd->pd_handle == boot_dev) (void) zfs_probe_dev(devname, &pool_guid); else (void) zfs_probe_dev(devname, NULL); Also why not merge the two sets of loops? smh: This logic is confusing why not just do:
```
if (pd->pd_handle == boot_dev)… | |||||
Not Done Inline Actionsyes, no need for them. nuked. tsoome: yes, no need for them. nuked. | |||||
snprintf(devname, sizeof(devname), "%s%dp%d:", | snprintf(devname, sizeof(devname), "%s%dp%d:", | ||||
efipart_hddev.dv_name, hd->pd_unit, pd->pd_unit); | efipart_hddev.dv_name, hd->pd_unit, pd->pd_unit); | ||||
(void) zfs_probe_dev(devname, guidp); | if (pd->pd_handle == img->DeviceHandle) | ||||
if (guidp != NULL && pool_guid != 0) | (void) zfs_probe_dev(devname, &pool_guid); | ||||
guidp = NULL; | else | ||||
(void) zfs_probe_dev(devname, NULL); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
uint64_t | uint64_t | ||||
ldi_get_size(void *priv) | ldi_get_size(void *priv) | ||||
{ | { | ||||
int fd = (uintptr_t) priv; | int fd = (uintptr_t) priv; | ||||
uint64_t size; | uint64_t size; | ||||
ioctl(fd, DIOCGMEDIASIZE, &size); | ioctl(fd, DIOCGMEDIASIZE, &size); | ||||
return (size); | return (size); | ||||
} | } | ||||
#endif | #endif |
Comment needs updating