104106297STyler Dauwalder #include "PhysicalPartition.h"
204106297STyler Dauwalder
304106297STyler Dauwalder #define B_NOT_IMPLEMENTED B_ERROR
404106297STyler Dauwalder
504106297STyler Dauwalder
604106297STyler Dauwalder /*! \brief Creates a new PhysicalPartition object.
704106297STyler Dauwalder */
PhysicalPartition(uint16 number,uint32 start,uint32 length)804106297STyler Dauwalder PhysicalPartition::PhysicalPartition(uint16 number, uint32 start, uint32 length)
9c9334140SSalvatore Benedetto :
10c9334140SSalvatore Benedetto fNumber(number),
11c9334140SSalvatore Benedetto fStart(start),
12c9334140SSalvatore Benedetto fLength(length)
1304106297STyler Dauwalder {
14*7e5b0f96SJérôme Duval TRACE(("PhysicalPartition::PhysicalPartition: number = %d, start = %"
15*7e5b0f96SJérôme Duval B_PRIu32 ",length = %" B_PRIu32 "\n", number, start, length));
1604106297STyler Dauwalder }
1704106297STyler Dauwalder
18c5855c9eSSalvatore Benedetto
1904106297STyler Dauwalder /*! \brief Destroys the PhysicalPartition object.
2004106297STyler Dauwalder */
~PhysicalPartition()2104106297STyler Dauwalder PhysicalPartition::~PhysicalPartition()
2204106297STyler Dauwalder {
2304106297STyler Dauwalder }
2404106297STyler Dauwalder
25c5855c9eSSalvatore Benedetto
2604106297STyler Dauwalder /*! \brief Maps the given logical block to a physical block on disc.
2704106297STyler Dauwalder
2804106297STyler Dauwalder The given logical block is simply treated as an offset from the
2904106297STyler Dauwalder start of the physical partition.
3004106297STyler Dauwalder */
3104106297STyler Dauwalder status_t
MapBlock(uint32 logicalBlock,off_t & physicalBlock)32a1b5a724STyler Dauwalder PhysicalPartition::MapBlock(uint32 logicalBlock, off_t &physicalBlock)
3304106297STyler Dauwalder {
34*7e5b0f96SJérôme Duval TRACE(("PhysicalPartition::MapBlock: %" B_PRIu32 "\n", logicalBlock));
3529d3fcedSTyler Dauwalder if (logicalBlock >= fLength) {
36*7e5b0f96SJérôme Duval TRACE_ERROR(("PhysicalPartition::MapBlock: block %" B_PRIu32 " invalid"
37*7e5b0f96SJérôme Duval ",length = %" B_PRIu32 "\n", logicalBlock, fLength));
3804106297STyler Dauwalder return B_BAD_ADDRESS;
3929d3fcedSTyler Dauwalder } else {
4004106297STyler Dauwalder physicalBlock = fStart + logicalBlock;
41*7e5b0f96SJérôme Duval TRACE(("PhysicalPartition::MapBlock: block %" B_PRIu32 " mapped to %"
42*7e5b0f96SJérôme Duval B_PRIdOFF "\n", logicalBlock, physicalBlock));
4304106297STyler Dauwalder return B_OK;
4404106297STyler Dauwalder }
4504106297STyler Dauwalder }
46