OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
OcFileLib.h File Reference
#include <Guid/FileInfo.h>
#include <IndustryStandard/Mbr.h>
#include <Protocol/SimpleFileSystem.h>
#include <Protocol/DevicePath.h>
#include <Protocol/BlockIo.h>
#include <Protocol/BlockIo2.h>

Go to the source code of this file.

Data Structures

struct  DIRECTORY_SEARCH_CONTEXT
 
struct  OC_DISK_CONTEXT
 
struct  OC_PARTITION_ENTRIES
 

Macros

#define OC_MAX_VOLUME_LABEL_SIZE   64
 
#define OC_MAX_CONTENT_FLAVOUR_SIZE   64
 

Typedefs

typedef EFI_STATUS(* OC_PROCESS_DIRECTORY_ENTRY) (EFI_FILE_HANDLE Directory, EFI_FILE_INFO *FileInfo, UINTN FileInfoSize, VOID *Context OPTIONAL)
 

Functions

EFI_SIMPLE_FILE_SYSTEM_PROTOCOL * OcLocateFileSystem (IN EFI_HANDLE DeviceHandle OPTIONAL, IN EFI_DEVICE_PATH_PROTOCOL *FilePath OPTIONAL)
 
EFI_FILE_PROTOCOL * OcLocateRootVolume (IN EFI_HANDLE DeviceHandle OPTIONAL, IN EFI_DEVICE_PATH_PROTOCOL *FilePath OPTIONAL)
 
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL * OcLocateFileSystemByGuid (IN CONST GUID *Guid)
 
CHAR16 * OcGetVolumeLabel (IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *FileSystem)
 
EFI_STATUS OcSafeFileOpen (IN CONST EFI_FILE_PROTOCOL *Directory, OUT EFI_FILE_PROTOCOL **NewHandle, IN CONST CHAR16 *FileName, IN CONST UINT64 OpenMode, IN CONST UINT64 Attributes)
 
BOOLEAN OcFileExists (IN CONST EFI_FILE_PROTOCOL *Directory, IN CONST CHAR16 *FileName)
 
EFI_STATUS OcDeleteFile (IN EFI_FILE_PROTOCOL *Directory, IN CONST CHAR16 *FileName)
 
VOID * OcReadFile (IN CONST EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *FileSystem, IN CONST CHAR16 *FilePath, OUT UINT32 *FileSize OPTIONAL, IN CONST UINT32 MaxFileSize OPTIONAL)
 
VOID * OcReadFileFromDirectory (IN CONST EFI_FILE_PROTOCOL *RootDirectory, IN CONST CHAR16 *FilePath, OUT UINT32 *FileSize OPTIONAL, IN UINT32 MaxFileSize OPTIONAL)
 
EFI_STATUS OcReadFileSize (IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *FileSystem, IN CONST CHAR16 *FilePath, OUT UINT32 *Size)
 
EFI_STATUS OcGetFileData (IN EFI_FILE_PROTOCOL *File, IN UINT32 Position, IN UINT32 Size, OUT UINT8 *Buffer)
 
EFI_STATUS OcSetFileData (IN EFI_FILE_PROTOCOL *WritableFs OPTIONAL, IN CONST CHAR16 *FileName, IN CONST VOID *Buffer, IN UINT32 Size)
 
EFI_STATUS OcAllocateCopyFileData (IN EFI_FILE_PROTOCOL *File, OUT UINT8 **Buffer, OUT UINT32 *BufferSize)
 
VOID OcDirectorySeachContextInit (IN OUT DIRECTORY_SEARCH_CONTEXT *Context)
 
EFI_STATUS OcGetNewestFileFromDirectory (IN OUT DIRECTORY_SEARCH_CONTEXT *Context, IN EFI_FILE_PROTOCOL *Directory, IN CHAR16 *FileNameStartsWith OPTIONAL, OUT EFI_FILE_INFO **FileInfo)
 
EFI_STATUS OcEnsureDirectoryFile (IN EFI_FILE_PROTOCOL *File, IN BOOLEAN IsDirectory)
 
EFI_STATUS OcScanDirectory (IN EFI_FILE_HANDLE Directory, IN OC_PROCESS_DIRECTORY_ENTRY ProcessEntry, IN OUT VOID *Context OPTIONAL)
 
