diff options
author | Joursoir <chat@joursoir.net> | 2021-11-17 19:25:43 +0300 |
---|---|---|
committer | Joursoir <chat@joursoir.net> | 2021-11-17 19:25:43 +0300 |
commit | b9c0d81eac650a2b1df7d3cafe0d41caed33421f (patch) | |
tree | 0a523a56cc2d389b540b3946a3b254807e8c1a37 | |
parent | 7bbbcb62f632e12edc228b1ab675db88a331b20c (diff) | |
download | ufm-b9c0d81eac650a2b1df7d3cafe0d41caed33421f.tar.gz ufm-b9c0d81eac650a2b1df7d3cafe0d41caed33421f.tar.bz2 ufm-b9c0d81eac650a2b1df7d3cafe0d41caed33421f.zip |
add routines to get filesystems
-rw-r--r-- | Library/UefiShellUfmCommandLib/fs.c | 47 | ||||
-rw-r--r-- | Library/UefiShellUfmCommandLib/fs.h | 30 |
2 files changed, 77 insertions, 0 deletions
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 <Library/UefiLib.h> +#include <Library/DebugLib.h> +#include <Library/ShellLib.h> +#include <Library/MemoryAllocationLib.h> +#include <Library/DevicePathLib.h> +#include <Library/ShellCommandLib.h> + +#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); +} diff --git a/Library/UefiShellUfmCommandLib/fs.h b/Library/UefiShellUfmCommandLib/fs.h new file mode 100644 index 0000000..f7625b1 --- /dev/null +++ b/Library/UefiShellUfmCommandLib/fs.h @@ -0,0 +1,30 @@ +#ifndef UFM_FS_H +#define UFM_FS_H + +#include <Uefi.h> + +struct fs_array { + CHAR16 **full_name; + int len; // number of elements in array +}; + +/* + * Gets the mapped names of the filesystems + * + * handles: a pointer to the buffer to array of handles that support Simple FS Protocol + * count: the number of handles + * + * return: A pointer to the allocated structure or NULL if allocation fails +*/ +struct fs_array *fsa_alloc(EFI_HANDLE *handles, UINTN count); + +/* + * Deletes the array of filesystems, frees the structure + * + * fsa: the pointer to the array of filesystems + * + * return: VOID +*/ +VOID fsa_release(struct fs_array *fsa); + +#endif /* UFM_FS_H */ |