2 * Copyright 2012, Jérôme Duval, korli@users.berlios.de.
3 * Copyright 2003 Tyler Dauwalder, tyler@dauwalder.net
4 * This file may be used under the terms of the MIT License.
8 #include "MetadataPartition.h"
13 /*! \brief Creates a new MetadataPartition object.
15 MetadataPartition::MetadataPartition(Volume
*volume
,
16 uint16 parentNumber
, Partition
&parentPartition
, uint32 metadataFileLocation
,
17 uint32 metadataMirrorFileLocation
, uint32 metadataBitmapFileLocation
,
18 uint32 allocationUnitSize
, uint16 alignmentUnitSize
,
19 bool metadataIsDuplicated
)
20 : fPartition(parentNumber
),
21 fParentPartition(parentPartition
),
22 fAllocationUnitSize(allocationUnitSize
),
23 fAlignmentUnitSize(alignmentUnitSize
),
24 fMetadataIsDuplicated(metadataIsDuplicated
),
25 fInitStatus(B_NO_INIT
),
29 address
.set_to(metadataFileLocation
, fPartition
);
31 fMetadataIcb
= new(nothrow
) Icb(volume
, address
);
32 if (fMetadataIcb
== NULL
|| fMetadataIcb
->InitCheck() != B_OK
)
33 fInitStatus
= B_NO_MEMORY
;
37 address
.set_to(metadataMirrorFileLocation
, fPartition
);
39 fMetadataMirrorIcb
= new(nothrow
) Icb(volume
, address
);
40 if (fMetadataMirrorIcb
== NULL
41 || fMetadataMirrorIcb
->InitCheck() != B_OK
) {
42 fInitStatus
= B_NO_MEMORY
;
46 /*! \brief Destroys the MetadataPartition object.
48 MetadataPartition::~MetadataPartition()
51 delete fMetadataMirrorIcb
;
54 /*! \brief Maps the given logical block to a physical block on disc.
57 MetadataPartition::MapBlock(uint32 logicalBlock
, off_t
&physicalBlock
)
61 status_t status
= fMetadataIcb
->FindBlock(logicalBlock
, block
, isRecorded
);
65 status
= fMetadataMirrorIcb
->FindBlock(logicalBlock
, block
, isRecorded
);
71 return fParentPartition
.MapBlock(block
, physicalBlock
);
74 /*! Returns the initialization status of the object.
77 MetadataPartition::InitCheck()