aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namespace.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2011-11-24 19:41:16 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2012-01-03 22:56:59 -0500
commit419148da6e76dd0d379b5ec33c461cee1015322e (patch)
tree472aa2dc22174ffd0d62218946c7a91104e37733 /fs/namespace.c
parent315fc83e56c6998f67af24b49c619f40a6ff2803 (diff)
vfs: spread struct mount - attach_mnt/detach_mnt
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namespace.c')
-rw-r--r--fs/namespace.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/fs/namespace.c b/fs/namespace.c
index 7226dc514b3b..444557e04b38 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -556,14 +556,14 @@ static void dentry_reset_mounted(struct dentry *dentry)
556/* 556/*
557 * vfsmount lock must be held for write 557 * vfsmount lock must be held for write
558 */ 558 */
559static void detach_mnt(struct vfsmount *mnt, struct path *old_path) 559static void detach_mnt(struct mount *mnt, struct path *old_path)
560{ 560{
561 old_path->dentry = mnt->mnt_mountpoint; 561 old_path->dentry = mnt->mnt.mnt_mountpoint;
562 old_path->mnt = mnt->mnt_parent; 562 old_path->mnt = mnt->mnt.mnt_parent;
563 mnt->mnt_parent = mnt; 563 mnt->mnt.mnt_parent = &mnt->mnt;
564 mnt->mnt_mountpoint = mnt->mnt_root; 564 mnt->mnt.mnt_mountpoint = mnt->mnt.mnt_root;
565 list_del_init(&mnt->mnt_child); 565 list_del_init(&mnt->mnt.mnt_child);
566 list_del_init(&mnt->mnt_hash); 566 list_del_init(&mnt->mnt.mnt_hash);
567 dentry_reset_mounted(old_path->dentry); 567 dentry_reset_mounted(old_path->dentry);
568} 568}
569 569
@@ -583,12 +583,12 @@ void mnt_set_mountpoint(struct vfsmount *mnt, struct dentry *dentry,
583/* 583/*
584 * vfsmount lock must be held for write 584 * vfsmount lock must be held for write
585 */ 585 */
586static void attach_mnt(struct vfsmount *mnt, struct path *path) 586static void attach_mnt(struct mount *mnt, struct path *path)
587{ 587{
588 mnt_set_mountpoint(path->mnt, path->dentry, mnt); 588 mnt_set_mountpoint(path->mnt, path->dentry, &mnt->mnt);
589 list_add_tail(&mnt->mnt_hash, mount_hashtable + 589 list_add_tail(&mnt->mnt.mnt_hash, mount_hashtable +
590 hash(path->mnt, path->dentry)); 590 hash(path->mnt, path->dentry));
591 list_add_tail(&mnt->mnt_child, &path->mnt->mnt_mounts); 591 list_add_tail(&mnt->mnt.mnt_child, &path->mnt->mnt_mounts);
592} 592}
593 593
594static inline void __mnt_make_longterm(struct vfsmount *mnt) 594static inline void __mnt_make_longterm(struct vfsmount *mnt)
@@ -1446,7 +1446,7 @@ struct vfsmount *copy_tree(struct vfsmount *mnt, struct dentry *dentry,
1446 goto Enomem; 1446 goto Enomem;
1447 br_write_lock(vfsmount_lock); 1447 br_write_lock(vfsmount_lock);
1448 list_add_tail(&q->mnt_list, &res->mnt_list); 1448 list_add_tail(&q->mnt_list, &res->mnt_list);
1449 attach_mnt(q, &path); 1449 attach_mnt(real_mount(q), &path);
1450 br_write_unlock(vfsmount_lock); 1450 br_write_unlock(vfsmount_lock);
1451 } 1451 }
1452 } 1452 }
@@ -1612,8 +1612,8 @@ static int attach_recursive_mnt(struct vfsmount *source_mnt,
1612 set_mnt_shared(&p->mnt); 1612 set_mnt_shared(&p->mnt);
1613 } 1613 }
1614 if (parent_path) { 1614 if (parent_path) {
1615 detach_mnt(source_mnt, parent_path); 1615 detach_mnt(real_mount(source_mnt), parent_path);
1616 attach_mnt(source_mnt, path); 1616 attach_mnt(real_mount(source_mnt), path);
1617 touch_mnt_namespace(parent_path->mnt->mnt_ns); 1617 touch_mnt_namespace(parent_path->mnt->mnt_ns);
1618 } else { 1618 } else {
1619 mnt_set_mountpoint(dest_mnt, dest_dentry, source_mnt); 1619 mnt_set_mountpoint(dest_mnt, dest_dentry, source_mnt);
@@ -2600,6 +2600,7 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
2600 const char __user *, put_old) 2600 const char __user *, put_old)
2601{ 2601{
2602 struct path new, old, parent_path, root_parent, root; 2602 struct path new, old, parent_path, root_parent, root;
2603 struct mount *new_mnt, *root_mnt;
2603 int error; 2604 int error;
2604 2605
2605 if (!capable(CAP_SYS_ADMIN)) 2606 if (!capable(CAP_SYS_ADMIN))
@@ -2623,6 +2624,8 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
2623 goto out3; 2624 goto out3;
2624 2625
2625 error = -EINVAL; 2626 error = -EINVAL;
2627 new_mnt = real_mount(new.mnt);
2628 root_mnt = real_mount(root.mnt);
2626 if (IS_MNT_SHARED(old.mnt) || 2629 if (IS_MNT_SHARED(old.mnt) ||
2627 IS_MNT_SHARED(new.mnt->mnt_parent) || 2630 IS_MNT_SHARED(new.mnt->mnt_parent) ||
2628 IS_MNT_SHARED(root.mnt->mnt_parent)) 2631 IS_MNT_SHARED(root.mnt->mnt_parent))
@@ -2651,12 +2654,12 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
2651 if (!is_path_reachable(old.mnt, old.dentry, &new)) 2654 if (!is_path_reachable(old.mnt, old.dentry, &new))
2652 goto out4; 2655 goto out4;
2653 br_write_lock(vfsmount_lock); 2656 br_write_lock(vfsmount_lock);
2654 detach_mnt(new.mnt, &parent_path); 2657 detach_mnt(new_mnt, &parent_path);
2655 detach_mnt(root.mnt, &root_parent); 2658 detach_mnt(root_mnt, &root_parent);
2656 /* mount old root on put_old */ 2659 /* mount old root on put_old */
2657 attach_mnt(root.mnt, &old); 2660 attach_mnt(root_mnt, &old);
2658 /* mount new_root on / */ 2661 /* mount new_root on / */
2659 attach_mnt(new.mnt, &root_parent); 2662 attach_mnt(new_mnt, &root_parent);
2660 touch_mnt_namespace(current->nsproxy->mnt_ns); 2663 touch_mnt_namespace(current->nsproxy->mnt_ns);
2661 br_write_unlock(vfsmount_lock); 2664 br_write_unlock(vfsmount_lock);
2662 chroot_fs_refs(&root, &new); 2665 chroot_fs_refs(&root, &new);