\r
#include "Udf.h"\r
\r
+//\r
+// Vendor-Defined Device Path GUID for UDF file system\r
+//\r
+EFI_GUID gUdfDevPathGuid = EFI_UDF_DEVICE_PATH_GUID;\r
+\r
+/**\r
+ Find the anchor volume descriptor pointer.\r
+\r
+ @param[in] BlockIo BlockIo interface.\r
+ @param[in] DiskIo DiskIo interface.\r
+ @param[out] AnchorPoint Anchor volume descriptor pointer.\r
+\r
+ @retval EFI_SUCCESS Anchor volume descriptor pointer found.\r
+ @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
+ @retval other Anchor volume descriptor pointer not found.\r
+\r
+**/\r
EFI_STATUS\r
FindAnchorVolumeDescriptorPointer (\r
IN EFI_BLOCK_IO_PROTOCOL *BlockIo,\r
return EFI_VOLUME_CORRUPTED;\r
}\r
\r
+/**\r
+ Save the content of Logical Volume Descriptors and Partitions Descriptors in\r
+ memory.\r
+\r
+ @param[in] BlockIo BlockIo interface.\r
+ @param[in] DiskIo DiskIo interface.\r
+ @param[in] AnchorPoint Anchor volume descriptor pointer.\r
+ @param[out] Volume UDF volume information structure.\r
+\r
+ @retval EFI_SUCCESS The descriptors were saved.\r
+ @retval EFI_OUT_OF_RESOURCES The descriptors were not saved due to lack of\r
+ resources.\r
+ @retval other The descriptors were not saved due to\r
+ ReadDisk error.\r
+\r
+**/\r
EFI_STATUS\r
StartMainVolumeDescriptorSequence (\r
IN EFI_BLOCK_IO_PROTOCOL *BlockIo,\r
return Status;\r
}\r
\r
-//\r
-// Return a Partition Descriptor given a Long Allocation Descriptor. This is\r
-// necessary to calculate the right extent (LongAd) offset which is added up\r
-// with partition's starting location.\r
-//\r
+/**\r
+ Return a Partition Descriptor given a Long Allocation Descriptor. This is\r
+ necessary to calculate the right extent (LongAd) offset which is added up\r
+ with partition's starting location.\r
+\r
+ @param[in] Volume Volume information pointer.\r
+ @param[in] LongAd Long Allocation Descriptor pointer.\r
+\r
+ @return A pointer to a Partition Descriptor.\r
+\r
+**/\r
UDF_PARTITION_DESCRIPTOR *\r
GetPdFromLongAd (\r
IN UDF_VOLUME_INFO *Volume,\r
return NULL;\r
}\r
\r
-//\r
-// Return logical sector number of a given Long Allocation Descriptor.\r
-//\r
+/**\r
+ Return logical sector number of a given Long Allocation Descriptor.\r
+\r
+ @param[in] Volume Volume information pointer.\r
+ @param[in] LongAd Long Allocation Descriptor pointer.\r
+\r
+ @return The logical sector number of a given Long Allocation Descriptor.\r
+\r
+**/\r
UINT64\r
GetLongAdLsn (\r
IN UDF_VOLUME_INFO *Volume,\r
LongAd->ExtentLocation.LogicalBlockNumber;\r
}\r
\r
-//\r
-// Return logical sector number of a given Short Allocation Descriptor.\r
-//\r
+/**\r
+ Return logical sector number of a given Short Allocation Descriptor.\r
+\r
+ @param[in] PartitionDesc Partition Descriptor pointer.\r
+ @param[in] ShortAd Short Allocation Descriptor pointer.\r
+\r
+ @return The logical sector number of a given Short Allocation Descriptor.\r
+\r
+**/\r
UINT64\r
GetShortAdLsn (\r
IN UDF_PARTITION_DESCRIPTOR *PartitionDesc,\r
IN UDF_SHORT_ALLOCATION_DESCRIPTOR *ShortAd\r
)\r
{\r
+ ASSERT (PartitionDesc != NULL);\r
+\r
return (UINT64)PartitionDesc->PartitionStartingLocation +\r
ShortAd->ExtentPosition;\r
}\r
\r
-//\r
-// Find File Set Descriptor of a given Logical Volume Descriptor.\r
-//\r
-// The found FSD will contain the extent (LogicalVolumeContentsUse) where our\r
-// root directory is.\r
-//\r
+/**\r
+ Find File Set Descriptor of a given Logical Volume Descriptor.\r
+\r
+ The found FSD will contain the extent (LogicalVolumeContentsUse) where our\r
+ root directory is.\r
+\r
+ @param[in] BlockIo BlockIo interface.\r
+ @param[in] DiskIo DiskIo interface.\r
+ @param[in] Volume Volume information pointer.\r
+ @param[in] LogicalVolDescNum Index of Logical Volume Descriptor\r
+ @param[out] FileSetDesc File Set Descriptor pointer.\r
+\r
+ @retval EFI_SUCCESS File Set Descriptor pointer found.\r
+ @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
+ @retval other File Set Descriptor pointer not found.\r
+\r
+**/\r
EFI_STATUS\r
FindFileSetDescriptor (\r
IN EFI_BLOCK_IO_PROTOCOL *BlockIo,\r
return EFI_SUCCESS;\r
}\r
\r
-//\r
-// Get all File Set Descriptors for each Logical Volume Descriptor.\r
-//\r
+/**\r
+ Get all File Set Descriptors for each Logical Volume Descriptor.\r
+\r
+ @param[in] BlockIo BlockIo interface.\r
+ @param[in] DiskIo DiskIo interface.\r
+ @param[in, out] Volume Volume information pointer.\r
+\r
+ @retval EFI_SUCCESS File Set Descriptors were got.\r
+ @retval EFI_OUT_OF_RESOURCES File Set Descriptors were not got due to lack\r
+ of resources.\r
+ @retval other Error occured when finding File Set\r
+ Descriptor in Logical Volume Descriptor.\r
+\r
+**/\r
EFI_STATUS\r
GetFileSetDescriptors (\r
IN EFI_BLOCK_IO_PROTOCOL *BlockIo,\r
return Status;\r
}\r
\r
-//\r
-// Read Volume and File Structure on an UDF file system.\r
-//\r
+/**\r
+ Read Volume and File Structure on an UDF file system.\r
+\r
+ @param[in] BlockIo BlockIo interface.\r
+ @param[in] DiskIo DiskIo interface.\r
+ @param[out] Volume Volume information pointer.\r
+\r
+ @retval EFI_SUCCESS Volume and File Structure were read.\r
+ @retval other Volume and File Structure were not read.\r
+\r
+**/\r
EFI_STATUS\r
ReadVolumeFileStructure (\r
IN EFI_BLOCK_IO_PROTOCOL *BlockIo,\r
return Status;\r
}\r
\r
-//\r
-// Calculate length of a given File Identifier Descriptor.\r
-//\r
+/**\r
+ Calculate length of a given File Identifier Descriptor.\r
+\r
+ @param[in] FileIdentifierDesc File Identifier Descriptor pointer.\r
+\r
+ @return The length of a given File Identifier Descriptor.\r
+\r
+**/\r
UINT64\r
GetFidDescriptorLength (\r
IN UDF_FILE_IDENTIFIER_DESCRIPTOR *FileIdentifierDesc\r
);\r
}\r
\r
-//\r
-// Duplicate a given File Identifier Descriptor.\r
-//\r
+/**\r
+ Duplicate a given File Identifier Descriptor.\r
+\r
+ @param[in] FileIdentifierDesc File Identifier Descriptor pointer.\r
+ @param[out] NewFileIdentifierDesc The duplicated File Identifier Descriptor.\r
+\r
+**/\r
VOID\r
DuplicateFid (\r
IN UDF_FILE_IDENTIFIER_DESCRIPTOR *FileIdentifierDesc,\r
*NewFileIdentifierDesc =\r
(UDF_FILE_IDENTIFIER_DESCRIPTOR *)AllocateCopyPool (\r
(UINTN) GetFidDescriptorLength (FileIdentifierDesc), FileIdentifierDesc);\r
+\r
+ ASSERT (*NewFileIdentifierDesc != NULL);\r
}\r
\r
-//\r
-// Duplicate either a given File Entry or a given Extended File Entry.\r
-//\r
+/**\r
+ Duplicate either a given File Entry or a given Extended File Entry.\r
+\r
+ @param[in] BlockIo BlockIo interface.\r
+ @param[in] Volume Volume information pointer.\r
+ @param[in] FileEntry (Extended) File Entry pointer.\r
+ @param[out] NewFileEntry The duplicated (Extended) File Entry.\r
+\r
+**/\r
VOID\r
DuplicateFe (\r
IN EFI_BLOCK_IO_PROTOCOL *BlockIo,\r
)\r
{\r
*NewFileEntry = AllocateCopyPool (Volume->FileEntrySize, FileEntry);\r
+\r
+ ASSERT (*NewFileEntry != NULL);\r
}\r
\r
-//\r
-// Get raw data + length of a given File Entry or Extended File Entry.\r
-//\r
-// The file's recorded data can contain either real file content (inline) or\r
-// a sequence of extents (or Allocation Descriptors) which tells where file's\r
-// content is stored in.\r
-//\r
-// NOTE: The FE/EFE can be thought it was an inode.\r
-//\r
+/**\r
+ Get raw data + length of a given File Entry or Extended File Entry.\r
+\r
+ The file's recorded data can contain either real file content (inline) or\r
+ a sequence of extents (or Allocation Descriptors) which tells where file's\r
+ content is stored in.\r
+\r
+ NOTE: The FE/EFE can be thought it was an inode.\r
+\r
+ @param[in] FileEntryData (Extended) File Entry pointer.\r
+ @param[out] Data Buffer contains the raw data of a given\r
+ (Extended) File Entry.\r
+ @param[out] Length Length of the data in Buffer.\r
+\r
+**/\r
VOID\r
GetFileEntryData (\r
IN VOID *FileEntryData,\r
}\r
}\r
\r
-//\r
-// Get Allocation Descriptors' data information from a given FE/EFE.\r
-//\r
+/**\r
+ Get Allocation Descriptors' data information from a given FE/EFE.\r
+\r
+ @param[in] FileEntryData (Extended) File Entry pointer.\r
+ @param[out] AdsData Buffer contains the Allocation Descriptors'\r
+ data from a given FE/EFE.\r
+ @param[out] Length Length of the data in AdsData.\r
+\r
+**/\r
VOID\r
GetAdsInformation (\r
IN VOID *FileEntryData,\r
}\r
}\r
\r
-//\r
-// Read next Long Allocation Descriptor from a given file's data.\r
-//\r
+/**\r
+ Read next Long Allocation Descriptor from a given file's data.\r
+\r
+ @param[in] Data File's data pointer.\r
+ @param[in,out] Offset Starting offset of the File's data to read.\r
+ @param[in] Length Length of the data to read.\r
+ @param[out] FoundLongAd Long Allocation Descriptor pointer.\r
+\r
+ @retval EFI_SUCCESS A Long Allocation Descriptor was found.\r
+ @retval EFI_DEVICE_ERROR No more Long Allocation Descriptors.\r
+\r
+**/\r
EFI_STATUS\r
GetLongAdFromAds (\r
IN VOID *Data,\r
// If it's either an indirect AD (Extended Alllocation Descriptor) or an\r
// allocated AD, then return it.\r
//\r
- ExtentFlags = GET_EXTENT_FLAGS (LONG_ADS_SEQUENCE, LongAd);\r
- if (ExtentFlags == EXTENT_IS_NEXT_EXTENT ||\r
- ExtentFlags == EXTENT_RECORDED_AND_ALLOCATED) {\r
+ ExtentFlags = GET_EXTENT_FLAGS (LongAdsSequence, LongAd);\r
+ if (ExtentFlags == ExtentIsNextExtent ||\r
+ ExtentFlags == ExtentRecordedAndAllocated) {\r
break;\r
}\r
\r
// This AD is either not recorded but allocated, or not recorded and not\r
// allocated. Skip it.\r
//\r
- *Offset += AD_LENGTH (LONG_ADS_SEQUENCE);\r
+ *Offset += AD_LENGTH (LongAdsSequence);\r
}\r
\r
*FoundLongAd = LongAd;\r
return EFI_SUCCESS;\r
}\r
\r
-//\r
-// Read next Short Allocation Descriptor from a given file's data.\r
-//\r
+/**\r
+ Read next Short Allocation Descriptor from a given file's data.\r
+\r
+ @param[in] Data File's data pointer.\r
+ @param[in,out] Offset Starting offset of the File's data to read.\r
+ @param[in] Length Length of the data to read.\r
+ @param[out] FoundShortAd Short Allocation Descriptor pointer.\r
+\r
+ @retval EFI_SUCCESS A Short Allocation Descriptor was found.\r
+ @retval EFI_DEVICE_ERROR No more Short Allocation Descriptors.\r
+\r
+**/\r
EFI_STATUS\r
GetShortAdFromAds (\r
IN VOID *Data,\r
// If it's either an indirect AD (Extended Alllocation Descriptor) or an\r
// allocated AD, then return it.\r
//\r
- ExtentFlags = GET_EXTENT_FLAGS (SHORT_ADS_SEQUENCE, ShortAd);\r
- if (ExtentFlags == EXTENT_IS_NEXT_EXTENT ||\r
- ExtentFlags == EXTENT_RECORDED_AND_ALLOCATED) {\r
+ ExtentFlags = GET_EXTENT_FLAGS (ShortAdsSequence, ShortAd);\r
+ if (ExtentFlags == ExtentIsNextExtent ||\r
+ ExtentFlags == ExtentRecordedAndAllocated) {\r
break;\r
}\r
\r
// This AD is either not recorded but allocated, or not recorded and not\r
// allocated. Skip it.\r
//\r
- *Offset += AD_LENGTH (SHORT_ADS_SEQUENCE);\r
+ *Offset += AD_LENGTH (ShortAdsSequence);\r
}\r
\r
*FoundShortAd = ShortAd;\r
return EFI_SUCCESS;\r
}\r
\r
-//\r
-// Get either a Short Allocation Descriptor or a Long Allocation Descriptor from\r
-// file's data.\r
-//\r
+/**\r
+ Get either a Short Allocation Descriptor or a Long Allocation Descriptor from\r
+ file's data.\r
+\r
+ @param[in] RecordingFlags Flag to indicate the type of descriptor.\r
+ @param[in] Data File's data pointer.\r
+ @param[in,out] Offset Starting offset of the File's data to read.\r
+ @param[in] Length Length of the data to read.\r
+ @param[out] FoundAd Allocation Descriptor pointer.\r
+\r
+ @retval EFI_SUCCESS A Short Allocation Descriptor was found.\r
+ @retval EFI_DEVICE_ERROR No more Allocation Descriptors.\r
+ Invalid type of descriptor was given.\r
+\r
+**/\r
EFI_STATUS\r
GetAllocationDescriptor (\r
IN UDF_FE_RECORDING_FLAGS RecordingFlags,\r
OUT VOID **FoundAd\r
)\r
{\r
- if (RecordingFlags == LONG_ADS_SEQUENCE) {\r
+ if (RecordingFlags == LongAdsSequence) {\r
return GetLongAdFromAds (\r
Data,\r
Offset,\r
Length,\r
(UDF_LONG_ALLOCATION_DESCRIPTOR **)FoundAd\r
);\r
- } else if (RecordingFlags == SHORT_ADS_SEQUENCE) {\r
+ } else if (RecordingFlags == ShortAdsSequence) {\r
return GetShortAdFromAds (\r
Data,\r
Offset,\r
return EFI_DEVICE_ERROR;\r
}\r
\r
-//\r
-// Return logical sector number of either Short or Long Allocation Descriptor.\r
-//\r
+/**\r
+ Return logical sector number of either Short or Long Allocation Descriptor.\r
+\r
+ @param[in] RecordingFlags Flag to indicate the type of descriptor.\r
+ @param[in] Volume Volume information pointer.\r
+ @param[in] ParentIcb Long Allocation Descriptor pointer.\r
+ @param[in] Ad Allocation Descriptor pointer.\r
+\r
+ @return The logical sector number of the given Allocation Descriptor.\r
+\r
+**/\r
UINT64\r
GetAllocationDescriptorLsn (\r
IN UDF_FE_RECORDING_FLAGS RecordingFlags,\r
IN VOID *Ad\r
)\r
{\r
- if (RecordingFlags == LONG_ADS_SEQUENCE) {\r
+ if (RecordingFlags == LongAdsSequence) {\r
return GetLongAdLsn (Volume, (UDF_LONG_ALLOCATION_DESCRIPTOR *)Ad);\r
- } else if (RecordingFlags == SHORT_ADS_SEQUENCE) {\r
+ } else if (RecordingFlags == ShortAdsSequence) {\r
return GetShortAdLsn (\r
GetPdFromLongAd (Volume, ParentIcb),\r
(UDF_SHORT_ALLOCATION_DESCRIPTOR *)Ad\r
return 0;\r
}\r
\r
-//\r
-// Return offset + length of a given indirect Allocation Descriptor (AED).\r
-//\r
+/**\r
+ Return offset + length of a given indirect Allocation Descriptor (AED).\r
+\r
+ @param[in] BlockIo BlockIo interface.\r
+ @param[in] DiskIo DiskIo interface.\r
+ @param[in] Volume Volume information pointer.\r
+ @param[in] ParentIcb Long Allocation Descriptor pointer.\r
+ @param[in] RecordingFlags Flag to indicate the type of descriptor.\r
+ @param[in] Ad Allocation Descriptor pointer.\r
+ @param[out] Offset Offset of a given indirect Allocation\r
+ Descriptor.\r
+ @param[out] Length Length of a given indirect Allocation\r
+ Descriptor.\r
+\r
+ @retval EFI_SUCCESS The offset and length were returned.\r
+ @retval EFI_OUT_OF_RESOURCES The offset and length were not returned due\r
+ to lack of resources.\r
+ @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
+ @retval other The offset and length were not returned.\r
+\r
+**/\r
EFI_STATUS\r
GetAedAdsOffset (\r
IN EFI_BLOCK_IO_PROTOCOL *BlockIo,\r
return Status;\r
}\r
\r
-//\r
-// Read Allocation Extent Descriptor into memory.\r
-//\r
+/**\r
+ Read Allocation Extent Descriptor into memory.\r
+\r
+ @param[in] BlockIo BlockIo interface.\r
+ @param[in] DiskIo DiskIo interface.\r
+ @param[in] Volume Volume information pointer.\r
+ @param[in] ParentIcb Long Allocation Descriptor pointer.\r
+ @param[in] RecordingFlags Flag to indicate the type of descriptor.\r
+ @param[in] Ad Allocation Descriptor pointer.\r
+ @param[out] Data Buffer that contains the Allocation Extent\r
+ Descriptor.\r
+ @param[out] Length Length of Data.\r
+\r
+ @retval EFI_SUCCESS The Allocation Extent Descriptor was read.\r
+ @retval EFI_OUT_OF_RESOURCES The Allocation Extent Descriptor was not read\r
+ due to lack of resources.\r
+ @retval other Fail to read the disk.\r
+\r
+**/\r
EFI_STATUS\r
GetAedAdsData (\r
IN EFI_BLOCK_IO_PROTOCOL *BlockIo,\r
);\r
}\r
\r
-//\r
-// Function used to serialise reads of Allocation Descriptors.\r
-//\r
+/**\r
+ Function used to serialise reads of Allocation Descriptors.\r
+\r
+ @param[in] RecordingFlags Flag to indicate the type of descriptor.\r
+ @param[in] Ad Allocation Descriptor pointer.\r
+ @param[in, out] Buffer Buffer to hold the next Allocation Descriptor.\r
+ @param[in] Length Length of Buffer.\r
+\r
+ @retval EFI_SUCCESS Buffer was grown to hold the next Allocation\r
+ Descriptor.\r
+ @retval EFI_OUT_OF_RESOURCES Buffer was not grown due to lack of resources.\r
+\r
+**/\r
EFI_STATUS\r
GrowUpBufferToNextAd (\r
IN UDF_FE_RECORDING_FLAGS RecordingFlags,\r
return EFI_SUCCESS;\r
}\r
\r
-//\r
-// Read data or size of either a File Entry or an Extended File Entry.\r
-//\r
+/**\r
+ Read data or size of either a File Entry or an Extended File Entry.\r
+\r
+ @param[in] BlockIo BlockIo interface.\r
+ @param[in] DiskIo DiskIo interface.\r
+ @param[in] Volume Volume information pointer.\r
+ @param[in] ParentIcb Long Allocation Descriptor pointer.\r
+ @param[in] FileEntryData FE/EFE structure pointer.\r
+ @param[in, out] ReadFileInfo Read file information pointer.\r
+\r
+ @retval EFI_SUCCESS Data or size of a FE/EFE was read.\r
+ @retval EFI_OUT_OF_RESOURCES Data or size of a FE/EFE was not read due to\r
+ lack of resources.\r
+ @retval EFI_INVALID_PARAMETER The read file flag given in ReadFileInfo is\r
+ invalid.\r
+ @retval EFI_UNSUPPORTED The FE recording flag given in FileEntryData\r
+ is not supported.\r
+ @retval other Data or size of a FE/EFE was not read.\r
+\r
+**/\r
EFI_STATUS\r
ReadFile (\r
IN EFI_BLOCK_IO_PROTOCOL *BlockIo,\r
LogicalBlockSize = LV_BLOCK_SIZE (Volume, UDF_DEFAULT_LV_NUM);\r
DoFreeAed = FALSE;\r
\r
+ //\r
+ // set BytesLeft to suppress incorrect compiler/analyzer warnings\r
+ //\r
+ BytesLeft = 0;\r
+ DataOffset = 0;\r
+ FilePosition = 0;\r
+ FinishedSeeking = FALSE;\r
+ Data = NULL;\r
+\r
switch (ReadFileInfo->Flags) {\r
- case READ_FILE_GET_FILESIZE:\r
- case READ_FILE_ALLOCATE_AND_READ:\r
+ case ReadFileGetFileSize:\r
+ case ReadFileAllocateAndRead:\r
//\r
// Initialise ReadFileInfo structure for either getting file size, or\r
// reading file's recorded data.\r
ReadFileInfo->ReadLength = 0;\r
ReadFileInfo->FileData = NULL;\r
break;\r
- case READ_FILE_SEEK_AND_READ:\r
+ case ReadFileSeekAndRead:\r
//\r
// About to seek a file and/or read its data.\r
//\r
\r
RecordingFlags = GET_FE_RECORDING_FLAGS (FileEntryData);\r
switch (RecordingFlags) {\r
- case INLINE_DATA:\r
+ case InlineData:\r
//\r
// There are no extents for this FE/EFE. All data is inline.\r
//\r
GetFileEntryData (FileEntryData, &Data, &Length);\r
\r
- if (ReadFileInfo->Flags == READ_FILE_GET_FILESIZE) {\r
+ if (ReadFileInfo->Flags == ReadFileGetFileSize) {\r
ReadFileInfo->ReadLength = Length;\r
- } else if (ReadFileInfo->Flags == READ_FILE_ALLOCATE_AND_READ) {\r
+ } else if (ReadFileInfo->Flags == ReadFileAllocateAndRead) {\r
//\r
// Allocate buffer for starting read data.\r
//\r
//\r
CopyMem (ReadFileInfo->FileData, Data, (UINTN) Length);\r
ReadFileInfo->ReadLength = Length;\r
- } else if (ReadFileInfo->Flags == READ_FILE_SEEK_AND_READ) {\r
+ } else if (ReadFileInfo->Flags == ReadFileSeekAndRead) {\r
//\r
// If FilePosition is non-zero, seek file to FilePosition, read\r
// FileDataSize bytes and then updates FilePosition.\r
);\r
\r
ReadFileInfo->FilePosition += ReadFileInfo->FileDataSize;\r
+ } else {\r
+ ASSERT (FALSE);\r
+ return EFI_INVALID_PARAMETER;\r
}\r
\r
+ Status = EFI_SUCCESS;\r
break;\r
- case LONG_ADS_SEQUENCE:\r
- case SHORT_ADS_SEQUENCE:\r
+\r
+ case LongAdsSequence:\r
+ case ShortAdsSequence:\r
//\r
// This FE/EFE contains a run of Allocation Descriptors. Get data + size\r
// for start reading them out.\r
// Check if AD is an indirect AD. If so, read Allocation Extent\r
// Descriptor and its extents (ADs).\r
//\r
- if (GET_EXTENT_FLAGS (RecordingFlags, Ad) == EXTENT_IS_NEXT_EXTENT) {\r
+ if (GET_EXTENT_FLAGS (RecordingFlags, Ad) == ExtentIsNextExtent) {\r
if (!DoFreeAed) {\r
DoFreeAed = TRUE;\r
} else {\r
if (EFI_ERROR (Status)) {\r
goto Error_Get_Aed;\r
}\r
+ ASSERT (Data != NULL);\r
\r
AdOffset = 0;\r
continue;\r
Ad);\r
\r
switch (ReadFileInfo->Flags) {\r
- case READ_FILE_GET_FILESIZE:\r
+ case ReadFileGetFileSize:\r
ReadFileInfo->ReadLength += ExtentLength;\r
break;\r
- case READ_FILE_ALLOCATE_AND_READ:\r
+ case ReadFileAllocateAndRead:\r
//\r
// Increase FileData (if necessary) to read next extent.\r
//\r
\r
ReadFileInfo->ReadLength += ExtentLength;\r
break;\r
- case READ_FILE_SEEK_AND_READ:\r
+ case ReadFileSeekAndRead:\r
//\r
// Seek file first before reading in its data.\r
//\r
\r
if (FilePosition + ExtentLength > ReadFileInfo->FilePosition) {\r
Offset = ReadFileInfo->FilePosition - FilePosition;\r
- if (Offset < 0) {\r
- Offset = -(Offset);\r
- }\r
} else {\r
Offset = 0;\r
}\r
}\r
\r
break;\r
- case EXTENDED_ADS_SEQUENCE:\r
+ case ExtendedAdsSequence:\r
// FIXME: Not supported. Got no volume with it, yet.\r
ASSERT (FALSE);\r
Status = EFI_UNSUPPORTED;\r
break;\r
+\r
+ default:\r
+ //\r
+ // A flag value reserved by the ECMA-167 standard (3rd Edition - June\r
+ // 1997); 14.6 ICB Tag; 14.6.8 Flags (RBP 18); was found.\r
+ //\r
+ Status = EFI_UNSUPPORTED;\r
+ break;\r
}\r
\r
Done:\r
\r
Error_Read_Disk_Blk:\r
Error_Alloc_Buffer_To_Next_Ad:\r
- if (ReadFileInfo->Flags != READ_FILE_SEEK_AND_READ) {\r
+ if (ReadFileInfo->Flags != ReadFileSeekAndRead) {\r
FreePool (ReadFileInfo->FileData);\r
}\r
\r
return Status;\r
}\r
\r
-//\r
-// Find a file by its filename from a given Parent file.\r
-//\r
+/**\r
+ Find a file by its filename from a given Parent file.\r
+\r
+ @param[in] BlockIo BlockIo interface.\r
+ @param[in] DiskIo DiskIo interface.\r
+ @param[in] Volume Volume information pointer.\r
+ @param[in] FileName File name string.\r
+ @param[in] Parent Parent directory file.\r
+ @param[in] Icb Long Allocation Descriptor pointer.\r
+ @param[out] File Found file.\r
+\r
+ @retval EFI_SUCCESS The file was found.\r
+ @retval EFI_INVALID_PARAMETER One or more input parameters are invalid.\r
+ @retval EFI_NOT_FOUND The file was not found.\r
+\r
+**/\r
EFI_STATUS\r
InternalFindFile (\r
IN EFI_BLOCK_IO_PROTOCOL *BlockIo,\r
CHAR16 FoundFileName[UDF_FILENAME_LENGTH];\r
VOID *CompareFileEntry;\r
\r
+ //\r
+ // Check if both Parent->FileIdentifierDesc and Icb are NULL.\r
+ //\r
+ if ((Parent->FileIdentifierDesc == NULL) && (Icb == NULL)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
//\r
// Check if parent file is really directory.\r
//\r
// FE/EFE and FID descriptors.\r
//\r
if (StrCmp (FileName, L".") == 0) {\r
+ if (Parent->FileIdentifierDesc == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
DuplicateFe (BlockIo, Volume, Parent->FileEntry, &File->FileEntry);\r
DuplicateFid (Parent->FileIdentifierDesc, &File->FileIdentifierDesc);\r
\r
BlockIo,\r
DiskIo,\r
Volume,\r
- Parent->FileIdentifierDesc ?\r
+ (Parent->FileIdentifierDesc != NULL) ?\r
&Parent->FileIdentifierDesc->Icb :\r
Icb,\r
Parent->FileEntry,\r
@param[in] FilePath File's absolute path.\r
@param[in] Root Root directory file.\r
@param[in] Parent Parent directory file.\r
+ @param[in] Icb ICB of Parent.\r
@param[out] File Found file.\r
\r
- @retval EFI_SUCCESS @p FilePath was found.\r
+ @retval EFI_SUCCESS FilePath was found.\r
@retval EFI_NO_MEDIA The device has no media.\r
@retval EFI_DEVICE_ERROR The device reported an error.\r
@retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
- @retval EFI_OUT_OF_RESOURCES The @p FilePath file was not found due to lack of\r
+ @retval EFI_OUT_OF_RESOURCES The FilePath file was not found due to lack of\r
resources.\r
\r
**/\r
@param[in] Volume UDF volume information structure.\r
@param[in] ParentIcb ICB of the parent file.\r
@param[in] FileEntryData FE/EFE of the parent file.\r
- @param[in out] ReadDirInfo Next read directory listing structure\r
+ @param[in, out] ReadDirInfo Next read directory listing structure\r
information.\r
@param[out] FoundFid File Identifier Descriptor pointer.\r
\r
// The directory's recorded data has not been read yet. So let's cache it\r
// into memory and the next calls won't need to read it again.\r
//\r
- ReadFileInfo.Flags = READ_FILE_ALLOCATE_AND_READ;\r
+ ReadFileInfo.Flags = ReadFileAllocateAndRead;\r
\r
Status = ReadFile (\r
BlockIo,\r
}\r
\r
if (Index < Length) {\r
- *FileName |= OstaCompressed[Index];\r
+ *FileName |= (CHAR16)(OstaCompressed[Index]);\r
}\r
\r
FileName++;\r
UDF_PATH_COMPONENT *PathComp;\r
UINT8 PathCompLength;\r
CHAR16 FileName[UDF_FILENAME_LENGTH];\r
- CHAR16 *C;\r
+ CHAR16 *Char;\r
UINTN Index;\r
UINT8 CompressionId;\r
UDF_FILE_INFO PreviousFile;\r
// all its data here -- usually the data will be inline with the FE/EFE for\r
// lower filenames.\r
//\r
- ReadFileInfo.Flags = READ_FILE_ALLOCATE_AND_READ;\r
+ ReadFileInfo.Flags = ReadFileAllocateAndRead;\r
\r
Status = ReadFile (\r
BlockIo,\r
return EFI_VOLUME_CORRUPTED;\r
}\r
\r
- C = FileName;\r
+ Char = FileName;\r
for (Index = 1; Index < PathCompLength; Index++) {\r
if (CompressionId == 16) {\r
- *C = *(UINT8 *)((UINT8 *)PathComp->ComponentIdentifier +\r
+ *Char = *(UINT8 *)((UINT8 *)PathComp->ComponentIdentifier +\r
Index) << 8;\r
Index++;\r
} else {\r
- *C = 0;\r
+ *Char = 0;\r
}\r
\r
if (Index < Length) {\r
- *C |= *(UINT8 *)((UINT8 *)PathComp->ComponentIdentifier + Index);\r
+ *Char |= (CHAR16)(*(UINT8 *)((UINT8 *)PathComp->ComponentIdentifier + Index));\r
}\r
\r
- C++;\r
+ Char++;\r
}\r
\r
- *C = L'\0';\r
+ *Char = L'\0';\r
break;\r
}\r
\r
@param[in] File File information structure.\r
@param[out] Size Size of the file.\r
\r
- @retval EFI_SUCCESS File size calculated and set in @p Size.\r
+ @retval EFI_SUCCESS File size calculated and set in Size.\r
@retval EFI_UNSUPPORTED Extended Allocation Descriptors not supported.\r
@retval EFI_NO_MEDIA The device has no media.\r
@retval EFI_DEVICE_ERROR The device reported an error.\r
EFI_STATUS Status;\r
UDF_READ_FILE_INFO ReadFileInfo;\r
\r
- ReadFileInfo.Flags = READ_FILE_GET_FILESIZE;\r
+ ReadFileInfo.Flags = ReadFileGetFileSize;\r
\r
Status = ReadFile (\r
BlockIo,\r
@param[in] File File pointer.\r
@param[in] FileSize Size of the file.\r
@param[in] FileName Filename of the file.\r
- @param[in out] BufferSize Size of the returned file infomation.\r
+ @param[in, out] BufferSize Size of the returned file infomation.\r
@param[out] Buffer Data of the returned file information.\r
\r
@retval EFI_SUCCESS File information set.\r
//\r
// Calculate the needed size for the EFI_FILE_INFO structure.\r
//\r
- FileInfoLength = sizeof (EFI_FILE_INFO) + (FileName ?\r
+ FileInfoLength = sizeof (EFI_FILE_INFO) + ((FileName != NULL) ?\r
StrSize (FileName) :\r
sizeof (CHAR16));\r
if (*BufferSize < FileInfoLength) {\r
@param[in] Volume UDF volume information structure.\r
@param[in] File File information structure.\r
@param[in] FileSize Size of the file.\r
- @param[in out] FilePosition File position.\r
- @param[in out] Buffer File data.\r
- @param[in out] BufferSize Read size.\r
+ @param[in, out] FilePosition File position.\r
+ @param[in, out] Buffer File data.\r
+ @param[in, out] BufferSize Read size.\r
\r
@retval EFI_SUCCESS File seeked and read.\r
@retval EFI_UNSUPPORTED Extended Allocation Descriptors not supported.\r
EFI_STATUS Status;\r
UDF_READ_FILE_INFO ReadFileInfo;\r
\r
- ReadFileInfo.Flags = READ_FILE_SEEK_AND_READ;\r
+ ReadFileInfo.Flags = ReadFileSeekAndRead;\r
ReadFileInfo.FilePosition = *FilePosition;\r
ReadFileInfo.FileData = Buffer;\r
ReadFileInfo.FileDataSize = *BufferSize;\r
EFI_DEVICE_PATH_PROTOCOL *DevicePathNode;\r
EFI_DEVICE_PATH_PROTOCOL *LastDevicePathNode;\r
EFI_GUID *VendorDefinedGuid;\r
- EFI_GUID UdfDevPathGuid = EFI_UDF_DEVICE_PATH_GUID;\r
\r
//\r
// Open Device Path protocol on ControllerHandle\r
DevicePathSubType (LastDevicePathNode) == MEDIA_VENDOR_DP) {\r
VendorDefinedGuid = (EFI_GUID *)((UINTN)LastDevicePathNode +\r
OFFSET_OF (VENDOR_DEVICE_PATH, Guid));\r
- if (CompareGuid (VendorDefinedGuid, &UdfDevPathGuid)) {\r
+ if (CompareGuid (VendorDefinedGuid, &gUdfDevPathGuid)) {\r
Status = EFI_SUCCESS;\r
}\r
}\r