aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namespace.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/namespace.c')
-rw-r--r--fs/namespace.c47
1 files changed, 20 insertions, 27 deletions
diff --git a/fs/namespace.c b/fs/namespace.c
index fa7ed6a9fc2d..55442a6cf221 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -13,30 +13,22 @@
13#include <linux/sched.h> 13#include <linux/sched.h>
14#include <linux/smp_lock.h> 14#include <linux/smp_lock.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/kernel.h>
16#include <linux/quotaops.h> 17#include <linux/quotaops.h>
17#include <linux/acct.h> 18#include <linux/acct.h>
18#include <linux/capability.h> 19#include <linux/capability.h>
19#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/sysfs.h>
20#include <linux/seq_file.h> 22#include <linux/seq_file.h>
21#include <linux/namespace.h> 23#include <linux/namespace.h>
22#include <linux/namei.h> 24#include <linux/namei.h>
23#include <linux/security.h> 25#include <linux/security.h>
24#include <linux/mount.h> 26#include <linux/mount.h>
27#include <linux/ramfs.h>
25#include <asm/uaccess.h> 28#include <asm/uaccess.h>
26#include <asm/unistd.h> 29#include <asm/unistd.h>
27#include "pnode.h" 30#include "pnode.h"
28 31
29extern int __init init_rootfs(void);
30
31#ifdef CONFIG_SYSFS
32extern int __init sysfs_init(void);
33#else
34static inline int sysfs_init(void)
35{
36 return 0;
37}
38#endif
39
40/* spinlock for vfsmount related operations, inplace of dcache_lock */ 32/* spinlock for vfsmount related operations, inplace of dcache_lock */
41__cacheline_aligned_in_smp DEFINE_SPINLOCK(vfsmount_lock); 33__cacheline_aligned_in_smp DEFINE_SPINLOCK(vfsmount_lock);
42 34
@@ -141,7 +133,7 @@ struct vfsmount *lookup_mnt(struct vfsmount *mnt, struct dentry *dentry)
141 133
142static inline int check_mnt(struct vfsmount *mnt) 134static inline int check_mnt(struct vfsmount *mnt)
143{ 135{
144 return mnt->mnt_namespace == current->namespace; 136 return mnt->mnt_namespace == current->nsproxy->namespace;
145} 137}
146 138
147static void touch_namespace(struct namespace *ns) 139static void touch_namespace(struct namespace *ns)
@@ -838,7 +830,7 @@ static int attach_recursive_mnt(struct vfsmount *source_mnt,
838 if (parent_nd) { 830 if (parent_nd) {
839 detach_mnt(source_mnt, parent_nd); 831 detach_mnt(source_mnt, parent_nd);
840 attach_mnt(source_mnt, nd); 832 attach_mnt(source_mnt, nd);
841 touch_namespace(current->namespace); 833 touch_namespace(current->nsproxy->namespace);
842 } else { 834 } else {
843 mnt_set_mountpoint(dest_mnt, dest_dentry, source_mnt); 835 mnt_set_mountpoint(dest_mnt, dest_dentry, source_mnt);
844 commit_tree(source_mnt); 836 commit_tree(source_mnt);
@@ -1449,7 +1441,7 @@ dput_out:
1449 */ 1441 */
1450struct namespace *dup_namespace(struct task_struct *tsk, struct fs_struct *fs) 1442struct namespace *dup_namespace(struct task_struct *tsk, struct fs_struct *fs)
1451{ 1443{
1452 struct namespace *namespace = tsk->namespace; 1444 struct namespace *namespace = tsk->nsproxy->namespace;
1453 struct namespace *new_ns; 1445 struct namespace *new_ns;
1454 struct vfsmount *rootmnt = NULL, *pwdmnt = NULL, *altrootmnt = NULL; 1446 struct vfsmount *rootmnt = NULL, *pwdmnt = NULL, *altrootmnt = NULL;
1455 struct vfsmount *p, *q; 1447 struct vfsmount *p, *q;
@@ -1516,7 +1508,7 @@ struct namespace *dup_namespace(struct task_struct *tsk, struct fs_struct *fs)
1516 1508
1517int copy_namespace(int flags, struct task_struct *tsk) 1509int copy_namespace(int flags, struct task_struct *tsk)
1518{ 1510{
1519 struct namespace *namespace = tsk->namespace; 1511 struct namespace *namespace = tsk->nsproxy->namespace;
1520 struct namespace *new_ns; 1512 struct namespace *new_ns;
1521 int err = 0; 1513 int err = 0;
1522 1514
@@ -1539,7 +1531,7 @@ int copy_namespace(int flags, struct task_struct *tsk)
1539 goto out; 1531 goto out;
1540 } 1532 }
1541 1533
1542 tsk->namespace = new_ns; 1534 tsk->nsproxy->namespace = new_ns;
1543 1535
1544out: 1536out:
1545 put_namespace(namespace); 1537 put_namespace(namespace);
@@ -1762,7 +1754,7 @@ asmlinkage long sys_pivot_root(const char __user * new_root,
1762 detach_mnt(user_nd.mnt, &root_parent); 1754 detach_mnt(user_nd.mnt, &root_parent);
1763 attach_mnt(user_nd.mnt, &old_nd); /* mount old root on put_old */ 1755 attach_mnt(user_nd.mnt, &old_nd); /* mount old root on put_old */
1764 attach_mnt(new_nd.mnt, &root_parent); /* mount new_root on / */ 1756 attach_mnt(new_nd.mnt, &root_parent); /* mount new_root on / */
1765 touch_namespace(current->namespace); 1757 touch_namespace(current->nsproxy->namespace);
1766 spin_unlock(&vfsmount_lock); 1758 spin_unlock(&vfsmount_lock);
1767 chroot_fs_refs(&user_nd, &new_nd); 1759 chroot_fs_refs(&user_nd, &new_nd);
1768 security_sb_post_pivotroot(&user_nd, &new_nd); 1760 security_sb_post_pivotroot(&user_nd, &new_nd);
@@ -1788,7 +1780,6 @@ static void __init init_mount_tree(void)
1788{ 1780{
1789 struct vfsmount *mnt; 1781 struct vfsmount *mnt;
1790 struct namespace *namespace; 1782 struct namespace *namespace;
1791 struct task_struct *g, *p;
1792 1783
1793 mnt = do_kern_mount("rootfs", 0, "rootfs", NULL); 1784 mnt = do_kern_mount("rootfs", 0, "rootfs", NULL);
1794 if (IS_ERR(mnt)) 1785 if (IS_ERR(mnt))
@@ -1804,13 +1795,8 @@ static void __init init_mount_tree(void)
1804 namespace->root = mnt; 1795 namespace->root = mnt;
1805 mnt->mnt_namespace = namespace; 1796 mnt->mnt_namespace = namespace;
1806 1797
1807 init_task.namespace = namespace; 1798 init_task.nsproxy->namespace = namespace;
1808 read_lock(&tasklist_lock); 1799 get_namespace(namespace);
1809 do_each_thread(g, p) {
1810 get_namespace(namespace);
1811 p->namespace = namespace;
1812 } while_each_thread(g, p);
1813 read_unlock(&tasklist_lock);
1814 1800
1815 set_fs_pwd(current->fs, namespace->root, namespace->root->mnt_root); 1801 set_fs_pwd(current->fs, namespace->root, namespace->root->mnt_root);
1816 set_fs_root(current->fs, namespace->root, namespace->root->mnt_root); 1802 set_fs_root(current->fs, namespace->root, namespace->root->mnt_root);
@@ -1821,6 +1807,7 @@ void __init mnt_init(unsigned long mempages)
1821 struct list_head *d; 1807 struct list_head *d;
1822 unsigned int nr_hash; 1808 unsigned int nr_hash;
1823 int i; 1809 int i;
1810 int err;
1824 1811
1825 init_rwsem(&namespace_sem); 1812 init_rwsem(&namespace_sem);
1826 1813
@@ -1861,8 +1848,14 @@ void __init mnt_init(unsigned long mempages)
1861 d++; 1848 d++;
1862 i--; 1849 i--;
1863 } while (i); 1850 } while (i);
1864 sysfs_init(); 1851 err = sysfs_init();
1865 subsystem_register(&fs_subsys); 1852 if (err)
1853 printk(KERN_WARNING "%s: sysfs_init error: %d\n",
1854 __FUNCTION__, err);
1855 err = subsystem_register(&fs_subsys);
1856 if (err)
1857 printk(KERN_WARNING "%s: subsystem_register error: %d\n",
1858 __FUNCTION__, err);
1866 init_rootfs(); 1859 init_rootfs();
1867 init_mount_tree(); 1860 init_mount_tree();
1868} 1861}