aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro2011-11-24 23:46:35 -0600
committerAl Viro2012-01-03 21:57:09 -0600
commit143c8c91cee7efdd732ec5f61b3471fc46192f20 (patch)
treedd3e9a9b8b88f1876a258fe1bf274532aeb72a62 /fs/namespace.c
parent900148dcac6bc93ca688d64a7f9a9f8d706e0d1c (diff)
downloadkernel-omap-143c8c91cee7efdd732ec5f61b3471fc46192f20.tar.gz
kernel-omap-143c8c91cee7efdd732ec5f61b3471fc46192f20.tar.xz
kernel-omap-143c8c91cee7efdd732ec5f61b3471fc46192f20.zip
vfs: mnt_ns moved to struct mount
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namespace.c')
-rw-r--r--fs/namespace.c45
1 files changed, 23 insertions, 22 deletions
diff --git a/fs/namespace.c b/fs/namespace.c
index 3e95cc26dda6..4cdb7f698613 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -505,7 +505,7 @@ struct vfsmount *lookup_mnt(struct path *path)
505 } 505 }
506} 506}
507 507
508static inline int check_mnt(struct vfsmount *mnt) 508static inline int check_mnt(struct mount *mnt)
509{ 509{
510 return mnt->mnt_ns == current->nsproxy->mnt_ns; 510 return mnt->mnt_ns == current->nsproxy->mnt_ns;
511} 511}
@@ -614,13 +614,13 @@ static void commit_tree(struct mount *mnt)
614 struct mount *parent = mnt->mnt_parent; 614 struct mount *parent = mnt->mnt_parent;
615 struct mount *m; 615 struct mount *m;
616 LIST_HEAD(head); 616 LIST_HEAD(head);
617 struct mnt_namespace *n = parent->mnt.mnt_ns; 617 struct mnt_namespace *n = parent->mnt_ns;
618 618
619 BUG_ON(parent == mnt); 619 BUG_ON(parent == mnt);
620 620
621 list_add_tail(&head, &mnt->mnt.mnt_list); 621 list_add_tail(&head, &mnt->mnt.mnt_list);
622 list_for_each_entry(m, &head, mnt.mnt_list) { 622 list_for_each_entry(m, &head, mnt.mnt_list) {
623 m->mnt.mnt_ns = n; 623 m->mnt_ns = n;
624 __mnt_make_longterm(m); 624 __mnt_make_longterm(m);
625 } 625 }
626 626
@@ -1234,8 +1234,8 @@ void umount_tree(struct mount *mnt, int propagate, struct list_head *kill)
1234 list_for_each_entry(p, &tmp_list, mnt_hash) { 1234 list_for_each_entry(p, &tmp_list, mnt_hash) {
1235 list_del_init(&p->mnt_expire); 1235 list_del_init(&p->mnt_expire);
1236 list_del_init(&p->mnt.mnt_list); 1236 list_del_init(&p->mnt.mnt_list);
1237 __touch_mnt_namespace(p->mnt.mnt_ns); 1237 __touch_mnt_namespace(p->mnt_ns);
1238 p->mnt.mnt_ns = NULL; 1238 p->mnt_ns = NULL;
1239 __mnt_make_shortterm(p); 1239 __mnt_make_shortterm(p);
1240 list_del_init(&p->mnt_child); 1240 list_del_init(&p->mnt_child);
1241 if (mnt_has_parent(p)) { 1241 if (mnt_has_parent(p)) {
@@ -1367,7 +1367,7 @@ SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
1367 retval = -EINVAL; 1367 retval = -EINVAL;
1368 if (path.dentry != path.mnt->mnt_root) 1368 if (path.dentry != path.mnt->mnt_root)
1369 goto dput_and_out; 1369 goto dput_and_out;
1370 if (!check_mnt(path.mnt)) 1370 if (!check_mnt(mnt))
1371 goto dput_and_out; 1371 goto dput_and_out;
1372 1372
1373 retval = -EPERM; 1373 retval = -EPERM;
@@ -1619,7 +1619,7 @@ static int attach_recursive_mnt(struct mount *source_mnt,
1619 if (parent_path) { 1619 if (parent_path) {
1620 detach_mnt(source_mnt, parent_path); 1620 detach_mnt(source_mnt, parent_path);
1621 attach_mnt(source_mnt, path); 1621 attach_mnt(source_mnt, path);
1622 touch_mnt_namespace(parent_path->mnt->mnt_ns); 1622 touch_mnt_namespace(source_mnt->mnt_ns);
1623 } else { 1623 } else {
1624 mnt_set_mountpoint(dest_mnt, dest_dentry, source_mnt); 1624 mnt_set_mountpoint(dest_mnt, dest_dentry, source_mnt);
1625 commit_tree(source_mnt); 1625 commit_tree(source_mnt);
@@ -1765,7 +1765,7 @@ static int do_loopback(struct path *path, char *old_name,
1765 if (IS_MNT_UNBINDABLE(old_path.mnt)) 1765 if (IS_MNT_UNBINDABLE(old_path.mnt))
1766 goto out2; 1766 goto out2;
1767 1767
1768 if (!check_mnt(path->mnt) || !check_mnt(old_path.mnt)) 1768 if (!check_mnt(real_mount(path->mnt)) || !check_mnt(old))
1769 goto out2; 1769 goto out2;
1770 1770
1771 err = -ENOMEM; 1771 err = -ENOMEM;
@@ -1818,11 +1818,12 @@ static int do_remount(struct path *path, int flags, int mnt_flags,
1818{ 1818{
1819 int err; 1819 int err;
1820 struct super_block *sb = path->mnt->mnt_sb; 1820 struct super_block *sb = path->mnt->mnt_sb;
1821 struct mount *mnt = real_mount(path->mnt);
1821 1822
1822 if (!capable(CAP_SYS_ADMIN)) 1823 if (!capable(CAP_SYS_ADMIN))
1823 return -EPERM; 1824 return -EPERM;
1824 1825
1825 if (!check_mnt(path->mnt)) 1826 if (!check_mnt(mnt))
1826 return -EINVAL; 1827 return -EINVAL;
1827 1828
1828 if (path->dentry != path->mnt->mnt_root) 1829 if (path->dentry != path->mnt->mnt_root)
@@ -1839,14 +1840,14 @@ static int do_remount(struct path *path, int flags, int mnt_flags,
1839 err = do_remount_sb(sb, flags, data, 0); 1840 err = do_remount_sb(sb, flags, data, 0);
1840 if (!err) { 1841 if (!err) {
1841 br_write_lock(vfsmount_lock); 1842 br_write_lock(vfsmount_lock);
1842 mnt_flags |= path->mnt->mnt_flags & MNT_PROPAGATION_MASK; 1843 mnt_flags |= mnt->mnt.mnt_flags & MNT_PROPAGATION_MASK;
1843 path->mnt->mnt_flags = mnt_flags; 1844 mnt->mnt.mnt_flags = mnt_flags;
1844 br_write_unlock(vfsmount_lock); 1845 br_write_unlock(vfsmount_lock);
1845 } 1846 }
1846 up_write(&sb->s_umount); 1847 up_write(&sb->s_umount);
1847 if (!err) { 1848 if (!err) {
1848 br_write_lock(vfsmount_lock); 1849 br_write_lock(vfsmount_lock);
1849 touch_mnt_namespace(path->mnt->mnt_ns); 1850 touch_mnt_namespace(mnt->mnt_ns);
1850 br_write_unlock(vfsmount_lock); 1851 br_write_unlock(vfsmount_lock);
1851 } 1852 }
1852 return err; 1853 return err;
@@ -1880,8 +1881,10 @@ static int do_move_mount(struct path *path, char *old_name)
1880 if (err < 0) 1881 if (err < 0)
1881 goto out; 1882 goto out;
1882 1883
1884 old = real_mount(old_path.mnt);
1885
1883 err = -EINVAL; 1886 err = -EINVAL;
1884 if (!check_mnt(path->mnt) || !check_mnt(old_path.mnt)) 1887 if (!check_mnt(real_mount(path->mnt)) || !check_mnt(old))
1885 goto out1; 1888 goto out1;
1886 1889
1887 if (d_unlinked(path->dentry)) 1890 if (d_unlinked(path->dentry))
@@ -1891,8 +1894,6 @@ static int do_move_mount(struct path *path, char *old_name)
1891 if (old_path.dentry != old_path.mnt->mnt_root) 1894 if (old_path.dentry != old_path.mnt->mnt_root)
1892 goto out1; 1895 goto out1;
1893 1896
1894 old = real_mount(old_path.mnt);
1895
1896 if (!mnt_has_parent(old)) 1897 if (!mnt_has_parent(old))
1897 goto out1; 1898 goto out1;
1898 1899
@@ -1984,7 +1985,7 @@ static int do_add_mount(struct mount *newmnt, struct path *path, int mnt_flags)
1984 return err; 1985 return err;
1985 1986
1986 err = -EINVAL; 1987 err = -EINVAL;
1987 if (!(mnt_flags & MNT_SHRINKABLE) && !check_mnt(path->mnt)) 1988 if (!(mnt_flags & MNT_SHRINKABLE) && !check_mnt(real_mount(path->mnt)))
1988 goto unlock; 1989 goto unlock;
1989 1990
1990 /* Refuse the same filesystem on the same mount point */ 1991 /* Refuse the same filesystem on the same mount point */
@@ -2112,7 +2113,7 @@ void mark_mounts_for_expiry(struct list_head *mounts)
2112 } 2113 }
2113 while (!list_empty(&graveyard)) { 2114 while (!list_empty(&graveyard)) {
2114 mnt = list_first_entry(&graveyard, struct mount, mnt_expire); 2115 mnt = list_first_entry(&graveyard, struct mount, mnt_expire);
2115 touch_mnt_namespace(mnt->mnt.mnt_ns); 2116 touch_mnt_namespace(mnt->mnt_ns);
2116 umount_tree(mnt, 1, &umounts); 2117 umount_tree(mnt, 1, &umounts);
2117 } 2118 }
2118 br_write_unlock(vfsmount_lock); 2119 br_write_unlock(vfsmount_lock);
@@ -2185,7 +2186,7 @@ static void shrink_submounts(struct mount *mnt, struct list_head *umounts)
2185 while (!list_empty(&graveyard)) { 2186 while (!list_empty(&graveyard)) {
2186 m = list_first_entry(&graveyard, struct mount, 2187 m = list_first_entry(&graveyard, struct mount,
2187 mnt_expire); 2188 mnt_expire);
2188 touch_mnt_namespace(m->mnt.mnt_ns); 2189 touch_mnt_namespace(m->mnt_ns);
2189 umount_tree(m, 1, umounts); 2190 umount_tree(m, 1, umounts);
2190 } 2191 }
2191 } 2192 }
@@ -2423,7 +2424,7 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
2423 p = real_mount(mnt_ns->root); 2424 p = real_mount(mnt_ns->root);
2424 q = new; 2425 q = new;
2425 while (p) { 2426 while (p) {
2426 q->mnt.mnt_ns = new_ns; 2427 q->mnt_ns = new_ns;
2427 __mnt_make_longterm(q); 2428 __mnt_make_longterm(q);
2428 if (fs) { 2429 if (fs) {
2429 if (&p->mnt == fs->root.mnt) { 2430 if (&p->mnt == fs->root.mnt) {
@@ -2479,7 +2480,7 @@ static struct mnt_namespace *create_mnt_ns(struct vfsmount *mnt)
2479 2480
2480 new_ns = alloc_mnt_ns(); 2481 new_ns = alloc_mnt_ns();
2481 if (!IS_ERR(new_ns)) { 2482 if (!IS_ERR(new_ns)) {
2482 mnt->mnt_ns = new_ns; 2483 real_mount(mnt)->mnt_ns = new_ns;
2483 __mnt_make_longterm(real_mount(mnt)); 2484 __mnt_make_longterm(real_mount(mnt));
2484 new_ns->root = mnt; 2485 new_ns->root = mnt;
2485 list_add(&new_ns->list, &new_ns->root->mnt_list); 2486 list_add(&new_ns->list, &new_ns->root->mnt_list);
@@ -2644,7 +2645,7 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
2644 IS_MNT_SHARED(&new_mnt->mnt_parent->mnt) || 2645 IS_MNT_SHARED(&new_mnt->mnt_parent->mnt) ||
2645 IS_MNT_SHARED(&root_mnt->mnt_parent->mnt)) 2646 IS_MNT_SHARED(&root_mnt->mnt_parent->mnt))
2646 goto out4; 2647 goto out4;
2647 if (!check_mnt(root.mnt) || !check_mnt(new.mnt)) 2648 if (!check_mnt(root_mnt) || !check_mnt(new_mnt))
2648 goto out4; 2649 goto out4;
2649 error = -ENOENT; 2650 error = -ENOENT;
2650 if (d_unlinked(new.dentry)) 2651 if (d_unlinked(new.dentry))
@@ -2793,5 +2794,5 @@ EXPORT_SYMBOL(kern_unmount);
2793 2794
2794bool our_mnt(struct vfsmount *mnt) 2795bool our_mnt(struct vfsmount *mnt)
2795{ 2796{
2796 return check_mnt(mnt); 2797 return check_mnt(real_mount(mnt));
2797} 2798}