]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/boot/efi/disk.c
Add SPDX license identifiers to source files under the LGPL
[thirdparty/systemd.git] / src / boot / efi / disk.c
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
8110e144
KS
2/*
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.
7 *
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.
12 *
13 * Copyright (C) 2015 Kay Sievers <kay@vrfy.org>
14 */
15
16#include <efi.h>
17#include <efilib.h>
18
19#include "util.h"
20
21EFI_STATUS disk_get_part_uuid(EFI_HANDLE *handle, CHAR16 uuid[37]) {
22 EFI_DEVICE_PATH *device_path;
23 EFI_STATUS r = EFI_NOT_FOUND;
24
25 /* export the device path this image is started from */
26 device_path = DevicePathFromHandle(handle);
27 if (device_path) {
28 EFI_DEVICE_PATH *path, *paths;
29
30 paths = UnpackDevicePath(device_path);
31 for (path = paths; !IsDevicePathEnd(path); path = NextDevicePathNode(path)) {
32 HARDDRIVE_DEVICE_PATH *drive;
33
34 if (DevicePathType(path) != MEDIA_DEVICE_PATH)
35 continue;
36 if (DevicePathSubType(path) != MEDIA_HARDDRIVE_DP)
37 continue;
38 drive = (HARDDRIVE_DEVICE_PATH *)path;
39 if (drive->SignatureType != SIGNATURE_TYPE_GUID)
40 continue;
41
42 GuidToString(uuid, (EFI_GUID *)&drive->Signature);
43 r = EFI_SUCCESS;
44 break;
45 }
46 FreePool(paths);
47 }
48
49 return r;
50}