// GetVNode status_t Volume::GetVNode(Node *node) { Node *dummy = NULL; status_t error = (fMounted ? GetVNode(node->GetID(), &dummy) : B_BAD_VALUE ); if (error == B_OK && dummy != node) { FATAL(("Two Nodes have the same ID: %Ld!\n", node->GetID())); PutVNode(dummy); error = B_ERROR; } return error; }
// PrepareToUnmount void VirtualVolume::PrepareToUnmount() { Volume::PrepareToUnmount(); // remove all child volumes // init a directory iterator fLock.Lock(); VirtualDirIterator iterator; iterator.SetDirectory(fRootNode, true); // iterate through the directory const char* name; Node* node; while (iterator.GetCurrentEntry(&name, &node)) { iterator.NextEntry(); Volume* volume = fVolumeManager->GetVolume(node->GetID()); fLock.Unlock(); if (volume) { RemoveChildVolume(volume); volume->SetUnmounting(true); volume->PutVolume(); } fLock.Lock(); } // uninit the directory iterator iterator.SetDirectory(NULL); // remove the our root node vnode_id rootNodeID = fRootNode->GetID(); fLock.Unlock(); if (GetVNode(rootNodeID, &node) == B_OK) { Volume::RemoveVNode(rootNodeID); PutVNode(rootNodeID); } }