No need for 'else' after return.
This commit is contained in:
@@ -1475,98 +1475,99 @@ BlockAllocator::CheckNextNode(check_control* control)
|
|||||||
// TODO: maybe have a force parameter that actually does that.
|
// TODO: maybe have a force parameter that actually does that.
|
||||||
// TODO: we also need to be able to repair broken B+trees!
|
// TODO: we also need to be able to repair broken B+trees!
|
||||||
return status;
|
return status;
|
||||||
} else {
|
}
|
||||||
// ignore "." and ".." entries
|
|
||||||
if (!strcmp(name, ".") || !strcmp(name, ".."))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// fill in the control data as soon as we have them
|
// ignore "." and ".." entries
|
||||||
strlcpy(fCheckCookie->control.name, name, B_FILE_NAME_LENGTH);
|
if (!strcmp(name, ".") || !strcmp(name, ".."))
|
||||||
fCheckCookie->control.inode = id;
|
continue;
|
||||||
fCheckCookie->control.errors = 0;
|
|
||||||
|
|
||||||
Vnode vnode(fVolume, id);
|
// fill in the control data as soon as we have them
|
||||||
Inode* inode;
|
strlcpy(fCheckCookie->control.name, name, B_FILE_NAME_LENGTH);
|
||||||
if (vnode.Get(&inode) != B_OK) {
|
fCheckCookie->control.inode = id;
|
||||||
FATAL(("Could not open inode ID %" B_PRIdINO "!\n", id));
|
fCheckCookie->control.errors = 0;
|
||||||
fCheckCookie->control.errors |= BFS_COULD_NOT_OPEN;
|
|
||||||
|
|
||||||
if ((fCheckCookie->control.flags & BFS_REMOVE_INVALID) != 0) {
|
Vnode vnode(fVolume, id);
|
||||||
status = _RemoveInvalidNode(fCheckCookie->parent,
|
Inode* inode;
|
||||||
fCheckCookie->iterator->Tree(), NULL, name);
|
if (vnode.Get(&inode) != B_OK) {
|
||||||
} else
|
FATAL(("Could not open inode ID %" B_PRIdINO "!\n", id));
|
||||||
status = B_ERROR;
|
fCheckCookie->control.errors |= BFS_COULD_NOT_OPEN;
|
||||||
|
|
||||||
fCheckCookie->control.status = status;
|
if ((fCheckCookie->control.flags & BFS_REMOVE_INVALID) != 0) {
|
||||||
return B_OK;
|
status = _RemoveInvalidNode(fCheckCookie->parent,
|
||||||
}
|
fCheckCookie->iterator->Tree(), NULL, name);
|
||||||
|
} else
|
||||||
|
status = B_ERROR;
|
||||||
|
|
||||||
// check if the inode's name is the same as in the b+tree
|
fCheckCookie->control.status = status;
|
||||||
if (inode->IsRegularNode()) {
|
return B_OK;
|
||||||
RecursiveLocker locker(inode->SmallDataLock());
|
}
|
||||||
NodeGetter node(fVolume, inode);
|
|
||||||
|
|
||||||
const char* localName = inode->Name(node.Node());
|
// check if the inode's name is the same as in the b+tree
|
||||||
if (localName == NULL || strcmp(localName, name)) {
|
if (inode->IsRegularNode()) {
|
||||||
fCheckCookie->control.errors |= BFS_NAMES_DONT_MATCH;
|
RecursiveLocker locker(inode->SmallDataLock());
|
||||||
FATAL(("Names differ: tree \"%s\", inode \"%s\"\n", name,
|
NodeGetter node(fVolume, inode);
|
||||||
localName));
|
|
||||||
|
|
||||||
if ((fCheckCookie->control.flags & BFS_FIX_NAME_MISMATCHES)
|
const char* localName = inode->Name(node.Node());
|
||||||
!= 0) {
|
if (localName == NULL || strcmp(localName, name)) {
|
||||||
// Rename the inode
|
fCheckCookie->control.errors |= BFS_NAMES_DONT_MATCH;
|
||||||
Transaction transaction(fVolume, inode->BlockNumber());
|
FATAL(("Names differ: tree \"%s\", inode \"%s\"\n", name,
|
||||||
|
localName));
|
||||||
|
|
||||||
status = inode->SetName(transaction, name);
|
if ((fCheckCookie->control.flags & BFS_FIX_NAME_MISMATCHES)
|
||||||
if (status == B_OK)
|
!= 0) {
|
||||||
status = inode->WriteBack(transaction);
|
// Rename the inode
|
||||||
if (status == B_OK)
|
Transaction transaction(fVolume, inode->BlockNumber());
|
||||||
status = transaction.Done();
|
|
||||||
if (status != B_OK) {
|
// TODO: this may potentially need new blocks!
|
||||||
fCheckCookie->control.status = status;
|
status = inode->SetName(transaction, name);
|
||||||
return B_OK;
|
if (status == B_OK)
|
||||||
}
|
status = inode->WriteBack(transaction);
|
||||||
|
if (status == B_OK)
|
||||||
|
status = transaction.Done();
|
||||||
|
if (status != B_OK) {
|
||||||
|
fCheckCookie->control.status = status;
|
||||||
|
return B_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fCheckCookie->control.mode = inode->Mode();
|
fCheckCookie->control.mode = inode->Mode();
|
||||||
|
|
||||||
// Check for the correct mode of the node (if the mode of the
|
// Check for the correct mode of the node (if the mode of the
|
||||||
// file don't fit to its parent, there is a serious problem)
|
// file don't fit to its parent, there is a serious problem)
|
||||||
if (((fCheckCookie->parent_mode & S_ATTR_DIR) != 0
|
if (((fCheckCookie->parent_mode & S_ATTR_DIR) != 0
|
||||||
&& !inode->IsAttribute())
|
&& !inode->IsAttribute())
|
||||||
|| ((fCheckCookie->parent_mode & S_INDEX_DIR) != 0
|
|| ((fCheckCookie->parent_mode & S_INDEX_DIR) != 0
|
||||||
&& !inode->IsIndex())
|
&& !inode->IsIndex())
|
||||||
|| (is_directory(fCheckCookie->parent_mode)
|
|| (is_directory(fCheckCookie->parent_mode)
|
||||||
&& !inode->IsRegularNode())) {
|
&& !inode->IsRegularNode())) {
|
||||||
FATAL(("inode at %" B_PRIdOFF " is of wrong type: %o (parent "
|
FATAL(("inode at %" B_PRIdOFF " is of wrong type: %o (parent "
|
||||||
"%o at %" B_PRIdOFF ")!\n", inode->BlockNumber(),
|
"%o at %" B_PRIdOFF ")!\n", inode->BlockNumber(),
|
||||||
inode->Mode(), fCheckCookie->parent_mode,
|
inode->Mode(), fCheckCookie->parent_mode,
|
||||||
fCheckCookie->parent->BlockNumber()));
|
fCheckCookie->parent->BlockNumber()));
|
||||||
|
|
||||||
// if we are allowed to fix errors, we should remove the file
|
// if we are allowed to fix errors, we should remove the file
|
||||||
if ((fCheckCookie->control.flags & BFS_REMOVE_WRONG_TYPES) != 0
|
if ((fCheckCookie->control.flags & BFS_REMOVE_WRONG_TYPES) != 0
|
||||||
&& (fCheckCookie->control.flags & BFS_FIX_BITMAP_ERRORS)
|
&& (fCheckCookie->control.flags & BFS_FIX_BITMAP_ERRORS)
|
||||||
!= 0) {
|
!= 0) {
|
||||||
status = _RemoveInvalidNode(fCheckCookie->parent, NULL,
|
status = _RemoveInvalidNode(fCheckCookie->parent, NULL,
|
||||||
inode, name);
|
inode, name);
|
||||||
} else
|
} else
|
||||||
status = B_ERROR;
|
status = B_ERROR;
|
||||||
|
|
||||||
fCheckCookie->control.errors |= BFS_WRONG_TYPE;
|
fCheckCookie->control.errors |= BFS_WRONG_TYPE;
|
||||||
fCheckCookie->control.status = status;
|
fCheckCookie->control.status = status;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// push the directory on the stack so that it will be scanned later
|
// push the directory on the stack so that it will be scanned later
|
||||||
if (inode->IsContainer() && !inode->IsIndex())
|
if (inode->IsContainer() && !inode->IsIndex())
|
||||||
fCheckCookie->stack.Push(inode->BlockRun());
|
fCheckCookie->stack.Push(inode->BlockRun());
|
||||||
else {
|
else {
|
||||||
// check it now
|
// check it now
|
||||||
fCheckCookie->control.status = CheckInode(inode);
|
fCheckCookie->control.status = CheckInode(inode);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// is never reached
|
// is never reached
|
||||||
|
|||||||
Reference in New Issue
Block a user