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