Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mnt: expose pointer to init_mnt_ns

There's various scenarios where we need to know whether we are in the
initial set of namespaces or not to e.g., shortcut permission checking.
All namespaces expose that information. Let's do that too.

Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>

+18 -11
+16 -11
fs/namespace.c
··· 6008 6008 return ret; 6009 6009 } 6010 6010 6011 + struct mnt_namespace init_mnt_ns = { 6012 + .ns.inum = PROC_MNT_INIT_INO, 6013 + .ns.ops = &mntns_operations, 6014 + .user_ns = &init_user_ns, 6015 + .ns.count = REFCOUNT_INIT(1), 6016 + .passive = REFCOUNT_INIT(1), 6017 + .mounts = RB_ROOT, 6018 + .poll = __WAIT_QUEUE_HEAD_INITIALIZER(init_mnt_ns.poll), 6019 + }; 6020 + 6011 6021 static void __init init_mount_tree(void) 6012 6022 { 6013 6023 struct vfsmount *mnt; 6014 6024 struct mount *m; 6015 - struct mnt_namespace *ns; 6016 6025 struct path root; 6017 6026 6018 6027 mnt = vfs_kern_mount(&rootfs_fs_type, 0, "rootfs", NULL); 6019 6028 if (IS_ERR(mnt)) 6020 6029 panic("Can't create rootfs"); 6021 6030 6022 - ns = alloc_mnt_ns(&init_user_ns, true); 6023 - if (IS_ERR(ns)) 6024 - panic("Can't allocate initial namespace"); 6025 - ns->ns.inum = PROC_MNT_INIT_INO; 6026 6031 m = real_mount(mnt); 6027 - ns->root = m; 6028 - ns->nr_mounts = 1; 6029 - mnt_add_to_ns(ns, m); 6030 - init_task.nsproxy->mnt_ns = ns; 6031 - get_mnt_ns(ns); 6032 + init_mnt_ns.root = m; 6033 + init_mnt_ns.nr_mounts = 1; 6034 + mnt_add_to_ns(&init_mnt_ns, m); 6035 + init_task.nsproxy->mnt_ns = &init_mnt_ns; 6036 + get_mnt_ns(&init_mnt_ns); 6032 6037 6033 6038 root.mnt = mnt; 6034 6039 root.dentry = mnt->mnt_root; ··· 6041 6036 set_fs_pwd(current->fs, &root); 6042 6037 set_fs_root(current->fs, &root); 6043 6038 6044 - ns_tree_add(ns); 6039 + ns_tree_add(&init_mnt_ns); 6045 6040 } 6046 6041 6047 6042 void __init mnt_init(void)
+2
include/linux/mnt_namespace.h
··· 11 11 struct user_namespace; 12 12 struct ns_common; 13 13 14 + extern struct mnt_namespace init_mnt_ns; 15 + 14 16 extern struct mnt_namespace *copy_mnt_ns(unsigned long, struct mnt_namespace *, 15 17 struct user_namespace *, struct fs_struct *); 16 18 extern void put_mnt_ns(struct mnt_namespace *ns);