VOID * OcGetFileInfo (IN EFI_FILE_PROTOCOL *File, IN EFI_GUID *InformationType, IN UINTN MinFileInfoSize, OUT UINTN *RealFileInfoSize OPTIONAL)
 
EFI_STATUS OcGetFileSize (IN EFI_FILE_PROTOCOL *File, OUT UINT32 *Size)
 
EFI_STATUS OcGetFileModificationTime (IN EFI_FILE_PROTOCOL *File, OUT EFI_TIME *Time)
 
BOOLEAN OcIsWritableFileSystem (IN EFI_FILE_PROTOCOL *Fs)
 
EFI_STATUS OcFindWritableFileSystem (IN OUT EFI_FILE_PROTOCOL **WritableFs)
 
EFI_STATUS OcFindWritableOcFileSystem (OUT EFI_FILE_PROTOCOL **FileSystem)
 
EFI_STATUS EFIAPI OcOpenFileByRemainingDevicePath (IN EFI_HANDLE FileSystemHandle, IN CONST EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath, OUT EFI_FILE_PROTOCOL **File, IN UINT64 OpenMode, IN UINT64 Attributes)
 
EFI_STATUS EFIAPI OcOpenFileByDevicePath (IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath, OUT EFI_FILE_PROTOCOL **File, IN UINT64 OpenMode, IN UINT64 Attributes)
 
EFI_DEVICE_PATH_PROTOCOL * OcDiskGetDevicePath (IN EFI_DEVICE_PATH_PROTOCOL *HdDevicePath)
 
EFI_HANDLE OcPartitionGetDiskHandle (IN EFI_DEVICE_PATH_PROTOCOL *HdDevicePath)
 
EFI_HANDLE OcPartitionGetPartitionHandle (IN EFI_DEVICE_PATH_PROTOCOL *HdDevicePath)
 
BOOLEAN OcIsDiskCdRom (IN EFI_DEVICE_PATH_PROTOCOL *DiskDevicePath)
 
EFI_STATUS OcDiskReadElTorito (IN EFI_DEVICE_PATH_PROTOCOL *DiskDevicePath, OUT UINT8 **Buffer, OUT UINTN *BufferSize)
 
EFI_DEVICE_PATH_PROTOCOL * OcDiskFindSystemPartitionPath (IN CONST EFI_DEVICE_PATH_PROTOCOL *DiskDevicePath, OUT UINTN *EspDevicePathSize, OUT EFI_HANDLE *EspDeviceHandle)
 
EFI_STATUS OcDiskInitializeContext (OUT OC_DISK_CONTEXT *Context, IN EFI_HANDLE DiskHandle, IN BOOLEAN UseBlockIo2)
 
EFI_STATUS OcDiskRead (IN OC_DISK_CONTEXT *Context, IN UINT64 Lba, IN UINTN BufferSize, OUT VOID *Buffer)
 
EFI_STATUS OcDiskWrite (IN OC_DISK_CONTEXT *Context, IN UINT64 Lba, IN UINTN BufferSize, IN VOID *Buffer)
 
CONST OC_PARTITION_ENTRIESOcGetDiskPartitions (IN EFI_HANDLE DiskHandle, IN BOOLEAN UseBlockIo2)
 
CONST EFI_PARTITION_ENTRY * OcGetGptPartitionEntry (IN EFI_HANDLE FsHandle)
 
MASTER_BOOT_RECORD * OcGetDiskMbrTable (IN EFI_HANDLE DiskHandle, IN BOOLEAN CheckPartitions)
 
EFI_STATUS OcDiskGetMbrPartitionIndex (IN EFI_HANDLE PartitionHandle, OUT UINT8 *PartitionIndex)
 
EFI_STATUS OcDiskMarkMbrPartitionActive (IN EFI_HANDLE DiskHandle, IN UINT8 PartitionIndex)
 
EFI_DEVICE_PATH_PROTOCOL * OcDiskFindActiveMbrPartitionPath (IN EFI_DEVICE_PATH_PROTOCOL *DiskDevicePath, OUT UINTN *PartitionDevicePathSize, OUT EFI_HANDLE *PartitionDeviceHandle)
 
