namespace.c (58be28256d98a6b996b20f49130ea11afb8de75a) namespace.c (64964528b24ea390824f0e5ce9d34b8d39b28cde)
1/*
2 * linux/fs/namespace.c
3 *
4 * (C) Copyright Al Viro 2000, 2001
5 * Released under GPL v2.
6 *
7 * Based on code from fs/super.c, copyright Linus Torvalds and others.
8 * Heavily rewritten.

--- 3135 unchanged lines hidden (view full) ---

3144 goto found;
3145 next: ;
3146 }
3147found:
3148 up_read(&namespace_sem);
3149 return visible;
3150}
3151
1/*
2 * linux/fs/namespace.c
3 *
4 * (C) Copyright Al Viro 2000, 2001
5 * Released under GPL v2.
6 *
7 * Based on code from fs/super.c, copyright Linus Torvalds and others.
8 * Heavily rewritten.

--- 3135 unchanged lines hidden (view full) ---

3144 goto found;
3145 next: ;
3146 }
3147found:
3148 up_read(&namespace_sem);
3149 return visible;
3150}
3151
3152static void *mntns_get(struct task_struct *task)
3152static struct ns_common *mntns_get(struct task_struct *task)
3153{
3154 struct ns_common *ns = NULL;
3155 struct nsproxy *nsproxy;
3156
3157 task_lock(task);
3158 nsproxy = task->nsproxy;
3159 if (nsproxy) {
3160 ns = &nsproxy->mnt_ns->ns;
3161 get_mnt_ns(to_mnt_ns(ns));
3162 }
3163 task_unlock(task);
3164
3165 return ns;
3166}
3167
3153{
3154 struct ns_common *ns = NULL;
3155 struct nsproxy *nsproxy;
3156
3157 task_lock(task);
3158 nsproxy = task->nsproxy;
3159 if (nsproxy) {
3160 ns = &nsproxy->mnt_ns->ns;
3161 get_mnt_ns(to_mnt_ns(ns));
3162 }
3163 task_unlock(task);
3164
3165 return ns;
3166}
3167
3168static void mntns_put(void *ns)
3168static void mntns_put(struct ns_common *ns)
3169{
3170 put_mnt_ns(to_mnt_ns(ns));
3171}
3172
3169{
3170 put_mnt_ns(to_mnt_ns(ns));
3171}
3172
3173static int mntns_install(struct nsproxy *nsproxy, void *ns)
3173static int mntns_install(struct nsproxy *nsproxy, struct ns_common *ns)
3174{
3175 struct fs_struct *fs = current->fs;
3176 struct mnt_namespace *mnt_ns = to_mnt_ns(ns);
3177 struct path root;
3178
3179 if (!ns_capable(mnt_ns->user_ns, CAP_SYS_ADMIN) ||
3180 !ns_capable(current_user_ns(), CAP_SYS_CHROOT) ||
3181 !ns_capable(current_user_ns(), CAP_SYS_ADMIN))

--- 16 unchanged lines hidden (view full) ---

3198 /* Update the pwd and root */
3199 set_fs_pwd(fs, &root);
3200 set_fs_root(fs, &root);
3201
3202 path_put(&root);
3203 return 0;
3204}
3205
3174{
3175 struct fs_struct *fs = current->fs;
3176 struct mnt_namespace *mnt_ns = to_mnt_ns(ns);
3177 struct path root;
3178
3179 if (!ns_capable(mnt_ns->user_ns, CAP_SYS_ADMIN) ||
3180 !ns_capable(current_user_ns(), CAP_SYS_CHROOT) ||
3181 !ns_capable(current_user_ns(), CAP_SYS_ADMIN))

--- 16 unchanged lines hidden (view full) ---

3198 /* Update the pwd and root */
3199 set_fs_pwd(fs, &root);
3200 set_fs_root(fs, &root);
3201
3202 path_put(&root);
3203 return 0;
3204}
3205
3206static unsigned int mntns_inum(void *ns)
3207{
3208 struct ns_common *p = ns;
3209 return p->inum;
3210}
3211
3212const struct proc_ns_operations mntns_operations = {
3213 .name = "mnt",
3214 .type = CLONE_NEWNS,
3215 .get = mntns_get,
3216 .put = mntns_put,
3217 .install = mntns_install,
3206const struct proc_ns_operations mntns_operations = {
3207 .name = "mnt",
3208 .type = CLONE_NEWNS,
3209 .get = mntns_get,
3210 .put = mntns_put,
3211 .install = mntns_install,
3218 .inum = mntns_inum,
3219};
3212};