aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKirill Korotaev <dev@sw.ru>2006-12-08 05:37:56 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-08 11:28:51 -0500
commit6b3286ed1169d74fea401367d6d4d6c6ec758a81 (patch)
treefaf5beddb797875bb92855f8606735478267959a
parent1ec320afdc9552c92191d5f89fcd1ebe588334ca (diff)
[PATCH] rename struct namespace to struct mnt_namespace
Rename 'struct namespace' to 'struct mnt_namespace' to avoid confusion with other namespaces being developped for the containers : pid, uts, ipc, etc. 'namespace' variables and attributes are also renamed to 'mnt_ns' Signed-off-by: Kirill Korotaev <dev@sw.ru> Signed-off-by: Cedric Le Goater <clg@fr.ibm.com> Cc: Eric W. Biederman <ebiederm@xmission.com> Cc: Herbert Poetzl <herbert@13thfloor.at> Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--fs/afs/mntpt.c2
-rw-r--r--fs/namespace.c113
-rw-r--r--fs/nfs/getroot.c2
-rw-r--r--fs/pnode.c2
-rw-r--r--fs/pnode.h2
-rw-r--r--fs/proc/base.c36
-rw-r--r--fs/reiserfs/super.c2
-rw-r--r--include/linux/init_task.h2
-rw-r--r--include/linux/mnt_namespace.h42
-rw-r--r--include/linux/mount.h4
-rw-r--r--include/linux/namespace.h42
-rw-r--r--include/linux/nsproxy.h4
-rw-r--r--kernel/exit.c2
-rw-r--r--kernel/fork.c21
-rw-r--r--kernel/kmod.c2
-rw-r--r--kernel/nsproxy.c16
16 files changed, 148 insertions, 146 deletions
diff --git a/fs/afs/mntpt.c b/fs/afs/mntpt.c
index f33b1a81a761..8f74e8450826 100644
--- a/fs/afs/mntpt.c
+++ b/fs/afs/mntpt.c
@@ -18,7 +18,7 @@
18#include <linux/pagemap.h> 18#include <linux/pagemap.h>
19#include <linux/mount.h> 19#include <linux/mount.h>
20#include <linux/namei.h> 20#include <linux/namei.h>
21#include <linux/namespace.h> 21#include <linux/mnt_namespace.h>
22#include "super.h" 22#include "super.h"
23#include "cell.h" 23#include "cell.h"
24#include "volume.h" 24#include "volume.h"
diff --git a/fs/namespace.c b/fs/namespace.c
index b00ac84ebbdd..fde8553faa76 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -20,7 +20,7 @@
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/sysfs.h> 21#include <linux/sysfs.h>
22#include <linux/seq_file.h> 22#include <linux/seq_file.h>
23#include <linux/namespace.h> 23#include <linux/mnt_namespace.h>
24#include <linux/namei.h> 24#include <linux/namei.h>
25#include <linux/security.h> 25#include <linux/security.h>
26#include <linux/mount.h> 26#include <linux/mount.h>
@@ -133,10 +133,10 @@ struct vfsmount *lookup_mnt(struct vfsmount *mnt, struct dentry *dentry)
133 133
134static inline int check_mnt(struct vfsmount *mnt) 134static inline int check_mnt(struct vfsmount *mnt)
135{ 135{
136 return mnt->mnt_namespace == current->nsproxy->namespace; 136 return mnt->mnt_ns == current->nsproxy->mnt_ns;
137} 137}
138 138
139static void touch_namespace(struct namespace *ns) 139static void touch_mnt_namespace(struct mnt_namespace *ns)
140{ 140{
141 if (ns) { 141 if (ns) {
142 ns->event = ++event; 142 ns->event = ++event;
@@ -144,7 +144,7 @@ static void touch_namespace(struct namespace *ns)
144 } 144 }
145} 145}
146 146
147static void __touch_namespace(struct namespace *ns) 147static void __touch_mnt_namespace(struct mnt_namespace *ns)
148{ 148{
149 if (ns && ns->event != event) { 149 if (ns && ns->event != event) {
150 ns->event = event; 150 ns->event = event;
@@ -187,19 +187,19 @@ static void commit_tree(struct vfsmount *mnt)
187 struct vfsmount *parent = mnt->mnt_parent; 187 struct vfsmount *parent = mnt->mnt_parent;
188 struct vfsmount *m; 188 struct vfsmount *m;
189 LIST_HEAD(head); 189 LIST_HEAD(head);
190 struct namespace *n = parent->mnt_namespace; 190 struct mnt_namespace *n = parent->mnt_ns;
191 191
192 BUG_ON(parent == mnt); 192 BUG_ON(parent == mnt);
193 193
194 list_add_tail(&head, &mnt->mnt_list); 194 list_add_tail(&head, &mnt->mnt_list);
195 list_for_each_entry(m, &head, mnt_list) 195 list_for_each_entry(m, &head, mnt_list)
196 m->mnt_namespace = n; 196 m->mnt_ns = n;
197 list_splice(&head, n->list.prev); 197 list_splice(&head, n->list.prev);
198 198
199 list_add_tail(&mnt->mnt_hash, mount_hashtable + 199 list_add_tail(&mnt->mnt_hash, mount_hashtable +
200 hash(parent, mnt->mnt_mountpoint)); 200 hash(parent, mnt->mnt_mountpoint));
201 list_add_tail(&mnt->mnt_child, &parent->mnt_mounts); 201 list_add_tail(&mnt->mnt_child, &parent->mnt_mounts);
202 touch_namespace(n); 202 touch_mnt_namespace(n);
203} 203}
204 204
205static struct vfsmount *next_mnt(struct vfsmount *p, struct vfsmount *root) 205static struct vfsmount *next_mnt(struct vfsmount *p, struct vfsmount *root)
@@ -320,7 +320,7 @@ EXPORT_SYMBOL(mnt_unpin);
320/* iterator */ 320/* iterator */
321static void *m_start(struct seq_file *m, loff_t *pos) 321static void *m_start(struct seq_file *m, loff_t *pos)
322{ 322{
323 struct namespace *n = m->private; 323 struct mnt_namespace *n = m->private;
324 struct list_head *p; 324 struct list_head *p;
325 loff_t l = *pos; 325 loff_t l = *pos;
326 326
@@ -333,7 +333,7 @@ static void *m_start(struct seq_file *m, loff_t *pos)
333 333
334static void *m_next(struct seq_file *m, void *v, loff_t *pos) 334static void *m_next(struct seq_file *m, void *v, loff_t *pos)
335{ 335{
336 struct namespace *n = m->private; 336 struct mnt_namespace *n = m->private;
337 struct list_head *p = ((struct vfsmount *)v)->mnt_list.next; 337 struct list_head *p = ((struct vfsmount *)v)->mnt_list.next;
338 (*pos)++; 338 (*pos)++;
339 return p == &n->list ? NULL : list_entry(p, struct vfsmount, mnt_list); 339 return p == &n->list ? NULL : list_entry(p, struct vfsmount, mnt_list);
@@ -526,8 +526,8 @@ void umount_tree(struct vfsmount *mnt, int propagate, struct list_head *kill)
526 list_for_each_entry(p, kill, mnt_hash) { 526 list_for_each_entry(p, kill, mnt_hash) {
527 list_del_init(&p->mnt_expire); 527 list_del_init(&p->mnt_expire);
528 list_del_init(&p->mnt_list); 528 list_del_init(&p->mnt_list);
529 __touch_namespace(p->mnt_namespace); 529 __touch_mnt_namespace(p->mnt_ns);
530 p->mnt_namespace = NULL; 530 p->mnt_ns = NULL;
531 list_del_init(&p->mnt_child); 531 list_del_init(&p->mnt_child);
532 if (p->mnt_parent != p) 532 if (p->mnt_parent != p)
533 p->mnt_mountpoint->d_mounted--; 533 p->mnt_mountpoint->d_mounted--;
@@ -830,7 +830,7 @@ static int attach_recursive_mnt(struct vfsmount *source_mnt,
830 if (parent_nd) { 830 if (parent_nd) {
831 detach_mnt(source_mnt, parent_nd); 831 detach_mnt(source_mnt, parent_nd);
832 attach_mnt(source_mnt, nd); 832 attach_mnt(source_mnt, nd);
833 touch_namespace(current->nsproxy->namespace); 833 touch_mnt_namespace(current->nsproxy->mnt_ns);
834 } else { 834 } else {
835 mnt_set_mountpoint(dest_mnt, dest_dentry, source_mnt); 835 mnt_set_mountpoint(dest_mnt, dest_dentry, source_mnt);
836 commit_tree(source_mnt); 836 commit_tree(source_mnt);
@@ -1145,9 +1145,9 @@ static void expire_mount(struct vfsmount *mnt, struct list_head *mounts,
1145 */ 1145 */
1146 if (!propagate_mount_busy(mnt, 2)) { 1146 if (!propagate_mount_busy(mnt, 2)) {
1147 /* delete from the namespace */ 1147 /* delete from the namespace */
1148 touch_namespace(mnt->mnt_namespace); 1148 touch_mnt_namespace(mnt->mnt_ns);
1149 list_del_init(&mnt->mnt_list); 1149 list_del_init(&mnt->mnt_list);
1150 mnt->mnt_namespace = NULL; 1150 mnt->mnt_ns = NULL;
1151 umount_tree(mnt, 1, umounts); 1151 umount_tree(mnt, 1, umounts);
1152 spin_unlock(&vfsmount_lock); 1152 spin_unlock(&vfsmount_lock);
1153 } else { 1153 } else {
@@ -1168,7 +1168,7 @@ static void expire_mount(struct vfsmount *mnt, struct list_head *mounts,
1168 */ 1168 */
1169static void expire_mount_list(struct list_head *graveyard, struct list_head *mounts) 1169static void expire_mount_list(struct list_head *graveyard, struct list_head *mounts)
1170{ 1170{
1171 struct namespace *namespace; 1171 struct mnt_namespace *ns;
1172 struct vfsmount *mnt; 1172 struct vfsmount *mnt;
1173 1173
1174 while (!list_empty(graveyard)) { 1174 while (!list_empty(graveyard)) {
@@ -1178,10 +1178,10 @@ static void expire_mount_list(struct list_head *graveyard, struct list_head *mou
1178 1178
1179 /* don't do anything if the namespace is dead - all the 1179 /* don't do anything if the namespace is dead - all the
1180 * vfsmounts from it are going away anyway */ 1180 * vfsmounts from it are going away anyway */
1181 namespace = mnt->mnt_namespace; 1181 ns = mnt->mnt_ns;
1182 if (!namespace || !namespace->root) 1182 if (!ns || !ns->root)
1183 continue; 1183 continue;
1184 get_namespace(namespace); 1184 get_mnt_ns(ns);
1185 1185
1186 spin_unlock(&vfsmount_lock); 1186 spin_unlock(&vfsmount_lock);
1187 down_write(&namespace_sem); 1187 down_write(&namespace_sem);
@@ -1189,7 +1189,7 @@ static void expire_mount_list(struct list_head *graveyard, struct list_head *mou
1189 up_write(&namespace_sem); 1189 up_write(&namespace_sem);
1190 release_mounts(&umounts); 1190 release_mounts(&umounts);
1191 mntput(mnt); 1191 mntput(mnt);
1192 put_namespace(namespace); 1192 put_mnt_ns(ns);
1193 spin_lock(&vfsmount_lock); 1193 spin_lock(&vfsmount_lock);
1194 } 1194 }
1195} 1195}
@@ -1439,14 +1439,15 @@ dput_out:
1439 * Allocate a new namespace structure and populate it with contents 1439 * Allocate a new namespace structure and populate it with contents
1440 * copied from the namespace of the passed in task structure. 1440 * copied from the namespace of the passed in task structure.
1441 */ 1441 */
1442struct namespace *dup_namespace(struct task_struct *tsk, struct fs_struct *fs) 1442struct mnt_namespace *dup_mnt_ns(struct task_struct *tsk,
1443 struct fs_struct *fs)
1443{ 1444{
1444 struct namespace *namespace = tsk->nsproxy->namespace; 1445 struct mnt_namespace *mnt_ns = tsk->nsproxy->mnt_ns;
1445 struct namespace *new_ns; 1446 struct mnt_namespace *new_ns;
1446 struct vfsmount *rootmnt = NULL, *pwdmnt = NULL, *altrootmnt = NULL; 1447 struct vfsmount *rootmnt = NULL, *pwdmnt = NULL, *altrootmnt = NULL;
1447 struct vfsmount *p, *q; 1448 struct vfsmount *p, *q;
1448 1449
1449 new_ns = kmalloc(sizeof(struct namespace), GFP_KERNEL); 1450 new_ns = kmalloc(sizeof(struct mnt_namespace), GFP_KERNEL);
1450 if (!new_ns) 1451 if (!new_ns)
1451 return NULL; 1452 return NULL;
1452 1453
@@ -1457,7 +1458,7 @@ struct namespace *dup_namespace(struct task_struct *tsk, struct fs_struct *fs)
1457 1458
1458 down_write(&namespace_sem); 1459 down_write(&namespace_sem);
1459 /* First pass: copy the tree topology */ 1460 /* First pass: copy the tree topology */
1460 new_ns->root = copy_tree(namespace->root, namespace->root->mnt_root, 1461 new_ns->root = copy_tree(mnt_ns->root, mnt_ns->root->mnt_root,
1461 CL_COPY_ALL | CL_EXPIRE); 1462 CL_COPY_ALL | CL_EXPIRE);
1462 if (!new_ns->root) { 1463 if (!new_ns->root) {
1463 up_write(&namespace_sem); 1464 up_write(&namespace_sem);
@@ -1473,10 +1474,10 @@ struct namespace *dup_namespace(struct task_struct *tsk, struct fs_struct *fs)
1473 * as belonging to new namespace. We have already acquired a private 1474 * as belonging to new namespace. We have already acquired a private
1474 * fs_struct, so tsk->fs->lock is not needed. 1475 * fs_struct, so tsk->fs->lock is not needed.
1475 */ 1476 */
1476 p = namespace->root; 1477 p = mnt_ns->root;
1477 q = new_ns->root; 1478 q = new_ns->root;
1478 while (p) { 1479 while (p) {
1479 q->mnt_namespace = new_ns; 1480 q->mnt_ns = new_ns;
1480 if (fs) { 1481 if (fs) {
1481 if (p == fs->rootmnt) { 1482 if (p == fs->rootmnt) {
1482 rootmnt = p; 1483 rootmnt = p;
@@ -1491,7 +1492,7 @@ struct namespace *dup_namespace(struct task_struct *tsk, struct fs_struct *fs)
1491 fs->altrootmnt = mntget(q); 1492 fs->altrootmnt = mntget(q);
1492 } 1493 }
1493 } 1494 }
1494 p = next_mnt(p, namespace->root); 1495 p = next_mnt(p, mnt_ns->root);
1495 q = next_mnt(q, new_ns->root); 1496 q = next_mnt(q, new_ns->root);
1496 } 1497 }
1497 up_write(&namespace_sem); 1498 up_write(&namespace_sem);
@@ -1506,16 +1507,16 @@ struct namespace *dup_namespace(struct task_struct *tsk, struct fs_struct *fs)
1506 return new_ns; 1507 return new_ns;
1507} 1508}
1508 1509
1509int copy_namespace(int flags, struct task_struct *tsk) 1510int copy_mnt_ns(int flags, struct task_struct *tsk)
1510{ 1511{
1511 struct namespace *namespace = tsk->nsproxy->namespace; 1512 struct mnt_namespace *ns = tsk->nsproxy->mnt_ns;
1512 struct namespace *new_ns; 1513 struct mnt_namespace *new_ns;
1513 int err = 0; 1514 int err = 0;
1514 1515
1515 if (!namespace) 1516 if (!ns)
1516 return 0; 1517 return 0;
1517 1518
1518 get_namespace(namespace); 1519 get_mnt_ns(ns);
1519 1520
1520 if (!(flags & CLONE_NEWNS)) 1521 if (!(flags & CLONE_NEWNS))
1521 return 0; 1522 return 0;
@@ -1525,16 +1526,16 @@ int copy_namespace(int flags, struct task_struct *tsk)
1525 goto out; 1526 goto out;
1526 } 1527 }
1527 1528
1528 new_ns = dup_namespace(tsk, tsk->fs); 1529 new_ns = dup_mnt_ns(tsk, tsk->fs);
1529 if (!new_ns) { 1530 if (!new_ns) {
1530 err = -ENOMEM; 1531 err = -ENOMEM;
1531 goto out; 1532 goto out;
1532 } 1533 }
1533 1534
1534 tsk->nsproxy->namespace = new_ns; 1535 tsk->nsproxy->mnt_ns = new_ns;
1535 1536
1536out: 1537out:
1537 put_namespace(namespace); 1538 put_mnt_ns(ns);
1538 return err; 1539 return err;
1539} 1540}
1540 1541
@@ -1754,7 +1755,7 @@ asmlinkage long sys_pivot_root(const char __user * new_root,
1754 detach_mnt(user_nd.mnt, &root_parent); 1755 detach_mnt(user_nd.mnt, &root_parent);
1755 attach_mnt(user_nd.mnt, &old_nd); /* mount old root on put_old */ 1756 attach_mnt(user_nd.mnt, &old_nd); /* mount old root on put_old */
1756 attach_mnt(new_nd.mnt, &root_parent); /* mount new_root on / */ 1757 attach_mnt(new_nd.mnt, &root_parent); /* mount new_root on / */
1757 touch_namespace(current->nsproxy->namespace); 1758 touch_mnt_namespace(current->nsproxy->mnt_ns);
1758 spin_unlock(&vfsmount_lock); 1759 spin_unlock(&vfsmount_lock);
1759 chroot_fs_refs(&user_nd, &new_nd); 1760 chroot_fs_refs(&user_nd, &new_nd);
1760 security_sb_post_pivotroot(&user_nd, &new_nd); 1761 security_sb_post_pivotroot(&user_nd, &new_nd);
@@ -1779,27 +1780,27 @@ out3:
1779static void __init init_mount_tree(void) 1780static void __init init_mount_tree(void)
1780{ 1781{
1781 struct vfsmount *mnt; 1782 struct vfsmount *mnt;
1782 struct namespace *namespace; 1783 struct mnt_namespace *ns;
1783 1784
1784 mnt = do_kern_mount("rootfs", 0, "rootfs", NULL); 1785 mnt = do_kern_mount("rootfs", 0, "rootfs", NULL);
1785 if (IS_ERR(mnt)) 1786 if (IS_ERR(mnt))
1786 panic("Can't create rootfs"); 1787 panic("Can't create rootfs");
1787 namespace = kmalloc(sizeof(*namespace), GFP_KERNEL); 1788 ns = kmalloc(sizeof(*ns), GFP_KERNEL);
1788 if (!namespace) 1789 if (!ns)
1789 panic("Can't allocate initial namespace"); 1790 panic("Can't allocate initial namespace");
1790 atomic_set(&namespace->count, 1); 1791 atomic_set(&ns->count, 1);
1791 INIT_LIST_HEAD(&namespace->list); 1792 INIT_LIST_HEAD(&ns->list);
1792 init_waitqueue_head(&namespace->poll); 1793 init_waitqueue_head(&ns->poll);
1793 namespace->event = 0; 1794 ns->event = 0;
1794 list_add(&mnt->mnt_list, &namespace->list); 1795 list_add(&mnt->mnt_list, &ns->list);
1795 namespace->root = mnt; 1796 ns->root = mnt;
1796 mnt->mnt_namespace = namespace; 1797 mnt->mnt_ns = ns;
1797 1798
1798 init_task.nsproxy->namespace = namespace; 1799 init_task.nsproxy->mnt_ns = ns;
1799 get_namespace(namespace); 1800 get_mnt_ns(ns);
1800 1801
1801 set_fs_pwd(current->fs, namespace->root, namespace->root->mnt_root); 1802 set_fs_pwd(current->fs, ns->root, ns->root->mnt_root);
1802 set_fs_root(current->fs, namespace->root, namespace->root->mnt_root); 1803 set_fs_root(current->fs, ns->root, ns->root->mnt_root);
1803} 1804}
1804 1805
1805void __init mnt_init(unsigned long mempages) 1806void __init mnt_init(unsigned long mempages)
@@ -1860,11 +1861,11 @@ void __init mnt_init(unsigned long mempages)
1860 init_mount_tree(); 1861 init_mount_tree();
1861} 1862}
1862 1863
1863void __put_namespace(struct namespace *namespace) 1864void __put_mnt_ns(struct mnt_namespace *ns)
1864{ 1865{
1865 struct vfsmount *root = namespace->root; 1866 struct vfsmount *root = ns->root;
1866 LIST_HEAD(umount_list); 1867 LIST_HEAD(umount_list);
1867 namespace->root = NULL; 1868 ns->root = NULL;
1868 spin_unlock(&vfsmount_lock); 1869 spin_unlock(&vfsmount_lock);
1869 down_write(&namespace_sem); 1870 down_write(&namespace_sem);
1870 spin_lock(&vfsmount_lock); 1871 spin_lock(&vfsmount_lock);
@@ -1872,5 +1873,5 @@ void __put_namespace(struct namespace *namespace)
1872 spin_unlock(&vfsmount_lock); 1873 spin_unlock(&vfsmount_lock);
1873 up_write(&namespace_sem); 1874 up_write(&namespace_sem);
1874 release_mounts(&umount_list); 1875 release_mounts(&umount_list);
1875 kfree(namespace); 1876 kfree(ns);
1876} 1877}
diff --git a/fs/nfs/getroot.c b/fs/nfs/getroot.c
index 20c6f39ea38a..8391bd7a83ce 100644
--- a/fs/nfs/getroot.c
+++ b/fs/nfs/getroot.c
@@ -31,7 +31,7 @@
31#include <linux/nfs_idmap.h> 31#include <linux/nfs_idmap.h>
32#include <linux/vfs.h> 32#include <linux/vfs.h>
33#include <linux/namei.h> 33#include <linux/namei.h>
34#include <linux/namespace.h> 34#include <linux/mnt_namespace.h>
35#include <linux/security.h> 35#include <linux/security.h>
36 36
37#include <asm/system.h> 37#include <asm/system.h>
diff --git a/fs/pnode.c b/fs/pnode.c
index da42ee61c1df..56aacead8362 100644
--- a/fs/pnode.c
+++ b/fs/pnode.c
@@ -6,7 +6,7 @@
6 * Author : Ram Pai (linuxram@us.ibm.com) 6 * Author : Ram Pai (linuxram@us.ibm.com)
7 * 7 *
8 */ 8 */
9#include <linux/namespace.h> 9#include <linux/mnt_namespace.h>
10#include <linux/mount.h> 10#include <linux/mount.h>
11#include <linux/fs.h> 11#include <linux/fs.h>
12#include "pnode.h" 12#include "pnode.h"
diff --git a/fs/pnode.h b/fs/pnode.h
index 020e1bb60fdb..d45bd8ec36bf 100644
--- a/fs/pnode.h
+++ b/fs/pnode.h
@@ -13,7 +13,7 @@
13 13
14#define IS_MNT_SHARED(mnt) (mnt->mnt_flags & MNT_SHARED) 14#define IS_MNT_SHARED(mnt) (mnt->mnt_flags & MNT_SHARED)
15#define IS_MNT_SLAVE(mnt) (mnt->mnt_master) 15#define IS_MNT_SLAVE(mnt) (mnt->mnt_master)
16#define IS_MNT_NEW(mnt) (!mnt->mnt_namespace) 16#define IS_MNT_NEW(mnt) (!mnt->mnt_ns)
17#define CLEAR_MNT_SHARED(mnt) (mnt->mnt_flags &= ~MNT_SHARED) 17#define CLEAR_MNT_SHARED(mnt) (mnt->mnt_flags &= ~MNT_SHARED)
18#define IS_MNT_UNBINDABLE(mnt) (mnt->mnt_flags & MNT_UNBINDABLE) 18#define IS_MNT_UNBINDABLE(mnt) (mnt->mnt_flags & MNT_UNBINDABLE)
19 19
diff --git a/fs/proc/base.c b/fs/proc/base.c
index a71f1755bb57..a3b5074118a7 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -59,7 +59,7 @@
59#include <linux/string.h> 59#include <linux/string.h>
60#include <linux/seq_file.h> 60#include <linux/seq_file.h>
61#include <linux/namei.h> 61#include <linux/namei.h>
62#include <linux/namespace.h> 62#include <linux/mnt_namespace.h>
63#include <linux/mm.h> 63#include <linux/mm.h>
64#include <linux/smp_lock.h> 64#include <linux/smp_lock.h>
65#include <linux/rcupdate.h> 65#include <linux/rcupdate.h>
@@ -365,33 +365,33 @@ struct proc_mounts {
365static int mounts_open(struct inode *inode, struct file *file) 365static int mounts_open(struct inode *inode, struct file *file)
366{ 366{
367 struct task_struct *task = get_proc_task(inode); 367 struct task_struct *task = get_proc_task(inode);
368 struct namespace *namespace = NULL; 368 struct mnt_namespace *ns = NULL;
369 struct proc_mounts *p; 369 struct proc_mounts *p;
370 int ret = -EINVAL; 370 int ret = -EINVAL;
371 371
372 if (task) { 372 if (task) {
373 task_lock(task); 373 task_lock(task);
374 namespace = task->nsproxy->namespace; 374 ns = task->nsproxy->mnt_ns;
375 if (namespace) 375 if (ns)
376 get_namespace(namespace); 376 get_mnt_ns(ns);
377 task_unlock(task); 377 task_unlock(task);
378 put_task_struct(task); 378 put_task_struct(task);
379 } 379 }
380 380
381 if (namespace) { 381 if (ns) {
382 ret = -ENOMEM; 382 ret = -ENOMEM;
383 p = kmalloc(sizeof(struct proc_mounts), GFP_KERNEL); 383 p = kmalloc(sizeof(struct proc_mounts), GFP_KERNEL);
384 if (p) { 384 if (p) {
385 file->private_data = &p->m; 385 file->private_data = &p->m;
386 ret = seq_open(file, &mounts_op); 386 ret = seq_open(file, &mounts_op);
387 if (!ret) { 387 if (!ret) {
388 p->m.private = namespace; 388 p->m.private = ns;
389 p->event = namespace->event; 389 p->event = ns->event;
390 return 0; 390 return 0;
391 } 391 }
392 kfree(p); 392 kfree(p);
393 } 393 }
394 put_namespace(namespace); 394 put_mnt_ns(ns);
395 } 395 }
396 return ret; 396 return ret;
397} 397}
@@ -399,15 +399,15 @@ static int mounts_open(struct inode *inode, struct file *file)
399static int mounts_release(struct inode *inode, struct file *file) 399static int mounts_release(struct inode *inode, struct file *file)
400{ 400{
401 struct seq_file *m = file->private_data; 401 struct seq_file *m = file->private_data;
402 struct namespace *namespace = m->private; 402 struct mnt_namespace *ns = m->private;
403 put_namespace(namespace); 403 put_mnt_ns(ns);
404 return seq_release(inode, file); 404 return seq_release(inode, file);
405} 405}
406 406
407static unsigned mounts_poll(struct file *file, poll_table *wait) 407static unsigned mounts_poll(struct file *file, poll_table *wait)
408{ 408{
409 struct proc_mounts *p = file->private_data; 409 struct proc_mounts *p = file->private_data;
410 struct namespace *ns = p->m.private; 410 struct mnt_namespace *ns = p->m.private;
411 unsigned res = 0; 411 unsigned res = 0;
412 412
413 poll_wait(file, &ns->poll, wait); 413 poll_wait(file, &ns->poll, wait);
@@ -437,21 +437,21 @@ static int mountstats_open(struct inode *inode, struct file *file)
437 437
438 if (!ret) { 438 if (!ret) {
439 struct seq_file *m = file->private_data; 439 struct seq_file *m = file->private_data;
440 struct namespace *namespace = NULL; 440 struct mnt_namespace *mnt_ns = NULL;
441 struct task_struct *task = get_proc_task(inode); 441 struct task_struct *task = get_proc_task(inode);
442 442
443 if (task) { 443 if (task) {
444 task_lock(task); 444 task_lock(task);
445 if (task->nsproxy) 445 if (task->nsproxy)
446 namespace = task->nsproxy->namespace; 446 mnt_ns = task->nsproxy->mnt_ns;
447 if (namespace) 447 if (mnt_ns)
448 get_namespace(namespace); 448 get_mnt_ns(mnt_ns);
449 task_unlock(task); 449 task_unlock(task);
450 put_task_struct(task); 450 put_task_struct(task);
451 } 451 }
452 452
453 if (namespace) 453 if (mnt_ns)
454 m->private = namespace; 454 m->private = mnt_ns;
455 else { 455 else {
456 seq_release(inode, file); 456 seq_release(inode, file);
457 ret = -EINVAL; 457 ret = -EINVAL;
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index 7fb5fb036f90..58ad4551a7c1 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -23,7 +23,7 @@
23#include <linux/blkdev.h> 23#include <linux/blkdev.h>
24#include <linux/buffer_head.h> 24#include <linux/buffer_head.h>
25#include <linux/vfs.h> 25#include <linux/vfs.h>
26#include <linux/namespace.h> 26#include <linux/mnt_namespace.h>
27#include <linux/mount.h> 27#include <linux/mount.h>
28#include <linux/namei.h> 28#include <linux/namei.h>
29#include <linux/quotaops.h> 29#include <linux/quotaops.h>
diff --git a/include/linux/init_task.h b/include/linux/init_task.h
index 848a68af3d42..5c4989172f7e 100644
--- a/include/linux/init_task.h
+++ b/include/linux/init_task.h
@@ -76,7 +76,7 @@ extern struct nsproxy init_nsproxy;
76 .count = ATOMIC_INIT(1), \ 76 .count = ATOMIC_INIT(1), \
77 .nslock = __SPIN_LOCK_UNLOCKED(nsproxy.nslock), \ 77 .nslock = __SPIN_LOCK_UNLOCKED(nsproxy.nslock), \
78 .uts_ns = &init_uts_ns, \ 78 .uts_ns = &init_uts_ns, \
79 .namespace = NULL, \ 79 .mnt_ns = NULL, \
80 INIT_IPC_NS(ipc_ns) \ 80 INIT_IPC_NS(ipc_ns) \
81} 81}
82 82
diff --git a/include/linux/mnt_namespace.h b/include/linux/mnt_namespace.h
new file mode 100644
index 000000000000..4af0b1fc282a
--- /dev/null
+++ b/include/linux/mnt_namespace.h
@@ -0,0 +1,42 @@
1#ifndef _NAMESPACE_H_
2#define _NAMESPACE_H_
3#ifdef __KERNEL__
4
5#include <linux/mount.h>
6#include <linux/sched.h>
7#include <linux/nsproxy.h>
8
9struct mnt_namespace {
10 atomic_t count;
11 struct vfsmount * root;
12 struct list_head list;
13 wait_queue_head_t poll;
14 int event;
15};
16
17extern int copy_mnt_ns(int, struct task_struct *);
18extern void __put_mnt_ns(struct mnt_namespace *ns);
19extern struct mnt_namespace *dup_mnt_ns(struct task_struct *,
20 struct fs_struct *);
21
22static inline void put_mnt_ns(struct mnt_namespace *ns)
23{
24 if (atomic_dec_and_lock(&ns->count, &vfsmount_lock))
25 /* releases vfsmount_lock */
26 __put_mnt_ns(ns);
27}
28
29static inline void exit_mnt_ns(struct task_struct *p)
30{
31 struct mnt_namespace *ns = p->nsproxy->mnt_ns;
32 if (ns)
33 put_mnt_ns(ns);
34}
35
36static inline void get_mnt_ns(struct mnt_namespace *ns)
37{
38 atomic_inc(&ns->count);
39}
40
41#endif
42#endif
diff --git a/include/linux/mount.h b/include/linux/mount.h
index 403d1a97c512..e357dc86a4de 100644
--- a/include/linux/mount.h
+++ b/include/linux/mount.h
@@ -20,7 +20,7 @@
20struct super_block; 20struct super_block;
21struct vfsmount; 21struct vfsmount;
22struct dentry; 22struct dentry;
23struct namespace; 23struct mnt_namespace;
24 24
25#define MNT_NOSUID 0x01 25#define MNT_NOSUID 0x01
26#define MNT_NODEV 0x02 26#define MNT_NODEV 0x02
@@ -52,7 +52,7 @@ struct vfsmount {
52 struct list_head mnt_slave_list;/* list of slave mounts */ 52 struct list_head mnt_slave_list;/* list of slave mounts */
53 struct list_head mnt_slave; /* slave list entry */ 53 struct list_head mnt_slave; /* slave list entry */
54 struct vfsmount *mnt_master; /* slave is on master->mnt_slave_list */ 54 struct vfsmount *mnt_master; /* slave is on master->mnt_slave_list */
55 struct namespace *mnt_namespace; /* containing namespace */ 55 struct mnt_namespace *mnt_ns; /* containing namespace */
56 int mnt_pinned; 56 int mnt_pinned;
57}; 57};
58 58
diff --git a/include/linux/namespace.h b/include/linux/namespace.h
deleted file mode 100644
index d137009f0b2b..000000000000
--- a/include/linux/namespace.h
+++ /dev/null
@@ -1,42 +0,0 @@
1#ifndef _NAMESPACE_H_
2#define _NAMESPACE_H_
3#ifdef __KERNEL__
4
5#include <linux/mount.h>
6#include <linux/sched.h>
7#include <linux/nsproxy.h>
8
9struct namespace {
10 atomic_t count;
11 struct vfsmount * root;
12 struct list_head list;
13 wait_queue_head_t poll;
14 int event;
15};
16
17extern int copy_namespace(int, struct task_struct *);
18extern void __put_namespace(struct namespace *namespace);
19extern struct namespace *dup_namespace(struct task_struct *, struct fs_struct *);
20
21static inline void put_namespace(struct namespace *namespace)
22{
23 if (atomic_dec_and_lock(&namespace->count, &vfsmount_lock))
24 /* releases vfsmount_lock */
25 __put_namespace(namespace);
26}
27
28static inline void exit_namespace(struct task_struct *p)
29{
30 struct namespace *namespace = p->nsproxy->namespace;
31 if (namespace) {
32 put_namespace(namespace);
33 }
34}
35
36static inline void get_namespace(struct namespace *namespace)
37{
38 atomic_inc(&namespace->count);
39}
40
41#endif
42#endif
diff --git a/include/linux/nsproxy.h b/include/linux/nsproxy.h
index 971d1c6dfc4b..0aba1b1a39c7 100644
--- a/include/linux/nsproxy.h
+++ b/include/linux/nsproxy.h
@@ -4,7 +4,7 @@
4#include <linux/spinlock.h> 4#include <linux/spinlock.h>
5#include <linux/sched.h> 5#include <linux/sched.h>
6 6
7struct namespace; 7struct mnt_namespace;
8struct uts_namespace; 8struct uts_namespace;
9struct ipc_namespace; 9struct ipc_namespace;
10 10
@@ -25,7 +25,7 @@ struct nsproxy {
25 spinlock_t nslock; 25 spinlock_t nslock;
26 struct uts_namespace *uts_ns; 26 struct uts_namespace *uts_ns;
27 struct ipc_namespace *ipc_ns; 27 struct ipc_namespace *ipc_ns;
28 struct namespace *namespace; 28 struct mnt_namespace *mnt_ns;
29}; 29};
30extern struct nsproxy init_nsproxy; 30extern struct nsproxy init_nsproxy;
31 31
diff --git a/kernel/exit.c b/kernel/exit.c
index 6267a6cc6113..28d9feedfd27 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -13,7 +13,7 @@
13#include <linux/completion.h> 13#include <linux/completion.h>
14#include <linux/personality.h> 14#include <linux/personality.h>
15#include <linux/tty.h> 15#include <linux/tty.h>
16#include <linux/namespace.h> 16#include <linux/mnt_namespace.h>
17#include <linux/key.h> 17#include <linux/key.h>
18#include <linux/security.h> 18#include <linux/security.h>
19#include <linux/cpu.h> 19#include <linux/cpu.h>
diff --git a/kernel/fork.c b/kernel/fork.c
index 60d2644bfe85..8c859eef8e6a 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -18,7 +18,7 @@
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/vmalloc.h> 19#include <linux/vmalloc.h>
20#include <linux/completion.h> 20#include <linux/completion.h>
21#include <linux/namespace.h> 21#include <linux/mnt_namespace.h>
22#include <linux/personality.h> 22#include <linux/personality.h>
23#include <linux/mempolicy.h> 23#include <linux/mempolicy.h>
24#include <linux/sem.h> 24#include <linux/sem.h>
@@ -1525,17 +1525,18 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
1525} 1525}
1526 1526
1527/* 1527/*
1528 * Unshare the namespace structure if it is being shared 1528 * Unshare the mnt_namespace structure if it is being shared
1529 */ 1529 */
1530static int unshare_namespace(unsigned long unshare_flags, struct namespace **new_nsp, struct fs_struct *new_fs) 1530static int unshare_mnt_namespace(unsigned long unshare_flags,
1531 struct mnt_namespace **new_nsp, struct fs_struct *new_fs)
1531{ 1532{
1532 struct namespace *ns = current->nsproxy->namespace; 1533 struct mnt_namespace *ns = current->nsproxy->mnt_ns;
1533 1534
1534 if ((unshare_flags & CLONE_NEWNS) && ns) { 1535 if ((unshare_flags & CLONE_NEWNS) && ns) {
1535 if (!capable(CAP_SYS_ADMIN)) 1536 if (!capable(CAP_SYS_ADMIN))
1536 return -EPERM; 1537 return -EPERM;
1537 1538
1538 *new_nsp = dup_namespace(current, new_fs ? new_fs : current->fs); 1539 *new_nsp = dup_mnt_ns(current, new_fs ? new_fs : current->fs);
1539 if (!*new_nsp) 1540 if (!*new_nsp)
1540 return -ENOMEM; 1541 return -ENOMEM;
1541 } 1542 }
@@ -1623,7 +1624,7 @@ asmlinkage long sys_unshare(unsigned long unshare_flags)
1623{ 1624{
1624 int err = 0; 1625 int err = 0;
1625 struct fs_struct *fs, *new_fs = NULL; 1626 struct fs_struct *fs, *new_fs = NULL;
1626 struct namespace *ns, *new_ns = NULL; 1627 struct mnt_namespace *ns, *new_ns = NULL;
1627 struct sighand_struct *new_sigh = NULL; 1628 struct sighand_struct *new_sigh = NULL;
1628 struct mm_struct *mm, *new_mm = NULL, *active_mm = NULL; 1629 struct mm_struct *mm, *new_mm = NULL, *active_mm = NULL;
1629 struct files_struct *fd, *new_fd = NULL; 1630 struct files_struct *fd, *new_fd = NULL;
@@ -1645,7 +1646,7 @@ asmlinkage long sys_unshare(unsigned long unshare_flags)
1645 goto bad_unshare_out; 1646 goto bad_unshare_out;
1646 if ((err = unshare_fs(unshare_flags, &new_fs))) 1647 if ((err = unshare_fs(unshare_flags, &new_fs)))
1647 goto bad_unshare_cleanup_thread; 1648 goto bad_unshare_cleanup_thread;
1648 if ((err = unshare_namespace(unshare_flags, &new_ns, new_fs))) 1649 if ((err = unshare_mnt_namespace(unshare_flags, &new_ns, new_fs)))
1649 goto bad_unshare_cleanup_fs; 1650 goto bad_unshare_cleanup_fs;
1650 if ((err = unshare_sighand(unshare_flags, &new_sigh))) 1651 if ((err = unshare_sighand(unshare_flags, &new_sigh)))
1651 goto bad_unshare_cleanup_ns; 1652 goto bad_unshare_cleanup_ns;
@@ -1686,8 +1687,8 @@ asmlinkage long sys_unshare(unsigned long unshare_flags)
1686 } 1687 }
1687 1688
1688 if (new_ns) { 1689 if (new_ns) {
1689 ns = current->nsproxy->namespace; 1690 ns = current->nsproxy->mnt_ns;
1690 current->nsproxy->namespace = new_ns; 1691 current->nsproxy->mnt_ns = new_ns;
1691 new_ns = ns; 1692 new_ns = ns;
1692 } 1693 }
1693 1694
@@ -1748,7 +1749,7 @@ bad_unshare_cleanup_sigh:
1748 1749
1749bad_unshare_cleanup_ns: 1750bad_unshare_cleanup_ns:
1750 if (new_ns) 1751 if (new_ns)
1751 put_namespace(new_ns); 1752 put_mnt_ns(new_ns);
1752 1753
1753bad_unshare_cleanup_fs: 1754bad_unshare_cleanup_fs:
1754 if (new_fs) 1755 if (new_fs)
diff --git a/kernel/kmod.c b/kernel/kmod.c
index 8d2bea09a4ec..3a7379aa31ca 100644
--- a/kernel/kmod.c
+++ b/kernel/kmod.c
@@ -25,7 +25,7 @@
25#include <linux/kmod.h> 25#include <linux/kmod.h>
26#include <linux/smp_lock.h> 26#include <linux/smp_lock.h>
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/namespace.h> 28#include <linux/mnt_namespace.h>
29#include <linux/completion.h> 29#include <linux/completion.h>
30#include <linux/file.h> 30#include <linux/file.h>
31#include <linux/workqueue.h> 31#include <linux/workqueue.h>
diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c
index 674aceb7335a..bd9cb435dfe0 100644
--- a/kernel/nsproxy.c
+++ b/kernel/nsproxy.c
@@ -17,7 +17,7 @@
17#include <linux/version.h> 17#include <linux/version.h>
18#include <linux/nsproxy.h> 18#include <linux/nsproxy.h>
19#include <linux/init_task.h> 19#include <linux/init_task.h>
20#include <linux/namespace.h> 20#include <linux/mnt_namespace.h>
21#include <linux/utsname.h> 21#include <linux/utsname.h>
22 22
23struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy); 23struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy);
@@ -60,8 +60,8 @@ struct nsproxy *dup_namespaces(struct nsproxy *orig)
60 struct nsproxy *ns = clone_namespaces(orig); 60 struct nsproxy *ns = clone_namespaces(orig);
61 61
62 if (ns) { 62 if (ns) {
63 if (ns->namespace) 63 if (ns->mnt_ns)
64 get_namespace(ns->namespace); 64 get_mnt_ns(ns->mnt_ns);
65 if (ns->uts_ns) 65 if (ns->uts_ns)
66 get_uts_ns(ns->uts_ns); 66 get_uts_ns(ns->uts_ns);
67 if (ns->ipc_ns) 67 if (ns->ipc_ns)
@@ -97,7 +97,7 @@ int copy_namespaces(int flags, struct task_struct *tsk)
97 97
98 tsk->nsproxy = new_ns; 98 tsk->nsproxy = new_ns;
99 99
100 err = copy_namespace(flags, tsk); 100 err = copy_mnt_ns(flags, tsk);
101 if (err) 101 if (err)
102 goto out_ns; 102 goto out_ns;
103 103
@@ -117,8 +117,8 @@ out_ipc:
117 if (new_ns->uts_ns) 117 if (new_ns->uts_ns)
118 put_uts_ns(new_ns->uts_ns); 118 put_uts_ns(new_ns->uts_ns);
119out_uts: 119out_uts:
120 if (new_ns->namespace) 120 if (new_ns->mnt_ns)
121 put_namespace(new_ns->namespace); 121 put_mnt_ns(new_ns->mnt_ns);
122out_ns: 122out_ns:
123 tsk->nsproxy = old_ns; 123 tsk->nsproxy = old_ns;
124 kfree(new_ns); 124 kfree(new_ns);
@@ -127,8 +127,8 @@ out_ns:
127 127
128void free_nsproxy(struct nsproxy *ns) 128void free_nsproxy(struct nsproxy *ns)
129{ 129{
130 if (ns->namespace) 130 if (ns->mnt_ns)
131 put_namespace(ns->namespace); 131 put_mnt_ns(ns->mnt_ns);
132 if (ns->uts_ns) 132 if (ns->uts_ns)
133 put_uts_ns(ns->uts_ns); 133 put_uts_ns(ns->uts_ns);
134 if (ns->ipc_ns) 134 if (ns->ipc_ns)