diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2010-01-30 13:16:21 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2010-03-03 14:07:55 -0500 |
commit | 2096f759abcb42200a81d776f597362fd9265024 (patch) | |
tree | f0784653a50713f9f91f39e24c40abacbfbb6427 /fs | |
parent | 495d6c9c6595ec7b37910dfd42634839431d21fd (diff) |
New helper: path_is_under(path1, path2)
Analog of is_subdir for vfsmount,dentry pairs, moved from audit_tree.c
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/dcache.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/fs/dcache.c b/fs/dcache.c index 4365998b8df4..74da947b160b 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
@@ -2191,6 +2191,30 @@ int is_subdir(struct dentry *new_dentry, struct dentry *old_dentry) | |||
2191 | return result; | 2191 | return result; |
2192 | } | 2192 | } |
2193 | 2193 | ||
2194 | int path_is_under(struct path *path1, struct path *path2) | ||
2195 | { | ||
2196 | struct vfsmount *mnt = path1->mnt; | ||
2197 | struct dentry *dentry = path1->dentry; | ||
2198 | int res; | ||
2199 | spin_lock(&vfsmount_lock); | ||
2200 | if (mnt != path2->mnt) { | ||
2201 | for (;;) { | ||
2202 | if (mnt->mnt_parent == mnt) { | ||
2203 | spin_unlock(&vfsmount_lock); | ||
2204 | return 0; | ||
2205 | } | ||
2206 | if (mnt->mnt_parent == path2->mnt) | ||
2207 | break; | ||
2208 | mnt = mnt->mnt_parent; | ||
2209 | } | ||
2210 | dentry = mnt->mnt_mountpoint; | ||
2211 | } | ||
2212 | res = is_subdir(dentry, path2->dentry); | ||
2213 | spin_unlock(&vfsmount_lock); | ||
2214 | return res; | ||
2215 | } | ||
2216 | EXPORT_SYMBOL(path_is_under); | ||
2217 | |||
2194 | void d_genocide(struct dentry *root) | 2218 | void d_genocide(struct dentry *root) |
2195 | { | 2219 | { |
2196 | struct dentry *this_parent = root; | 2220 | struct dentry *this_parent = root; |