TianoCore EDK2 master
Loading...
Searching...
No Matches
FileSystemOperations.c File Reference
#include "Udf.h"

Go to the source code of this file.

Functions

EFI_STATUS FindAnchorVolumeDescriptorPointer (IN EFI_BLOCK_IO_PROTOCOL *BlockIo, IN EFI_DISK_IO_PROTOCOL *DiskIo, OUT UDF_ANCHOR_VOLUME_DESCRIPTOR_POINTER *AnchorPoint)
 
EFI_STATUS StartMainVolumeDescriptorSequence (IN EFI_BLOCK_IO_PROTOCOL *BlockIo, IN EFI_DISK_IO_PROTOCOL *DiskIo, IN UDF_ANCHOR_VOLUME_DESCRIPTOR_POINTER *AnchorPoint, OUT UDF_VOLUME_INFO *Volume)
 
UDF_PARTITION_DESCRIPTORGetPdFromLongAd (IN UDF_VOLUME_INFO *Volume, IN UDF_LONG_ALLOCATION_DESCRIPTOR *LongAd)
 
EFI_STATUS GetLongAdLsn (IN UDF_VOLUME_INFO *Volume, IN UDF_LONG_ALLOCATION_DESCRIPTOR *LongAd, OUT UINT64 *Lsn)
 
UINT64 GetShortAdLsn (IN UDF_VOLUME_INFO *Volume, IN UDF_PARTITION_DESCRIPTOR *PartitionDesc, IN UDF_SHORT_ALLOCATION_DESCRIPTOR *ShortAd)
 
EFI_STATUS FindFileSetDescriptor (IN EFI_BLOCK_IO_PROTOCOL *BlockIo, IN EFI_DISK_IO_PROTOCOL *DiskIo, IN UDF_VOLUME_INFO *Volume)
 
EFI_STATUS ReadVolumeFileStructure (IN EFI_BLOCK_IO_PROTOCOL *BlockIo, IN EFI_DISK_IO_PROTOCOL *DiskIo, OUT UDF_VOLUME_INFO *Volume)
 
UINT64 GetFidDescriptorLength (IN UDF_FILE_IDENTIFIER_DESCRIPTOR *FileIdentifierDesc)
 
VOID DuplicateFid (IN UDF_FILE_IDENTIFIER_DESCRIPTOR *FileIdentifierDesc, OUT UDF_FILE_IDENTIFIER_DESCRIPTOR **NewFileIdentifierDesc)
 
VOID DuplicateFe (IN EFI_BLOCK_IO_PROTOCOL *BlockIo, IN UDF_VOLUME_INFO *Volume, IN VOID *FileEntry, OUT VOID **NewFileEntry)
 
EFI_STATUS GetFileEntryData (IN VOID *FileEntryData, IN UINTN FileEntrySize, OUT VOID **Data, OUT UINT64 *Length)
 
EFI_STATUS GetAdsInformation (IN VOID *FileEntryData, IN UINTN FileEntrySize, OUT VOID **AdsData, OUT UINT64 *Length)
 
EFI_STATUS GetLongAdFromAds (IN VOID *Data, IN OUT UINT64 *Offset, IN UINT64 Length, OUT UDF_LONG_ALLOCATION_DESCRIPTOR **FoundLongAd)
 
EFI_STATUS GetShortAdFromAds (IN VOID *Data, IN OUT UINT64 *Offset, IN UINT64 Length, OUT UDF_SHORT_ALLOCATION_DESCRIPTOR **FoundShortAd)
 
EFI_STATUS GetAllocationDescriptor (IN UDF_FE_RECORDING_FLAGS RecordingFlags, IN VOID *Data, IN OUT UINT64 *Offset, IN UINT64 Length, OUT VOID **FoundAd)
 
EFI_STATUS GetAllocationDescriptorLsn (IN UDF_FE_RECORDING_FLAGS RecordingFlags, IN UDF_VOLUME_INFO *Volume, IN UDF_LONG_ALLOCATION_DESCRIPTOR *ParentIcb, IN VOID *Ad, OUT UINT64 *Lsn)
 
EFI_STATUS GetAedAdsOffset (IN EFI_BLOCK_IO_PROTOCOL *BlockIo, IN EFI_DISK_IO_PROTOCOL *DiskIo, IN UDF_VOLUME_INFO *Volume, IN UDF_LONG_ALLOCATION_DESCRIPTOR *ParentIcb, IN UDF_FE_RECORDING_FLAGS RecordingFlags, IN VOID *Ad, OUT UINT64 *Offset, OUT UINT64 *Length)
 
EFI_STATUS GetAedAdsData (IN EFI_BLOCK_IO_PROTOCOL *BlockIo, IN EFI_DISK_IO_PROTOCOL *DiskIo, IN UDF_VOLUME_INFO *Volume, IN UDF_LONG_ALLOCATION_DESCRIPTOR *ParentIcb, IN UDF_FE_RECORDING_FLAGS RecordingFlags, IN VOID *Ad, OUT VOID **Data, OUT UINT64 *Length)
 
EFI_STATUS GrowUpBufferToNextAd (IN UDF_FE_RECORDING_FLAGS RecordingFlags, IN VOID *Ad, IN OUT VOID **Buffer, IN UINT64 Length)
 
