/**\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
+ @param[in] Volume Volume information pointer.\r
+ @param[in] LongAd Long Allocation Descriptor pointer.\r
+ @param[out] Lsn Logical sector number pointer.\r
\r
- @return The logical sector number of a given Long Allocation Descriptor.\r
+ @retval EFI_SUCCESS Logical sector number successfully returned.\r
+ @retval EFI_UNSUPPORTED Logical sector number is not returned due to\r
+ unrecognized format.\r
\r
**/\r
-UINT64\r
+EFI_STATUS\r
GetLongAdLsn (\r
- IN UDF_VOLUME_INFO *Volume,\r
- IN UDF_LONG_ALLOCATION_DESCRIPTOR *LongAd\r
+ IN UDF_VOLUME_INFO *Volume,\r
+ IN UDF_LONG_ALLOCATION_DESCRIPTOR *LongAd,\r
+ OUT UINT64 *Lsn\r
)\r
{\r
UDF_PARTITION_DESCRIPTOR *PartitionDesc;\r
\r
PartitionDesc = GetPdFromLongAd (Volume, LongAd);\r
- ASSERT (PartitionDesc != NULL);\r
+ if (PartitionDesc == NULL) {\r
+ DEBUG ((\r
+ DEBUG_ERROR,\r
+ "%a: Fail to get the Partition Descriptor from the given Long Allocation Descriptor.\n",\r
+ __FUNCTION__\r
+ ));\r
+ return EFI_UNSUPPORTED;\r
+ }\r
\r
- return (UINT64)PartitionDesc->PartitionStartingLocation -\r
- Volume->MainVdsStartLocation +\r
- LongAd->ExtentLocation.LogicalBlockNumber;\r
+ *Lsn = (UINT64)PartitionDesc->PartitionStartingLocation -\r
+ Volume->MainVdsStartLocation +\r
+ LongAd->ExtentLocation.LogicalBlockNumber;\r
+\r
+ return EFI_SUCCESS;\r
}\r
\r
/**\r
UDF_DESCRIPTOR_TAG *DescriptorTag;\r
\r
LogicalVolDesc = &Volume->LogicalVolDesc;\r
- Lsn = GetLongAdLsn (Volume, &LogicalVolDesc->LogicalVolumeContentsUse);\r
+ Status = GetLongAdLsn (Volume, &LogicalVolDesc->LogicalVolumeContentsUse, &Lsn);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
\r
//\r
// As per UDF 2.60 specification:\r
@param[in] Volume Volume information pointer.\r
@param[in] ParentIcb Long Allocation Descriptor pointer.\r
@param[in] Ad Allocation Descriptor pointer.\r
+ @param[out] Lsn Logical sector number pointer.\r
\r
- @return The logical sector number of the given Allocation Descriptor.\r
+ @retval EFI_SUCCESS Logical sector number of the given Allocation\r
+ Descriptor successfully returned.\r
+ @retval EFI_UNSUPPORTED Logical sector number of the given Allocation\r
+ Descriptor is not returned due to unrecognized\r
+ format.\r
\r
**/\r
-UINT64\r
+EFI_STATUS\r
GetAllocationDescriptorLsn (\r
- IN UDF_FE_RECORDING_FLAGS RecordingFlags,\r
- IN UDF_VOLUME_INFO *Volume,\r
- IN UDF_LONG_ALLOCATION_DESCRIPTOR *ParentIcb,\r
- IN VOID *Ad\r
+ IN UDF_FE_RECORDING_FLAGS RecordingFlags,\r
+ IN UDF_VOLUME_INFO *Volume,\r
+ IN UDF_LONG_ALLOCATION_DESCRIPTOR *ParentIcb,\r
+ IN VOID *Ad,\r
+ OUT UINT64 *Lsn\r
)\r
{\r
UDF_PARTITION_DESCRIPTOR *PartitionDesc;\r
\r
if (RecordingFlags == LongAdsSequence) {\r
- return GetLongAdLsn (Volume, (UDF_LONG_ALLOCATION_DESCRIPTOR *)Ad);\r
+ return GetLongAdLsn (Volume, (UDF_LONG_ALLOCATION_DESCRIPTOR *)Ad, Lsn);\r
} else if (RecordingFlags == ShortAdsSequence) {\r
PartitionDesc = GetPdFromLongAd (Volume, ParentIcb);\r
- ASSERT (PartitionDesc != NULL);\r
+ if (PartitionDesc == NULL) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
\r
- return GetShortAdLsn (\r
- Volume,\r
- PartitionDesc,\r
- (UDF_SHORT_ALLOCATION_DESCRIPTOR *)Ad\r
- );\r
+ *Lsn = GetShortAdLsn (\r
+ Volume,\r
+ PartitionDesc,\r
+ (UDF_SHORT_ALLOCATION_DESCRIPTOR *)Ad\r
+ );\r
+ return EFI_SUCCESS;\r
}\r
\r
- return 0;\r
+ return EFI_UNSUPPORTED;\r
}\r
\r
/**\r
UDF_DESCRIPTOR_TAG *DescriptorTag;\r
\r
ExtentLength = GET_EXTENT_LENGTH (RecordingFlags, Ad);\r
- Lsn = GetAllocationDescriptorLsn (RecordingFlags,\r
+ Status = GetAllocationDescriptorLsn (RecordingFlags,\r
Volume,\r
ParentIcb,\r
- Ad);\r
+ Ad,\r
+ &Lsn);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
\r
Data = AllocatePool (ExtentLength);\r
if (Data == NULL) {\r
\r
ExtentLength = GET_EXTENT_LENGTH (RecordingFlags, Ad);\r
\r
- Lsn = GetAllocationDescriptorLsn (RecordingFlags,\r
- Volume,\r
- ParentIcb,\r
- Ad);\r
+ Status = GetAllocationDescriptorLsn (RecordingFlags,\r
+ Volume,\r
+ ParentIcb,\r
+ Ad,\r
+ &Lsn);\r
+ if (EFI_ERROR (Status)) {\r
+ goto Done;\r
+ }\r
\r
switch (ReadFileInfo->Flags) {\r
case ReadFileGetFileSize:\r
UDF_DESCRIPTOR_TAG *DescriptorTag;\r
VOID *ReadBuffer;\r
\r
- Lsn = GetLongAdLsn (Volume, Icb);\r
+ Status = GetLongAdLsn (Volume, Icb, &Lsn);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
LogicalBlockSize = Volume->LogicalVolDesc.LogicalBlockSize;\r
\r
ReadBuffer = AllocateZeroPool (Volume->FileEntrySize);\r