1 /* SPDX-License-Identifier: LGPL-2.1+ */
3 * This program is free software; you can redistribute it and/or modify it
4 * under the terms of the GNU Lesser General Public License as published by
5 * the Free Software Foundation; either version 2.1 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * Copyright (C) 2015 Kay Sievers <kay@vrfy.org>
21 EFI_STATUS
disk_get_part_uuid(EFI_HANDLE
*handle
, CHAR16 uuid
[37]) {
22 EFI_DEVICE_PATH
*device_path
;
24 /* export the device path this image is started from */
25 device_path
= DevicePathFromHandle(handle
);
27 _cleanup_freepool_ EFI_DEVICE_PATH
*paths
= NULL
;
28 EFI_DEVICE_PATH
*path
;
30 paths
= UnpackDevicePath(device_path
);
31 for (path
= paths
; !IsDevicePathEnd(path
); path
= NextDevicePathNode(path
)) {
32 HARDDRIVE_DEVICE_PATH
*drive
;
34 if (DevicePathType(path
) != MEDIA_DEVICE_PATH
)
36 if (DevicePathSubType(path
) != MEDIA_HARDDRIVE_DP
)
38 drive
= (HARDDRIVE_DEVICE_PATH
*)path
;
39 if (drive
->SignatureType
!= SIGNATURE_TYPE_GUID
)
42 GuidToString(uuid
, (EFI_GUID
*)&drive
->Signature
);