EFI_STATUS ReadFile (IN EFI_BLOCK_IO_PROTOCOL *BlockIo, IN EFI_DISK_IO_PROTOCOL *DiskIo, IN UDF_VOLUME_INFO *Volume, IN UDF_LONG_ALLOCATION_DESCRIPTOR *ParentIcb, IN VOID *FileEntryData, IN OUT UDF_READ_FILE_INFO *ReadFileInfo)
 
EFI_STATUS InternalFindFile (IN EFI_BLOCK_IO_PROTOCOL *BlockIo, IN EFI_DISK_IO_PROTOCOL *DiskIo, IN UDF_VOLUME_INFO *Volume, IN CHAR16 *FileName, IN UDF_FILE_INFO *Parent, IN UDF_LONG_ALLOCATION_DESCRIPTOR *Icb, OUT UDF_FILE_INFO *File)
 
EFI_STATUS ReadUdfVolumeInformation (IN EFI_BLOCK_IO_PROTOCOL *BlockIo, IN EFI_DISK_IO_PROTOCOL *DiskIo, OUT UDF_VOLUME_INFO *Volume)
 
EFI_STATUS FindRootDirectory (IN EFI_BLOCK_IO_PROTOCOL *BlockIo, IN EFI_DISK_IO_PROTOCOL *DiskIo, IN UDF_VOLUME_INFO *Volume, OUT UDF_FILE_INFO *File)
 
EFI_STATUS FindFileEntry (IN EFI_BLOCK_IO_PROTOCOL *BlockIo, IN EFI_DISK_IO_PROTOCOL *DiskIo, IN UDF_VOLUME_INFO *Volume, IN UDF_LONG_ALLOCATION_DESCRIPTOR *Icb, OUT VOID **FileEntry)
 
EFI_STATUS FindFile (IN EFI_BLOCK_IO_PROTOCOL *BlockIo, IN EFI_DISK_IO_PROTOCOL *DiskIo, IN UDF_VOLUME_INFO *Volume, IN CHAR16 *FilePath, IN UDF_FILE_INFO *Root, IN UDF_FILE_INFO *Parent, IN UDF_LONG_ALLOCATION_DESCRIPTOR *Icb, OUT UDF_FILE_INFO *File)
 
EFI_STATUS ReadDirectoryEntry (IN EFI_BLOCK_IO_PROTOCOL *BlockIo, IN EFI_DISK_IO_PROTOCOL *DiskIo, IN UDF_VOLUME_INFO *Volume, IN UDF_LONG_ALLOCATION_DESCRIPTOR *ParentIcb, IN VOID *FileEntryData, IN OUT UDF_READ_DIRECTORY_INFO *ReadDirInfo, OUT UDF_FILE_IDENTIFIER_DESCRIPTOR **FoundFid)
 
EFI_STATUS GetFileNameFromFid (IN UDF_FILE_IDENTIFIER_DESCRIPTOR *FileIdentifierDesc, IN UINTN CharMax, OUT CHAR16 *FileName)
 
EFI_STATUS ResolveSymlink (IN EFI_BLOCK_IO_PROTOCOL *BlockIo, IN EFI_DISK_IO_PROTOCOL *DiskIo, IN UDF_VOLUME_INFO *Volume, IN UDF_FILE_INFO *Parent, IN VOID *FileEntryData, OUT UDF_FILE_INFO *File)
 
VOID CleanupFileInformation (IN UDF_FILE_INFO *File)
 
EFI_STATUS GetFileSize (IN EFI_BLOCK_IO_PROTOCOL *BlockIo, IN EFI_DISK_IO_PROTOCOL *DiskIo, IN UDF_VOLUME_INFO *Volume, IN UDF_FILE_INFO *File, OUT UINT64 *Size)
 
