Implement BlpLoadConfigurationFile() routine
All checks were successful
Builds / ExectOS (amd64) (push) Successful in 29s
Builds / ExectOS (i686) (push) Successful in 27s

This commit is contained in:
Rafal Kupiec 2023-12-08 19:29:10 +01:00
parent e1be0e56ea
commit 40e7b29af8
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
2 changed files with 63 additions and 0 deletions

View File

@ -9,6 +9,63 @@
#include <xtldr.h>
/**
* Loads configuration file from the specified directory on the FS0:/ drive.
*
* @param ConfigDirectory
* Specifies a path to the directory containing the configuration file.
*
* @param ConfigFile
* Specifies the name of the configuration file.
*
* @param ConfigData
* Provides a buffer to store the data read from the configuration file.
*
* @return This routine returns status code.
*
* @since XT 1.0
*/
XTCDECL
EFI_STATUS
BlpLoadConfigurationFile(IN CONST PWCHAR ConfigDirectory,
IN CONST PWCHAR ConfigFile,
OUT PCHAR *ConfigData)
{
PEFI_FILE_HANDLE DirHandle, FsHandle;
EFI_HANDLE DiskHandle;
EFI_STATUS Status;
SIZE_T FileSize;
/* Open EFI volume */
Status = BlOpenVolume(NULL, &DiskHandle, &FsHandle);
if(Status != STATUS_EFI_SUCCESS)
{
/* Failed to open a volume */
return Status;
}
/* Open specified directory, containing the configuration file and close the FS immediately */
Status = FsHandle->Open(FsHandle, &DirHandle, ConfigDirectory, EFI_FILE_MODE_READ, 0);
FsHandle->Close(FsHandle);
/* Check if directory opened successfully */
if(Status != STATUS_EFI_SUCCESS)
{
/* Failed to open directory */
BlCloseVolume(DiskHandle);
return Status;
}
/* Read configuration file */
Status = BlReadFile(DirHandle, ConfigFile, (PVOID *)ConfigData, &FileSize);
/* Close EFI volume */
BlCloseVolume(DiskHandle);
/* Return read status */
return STATUS_EFI_SUCCESS;
}
/**
* Parses command line arguments and updates global configuration.
*

View File

@ -141,6 +141,12 @@ BlpFindParentBlockDevice(IN PLIST_ENTRY BlockDevices,
IN PEFI_BLOCK_DEVICE_DATA ChildNode,
OUT PEFI_BLOCK_DEVICE_DATA ParentNode);
XTCDECL
EFI_STATUS
BlpLoadConfigurationFile(IN CONST PWCHAR ConfigDirectory,
IN CONST PWCHAR ConfigFile,
OUT PCHAR *ConfigData);
XTCDECL
VOID
BlpParseCommandLineOptions(VOID);