1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * Copyright (C) 2015 Kay Sievers <kay@vrfy.org>
22 EFI_STATUS disk_get_part_uuid(EFI_HANDLE *handle, CHAR16 uuid[37]) {
23 EFI_DEVICE_PATH *device_path;
24 EFI_STATUS r = EFI_NOT_FOUND;
26 /* export the device path this image is started from */
27 device_path = DevicePathFromHandle(handle);
29 EFI_DEVICE_PATH *path, *paths;
31 paths = UnpackDevicePath(device_path);
32 for (path = paths; !IsDevicePathEnd(path); path = NextDevicePathNode(path)) {
33 HARDDRIVE_DEVICE_PATH *drive;
35 if (DevicePathType(path) != MEDIA_DEVICE_PATH)
37 if (DevicePathSubType(path) != MEDIA_HARDDRIVE_DP)
39 drive = (HARDDRIVE_DEVICE_PATH *)path;
40 if (drive->SignatureType != SIGNATURE_TYPE_GUID)
43 GuidToString(uuid, (EFI_GUID *)&drive->Signature);