aboutsummaryrefslogtreecommitdiffstats
path: root/Library/UefiShellUfmCommandLib/fs.c
diff options
context:
space:
mode:
authorJoursoir <chat@joursoir.net>2021-11-17 19:25:43 +0300
committerJoursoir <chat@joursoir.net>2021-11-17 19:25:43 +0300
commitb9c0d81eac650a2b1df7d3cafe0d41caed33421f (patch)
tree0a523a56cc2d389b540b3946a3b254807e8c1a37 /Library/UefiShellUfmCommandLib/fs.c
parent7bbbcb62f632e12edc228b1ab675db88a331b20c (diff)
downloadufm-b9c0d81eac650a2b1df7d3cafe0d41caed33421f.tar.gz
ufm-b9c0d81eac650a2b1df7d3cafe0d41caed33421f.tar.bz2
ufm-b9c0d81eac650a2b1df7d3cafe0d41caed33421f.zip
add routines to get filesystems
Diffstat (limited to 'Library/UefiShellUfmCommandLib/fs.c')
-rw-r--r--Library/UefiShellUfmCommandLib/fs.c47
1 files changed, 47 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);
+}