rem: udf_primary_descriptor *primary = reinterpret_cast<udf_primary_descriptor*>(tag);
add: primary_descriptor *primary = reinterpret_cast<primary_descriptor*>(tag);
context: walk_volume_descriptor_sequence(udf_extent_address descriptorSequence,								int device, uint32 blockSize, uint32 blockShift,							    udf_logical_descriptor &logicalVolumeDescriptor,							    udf_partition_descriptor partitionDescriptors[],							    uint8 &partitionDescriptorCount){	DEBUG_INIT_ETC(CF_PRIVATE, NULL, ("descriptorSequence.loc:%ld, descriptorSequence.len:%ld",	           descriptorSequence.location(), descriptorSequence.length()));	uint32 count = descriptorSequence.length() >> blockShift;			bool foundLogicalVolumeDescriptor = false;	uint8 uniquePartitions = 0;	status_t error = B_OK;		for (uint32 i = 0; i < count; i++)	{		off_t block = descriptorSequence.location()+i;		off_t address = block << blockShift; 		MemoryChunk chunk(blockSize);		udf_tag *tag = NULL;		PRINT(("descriptor #%ld (block %Ld):\n", i, block));		status_t loopErr = chunk.InitCheck();		if (!loopErr) {			ssize_t bytesRead = read_pos(device, address, chunk.Data(), blockSize);			loopErr = bytesRead == (ssize_t)blockSize ? B_OK : B_IO_ERROR;			if (loopErr) {				PRINT(("block %Ld: read_pos(pos:%Ld, len:%ld) failed with error 0x%lx\n",				       block, address, blockSize, bytesRead));			}		}		if (!loopErr) {			tag = reinterpret_cast<udf_tag*>(chunk.Data());			loopErr = tag->init_check(block);		}		if (!loopErr) {			// Now decide what type of descriptor we have			switch (tag->id()) {				case TAGID_UNDEFINED:					break;									case TAGID_PRIMARY_VOLUME_DESCRIPTOR:				{					udf_primary_descriptor *primary = reinterpret_cast<udf_primary_descriptor*>(tag);					PDUMP(primary);									(void)primary;	// kill the warning							break;				}								case TAGID_ANCHOR_VOLUME_DESCRIPTOR_POINTER:					break;									case TAGID_VOLUME_DESCRIPTOR_POINTER:					break;				case TAGID_IMPLEMENTATION_USE_VOLUME_DESCRIPTOR:				{					udf_implementation_use_descriptor *imp_use = reinterpret_cast<udf_implementation_use_descriptor*>(tag);					PDUMP(imp_use);									(void)imp_use;	// kill the warning							break;				}				case TAGID_PARTITION_DESCRIPTOR:				{					udf_partition_descriptor *partition = reinterpret_cast<udf_partition_descriptor*>(tag);					PDUMP(partition);					if (partition->tag().init_check(block) == B_OK) {						// Check for a previously discovered partition descriptor with						// the same number as this partition. If found, keep the one with						// the higher vds number.						bool foundDuplicate = false;						int num;						for (num = 0; num < uniquePartitions; num++) {							if (partitionDescriptors[num].partition_number()							    == partition->partition_number())							{								foundDuplicate = true;								if (partitionDescriptors[num].vds_number()								    < partition->vds_number())								{									partitionDescriptors[num] = *partition;											PRINT(("Replacing previous partition #%d (vds_number: %ld) with "									       "new partition #%d (vds_number: %ld)\n",									       partitionDescriptors[num].partition_number(),									       partitionDescriptors[num].vds_number(),									       partition->partition_number(),									       partition->vds_number()));								}								break;							}							    						}						// If we didn't find a duplicate, see if we have any open descriptor						// spaces left.						if (!foundDuplicate) {							if (num < Udf::kMaxPartitionDescriptors) {								// At least one more partition descriptor allowed								partitionDescriptors[num] = *partition;								uniquePartitions++;								PRINT(("Adding partition #%d (vds_number: %ld)\n",								       partition->partition_number(),								       partition->vds_number()));							} else {								// We've found more than kMaxPartitionDescriptor uniquely-								// numbered partitions. So, search through the partitions								// we already have again, this time just looking for a								// partition with a lower vds number. If we find one,								// replace it with this one. If we don't, scream bloody								// murder.								bool foundReplacement = false;								for (int j = 0; j < uniquePartitions; j++) {									if (partitionDescriptors[j].vds_number()									    < partition->vds_number())									{										foundReplacement = true;										partitionDescriptors[j] = *partition;										PRINT(("Replacing partition #%d (vds_number: %ld) "										       "with partition #%d (vds_number: %ld)\n",										       partitionDescriptors[j].partition_number(),										       partitionDescriptors[j].vds_number(),										       partition->partition_number(),										       partition->vds_number()));										break;									}								}								if (!foundReplacement) {									PRINT(("Found more than kMaxPartitionDescriptors == %d "									       "unique partition descriptors!\n",									       kMaxPartitionDescriptors));									error = B_BAD_VALUE;									break;								}							}															} 					}					break;				}									case TAGID_LOGICAL_VOLUME_DESCRIPTOR:				{					udf_logical_descriptor *logical = reinterpret_cast<udf_logical_descriptor*>(tag);					PDUMP(logical);					if (foundLogicalVolumeDescriptor) {						// Keep the vd with the highest vds_number						if (logicalVolumeDescriptor.vds_number() < logical->vds_number())							logicalVolumeDescriptor = *logical;					} else {						logicalVolumeDescriptor = *logical;						foundLogicalVolumeDescriptor = true;						DUMP(logicalVolumeDescriptor);					}					break;				}									case TAGID_UNALLOCATED_SPACE_DESCRIPTOR:				{					udf_unallocated_space_descriptor *unallocated = reinterpret_cast<udf_unallocated_space_descriptor*>(tag);					PDUMP(unallocated);									(void)unallocated;	// kill the warning							break;				}									case TAGID_TERMINATING_DESCRIPTOR:				{					udf_terminating_descriptor *terminating = reinterpret_cast<udf_terminating_descriptor*>(tag);					PDUMP(terminating);					(void)terminating;	// kill the warning							break;				}									case TAGID_LOGICAL_VOLUME_INTEGRITY_DESCRIPTOR:					// Not found in this descriptor sequence					break;				default:					break;									}		}	}	PRINT(("found %d unique partition%s\n", uniquePartitions,	       (uniquePartitions == 1 ? "" : "s")));		if (!error) 		error = foundLogicalVolumeDescriptor ? B_OK : B_ERROR;	if (!error) 		error = uniquePartitions >= 1 ? B_OK : B_ERROR;	if (!error) 		partitionDescriptorCount = uniquePartitions;					RETURN(error);}