* The inode may actually not be known when calling _RemoveInvalidNode(), this
could cause a KDL. * Added a "force" argument to Inode::Remove() which should make it remove inodes more reliably for checkfs. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31773 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1428,7 +1428,7 @@ BlockAllocator::CheckNextNode(check_control* control)
|
|||||||
control->errors |= BFS_COULD_NOT_OPEN;
|
control->errors |= BFS_COULD_NOT_OPEN;
|
||||||
|
|
||||||
if ((control->flags & BFS_REMOVE_INVALID) != 0)
|
if ((control->flags & BFS_REMOVE_INVALID) != 0)
|
||||||
status = _RemoveInvalidNode(cookie->parent, inode, name);
|
status = _RemoveInvalidNode(cookie->parent, NULL, name);
|
||||||
else
|
else
|
||||||
status = B_ERROR;
|
status = B_ERROR;
|
||||||
|
|
||||||
@@ -1500,9 +1500,10 @@ BlockAllocator::_RemoveInvalidNode(Inode* parent, Inode* inode,
|
|||||||
// the bitmap anyway
|
// the bitmap anyway
|
||||||
Transaction transaction(fVolume, parent->BlockNumber());
|
Transaction transaction(fVolume, parent->BlockNumber());
|
||||||
|
|
||||||
inode->Node().flags |= HOST_ENDIAN_TO_BFS_INT32(INODE_DONT_FREE_SPACE);
|
if (inode != NULL)
|
||||||
status_t status
|
inode->Node().flags |= HOST_ENDIAN_TO_BFS_INT32(INODE_DONT_FREE_SPACE);
|
||||||
= parent->Remove(transaction, name, NULL, inode->IsContainer());
|
|
||||||
|
status_t status = parent->Remove(transaction, name, NULL, false, true);
|
||||||
if (status == B_OK)
|
if (status == B_OK)
|
||||||
transaction.Done();
|
transaction.Done();
|
||||||
|
|
||||||
|
|||||||
@@ -2333,7 +2333,7 @@ Inode::Sync()
|
|||||||
|
|
||||||
status_t
|
status_t
|
||||||
Inode::Remove(Transaction& transaction, const char* name, ino_t* _id,
|
Inode::Remove(Transaction& transaction, const char* name, ino_t* _id,
|
||||||
bool isDirectory)
|
bool isDirectory, bool force)
|
||||||
{
|
{
|
||||||
BPlusTree* tree;
|
BPlusTree* tree;
|
||||||
if (GetTree(&tree) != B_OK)
|
if (GetTree(&tree) != B_OK)
|
||||||
@@ -2364,7 +2364,7 @@ Inode::Remove(Transaction& transaction, const char* name, ino_t* _id,
|
|||||||
// bit is set for indices in BFS, not for attribute directories) - but you
|
// bit is set for indices in BFS, not for attribute directories) - but you
|
||||||
// should really be able to do whatever you want with your indices
|
// should really be able to do whatever you want with your indices
|
||||||
// without having to remove all files first :)
|
// without having to remove all files first :)
|
||||||
if (!inode->IsIndex()) {
|
if (!inode->IsIndex() && !force) {
|
||||||
// if it's not of the correct type, don't delete it!
|
// if it's not of the correct type, don't delete it!
|
||||||
if (inode->IsContainer() != isDirectory)
|
if (inode->IsContainer() != isDirectory)
|
||||||
return isDirectory ? B_NOT_A_DIRECTORY : B_IS_A_DIRECTORY;
|
return isDirectory ? B_NOT_A_DIRECTORY : B_IS_A_DIRECTORY;
|
||||||
@@ -2379,7 +2379,7 @@ Inode::Remove(Transaction& transaction, const char* name, ino_t* _id,
|
|||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
if (tree->Remove(transaction, name, id) < B_OK) {
|
if (tree->Remove(transaction, name, id) != B_OK && !force) {
|
||||||
unremove_vnode(fVolume->FSVolume(), id);
|
unremove_vnode(fVolume->FSVolume(), id);
|
||||||
RETURN_ERROR(B_ERROR);
|
RETURN_ERROR(B_ERROR);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,7 +142,8 @@ public:
|
|||||||
|
|
||||||
// create/remove inodes
|
// create/remove inodes
|
||||||
status_t Remove(Transaction& transaction, const char* name,
|
status_t Remove(Transaction& transaction, const char* name,
|
||||||
ino_t* _id = NULL, bool isDirectory = false);
|
ino_t* _id = NULL, bool isDirectory = false,
|
||||||
|
bool force = false);
|
||||||
static status_t Create(Transaction& transaction, Inode* parent,
|
static status_t Create(Transaction& transaction, Inode* parent,
|
||||||
const char* name, int32 mode, int openMode,
|
const char* name, int32 mode, int openMode,
|
||||||
uint32 type, bool* _created = NULL,
|
uint32 type, bool* _created = NULL,
|
||||||
|
|||||||
Reference in New Issue
Block a user