Пример #1
0
// Walk
status_t
VirtualVolume::Walk(Node* dir, const char* entryName, char** resolvedPath,
	vnode_id* vnid)
{
	if (dir != fRootNode)
		return B_BAD_VALUE;

	// get the referred to node ID
	AutoLocker<Locker> locker(fLock);
	if (strcmp(entryName, ".") == 0) {
		*vnid = dir->GetID();
	} else if (strcmp(entryName, "..") == 0) {
		if (Volume* parentVolume = GetParentVolume())
			*vnid = parentVolume->GetRootID();
		else
			*vnid = dir->GetID();
	} else {
		Node* node = fRootNode->GetChildNode(entryName);
		if (!node)
			return B_ENTRY_NOT_FOUND;
		*vnid = node->GetID();
	}
	locker.Unlock();

	// get a VFS node reference
	Node* dummyNode;
	status_t error = GetVNode(*vnid, &dummyNode);
	if (error != B_OK)
		return error;
	return B_OK;
}
Пример #2
0
// 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;
}
Пример #3
0
// 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);
	}
}
Пример #4
0
int Connection::Reconnect()
{
	Close();
	Connect(GetVNode()->GetAddress(),GetVNode()->GetPort());
	SetFlag(WRITABLE_SOCKET||READABLE_SOCKET);
}