Lines Matching refs:mount

31 #include <uapi/linux/mount.h>
39 /* Maximum number of mounts in a mount namespace */
127 static int mnt_alloc_id(struct mount *mnt)
137 static void mnt_free_id(struct mount *mnt)
145 static int mnt_alloc_group_id(struct mount *mnt)
158 void mnt_release_group_id(struct mount *mnt)
167 static inline void mnt_add_count(struct mount *mnt, int n)
181 int mnt_get_count(struct mount *mnt)
197 static struct mount *alloc_vfsmnt(const char *name)
199 struct mount *mnt = kmem_cache_zalloc(mnt_cache, GFP_KERNEL);
260 * __mnt_is_readonly: check whether a mount is read-only
261 * @mnt: the mount to check for its write status
276 static inline void mnt_inc_writers(struct mount *mnt)
285 static inline void mnt_dec_writers(struct mount *mnt)
294 static unsigned int mnt_get_writers(struct mount *mnt)
317 * not see any superblock / mount flag changes done by remount.
320 * see the values of superblock / mount flags updated by remount.
333 * __mnt_want_write - get write access to a mount without freeze protection
334 * @m: the mount on which to take a write
344 struct mount *mnt = real_mount(m);
391 * mnt_want_write - get write access to a mount
392 * @m: the mount on which to take a write
395 * it, and makes sure that writes are allowed (mount is read-write, filesystem
412 * __mnt_want_write_file - get write access to a file's mount
413 * @file: the file who's mount on which to take a write
435 * mnt_want_write_file - get write access to a file's mount
436 * @file: the file who's mount on which to take a write
456 * __mnt_drop_write - give up write access to a mount
457 * @mnt: the mount on which to give up write access
471 * mnt_drop_write - give up write access to a mount
472 * @mnt: the mount on which to give up write access
499 * mnt_hold_writers - prevent write access to the given mount
516 static inline int mnt_hold_writers(struct mount *mnt)
548 * mnt_unhold_writers - stop preventing write access to the given mount
559 static inline void mnt_unhold_writers(struct mount *mnt)
569 static int mnt_make_readonly(struct mount *mnt)
582 struct mount *mnt;
611 static void free_vfsmnt(struct mount *mnt)
623 free_vfsmnt(container_of(head, struct mount, mnt_rcu));
629 struct mount *mnt;
669 * __lookup_mnt - find first child mount
670 * @mnt: parent mount
673 * If @mnt has a child mount @c mounted @dentry find and return it.
675 * Note that the child mount @c need not be unique. There are cases
676 * where shadow mounts are created. For example, during mount
677 * propagation when a source mount @mnt whose root got overmounted by a
678 * mount @o after path lookup but before @namespace_sem could be
680 * @o. When @mnt is propagated to a destination mount @d that already
681 * has another mount @n mounted at the same mountpoint then the source
682 * mount @mnt will be tucked beneath @n, i.e., @n will be mounted on
688 struct mount *__lookup_mnt(struct vfsmount *mnt, struct dentry *dentry)
691 struct mount *p;
700 * lookup_mnt - Return the first child mount mounted at path
705 * mount /dev/sda1 /mnt
706 * mount /dev/sda2 /mnt
707 * mount /dev/sda3 /mnt
709 * Then lookup_mnt() on the base /mnt dentry in the root mount will
717 struct mount *child_mnt;
741 static inline bool mnt_is_cursor(struct mount *mnt)
748 * current mount namespace.
753 * mounts in the current mount namespace and test to see if the dentry
757 * need to identify all mounts that may be in the current mount
758 * namespace not just a mount that happens to have some specified
759 * parent mount.
764 struct mount *mnt;
870 static inline int check_mnt(struct mount *mnt)
900 static struct mountpoint *unhash_mnt(struct mount *mnt)
916 static void umount_mnt(struct mount *mnt)
924 void mnt_set_mountpoint(struct mount *mnt,
926 struct mount *child_mnt)
937 * mnt_set_mountpoint_beneath - mount a mount beneath another one
939 * @new_parent: the source mount
940 * @top_mnt: the mount beneath which @new_parent is mounted
944 * parent @top_mnt->mnt_parent and mount it on top of @new_parent at
945 * @new_mp. And mount @new_parent on the old parent and old
951 static void mnt_set_mountpoint_beneath(struct mount *new_parent,
952 struct mount *top_mnt,
955 struct mount *old_top_parent = top_mnt->mnt_parent;
963 static void __attach_mnt(struct mount *mnt, struct mount *parent)
971 * attach_mnt - mount a mount, attach to @mount_hashtable and parent's
974 * @mnt: the new mount
976 * @beneath: whether to mount @mnt beneath or on top of @parent
978 * If @beneath is false, mount @mnt at @mp on @parent. Then attach @mnt
979 * to @parent's child mount list and to @mount_hashtable.
982 * mountpoint and mount it on @mp on @parent, and mount @parent on the
992 static void attach_mnt(struct mount *mnt, struct mount *parent,
1003 * isn't the same mount as @parent.
1008 void mnt_change_mountpoint(struct mount *parent, struct mountpoint *mp, struct mount *mnt)
1011 struct mount *old_parent = mnt->mnt_parent;
1026 static void commit_tree(struct mount *mnt)
1028 struct mount *parent = mnt->mnt_parent;
1029 struct mount *m;
1048 static struct mount *next_mnt(struct mount *p, struct mount *root)
1061 return list_entry(next, struct mount, mnt_child);
1064 static struct mount *skip_mnt_tree(struct mount *p)
1068 p = list_entry(prev, struct mount, mnt_child);
1075 * vfs_create_mount - Create a mount for a configured superblock
1078 * Create a mount to an already configured superblock. If necessary, the
1081 * Note that this does not attach the mount to anything.
1085 struct mount *mnt;
1156 * through from the parent mount to the submount don't support
1166 static struct mount *clone_mnt(struct mount *old, struct dentry *root,
1170 struct mount *mnt;
1219 /* stick the duplicate mount on the same expiry list
1234 static void cleanup_mnt(struct mount *mnt)
1237 struct mount *m;
1261 cleanup_mnt(container_of(head, struct mount, mnt_rcu));
1268 struct mount *m, *t;
1275 static void mntput_no_expire(struct mount *mnt)
1320 struct mount *p, *tmp;
1346 struct mount *m = real_mount(mnt);
1364 * Make a mount point inaccessible to new lookups.
1366 * for an RCU grace period before destroying the mount point.
1375 * path_is_mountpoint() - Check if path is a mount in the current namespace.
1406 struct mount *p;
1415 static struct mount *mnt_list_next(struct mnt_namespace *ns,
1418 struct mount *mnt, *ret = NULL;
1456 struct mount *mnt = v;
1465 struct mount *mnt = v;
1479 struct mount *r = v;
1490 void mnt_cursor_del(struct mnt_namespace *ns, struct mount *cursor)
1501 * may_umount_tree - check if a mount tree is busy
1502 * @m: root of mount tree
1510 struct mount *mnt = real_mount(m);
1513 struct mount *p;
1533 * may_umount - check if a mount point is busy
1534 * @mnt: root of mount
1536 * This is called to check if a mount point has any
1538 * mount has sub mounts this will return busy
1563 struct mount *m;
1595 static bool disconnect_mount(struct mount *mnt, enum umount_tree_flags how)
1601 /* A mount without a parent has nothing to be connected to */
1612 /* Has it been requested that the mount remain connected? */
1616 /* Is the mount locked such that it needs to remain connected? */
1620 /* By default disconnect the mount */
1628 static void umount_tree(struct mount *mnt, enum umount_tree_flags how)
1631 struct mount *p;
1654 p = list_first_entry(&tmp_list, struct mount, mnt_list);
1682 static void shrink_submounts(struct mount *mnt);
1707 static int do_umount(struct mount *mnt, int flags)
1744 * mount, and they will themselves hold resources we must
1748 * must return, and the like. Thats for the mount program to worry
1807 * to an existing mountpoint, and wind up leaking the mount.
1816 struct mount *mnt;
1826 mnt = hlist_entry(mp->m_list.first, struct mount, mnt_mp_list);
1851 * Determine whether @path refers to the root of a mount.
1853 * Return: true if @path is the root of a mount, false if not.
1863 "WARNING: The mand mount option has been deprecated and\n"
1865 " option from the mount to silence this warning.\n"
1871 struct mount *mnt = real_mount(path->mnt);
1889 struct mount *mnt = real_mount(path->mnt);
1939 /* Is this a proxy for a mount namespace? */
1956 /* Could bind mounting the mount namespace inode cause a
1957 * mount namespace loop?
1967 struct mount *copy_tree(struct mount *mnt, struct dentry *dentry,
1970 struct mount *res, *p, *q, *r, *parent;
1986 struct mount *s;
2036 struct mount *tree;
2079 static bool has_locked_children(struct mount *mnt, struct dentry *dentry)
2081 struct mount *child;
2097 * This creates a new vfsmount, which will be the clone of @path. The new mount
2099 * changes to the originating mount won't be propagated into this).
2105 struct mount *old_mnt = real_mount(path->mnt);
2106 struct mount *new_mnt;
2124 /* Longterm mount to be removed by kern_unmount*() */
2138 struct mount *mnt;
2150 static void lock_mnt_tree(struct mount *mnt)
2152 struct mount *p;
2156 /* Don't allow unprivileged users to change mount flags */
2170 /* Don't allow unprivileged users to reveal what is under a mount */
2177 static void cleanup_group_ids(struct mount *mnt, struct mount *end)
2179 struct mount *p;
2187 static int invent_group_ids(struct mount *mnt, bool recurse)
2189 struct mount *p;
2204 int count_mounts(struct mnt_namespace *ns, struct mount *mnt)
2208 struct mount *p;
2233 * attach_recursive_mnt - attach a source mount tree
2234 * @source_mnt: mount tree to be attached
2235 * @top_mnt: mount that @source_mnt will be mounted on or mounted beneath
2239 * NOTE: in the table below explains the semantics when a source mount
2240 * of a given type is attached to a destination mount of a given type.
2253 * A bind operation clones the source mount and mounts the clone on the
2254 * destination mount.
2256 * (++) the cloned mount is propagated to all the mounts in the propagation
2257 * tree of the destination mount and the cloned mount is added to
2258 * the peer group of the source mount.
2259 * (+) the cloned mount is created under the destination mount and is marked
2260 * as shared. The cloned mount is added to the peer group of the source
2261 * mount.
2262 * (+++) the mount is propagated to all the mounts in the propagation tree
2263 * of the destination mount and the cloned mount is made slave
2264 * of the same master as that of the source mount. The cloned mount
2266 * (*) the cloned mount is made a slave of the same master as that of the
2267 * source mount.
2282 * (+) the mount is moved to the destination. And is then propagated to
2283 * all the mounts in the propagation tree of the destination mount.
2284 * (+*) the mount is moved to the destination.
2285 * (+++) the mount is moved to the destination and is then propagated to
2286 * all the mounts belonging to the destination mount's propagation tree.
2287 * the mount is marked as 'shared and slave'.
2288 * (*) the mount continues to be a slave at the new location.
2290 * if the source mount is a tree, the operations explained above is
2291 * applied to each mount in the tree.
2299 static int attach_recursive_mnt(struct mount *source_mnt,
2300 struct mount *top_mnt,
2308 struct mount *child, *dest_mnt, *p;
2321 /* Is there space to add these mounts to the mount namespace? */
2367 struct mount *q;
2386 child = hlist_entry(tree_list.first, struct mount, mnt_hash);
2403 * do_lock_mount - lock mount and mountpoint
2405 * @beneath: whether the intention is to mount beneath @path
2407 * Follow the mount stack on @path until the top mount @mnt is found. If
2409 * mount stacked on top of it. Then simply follow @{mnt,mnt->mnt_root}
2412 * Acquire the inode_lock() on the top mount's ->mnt_root to protect
2413 * against concurrent removal of the new mountpoint from another mount
2418 * concurrent unlink of @mp->mnt_dentry from another mount namespace
2419 * where @mnt doesn't have a child mount mounted @mp. A concurrent
2433 * Return: Either the target mountpoint on the top mount or the top
2434 * mount's mountpoint.
2443 struct mount *m;
2511 static int graft_tree(struct mount *mnt, struct mount *p, struct mountpoint *mp)
2545 struct mount *m;
2546 struct mount *mnt = real_mount(path->mnt);
2575 static struct mount *__do_loopback(struct path *old_path, int recurse)
2577 struct mount *mnt = ERR_PTR(-EINVAL), *old = real_mount(old_path->mnt);
2600 * do loopback mount.
2606 struct mount *mnt = NULL, *parent;
2652 struct mount *mnt, *p;
2739 * Don't allow locked mount flags to be cleared.
2744 static bool can_change_locked_flags(struct mount *mnt, unsigned int mnt_flags)
2771 static int change_mount_ro_state(struct mount *mnt, unsigned int mnt_flags)
2785 static void set_mount_attributes(struct mount *mnt, unsigned int mnt_flags)
2816 * to mount(2).
2821 struct mount *mnt = real_mount(path->mnt);
2860 struct mount *mnt = real_mount(path->mnt);
2878 * from the legacy mount system call.
2903 static inline int tree_contains_unbindable(struct mount *mnt)
2905 struct mount *p;
2914 * Check that there aren't references to earlier/same mount namespaces in the
2915 * specified subtree. Such references can act as pins for mount namespaces
2916 * that aren't checked by the mount-cycle checking code, thereby allowing
2919 static bool check_for_nsfs_mounts(struct mount *subtree)
2921 struct mount *p;
2937 struct mount *from, *to;
2953 /* We should be allowed to modify mount namespaces of both mounts */
2960 /* To and From paths should be mount roots */
2970 /* From mount root should be wider than To mount root */
2974 /* From mount should not have locked children in place of To's root */
2987 struct mount *m = from->mnt_master;
3011 * Check if path is overmounted, i.e., if there's a mount on top of
3029 * can_move_mount_beneath - check that we can mount beneath the top mount
3030 * @from: mount to mount beneath
3031 * @to: mount under which to mount
3033 * - Make sure that @to->dentry is actually the root of a mount under
3034 * which we can mount another mount.
3037 * - Make sure that the caller can unmount the topmost mount ensuring
3041 * - Prevent mounting beneath a mount if the propagation relationship
3042 * between the source mount, parent mount, and top mount would lead to
3043 * nonsensical mount trees.
3052 struct mount *mnt_from = real_mount(from->mnt),
3065 /* Avoid creating shadow mounts during mount propagation. */
3078 for (struct mount *p = mnt_from; mnt_has_parent(p); p = p->mnt_parent)
3083 * If the parent mount propagates to the child mount this would
3086 * defeats the whole purpose of mounting beneath another mount.
3113 struct mount *p;
3114 struct mount *old;
3115 struct mount *parent;
3157 * Don't move a mount residing in a shared parent.
3173 * Don't move a mount tree containing unbindable mounts to a destination
3174 * mount which is shared.
3189 /* if the mount is moved, it should no longer be expire
3223 * add a mount into a namespace's mount tree
3225 static int do_add_mount(struct mount *newmnt, struct mountpoint *mp,
3228 struct mount *parent = real_mount(path->mnt);
3241 /* Refuse the same filesystem on the same mount point */
3255 * Create a new mount using a superblock configuration and request it
3296 * create a new mount for userspace and request it to be added into the
3331 * Indicate to the filesystem that the mount request is coming
3332 * from the legacy mount system call.
3358 struct mount *mnt;
3367 /* The new mount record should have at least 2 refs to prevent it being
3381 * got", not "try to mount it on top".
3422 * mnt_set_expiry - Put a mount on an expiration list
3423 * @mnt: The mount to list.
3424 * @expiry_list: The list to add the mount to.
3443 struct mount *mnt, *next;
3465 mnt = list_first_entry(&graveyard, struct mount, mnt_expire);
3481 static int select_submounts(struct mount *parent, struct list_head *graveyard)
3483 struct mount *this_parent = parent;
3492 struct mount *mnt = list_entry(tmp, struct mount, mnt_child);
3527 static void shrink_submounts(struct mount *mnt)
3530 struct mount *m;
3535 m = list_first_entry(&graveyard, struct mount,
3586 * be given to the mount() call (ie: read-only, no-dev, no-suid etc).
3592 * Pre-0.97 versions of mount() didn't have a flags word.
3712 * mount a reference to an older mount namespace into the current
3713 * mount namespace, preventing reference counting loops. A 64bit
3760 struct mount *p, *q;
3761 struct mount *old;
3762 struct mount *new;
3837 struct mount *mnt = real_mount(m);
3872 SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
3937 * Create a kernel mount representation for a new, prepared superblock
3947 struct mount *mnt;
3990 /* There must be a valid superblock or we can't mount it */
4016 /* We've done the mount bit - now move the file context into more or
4062 * Move a mount from one place to another. In combination with
4063 * fsopen()/fsmount() this is used to install a new mount and in combination
4065 * a mount subtree.
4132 bool is_path_reachable(struct mount *mnt, struct dentry *dentry,
4173 * /nfs/my_root where /nfs is the mount point. It must be a mountpoint,
4174 * though, so you may need to say mount --bind /nfs/my_root /nfs/my_root
4181 struct mount *new_mnt, *root_mnt, *old_mnt, *root_parent, *ex_parent;
4250 /* mount old root on put_old */
4252 /* mount new_root on / */
4256 /* A moved mount should not expire automatically */
4276 static unsigned int recalc_flags(struct mount_kattr *kattr, struct mount *mnt)
4288 static int can_idmap_mount(const struct mount_kattr *kattr, struct mount *mnt)
4297 * Creating an idmapped mount with the filesystem wide idmapping
4304 * Once a mount has been idmapped we don't allow it to change its
4306 * another bind-mount they can idmap if they want to.
4328 * @kattr: the new mount attributes
4329 * @mnt: the mount to which @kattr will be applied
4331 * Check whether thew new mount attributes in @kattr allow concurrent writers.
4336 const struct mount *mnt)
4343 static int mount_setattr_prepare(struct mount_kattr *kattr, struct mount *mnt)
4345 struct mount *m;
4369 struct mount *p;
4374 * mounts and needs to take care to include the first mount.
4382 * We're done once the first mount we changed got
4392 static void do_idmap_mount(const struct mount_kattr *kattr, struct mount *mnt)
4400 * Since we only allow a mount to change the idmapping once and
4401 * verified this in can_idmap_mount() we know that the mount has
4408 static void mount_setattr_commit(struct mount_kattr *kattr, struct mount *mnt)
4410 struct mount *m;
4433 struct mount *mnt = real_mount(path->mnt);
4471 * If this is an attached mount make sure it's located in the callers
4472 * mount namespace. If it's not don't let the caller interact with it.
4474 * If this mount doesn't have a parent it's most often simply a
4475 * detached mount with an anonymous mount namespace. IOW, something
4477 * that do change mount properties on the rootfs itself. That obviously
4478 * neither has a parent nor is it a detached mount so we cannot
4485 * First, we get the mount tree in a shape where we can change mount
4517 * We currently do not support clearing an idmapped mount. If this ever
4544 * mount. We use the initial idmapping as an indicator of a mount
4696 struct mount *m;
4727 mnt_cache = kmem_cache_create("mnt_cache", sizeof(struct mount),
4742 panic("Failed to allocate mount hash table\n");
4772 * it is a longterm mount, don't release mnt until
4783 /* release long term mount so mount point can be released */
4838 struct mount *mnt;
4844 struct mount *child;
4853 /* This mount is not fully visible if it's root directory
4859 /* A local view of the mount flags */
4866 /* Verify the mount flags are equal to or more permissive
4867 * than the proposed new mount.
4876 /* This mount is not fully visible if there are any
5020 .procname = "mount-max",