Lines Matching refs:mount

55 #define HAS_FS_MOUNT_CALL(mount, op)	(mount->volume->ops->op != NULL)
58 vnode->ops->op(vnode->mount->volume, vnode, params)
60 vnode->ops->op(vnode->mount->volume, vnode)
61 #define FS_MOUNT_CALL(mount, op, params...) \
62 mount->volume->ops->op(mount->volume, params)
63 #define FS_MOUNT_CALL_NO_PARAMS(mount, op) \
64 mount->volume->ops->op(mount->volume)
81 struct fs_mount *mount;
102 as the mount is mounted and it is made sure it won't be unmounted
103 (e.g. by holding a reference to a vnode of that mount) (read) access
105 while mounted the mount holds a reference to the covers_vnode, and thus
106 making the access path vnode->mount->covers_vnode->mount->... safe if a
107 reference to vnode is held (note that for the root mount covers_vnode
136 /** \brief Guards mount/unmount operations.
164 * to the immutable fields (device, id, private_node, mount) to which
405 struct fs_mount *mount = (fs_mount *)_m;
408 if (mount->id == *id)
418 struct fs_mount *mount = (fs_mount *)_m;
421 if (mount)
422 return mount->id % range;
446 struct fs_mount *mount = find_mount(id);
447 if (mount == NULL)
450 if (mount->root_vnode == NULL) {
451 // might have been called during a mount operation in which
456 inc_vnode_ref_count(mount->root_vnode);
457 *_mount = mount;
464 put_mount(struct fs_mount *mount)
466 if (mount)
467 put_vnode(mount->root_vnode);
569 add_vnode_to_mount_list(struct vnode *vnode, struct fs_mount *mount)
571 fssh_recursive_lock_lock(&mount->rlock);
573 list_add_link_to_head(&mount->vnodes, &vnode->mount_link);
575 fssh_recursive_lock_unlock(&mount->rlock);
580 remove_vnode_from_mount_list(struct vnode *vnode, struct fs_mount *mount)
582 fssh_recursive_lock_lock(&mount->rlock);
587 fssh_recursive_lock_unlock(&mount->rlock);
605 // add the vnode to the mount structure
607 vnode->mount = find_mount(mountID);
608 if (!vnode->mount || vnode->mount->unmounting) {
615 add_vnode_to_mount_list(vnode, vnode->mount);
627 * it from the vnode hash as well as from its mount structure.
656 remove_vnode_from_mount_list(vnode, vnode->mount);
734 /** \brief Looks up a vnode by mount and node ID in the sVnodeTable.
738 * \param mountID the mount ID.
757 /** \brief Retrieves a vnode for a given mount ID, node ID pair.
763 * \param mountID the mount ID.
818 status = FS_MOUNT_CALL(vnode->mount, get_vnode, vnodeID, vnode, &type,
841 remove_vnode_from_mount_list(vnode, vnode->mount);
870 * \a mount object.
881 disconnect_mount_or_vnode_fds(struct fs_mount *mount,
887 /** \brief Resolves a mount point vnode to the volume root vnode it is covered
896 * indeed a mount point, or \c NULL otherwise.
918 /** \brief Resolves a mount point vnode to the volume root vnode it is covered
921 * Given an arbitrary vnode (identified by mount and node ID), the function
923 * function returns the mount and node ID of the volume root node. Otherwise
924 * it simply returns the supplied mount and node ID.
927 * for storing the resolved mount and node ID remain untouched and an error
930 * \param mountID The mount ID of the vnode in question.
932 * \param resolvedMountID Pointer to storage for the resolved mount ID.
966 /** \brief Resolves a volume root vnode to the underlying mount point vnode.
970 * a reference to the underlying mount point node and returns it.
973 * \return The mount point vnode the vnode covers, if it is indeed a volume
985 struct fs_mount *mount = vnode->mount;
986 if (vnode == mount->root_vnode && mount->covers_vnode) {
987 mountPoint = mount->covers_vnode;
1127 // See if the '..' is at the root of a mount and move to the covered
1130 && vnode->mount->root_vnode == vnode
1131 && vnode->mount->covers_vnode) {
1132 nextVnode = vnode->mount->covers_vnode;
1226 // see if we hit a mount point
1349 // See if vnode is the root of a mount and move to the covered
1352 if (vnode->mount->root_vnode == vnode && vnode->mount->covers_vnode != NULL) {
1353 vnode = vnode->mount->covers_vnode;
1454 // resolve a volume root to its mount point
1479 // resolve a volume root to its mount point
1664 get_new_fd(int type, struct fs_mount *mount, struct vnode *vnode,
1681 descriptor->u.mount = mount;
1699 // mount types
2128 return vnode->mount->volume;
2380 /** Looks up a vnode with the given mount and vnode ID.
2413 fs_mount *mount;
2414 fssh_status_t status = get_mount(volume->id, &mount);
2421 struct vnode *vnode = mount->root_vnode;
2431 put_mount(mount);
2437 // wrong mount ID - must not gain access on foreign file system nodes
3357 && parent->mount->root_vnode == parent
3358 && parent->mount->covers_vnode) {
3372 // resolve mount points
3718 if (directory->mount != vnode->mount) {
4254 struct fs_mount *mount;
4259 fssh_status_t status = get_mount(mountID, &mount);
4263 if (!HAS_FS_MOUNT_CALL(mount, open_index_dir)) {
4268 status = FS_MOUNT_CALL(mount, open_index_dir, &cookie);
4273 status = get_new_fd(FDTYPE_INDEX_DIR, mount, NULL, cookie, 0, kernel);
4278 FS_MOUNT_CALL(mount, close_index_dir, cookie);
4279 FS_MOUNT_CALL(mount, free_index_dir_cookie, cookie);
4282 put_mount(mount);
4290 struct fs_mount *mount = descriptor->u.mount;
4294 if (HAS_FS_MOUNT_CALL(mount, close_index_dir))
4295 return FS_MOUNT_CALL(mount, close_index_dir, descriptor->cookie);
4304 struct fs_mount *mount = descriptor->u.mount;
4306 if (mount != NULL) {
4307 FS_MOUNT_CALL(mount, free_index_dir_cookie, descriptor->cookie);
4318 struct fs_mount *mount = descriptor->u.mount;
4320 if (HAS_FS_MOUNT_CALL(mount, read_index_dir))
4321 return FS_MOUNT_CALL(mount, read_index_dir, descriptor->cookie, buffer, bufferSize, _count);
4330 struct fs_mount *mount = descriptor->u.mount;
4332 if (HAS_FS_MOUNT_CALL(mount, rewind_index_dir))
4333 return FS_MOUNT_CALL(mount, rewind_index_dir, descriptor->cookie);
4344 struct fs_mount *mount;
4345 fssh_status_t status = get_mount(mountID, &mount);
4349 if (!HAS_FS_MOUNT_CALL(mount, create_index)) {
4354 status = FS_MOUNT_CALL(mount, create_index, name, type, flags);
4357 put_mount(mount);
4368 struct fs_mount *mount;
4369 fssh_status_t status = get_mount(mountID, &mount);
4373 if (!HAS_FS_MOUNT_CALL(mount, read_index_stat)) {
4378 status = FS_MOUNT_CALL(mount, read_index_stat, name, stat);
4381 put_mount(mount);
4391 struct fs_mount *mount;
4392 fssh_status_t status = get_mount(mountID, &mount);
4396 if (!HAS_FS_MOUNT_CALL(mount, remove_index)) {
4401 status = FS_MOUNT_CALL(mount, remove_index, name);
4404 put_mount(mount);
4418 struct fs_mount *mount;
4423 fssh_status_t status = get_mount(device, &mount);
4427 if (!HAS_FS_MOUNT_CALL(mount, open_query)) {
4432 status = FS_MOUNT_CALL(mount, open_query, query, flags, port, token, &cookie);
4437 status = get_new_fd(FDTYPE_QUERY, mount, NULL, cookie, 0, kernel);
4442 FS_MOUNT_CALL(mount, close_query, cookie);
4443 FS_MOUNT_CALL(mount, free_query_cookie, cookie);
4446 put_mount(mount);
4454 struct fs_mount *mount = descriptor->u.mount;
4458 if (HAS_FS_MOUNT_CALL(mount, close_query))
4459 return FS_MOUNT_CALL(mount, close_query, descriptor->cookie);
4468 struct fs_mount *mount = descriptor->u.mount;
4470 if (mount != NULL) {
4471 FS_MOUNT_CALL(mount, free_query_cookie, descriptor->cookie);
4482 struct fs_mount *mount = descriptor->u.mount;
4484 if (HAS_FS_MOUNT_CALL(mount, read_query))
4485 return FS_MOUNT_CALL(mount, read_query, descriptor->cookie, buffer, bufferSize, _count);
4494 struct fs_mount *mount = descriptor->u.mount;
4496 if (HAS_FS_MOUNT_CALL(mount, rewind_query))
4497 return FS_MOUNT_CALL(mount, rewind_query, descriptor->cookie);
4511 struct fs_mount *mount;
4545 mount = (struct fs_mount *)malloc(sizeof(struct fs_mount));
4546 if (mount == NULL)
4549 mount->volume = (fssh_fs_volume*)malloc(sizeof(fssh_fs_volume));
4550 if (mount->volume == NULL) {
4551 free(mount);
4555 list_init_etc(&mount->vnodes, fssh_offsetof(struct vnode, mount_link));
4557 mount->fs_name = get_file_system_name(fsName);
4558 if (mount->fs_name == NULL) {
4563 mount->device_name = fssh_strdup(device);
4566 mount->fs = get_file_system(fsName);
4567 if (mount->fs == NULL) {
4572 fssh_recursive_lock_init(&mount->rlock, "mount rlock");
4575 mount->id = sNextMountID++;
4576 mount->root_vnode = NULL;
4577 mount->covers_vnode = NULL;
4578 mount->unmounting = false;
4579 mount->owns_file_device = false;
4581 mount->volume->id = mount->id;
4582 mount->volume->layer = 0;
4583 mount->volume->private_volume = NULL;
4584 mount->volume->ops = NULL;
4585 mount->volume->sub_volume = NULL;
4586 mount->volume->super_volume = NULL;
4588 // insert mount struct into list before we call FS's mount() function
4589 // so that vnodes can be created for this mount
4591 hash_insert(sMountsTable, mount);
4603 status = mount->fs->mount(mount->volume, device, flags, args, &rootID);
4626 if (coveredVnode->mount->root_vnode == coveredVnode) {
4627 // this is already a mount point
4632 mount->covers_vnode = coveredVnode;
4634 // mount it
4635 status = mount->fs->mount(mount->volume, device, flags, args, &rootID);
4642 mount->root_vnode = lookup_vnode(mount->id, rootID);
4643 if (mount->root_vnode == NULL || mount->root_vnode->ref_count != 1) {
4652 if (mount->covers_vnode)
4653 mount->covers_vnode->covered_by = mount->root_vnode;
4657 sRoot = mount->root_vnode;
4659 return mount->id;
4662 FS_MOUNT_CALL_NO_PARAMS(mount, unmount);
4664 if (mount->covers_vnode)
4665 put_vnode(mount->covers_vnode);
4669 hash_remove(sMountsTable, mount);
4672 fssh_recursive_lock_destroy(&mount->rlock);
4674 put_file_system(mount->fs);
4675 free(mount->device_name);
4677 free(mount->fs_name);
4679 free(mount->volume);
4680 free(mount);
4689 struct fs_mount *mount;
4701 mount = find_mount(vnode->device);
4702 if (!mount)
4703 fssh_panic("vfs_unmount: find_mount() failed on root vnode @%p of mount\n", vnode);
4705 if (mount->root_vnode != vnode) {
4720 // cycle through the list of vnodes associated with this mount and
4723 while ((vnode = (struct vnode *)list_get_next_item(&mount->vnodes, vnode)) != NULL) {
4727 || ((vnode->ref_count != 0 && mount->root_vnode != vnode)
4728 || (vnode->ref_count != 2 && mount->root_vnode == vnode))) {
4729 // there are still vnodes in use on this mount, so we cannot
4741 put_vnode(mount->root_vnode);
4759 mount->unmounting = true;
4764 disconnect_mount_or_vnode_fds(mount, NULL);
4770 // we can safely continue, mark all of the vnodes busy and this mount
4772 mount->unmounting = true;
4774 while ((vnode = (struct vnode *)list_get_next_item(&mount->vnodes, vnode)) != NULL) {
4785 mount->root_vnode->ref_count -= 2;
4790 mount->covers_vnode->covered_by = NULL;
4792 put_vnode(mount->covers_vnode);
4794 // Free all vnodes associated with this mount.
4795 // They will be removed from the mount list by free_vnode(), so
4797 while ((vnode = (struct vnode *)list_get_first_item(&mount->vnodes)) != NULL) {
4801 // remove the mount structure from the hash table
4803 hash_remove(sMountsTable, mount);
4808 FS_MOUNT_CALL_NO_PARAMS(mount, unmount);
4811 put_file_system(mount->fs);
4813 free(mount->device_name);
4814 free(mount->fs_name);
4815 free(mount);
4824 struct fs_mount *mount;
4825 fssh_status_t status = get_mount(device, &mount);
4831 if (HAS_FS_MOUNT_CALL(mount, sync))
4832 status = FS_MOUNT_CALL_NO_PARAMS(mount, sync);
4839 fssh_recursive_lock_lock(&mount->rlock);
4841 struct vnode *vnode = (struct vnode *)list_get_next_item(&mount->vnodes,
4848 fssh_recursive_lock_unlock(&mount->rlock);
4855 if (get_vnode(mount->id, id, &vnode, true) == FSSH_B_OK) {
4866 fssh_dprintf("syncing of mount %d stopped due to vnode %"
4867 FSSH_B_PRIdINO ".\n", (int)mount->id, id);
4875 put_mount(mount);
4883 struct fs_mount *mount;
4884 fssh_status_t status = get_mount(device, &mount);
4890 if (HAS_FS_MOUNT_CALL(mount, read_fs_info))
4891 status = FS_MOUNT_CALL(mount, read_fs_info, info);
4895 info->dev = mount->id;
4896 info->root = mount->root_vnode->id;
4897 fssh_strlcpy(info->fsh_name, mount->fs_name, sizeof(info->fsh_name));
4898 if (mount->device_name != NULL) {
4899 fssh_strlcpy(info->device_name, mount->device_name,
4907 put_mount(mount);
4915 struct fs_mount *mount;
4916 fssh_status_t status = get_mount(device, &mount);
4920 if (HAS_FS_MOUNT_CALL(mount, write_fs_info))
4921 status = FS_MOUNT_CALL(mount, write_fs_info, info, mask);
4925 put_mount(mount);
4933 struct fs_mount *mount = NULL;
4944 mount = find_mount(device++);
4945 if (mount != NULL && mount->cookie != NULL)
4951 if (mount != NULL)
4952 device = mount->id;