diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2011-11-24 19:59:16 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-01-03 22:57:00 -0500 |
commit | 0fb54e50562d8d6f4b1a4517ba9783a9c7c5c2b7 (patch) | |
tree | 5cb0c780208f837b004b7cc0be18e6dff3839246 /fs/namespace.c | |
parent | 4b8b21f4fe16ee15eec5c69ea5fb41b30e428e59 (diff) |
vfs: spread struct mount - attach_recursive_mnt
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namespace.c')
-rw-r--r-- | fs/namespace.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/fs/namespace.c b/fs/namespace.c index 60d5c15c0879..64ae40c91079 100644 --- a/fs/namespace.c +++ b/fs/namespace.c | |||
@@ -1587,7 +1587,7 @@ static int invent_group_ids(struct mount *mnt, bool recurse) | |||
1587 | * Must be called without spinlocks held, since this function can sleep | 1587 | * Must be called without spinlocks held, since this function can sleep |
1588 | * in allocations. | 1588 | * in allocations. |
1589 | */ | 1589 | */ |
1590 | static int attach_recursive_mnt(struct vfsmount *source_mnt, | 1590 | static int attach_recursive_mnt(struct mount *source_mnt, |
1591 | struct path *path, struct path *parent_path) | 1591 | struct path *path, struct path *parent_path) |
1592 | { | 1592 | { |
1593 | LIST_HEAD(tree_list); | 1593 | LIST_HEAD(tree_list); |
@@ -1597,27 +1597,27 @@ static int attach_recursive_mnt(struct vfsmount *source_mnt, | |||
1597 | int err; | 1597 | int err; |
1598 | 1598 | ||
1599 | if (IS_MNT_SHARED(dest_mnt)) { | 1599 | if (IS_MNT_SHARED(dest_mnt)) { |
1600 | err = invent_group_ids(real_mount(source_mnt), true); | 1600 | err = invent_group_ids(source_mnt, true); |
1601 | if (err) | 1601 | if (err) |
1602 | goto out; | 1602 | goto out; |
1603 | } | 1603 | } |
1604 | err = propagate_mnt(dest_mnt, dest_dentry, source_mnt, &tree_list); | 1604 | err = propagate_mnt(dest_mnt, dest_dentry, &source_mnt->mnt, &tree_list); |
1605 | if (err) | 1605 | if (err) |
1606 | goto out_cleanup_ids; | 1606 | goto out_cleanup_ids; |
1607 | 1607 | ||
1608 | br_write_lock(vfsmount_lock); | 1608 | br_write_lock(vfsmount_lock); |
1609 | 1609 | ||
1610 | if (IS_MNT_SHARED(dest_mnt)) { | 1610 | if (IS_MNT_SHARED(dest_mnt)) { |
1611 | for (p = real_mount(source_mnt); p; p = next_mnt(p, source_mnt)) | 1611 | for (p = source_mnt; p; p = next_mnt(p, &source_mnt->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(real_mount(source_mnt), parent_path); | 1615 | detach_mnt(source_mnt, parent_path); |
1616 | attach_mnt(real_mount(source_mnt), path); | 1616 | attach_mnt(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->mnt); |
1620 | commit_tree(real_mount(source_mnt)); | 1620 | commit_tree(source_mnt); |
1621 | } | 1621 | } |
1622 | 1622 | ||
1623 | list_for_each_entry_safe(child, p, &tree_list, mnt.mnt_hash) { | 1623 | list_for_each_entry_safe(child, p, &tree_list, mnt.mnt_hash) { |
@@ -1630,7 +1630,7 @@ static int attach_recursive_mnt(struct vfsmount *source_mnt, | |||
1630 | 1630 | ||
1631 | out_cleanup_ids: | 1631 | out_cleanup_ids: |
1632 | if (IS_MNT_SHARED(dest_mnt)) | 1632 | if (IS_MNT_SHARED(dest_mnt)) |
1633 | cleanup_group_ids(real_mount(source_mnt), NULL); | 1633 | cleanup_group_ids(source_mnt, NULL); |
1634 | out: | 1634 | out: |
1635 | return err; | 1635 | return err; |
1636 | } | 1636 | } |
@@ -1674,7 +1674,7 @@ static int graft_tree(struct vfsmount *mnt, struct path *path) | |||
1674 | if (d_unlinked(path->dentry)) | 1674 | if (d_unlinked(path->dentry)) |
1675 | return -ENOENT; | 1675 | return -ENOENT; |
1676 | 1676 | ||
1677 | return attach_recursive_mnt(mnt, path, NULL); | 1677 | return attach_recursive_mnt(real_mount(mnt), path, NULL); |
1678 | } | 1678 | } |
1679 | 1679 | ||
1680 | /* | 1680 | /* |
@@ -1859,6 +1859,7 @@ static int do_move_mount(struct path *path, char *old_name) | |||
1859 | { | 1859 | { |
1860 | struct path old_path, parent_path; | 1860 | struct path old_path, parent_path; |
1861 | struct vfsmount *p; | 1861 | struct vfsmount *p; |
1862 | struct mount *old; | ||
1862 | int err = 0; | 1863 | int err = 0; |
1863 | if (!capable(CAP_SYS_ADMIN)) | 1864 | if (!capable(CAP_SYS_ADMIN)) |
1864 | return -EPERM; | 1865 | return -EPERM; |
@@ -1883,6 +1884,8 @@ static int do_move_mount(struct path *path, char *old_name) | |||
1883 | if (old_path.dentry != old_path.mnt->mnt_root) | 1884 | if (old_path.dentry != old_path.mnt->mnt_root) |
1884 | goto out1; | 1885 | goto out1; |
1885 | 1886 | ||
1887 | old = real_mount(old_path.mnt); | ||
1888 | |||
1886 | if (!mnt_has_parent(old_path.mnt)) | 1889 | if (!mnt_has_parent(old_path.mnt)) |
1887 | goto out1; | 1890 | goto out1; |
1888 | 1891 | ||
@@ -1906,7 +1909,7 @@ static int do_move_mount(struct path *path, char *old_name) | |||
1906 | if (p == old_path.mnt) | 1909 | if (p == old_path.mnt) |
1907 | goto out1; | 1910 | goto out1; |
1908 | 1911 | ||
1909 | err = attach_recursive_mnt(old_path.mnt, path, &parent_path); | 1912 | err = attach_recursive_mnt(old, path, &parent_path); |
1910 | if (err) | 1913 | if (err) |
1911 | goto out1; | 1914 | goto out1; |
1912 | 1915 | ||