From: Andreas Reichel <
andreas.r...@siemens.com>
To decide wether a volume is on the boot medium, add a
function that extracts the part of the device path that
describes the boot medium (in the use cases we have atm).
Signed-off-by: Andreas Reichel <
andreas.r...@siemens.com>
---
include/utils.h | 1 +
utils.c | 25 +++++++++++++++++++++++++
2 files changed, 26 insertions(+)
diff --git a/include/utils.h b/include/utils.h
index b8eddd1..e7c76fc 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -41,5 +41,6 @@ EFI_STATUS get_volumes(VOLUME_DESC **volumes, UINTN *count);
EFI_STATUS close_volumes(VOLUME_DESC *volumes, UINTN count);
EFI_DEVICE_PATH *FileDevicePathFromConfig(EFI_HANDLE device,
CHAR16 *payloadpath);
+CHAR16 *GetBootMediumPath(CHAR16 *input);
#endif // __H_UTILS__
diff --git a/utils.c b/utils.c
index 5aff01b..c544eeb 100644
--- a/utils.c
+++ b/utils.c
@@ -271,3 +271,28 @@ EFI_DEVICE_PATH *FileDevicePathFromConfig(EFI_HANDLE device,
return appendeddevpath;
}
+
+CHAR16 *GetBootMediumPath(CHAR16 *input)
+{
+ CHAR16 *dst;
+ UINTN len;
+
+ len = StrLen(input);
+
+ dst = mmalloc((len + 1) * sizeof(CHAR16));
+ if (!dst) {
+ return NULL;
+ }
+
+ StrCpy(dst, input);
+
+ for (UINTN i = len; i > 0; i--)
+ {
+ if (dst[i * sizeof(CHAR16)] == L'/') {
+ dst[i * sizeof(CHAR16)] = L'\0';
+ break;
+ }
+ }
+
+ return dst;
+}
--
2.18.0