UEFIStarter
a simple UEFI framework
Functions
files.c File Reference

File handling functions. More...

#include <Library/UefiLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Protocol/SimpleFileSystem.h>
#include <Guid/FileInfo.h>
#include <UEFIStarter/core/files.h>
#include <UEFIStarter/core/memory.h>
#include <UEFIStarter/core/logger.h>

Functions

EFI_FILE_HANDLE find_root_volume ()
 Opens a handle for the first filesystem root. More...
 
EFI_FILE_HANDLE find_file (CHAR16 *pathname)
 Opens a file handle, if the given file exists. More...
 
file_contents_tget_file_contents (CHAR16 *filename)
 Reads a file's contents. More...
 

Detailed Description

File handling functions.

Author
Richard Nusser
License
GPLv3 (see http://www.gnu.org/licenses/)
See also
https://github.com/rinusser/UEFIStarter

Function Documentation

◆ find_root_volume()

EFI_FILE_HANDLE find_root_volume ( )

Opens a handle for the first filesystem root.

In the UEFI shell, this will most likely be FS0:.

Returns
the root volume's handle on success, NULL otherwise

◆ find_file()

EFI_FILE_HANDLE find_file ( CHAR16 *  pathname)

Opens a file handle, if the given file exists.

This assumes the file is on the first root volume (usually FS0:).

Parameters
pathnamethe file's full path within the volume, e.g. "\\startup.nsh" to get the startup script.
Returns
a handle to the file on success, NULL otherwise

◆ get_file_contents()

file_contents_t* get_file_contents ( CHAR16 *  filename)

Reads a file's contents.

If you just want to read files you'll probably want to use this function: it performs all the UEFI overhead for you already. All you have to do is free the returned pointer's memory pages when you're done.

Parameters
filenamethe file's full path within the volume, e.g. "\\startup.nsh" to get the startup script.
Returns
a pointer to the file content descriptor, or NULL on error
Todo:
start a list of pitfalls, e.g. this: bufsize was too small (unsigned int instead of UINTN), so this call changed the last declared uninitialized variable in this function