Lines Matching full:mount
31 #include <uapi/linux/mount.h>
38 /* Maximum number of mounts in a mount namespace */
125 static int mnt_alloc_id(struct mount *mnt) in mnt_alloc_id()
135 static void mnt_free_id(struct mount *mnt) in mnt_free_id()
143 static int mnt_alloc_group_id(struct mount *mnt) in mnt_alloc_group_id()
156 void mnt_release_group_id(struct mount *mnt) in mnt_release_group_id()
165 static inline void mnt_add_count(struct mount *mnt, int n) in mnt_add_count()
179 int mnt_get_count(struct mount *mnt) in mnt_get_count()
195 static struct mount *alloc_vfsmnt(const char *name) in alloc_vfsmnt()
197 struct mount *mnt = kmem_cache_zalloc(mnt_cache, GFP_KERNEL); in alloc_vfsmnt()
258 * __mnt_is_readonly: check whether a mount is read-only
259 * @mnt: the mount to check for its write status
274 static inline void mnt_inc_writers(struct mount *mnt) in mnt_inc_writers()
283 static inline void mnt_dec_writers(struct mount *mnt) in mnt_dec_writers()
292 static unsigned int mnt_get_writers(struct mount *mnt) in mnt_get_writers()
324 * __mnt_want_write - get write access to a mount without freeze protection
325 * @m: the mount on which to take a write
335 struct mount *mnt = real_mount(m); in __mnt_want_write()
364 * mnt_want_write - get write access to a mount
365 * @m: the mount on which to take a write
368 * it, and makes sure that writes are allowed (mount is read-write, filesystem
385 * __mnt_want_write_file - get write access to a file's mount
386 * @file: the file who's mount on which to take a write
408 * mnt_want_write_file - get write access to a file's mount
409 * @file: the file who's mount on which to take a write
429 * __mnt_drop_write - give up write access to a mount
430 * @mnt: the mount on which to give up write access
444 * mnt_drop_write - give up write access to a mount
445 * @mnt: the mount on which to give up write access
471 static inline int mnt_hold_writers(struct mount *mnt) in mnt_hold_writers()
502 static inline void mnt_unhold_writers(struct mount *mnt) in mnt_unhold_writers()
512 static int mnt_make_readonly(struct mount *mnt) in mnt_make_readonly()
525 struct mount *mnt; in sb_prepare_remount_readonly()
559 static void free_vfsmnt(struct mount *mnt) in free_vfsmnt()
575 free_vfsmnt(container_of(head, struct mount, mnt_rcu)); in delayed_free_vfsmnt()
581 struct mount *mnt; in __legitimize_mnt()
621 * find the first mount at @dentry on vfsmount @mnt.
624 struct mount *__lookup_mnt(struct vfsmount *mnt, struct dentry *dentry) in __lookup_mnt()
627 struct mount *p; in __lookup_mnt()
636 * lookup_mnt - Return the first child mount mounted at path
641 * mount /dev/sda1 /mnt
642 * mount /dev/sda2 /mnt
643 * mount /dev/sda3 /mnt
645 * Then lookup_mnt() on the base /mnt dentry in the root mount will
653 struct mount *child_mnt; in lookup_mnt()
677 static inline bool mnt_is_cursor(struct mount *mnt) in mnt_is_cursor()
684 * current mount namespace.
689 * mounts in the current mount namespace and test to see if the dentry
693 * need to identify all mounts that may be in the current mount
694 * namespace not just a mount that happens to have some specified
695 * parent mount.
700 struct mount *mnt; in __is_local_mountpoint()
806 static inline int check_mnt(struct mount *mnt) in check_mnt()
836 static struct mountpoint *unhash_mnt(struct mount *mnt) in unhash_mnt()
852 static void umount_mnt(struct mount *mnt) in umount_mnt()
860 void mnt_set_mountpoint(struct mount *mnt, in mnt_set_mountpoint()
862 struct mount *child_mnt) in mnt_set_mountpoint()
872 static void __attach_mnt(struct mount *mnt, struct mount *parent) in __attach_mnt()
882 static void attach_mnt(struct mount *mnt, in attach_mnt()
883 struct mount *parent, in attach_mnt()
890 void mnt_change_mountpoint(struct mount *parent, struct mountpoint *mp, struct mount *mnt) in mnt_change_mountpoint()
893 struct mount *old_parent = mnt->mnt_parent; in mnt_change_mountpoint()
908 static void commit_tree(struct mount *mnt) in commit_tree()
910 struct mount *parent = mnt->mnt_parent; in commit_tree()
911 struct mount *m; in commit_tree()
930 static struct mount *next_mnt(struct mount *p, struct mount *root) in next_mnt()
943 return list_entry(next, struct mount, mnt_child); in next_mnt()
946 static struct mount *skip_mnt_tree(struct mount *p) in skip_mnt_tree()
950 p = list_entry(prev, struct mount, mnt_child); in skip_mnt_tree()
957 * vfs_create_mount - Create a mount for a configured superblock
960 * Create a mount to an already configured superblock. If necessary, the
963 * Note that this does not attach the mount to anything.
967 struct mount *mnt; in vfs_create_mount()
1038 * through from the parent mount to the submount don't support in vfs_submount()
1048 static struct mount *clone_mnt(struct mount *old, struct dentry *root, in clone_mnt()
1052 struct mount *mnt; in clone_mnt()
1102 /* stick the duplicate mount on the same expiry list in clone_mnt()
1117 static void cleanup_mnt(struct mount *mnt) in cleanup_mnt()
1120 struct mount *m; in cleanup_mnt()
1144 cleanup_mnt(container_of(head, struct mount, mnt_rcu)); in __cleanup_mnt()
1151 struct mount *m, *t; in delayed_mntput()
1158 static void mntput_no_expire(struct mount *mnt) in mntput_no_expire()
1203 struct mount *p, *tmp; in mntput_no_expire()
1229 struct mount *m = real_mount(mnt); in mntput()
1247 * path_is_mountpoint() - Check if path is a mount in the current namespace.
1278 struct mount *p; in mnt_clone_internal()
1287 static struct mount *mnt_list_next(struct mnt_namespace *ns, in mnt_list_next()
1290 struct mount *mnt, *ret = NULL; in mnt_list_next()
1328 struct mount *mnt = v; in m_next()
1337 struct mount *mnt = v; in m_stop()
1351 struct mount *r = v; in m_show()
1362 void mnt_cursor_del(struct mnt_namespace *ns, struct mount *cursor) in mnt_cursor_del()
1373 * may_umount_tree - check if a mount tree is busy
1374 * @m: root of mount tree
1382 struct mount *mnt = real_mount(m); in may_umount_tree()
1385 struct mount *p; in may_umount_tree()
1405 * may_umount - check if a mount point is busy
1406 * @mnt: root of mount
1408 * This is called to check if a mount point has any
1410 * mount has sub mounts this will return busy
1435 struct mount *m; in namespace_unlock()
1467 static bool disconnect_mount(struct mount *mnt, enum umount_tree_flags how) in disconnect_mount()
1473 /* A mount without a parent has nothing to be connected to */ in disconnect_mount()
1484 /* Has it been requested that the mount remain connected? */ in disconnect_mount()
1488 /* Is the mount locked such that it needs to remain connected? */ in disconnect_mount()
1492 /* By default disconnect the mount */ in disconnect_mount()
1500 static void umount_tree(struct mount *mnt, enum umount_tree_flags how) in umount_tree()
1503 struct mount *p; in umount_tree()
1526 p = list_first_entry(&tmp_list, struct mount, mnt_list); in umount_tree()
1554 static void shrink_submounts(struct mount *mnt);
1579 static int do_umount(struct mount *mnt, int flags) in do_umount()
1616 * mount, and they will themselves hold resources we must in do_umount()
1620 * must return, and the like. Thats for the mount program to worry in do_umount()
1679 * to an existing mountpoint, and wind up leaking the mount.
1688 struct mount *mnt; in __detach_mounts()
1698 mnt = hlist_entry(mp->m_list.first, struct mount, mnt_mp_list); in __detach_mounts()
1722 "WARNING: The mand mount option has been deprecated and\n" in warn_mandlock()
1724 " option from the mount to silence this warning.\n" in warn_mandlock()
1730 struct mount *mnt = real_mount(path->mnt); in can_umount()
1748 struct mount *mnt = real_mount(path->mnt); in path_umount()
1798 /* Is this a proxy for a mount namespace? */ in is_mnt_ns_file()
1815 /* Could bind mounting the mount namespace inode cause a in mnt_ns_loop()
1816 * mount namespace loop? in mnt_ns_loop()
1826 struct mount *copy_tree(struct mount *mnt, struct dentry *dentry, in copy_tree()
1829 struct mount *res, *p, *q, *r, *parent; in copy_tree()
1845 struct mount *s; in copy_tree()
1895 struct mount *tree; in collect_mounts()
1938 static bool has_locked_children(struct mount *mnt, struct dentry *dentry) in has_locked_children()
1940 struct mount *child; in has_locked_children()
1956 * This creates a new vfsmount, which will be the clone of @path. The new mount
1958 * changes to the originating mount won't be propagated into this).
1964 struct mount *old_mnt = real_mount(path->mnt); in clone_private_mount()
1965 struct mount *new_mnt; in clone_private_mount()
1983 /* Longterm mount to be removed by kern_unmount*() */ in clone_private_mount()
1997 struct mount *mnt; in iterate_mounts()
2009 static void lock_mnt_tree(struct mount *mnt) in lock_mnt_tree()
2011 struct mount *p; in lock_mnt_tree()
2015 /* Don't allow unprivileged users to change mount flags */ in lock_mnt_tree()
2029 /* Don't allow unprivileged users to reveal what is under a mount */ in lock_mnt_tree()
2036 static void cleanup_group_ids(struct mount *mnt, struct mount *end) in cleanup_group_ids()
2038 struct mount *p; in cleanup_group_ids()
2046 static int invent_group_ids(struct mount *mnt, bool recurse) in invent_group_ids()
2048 struct mount *p; in invent_group_ids()
2063 int count_mounts(struct mnt_namespace *ns, struct mount *mnt) in count_mounts()
2067 struct mount *p; in count_mounts()
2086 * @source_mnt : mount tree to be attached
2087 * @nd : place the mount tree @source_mnt is attached
2089 * store the parent mount and mountpoint dentry.
2092 * NOTE: in the table below explains the semantics when a source mount
2093 * of a given type is attached to a destination mount of a given type.
2095 * | BIND MOUNT OPERATION |
2106 * A bind operation clones the source mount and mounts the clone on the
2107 * destination mount.
2109 * (++) the cloned mount is propagated to all the mounts in the propagation
2110 * tree of the destination mount and the cloned mount is added to
2111 * the peer group of the source mount.
2112 * (+) the cloned mount is created under the destination mount and is marked
2113 * as shared. The cloned mount is added to the peer group of the source
2114 * mount.
2115 * (+++) the mount is propagated to all the mounts in the propagation tree
2116 * of the destination mount and the cloned mount is made slave
2117 * of the same master as that of the source mount. The cloned mount
2119 * (*) the cloned mount is made a slave of the same master as that of the
2120 * source mount.
2123 * | MOVE MOUNT OPERATION |
2135 * (+) the mount is moved to the destination. And is then propagated to
2136 * all the mounts in the propagation tree of the destination mount.
2137 * (+*) the mount is moved to the destination.
2138 * (+++) the mount is moved to the destination and is then propagated to
2139 * all the mounts belonging to the destination mount's propagation tree.
2140 * the mount is marked as 'shared and slave'.
2141 * (*) the mount continues to be a slave at the new location.
2143 * if the source mount is a tree, the operations explained above is
2144 * applied to each mount in the tree.
2148 static int attach_recursive_mnt(struct mount *source_mnt, in attach_recursive_mnt()
2149 struct mount *dest_mnt, in attach_recursive_mnt()
2157 struct mount *child, *p; in attach_recursive_mnt()
2168 /* Is there space to add these mounts to the mount namespace? */ in attach_recursive_mnt()
2202 struct mount *q; in attach_recursive_mnt()
2221 child = hlist_entry(tree_list.first, struct mount, mnt_hash); in attach_recursive_mnt()
2278 static int graft_tree(struct mount *mnt, struct mount *p, struct mountpoint *mp) in graft_tree()
2312 struct mount *m; in do_change_type()
2313 struct mount *mnt = real_mount(path->mnt); in do_change_type()
2342 static struct mount *__do_loopback(struct path *old_path, int recurse) in __do_loopback()
2344 struct mount *mnt = ERR_PTR(-EINVAL), *old = real_mount(old_path->mnt); in __do_loopback()
2367 * do loopback mount.
2373 struct mount *mnt = NULL, *parent; in do_loopback()
2419 struct mount *mnt, *p; in open_detached_copy()
2506 * Don't allow locked mount flags to be cleared.
2511 static bool can_change_locked_flags(struct mount *mnt, unsigned int mnt_flags) in can_change_locked_flags()
2538 static int change_mount_ro_state(struct mount *mnt, unsigned int mnt_flags) in change_mount_ro_state()
2552 static void set_mount_attributes(struct mount *mnt, unsigned int mnt_flags) in set_mount_attributes()
2584 * to mount(2).
2589 struct mount *mnt = real_mount(path->mnt); in do_reconfigure_mnt()
2628 struct mount *mnt = real_mount(path->mnt); in do_remount()
2666 static inline int tree_contains_unbindable(struct mount *mnt) in tree_contains_unbindable()
2668 struct mount *p; in tree_contains_unbindable()
2677 * Check that there aren't references to earlier/same mount namespaces in the
2678 * specified subtree. Such references can act as pins for mount namespaces
2679 * that aren't checked by the mount-cycle checking code, thereby allowing
2682 static bool check_for_nsfs_mounts(struct mount *subtree) in check_for_nsfs_mounts()
2684 struct mount *p; in check_for_nsfs_mounts()
2700 struct mount *from, *to; in do_set_group()
2716 /* We should be allowed to modify mount namespaces of both mounts */ in do_set_group()
2723 /* To and From paths should be mount roots */ in do_set_group()
2733 /* From mount root should be wider than To mount root */ in do_set_group()
2737 /* From mount should not have locked children in place of To's root */ in do_set_group()
2750 struct mount *m = from->mnt_master; in do_set_group()
2773 struct mount *p; in do_move_mount()
2774 struct mount *old; in do_move_mount()
2775 struct mount *parent; in do_move_mount()
2814 * Don't move a mount residing in a shared parent. in do_move_mount()
2819 * Don't move a mount tree containing unbindable mounts to a destination in do_move_mount()
2820 * mount which is shared. in do_move_mount()
2836 /* if the mount is moved, it should no longer be expire in do_move_mount()
2870 * add a mount into a namespace's mount tree
2872 static int do_add_mount(struct mount *newmnt, struct mountpoint *mp, in do_add_mount()
2875 struct mount *parent = real_mount(path->mnt); in do_add_mount()
2888 /* Refuse the same filesystem on the same mount point */ in do_add_mount()
2903 * Create a new mount using a superblock configuration and request it
2944 * create a new mount for userspace and request it to be added into the
3000 struct mount *mnt; in finish_automount()
3009 /* The new mount record should have at least 2 refs to prevent it being in finish_automount()
3023 * got", not "try to mount it on top". in finish_automount()
3067 * mnt_set_expiry - Put a mount on an expiration list
3068 * @mnt: The mount to list.
3069 * @expiry_list: The list to add the mount to.
3088 struct mount *mnt, *next; in mark_mounts_for_expiry()
3110 mnt = list_first_entry(&graveyard, struct mount, mnt_expire); in mark_mounts_for_expiry()
3126 static int select_submounts(struct mount *parent, struct list_head *graveyard) in select_submounts()
3128 struct mount *this_parent = parent; in select_submounts()
3137 struct mount *mnt = list_entry(tmp, struct mount, mnt_child); in select_submounts()
3172 static void shrink_submounts(struct mount *mnt) in shrink_submounts()
3175 struct mount *m; in shrink_submounts()
3180 m = list_first_entry(&graveyard, struct mount, in shrink_submounts()
3231 * be given to the mount() call (ie: read-only, no-dev, no-suid etc).
3237 * Pre-0.97 versions of mount() didn't have a flags word.
3357 * mount a reference to an older mount namespace into the current
3358 * mount namespace, preventing reference counting loops. A 64bit
3405 struct mount *p, *q; in copy_mnt_ns()
3406 struct mount *old; in copy_mnt_ns()
3407 struct mount *new; in copy_mnt_ns()
3481 struct mount *mnt = real_mount(m); in mount_subtree()
3516 SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name, in SYSCALL_DEFINE5() argument
3581 * Create a kernel mount representation for a new, prepared superblock
3591 struct mount *mnt; in SYSCALL_DEFINE3()
3634 /* There must be a valid superblock or we can't mount it */ in SYSCALL_DEFINE3()
3641 pr_warn("VFS: Mount too revealing\n"); in SYSCALL_DEFINE3()
3660 /* We've done the mount bit - now move the file context into more or in SYSCALL_DEFINE3()
3706 * Move a mount from one place to another. In combination with
3707 * fsopen()/fsmount() this is used to install a new mount and in combination
3709 * a mount subtree.
3771 bool is_path_reachable(struct mount *mnt, struct dentry *dentry, in is_path_reachable()
3812 * /nfs/my_root where /nfs is the mount point. It must be a mountpoint,
3813 * though, so you may need to say mount --bind /nfs/my_root /nfs/my_root
3820 struct mount *new_mnt, *root_mnt, *old_mnt, *root_parent, *ex_parent; in SYSCALL_DEFINE2()
3889 /* mount old root on put_old */ in SYSCALL_DEFINE2()
3891 /* mount new_root on / */ in SYSCALL_DEFINE2()
3895 /* A moved mount should not expire automatically */ in SYSCALL_DEFINE2()
3915 static unsigned int recalc_flags(struct mount_kattr *kattr, struct mount *mnt) in recalc_flags()
3927 static int can_idmap_mount(const struct mount_kattr *kattr, struct mount *mnt) in can_idmap_mount()
3935 * Once a mount has been idmapped we don't allow it to change its in can_idmap_mount()
3937 * another bind-mount they can idmap if they want to. in can_idmap_mount()
3954 /* Mount has already been visible in the filesystem hierarchy. */ in can_idmap_mount()
3961 static struct mount *mount_setattr_prepare(struct mount_kattr *kattr, in mount_setattr_prepare()
3962 struct mount *mnt, int *err) in mount_setattr_prepare()
3964 struct mount *m = mnt, *last = NULL; in mount_setattr_prepare()
4003 static void do_idmap_mount(const struct mount_kattr *kattr, struct mount *mnt) in do_idmap_mount()
4016 struct mount *mnt, struct mount *last, in mount_setattr_commit()
4019 struct mount *m = mnt; in mount_setattr_commit()
4033 * apply mount options. in mount_setattr_commit()
4043 * On failure, only cleanup until we found the first mount in mount_setattr_commit()
4056 struct mount *mnt = real_mount(path->mnt), *last = NULL; in do_mount_setattr()
4080 * Get the mount tree in a shape where we can change mount in do_mount_setattr()
4110 * We currently do not support clearing an idmapped mount. If this ever in build_mount_idmapped()
4138 * wanting to idmap a mount to init_user_ns can just use a namespace in build_mount_idmapped()
4278 struct mount *m; in init_mount_tree()
4309 mnt_cache = kmem_cache_create("mnt_cache", sizeof(struct mount), in mnt_init()
4312 mount_hashtable = alloc_large_system_hash("Mount-cache", in mnt_init()
4324 panic("Failed to allocate mount hash table\n"); in mnt_init()
4354 * it is a longterm mount, don't release mnt until in kern_mount()
4365 /* release long term mount so mount point can be released */ in kern_unmount()
4421 struct mount *mnt; in mnt_already_visible()
4427 struct mount *child; in mnt_already_visible()
4436 /* This mount is not fully visible if it's root directory in mnt_already_visible()
4442 /* A local view of the mount flags */ in mnt_already_visible()
4449 /* Verify the mount flags are equal to or more permissive in mnt_already_visible()
4450 * than the proposed new mount. in mnt_already_visible()
4459 /* This mount is not fully visible if there are any in mnt_already_visible()