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:
parent
7707f8cec2
commit
29a73026aa
@ -1,8 +1,9 @@
|
||||
/*
|
||||
* Copyright 2001-2009, Axel Dörfler, axeld@pinc-software.de.
|
||||
* Copyright 2001-2012, Axel Dörfler, axeld@pinc-software.de.
|
||||
* This file may be used under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
//! super block, mounting, etc.
|
||||
|
||||
|
||||
@ -189,7 +190,7 @@ DeviceOpener::GetSize(off_t* _size, uint32* _blockSize)
|
||||
|
||||
|
||||
bool
|
||||
disk_super_block::IsValid()
|
||||
disk_super_block::IsValid() const
|
||||
{
|
||||
if (Magic1() != (int32)SUPER_BLOCK_MAGIC1
|
||||
|| Magic2() != (int32)SUPER_BLOCK_MAGIC2
|
||||
@ -296,12 +297,21 @@ Volume::~Volume()
|
||||
|
||||
|
||||
bool
|
||||
Volume::IsValidSuperBlock()
|
||||
Volume::IsValidSuperBlock() const
|
||||
{
|
||||
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
|
||||
Volume::Panic()
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2010, Axel Dörfler, axeld@pinc-software.de.
|
||||
* Copyright 2001-2012, Axel Dörfler, axeld@pinc-software.de.
|
||||
* This file may be used under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef VOLUME_H
|
||||
@ -40,7 +40,8 @@ public:
|
||||
|
||||
bool IsInitializing() const { return fVolume == NULL; }
|
||||
|
||||
bool IsValidSuperBlock();
|
||||
bool IsValidSuperBlock() const;
|
||||
bool IsValidInodeBlock(off_t block) const;
|
||||
bool IsReadOnly() const;
|
||||
void Panic();
|
||||
mutex& Lock();
|
||||
|
@ -99,7 +99,7 @@ struct disk_super_block {
|
||||
off_t LogEnd() const { return BFS_ENDIAN_TO_HOST_INT64(log_end); }
|
||||
|
||||
// implemented in Volume.cpp:
|
||||
bool IsValid();
|
||||
bool IsValid() const;
|
||||
void Initialize(const char *name, off_t numBlocks, uint32 blockSize);
|
||||
} _PACKED;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user