Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\namespace.c Create Date:2022-07-28 20:09:20
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:copy_mnt_ns

Proto:struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns, struct user_namespace *user_ns, struct fs_struct *new_fs)

Type:struct mnt_namespace

Parameter:

TypeParameterName
unsigned longflags
struct mnt_namespace *ns
struct user_namespace *user_ns
struct fs_struct *new_fs
3216  struct vfsmount * rootmnt = NULL, * pwdmnt = NULL
3222  BUG_ON(!ns)
3224  If Value is more likely to compile time(!(flags & New mount namespace group )) Then
3225  get_mnt_ns(ns)
3226  Return ns
3229  old = root
3231  new_ns = alloc_mnt_ns(user_ns, false)
3232  If IS_ERR(new_ns) Then Return new_ns
3235  namespace_lock()
3237  copy_flags = CL_COPY_UNBINDABLE | CL_EXPIRE
3238  If user_ns != user_ns Then copy_flags |= CL_SHARED_TO_SLAVE
3240  new = copy_tree(old, root of the mounted tree , copy_flags)
3241  If IS_ERR(new) Then
3242  namespace_unlock()
3243  free_mnt_ns(new_ns)
3244  Return ERR_CAST - Explicitly cast an error-valued pointer to another pointer type*@ptr: The pointer to cast.* Explicitly cast an error-valued pointer to another pointer type in such a* way as to make it clear that's what's going on.
3246  If user_ns != user_ns Then
3247  lock_mount_hash()
3248  lock_mnt_tree(new)
3249  unlock_mount_hash()
3251  root = new
3252  list_add_tail - add a new entry*@new: new entry to be added*@head: list head to add it before* Insert a new entry before the specified head.* This is useful for implementing queues.
3259  p = old
3260  q = new
3261  When p cycle
3262  containing namespace = new_ns
3263  # of mounts in the namespace ++
3264  If new_fs Then
3265  If mnt == mnt Then
3266  mnt = mntget( & mnt)
3267  rootmnt = mnt
3269  If mnt == mnt Then
3270  mnt = mntget( & mnt)
3271  pwdmnt = mnt
3274  p = next_mnt(p, old)
3275  q = next_mnt(q, new)
3276  If Not q Then Break
3278  When root of the mounted tree != root of the mounted tree cycle
3279  p = next_mnt(p, old)
3281  namespace_unlock()
3283  If rootmnt Then mntput(rootmnt)
3285  If pwdmnt Then mntput(pwdmnt)
3288  Return new_ns