EFI_STATUS SetFileInfo (IN UDF_FILE_INFO *File, IN UINT64 FileSize, IN CHAR16 *FileName, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
 
EFI_STATUS GetVolumeLabel (IN UDF_VOLUME_INFO *Volume, IN UINTN CharMax, OUT CHAR16 *String)
 
EFI_STATUS GetVolumeSize (IN EFI_BLOCK_IO_PROTOCOL *BlockIo, IN EFI_DISK_IO_PROTOCOL *DiskIo, IN UDF_VOLUME_INFO *Volume, OUT UINT64 *VolumeSize, OUT UINT64 *FreeSpaceSize)
 
EFI_STATUS ReadFileData (IN EFI_BLOCK_IO_PROTOCOL *BlockIo, IN EFI_DISK_IO_PROTOCOL *DiskIo, IN UDF_VOLUME_INFO *Volume, IN UDF_FILE_INFO *File, IN UINT64 FileSize, IN OUT UINT64 *FilePosition, IN OUT VOID *Buffer, IN OUT UINT64 *BufferSize)
 
EFI_STATUS SupportUdfFileSystem (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle)
 

Variables

EFI_GUID gUdfDevPathGuid = EFI_UDF_DEVICE_PATH_GUID
 

Detailed Description

Handle on-disk format and volume structures in UDF/ECMA-167 file systems.

Copyright (C) 2014-2017 Paulo Alcantara pcacj.nosp@m.r@zy.nosp@m.tor.c.nosp@m.om Copyright (c) 2018, Intel Corporation. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file FileSystemOperations.c.

Function Documentation

◆ CleanupFileInformation()

VOID CleanupFileInformation ( IN UDF_FILE_INFO File)

Clean up in-memory UDF file information.

Parameters
[in]FileFile information pointer.

Definition at line 2395 of file FileSystemOperations.c.

◆ DuplicateFe()

VOID DuplicateFe ( IN EFI_BLOCK_IO_PROTOCOL BlockIo,
IN UDF_VOLUME_INFO Volume,
IN VOID *  FileEntry,
OUT VOID **  NewFileEntry 
)

Duplicate either a given File Entry or a given Extended File Entry.

Parameters
[in]BlockIoBlockIo interface.
[in]VolumeVolume information pointer.
[in]FileEntry(Extended) File Entry pointer.
[out]NewFileEntryThe duplicated (Extended) File Entry.

Definition at line 505 of file FileSystemOperations.c.

◆ DuplicateFid()

VOID DuplicateFid ( IN UDF_FILE_IDENTIFIER_DESCRIPTOR FileIdentifierDesc,
OUT UDF_FILE_IDENTIFIER_DESCRIPTOR **  NewFileIdentifierDesc 
)

Duplicate a given File Identifier Descriptor.

Parameters
[in]FileIdentifierDescFile Identifier Descriptor pointer.
[out]NewFileIdentifierDescThe duplicated File Identifier Descriptor.

Definition at line 483 of file FileSystemOperations.c.

◆ FindAnchorVolumeDescriptorPointer()

EFI_STATUS FindAnchorVolumeDescriptorPointer ( IN EFI_BLOCK_IO_PROTOCOL BlockIo,
IN EFI_DISK_IO_PROTOCOL DiskIo,
OUT UDF_ANCHOR_VOLUME_DESCRIPTOR_POINTER AnchorPoint 
)

Find the anchor volume descriptor pointer.

Parameters
[in]BlockIoBlockIo interface.
[in]DiskIoDiskIo interface.
[out]AnchorPointAnchor volume descriptor pointer.
Return values
EFI_SUCCESSAnchor volume descriptor pointer found.
EFI_VOLUME_CORRUPTEDThe file system structures are corrupted.
otherAnchor volume descriptor pointer not found.

Definition at line 30 of file FileSystemOperations.c.

◆ FindFile()

EFI_STATUS FindFile ( IN EFI_BLOCK_IO_PROTOCOL BlockIo,
IN EFI_DISK_IO_PROTOCOL DiskIo,
IN UDF_VOLUME_INFO Volume,
IN CHAR16 *  FilePath,
IN UDF_FILE_INFO Root,
IN UDF_FILE_INFO Parent,
IN UDF_LONG_ALLOCATION_DESCRIPTOR Icb,
OUT UDF_FILE_INFO File 
)

Find a file given its absolute path on an UDF volume.

Parameters
[in]BlockIoBlockIo interface.
[in]DiskIoDiskIo interface.
[in]VolumeUDF volume information structure.
[in]FilePathFile's absolute path.
[in]RootRoot directory file.
[in]ParentParent directory file.
[in]IcbICB of Parent.
[out]FileFound file.
Return values
EFI_SUCCESSFilePath was found.
EFI_NO_MEDIAThe device has no media.
EFI_DEVICE_ERRORThe device reported an error.
EFI_VOLUME_CORRUPTEDThe file system structures are corrupted.
EFI_OUT_OF_RESOURCESThe FilePath file was not found due to lack of resources.

Definition at line 1815 of file FileSystemOperations.c.

◆ FindFileEntry()

EFI_STATUS FindFileEntry ( IN EFI_BLOCK_IO_PROTOCOL BlockIo,
IN EFI_DISK_IO_PROTOCOL DiskIo,
IN UDF_VOLUME_INFO Volume,
IN UDF_LONG_ALLOCATION_DESCRIPTOR Icb,
OUT VOID **  FileEntry 
)

Find either a File Entry or a Extended File Entry from a given ICB.

Parameters
[in]BlockIoBlockIo interface.
[in]DiskIoDiskIo interface.
[in]VolumeUDF volume information structure.
[in]IcbICB of the FID.
[out]FileEntryFile Entry or Extended File Entry.
Return values
EFI_SUCCESSFile Entry or Extended File Entry found.
EFI_NO_MEDIAThe device has no media.
EFI_DEVICE_ERRORThe device reported an error.
EFI_VOLUME_CORRUPTEDThe file system structures are corrupted.
EFI_OUT_OF_RESOURCESThe FE/EFE entry was not found due to lack of resources.

Definition at line 1731 of file FileSystemOperations.c.

◆ FindFileSetDescriptor()

EFI_STATUS FindFileSetDescriptor ( IN EFI_BLOCK_IO_PROTOCOL BlockIo,
IN EFI_DISK_IO_PROTOCOL DiskIo,
IN UDF_VOLUME_INFO Volume 
)

Find File Set Descriptor of a given Logical Volume Descriptor.

The found FSD will contain the extent (LogicalVolumeContentsUse) where our root directory is.

Parameters
[in]BlockIoBlockIo interface.
[in]DiskIoDiskIo interface.
[in]VolumeVolume information pointer.
Return values
EFI_SUCCESSFile Set Descriptor pointer found.
EFI_VOLUME_CORRUPTEDThe file system structures are corrupted.
otherFile Set Descriptor pointer not found.

Definition at line 350 of file FileSystemOperations.c.

◆ FindRootDirectory()

EFI_STATUS FindRootDirectory ( IN EFI_BLOCK_IO_PROTOCOL BlockIo,
IN EFI_DISK_IO_PROTOCOL DiskIo,
IN UDF_VOLUME_INFO Volume,
OUT UDF_FILE_INFO File 
)

Find the root directory on an UDF volume.

Parameters
[in]BlockIoBlockIo interface.
[in]DiskIoDiskIo interface.
[in]VolumeUDF volume information structure.
[out]FileRoot directory file.
Return values
EFI_SUCCESSRoot directory found.
EFI_NO_MEDIAThe device has no media.
EFI_DEVICE_ERRORThe device reported an error.
EFI_VOLUME_CORRUPTEDThe file system structures are corrupted.
EFI_OUT_OF_RESOURCESThe root directory was not found due to lack of resources.

Definition at line 1672 of file FileSystemOperations.c.

◆ GetAdsInformation()

EFI_STATUS GetAdsInformation ( IN VOID *  FileEntryData,
IN UINTN  FileEntrySize,
OUT VOID **  AdsData,
OUT UINT64 *  Length 
)

Get Allocation Descriptors' data information from a given FE/EFE.

Attention
This is boundary function that may receive untrusted input.
The input is from FileSystem.

The (Extended) File Entry is external input, so this routine will do basic validation for (Extended) File Entry and report status.

Parameters
[in]FileEntryData(Extended) File Entry pointer.
[in]FileEntrySizeSize of the (Extended) File Entry specified by FileEntryData.
[out]AdsDataBuffer contains the Allocation Descriptors' data from a given FE/EFE.
[out]LengthLength of the data in AdsData.
Return values
EFI_SUCCESSThe data and size of Allocation Descriptors were read from the FE/EFE.
EFI_VOLUME_CORRUPTEDThe file system structures are corrupted.

Definition at line 601 of file FileSystemOperations.c.

◆ GetAedAdsData()

EFI_STATUS GetAedAdsData ( IN EFI_BLOCK_IO_PROTOCOL BlockIo,
IN EFI_DISK_IO_PROTOCOL DiskIo,
IN UDF_VOLUME_INFO Volume,
IN UDF_LONG_ALLOCATION_DESCRIPTOR ParentIcb,
IN UDF_FE_RECORDING_FLAGS  RecordingFlags,
IN VOID *  Ad,
OUT VOID **  Data,
OUT UINT64 *  Length 
)

Read Allocation Extent Descriptor into memory.

Parameters
[in]BlockIoBlockIo interface.
[in]DiskIoDiskIo interface.
[in]VolumeVolume information pointer.
[in]ParentIcbLong Allocation Descriptor pointer.
[in]RecordingFlagsFlag to indicate the type of descriptor.
[in]AdAllocation Descriptor pointer.
[out]DataBuffer that contains the Allocation Extent Descriptor.
[out]LengthLength of Data.
Return values
EFI_SUCCESSThe Allocation Extent Descriptor was read.
EFI_OUT_OF_RESOURCESThe Allocation Extent Descriptor was not read due to lack of resources.
otherFail to read the disk.

Definition at line 968 of file FileSystemOperations.c.

◆ GetAedAdsOffset()

EFI_STATUS GetAedAdsOffset ( IN EFI_BLOCK_IO_PROTOCOL BlockIo,
IN EFI_DISK_IO_PROTOCOL DiskIo,
IN UDF_VOLUME_INFO Volume,
IN UDF_LONG_ALLOCATION_DESCRIPTOR ParentIcb,
IN UDF_FE_RECORDING_FLAGS  RecordingFlags,
IN VOID *  Ad,
OUT UINT64 *  Offset,
OUT UINT64 *  Length 
)

Return offset + length of a given indirect Allocation Descriptor (AED).

Parameters
[in]BlockIoBlockIo interface.
[in]DiskIoDiskIo interface.
[in]VolumeVolume information pointer.
[in]ParentIcbLong Allocation Descriptor pointer.
[in]RecordingFlagsFlag to indicate the type of descriptor.
[in]AdAllocation Descriptor pointer.
[out]OffsetOffset of a given indirect Allocation Descriptor.
[out]LengthLength of a given indirect Allocation Descriptor.
Return values
EFI_SUCCESSThe offset and length were returned.
EFI_OUT_OF_RESOURCESThe offset and length were not returned due to lack of resources.
EFI_VOLUME_CORRUPTEDThe file system structures are corrupted.
otherThe offset and length were not returned.

Definition at line 871 of file FileSystemOperations.c.

◆ GetAllocationDescriptor()

EFI_STATUS GetAllocationDescriptor ( IN UDF_FE_RECORDING_FLAGS  RecordingFlags,
IN VOID *  Data,
IN OUT UINT64 *  Offset,
IN UINT64  Length,
OUT VOID **  FoundAd 
)

Get either a Short Allocation Descriptor or a Long Allocation Descriptor from file's data.

Parameters
[in]RecordingFlagsFlag to indicate the type of descriptor.
[in]DataFile's data pointer.
[in,out]OffsetStarting offset of the File's data to read.
[in]LengthLength of the data to read.
[out]FoundAdAllocation Descriptor pointer.
Return values
EFI_SUCCESSA Short Allocation Descriptor was found.
EFI_DEVICE_ERRORNo more Allocation Descriptors. Invalid type of descriptor was given.

Definition at line 768 of file FileSystemOperations.c.

◆ GetAllocationDescriptorLsn()

EFI_STATUS GetAllocationDescriptorLsn ( IN UDF_FE_RECORDING_FLAGS  RecordingFlags,
IN UDF_VOLUME_INFO Volume,
IN UDF_LONG_ALLOCATION_DESCRIPTOR ParentIcb,
IN VOID *  Ad,
OUT UINT64 *  Lsn 
)

Return logical sector number of either Short or Long Allocation Descriptor.

Parameters
[in]RecordingFlagsFlag to indicate the type of descriptor.
[in]VolumeVolume information pointer.
[in]ParentIcbLong Allocation Descriptor pointer.
[in]AdAllocation Descriptor pointer.
[out]LsnLogical sector number pointer.
Return values
EFI_SUCCESSLogical sector number of the given Allocation Descriptor successfully returned.
EFI_UNSUPPORTEDLogical sector number of the given Allocation Descriptor is not returned due to unrecognized format.

Definition at line 816 of file FileSystemOperations.c.

◆ GetFidDescriptorLength()

UINT64 GetFidDescriptorLength ( IN UDF_FILE_IDENTIFIER_DESCRIPTOR FileIdentifierDesc)

Calculate length of a given File Identifier Descriptor.

Parameters
[in]FileIdentifierDescFile Identifier Descriptor pointer.
Returns
The length of a given File Identifier Descriptor.

Definition at line 464 of file FileSystemOperations.c.

◆ GetFileEntryData()

EFI_STATUS GetFileEntryData ( IN VOID *  FileEntryData,
IN UINTN  FileEntrySize,
OUT VOID **  Data,
OUT UINT64 *  Length 
)

Get raw data + length of a given File Entry or Extended File Entry.

The file's recorded data can contain either real file content (inline) or a sequence of extents (or Allocation Descriptors) which tells where file's content is stored in.

NOTE: The FE/EFE can be thought it was an inode.

Attention
This is boundary function that may receive untrusted input.
The input is from FileSystem.

The (Extended) File Entry is external input, so this routine will do basic validation for (Extended) File Entry and report status.

Parameters
[in]FileEntryData(Extended) File Entry pointer.
[in]FileEntrySizeSize of the (Extended) File Entry specified by FileEntryData.
[out]DataBuffer contains the raw data of a given (Extended) File Entry.
[out]LengthLength of the data in Buffer.
Return values
EFI_SUCCESSRaw data and size of the FE/EFE was read.
EFI_VOLUME_CORRUPTEDThe file system structures are corrupted.

Definition at line 542 of file FileSystemOperations.c.

◆ GetFileNameFromFid()

EFI_STATUS GetFileNameFromFid ( IN UDF_FILE_IDENTIFIER_DESCRIPTOR FileIdentifierDesc,
IN UINTN  CharMax,
OUT CHAR16 *  FileName 
)

Get a filename (encoded in OSTA-compressed format) from a File Identifier Descriptor on an UDF volume.

Attention
This is boundary function that may receive untrusted input.
The input is from FileSystem.

The File Identifier Descriptor is external input, so this routine will do basic validation for File Identifier Descriptor and report status.

Parameters
[in]FileIdentifierDescFile Identifier Descriptor pointer.
[in]CharMaxThe maximum number of FileName Unicode char, including terminating null char.
[out]FileNameDecoded filename.
Return values
EFI_SUCCESSFilename decoded and read.
EFI_VOLUME_CORRUPTEDThe file system structures are corrupted.
EFI_BUFFER_TOO_SMALLThe string buffer FileName cannot hold the decoded filename.

Definition at line 2064 of file FileSystemOperations.c.

◆ GetFileSize()

EFI_STATUS GetFileSize ( IN EFI_BLOCK_IO_PROTOCOL BlockIo,
IN EFI_DISK_IO_PROTOCOL DiskIo,
IN UDF_VOLUME_INFO Volume,
IN UDF_FILE_INFO File,
OUT UINT64 *  Size 
)

Find a file from its absolute path on an UDF volume.

Parameters
[in]BlockIoBlockIo interface.
[in]DiskIoDiskIo interface.
[in]VolumeUDF volume information structure.
[in]FileFile information structure.
[out]SizeSize of the file.
Return values
EFI_SUCCESSFile size calculated and set in Size.
EFI_UNSUPPORTEDExtended Allocation Descriptors not supported.
EFI_NO_MEDIAThe device has no media.
EFI_DEVICE_ERRORThe device reported an error.
EFI_VOLUME_CORRUPTEDThe file system structures are corrupted.
EFI_OUT_OF_RESOURCESThe file size was not calculated due to lack of resources.

Definition at line 2429 of file FileSystemOperations.c.

◆ GetLongAdFromAds()

EFI_STATUS GetLongAdFromAds ( IN VOID *  Data,
IN OUT UINT64 *  Offset,
IN UINT64  Length,
OUT UDF_LONG_ALLOCATION_DESCRIPTOR **  FoundLongAd 
)

Read next Long Allocation Descriptor from a given file's data.

Parameters
[in]DataFile's data pointer.
[in,out]OffsetStarting offset of the File's data to read.
[in]LengthLength of the data to read.
[out]FoundLongAdLong Allocation Descriptor pointer.
Return values
EFI_SUCCESSA Long Allocation Descriptor was found.
EFI_DEVICE_ERRORNo more Long Allocation Descriptors.

Definition at line 651 of file FileSystemOperations.c.

◆ GetLongAdLsn()

EFI_STATUS GetLongAdLsn ( IN UDF_VOLUME_INFO Volume,
IN UDF_LONG_ALLOCATION_DESCRIPTOR LongAd,
OUT UINT64 *  Lsn 
)

Return logical sector number of a given Long Allocation Descriptor.

Parameters
[in]VolumeVolume information pointer.
[in]LongAdLong Allocation Descriptor pointer.
[out]LsnLogical sector number pointer.
Return values
EFI_SUCCESSLogical sector number successfully returned.
EFI_UNSUPPORTEDLogical sector number is not returned due to unrecognized format.

Definition at line 288 of file FileSystemOperations.c.

◆ GetPdFromLongAd()

UDF_PARTITION_DESCRIPTOR * GetPdFromLongAd ( IN UDF_VOLUME_INFO Volume,
IN UDF_LONG_ALLOCATION_DESCRIPTOR LongAd 
)

Return a Partition Descriptor given a Long Allocation Descriptor. This is necessary to calculate the right extent (LongAd) offset which is added up with partition's starting location.

Parameters
[in]VolumeVolume information pointer.
[in]LongAdLong Allocation Descriptor pointer.
Returns
A pointer to a Partition Descriptor.

Definition at line 211 of file FileSystemOperations.c.

◆ GetShortAdFromAds()

EFI_STATUS GetShortAdFromAds ( IN VOID *  Data,
IN OUT UINT64 *  Offset,
IN UINT64  Length,
OUT UDF_SHORT_ALLOCATION_DESCRIPTOR **  FoundShortAd 
)

Read next Short Allocation Descriptor from a given file's data.

Parameters
[in]DataFile's data pointer.
[in,out]OffsetStarting offset of the File's data to read.
[in]LengthLength of the data to read.
[out]FoundShortAdShort Allocation Descriptor pointer.
Return values
EFI_SUCCESSA Short Allocation Descriptor was found.
EFI_DEVICE_ERRORNo more Short Allocation Descriptors.

Definition at line 708 of file FileSystemOperations.c.

◆ GetShortAdLsn()

UINT64 GetShortAdLsn ( IN UDF_VOLUME_INFO Volume,
IN UDF_PARTITION_DESCRIPTOR PartitionDesc,
IN UDF_SHORT_ALLOCATION_DESCRIPTOR ShortAd 
)

Return logical sector number of a given Short Allocation Descriptor.

Parameters
[in]VolumeVolume pointer.
[in]PartitionDescPartition Descriptor pointer.
[in]ShortAdShort Allocation Descriptor pointer.
Returns
The logical sector number of a given Short Allocation Descriptor.

Definition at line 324 of file FileSystemOperations.c.

◆ GetVolumeLabel()

EFI_STATUS GetVolumeLabel ( IN UDF_VOLUME_INFO Volume,
IN UINTN  CharMax,
OUT CHAR16 *  String 
)

Get volume label of an UDF volume.

Attention
This is boundary function that may receive untrusted input.
The input is from FileSystem.

The File Set Descriptor is external input, so this routine will do basic validation for File Set Descriptor and report status.

Parameters
[in]VolumeVolume information pointer.
[in]CharMaxThe maximum number of Unicode char in String, including terminating null char.
[out]StringString buffer pointer to store the volume label.
Return values
EFI_SUCCESSVolume label is returned.
EFI_VOLUME_CORRUPTEDThe file system structures are corrupted.
EFI_BUFFER_TOO_SMALLThe string buffer String cannot hold the volume label.

Definition at line 2643 of file FileSystemOperations.c.

◆ GetVolumeSize()

EFI_STATUS GetVolumeSize ( IN EFI_BLOCK_IO_PROTOCOL BlockIo,
IN EFI_DISK_IO_PROTOCOL DiskIo,
IN UDF_VOLUME_INFO Volume,
OUT UINT64 *  VolumeSize,
OUT UINT64 *  FreeSpaceSize 
)

Get volume and free space size information of an UDF volume.

Attention
This is boundary function that may receive untrusted input.
The input is from FileSystem.

The Logical Volume Descriptor and the Logical Volume Integrity Descriptor are external inputs, so this routine will do basic validation for both descriptors and report status.

Parameters
[in]BlockIoBlockIo interface.
[in]DiskIoDiskIo interface.
[in]VolumeUDF volume information structure.
[out]VolumeSizeVolume size.
[out]FreeSpaceSizeFree space size.
Return values
EFI_SUCCESSVolume and free space size calculated.
EFI_NO_MEDIAThe device has no media.
EFI_DEVICE_ERRORThe device reported an error.
EFI_VOLUME_CORRUPTEDThe file system structures are corrupted.
EFI_OUT_OF_RESOURCESThe volume and free space size were not calculated due to lack of resources.

Definition at line 2732 of file FileSystemOperations.c.

◆ GrowUpBufferToNextAd()

EFI_STATUS GrowUpBufferToNextAd ( IN UDF_FE_RECORDING_FLAGS  RecordingFlags,
IN VOID *  Ad,
IN OUT VOID **  Buffer,
IN UINT64  Length 
)

Function used to serialise reads of Allocation Descriptors.

Parameters
[in]RecordingFlagsFlag to indicate the type of descriptor.
[in]AdAllocation Descriptor pointer.
[in,out]BufferBuffer to hold the next Allocation Descriptor.
[in]LengthLength of Buffer.
Return values
EFI_SUCCESSBuffer was grown to hold the next Allocation Descriptor.
EFI_OUT_OF_RESOURCESBuffer was not grown due to lack of resources.

Definition at line 1030 of file FileSystemOperations.c.

◆ InternalFindFile()

EFI_STATUS InternalFindFile ( IN EFI_BLOCK_IO_PROTOCOL BlockIo,
IN EFI_DISK_IO_PROTOCOL DiskIo,
IN UDF_VOLUME_INFO Volume,
IN CHAR16 *  FileName,
IN UDF_FILE_INFO Parent,
IN UDF_LONG_ALLOCATION_DESCRIPTOR Icb,
OUT UDF_FILE_INFO File 
)

Find a file by its filename from a given Parent file.

Parameters
[in]BlockIoBlockIo interface.
[in]DiskIoDiskIo interface.
[in]VolumeVolume information pointer.
[in]FileNameFile name string.
[in]ParentParent directory file.
[in]IcbLong Allocation Descriptor pointer.
[out]FileFound file.
Return values
EFI_SUCCESSThe file was found.
EFI_INVALID_PARAMETEROne or more input parameters are invalid.
EFI_NOT_FOUNDThe file was not found.

Definition at line 1435 of file FileSystemOperations.c.

◆ ReadDirectoryEntry()

EFI_STATUS ReadDirectoryEntry ( IN EFI_BLOCK_IO_PROTOCOL BlockIo,
IN EFI_DISK_IO_PROTOCOL DiskIo,
IN UDF_VOLUME_INFO Volume,
IN UDF_LONG_ALLOCATION_DESCRIPTOR ParentIcb,
IN VOID *  FileEntryData,
IN OUT UDF_READ_DIRECTORY_INFO ReadDirInfo,
OUT UDF_FILE_IDENTIFIER_DESCRIPTOR **  FoundFid 
)

Read a directory entry at a time on an UDF volume.

Parameters
[in]BlockIoBlockIo interface.
[in]DiskIoDiskIo interface.
[in]VolumeUDF volume information structure.
[in]ParentIcbICB of the parent file.
[in]FileEntryDataFE/EFE of the parent file.
[in,out]ReadDirInfoNext read directory listing structure information.
[out]FoundFidFile Identifier Descriptor pointer.
Return values
EFI_SUCCESSDirectory entry read.
EFI_UNSUPPORTEDExtended Allocation Descriptors not supported.
EFI_NO_MEDIAThe device has no media.
EFI_DEVICE_ERRORThe device reported an error.
EFI_VOLUME_CORRUPTEDThe file system structures are corrupted.
EFI_OUT_OF_RESOURCESThe directory entry was not read due to lack of resources.

Definition at line 1972 of file FileSystemOperations.c.

◆ ReadFile()

EFI_STATUS ReadFile ( IN EFI_BLOCK_IO_PROTOCOL BlockIo,
IN EFI_DISK_IO_PROTOCOL DiskIo,
IN UDF_VOLUME_INFO Volume,
IN UDF_LONG_ALLOCATION_DESCRIPTOR ParentIcb,
IN VOID *  FileEntryData,
IN OUT UDF_READ_FILE_INFO ReadFileInfo 
)

Read data or size of either a File Entry or an Extended File Entry.

Parameters
[in]BlockIoBlockIo interface.
[in]DiskIoDiskIo interface.
[in]VolumeVolume information pointer.
[in]ParentIcbLong Allocation Descriptor pointer.
[in]FileEntryDataFE/EFE structure pointer.
[in,out]ReadFileInfoRead file information pointer.
Return values
EFI_SUCCESSData or size of a FE/EFE was read.
EFI_OUT_OF_RESOURCESData or size of a FE/EFE was not read due to lack of resources.
EFI_INVALID_PARAMETERThe read file flag given in ReadFileInfo is invalid.
EFI_UNSUPPORTEDThe FE recording flag given in FileEntryData is not supported.
otherData or size of a FE/EFE was not read.

Definition at line 1077 of file FileSystemOperations.c.

◆ ReadFileData()

EFI_STATUS ReadFileData ( IN EFI_BLOCK_IO_PROTOCOL BlockIo,
IN EFI_DISK_IO_PROTOCOL DiskIo,
IN UDF_VOLUME_INFO Volume,
IN UDF_FILE_INFO File,
IN UINT64  FileSize,
IN OUT UINT64 *  FilePosition,
IN OUT VOID *  Buffer,
IN OUT UINT64 *  BufferSize 
)

Seek a file and read its data into memory on an UDF volume.

Parameters
[in]BlockIoBlockIo interface.
[in]DiskIoDiskIo interface.
[in]VolumeUDF volume information structure.
[in]FileFile information structure.
[in]FileSizeSize of the file.
[in,out]FilePositionFile position.
[in,out]BufferFile data.
[in,out]BufferSizeRead size.
Return values
EFI_SUCCESSFile seeked and read.
EFI_UNSUPPORTEDExtended Allocation Descriptors not supported.
EFI_NO_MEDIAThe device has no media.
EFI_DEVICE_ERRORThe device reported an error.
EFI_VOLUME_CORRUPTEDThe file system structures are corrupted.
EFI_OUT_OF_RESOURCESThe file's recorded data was not read due to lack of resources.

Definition at line 2873 of file FileSystemOperations.c.

◆ ReadUdfVolumeInformation()

EFI_STATUS ReadUdfVolumeInformation ( IN EFI_BLOCK_IO_PROTOCOL BlockIo,
IN EFI_DISK_IO_PROTOCOL DiskIo,
OUT UDF_VOLUME_INFO Volume 
)

Read volume information on a medium which contains a valid UDF file system.

Parameters
[in]BlockIoBlockIo interface.
[in]DiskIoDiskIo interface.
[out]VolumeUDF volume information structure.
Return values
EFI_SUCCESSVolume information read.
EFI_NO_MEDIAThe device has no media.
EFI_DEVICE_ERRORThe device reported an error.
EFI_VOLUME_CORRUPTEDThe file system structures are corrupted.
EFI_OUT_OF_RESOURCESThe volume was not read due to lack of resources.

Definition at line 1624 of file FileSystemOperations.c.

◆ ReadVolumeFileStructure()

EFI_STATUS ReadVolumeFileStructure ( IN EFI_BLOCK_IO_PROTOCOL BlockIo,
IN EFI_DISK_IO_PROTOCOL DiskIo,
OUT UDF_VOLUME_INFO Volume 
)

Read Volume and File Structure on an UDF file system.

Parameters
[in]BlockIoBlockIo interface.
[in]DiskIoDiskIo interface.
[out]VolumeVolume information pointer.
Return values
EFI_SUCCESSVolume and File Structure were read.
otherVolume and File Structure were not read.

Definition at line 410 of file FileSystemOperations.c.

◆ ResolveSymlink()

EFI_STATUS ResolveSymlink ( IN EFI_BLOCK_IO_PROTOCOL BlockIo,
IN EFI_DISK_IO_PROTOCOL DiskIo,
IN UDF_VOLUME_INFO Volume,
IN UDF_FILE_INFO Parent,
IN VOID *  FileEntryData,
OUT UDF_FILE_INFO File 
)

Resolve a symlink file on an UDF volume.

Attention
This is boundary function that may receive untrusted input.
The input is from FileSystem.

The Path Component is external input, so this routine will do basic validation for Path Component and report status.

Parameters
[in]BlockIoBlockIo interface.
[in]DiskIoDiskIo interface.
[in]VolumeUDF volume information structure.
[in]ParentParent file.
[in]FileEntryDataFE/EFE structure pointer.
[out]FileResolved file.
Return values
EFI_SUCCESSSymlink file resolved.
EFI_UNSUPPORTEDExtended Allocation Descriptors not supported.
EFI_NO_MEDIAThe device has no media.
EFI_DEVICE_ERRORThe device reported an error.
EFI_VOLUME_CORRUPTEDThe file system structures are corrupted.
EFI_OUT_OF_RESOURCESThe symlink file was not resolved due to lack of resources.

Definition at line 2157 of file FileSystemOperations.c.

◆ SetFileInfo()

EFI_STATUS SetFileInfo ( IN UDF_FILE_INFO File,
IN UINT64  FileSize,
IN CHAR16 *  FileName,
IN OUT UINTN BufferSize,
OUT VOID *  Buffer 
)

Set information about a file on an UDF volume.

Parameters
[in]FileFile pointer.
[in]FileSizeSize of the file.
[in]FileNameFilename of the file.
[in,out]BufferSizeSize of the returned file infomation.
[out]BufferData of the returned file information.
Return values
EFI_SUCCESSFile information set.
EFI_NO_MEDIAThe device has no media.
EFI_DEVICE_ERRORThe device reported an error.
EFI_VOLUME_CORRUPTEDThe file system structures are corrupted.
EFI_OUT_OF_RESOURCESThe file information was not set due to lack of resources.

Definition at line 2477 of file FileSystemOperations.c.

◆ StartMainVolumeDescriptorSequence()

EFI_STATUS StartMainVolumeDescriptorSequence ( IN EFI_BLOCK_IO_PROTOCOL BlockIo,
IN EFI_DISK_IO_PROTOCOL DiskIo,
IN UDF_ANCHOR_VOLUME_DESCRIPTOR_POINTER AnchorPoint,
OUT UDF_VOLUME_INFO Volume 
)

Save the content of Logical Volume Descriptors and Partitions Descriptors in memory.

Parameters
[in]BlockIoBlockIo interface.
[in]DiskIoDiskIo interface.
[in]AnchorPointAnchor volume descriptor pointer.
[out]VolumeUDF volume information structure.
Return values
EFI_SUCCESSThe descriptors were saved.
EFI_OUT_OF_RESOURCESThe descriptors were not saved due to lack of resources.
otherThe descriptors were not saved due to ReadDisk error.

Definition at line 95 of file FileSystemOperations.c.

◆ SupportUdfFileSystem()

EFI_STATUS SupportUdfFileSystem ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  ControllerHandle 
)

Check if ControllerHandle supports an UDF file system.

Parameters
[in]ThisProtocol instance pointer.
[in]ControllerHandleHandle of device to test.
Return values
EFI_SUCCESSUDF file system found.
EFI_UNSUPPORTEDUDF file system not found.

Definition at line 2922 of file FileSystemOperations.c.

Variable Documentation

◆ gUdfDevPathGuid

EFI_GUID gUdfDevPathGuid = EFI_UDF_DEVICE_PATH_GUID

Definition at line 15 of file FileSystemOperations.c.