rem: mount->partition = NULL;
add: mount->owns_file_device = false;
context: fs_mount(char *path, const char *device, const char *fsName, uint32 flags,	void *args, bool kernel){	struct fs_mount *mount;	struct vnode *covered_vnode = NULL;	vnode_id root_id;	int err = 0;	FUNCTION(("fs_mount: entry. path = '%s', fs_name = '%s'\n", path, fsName));	// The path is always safe, we just have to make sure that fsName is	// almost valid - we can't make any assumptions about args, though.// TODO: fsName == NULL is OK, if device refers to a partition. Then the DDM// will know, what FS to use.	if (fsName == NULL || fsName[0] == '\0')		return B_BAD_VALUE;	RecursiveLocker mountOpLocker(sMountOpLock);	// If the file system is not a "virtual" one, the device argument should	// point to a real file/device (if given at all).	// get the partition	KDiskDeviceManager* ddm = KDiskDeviceManager::Default();	KPartition* partition = NULL;	if (!(flags & B_MOUNT_VIRTUAL_DEVICE) && device) {		// get a corresponding partition from the DDM		partition = ddm->RegisterPartition(device, true);			// TODO: Normalize the path!			// TODO: Support for mounting images!		if (!partition) {			PRINT(("fs_mount(): Partition `%s' not found.\n", device));			return B_ENTRY_NOT_FOUND;		}	}	PartitionRegistrar partitionRegistrar(partition, true);	// Write lock the partition's device. For the time being, we keep the lock	// until we're done mounting -- not nice, but ensure, that no-one is	// interfering.	// TODO: Find a better solution.	KDiskDevice* diskDevice = NULL;	if (partition) {		diskDevice = ddm->WriteLockDevice(partition->Device()->ID());		if (!diskDevice) {			PRINT(("fs_mount(): 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_mount(): Partition is busy.\n"));			return B_BUSY;		}	}	mount = (struct fs_mount *)malloc(sizeof(struct fs_mount));	if (mount == NULL)		return B_NO_MEMORY;	list_init_etc(&mount->vnodes, offsetof(struct vnode, mount_link));	mount->fs_name = strdup(fsName);	if (mount->fs_name == NULL) {		err = B_NO_MEMORY;		goto err1;	}	mount->device_name = strdup(device);		// "device" can be NULL	mount->fs = get_file_system(fsName);	if (mount->fs == NULL) {		err = ENODEV;		goto err3;	}	err = recursive_lock_init(&mount->rlock, "mount rlock");	if (err < B_OK)		goto err4;	mount->id = sNextMountID++;	mount->unmounting = false;	mount->partition = NULL;	mutex_lock(&sMountMutex);	// insert mount struct into list before we call fs mount()	hash_insert(sMountsTable, mount);	mutex_unlock(&sMountMutex);	if (!sRoot) {		// we haven't mounted anything yet		if (strcmp(path, "/") != 0) {			err = B_ERROR;			goto err5;		}		err = FS_MOUNT_CALL(mount, mount)(mount->id, device, NULL, &mount->cookie, &root_id);		if (err < 0) {			// ToDo: why should we hide the error code from the file system here?			//err = ERR_VFS_GENERAL;			goto err5;		}		mount->covers_vnode = NULL; // this is the root mount	} else {		err = path_to_vnode(path, true, &covered_vnode, kernel);		if (err < 0)			goto err5;		if (!covered_vnode) {			err = B_ERROR;			goto err5;		}		// make sure covered_vnode is a DIR		struct stat coveredNodeStat;		err = FS_CALL(covered_vnode, read_stat)(covered_vnode->mount->cookie,			covered_vnode->private_node, &coveredNodeStat);		if (err < 0)			goto err5;		if (!S_ISDIR(coveredNodeStat.st_mode)) {			err = B_NOT_A_DIRECTORY;			goto err5;		}		if (covered_vnode->mount->root_vnode == covered_vnode) {			err = ERR_VFS_ALREADY_MOUNTPOINT;			goto err5;		}		mount->covers_vnode = covered_vnode;		// mount it		err = FS_MOUNT_CALL(mount, mount)(mount->id, device, NULL, &mount->cookie, &root_id);		if (err < 0)			goto err6;	}	err = get_vnode(mount->id, root_id, &mount->root_vnode, 0);	if (err < 0)		goto err7;	// No race here, since fs_mount() is the only function changing	// covers_vnode (and holds sMountOpLock at that time).	if (mount->covers_vnode)		mount->covers_vnode->covered_by = mount->root_vnode;	if (!sRoot)		sRoot = mount->root_vnode;	// supply the partition (if any) with the mount cookie and mark it mounted	if (partition) {		partition->SetMountCookie(mount->cookie);		partition->AddFlags(B_PARTITION_MOUNTED);		// keep a partition reference as long as the partition is mounted		partitionRegistrar.Detach();		mount->partition = partition;	}	return B_OK;err7:	FS_MOUNT_CALL(mount, unmount)(mount->cookie);err6:	if (mount->covers_vnode)		put_vnode(mount->covers_vnode);err5:	mutex_lock(&sMountMutex);	hash_remove(sMountsTable, mount);	mutex_unlock(&sMountMutex);	recursive_lock_destroy(&mount->rlock);err4:	put_file_system(mount->fs);	free(mount->device_name);err3:	free(mount->fs_name);err1:	free(mount);	return err;}