1*3b9617bcSTyler Dauwalder #include "SparablePartition.h" 2*3b9617bcSTyler Dauwalder 3*3b9617bcSTyler Dauwalder #define B_NOT_IMPLEMENTED B_ERROR 4*3b9617bcSTyler Dauwalder 5*3b9617bcSTyler Dauwalder using namespace Udf; 6*3b9617bcSTyler Dauwalder 7*3b9617bcSTyler Dauwalder /*! \brief Creates a new SparablePartition object. 8*3b9617bcSTyler Dauwalder */ 9*3b9617bcSTyler Dauwalder SparablePartition::SparablePartition(uint16 number, uint32 start, uint32 length, 10*3b9617bcSTyler Dauwalder uint16 packetLength, uint8 tableCount, 11*3b9617bcSTyler Dauwalder uint32 *tableLocations) 12*3b9617bcSTyler Dauwalder : fNumber(number) 13*3b9617bcSTyler Dauwalder , fStart(start) 14*3b9617bcSTyler Dauwalder , fLength(length) 15*3b9617bcSTyler Dauwalder , fPacketLength(packetLength) 16*3b9617bcSTyler Dauwalder , fTableCount(tableCount) 17*3b9617bcSTyler Dauwalder , fInitStatus(B_NO_INIT) 18*3b9617bcSTyler Dauwalder { 19*3b9617bcSTyler Dauwalder status_t error = (0 < TableCount() && TableCount() <= kMaxSparingTableCount) 20*3b9617bcSTyler Dauwalder ? B_OK : B_BAD_VALUE; 21*3b9617bcSTyler Dauwalder if (!error) { 22*3b9617bcSTyler Dauwalder for (uint8 i = 0; i < TableCount(); i++) 23*3b9617bcSTyler Dauwalder fTableLocations[i] = tableLocations[i]; 24*3b9617bcSTyler Dauwalder } 25*3b9617bcSTyler Dauwalder if (!error) 26*3b9617bcSTyler Dauwalder fInitStatus = B_OK; 27*3b9617bcSTyler Dauwalder } 28*3b9617bcSTyler Dauwalder 29*3b9617bcSTyler Dauwalder /*! \brief Destroys the SparablePartition object. 30*3b9617bcSTyler Dauwalder */ 31*3b9617bcSTyler Dauwalder SparablePartition::~SparablePartition() 32*3b9617bcSTyler Dauwalder { 33*3b9617bcSTyler Dauwalder } 34*3b9617bcSTyler Dauwalder 35*3b9617bcSTyler Dauwalder /*! \brief Maps the given logical block to a physical block on disc. 36*3b9617bcSTyler Dauwalder 37*3b9617bcSTyler Dauwalder The sparing tables are first checked to see if the logical block has 38*3b9617bcSTyler Dauwalder been remapped from a defective location to a non-defective one. If 39*3b9617bcSTyler Dauwalder not, the given logical block is then simply treated as an offset from 40*3b9617bcSTyler Dauwalder the start of the physical partition. 41*3b9617bcSTyler Dauwalder */ 42*3b9617bcSTyler Dauwalder status_t 43*3b9617bcSTyler Dauwalder SparablePartition::MapBlock(uint32 logicalBlock, uint32 &physicalBlock) 44*3b9617bcSTyler Dauwalder { 45*3b9617bcSTyler Dauwalder status_t error = InitCheck(); 46*3b9617bcSTyler Dauwalder if (!error) { 47*3b9617bcSTyler Dauwalder if (logicalBlock >= fLength) 48*3b9617bcSTyler Dauwalder error = B_BAD_ADDRESS; 49*3b9617bcSTyler Dauwalder else { 50*3b9617bcSTyler Dauwalder // Check for the logical block in the sparing tables. If not 51*3b9617bcSTyler Dauwalder // found, map directly to physical space. 52*3b9617bcSTyler Dauwalder 53*3b9617bcSTyler Dauwalder //physicalBlock = fStart + logicalBlock; 54*3b9617bcSTyler Dauwalder //return B_OK; 55*3b9617bcSTyler Dauwalder error = B_NOT_IMPLEMENTED; 56*3b9617bcSTyler Dauwalder } 57*3b9617bcSTyler Dauwalder } 58*3b9617bcSTyler Dauwalder return error; 59*3b9617bcSTyler Dauwalder } 60*3b9617bcSTyler Dauwalder 61*3b9617bcSTyler Dauwalder /*! Returns the initialization status of the object. 62*3b9617bcSTyler Dauwalder */ 63*3b9617bcSTyler Dauwalder status_t 64*3b9617bcSTyler Dauwalder SparablePartition::InitCheck() 65*3b9617bcSTyler Dauwalder { 66*3b9617bcSTyler Dauwalder return fInitStatus; 67*3b9617bcSTyler Dauwalder } 68