OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
OpenFile.c File Reference
#include <Uefi.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/DevicePathLib.h>
#include <Library/OcFileLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Protocol/DevicePath.h>
#include <Protocol/SimpleFileSystem.h>

Go to the source code of this file.

Functions

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)
 
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)
 

Detailed Description

The UEFI Library provides functions and macros that simplify the development of UEFI Drivers and UEFI Applications. These functions and macros help manage EFI events, build simple locks utilizing EFI Task Priority Levels (TPLs), install EFI Driver Model related protocols, manage Unicode string tables for UEFI Drivers, and print messages on the console output and standard error devices. Copyright (c) 2006 - 2018, Intel Corporation. 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 OpenFile.c.

Function Documentation

◆ 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.

◆ 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.