]> git.proxmox.com Git - systemd.git/blob - src/boot/efi/disk.c
Merge tag 'upstream/229'
[systemd.git] / src / boot / efi / disk.c
1 /*
2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU Lesser General Public License as published by
4 * the Free Software Foundation; either version 2.1 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful, but
8 * WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * Lesser General Public License for more details.
11 *
12 * Copyright (C) 2015 Kay Sievers <kay@vrfy.org>
13 */
14
15 #include <efi.h>
16 #include <efilib.h>
17
18 #include "util.h"
19
20 EFI_STATUS disk_get_part_uuid(EFI_HANDLE *handle, CHAR16 uuid[37]) {
21 EFI_DEVICE_PATH *device_path;
22 EFI_STATUS r = EFI_NOT_FOUND;
23
24 /* export the device path this image is started from */
25 device_path = DevicePathFromHandle(handle);
26 if (device_path) {
27 EFI_DEVICE_PATH *path, *paths;
28
29 paths = UnpackDevicePath(device_path);
30 for (path = paths; !IsDevicePathEnd(path); path = NextDevicePathNode(path)) {
31 HARDDRIVE_DEVICE_PATH *drive;
32
33 if (DevicePathType(path) != MEDIA_DEVICE_PATH)
34 continue;
35 if (DevicePathSubType(path) != MEDIA_HARDDRIVE_DP)
36 continue;
37 drive = (HARDDRIVE_DEVICE_PATH *)path;
38 if (drive->SignatureType != SIGNATURE_TYPE_GUID)
39 continue;
40
41 GuidToString(uuid, (EFI_GUID *)&drive->Signature);
42 r = EFI_SUCCESS;
43 break;
44 }
45 FreePool(paths);
46 }
47
48 return r;
49 }