EFI_DEVICE_PATH_PROTOCOL * OcCreateFvFileDevicePath (IN EFI_GUID *FileGuid)
 
VOID * OcReadFvFileSection (IN EFI_GUID *FileGuid, IN UINT8 SectionType, OUT UINT32 *FileSize)
 

Detailed Description

Copyright (C) 2016 - 2017, The HermitCrabs Lab. All rights reserved.

All rights reserved.

This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

Definition in file OcFileLib.h.

Macro Definition Documentation

◆ OC_MAX_CONTENT_FLAVOUR_SIZE

#define OC_MAX_CONTENT_FLAVOUR_SIZE   64

Maximum safe content flavour size.

Definition at line 37 of file OcFileLib.h.

◆ OC_MAX_VOLUME_LABEL_SIZE

#define OC_MAX_VOLUME_LABEL_SIZE   64

Maximum safe volume label size.

Definition at line 32 of file OcFileLib.h.

Typedef Documentation

◆ OC_PROCESS_DIRECTORY_ENTRY

typedef EFI_STATUS(* OC_PROCESS_DIRECTORY_ENTRY) (EFI_FILE_HANDLE Directory, EFI_FILE_INFO *FileInfo, UINTN FileInfoSize, VOID *Context OPTIONAL)

Process directory item.

Note: Successful processing must return EFI_SUCCESS or EFI_NOT_FOUND, or further processing will be aborted.

Return EFI_NOT_FOUND to continue processing but act if no file found.

Parameters
[in]DirectoryParent directory file handle.
[in]FileInfoEFI_FILE_INFO allocated from pool memory, will be freed after this call, data to preserve must be copied.
[in]FileInfoSizeFileInfoSize.
[in,out]ContextOptional application-specific context.
Return values
EFI_SUCCESSFile found and successfully processed.
EFI_NOT_FOUND(Act as if) no matching file was found.
otherError processing file (aborts directory scan).

Definition at line 330 of file OcFileLib.h.

Function Documentation

◆ OcAllocateCopyFileData()

EFI_STATUS OcAllocateCopyFileData ( IN EFI_FILE_PROTOCOL * File,
OUT UINT8 ** Buffer,
OUT UINT32 * BufferSize )

Read all bytes from EFI_FILE_PROTOCOL and return a buffer.

Parameters
[in]FileA pointer to the file protocol.
[out]BufferA pointer for the returned buffer.
[out]BufferSizeA pointer for the size of the returned buffer.
Return values
EFI_SUCCESSon success.

Definition at line 373 of file FileProtocol.c.

◆ OcCreateFvFileDevicePath()

EFI_DEVICE_PATH_PROTOCOL * OcCreateFvFileDevicePath ( IN EFI_GUID * FileGuid)

Creates a device path for a firmware file.

Parameters
[in]FileGuidFirmware file GUID.
Return values
devicepath allocated from pool on success.
NULLon failure (e.g. when a file is not present).

Definition at line 163 of file FirmwareFile.c.

◆ OcDeleteFile()

EFI_STATUS OcDeleteFile ( IN EFI_FILE_PROTOCOL * Directory,
IN CONST CHAR16 * FileName )

Delete child file relative to source file's location.

Parameters
DirectoryFile protocol instance of parent directory.
FileNameNull-terminated file name or relative path.
Return values
EFI_SUCCESSFile successfully deleted.
EFI_NOT_FOUNDFile was not present.
otherOther error opening or deleting file.

Definition at line 49 of file FileMisc.c.

◆ OcDirectorySeachContextInit()

VOID OcDirectorySeachContextInit ( IN OUT DIRECTORY_SEARCH_CONTEXT * Context)

Initialize DIRECTORY_SEARCH_CONTEXT.

Parameters
[in,out]ContextA pointer to the DIRECTORY_SEARCH_CONTEXT.

Definition at line 408 of file FileProtocol.c.

◆ OcDiskFindActiveMbrPartitionPath()

EFI_DEVICE_PATH_PROTOCOL * OcDiskFindActiveMbrPartitionPath ( IN EFI_DEVICE_PATH_PROTOCOL * DiskDevicePath,
OUT UINTN * PartitionDevicePathSize,
OUT EFI_HANDLE * PartitionDeviceHandle )

Locate the disk's active MBR partition.

