aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2011-11-24 21:47:05 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2012-01-03 22:57:04 -0500
commit676da58df740f325034b8641311413c2393588e1 (patch)
tree88d1e385d368d73c7b1284da2fc46516879a867d
parent1ab597386205f8dc757cf8750465502aeae65154 (diff)
vfs: spread struct mount - mnt_has_parent
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/dcache.c3
-rw-r--r--fs/mount.h4
-rw-r--r--fs/namespace.c18
3 files changed, 13 insertions, 12 deletions
diff --git a/fs/dcache.c b/fs/dcache.c
index 64c8ce4c147f..1834e715f814 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -2460,8 +2460,9 @@ static int prepend_path(const struct path *path,
2460 struct dentry * parent; 2460 struct dentry * parent;
2461 2461
2462 if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) { 2462 if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
2463 struct mount *mnt = real_mount(vfsmnt);
2463 /* Global root? */ 2464 /* Global root? */
2464 if (!mnt_has_parent(vfsmnt)) 2465 if (!mnt_has_parent(mnt))
2465 goto global_root; 2466 goto global_root;
2466 dentry = vfsmnt->mnt_mountpoint; 2467 dentry = vfsmnt->mnt_mountpoint;
2467 vfsmnt = vfsmnt->mnt_parent; 2468 vfsmnt = vfsmnt->mnt_parent;
diff --git a/fs/mount.h b/fs/mount.h
index 831e7c86835b..541daf568f63 100644
--- a/fs/mount.h
+++ b/fs/mount.h
@@ -10,9 +10,9 @@ static inline struct mount *real_mount(struct vfsmount *mnt)
10 return container_of(mnt, struct mount, mnt); 10 return container_of(mnt, struct mount, mnt);
11} 11}
12 12
13static inline int mnt_has_parent(struct vfsmount *mnt) 13static inline int mnt_has_parent(struct mount *mnt)
14{ 14{
15 return mnt != mnt->mnt_parent; 15 return &mnt->mnt != mnt->mnt.mnt_parent;
16} 16}
17 17
18extern struct mount *__lookup_mnt(struct vfsmount *, struct dentry *, int); 18extern struct mount *__lookup_mnt(struct vfsmount *, struct dentry *, int);
diff --git a/fs/namespace.c b/fs/namespace.c
index 17927f9eeca4..ced3aa53fb38 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1195,7 +1195,7 @@ void release_mounts(struct list_head *head)
1195 while (!list_empty(head)) { 1195 while (!list_empty(head)) {
1196 mnt = list_first_entry(head, struct mount, mnt_hash); 1196 mnt = list_first_entry(head, struct mount, mnt_hash);
1197 list_del_init(&mnt->mnt_hash); 1197 list_del_init(&mnt->mnt_hash);
1198 if (mnt_has_parent(&mnt->mnt)) { 1198 if (mnt_has_parent(mnt)) {
1199 struct dentry *dentry; 1199 struct dentry *dentry;
1200 struct vfsmount *m; 1200 struct vfsmount *m;
1201 1201
@@ -1235,7 +1235,7 @@ void umount_tree(struct mount *mnt, int propagate, struct list_head *kill)
1235 p->mnt.mnt_ns = NULL; 1235 p->mnt.mnt_ns = NULL;
1236 __mnt_make_shortterm(&p->mnt); 1236 __mnt_make_shortterm(&p->mnt);
1237 list_del_init(&p->mnt.mnt_child); 1237 list_del_init(&p->mnt.mnt_child);
1238 if (mnt_has_parent(&p->mnt)) { 1238 if (mnt_has_parent(p)) {
1239 p->mnt.mnt_parent->mnt_ghosts++; 1239 p->mnt.mnt_parent->mnt_ghosts++;
1240 dentry_reset_mounted(p->mnt.mnt_mountpoint); 1240 dentry_reset_mounted(p->mnt.mnt_mountpoint);
1241 } 1241 }
@@ -1861,7 +1861,7 @@ static inline int tree_contains_unbindable(struct mount *mnt)
1861static int do_move_mount(struct path *path, char *old_name) 1861static int do_move_mount(struct path *path, char *old_name)
1862{ 1862{
1863 struct path old_path, parent_path; 1863 struct path old_path, parent_path;
1864 struct vfsmount *p; 1864 struct mount *p;
1865 struct mount *old; 1865 struct mount *old;
1866 int err = 0; 1866 int err = 0;
1867 if (!capable(CAP_SYS_ADMIN)) 1867 if (!capable(CAP_SYS_ADMIN))
@@ -1889,7 +1889,7 @@ static int do_move_mount(struct path *path, char *old_name)
1889 1889
1890 old = real_mount(old_path.mnt); 1890 old = real_mount(old_path.mnt);
1891 1891
1892 if (!mnt_has_parent(old_path.mnt)) 1892 if (!mnt_has_parent(old))
1893 goto out1; 1893 goto out1;
1894 1894
1895 if (S_ISDIR(path->dentry->d_inode->i_mode) != 1895 if (S_ISDIR(path->dentry->d_inode->i_mode) !=
@@ -1908,8 +1908,8 @@ static int do_move_mount(struct path *path, char *old_name)
1908 tree_contains_unbindable(old)) 1908 tree_contains_unbindable(old))
1909 goto out1; 1909 goto out1;
1910 err = -ELOOP; 1910 err = -ELOOP;
1911 for (p = path->mnt; mnt_has_parent(p); p = p->mnt_parent) 1911 for (p = real_mount(path->mnt); mnt_has_parent(p); p = real_mount(p->mnt.mnt_parent))
1912 if (p == old_path.mnt) 1912 if (p == old)
1913 goto out1; 1913 goto out1;
1914 1914
1915 err = attach_recursive_mnt(old, path, &parent_path); 1915 err = attach_recursive_mnt(old, path, &parent_path);
@@ -2562,7 +2562,7 @@ out_type:
2562bool is_path_reachable(struct vfsmount *mnt, struct dentry *dentry, 2562bool is_path_reachable(struct vfsmount *mnt, struct dentry *dentry,
2563 const struct path *root) 2563 const struct path *root)
2564{ 2564{
2565 while (mnt != root->mnt && mnt_has_parent(mnt)) { 2565 while (mnt != root->mnt && mnt_has_parent(real_mount(mnt))) {
2566 dentry = mnt->mnt_mountpoint; 2566 dentry = mnt->mnt_mountpoint;
2567 mnt = mnt->mnt_parent; 2567 mnt = mnt->mnt_parent;
2568 } 2568 }
@@ -2652,11 +2652,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
2652 error = -EINVAL; 2652 error = -EINVAL;
2653 if (root.mnt->mnt_root != root.dentry) 2653 if (root.mnt->mnt_root != root.dentry)
2654 goto out4; /* not a mountpoint */ 2654 goto out4; /* not a mountpoint */
2655 if (!mnt_has_parent(root.mnt)) 2655 if (!mnt_has_parent(root_mnt))
2656 goto out4; /* not attached */ 2656 goto out4; /* not attached */
2657 if (new.mnt->mnt_root != new.dentry) 2657 if (new.mnt->mnt_root != new.dentry)
2658 goto out4; /* not a mountpoint */ 2658 goto out4; /* not a mountpoint */
2659 if (!mnt_has_parent(new.mnt)) 2659 if (!mnt_has_parent(new_mnt))
2660 goto out4; /* not attached */ 2660 goto out4; /* not attached */
2661 /* make sure we can reach put_old from new_root */ 2661 /* make sure we can reach put_old from new_root */
2662 if (!is_path_reachable(old.mnt, old.dentry, &new)) 2662 if (!is_path_reachable(old.mnt, old.dentry, &new))