* Clean up, no functional changes.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27174 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Salvatore Benedetto
2008-08-23 12:58:24 +00:00
parent 3f60937555
commit c5855c9ef4
4 changed files with 71 additions and 58 deletions
@@ -11,14 +11,18 @@ PhysicalPartition::PhysicalPartition(uint16 number, uint32 start, uint32 length)
fStart(start), fStart(start),
fLength(length) fLength(length)
{ {
TRACE(("PhysicalPartition::PhysicalPartition: number = %d, start = %d,
length = %d\n", number, start, length));
} }
/*! \brief Destroys the PhysicalPartition object. /*! \brief Destroys the PhysicalPartition object.
*/ */
PhysicalPartition::~PhysicalPartition() PhysicalPartition::~PhysicalPartition()
{ {
} }
/*! \brief Maps the given logical block to a physical block on disc. /*! \brief Maps the given logical block to a physical block on disc.
The given logical block is simply treated as an offset from the The given logical block is simply treated as an offset from the
@@ -161,8 +161,8 @@ walk_volume_recognition_sequence(int device, off_t offset, uint32 blockSize,
return foundECMA167 || (foundExtended && !foundECMA168) ? B_OK : B_ERROR; return foundECMA167 || (foundExtended && !foundECMA168) ? B_OK : B_ERROR;
} }
static
status_t static status_t
walk_anchor_volume_descriptor_sequences(int device, off_t offset, off_t length, walk_anchor_volume_descriptor_sequences(int device, off_t offset, off_t length,
uint32 blockSize, uint32 blockShift, uint32 blockSize, uint32 blockShift,
logical_volume_descriptor &logicalVolumeDescriptor, logical_volume_descriptor &logicalVolumeDescriptor,
@@ -188,10 +188,10 @@ walk_anchor_volume_descriptor_sequences(int device, off_t offset, off_t length,
PRINT(("block %Ld: read_pos(pos:%Ld, len:%ld) failed with error 0x%lx\n", PRINT(("block %Ld: read_pos(pos:%Ld, len:%ld) failed with error 0x%lx\n",
block, address, blockSize, bytesRead)); block, address, blockSize, bytesRead));
} }
} }
if (!anchorErr) { if (!anchorErr) {
anchor = reinterpret_cast<anchor_volume_descriptor*>(chunk.Data()); anchor = reinterpret_cast<anchor_volume_descriptor*>(chunk.Data());
anchorErr = anchor->tag().init_check(block+offset); anchorErr = anchor->tag().init_check(block + offset);
if (anchorErr) { if (anchorErr) {
PRINT(("block %Ld: invalid anchor\n", block)); PRINT(("block %Ld: invalid anchor\n", block));
} else { } else {
@@ -203,17 +203,14 @@ walk_anchor_volume_descriptor_sequences(int device, off_t offset, off_t length,
PDUMP(anchor); PDUMP(anchor);
// Found an avds, so try the main sequence first, then // Found an avds, so try the main sequence first, then
// the reserve sequence if the main one fails. // the reserve sequence if the main one fails.
anchorErr = walk_volume_descriptor_sequence(anchor->main_vds(), device, anchorErr = walk_volume_descriptor_sequence(anchor->main_vds(),
blockSize, blockShift, device, blockSize, blockShift, logicalVolumeDescriptor,
logicalVolumeDescriptor, partitionDescriptors, partitionDescriptorCount);
partitionDescriptors,
partitionDescriptorCount);
if (anchorErr) if (anchorErr)
anchorErr = walk_volume_descriptor_sequence(anchor->reserve_vds(), device, anchorErr = walk_volume_descriptor_sequence(anchor->reserve_vds(),
blockSize, blockShift, device, blockSize, blockShift, logicalVolumeDescriptor,
logicalVolumeDescriptor, partitionDescriptors, partitionDescriptorCount);
partitionDescriptors,
partitionDescriptorCount);
} }
if (!anchorErr) { if (!anchorErr) {
PRINT(("block %Ld: found valid vds\n", avds_locations[i])); PRINT(("block %Ld: found valid vds\n", avds_locations[i]));
@@ -231,10 +228,10 @@ walk_anchor_volume_descriptor_sequences(int device, off_t offset, off_t length,
static static
status_t status_t
walk_volume_descriptor_sequence(extent_address descriptorSequence, walk_volume_descriptor_sequence(extent_address descriptorSequence,
int device, uint32 blockSize, uint32 blockShift, int device, uint32 blockSize, uint32 blockShift,
logical_volume_descriptor &logicalVolumeDescriptor, logical_volume_descriptor &logicalVolumeDescriptor,
partition_descriptor partitionDescriptors[], partition_descriptor partitionDescriptors[],
uint8 &partitionDescriptorCount) uint8 &partitionDescriptorCount)
{ {
DEBUG_INIT_ETC(NULL, ("descriptorSequence.loc:%ld, descriptorSequence.len:%ld", DEBUG_INIT_ETC(NULL, ("descriptorSequence.loc:%ld, descriptorSequence.len:%ld",
descriptorSequence.location(), descriptorSequence.length())); descriptorSequence.location(), descriptorSequence.length()));
@@ -273,7 +270,7 @@ walk_volume_descriptor_sequence(extent_address descriptorSequence,
switch (tag->id()) { switch (tag->id()) {
case TAGID_UNDEFINED: case TAGID_UNDEFINED:
break; break;
case TAGID_PRIMARY_VOLUME_DESCRIPTOR: case TAGID_PRIMARY_VOLUME_DESCRIPTOR:
{ {
primary_volume_descriptor *primary = reinterpret_cast<primary_volume_descriptor*>(tag); primary_volume_descriptor *primary = reinterpret_cast<primary_volume_descriptor*>(tag);
@@ -281,7 +278,7 @@ walk_volume_descriptor_sequence(extent_address descriptorSequence,
(void)primary; // kill the warning (void)primary; // kill the warning
break; break;
} }
case TAGID_ANCHOR_VOLUME_DESCRIPTOR_POINTER: case TAGID_ANCHOR_VOLUME_DESCRIPTOR_POINTER:
break; break;
@@ -1,36 +1,44 @@
/*
* Copyright 2003, Tyler Dauwalder, [email protected].
* Distributed under the terms of the MIT License.
*/
#include "SparablePartition.h" #include "SparablePartition.h"
#define B_NOT_IMPLEMENTED B_ERROR #define B_NOT_IMPLEMENTED B_ERROR
/*! \brief Creates a new SparablePartition object. /*! \brief Creates a new SparablePartition object. */
*/
SparablePartition::SparablePartition(uint16 number, uint32 start, uint32 length, SparablePartition::SparablePartition(uint16 number, uint32 start, uint32 length,
uint16 packetLength, uint8 tableCount, uint16 packetLength, uint8 tableCount, uint32 *tableLocations)
uint32 *tableLocations) :
: fNumber(number) fNumber(number),
, fStart(start) fStart(start),
, fLength(length) fLength(length),
, fPacketLength(packetLength) fPacketLength(packetLength),
, fTableCount(tableCount) fTableCount(tableCount),
, fInitStatus(B_NO_INIT) fInitStatus(B_NO_INIT)
{ {
status_t error = (0 < TableCount() && TableCount() <= kMaxSparingTableCount) TRACE(("SparablePartition::SparablePartition: number = %d, start = %d,
? B_OK : B_BAD_VALUE; length = %d, packetLength = %d\n", number, start, length, packetLength));
if (!error) {
for (uint8 i = 0; i < TableCount(); i++) status_t status = (0 < TableCount() && TableCount() <= kMaxSparingTableCount)
fTableLocations[i] = tableLocations[i]; ? B_OK : B_BAD_VALUE;
} if (status != B_OK)
if (!error) return;
fInitStatus = B_OK;
for (uint8 i = 0; i < TableCount(); i++)
fTableLocations[i] = tableLocations[i];
fInitStatus = B_OK;
} }
/*! \brief Destroys the SparablePartition object.
*/ /*! \brief Destroys the SparablePartition object. */
SparablePartition::~SparablePartition() SparablePartition::~SparablePartition()
{ {
} }
/*! \brief Maps the given logical block to a physical block on disc. /*! \brief Maps the given logical block to a physical block on disc.
The sparing tables are first checked to see if the logical block has The sparing tables are first checked to see if the logical block has
@@ -41,24 +49,26 @@ SparablePartition::~SparablePartition()
status_t status_t
SparablePartition::MapBlock(uint32 logicalBlock, off_t &physicalBlock) SparablePartition::MapBlock(uint32 logicalBlock, off_t &physicalBlock)
{ {
status_t error = InitCheck(); status_t status = InitCheck();
if (!error) {
if (logicalBlock >= fLength)
error = B_BAD_ADDRESS;
else {
// Check for the logical block in the sparing tables. If not
// found, map directly to physical space.
//physicalBlock = fStart + logicalBlock; if (status != B_OK)
//return B_OK; return status;
error = B_ERROR;
} if (logicalBlock >= fLength)
return B_BAD_ADDRESS;
else {
// Check for the logical block in the sparing tables. If not
// found, map directly to physical space.
//physicalBlock = fStart + logicalBlock;
//return B_OK;
status = B_ERROR;
} }
return error; return status;
} }
/*! Returns the initialization status of the object.
*/ /*! Returns the initialization status of the object. */
status_t status_t
SparablePartition::InitCheck() SparablePartition::InitCheck()
{ {
@@ -13,15 +13,17 @@
VirtualPartition::VirtualPartition(PhysicalPartition &physicalPartition) VirtualPartition::VirtualPartition(PhysicalPartition &physicalPartition)
: fPhysicalPartition(physicalPartition) : fPhysicalPartition(physicalPartition)
{ {
TRACE_ERROR(("VirtualPartition::VirtualPartition: not implemented!\n"));
// Find VAT // Find VAT
} }
/*! \brief Destroys the VirtualPartition object.
*/ /*! \brief Destroys the VirtualPartition object. */
VirtualPartition::~VirtualPartition() VirtualPartition::~VirtualPartition()
{ {
} }
/*! \brief Maps the given logical block to a physical block on disc. /*! \brief Maps the given logical block to a physical block on disc.
The given logical block is indexed into the VAT. If a corresponding The given logical block is indexed into the VAT. If a corresponding
@@ -34,8 +36,8 @@ VirtualPartition::MapBlock(uint32 logicalBlock, off_t &physicalBlock)
return B_NOT_IMPLEMENTED; return B_NOT_IMPLEMENTED;
} }
/*! Returns the initialization status of the object.
*/ /*! Returns the initialization status of the object. */
status_t status_t
VirtualPartition::InitCheck() VirtualPartition::InitCheck()
{ {