file_systems/udf: Reduce indent
Reduce indent in walk_volume_descriptor_sequence() for readability. Change-Id: Ie4d46fc69ebee3b74f0410639f06010351e71894 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3294 Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
1e22d0d338
commit
d3179631c9
@@ -239,84 +239,15 @@ walk_anchor_volume_descriptor_sequences(int device, off_t offset, off_t length,
|
||||
RETURN(error);
|
||||
}
|
||||
|
||||
static
|
||||
status_t
|
||||
walk_volume_descriptor_sequence(extent_address descriptorSequence,
|
||||
int device, uint32 blockSize, uint32 blockShift,
|
||||
primary_volume_descriptor &primaryVolumeDescriptor,
|
||||
logical_volume_descriptor &logicalVolumeDescriptor,
|
||||
partition_descriptor partitionDescriptors[],
|
||||
uint8 &partitionDescriptorCount)
|
||||
static status_t
|
||||
walk_tagid_partition_descriptor(descriptor_tag *tag, off_t block,
|
||||
uint8& uniquePartitions, partition_descriptor* partitionDescriptors)
|
||||
{
|
||||
DEBUG_INIT_ETC(NULL, ("descriptorSequence.loc:%" PRIu32 ", "
|
||||
"descriptorSequence.len:%" PRIu32,
|
||||
descriptorSequence.location(), descriptorSequence.length()));
|
||||
uint32 count = descriptorSequence.length() >> blockShift;
|
||||
DEBUG_INIT(NULL);
|
||||
|
||||
bool foundLogicalVolumeDescriptor = false;
|
||||
bool foundUnallocatedSpaceDescriptor = false;
|
||||
bool foundUdfImplementationUseDescriptor = 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);
|
||||
descriptor_tag *tag = NULL;
|
||||
|
||||
PRINT(("descriptor #%" PRIu32 " (block %" B_PRIdOFF "):\n", i, block));
|
||||
|
||||
status_t loopError = chunk.InitCheck();
|
||||
if (!loopError) {
|
||||
ssize_t bytesRead = read_pos(device, address, chunk.Data(), blockSize);
|
||||
loopError = bytesRead == (ssize_t)blockSize ? B_OK : B_IO_ERROR;
|
||||
if (loopError) {
|
||||
PRINT(("block %" B_PRIdOFF ": read_pos(pos:%" B_PRIdOFF ", "
|
||||
"len:%" B_PRIu32 ") failed with error 0x%lx\n",
|
||||
block, address, blockSize, bytesRead));
|
||||
}
|
||||
}
|
||||
if (!loopError) {
|
||||
tag = reinterpret_cast<descriptor_tag *>(chunk.Data());
|
||||
loopError = tag->init_check(block);
|
||||
}
|
||||
if (!loopError) {
|
||||
// Now decide what type of descriptor we have
|
||||
switch (tag->id()) {
|
||||
case TAGID_UNDEFINED:
|
||||
break;
|
||||
|
||||
case TAGID_PRIMARY_VOLUME_DESCRIPTOR:
|
||||
{
|
||||
primary_volume_descriptor *primary = reinterpret_cast<primary_volume_descriptor*>(tag);
|
||||
PDUMP(primary);
|
||||
primaryVolumeDescriptor = *primary;
|
||||
break;
|
||||
}
|
||||
|
||||
case TAGID_ANCHOR_VOLUME_DESCRIPTOR_POINTER:
|
||||
break;
|
||||
|
||||
case TAGID_VOLUME_DESCRIPTOR_POINTER:
|
||||
break;
|
||||
|
||||
case TAGID_IMPLEMENTATION_USE_VOLUME_DESCRIPTOR:
|
||||
{
|
||||
implementation_use_descriptor *impUse = reinterpret_cast<implementation_use_descriptor*>(tag);
|
||||
PDUMP(impUse);
|
||||
// Check for a matching implementation id string (note that the
|
||||
// revision version is not checked)
|
||||
if (impUse->tag().init_check(block) == B_OK
|
||||
&& impUse->implementation_id().matches(kLogicalVolumeInfoId201)) {
|
||||
foundUdfImplementationUseDescriptor = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case TAGID_PARTITION_DESCRIPTOR:
|
||||
{
|
||||
partition_descriptor *partition = reinterpret_cast<partition_descriptor*>(tag);
|
||||
partition_descriptor *partition =
|
||||
reinterpret_cast<partition_descriptor*>(tag);
|
||||
PDUMP(partition);
|
||||
if (partition->tag().init_check(block) == B_OK) {
|
||||
// Check for a previously discovered partition descriptor with
|
||||
@@ -332,8 +263,7 @@ walk_volume_descriptor_sequence(extent_address descriptorSequence,
|
||||
< partition->vds_number()) {
|
||||
partitionDescriptors[num] = *partition;
|
||||
PRINT(("Replacing previous partition #%d "
|
||||
"(vds_number: %" B_PRIu32 ") "
|
||||
"with new partition #%d "
|
||||
"(vds_number: %" B_PRIu32 ") with new partition #%d "
|
||||
"(vds_number: %" B_PRIu32 ")\n",
|
||||
partitionDescriptors[num].partition_number(),
|
||||
partitionDescriptors[num].vds_number(),
|
||||
@@ -350,8 +280,7 @@ walk_volume_descriptor_sequence(extent_address descriptorSequence,
|
||||
// At least one more partition descriptor allowed
|
||||
partitionDescriptors[num] = *partition;
|
||||
uniquePartitions++;
|
||||
PRINT(("Adding partition #%d (vds_number: %" B_PRIu32
|
||||
")\n",
|
||||
PRINT(("Adding partition #%d (vds_number: %" B_PRIu32 ")\n",
|
||||
partition->partition_number(),
|
||||
partition->vds_number()));
|
||||
} else {
|
||||
@@ -383,22 +312,111 @@ walk_volume_descriptor_sequence(extent_address descriptorSequence,
|
||||
"unique partition descriptors!\n",
|
||||
kMaxPartitionDescriptors));
|
||||
error = B_BAD_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RETURN(error);
|
||||
}
|
||||
|
||||
static
|
||||
status_t
|
||||
walk_volume_descriptor_sequence(extent_address descriptorSequence,
|
||||
int device, uint32 blockSize, uint32 blockShift,
|
||||
primary_volume_descriptor &primaryVolumeDescriptor,
|
||||
logical_volume_descriptor &logicalVolumeDescriptor,
|
||||
partition_descriptor partitionDescriptors[],
|
||||
uint8 &partitionDescriptorCount)
|
||||
{
|
||||
DEBUG_INIT_ETC(NULL, ("descriptorSequence.loc:%" PRIu32 ", "
|
||||
"descriptorSequence.len:%" PRIu32,
|
||||
descriptorSequence.location(), descriptorSequence.length()));
|
||||
uint32 count = descriptorSequence.length() >> blockShift;
|
||||
|
||||
bool foundLogicalVolumeDescriptor = false;
|
||||
bool foundUnallocatedSpaceDescriptor = false;
|
||||
bool foundUdfImplementationUseDescriptor = 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);
|
||||
descriptor_tag *tag = NULL;
|
||||
|
||||
PRINT(("descriptor #%" PRIu32 " (block %" B_PRIdOFF "):\n", i, block));
|
||||
|
||||
status_t loopError = chunk.InitCheck();
|
||||
if (!loopError) {
|
||||
ssize_t bytesRead = read_pos(device, address, chunk.Data(),
|
||||
blockSize);
|
||||
loopError = bytesRead == (ssize_t)blockSize ? B_OK : B_IO_ERROR;
|
||||
if (loopError) {
|
||||
PRINT(("block %" B_PRIdOFF ": read_pos(pos:%" B_PRIdOFF ", "
|
||||
"len:%" B_PRIu32 ") failed with error 0x%lx\n",
|
||||
block, address, blockSize, bytesRead));
|
||||
}
|
||||
}
|
||||
if (!loopError) {
|
||||
tag = reinterpret_cast<descriptor_tag *>(chunk.Data());
|
||||
loopError = tag->init_check(block);
|
||||
}
|
||||
if (!loopError) {
|
||||
// Now decide what type of descriptor we have
|
||||
switch (tag->id()) {
|
||||
case TAGID_UNDEFINED:
|
||||
break;
|
||||
|
||||
case TAGID_PRIMARY_VOLUME_DESCRIPTOR:
|
||||
{
|
||||
primary_volume_descriptor *primary =
|
||||
reinterpret_cast<primary_volume_descriptor*>(tag);
|
||||
PDUMP(primary);
|
||||
primaryVolumeDescriptor = *primary;
|
||||
break;
|
||||
}
|
||||
|
||||
case TAGID_ANCHOR_VOLUME_DESCRIPTOR_POINTER:
|
||||
break;
|
||||
|
||||
case TAGID_VOLUME_DESCRIPTOR_POINTER:
|
||||
break;
|
||||
|
||||
case TAGID_IMPLEMENTATION_USE_VOLUME_DESCRIPTOR:
|
||||
{
|
||||
implementation_use_descriptor *impUse =
|
||||
reinterpret_cast<implementation_use_descriptor*>(tag);
|
||||
PDUMP(impUse);
|
||||
// Check for a matching implementation id string
|
||||
// (note that the revision version is not checked)
|
||||
if (impUse->tag().init_check(block) == B_OK
|
||||
&& impUse->implementation_id().matches(
|
||||
kLogicalVolumeInfoId201)) {
|
||||
foundUdfImplementationUseDescriptor = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
case TAGID_PARTITION_DESCRIPTOR:
|
||||
{
|
||||
error = walk_tagid_partition_descriptor(
|
||||
tag, block, uniquePartitions, partitionDescriptors);
|
||||
break;
|
||||
}
|
||||
|
||||
case TAGID_LOGICAL_VOLUME_DESCRIPTOR:
|
||||
{
|
||||
logical_volume_descriptor *logical = reinterpret_cast<logical_volume_descriptor*>(tag);
|
||||
logical_volume_descriptor *logical =
|
||||
reinterpret_cast<logical_volume_descriptor*>(tag);
|
||||
PDUMP(logical);
|
||||
if (foundLogicalVolumeDescriptor) {
|
||||
// Keep the vd with the highest vds_number
|
||||
if (logicalVolumeDescriptor.vds_number() < logical->vds_number())
|
||||
if (logicalVolumeDescriptor.vds_number()
|
||||
< logical->vds_number()) {
|
||||
logicalVolumeDescriptor = *logical;
|
||||
}
|
||||
} else {
|
||||
logicalVolumeDescriptor = *logical;
|
||||
foundLogicalVolumeDescriptor = true;
|
||||
@@ -408,7 +426,8 @@ walk_volume_descriptor_sequence(extent_address descriptorSequence,
|
||||
|
||||
case TAGID_UNALLOCATED_SPACE_DESCRIPTOR:
|
||||
{
|
||||
unallocated_space_descriptor *unallocated = reinterpret_cast<unallocated_space_descriptor*>(tag);
|
||||
unallocated_space_descriptor *unallocated =
|
||||
reinterpret_cast<unallocated_space_descriptor*>(tag);
|
||||
PDUMP(unallocated);
|
||||
foundUnallocatedSpaceDescriptor = true;
|
||||
(void)unallocated; // kill the warning
|
||||
@@ -417,7 +436,8 @@ walk_volume_descriptor_sequence(extent_address descriptorSequence,
|
||||
|
||||
case TAGID_TERMINATING_DESCRIPTOR:
|
||||
{
|
||||
terminating_descriptor *terminating = reinterpret_cast<terminating_descriptor*>(tag);
|
||||
terminating_descriptor *terminating =
|
||||
reinterpret_cast<terminating_descriptor*>(tag);
|
||||
PDUMP(terminating);
|
||||
(void)terminating; // kill the warning
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user