Added Volume::IsValidInodeBlock().
* The method checks whether a block may be occupied by an inode, ie. is neither part of the bitmap nor of the log, and would also fit on the disk. * Also made disk_super_block::IsValid() const.
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2009, Axel Dörfler, [email protected].
|
* Copyright 2001-2012, Axel Dörfler, [email protected].
|
||||||
* This file may be used under the terms of the MIT License.
|
* This file may be used under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
//! super block, mounting, etc.
|
//! super block, mounting, etc.
|
||||||
|
|
||||||
|
|
||||||
@@ -189,7 +190,7 @@ DeviceOpener::GetSize(off_t* _size, uint32* _blockSize)
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
disk_super_block::IsValid()
|
disk_super_block::IsValid() const
|
||||||
{
|
{
|
||||||
if (Magic1() != (int32)SUPER_BLOCK_MAGIC1
|
if (Magic1() != (int32)SUPER_BLOCK_MAGIC1
|
||||||
|| Magic2() != (int32)SUPER_BLOCK_MAGIC2
|
|| Magic2() != (int32)SUPER_BLOCK_MAGIC2
|
||||||
@@ -296,12 +297,21 @@ Volume::~Volume()
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Volume::IsValidSuperBlock()
|
Volume::IsValidSuperBlock() const
|
||||||
{
|
{
|
||||||
return fSuperBlock.IsValid();
|
return fSuperBlock.IsValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! Checks whether the given block number may be the location of an inode block.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
Volume::IsValidInodeBlock(off_t block) const
|
||||||
|
{
|
||||||
|
return block > fSuperBlock.LogEnd() && block < NumBlocks();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Volume::Panic()
|
Volume::Panic()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2010, Axel Dörfler, [email protected].
|
* Copyright 2001-2012, Axel Dörfler, [email protected].
|
||||||
* This file may be used under the terms of the MIT License.
|
* This file may be used under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef VOLUME_H
|
#ifndef VOLUME_H
|
||||||
@@ -40,7 +40,8 @@ public:
|
|||||||
|
|
||||||
bool IsInitializing() const { return fVolume == NULL; }
|
bool IsInitializing() const { return fVolume == NULL; }
|
||||||
|
|
||||||
bool IsValidSuperBlock();
|
bool IsValidSuperBlock() const;
|
||||||
|
bool IsValidInodeBlock(off_t block) const;
|
||||||
bool IsReadOnly() const;
|
bool IsReadOnly() const;
|
||||||
void Panic();
|
void Panic();
|
||||||
mutex& Lock();
|
mutex& Lock();
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ struct disk_super_block {
|
|||||||
off_t LogEnd() const { return BFS_ENDIAN_TO_HOST_INT64(log_end); }
|
off_t LogEnd() const { return BFS_ENDIAN_TO_HOST_INT64(log_end); }
|
||||||
|
|
||||||
// implemented in Volume.cpp:
|
// implemented in Volume.cpp:
|
||||||
bool IsValid();
|
bool IsValid() const;
|
||||||
void Initialize(const char *name, off_t numBlocks, uint32 blockSize);
|
void Initialize(const char *name, off_t numBlocks, uint32 blockSize);
|
||||||
} _PACKED;
|
} _PACKED;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user