1#include "PhysicalPartition.h" 2 3#define B_NOT_IMPLEMENTED B_ERROR 4 5 6/*! \brief Creates a new PhysicalPartition object. 7*/ 8PhysicalPartition::PhysicalPartition(uint16 number, uint32 start, uint32 length) 9 : 10 fNumber(number), 11 fStart(start), 12 fLength(length) 13{ 14 TRACE(("PhysicalPartition::PhysicalPartition: number = %d, start = %" 15 B_PRIu32 ",length = %" B_PRIu32 "\n", number, start, length)); 16} 17 18 19/*! \brief Destroys the PhysicalPartition object. 20*/ 21PhysicalPartition::~PhysicalPartition() 22{ 23} 24 25 26/*! \brief Maps the given logical block to a physical block on disc. 27 28 The given logical block is simply treated as an offset from the 29 start of the physical partition. 30*/ 31status_t 32PhysicalPartition::MapBlock(uint32 logicalBlock, off_t &physicalBlock) 33{ 34 TRACE(("PhysicalPartition::MapBlock: %" B_PRIu32 "\n", logicalBlock)); 35 if (logicalBlock >= fLength) { 36 TRACE_ERROR(("PhysicalPartition::MapBlock: block %" B_PRIu32 " invalid" 37 ",length = %" B_PRIu32 "\n", logicalBlock, fLength)); 38 return B_BAD_ADDRESS; 39 } else { 40 physicalBlock = fStart + logicalBlock; 41 TRACE(("PhysicalPartition::MapBlock: block %" B_PRIu32 " mapped to %" 42 B_PRIdOFF "\n", logicalBlock, physicalBlock)); 43 return B_OK; 44 } 45} 46