Exemplo n.º 1
0
static status_t
checksumfs_lookup(fs_volume* fsVolume, fs_vnode* fsDir, const char* name,
	ino_t* _id)
{
	Volume* volume = (Volume*)fsVolume->private_volume;
	Node* node = (Node*)fsDir->private_node;

	Directory* directory = dynamic_cast<Directory*>(node);
	if (directory == NULL)
		return B_NOT_A_DIRECTORY;

	uint64 blockIndex;

	if (strcmp(name, ".") == 0) {
		blockIndex = directory->BlockIndex();
	} else if (strcmp(name, "..") == 0) {
		blockIndex = directory->ParentDirectory();
	} else {
		// TODO: Implement!
		return B_ENTRY_NOT_FOUND;
	}

	// get the node
	Node* childNode;
	status_t error = volume->GetNode(blockIndex, childNode);
	if (error != B_OK)
		return error;

	*_id = blockIndex;
	return B_OK;
}
Exemplo n.º 2
0
	status_t ReadNextEntry(struct dirent* buffer, size_t size,
		uint32& _countRead)
	{
		const char* name;
		uint64 blockIndex;

		int nextIterationState = OTHERS;
		switch (iterationState) {
			case DOT:
				name = ".";
				blockIndex = directory->BlockIndex();
				nextIterationState = DOT_DOT;
				break;
			case DOT_DOT:
				name = "..";
				blockIndex = directory->ParentDirectory();
				break;
			default:
				// TODO: Implement!
				_countRead = 0;
				return B_OK;
		}

		size_t entrySize = sizeof(dirent) + strlen(name);
		if (entrySize > size)
			return B_BUFFER_OVERFLOW;

		buffer->d_dev = directory->GetVolume()->ID();
		buffer->d_ino = blockIndex;
		buffer->d_reclen = entrySize;
		strcpy(buffer->d_name, name);

		iterationState = nextIterationState;

		_countRead = 1;
		return B_OK;
	}