Parameters
[in]DiskDevicePathThe Device Path of the disk to scan.
[out]PartitionDevicePathSizeThe size of the returned Device Path.
[out]PartitionDeviceHandleDevice handle of the returned partition.
Returns
The device path protocol from the discovered handle or NULL.

Definition at line 1057 of file DiskMisc.c.

◆ OcDiskFindSystemPartitionPath()

EFI_DEVICE_PATH_PROTOCOL * OcDiskFindSystemPartitionPath ( IN CONST EFI_DEVICE_PATH_PROTOCOL * DiskDevicePath,
OUT UINTN * EspDevicePathSize,
OUT EFI_HANDLE * EspDeviceHandle )

Locate the disk's EFI System Partition.

Parameters
[in]DiskDevicePathThe Device Path of the disk to scan.
[out]EspDevicePathSizeThe size of the returned Device Path.
[out]EspDeviceHandleDevice handle of the returned partition.
Returns
The device path protocol from the discovered handle or NULL.

Definition at line 458 of file DiskMisc.c.

◆ OcDiskGetDevicePath()

EFI_DEVICE_PATH_PROTOCOL * OcDiskGetDevicePath ( IN EFI_DEVICE_PATH_PROTOCOL * HdDevicePath)

Retrieve the disk's Device Path from a partition's Device Path.

Parameters
[in]HdDevicePathThe Device Path of the partition.
Return values
DevicePath or NULL

Definition at line 280 of file DiskMisc.c.

◆ OcDiskGetMbrPartitionIndex()

EFI_STATUS OcDiskGetMbrPartitionIndex ( IN EFI_HANDLE PartitionHandle,
OUT UINT8 * PartitionIndex )

Retrieve the MBR partition index for the specified partition.

Parameters
[in]PartitionHandlePartition device handle to retrieve MBR partition index for.
[out]PartitionIndexPointer to store partition index in.
Return values
EFI_SUCCESSon success.

Definition at line 908 of file DiskMisc.c.

◆ OcDiskInitializeContext()

EFI_STATUS OcDiskInitializeContext ( OUT OC_DISK_CONTEXT * Context,
IN EFI_HANDLE DiskHandle,
IN BOOLEAN UseBlockIo2 )

Initialize disk I/O context.

Parameters
[out]ContextDisk I/O context to intialize.
[in]DiskHandleDisk handle with protocols.
[in]UseBlockIo2Try to use BlockIo2 protocol if available.
Return values
EFI_SUCCESSon success.

Definition at line 46 of file DiskMisc.c.

◆ OcDiskMarkMbrPartitionActive()

EFI_STATUS OcDiskMarkMbrPartitionActive ( IN EFI_HANDLE DiskHandle,
IN UINT8 PartitionIndex )

Mark specified MBR partition as active.

Parameters
[in]DiskHandleDisk device handle containing MBR partition table
[in]PartitionIndexMBR partition index.
Return values
EFI_SUCCESSon success.

Definition at line 978 of file DiskMisc.c.

◆ OcDiskRead()

EFI_STATUS OcDiskRead ( IN OC_DISK_CONTEXT * Context,
IN UINT64 Lba,
IN UINTN BufferSize,
OUT VOID * Buffer )

Read information from disk.

Parameters
[in]ContextDisk I/O context.
[in]LbaLBA number to read from.
[in]BufferSizeBuffer size allocated in Buffer.
[out]BufferBuffer to store data in.
Return values
EFI_SUCCESSon success.

Definition at line 116 of file DiskMisc.c.

◆ OcDiskReadElTorito()

EFI_STATUS OcDiskReadElTorito ( IN EFI_DEVICE_PATH_PROTOCOL * DiskDevicePath,
OUT UINT8 ** Buffer,
OUT UINTN * BufferSize )

Read El-Torito boot sector from CD-ROM device.

Parameters
[in]DiskDevicePathThe Device Path of the disk.
[out]BufferPointer to pool-allocated buffer containing the boot sector data.
[out]BufferSizeSize of Buffer.
Return values
EFI_SUCCESSon success.

Definition at line 392 of file DiskMisc.c.

◆ OcDiskWrite()

