btrfs: [] on the end of a struct field is a variable length array.
[haiku.git] / src / add-ons / kernel / file_systems / udf / SparablePartition.cpp
blob480bbb498cbd5ee25956283ef5b3b1c14c0dd35e
1 /*
2 * Copyright 2003, Tyler Dauwalder, tyler@dauwalder.net.
3 * Distributed under the terms of the MIT License.
4 */
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)
15 fNumber(number),
16 fStart(start),
17 fLength(length),
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)
27 ? B_OK : B_BAD_VALUE;
28 if (status != B_OK)
29 return;
31 for (uint8 i = 0; i < TableCount(); i++)
32 fTableLocations[i] = tableLocations[i];
33 fInitStatus = B_OK;
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.
50 status_t
51 SparablePartition::MapBlock(uint32 logicalBlock, off_t &physicalBlock)
53 status_t status = InitCheck();
55 if (status != B_OK)
56 return status;
58 if (logicalBlock >= fLength)
59 return B_BAD_ADDRESS;
60 else {
61 // Check for the logical block in the sparing tables. If not
62 // found, map directly to physical space.
64 //physicalBlock = fStart + logicalBlock;
65 //return B_OK;
66 status = B_ERROR;
68 return status;
72 /*! Returns the initialization status of the object. */
73 status_t
74 SparablePartition::InitCheck()
76 return fInitStatus;