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,
|
CheckVisitor::OpenInodeFailed(status_t reason, ino_t id, Inode* parent,
|
||||||
char* treeName, TreeIterator* iterator)
|
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)
|
if (treeName != NULL)
|
||||||
strlcpy(Control().name, treeName, B_FILE_NAME_LENGTH);
|
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().inode = id;
|
||||||
Control().errors = BFS_COULD_NOT_OPEN;
|
Control().errors = BFS_COULD_NOT_OPEN;
|
||||||
|
|
||||||
// remove inode from the tree if we can
|
// TODO: check other error codes; B_IO_ERROR might be a temporary
|
||||||
if (parent != NULL && iterator != NULL
|
// issue, so it should be guarded by a force mode
|
||||||
&& (Control().flags & BFS_REMOVE_INVALID) != 0) {
|
if (reason == B_BAD_VALUE || reason == B_BAD_DATA || reason == B_IO_ERROR) {
|
||||||
Control().status = _RemoveInvalidNode(parent, iterator->Tree(), NULL,
|
// Remove inode from the tree if we can
|
||||||
treeName);
|
if (parent != NULL && iterator != NULL
|
||||||
} else
|
&& (Control().flags & BFS_REMOVE_INVALID) != 0) {
|
||||||
Control().status = B_ERROR;
|
Control().status = _RemoveInvalidNode(parent, iterator->Tree(),
|
||||||
|
NULL, treeName);
|
||||||
|
} else
|
||||||
|
Control().status = B_ERROR;
|
||||||
|
} else {
|
||||||
|
Control().status = B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user