EFI_STATUS OcDiskWrite ( IN OC_DISK_CONTEXT * Context,
IN UINT64 Lba,
IN UINTN BufferSize,
IN VOID * Buffer )

Write information to disk.

Parameters
[in]ContextDisk I/O context.
[in]LbaLBA number to write to.
[in]BufferSizeBuffer size allocated in Buffer.
[out]BufferBuffer containing data to write.
Return values
EFI_SUCCESSon success.

Definition at line 151 of file DiskMisc.c.

◆ OcEnsureDirectoryFile()

EFI_STATUS OcEnsureDirectoryFile ( IN EFI_FILE_PROTOCOL * File,
IN BOOLEAN IsDirectory )

Ensure specified file is directory or file as specified by IsDirectory.

Parameters
[in]FileThe file to check.
[in]IsDirectoryRequire that file is directory.
Return values
EFI_SUCCESSFile is directory/file as specified.
EFI_INVALID_PARAMETERFile is not directory/file as specified.

Definition at line 418 of file FileProtocol.c.

◆ OcFileExists()

BOOLEAN OcFileExists ( IN CONST EFI_FILE_PROTOCOL * Directory,
IN CONST CHAR16 * FileName )

Report existence of file relative to source file's location.

Parameters
DirectoryFile protocol instance of parent directory.
FileNameNull-terminated file name or relative path.
Return values
TRUEwhen file exists.

Definition at line 21 of file FileMisc.c.

◆ OcFindWritableFileSystem()

EFI_STATUS OcFindWritableFileSystem ( IN OUT EFI_FILE_PROTOCOL ** WritableFs)

Find writable filesystem.

Parameters
[in,out]WritableFsFirst found writeable file system.
Return values
EFI_SUCCESSon success.

Definition at line 206 of file FileProtocol.c.

◆ OcFindWritableOcFileSystem()

EFI_STATUS OcFindWritableOcFileSystem ( OUT EFI_FILE_PROTOCOL ** FileSystem)

Find writable filesystem from Bootstrap.

Parameters
[out]FileSystemPointer to first found writeable file system.
Return values
EFI_SUCCESSon success.

Definition at line 277 of file FileProtocol.c.

◆ OcGetDiskMbrTable()

MASTER_BOOT_RECORD * OcGetDiskMbrTable ( IN EFI_HANDLE DiskHandle,
IN BOOLEAN CheckPartitions )

Retrieve the disk MBR table, if applicable.

Parameters
[in]DiskHandleDisk device handle to retrive MBR partition table from.
[in]CheckPartitionsCheck partition layout. This should be FALSE for a PBR.
Return values
MBRpartition table or NULL.

Definition at line 828 of file DiskMisc.c.

◆ OcGetDiskPartitions()

CONST OC_PARTITION_ENTRIES * OcGetDiskPartitions ( IN EFI_HANDLE DiskHandle,
IN BOOLEAN UseBlockIo2 )

Retrieve the disk GPT partitions, if applicable.

Parameters
[in]DiskHandleDisk device handle to retrive partition table from.
[in]UseBlockIo2Use 2nd revision of Block I/O if available.
Return values
partitionentry list or NULL.

Definition at line 573 of file DiskMisc.c.

◆ OcGetFileData()

EFI_STATUS OcGetFileData ( IN EFI_FILE_PROTOCOL * File,
IN UINT32 Position,
IN UINT32 Size,
OUT UINT8 * Buffer )

Read exact amount of bytes from EFI_FILE_PROTOCOL at specified position.

Parameters
[in]FileA pointer to the file protocol.
[in]PositionPosition to read data from.
[in]SizeThe size of the data read.
[out]BufferA pointer to previously allocated buffer to read data to.
Return values
EFI_SUCCESSon success.

Definition at line 69 of file FileProtocol.c.

◆ OcGetFileInfo()

VOID * OcGetFileInfo ( IN EFI_FILE_PROTOCOL * File,
IN EFI_GUID * InformationType,
IN UINTN MinFileInfoSize,
OUT UINTN *RealFileInfoSize OPTIONAL )

Get file information of specified type.

Parameters
[in]FileA pointer to file handle.
[in]InformationTypeA pointer to file info GUID.
[in]MinFileInfoSizeMinimal size of the info provided.
[out]RealFileInfoSizeActual info size read (optional).
Return values
readfile info or NULL.

