Example #1
0
status_t
packagefs_read_index_dir(fs_volume* fsVolume, void* cookie,
	struct dirent* buffer, size_t bufferSize, uint32* _num)
{
	Volume* volume = (Volume*)fsVolume->private_volume;

	FUNCTION("volume: %p, cookie: %p, buffer: %p, bufferSize: %zu, num: %"
		B_PRIu32 "\n", volume, cookie, buffer, bufferSize, *_num);

	IndexDirIterator* iterator = (IndexDirIterator*)cookie;

	if (*_num == 0)
		return B_BAD_VALUE;

	IndexDirIterator previousIterator = *iterator;

	// get the next index
	Index* index = iterator->Next();
	if (index == NULL) {
		*_num = 0;
		return B_OK;
	}

	// fill in the entry
	if (!set_dirent_name(buffer, bufferSize, index->Name())) {
		*iterator = previousIterator;
		return B_BUFFER_OVERFLOW;
	}

	buffer->d_dev = volume->ID();
	buffer->d_ino = 0;

	*_num = 1;
	return B_OK;
}
Example #2
0
static status_t
packagefs_get_vnode(fs_volume* fsVolume, ino_t vnid, fs_vnode* fsNode,
	int* _type, uint32* _flags, bool reenter)
{
	Volume* volume = (Volume*)fsVolume->private_volume;

	FUNCTION("volume: %p, vnid: %" B_PRId64 "\n", volume, vnid);

	VolumeReadLocker volumeLocker(volume);
	Node* node = volume->FindNode(vnid);
	if (node == NULL)
		return B_ENTRY_NOT_FOUND;
	BReference<Node> nodeReference(node);
	volumeLocker.Unlock();

	NodeWriteLocker nodeLocker(node);
	status_t error = node->VFSInit(volume->ID());
	if (error != B_OK)
		RETURN_ERROR(error);
	nodeLocker.Unlock();

	fsNode->private_node = nodeReference.Detach();
	fsNode->ops = &gPackageFSVnodeOps;
	*_type = node->Mode() & S_IFMT;
	*_flags = 0;

	return B_OK;
}
Example #3
0
static status_t
packagefs_mount(fs_volume* fsVolume, const char* device, uint32 flags,
	const char* parameters, ino_t* _rootID)
{
	FUNCTION("fsVolume: %p, device: \"%s\", flags: %#" B_PRIx32 ", parameters: "
			"\"%s\"\n", fsVolume, device, flags, parameters);

	// create a Volume object
	Volume* volume = new(std::nothrow) Volume(fsVolume);
	if (volume == NULL)
		RETURN_ERROR(B_NO_MEMORY);
	ObjectDeleter<Volume> volumeDeleter(volume);

	// Initialize the fs_volume now already, so it is mostly usable in during
	// mounting.
	fsVolume->private_volume = volumeDeleter.Detach();
	fsVolume->ops = &gPackageFSVolumeOps;

	status_t error = volume->Mount(parameters);
	if (error != B_OK)
		return error;

	// set return values
	*_rootID = volume->RootDirectory()->ID();

	return B_OK;
}
Example #4
0
void SkeletonDrawable::adjustVolume(Volume & volume)
{
    Inherited::adjustVolume(volume);

    //Extend the volume by all the Root Joints of Skeleton
    if(getSkeleton() == NULL)
    {
        FWARNING(("SkeletonDrawable::drawPrimitives:: no skeleton!\n"));;
    }
    else
    {
        Pnt3f JointLocation(0.0,0.0,0.0);
        for(UInt32 i(0) ; i<getSkeleton()->getNumJoints() ; ++i)
        {
            JointLocation.setValues(0.0,0.0,0.0);
            if(getDrawPose())
            {
                getSkeleton()->getAbsoluteTransformation(i).mult(Pnt3f(0.0f,0.0f,0.0f),JointLocation);
                volume.extendBy(JointLocation);
            }
            if(getDrawBindPose())
            {
                getSkeleton()->getAbsoluteBindTransformation(i).mult(Pnt3f(0.0f,0.0f,0.0f),JointLocation);
                volume.extendBy(JointLocation);
            }
        }
    }

}
Example #5
0
void Geometry::adjustVolume(Volume & volume)
{
    if(!_volumeCache.isEmpty())
    {
        // use cached volume.
        volume.setValid();
        volume.extendBy(_volumeCache);

        return;
    }

    GeoVectorProperty *pos = getPositions();

    if(pos == NULL)
        return;                  // Node has no points, no volume

    _volumeCache.setValid();
    
    PrimitiveIterator it  = this->beginPrimitives();
    PrimitiveIterator end = this->endPrimitives  ();

    for(; it != end; ++it)
    {
        for(UInt32 v = 0; v < it.getLength(); ++v)
        {
            _volumeCache.extendBy(it.getPosition(v));
        }
    }

    volume.extendBy(_volumeCache);
}
Example #6
0
// reiserfs_open
static status_t
reiserfs_open(fs_volume *fs, fs_vnode *_node, int openMode, void **cookie)
{
//	FUNCTION_START();
	Volume *volume = (Volume*)fs->private_volume;
	VNode *node = (VNode*)_node->private_node;
FUNCTION(("node: (%Ld: %lu, %lu)\n", node->GetID(), node->GetDirID(),
		  node->GetObjectID()));
	status_t error = B_OK;
	// check the open mode
	if ((openMode & O_RWMASK) == O_WRONLY || (openMode & O_RWMASK) == O_RDWR
		|| (openMode & (O_TRUNC | O_CREAT))) {
		error = B_READ_ONLY_DEVICE;
	}
	// create a StreamReader
	if (error == B_OK) {
		StreamReader *reader = new(nothrow) StreamReader(volume->GetTree(),
			node->GetDirID(), node->GetObjectID());
		if (reader) {
			error = reader->Suspend();
			if (error == B_OK)
				*cookie = reader;
			else
				delete reader;
		} else
			error = B_NO_MEMORY;
	}
	RETURN_ERROR(error);
}
Example #7
0
// HandleEvent
void
ServerVolume::HandleEvent(VolumeEvent* event)
{
	if (event->GetType() == CONNECTION_BROKEN_EVENT) {
		// tell all share volumes that they have been disconnected

		// 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 (ShareVolume* shareVolume = dynamic_cast<ShareVolume*>(volume))
				shareVolume->ConnectionClosed();
			if (volume)
				volume->PutVolume();
			fLock.Lock();
		}

		// uninit the directory iterator
		iterator.SetDirectory(NULL);

		// mark ourselves unmounting
		SetUnmounting(true);
		fLock.Unlock();
	}
}
Example #8
0
static status_t
ext2_get_vnode(fs_volume* _volume, ino_t id, fs_vnode* _node, int* _type,
	uint32* _flags, bool reenter)
{
	Volume* volume = (Volume*)_volume->private_volume;

	if (id < 2 || id > volume->NumInodes()) {
		ERROR("invalid inode id %" B_PRIdINO " requested!\n", id);
		return B_BAD_VALUE;
	}

	Inode* inode = new(std::nothrow) Inode(volume, id);
	if (inode == NULL)
		return B_NO_MEMORY;

	status_t status = inode->InitCheck();
	if (status != B_OK)
		delete inode;

	if (status == B_OK) {
		_node->private_node = inode;
		_node->ops = &gExt2VnodeOps;
		*_type = inode->Mode();
		*_flags = 0;
	} else
		ERROR("get_vnode: InitCheck() failed. Error: %s\n", strerror(status));

	return status;
}
Example #9
0
////////////////////////////////////////////////////////////////////////
//	GetNeighbours - sreiter
void GetNeighbours(std::vector<Volume*>& vVolsOut, Grid& grid, Volume* v,
					int side, bool clearContainer)
{
	if(clearContainer)
		vVolsOut.clear();

//	if VOLOPT_AUTOGENERATE_FACES and FACEOPT_STORE_ASSOCIATED_VOLUMES are
//	activated, we may use them to find the connected volume quite fast.
	if(grid.option_is_enabled(VOLOPT_AUTOGENERATE_FACES
							| FACEOPT_STORE_ASSOCIATED_VOLUMES))
	{
		Face* f = grid.get_face(v, side);
		Grid::AssociatedVolumeIterator iterEnd = grid.associated_volumes_end(f);
		for(Grid::AssociatedVolumeIterator iter = grid.associated_volumes_begin(f);
			iter != iterEnd; ++iter)
		{
			if(*iter != v)
				vVolsOut.push_back(*iter);
		}

		return;
	}

//	we can't assume that associated faces exist.
//	we have to find the neighbour by hand.
//	mark all vertices of the side
	grid.begin_marking();

	FaceDescriptor fd;
	v->face_desc(side, fd);
	uint numFaceVrts = fd.num_vertices();
	for(uint i = 0; i < numFaceVrts; ++ i)
		grid.mark(fd.vertex(i));

//	iterate over associated volumes of the first vertex and count
//	the number of marked vertices it contains.
	Vertex* vrt = fd.vertex(0);
	Grid::AssociatedVolumeIterator iterEnd = grid.associated_volumes_end(vrt);
	for(Grid::AssociatedVolumeIterator iter = grid.associated_volumes_begin(vrt);
		iter != iterEnd; ++iter)
	{
		Volume* vol = *iter;
		if(vol != v){
			size_t count = 0;
			uint numVrts = vol->num_vertices();
			for(uint i = 0; i < numVrts; ++i){
				if(grid.is_marked(vol->vertex(i)))
					++count;
			}

		//	if the number of marked vertices in vol matches the
		//	number of vertices of the specified side, we consider
		//	the volume to be a neighbout of that side.
			if(count == numFaceVrts)
				vVolsOut.push_back(vol);
		}
	}

	grid.end_marking();
}
Example #10
0
static status_t
checksumfs_read_fs_info(fs_volume* fsVolume, struct fs_info* info)
{
	Volume* volume = (Volume*)fsVolume->private_volume;
	volume->GetInfo(*info);
	return B_OK;
}
Example #11
0
// NOTE: We only set the volume in DiskInfo if 'containerPath' is set.
// If volume mode is not specified, Volume::RW will be used (assuming
// 'containerPath' is set).
inline Resource::DiskInfo createDiskInfo(
    const Option<std::string>& persistenceId,
    const Option<std::string>& containerPath,
    const Option<Volume::Mode>& mode = None(),
    const Option<std::string>& hostPath = None(),
    const Option<Resource::DiskInfo::Source>& source = None())
{
  Resource::DiskInfo info;

  if (persistenceId.isSome()) {
    info.mutable_persistence()->set_id(persistenceId.get());
  }

  if (containerPath.isSome()) {
    Volume volume;
    volume.set_container_path(containerPath.get());
    volume.set_mode(mode.isSome() ? mode.get() : Volume::RW);

    if (hostPath.isSome()) {
      volume.set_host_path(hostPath.get());
    }

    info.mutable_volume()->CopyFrom(volume);
  }

  if (source.isSome()) {
    info.mutable_source()->CopyFrom(source.get());
  }

  return info;
}
Example #12
0
//! set the bounding volume of the node
void DVRVolume::adjustVolume(Volume &volume)
{
    volume.setValid();
    volume.setEmpty();
    
    DVRVolumeTexturePtr tex = DVRVOLUME_PARAMETER(this, DVRVolumeTexture);

    if (tex != NullFC) 
    {
        const Vec3f & res   = tex->getResolution    ();
        const Vec3f & slice = tex->getSliceThickness();
    
        Vec3f minBB(-0.5f * res[0] * slice[0],
                    -0.5f * res[1] * slice[1],
                    -0.5f * res[2] * slice[2]);

        Vec3f maxBB(-minBB);
    
        volume.extendBy(minBB);
        volume.extendBy(maxBB);
    }    
    else 
    {
        // something wrong with initialization - show boundingbox either
        Vec3f minBB(-0.5, -0.5, -0.5);
        Vec3f maxBB( 0.5,  0.5,  0.5);
        
        volume.extendBy(minBB);
        volume.extendBy(maxBB);
    }
}
Example #13
0
static status_t
ext2_io(fs_volume* _volume, fs_vnode* _node, void* _cookie, io_request* request)
{
	Volume* volume = (Volume*)_volume->private_volume;
	Inode* inode = (Inode*)_node->private_node;

#ifndef EXT2_SHELL
	if (io_request_is_write(request) && volume->IsReadOnly()) {
		notify_io_request(request, B_READ_ONLY_DEVICE);
		return B_READ_ONLY_DEVICE;
	}
#endif

	if (inode->FileCache() == NULL) {
#ifndef EXT2_SHELL
		notify_io_request(request, B_BAD_VALUE);
#endif
		return B_BAD_VALUE;
	}

	// We lock the node here and will unlock it in the "finished" hook.
	rw_lock_read_lock(inode->Lock());

	return do_iterative_fd_io(volume->Device(), request,
		iterative_io_get_vecs_hook, iterative_io_finished_hook, inode);
}
Example #14
0
bool ExportSystemData(const Volume& volume, const Partition& partition,
                      const std::string& export_folder)
{
  bool success = true;

  File::CreateFullPath(export_folder + "/sys/");
  success &= ExportHeader(volume, partition, export_folder + "/sys/boot.bin");
  success &= ExportBI2Data(volume, partition, export_folder + "/sys/bi2.bin");
  success &= ExportApploader(volume, partition, export_folder + "/sys/apploader.img");
  success &= ExportDOL(volume, partition, export_folder + "/sys/main.dol");
  success &= ExportFST(volume, partition, export_folder + "/sys/fst.bin");

  if (volume.GetVolumeType() == Platform::WiiDisc)
  {
    File::CreateFullPath(export_folder + "/disc/");
    success &= ExportWiiUnencryptedHeader(volume, export_folder + "/disc/header.bin");
    success &= ExportWiiRegionData(volume, export_folder + "/disc/region.bin");

    success &= ExportTicket(volume, partition, export_folder + "/ticket.bin");
    success &= ExportTMD(volume, partition, export_folder + "/tmd.bin");
    success &= ExportCertificateChain(volume, partition, export_folder + "/cert.bin");
    if (volume.IsEncryptedAndHashed())
      success &= ExportH3Hashes(volume, partition, export_folder + "/h3.bin");
  }

  return success;
}
Example #15
0
Model loadModelSTL_binary(const char* filename)
{
    Model m;
    FILE* f = fopen(filename, "rb");

    if (f == NULL) {
        ostringstream oss;
        oss << "Can't open file " << filename << " for reading";
        throw oss.str();
    }

    char buffer[80];
    uint32_t faceCount;
    //Skip the header
    if (fread(buffer, 80, 1, f) != 1)
    {
        fclose(f);
        return m;
    }
    //Read the face count
    if (fread(&faceCount, sizeof(uint32_t), 1, f) != 1)
    {
        fclose(f);
        return m;
    }
    //For each face read:
    //float(x,y,z) = normal, float(X,Y,Z)*3 = vertexes, uint16_t = flags
    m.volumes.push_back(Volume());
    Volume* vol = &m.volumes[0];
    if(vol == NULL)
    {
        fclose(f);
        return m;
    }
    for(unsigned int i=0;i<faceCount;i++)
    {
        if (fread(buffer, sizeof(float) * 3, 1, f) != 1)
        {
            fclose(f);
            return m;
        }
        float v[9];
        if (fread(v, sizeof(float) * 9, 1, f) != 1)
        {
            fclose(f);
            return m;
        }
        Point3 v0 = Point3(v[0]*1000, v[1]*1000, v[2]*1000);
        Point3 v1 = Point3(v[3]*1000, v[4]*1000, v[5]*1000);
        Point3 v2 = Point3(v[6]*1000, v[7]*1000, v[8]*1000);
        vol->addFace(Face(v0, v1, v2));
        if (fread(buffer, sizeof(uint16_t), 1, f) != 1)
        {
            fclose(f);
            return m;
        }
    } 
    fclose(f);
    return m;
}
Example #16
0
static status_t
ext2_get_file_map(fs_volume* _volume, fs_vnode* _node, off_t offset,
	size_t size, struct file_io_vec* vecs, size_t* _count)
{
	TRACE("ext2_get_file_map()\n");
	Volume* volume = (Volume*)_volume->private_volume;
	Inode* inode = (Inode*)_node->private_node;
	size_t index = 0, max = *_count;

	while (true) {
		fsblock_t block;
		uint32 count = 1;
		status_t status = inode->FindBlock(offset, block, &count);
		if (status != B_OK)
			return status;

		if (block > volume->NumBlocks()) {
			panic("ext2_get_file_map() found block %" B_PRIu64 " for offset %"
				B_PRIdOFF "\n", block, offset);
		}

		off_t blockOffset = block << volume->BlockShift();
		uint32 blockLength = volume->BlockSize() * count;

		if (index > 0 && (vecs[index - 1].offset
				== blockOffset - vecs[index - 1].length
				|| (vecs[index - 1].offset == -1 && block == 0))) {
			vecs[index - 1].length += blockLength;
		} else {
			if (index >= max) {
				// we're out of file_io_vecs; let's bail out
				*_count = index;
				return B_BUFFER_OVERFLOW;
			}

			// 'block' is 0 for sparse blocks
			if (block != 0)
				vecs[index].offset = blockOffset;
			else
				vecs[index].offset = -1;

			vecs[index].length = blockLength;
			index++;
		}

		offset += blockLength;

		if (offset >= inode->Size() || size <= blockLength) {
			// We're done!
			*_count = index;
			TRACE("ext2_get_file_map for inode %" B_PRIdINO "\n", inode->ID());
			return B_OK;
		}

		size -= blockLength;
	}

	// can never get here
	return B_ERROR;
}
Example #17
0
static status_t
ext2_read_attr_dir(fs_volume* _volume, fs_vnode* _node,
				void* _cookie, struct dirent* dirent, size_t bufferSize,
				uint32* _num)
{
	Inode* inode = (Inode*)_node->private_node;
	int32 index = *(int32 *)_cookie;
	Attribute attribute(inode);
	TRACE("%s()\n", __FUNCTION__);

	size_t length = bufferSize;
	status_t status = attribute.Find(index);
	if (status == B_ENTRY_NOT_FOUND) {
		*_num = 0;
		return B_OK;
	} else if (status != B_OK)
		return status;

	status = attribute.GetName(dirent->d_name, &length);
	if (status != B_OK)
		return B_OK;

	Volume* volume = (Volume*)_volume->private_volume;

	dirent->d_dev = volume->ID();
	dirent->d_ino = inode->ID();
	dirent->d_reclen = sizeof(struct dirent) + length;

	*_num = 1;
	*(int32*)_cookie = index + 1;
	return B_OK;
}
Example #18
0
// reiserfs_mount
static status_t
reiserfs_mount(fs_volume *_volume, const char *device, uint32 flags,
	const char *parameters, ino_t *rootID)
{
	TOUCH(flags); TOUCH(parameters);
	FUNCTION_START();
	// parameters are ignored for now
	status_t error = B_OK;

	// allocate and init the volume
	Volume *volume = new(nothrow) Volume;
	if (!volume)
		error = B_NO_MEMORY;
	if (error == B_OK)
		error = volume->Mount(_volume, device);

	// set the results
	if (error == B_OK) {
		*rootID = volume->GetRootVNode()->GetID();
		_volume->private_volume = volume;
		_volume->ops = &gReiserFSVolumeOps;
	}

	// cleanup on failure
	if (error != B_OK && volume)
		delete volume;
	RETURN_ERROR(error);
}
Example #19
0
static status_t
ext2_mount(fs_volume* _volume, const char* device, uint32 flags,
	const char* args, ino_t* _rootID)
{
	Volume* volume = new(std::nothrow) Volume(_volume);
	if (volume == NULL)
		return B_NO_MEMORY;

	// TODO: this is a bit hacky: we can't use publish_vnode() to publish
	// the root node, or else its file cache cannot be created (we could
	// create it later, though). Therefore we're using get_vnode() in Mount(),
	// but that requires us to export our volume data before calling it.
	_volume->private_volume = volume;
	_volume->ops = &gExt2VolumeOps;

	status_t status = volume->Mount(device, flags);
	if (status != B_OK) {
		ERROR("Failed mounting the volume. Error: %s\n", strerror(status));
		delete volume;
		return status;
	}

	*_rootID = volume->RootNode()->ID();
	return B_OK;
}
Example #20
0
//------------------------------------------------------------------------------
// serialize() -- print the value of this object to the output stream sout.
//------------------------------------------------------------------------------
std::ostream& FlowRate::serialize(std::ostream& sout, const int i, const bool slotsOnly) const
{    
    using namespace std;
    int j = 0;
    if (!slotsOnly) {
        sout << "( " << getFormName() << endl;
        // tab here
        j = 4;
    }
    
    indent(sout, i+j);
    sout << "value: " << flowRate << endl;
    
    if (myVolume != 0) {
        indent(sout, i+j);
        sout << "volume: ";
        Volume* mv = (Volume*) myVolume;
        mv->serialize(sout, i+j);
    }
    if (myTime != 0) {
        indent(sout, i+j);
        sout << "time: ";
        Time* mt = (Time*) myTime;
        mt->serialize(sout, i+j);
    }
    
    sout << ")" << endl;
        
    return sout;
}
Example #21
0
static status_t
checksumfs_unmount(fs_volume* fsVolume)
{
	Volume* volume = (Volume*)fsVolume->private_volume;
	volume->Unmount();
	return B_OK;
}
Example #22
0
static status_t
ext2_lookup(fs_volume* _volume, fs_vnode* _directory, const char* name,
	ino_t* _vnodeID)
{
	TRACE("ext2_lookup: name address: %p\n", name);
	TRACE("ext2_lookup: name: %s\n", name);
	Volume* volume = (Volume*)_volume->private_volume;
	Inode* directory = (Inode*)_directory->private_node;

	// check access permissions
	status_t status = directory->CheckPermissions(X_OK);
	if (status < B_OK)
		return status;

	HTree htree(volume, directory);
	DirectoryIterator* iterator;

	status = htree.Lookup(name, &iterator);
	if (status != B_OK)
		return status;

	ObjectDeleter<DirectoryIterator> iteratorDeleter(iterator);

	status = iterator->FindEntry(name, _vnodeID);
	if (status != B_OK)
		return status;

	return get_vnode(volume->FSVolume(), *_vnodeID, NULL);
}
Example #23
0
static status_t
ext2_open(fs_volume* _volume, fs_vnode* _node, int openMode, void** _cookie)
{
	Volume* volume = (Volume*)_volume->private_volume;
	Inode* inode = (Inode*)_node->private_node;

	// opening a directory read-only is allowed, although you can't read
	// any data from it.
	if (inode->IsDirectory() && (openMode & O_RWMASK) != 0)
		return B_IS_A_DIRECTORY;

	status_t status =  inode->CheckPermissions(open_mode_to_access(openMode)
		| (openMode & O_TRUNC ? W_OK : 0));
	if (status != B_OK)
		return status;

	// Prepare the cookie
	file_cookie* cookie = new(std::nothrow) file_cookie;
	if (cookie == NULL)
		return B_NO_MEMORY;
	ObjectDeleter<file_cookie> cookieDeleter(cookie);

	cookie->open_mode = openMode & EXT2_OPEN_MODE_USER_MASK;
	cookie->last_size = inode->Size();
	cookie->last_notification = system_time();

	MethodDeleter<Inode, status_t> fileCacheEnabler(&Inode::EnableFileCache);
	if ((openMode & O_NOCACHE) != 0) {
		status = inode->DisableFileCache();
		if (status != B_OK)
			return status;
		fileCacheEnabler.SetTo(inode);
	}

	// Should we truncate the file?
	if ((openMode & O_TRUNC) != 0) {
		if ((openMode & O_RWMASK) == O_RDONLY)
			return B_NOT_ALLOWED;

		Transaction transaction(volume->GetJournal());
		inode->WriteLockInTransaction(transaction);

		status_t status = inode->Resize(transaction, 0);
		if (status == B_OK)
			status = inode->WriteBack(transaction);
		if (status == B_OK)
			status = transaction.Done();
		if (status != B_OK)
			return status;

		// TODO: No need to notify file size changed?
	}

	fileCacheEnabler.Detach();
	cookieDeleter.Detach();
	*_cookie = cookie;

	return B_OK;
}
Example #24
0
std::optional<u64> GetFSTSize(const Volume& volume, const Partition& partition)
{
  const Platform volume_type = volume.GetVolumeType();
  if (!IsDisc(volume_type))
    return {};

  return volume.ReadSwappedAndShifted(0x428, partition);
}
Example #25
0
 void ISPCDevice::sampleVolume(float **results,
                               OSPVolume _volume,
                               const vec3f *worldCoordinates,
                               const size_t &count)
 {
   Volume *volume = (Volume *)_volume;
   volume->computeSamples(results, worldCoordinates, count);
 }
