Initial checkin. Mostly empty implementation of UDF 2.01 sparable partitions.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5232 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Tyler Dauwalder 2003-11-02 01:13:15 +00:00
parent 04106297aa
commit 3b9617bcc4
2 changed files with 129 additions and 0 deletions

View File

@ -0,0 +1,67 @@
#include "SparablePartition.h"
#define B_NOT_IMPLEMENTED B_ERROR
using namespace Udf;
/*! \brief Creates a new SparablePartition object.
*/
SparablePartition::SparablePartition(uint16 number, uint32 start, uint32 length,
uint16 packetLength, uint8 tableCount,
uint32 *tableLocations)
: fNumber(number)
, fStart(start)
, fLength(length)
, fPacketLength(packetLength)
, fTableCount(tableCount)
, fInitStatus(B_NO_INIT)
{
status_t error = (0 < TableCount() && TableCount() <= kMaxSparingTableCount)
? B_OK : B_BAD_VALUE;
if (!error) {
for (uint8 i = 0; i < TableCount(); i++)
fTableLocations[i] = tableLocations[i];
}
if (!error)
fInitStatus = B_OK;
}
/*! \brief Destroys the SparablePartition object.
*/
SparablePartition::~SparablePartition()
{
}
/*! \brief Maps the given logical block to a physical block on disc.
The sparing tables are first checked to see if the logical block has
been remapped from a defective location to a non-defective one. If
not, the given logical block is then simply treated as an offset from
the start of the physical partition.
*/
status_t
SparablePartition::MapBlock(uint32 logicalBlock, uint32 &physicalBlock)
{
status_t error = InitCheck();
if (!error) {
if (logicalBlock >= fLength)
error = B_BAD_ADDRESS;
else {
// Check for the logical block in the sparing tables. If not
// found, map directly to physical space.
//physicalBlock = fStart + logicalBlock;
//return B_OK;
error = B_NOT_IMPLEMENTED;
}
}
return error;
}
/*! Returns the initialization status of the object.
*/
status_t
SparablePartition::InitCheck()
{
return fInitStatus;
}

View File

@ -0,0 +1,62 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//
// Copyright (c) 2003 Tyler Dauwalder, tyler@dauwalder.net
//---------------------------------------------------------------------
#ifndef _UDF_SPARABLE_PARTITION_H
#define _UDF_SPARABLE_PARTITION_H
/*! \file SparablePartition.h
*/
#include <kernel_cpp.h>
#include "Partition.h"
#include "UdfDebug.h"
namespace Udf {
/*! \brief Type 2 sparable partition
Sparable partitions provide a defect-managed partition
space for media that does not implicitly provide defect management,
such as CD-RW. Arbitrary packets of blocks in the sparable partition
may be transparently remapped to other locations on disc should the
original locations become defective.
Per UDF-2.01 2.2.11, sparable partitions shall be recorded only on
disk/drive systems that do not perform defect management.
See also UDF-2.01 2.2.9, UDF-2.01 2.2.11
*/
class SparablePartition : public Partition {
public:
SparablePartition(uint16 number, uint32 start, uint32 length, uint16 packetLength,
uint8 tableCount, uint32 *tableLocations);
virtual ~SparablePartition();
virtual status_t MapBlock(uint32 logicalBlock, uint32 &physicalBlock);
status_t InitCheck();
uint16 Number() const { return fNumber; }
uint32 Start() const { return fStart; }
uint32 Length() const { return fLength; }
uint32 PacketLength() const { return fPacketLength; }
uint8 TableCount() const { return fTableCount; }
//! Maximum number of redundant sparing tables per SparablePartition
static const uint8 kMaxSparingTableCount = 4;
private:
uint16 fNumber;
uint32 fStart;
uint32 fLength;
uint32 fPacketLength;
uint8 fTableCount;
uint32 fTableLocations[kMaxSparingTableCount];
status_t fInitStatus;
};
}; // namespace Udf
#endif // _UDF_SPARABLE_PARTITION_H