xref: /haiku/src/add-ons/kernel/file_systems/udf/SparablePartition.h (revision 3b9617bcc49ac590e177a97de09e06130551a5f4)
1*3b9617bcSTyler Dauwalder //----------------------------------------------------------------------
2*3b9617bcSTyler Dauwalder //  This software is part of the OpenBeOS distribution and is covered
3*3b9617bcSTyler Dauwalder //  by the OpenBeOS license.
4*3b9617bcSTyler Dauwalder //
5*3b9617bcSTyler Dauwalder //  Copyright (c) 2003 Tyler Dauwalder, tyler@dauwalder.net
6*3b9617bcSTyler Dauwalder //---------------------------------------------------------------------
7*3b9617bcSTyler Dauwalder #ifndef _UDF_SPARABLE_PARTITION_H
8*3b9617bcSTyler Dauwalder #define _UDF_SPARABLE_PARTITION_H
9*3b9617bcSTyler Dauwalder 
10*3b9617bcSTyler Dauwalder /*! \file SparablePartition.h
11*3b9617bcSTyler Dauwalder */
12*3b9617bcSTyler Dauwalder 
13*3b9617bcSTyler Dauwalder #include <kernel_cpp.h>
14*3b9617bcSTyler Dauwalder 
15*3b9617bcSTyler Dauwalder #include "Partition.h"
16*3b9617bcSTyler Dauwalder #include "UdfDebug.h"
17*3b9617bcSTyler Dauwalder 
18*3b9617bcSTyler Dauwalder namespace Udf {
19*3b9617bcSTyler Dauwalder 
20*3b9617bcSTyler Dauwalder /*! \brief Type 2 sparable partition
21*3b9617bcSTyler Dauwalder 
22*3b9617bcSTyler Dauwalder 	Sparable partitions provide a defect-managed partition
23*3b9617bcSTyler Dauwalder 	space for media that does not implicitly provide defect management,
24*3b9617bcSTyler Dauwalder 	such as CD-RW. Arbitrary packets of blocks in the sparable partition
25*3b9617bcSTyler Dauwalder 	may be transparently remapped to other locations on disc should the
26*3b9617bcSTyler Dauwalder 	original locations become defective.
27*3b9617bcSTyler Dauwalder 
28*3b9617bcSTyler Dauwalder 	Per UDF-2.01 2.2.11, sparable partitions shall be recorded only on
29*3b9617bcSTyler Dauwalder 	disk/drive systems that do not perform defect management.
30*3b9617bcSTyler Dauwalder 
31*3b9617bcSTyler Dauwalder 	See also UDF-2.01 2.2.9, UDF-2.01 2.2.11
32*3b9617bcSTyler Dauwalder */
33*3b9617bcSTyler Dauwalder class SparablePartition : public Partition {
34*3b9617bcSTyler Dauwalder public:
35*3b9617bcSTyler Dauwalder 	SparablePartition(uint16 number, uint32 start, uint32 length, uint16 packetLength,
36*3b9617bcSTyler Dauwalder 	                  uint8 tableCount, uint32 *tableLocations);
37*3b9617bcSTyler Dauwalder 	virtual ~SparablePartition();
38*3b9617bcSTyler Dauwalder 	virtual status_t MapBlock(uint32 logicalBlock, uint32 &physicalBlock);
39*3b9617bcSTyler Dauwalder 
40*3b9617bcSTyler Dauwalder 	status_t InitCheck();
41*3b9617bcSTyler Dauwalder 
42*3b9617bcSTyler Dauwalder 	uint16 Number() const { return fNumber; }
43*3b9617bcSTyler Dauwalder 	uint32 Start() const { return fStart; }
44*3b9617bcSTyler Dauwalder 	uint32 Length() const { return fLength; }
45*3b9617bcSTyler Dauwalder 	uint32 PacketLength() const { return fPacketLength; }
46*3b9617bcSTyler Dauwalder 	uint8 TableCount() const { return fTableCount; }
47*3b9617bcSTyler Dauwalder 
48*3b9617bcSTyler Dauwalder 	//! Maximum number of redundant sparing tables per SparablePartition
49*3b9617bcSTyler Dauwalder 	static const uint8 kMaxSparingTableCount = 4;
50*3b9617bcSTyler Dauwalder private:
51*3b9617bcSTyler Dauwalder 	uint16 fNumber;
52*3b9617bcSTyler Dauwalder 	uint32 fStart;
53*3b9617bcSTyler Dauwalder 	uint32 fLength;
54*3b9617bcSTyler Dauwalder 	uint32 fPacketLength;
55*3b9617bcSTyler Dauwalder 	uint8 fTableCount;
56*3b9617bcSTyler Dauwalder 	uint32 fTableLocations[kMaxSparingTableCount];
57*3b9617bcSTyler Dauwalder 	status_t fInitStatus;
58*3b9617bcSTyler Dauwalder };
59*3b9617bcSTyler Dauwalder 
60*3b9617bcSTyler Dauwalder };	// namespace Udf
61*3b9617bcSTyler Dauwalder 
62*3b9617bcSTyler Dauwalder #endif	// _UDF_SPARABLE_PARTITION_H
63