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