// PutVolume
//
// The VolumeManager must not be locked, when this method is invoked.
void
VolumeManager::PutVolume(Volume* volume)
{
	if (!volume)
		return;

	// If the volume is marked unmounting and is not yet marked removed, we
	// initiate the removal process.
	{
		AutoLocker<Locker> locker(this);
//PRINT(("VolumeManager::PutVolume(%p): reference count before: %ld\n",
//volume, volume->CountReferences()));
		if (volume->IsUnmounting() && !volume->IsRemoved()) {
//PRINT(("VolumeManager::PutVolume(%p): Volume connection broken, marking "
//"removed and removing all nodes.\n", volume));
			// mark removed
			volume->MarkRemoved();

			// get parent volume
			Volume* parentVolume = volume->GetParentVolume();
			if (parentVolume && !GetVolume(parentVolume))
				parentVolume = NULL;

			locker.Unlock();

			// prepare to unmount
			volume->PrepareToUnmount();

			// remove from parent volume
			if (parentVolume) {
				parentVolume->RemoveChildVolume(volume);
				PutVolume(parentVolume);
			}
		}
	}

	// If the volume is marked removed and it's reference count drops to 0,
	// we unmount and delete it.
	{
		AutoLocker<Locker> locker(this);
		if (volume->ReleaseReference() && volume->IsRemoved()) {
PRINT(("VolumeManager::PutVolume(%p): Removed volume unreferenced. "
"Unmounting...\n", volume));
			// remove from volume set -- now noone can get a reference to it
			// anymore
			fVolumes->Remove(volume);

			locker.Unlock();

			// unmount and delete the volume
// TODO: At some point all the volume's node IDs have to be removed from
// fNodeIDs2Volumes. For the time being we expect the volume to do that itself
// in Unmount().
			volume->Unmount();
			delete volume;
		}
	}
}
Example #27
0
static status_t
ext2_unlink(fs_volume* _volume, fs_vnode* _directory, const char* name)
{
	TRACE("ext2_unlink()\n");
	if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0)
		return B_NOT_ALLOWED;

	Volume* volume = (Volume*)_volume->private_volume;
	Inode* directory = (Inode*)_directory->private_node;

	status_t status = directory->CheckPermissions(W_OK);
	if (status != B_OK)
		return status;

	TRACE("ext2_unlink(): Starting transaction\n");
	Transaction transaction(volume->GetJournal());

	directory->WriteLockInTransaction(transaction);

	TRACE("ext2_unlink(): Looking up for directory entry\n");
	HTree htree(volume, directory);
	DirectoryIterator* directoryIterator;

	status = htree.Lookup(name, &directoryIterator);
	if (status != B_OK)
		return status;

	ino_t id;
	status = directoryIterator->FindEntry(name, &id);
	if (status != B_OK)
		return status;

	Vnode vnode(volume, id);
	Inode* inode;
	status = vnode.Get(&inode);
	if (status != B_OK)
		return status;

	inode->WriteLockInTransaction(transaction);

	status = inode->Unlink(transaction);
	if (status != B_OK)
		return status;

	status = directoryIterator->RemoveEntry(transaction);
	if (status != B_OK)
		return status;

	entry_cache_remove(volume->ID(), directory->ID(), name);

	status = transaction.Done();
	if (status != B_OK)
		entry_cache_add(volume->ID(), directory->ID(), name, id);
	else
		notify_entry_removed(volume->ID(), directory->ID(), name, id);

	return status;
}
Example #28
0
// OpenQuery
status_t
VirtualVolume::OpenQuery(const char* queryString, uint32 flags, port_id port,
	int32 token, QueryIterator** _iterator)
{
	QueryManager* queryManager = fVolumeManager->GetQueryManager();

	// allocate a hierarchical iterator
	HierarchicalQueryIterator* iterator
		= new(std::nothrow) HierarchicalQueryIterator(this);
	if (!iterator)
		return B_NO_MEMORY;

	// add it to the query manager
	status_t error = queryManager->AddIterator(iterator);
	if (error != B_OK) {
		delete iterator;
		return error;
	}
	QueryIteratorPutter iteratorPutter(queryManager, iterator);

	// iterate through the child volumes and open subqueries for them
	// init a directory iterator
	fLock.Lock();
	VirtualDirIterator dirIterator;
	dirIterator.SetDirectory(fRootNode, true);

	// iterate through the directory
	const char* name;
	Node* node;
	while (dirIterator.GetCurrentEntry(&name, &node)) {
		dirIterator.NextEntry();
		Volume* volume = fVolumeManager->GetVolume(node->GetID());
		fLock.Unlock();

		// open the subquery
		QueryIterator* subIterator;
		if (volume->OpenQuery(queryString, flags, port, token,
			&subIterator) == B_OK) {
			// add the subiterator
			if (queryManager->AddSubIterator(iterator, subIterator) != B_OK)
				queryManager->PutIterator(subIterator);
		}
		volume->PutVolume();

		fLock.Lock();
	}

	// uninit the directory iterator
	dirIterator.SetDirectory(NULL);
	fLock.Unlock();

	// return the result
	*_iterator = iterator;
	iteratorPutter.Detach();

	return B_OK;
}
Example #29
0
voreen::VolumeCollection* VolumeCollection::selectOrigin(const VolumeURL& origin) const {
    VolumeCollection* collection = new VolumeCollection();
    for (size_t i=0; i<volumeHandles_.size(); ++i) {
        Volume* vh = dynamic_cast<Volume*>(volumeHandles_[i]);
        if (vh && vh->getOrigin() == origin)
            collection->add(volumeHandles_[i]);
    }
    return collection;
}
void
khResourceManager::CleanVolumeReservation(const std::string &volume,
                                          const std::string &path)
{
  Volume *vol = GetVolume(volume);
  if (vol) {
    vol->CleanReservation(path);
  }
}