From b9c0d81eac650a2b1df7d3cafe0d41caed33421f Mon Sep 17 00:00:00 2001 From: Joursoir Date: Wed, 17 Nov 2021 19:25:43 +0300 Subject: add routines to get filesystems --- Library/UefiShellUfmCommandLib/fs.c | 47 +++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Library/UefiShellUfmCommandLib/fs.c (limited to 'Library/UefiShellUfmCommandLib/fs.c') diff --git a/Library/UefiShellUfmCommandLib/fs.c b/Library/UefiShellUfmCommandLib/fs.c new file mode 100644 index 0000000..edde591 --- /dev/null +++ b/Library/UefiShellUfmCommandLib/fs.c @@ -0,0 +1,47 @@ +#include +#include +#include +#include +#include +#include + +#include "fs.h" + +struct fs_array *fsa_alloc(EFI_HANDLE *handles, UINTN count) +{ + UINTN i; + struct fs_array *fsa; + EFI_DEVICE_PATH_PROTOCOL *dev_path; + CONST CHAR16 *map_list; + + fsa = AllocatePool(sizeof(struct fs_array)); + if(!fsa) + return NULL; + + fsa->full_name = AllocateZeroPool(count * sizeof(CHAR16 *)); + if(!fsa->full_name) { + fsa_release(fsa); + return NULL; + } + + fsa->len = count; + for(i = 0; i < count; i++) { + dev_path = DevicePathFromHandle(handles[i]); + map_list = gEfiShellProtocol->GetMapFromDevicePath(&dev_path); + } + + return fsa; +} + +VOID fsa_release(struct fs_array *fsa) +{ + UINTN i; + if(fsa->full_name) { + for(i = 0; i < fsa->len; i++) { + if(fsa->full_name[i]) // safety measure and our good sleep + FreePool(fsa->full_name[i]); + } + FreePool(fsa->full_name); + } + FreePool(fsa); +} -- cgit v1.2.3-18-g5258