1 /* SPDX-License-Identifier: LGPL-2.1-or-later */ 2 3 #include <efi.h> 4 #include <efilib.h> 5 6 #include "disk.h" 7 #include "util.h" 8 disk_get_part_uuid(EFI_HANDLE * handle,CHAR16 uuid[static37])9EFI_STATUS disk_get_part_uuid(EFI_HANDLE *handle, CHAR16 uuid[static 37]) { 10 EFI_DEVICE_PATH *device_path; 11 _cleanup_freepool_ EFI_DEVICE_PATH *paths = NULL; 12 13 if (!handle) 14 return EFI_NOT_FOUND; 15 16 /* export the device path this image is started from */ 17 device_path = DevicePathFromHandle(handle); 18 if (!device_path) 19 return EFI_NOT_FOUND; 20 21 paths = UnpackDevicePath(device_path); 22 for (EFI_DEVICE_PATH *path = paths; !IsDevicePathEnd(path); path = NextDevicePathNode(path)) { 23 HARDDRIVE_DEVICE_PATH *drive; 24 25 if (DevicePathType(path) != MEDIA_DEVICE_PATH) 26 continue; 27 if (DevicePathSubType(path) != MEDIA_HARDDRIVE_DP) 28 continue; 29 drive = (HARDDRIVE_DEVICE_PATH *)path; 30 if (drive->SignatureType != SIGNATURE_TYPE_GUID) 31 continue; 32 33 GuidToString(uuid, (EFI_GUID *)&drive->Signature); 34 return EFI_SUCCESS; 35 } 36 37 return EFI_NOT_FOUND; 38 } 39