diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2011-11-23 19:26:23 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-01-03 22:52:36 -0500 |
commit | b2dba1af3c4157040303a76d25216b1713d333d0 (patch) | |
tree | c846b1c8074d29b9fc02ef3eeda98631dfd6ee94 /fs/namespace.c | |
parent | aa9c0e07bb90589186f3b5a0ca97660c2cb50806 (diff) |
vfs: new internal helper: mnt_has_parent(mnt)
vfsmounts have ->mnt_parent pointing either to a different vfsmount
or to itself; it's never NULL and termination condition in loops
traversing the tree towards root is mnt == mnt->mnt_parent. At least
one place (see the next patch) is confused about what's going on;
let's add an explicit helper checking it right way and use it in
all places where we need it. Not that there had been too many,
but...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namespace.c')
-rw-r--r-- | fs/namespace.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/fs/namespace.c b/fs/namespace.c index 31d357450f7f..ec8512478b04 100644 --- a/fs/namespace.c +++ b/fs/namespace.c | |||
@@ -1182,7 +1182,7 @@ void release_mounts(struct list_head *head) | |||
1182 | while (!list_empty(head)) { | 1182 | while (!list_empty(head)) { |
1183 | mnt = list_first_entry(head, struct vfsmount, mnt_hash); | 1183 | mnt = list_first_entry(head, struct vfsmount, mnt_hash); |
1184 | list_del_init(&mnt->mnt_hash); | 1184 | list_del_init(&mnt->mnt_hash); |
1185 | if (mnt->mnt_parent != mnt) { | 1185 | if (mnt_has_parent(mnt)) { |
1186 | struct dentry *dentry; | 1186 | struct dentry *dentry; |
1187 | struct vfsmount *m; | 1187 | struct vfsmount *m; |
1188 | 1188 | ||
@@ -1222,7 +1222,7 @@ void umount_tree(struct vfsmount *mnt, int propagate, struct list_head *kill) | |||
1222 | p->mnt_ns = NULL; | 1222 | p->mnt_ns = NULL; |
1223 | __mnt_make_shortterm(p); | 1223 | __mnt_make_shortterm(p); |
1224 | list_del_init(&p->mnt_child); | 1224 | list_del_init(&p->mnt_child); |
1225 | if (p->mnt_parent != p) { | 1225 | if (mnt_has_parent(p)) { |
1226 | p->mnt_parent->mnt_ghosts++; | 1226 | p->mnt_parent->mnt_ghosts++; |
1227 | dentry_reset_mounted(p->mnt_parent, p->mnt_mountpoint); | 1227 | dentry_reset_mounted(p->mnt_parent, p->mnt_mountpoint); |
1228 | } | 1228 | } |
@@ -1867,7 +1867,7 @@ static int do_move_mount(struct path *path, char *old_name) | |||
1867 | if (old_path.dentry != old_path.mnt->mnt_root) | 1867 | if (old_path.dentry != old_path.mnt->mnt_root) |
1868 | goto out1; | 1868 | goto out1; |
1869 | 1869 | ||
1870 | if (old_path.mnt == old_path.mnt->mnt_parent) | 1870 | if (!mnt_has_parent(old_path.mnt)) |
1871 | goto out1; | 1871 | goto out1; |
1872 | 1872 | ||
1873 | if (S_ISDIR(path->dentry->d_inode->i_mode) != | 1873 | if (S_ISDIR(path->dentry->d_inode->i_mode) != |
@@ -1887,7 +1887,7 @@ static int do_move_mount(struct path *path, char *old_name) | |||
1887 | tree_contains_unbindable(old_path.mnt)) | 1887 | tree_contains_unbindable(old_path.mnt)) |
1888 | goto out1; | 1888 | goto out1; |
1889 | err = -ELOOP; | 1889 | err = -ELOOP; |
1890 | for (p = path->mnt; p->mnt_parent != p; p = p->mnt_parent) | 1890 | for (p = path->mnt; mnt_has_parent(p); p = p->mnt_parent) |
1891 | if (p == old_path.mnt) | 1891 | if (p == old_path.mnt) |
1892 | goto out1; | 1892 | goto out1; |
1893 | 1893 | ||
@@ -2604,17 +2604,17 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root, | |||
2604 | error = -EINVAL; | 2604 | error = -EINVAL; |
2605 | if (root.mnt->mnt_root != root.dentry) | 2605 | if (root.mnt->mnt_root != root.dentry) |
2606 | goto out4; /* not a mountpoint */ | 2606 | goto out4; /* not a mountpoint */ |
2607 | if (root.mnt->mnt_parent == root.mnt) | 2607 | if (!mnt_has_parent(root.mnt)) |
2608 | goto out4; /* not attached */ | 2608 | goto out4; /* not attached */ |
2609 | if (new.mnt->mnt_root != new.dentry) | 2609 | if (new.mnt->mnt_root != new.dentry) |
2610 | goto out4; /* not a mountpoint */ | 2610 | goto out4; /* not a mountpoint */ |
2611 | if (new.mnt->mnt_parent == new.mnt) | 2611 | if (!mnt_has_parent(new.mnt)) |
2612 | goto out4; /* not attached */ | 2612 | goto out4; /* not attached */ |
2613 | /* make sure we can reach put_old from new_root */ | 2613 | /* make sure we can reach put_old from new_root */ |
2614 | tmp = old.mnt; | 2614 | tmp = old.mnt; |
2615 | if (tmp != new.mnt) { | 2615 | if (tmp != new.mnt) { |
2616 | for (;;) { | 2616 | for (;;) { |
2617 | if (tmp->mnt_parent == tmp) | 2617 | if (!mnt_has_parent(tmp)) |
2618 | goto out4; /* already mounted on put_old */ | 2618 | goto out4; /* already mounted on put_old */ |
2619 | if (tmp->mnt_parent == new.mnt) | 2619 | if (tmp->mnt_parent == new.mnt) |
2620 | break; | 2620 | break; |