xref: /haiku/src/add-ons/kernel/file_systems/udf/SparablePartition.h (revision 9c6a058880769a0e754a9c3a59c9793683aa6de3)
13b9617bcSTyler Dauwalder //----------------------------------------------------------------------
23b9617bcSTyler Dauwalder //  This software is part of the OpenBeOS distribution and is covered
33b9617bcSTyler Dauwalder //  by the OpenBeOS license.
43b9617bcSTyler Dauwalder //
53b9617bcSTyler Dauwalder //  Copyright (c) 2003 Tyler Dauwalder, tyler@dauwalder.net
63b9617bcSTyler Dauwalder //---------------------------------------------------------------------
73b9617bcSTyler Dauwalder #ifndef _UDF_SPARABLE_PARTITION_H
83b9617bcSTyler Dauwalder #define _UDF_SPARABLE_PARTITION_H
93b9617bcSTyler Dauwalder 
103b9617bcSTyler Dauwalder /*! \file SparablePartition.h
113b9617bcSTyler Dauwalder */
123b9617bcSTyler Dauwalder 
133b9617bcSTyler Dauwalder #include <kernel_cpp.h>
143b9617bcSTyler Dauwalder 
15*9c6a0588STyler Dauwalder #include "UdfStructures.h"
163b9617bcSTyler Dauwalder #include "Partition.h"
173b9617bcSTyler Dauwalder #include "UdfDebug.h"
183b9617bcSTyler Dauwalder 
193b9617bcSTyler Dauwalder namespace Udf {
203b9617bcSTyler Dauwalder 
213b9617bcSTyler Dauwalder /*! \brief Type 2 sparable partition
223b9617bcSTyler Dauwalder 
233b9617bcSTyler Dauwalder 	Sparable partitions provide a defect-managed partition
243b9617bcSTyler Dauwalder 	space for media that does not implicitly provide defect management,
253b9617bcSTyler Dauwalder 	such as CD-RW. Arbitrary packets of blocks in the sparable partition
263b9617bcSTyler Dauwalder 	may be transparently remapped to other locations on disc should the
273b9617bcSTyler Dauwalder 	original locations become defective.
283b9617bcSTyler Dauwalder 
293b9617bcSTyler Dauwalder 	Per UDF-2.01 2.2.11, sparable partitions shall be recorded only on
303b9617bcSTyler Dauwalder 	disk/drive systems that do not perform defect management.
313b9617bcSTyler Dauwalder 
323b9617bcSTyler Dauwalder 	See also UDF-2.01 2.2.9, UDF-2.01 2.2.11
333b9617bcSTyler Dauwalder */
343b9617bcSTyler Dauwalder class SparablePartition : public Partition {
353b9617bcSTyler Dauwalder public:
363b9617bcSTyler Dauwalder 	SparablePartition(uint16 number, uint32 start, uint32 length, uint16 packetLength,
373b9617bcSTyler Dauwalder 	                  uint8 tableCount, uint32 *tableLocations);
383b9617bcSTyler Dauwalder 	virtual ~SparablePartition();
39a1b5a724STyler Dauwalder 	virtual status_t MapBlock(uint32 logicalBlock, off_t &physicalBlock);
403b9617bcSTyler Dauwalder 
413b9617bcSTyler Dauwalder 	status_t InitCheck();
423b9617bcSTyler Dauwalder 
433b9617bcSTyler Dauwalder 	uint16 Number() const { return fNumber; }
443b9617bcSTyler Dauwalder 	uint32 Start() const { return fStart; }
453b9617bcSTyler Dauwalder 	uint32 Length() const { return fLength; }
463b9617bcSTyler Dauwalder 	uint32 PacketLength() const { return fPacketLength; }
473b9617bcSTyler Dauwalder 	uint8 TableCount() const { return fTableCount; }
483b9617bcSTyler Dauwalder 
493b9617bcSTyler Dauwalder 	//! Maximum number of redundant sparing tables per SparablePartition
50a1b5a724STyler Dauwalder 	static const uint8 kMaxSparingTableCount = UDF_MAX_SPARING_TABLE_COUNT;
513b9617bcSTyler Dauwalder private:
523b9617bcSTyler Dauwalder 	uint16 fNumber;
533b9617bcSTyler Dauwalder 	uint32 fStart;
543b9617bcSTyler Dauwalder 	uint32 fLength;
553b9617bcSTyler Dauwalder 	uint32 fPacketLength;
563b9617bcSTyler Dauwalder 	uint8 fTableCount;
573b9617bcSTyler Dauwalder 	uint32 fTableLocations[kMaxSparingTableCount];
583b9617bcSTyler Dauwalder 	status_t fInitStatus;
593b9617bcSTyler Dauwalder };
603b9617bcSTyler Dauwalder 
613b9617bcSTyler Dauwalder };	// namespace Udf
623b9617bcSTyler Dauwalder 
633b9617bcSTyler Dauwalder #endif	// _UDF_SPARABLE_PARTITION_H
64