Definition at line 33 of file GetFileInfo.c.

◆ OcGetFileModificationTime()

EFI_STATUS OcGetFileModificationTime ( IN EFI_FILE_PROTOCOL * File,
OUT EFI_TIME * Time )

Determine file modification time.

Parameters
[in]FileA pointer to the file protocol.
[out]TimeModification time.
Return values
EFI_SUCCESSon success.

Definition at line 158 of file FileProtocol.c.

◆ OcGetFileSize()

EFI_STATUS OcGetFileSize ( IN EFI_FILE_PROTOCOL * File,
OUT UINT32 * Size )

Determine file size if it is less than 4 GB.

Parameters
[in]FileA pointer to the file protocol.
[out]Size32-bit file size.
Return values
EFI_SUCCESSon success.

Definition at line 114 of file FileProtocol.c.

◆ OcGetGptPartitionEntry()

CONST EFI_PARTITION_ENTRY * OcGetGptPartitionEntry ( IN EFI_HANDLE FsHandle)

Retrieve the partition's GPT information, if applicable. Calls to this function undergo internal lazy caching.

Parameters
[in]FsHandleThe device handle of the partition to retrieve info of.
Return values
partitionentry or NULL

Retrieve the partition's GPT information, if applicable

Parameters
[in]FsHandleThe device handle of the partition to retrieve info of.

Definition at line 732 of file DiskMisc.c.

◆ OcGetNewestFileFromDirectory()

EFI_STATUS OcGetNewestFileFromDirectory ( IN OUT DIRECTORY_SEARCH_CONTEXT * Context,
IN EFI_FILE_PROTOCOL * Directory,
IN CHAR16 *FileNameStartsWith OPTIONAL,
OUT EFI_FILE_INFO ** FileInfo )

Gets the next newest file from the specified directory.

Parameters
[in,out]ContextContext.
[in]DirectoryThe directory EFI_FILE_PROTOCOL instance.
[in]FileNameStartsWithSkip files starting with this value.
[out]FileInfoEFI_FILE_INFO allocated from pool memory.
Return values
EFI_SUCCESSon success.

Definition at line 444 of file FileProtocol.c.

◆ OcGetVolumeLabel()

CHAR16 * OcGetVolumeLabel ( IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL * FileSystem)

Retrieves volume label.

Parameters
[in]FileSystemA pointer to the file system protocol of the volume.
Return values
Apointer to the NULL terminated unicode volume label.

Definition at line 35 of file GetVolumeLabel.c.

◆ OcIsDiskCdRom()

BOOLEAN OcIsDiskCdRom ( IN EFI_DEVICE_PATH_PROTOCOL * DiskDevicePath)

Check if disk is a CD-ROM device.

Parameters
[in]DiskDevicePathThe Device Path of the disk.
Return values
DevicePath or NULL

Definition at line 369 of file DiskMisc.c.

◆ OcIsWritableFileSystem()

BOOLEAN OcIsWritableFileSystem ( IN EFI_FILE_PROTOCOL * Fs)

Check if filesystem is writable.

Parameters
[in]FsFile system to check.
Return values
TRUEon success.

Definition at line 177 of file FileProtocol.c.

◆ OcLocateFileSystem()

EFI_SIMPLE_FILE_SYSTEM_PROTOCOL * OcLocateFileSystem ( IN EFI_HANDLE DeviceHandle OPTIONAL,
IN EFI_DEVICE_PATH_PROTOCOL *FilePath OPTIONAL )

Locate file system from Device handle or path.

Parameters
[in]DeviceHandleDevice handle.
[in]FilePathDevice path.
Return values
simplefile system protocol or NULL.

Definition at line 29 of file LocateFileSystem.c.

◆ OcLocateFileSystemByGuid()

EFI_SIMPLE_FILE_SYSTEM_PROTOCOL * OcLocateFileSystemByGuid ( IN CONST GUID * Guid)

Locate file system from GUID.

Parameters
[in]GuidGUID of the volume to locate.
Return values
simplefile system protocol or NULL.

Definition at line 104 of file LocateFileSystem.c.

◆ OcLocateRootVolume()

