* checkfs should now also remove unaccessible files. Not yet tested.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31771 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2009-07-26 13:45:12 +00:00
parent 71e439ea3e
commit 84ce48c248
2 changed files with 33 additions and 17 deletions

View File

@ -1347,7 +1347,7 @@ BlockAllocator::CheckNextNode(check_control* control)
Vnode vnode(fVolume, cookie->current);
Inode* inode;
if (vnode.Get(&inode) < B_OK) {
if (vnode.Get(&inode) != B_OK) {
FATAL(("check: Could not open inode at %Ld\n",
fVolume->ToBlock(cookie->current)));
continue;
@ -1423,9 +1423,15 @@ BlockAllocator::CheckNextNode(check_control* control)
Vnode vnode(fVolume, id);
Inode* inode;
if (vnode.Get(&inode) < B_OK) {
if (vnode.Get(&inode) != B_OK) {
FATAL(("Could not open inode ID %Ld!\n", id));
control->errors |= BFS_COULD_NOT_OPEN;
if ((control->flags & BFS_REMOVE_INVALID) != 0)
status = _RemoveInvalidNode(cookie->parent, inode, name);
else
status = B_ERROR;
control->status = B_ERROR;
return B_OK;
}
@ -1459,21 +1465,9 @@ BlockAllocator::CheckNextNode(check_control* control)
// if we are allowed to fix errors, we should remove the file
if ((control->flags & BFS_REMOVE_WRONG_TYPES) != 0
&& (control->flags & BFS_FIX_BITMAP_ERRORS) != 0) {
// it's safe to start a transaction, because Inode::Remove()
// won't touch the block bitmap (which we hold the lock for)
// if we set the INODE_DONT_FREE_SPACE flag - since we fix
// the bitmap anyway
Transaction transaction(fVolume,
cookie->parent->BlockNumber());
inode->Node().flags
|= HOST_ENDIAN_TO_BFS_INT32(INODE_DONT_FREE_SPACE);
status = cookie->parent->Remove(transaction, name, NULL,
inode->IsContainer());
if (status == B_OK)
transaction.Done();
} else
&& (control->flags & BFS_FIX_BITMAP_ERRORS) != 0)
status = _RemoveInvalidNode(cookie->parent, inode, name);
else
status = B_ERROR;
control->errors |= BFS_WRONG_TYPE;
@ -1496,6 +1490,26 @@ BlockAllocator::CheckNextNode(check_control* control)
}
status_t
BlockAllocator::_RemoveInvalidNode(Inode* parent, Inode* inode,
const char* name)
{
// it's safe to start a transaction, because Inode::Remove()
// won't touch the block bitmap (which we hold the lock for)
// if we set the INODE_DONT_FREE_SPACE flag - since we fix
// the bitmap anyway
Transaction transaction(fVolume, parent->BlockNumber());
inode->Node().flags |= HOST_ENDIAN_TO_BFS_INT32(INODE_DONT_FREE_SPACE);
status_t status
= parent->Remove(transaction, name, NULL, inode->IsContainer());
if (status == B_OK)
transaction.Done();
return status;
}
bool
BlockAllocator::_CheckBitmapIsUsedAt(off_t block) const
{

View File

@ -64,6 +64,8 @@ public:
#endif
private:
status_t _RemoveInvalidNode(Inode* parent, Inode* inode,
const char* name);
#ifdef DEBUG_ALLOCATION_GROUPS
void _CheckGroup(int32 group) const;
#endif