Exemple #1
0
static status_t
nfs4_remove_dir(fs_volume* volume, fs_vnode* parent, const char* name)
{
	VnodeToInode* vti = reinterpret_cast<VnodeToInode*>(parent->private_node);
	TRACE("volume = %p, parent = %" B_PRIi64 ", name = %s", volume, vti->ID(),
		name);

	VnodeToInodeLocker _(vti);
	Inode* inode = vti->Get();
	if (inode == NULL)
		return B_ENTRY_NOT_FOUND;

	ino_t id;
	status_t result = inode->Remove(name, NF4DIR, &id);
	if (result != B_OK)
		return result;

	result = acquire_vnode(volume, id);
	if (result == B_OK) {
		result = get_vnode(volume, id, reinterpret_cast<void**>(&vti));
		ASSERT(result == B_OK);

		if (vti->Unlink(inode->fInfo.fNames, name))
			remove_vnode(volume, id);

		put_vnode(volume, id);
		put_vnode(volume, id);
	}

	return B_OK;
}
Exemple #2
0
static status_t
get_new_vnode(fs_volume* volume, ino_t id, VnodeToInode** _vti)
{
	FileSystem* fs = reinterpret_cast<FileSystem*>(volume->private_volume);
	Inode* inode;
	VnodeToInode* vti;

	status_t result = acquire_vnode(volume, id);
	if (result == B_OK) {
		ASSERT(get_vnode(volume, id, reinterpret_cast<void**>(_vti)) == B_OK);
		unremove_vnode(volume, id);

		// Release after acquire
		put_vnode(volume, id);

		vti = *_vti;

		if (vti->Get() == NULL) {
			result = fs->GetInode(id, &inode);
			if (result != B_OK) {
				put_vnode(volume, id);
				return result;
			}

			vti->Replace(inode);
		}
		return B_OK;
	}

	return get_vnode(volume, id, reinterpret_cast<void**>(_vti));
}
Exemple #3
0
void
Inode::WriteLockInTransaction(Transaction& transaction)
{
	acquire_vnode(fVolume->FSVolume(), ID());

	TRACE("Inode::WriteLockInTransaction(): Locking\n");
	rw_lock_write_lock(&fLock);

	transaction.AddListener(this);
}
Exemple #4
0
static status_t
nfs4_rename(fs_volume* volume, fs_vnode* fromDir, const char* fromName,
	fs_vnode* toDir, const char* toName)
{
	VnodeToInode* fromVti
		= reinterpret_cast<VnodeToInode*>(fromDir->private_node);
	VnodeToInode* toVti = reinterpret_cast<VnodeToInode*>(toDir->private_node);
	TRACE("volume = %p, fromDir = %" B_PRIi64 ", toDir = %" B_PRIi64 ","	\
		" fromName = %s, toName = %s", volume, fromVti->ID(), toVti->ID(),	\
		fromName, toName);

	VnodeToInodeLocker _from(fromVti);
	Inode* fromInode = fromVti->Get();
	if (fromInode == NULL)
		return B_ENTRY_NOT_FOUND;


	VnodeToInodeLocker _to(toVti);
	Inode* toInode = toVti->Get();
	if (toInode == NULL)
		return B_ENTRY_NOT_FOUND;

	ino_t id;
	ino_t oldID;
	status_t result = Inode::Rename(fromInode, toInode, fromName, toName, false,
		&id, &oldID);
	if (result != B_OK)
		return result;

	VnodeToInode* vti;

	if (oldID != 0) {
		// we have overriden an inode
		result = acquire_vnode(volume, oldID);
		if (result == B_OK) {
			result = get_vnode(volume, oldID, reinterpret_cast<void**>(&vti));
			ASSERT(result == B_OK);
			if (vti->Unlink(toInode->fInfo.fNames, toName))
				remove_vnode(volume, oldID);

			put_vnode(volume, oldID);
			put_vnode(volume, oldID);
		}
	}

	result = get_vnode(volume, id, reinterpret_cast<void**>(&vti));
	if (result == B_OK) {
		Inode* child = vti->Get();
		if (child == NULL) {
			put_vnode(volume, id);
			return B_ENTRY_NOT_FOUND;
		}

		unremove_vnode(volume, id);
		child->fInfo.fNames->RemoveName(fromInode->fInfo.fNames, fromName);
		child->fInfo.fNames->AddName(toInode->fInfo.fNames, toName);
		put_vnode(volume, id);
	}

	return B_OK;
}