EFI_FILE_PROTOCOL * OcLocateRootVolume ( IN EFI_HANDLE DeviceHandle OPTIONAL,
IN EFI_DEVICE_PATH_PROTOCOL *FilePath OPTIONAL )

Locate root volume from Device handle or path.

Parameters
[in]DeviceHandleDevice handle.
[in]FilePathDevice path.
Return values
openedfile protocol or NULL.

Definition at line 81 of file LocateFileSystem.c.

◆ OcOpenFileByDevicePath()

EFI_STATUS EFIAPI OcOpenFileByDevicePath ( IN OUT EFI_DEVICE_PATH_PROTOCOL ** FilePath,
OUT EFI_FILE_PROTOCOL ** File,
IN UINT64 OpenMode,
IN UINT64 Attributes )

Open a file or directory by device path. This is a modified version of EfiOpenFileByDevicePath function, which handles paths with trailing slashes, that cause Open failure on old firmware. EfiOpenFileByDevicePath is additionally not available in UDK.

See more details at: https://github.com/tianocore/edk2/commit/768b611136d0f2b99a99e446c089d1a30c3fa5d5

Parameters
[in,out]FilePathDevice path protocol.
[out]FileResulting file protocol.
[in]OpenModeFile open mode.
[in]AttributesFile attributes.
Return values
EFI_SUCCESSon succesful open.

Definition at line 206 of file OpenFile.c.

◆ OcOpenFileByRemainingDevicePath()

EFI_STATUS EFIAPI OcOpenFileByRemainingDevicePath ( IN EFI_HANDLE FileSystemHandle,
IN CONST EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath,
OUT EFI_FILE_PROTOCOL ** File,
IN UINT64 OpenMode,
IN UINT64 Attributes )

Open a file or directory by file system handle and path. See OcOpenFileByDevicePath() for more details.

Parameters
[in]FileSystemHandleFile System handle.
[in]RemainingDevicePathThe remaining Device Path (must be all file path nodes).
[out]FileResulting file protocol.
[in]OpenModeFile open mode.
[in]AttributesFile attributes.
Return values
EFI_SUCCESSon succesful open.

Definition at line 83 of file OpenFile.c.

◆ OcPartitionGetDiskHandle()

EFI_HANDLE OcPartitionGetDiskHandle ( IN EFI_DEVICE_PATH_PROTOCOL * HdDevicePath)

Retrieve the disk's device handle from a partition's Device Path.

Parameters
[in]HdDevicePathThe Device Path of the partition.
Return values
devicehandle or NULL

Retrieve the disk's device handle from a partition's Device Path.

Parameters
[in]HdDevicePathThe Device Path of the partition.

Definition at line 331 of file DiskMisc.c.

◆ OcPartitionGetPartitionHandle()

EFI_HANDLE OcPartitionGetPartitionHandle ( IN EFI_DEVICE_PATH_PROTOCOL * HdDevicePath)

Retrieve the partition's device handle from a partition's Device Path.

Parameters
[in]HdDevicePathThe Device Path of the partition.

Definition at line 353 of file DiskMisc.c.

◆ OcReadFile()

VOID * OcReadFile ( IN CONST EFI_SIMPLE_FILE_SYSTEM_PROTOCOL * FileSystem,
IN CONST CHAR16 * FilePath,
OUT UINT32 *FileSize OPTIONAL,
IN CONST UINT32 MaxFileSize OPTIONAL )

Read file from file system with implicit double (2 byte) null termination. Null termination does not affect the returned file size. Depending on the implementation 0 byte files may return null.

Parameters
[in]FileSystemA pointer to the file system protocol of the volume.
[in]FilePathThe full path to the file on the device.
[out]FileSizeThe size of the file read (optional).
[in]MaxFileSizeUpper file size bound (optional).
Return values
Apointer to a buffer containing file read or NULL.

Definition at line 33 of file ReadFile.c.

◆ OcReadFileFromDirectory()

VOID * OcReadFileFromDirectory ( IN CONST EFI_FILE_PROTOCOL * RootDirectory,
IN CONST CHAR16 * FilePath,
OUT UINT32 *FileSize OPTIONAL,
IN UINT32 MaxFileSize OPTIONAL )

Read file from file protocol with implicit double (2 byte) null termination. Null termination does not affect the returned file size. Depending on the implementation 0 byte files may return null.

