2 * Copyright 2003, Tyler Dauwalder, tyler@dauwalder.net.
3 * Distributed under the terms of the MIT License.
6 #include "SparablePartition.h"
8 #define B_NOT_IMPLEMENTED B_ERROR
11 /*! \brief Creates a new SparablePartition object. */
12 SparablePartition::SparablePartition(uint16 number
, uint32 start
, uint32 length
,
13 uint16 packetLength
, uint8 tableCount
, uint32
*tableLocations
)
18 fPacketLength(packetLength
),
19 fTableCount(tableCount
),
20 fInitStatus(B_NO_INIT
)
22 TRACE(("SparablePartition::SparablePartition: number = %d, start = %"
23 B_PRIu32
",length = %" B_PRIu32
", packetLength = %d\n", number
, start
,
24 length
, packetLength
));
26 status_t status
= (0 < TableCount() && TableCount() <= kMaxSparingTableCount
)
31 for (uint8 i
= 0; i
< TableCount(); i
++)
32 fTableLocations
[i
] = tableLocations
[i
];
37 /*! \brief Destroys the SparablePartition object. */
38 SparablePartition::~SparablePartition()
43 /*! \brief Maps the given logical block to a physical block on disc.
45 The sparing tables are first checked to see if the logical block has
46 been remapped from a defective location to a non-defective one. If
47 not, the given logical block is then simply treated as an offset from
48 the start of the physical partition.
51 SparablePartition::MapBlock(uint32 logicalBlock
, off_t
&physicalBlock
)
53 status_t status
= InitCheck();
58 if (logicalBlock
>= fLength
)
61 // Check for the logical block in the sparing tables. If not
62 // found, map directly to physical space.
64 //physicalBlock = fStart + logicalBlock;
72 /*! Returns the initialization status of the object. */
74 SparablePartition::InitCheck()