rem: if (partition) partition->Unregister();
context: fs_unmount(char *path, bool kernel){	struct fs_mount *mount;	struct vnode *vnode;	int err;	FUNCTION(("vfs_unmount: entry. path = '%s', kernel %d\n", path, kernel));	err = path_to_vnode(path, true, &vnode, kernel);	if (err < 0)		return ERR_VFS_PATH_NOT_FOUND;	RecursiveLocker mountOpLocker(sMountOpLock);	mount = find_mount(vnode->device);	if (!mount)		panic("vfs_unmount: find_mount() failed on root vnode @%p of mount\n", vnode);	if (mount->root_vnode != vnode) {		// not mountpoint		put_vnode(vnode);		return ERR_VFS_NOT_MOUNTPOINT;	}	// if the volume is associated with a partition, lock the device of the	// partition as long as we are unmounting	KDiskDeviceManager* ddm = KDiskDeviceManager::Default();	KPartition *partition = mount->partition;	KDiskDevice *diskDevice = NULL;	if (partition) {		diskDevice = ddm->WriteLockDevice(partition->Device()->ID());		if (!diskDevice) {			PRINT(("fs_unmount(): Failed to lock disk device!\n"));			return B_ERROR;		}	}	DeviceWriteLocker writeLocker(diskDevice, true);	// make sure, that the partition is not busy	if (partition) {		if (partition->IsBusy() || partition->IsDescendantBusy()) {			PRINT(("fs_unmount(): Partition is busy.\n"));			return B_BUSY;		}	}	/* grab the vnode master mutex to keep someone from creating	 * a vnode while we're figuring out if we can continue	 */	mutex_lock(&sVnodeMutex);	/* simulate the root vnode having it's refcount decremented */	mount->root_vnode->ref_count -= 2;	// cycle through the list of vnodes associated with this mount and	// make sure all of them are not busy or have refs on them	vnode = NULL;	while ((vnode = (struct vnode *)list_get_next_item(&mount->vnodes, vnode)) != NULL) {		if (vnode->busy || vnode->ref_count != 0) {			mount->root_vnode->ref_count += 2;			mutex_unlock(&sVnodeMutex);			put_vnode(mount->root_vnode);			return EBUSY;		}	}	/* we can safely continue, mark all of the vnodes busy and this mount	 * structure in unmounting state	 */	while ((vnode = (struct vnode *)list_get_next_item(&mount->vnodes, vnode)) != NULL) {		if (vnode != mount->root_vnode)			vnode->busy = true;	}	mount->unmounting = true;	/* add 2 back to the root vnode's ref */	mount->root_vnode->ref_count += 2;	mutex_unlock(&sVnodeMutex);	mount->covers_vnode->covered_by = NULL;	put_vnode(mount->covers_vnode);	/* release the ref on the root vnode twice */	put_vnode(mount->root_vnode);	put_vnode(mount->root_vnode);	// ToDo: when full vnode cache in place, will need to force	// a putvnode/removevnode here	/* remove the mount structure from the hash table */	mutex_lock(&sMountMutex);	hash_remove(sMountsTable, mount);	mutex_unlock(&sMountMutex);	mountOpLocker.Unlock();	FS_MOUNT_CALL(mount, unmount)(mount->cookie);	// release the file system	put_file_system(mount->fs);	free(mount->device_name);	free(mount->fs_name);	free(mount);	// dereference the partition	if (partition)		partition->Unregister();	return 0;}