Parameters
[in]RootDirectoryA pointer to the file protocol of the directory.
[in]FilePathThe full path to the file on the device.
[out]FileSizeThe size of the file read (optional).
[in]MaxFileSizeUpper file size bound (optional).
Return values
Apointer to a buffer containing file read or NULL.

Definition at line 155 of file ReadFile.c.

◆ OcReadFileSize()

EFI_STATUS OcReadFileSize ( IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL * FileSystem,
IN CONST CHAR16 * FilePath,
OUT UINT32 * Size )

Determine file size if it is less than 4 GB.

Parameters
[in]FileSystemA pointer to the file system protocol of the volume.
[in]FilePathThe full path to the file on the device.
[out]Size32-bit file size.
Return values
EFI_SUCCESSon success.

Definition at line 110 of file ReadFile.c.

◆ OcReadFvFileSection()

VOID * OcReadFvFileSection ( IN EFI_GUID * FileGuid,
IN UINT8 SectionType,
OUT UINT32 * FileSize )

Reads firmware file section to pool-allocated buffer.

Parameters
[in]FileGuidFirmware file GUID.
[in]SectionTypeSection type to read.
[out]FileSizeSize of the section read.
Returns
file contents allocated from pool.
Return values
NULLon failure (e.g. when a file is not present).

Definition at line 186 of file FirmwareFile.c.

◆ OcSafeFileOpen()

EFI_STATUS OcSafeFileOpen ( IN CONST EFI_FILE_PROTOCOL * Directory,
OUT EFI_FILE_PROTOCOL ** NewHandle,
IN CONST CHAR16 * FileName,
IN CONST UINT64 OpenMode,
IN CONST UINT64 Attributes )

Opens a new file relative to the source file's location. This function is equivalent to EFI_FILE_OPEN but has additional restrictions to provide board compatibility. Currently the only restriction is no trailing slash in the filename due to issues in FAT drivers.

  • Multiple boards, namely ASUS P8H61-M and P8H61-M LX2 will not open directories with trailing slash. It is irrelevant whether front slash is present for them. For example, it means that L"EFI\\OC\\" or L"\EFI\OC\" will both fail to open, while L"EFI\OC" and L"\EFI\OC" will open fine.
  • Most newer boards on APTIO IV do handle directories with trailing slash, however, their driver will modify passed string by removing the slash by \0.
Parameters
DirectoryFile protocol instance of parent directory.
NewHandlePointer for returned handle.
FileNameNull-terminated file name or relative path.
OpenModeFile open mode.
AttributesAttributes for the newly created file.
Return values
EFI_SUCCESSfor successfully opened file.

Definition at line 29 of file OpenFile.c.

◆ OcScanDirectory()

EFI_STATUS OcScanDirectory ( IN EFI_FILE_HANDLE Directory,
IN OC_PROCESS_DIRECTORY_ENTRY ProcessEntry,
IN OUT VOID *Context OPTIONAL )

Scan directory, calling specified procedure for each directory entry.

Parameters
[in]DirectoryThe directory to scan.
[in]ProcessEntryProcess entry, called for each directory entry matching filter.
[in,out]ContextOptional application-specific context.
Return values
EFI_NOT_FOUNDSuccessful processing, no entries matching filter were found.
EFI_SUCCESSSuccessful processing, at least one entry matching filter was found.
EFI_OUT_OF_RESOURCESOut of memory.
otherOther error returned by file system or ProcessEntry during processing

Definition at line 587 of file FileProtocol.c.

◆ OcSetFileData()

EFI_STATUS OcSetFileData ( IN EFI_FILE_PROTOCOL *WritableFs OPTIONAL,
IN CONST CHAR16 * FileName,
IN CONST VOID * Buffer,
IN UINT32 Size )

Write exact amount of bytes to a newly created file in EFI_FILE_PROTOCOL. Please note, that several filesystems (or drivers) may limit file name length.

Parameters
[in]WritableFsA pointer to the file protocol, any will be tried if NULL.
[in]FileNameFile name (possibly with path) to write.
[in]BufferA pointer with the data to be written.
[in]SizeAmount of data to be written.
Return values
EFI_SUCCESSon success.

Definition at line 312 of file FileProtocol.c.