bfs: CheckVisitor only deletes nodes on specific errors
* This should prevent erroneously deleting any files in low memory situations. Change-Id: I21b1d042e5f7e03a5abfaaa567b6c679b95e3188 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2914 Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
93845aec95
commit
2d4d531731
@@ -336,7 +336,8 @@ status_t
|
||||
CheckVisitor::OpenInodeFailed(status_t reason, ino_t id, Inode* parent,
|
||||
char* treeName, TreeIterator* iterator)
|
||||
{
|
||||
FATAL(("Could not open inode at %" B_PRIdOFF "\n", id));
|
||||
FATAL(("Could not open inode at %" B_PRIdOFF ": %s\n", id,
|
||||
strerror(reason)));
|
||||
|
||||
if (treeName != NULL)
|
||||
strlcpy(Control().name, treeName, B_FILE_NAME_LENGTH);
|
||||
@@ -346,13 +347,19 @@ CheckVisitor::OpenInodeFailed(status_t reason, ino_t id, Inode* parent,
|
||||
Control().inode = id;
|
||||
Control().errors = BFS_COULD_NOT_OPEN;
|
||||
|
||||
// remove inode from the tree if we can
|
||||
if (parent != NULL && iterator != NULL
|
||||
&& (Control().flags & BFS_REMOVE_INVALID) != 0) {
|
||||
Control().status = _RemoveInvalidNode(parent, iterator->Tree(), NULL,
|
||||
treeName);
|
||||
} else
|
||||
Control().status = B_ERROR;
|
||||
// TODO: check other error codes; B_IO_ERROR might be a temporary
|
||||
// issue, so it should be guarded by a force mode
|
||||
if (reason == B_BAD_VALUE || reason == B_BAD_DATA || reason == B_IO_ERROR) {
|
||||
// Remove inode from the tree if we can
|
||||
if (parent != NULL && iterator != NULL
|
||||
&& (Control().flags & BFS_REMOVE_INVALID) != 0) {
|
||||
Control().status = _RemoveInvalidNode(parent, iterator->Tree(),
|
||||
NULL, treeName);
|
||||
} else
|
||||
Control().status = B_ERROR;
|
||||
} else {
|
||||
Control().status = B_OK;
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user