/* 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. */
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. */
UDF_PARTITION_DESCRIPTOR* GetPdFromLongAd(IN UDF_VOLUME_INFO *Volume, IN UDF_LONG_ALLOCATION_DESCRIPTOR *LongAd)
{
  UDF_LOGICAL_VOLUME_DESCRIPTOR  *LogicalVolDesc;
  UINT16                         PartitionNum;
  LogicalVolDesc = &Volume->LogicalVolDesc;
  switch (LogicalVolDesc->DomainIdentifier.Suffix.Domain.UdfRevision) {
    case 0x0102:
    case 0x0150:
    case 0x0200:
    case 0x0201:
    case 0x0250:
    case 0x0260:
      if (LongAd->ExtentLocation.PartitionReferenceNumber != 0) {
        return NULL;
      }
      PartitionNum = *(UINT16 *)((UINTN)&LogicalVolDesc->PartitionMaps[4]);
      break;
    default:
      return NULL;
  }
  if (Volume->PartitionDesc.PartitionNumber == PartitionNum) {
    return &Volume->PartitionDesc;
  }
  return NULL;
}