summaryrefslogtreecommitdiffstats
path: root/fs/namespace.c
diff options
context:
space:
mode:
authorIan Kent <ikent@redhat.com>2016-11-24 08:03:41 +1100
committerAl Viro <viro@zeniv.linux.org.uk>2016-12-03 20:51:35 -0500
commitc6609c0a1c34fc097152b28b496236625673924f (patch)
tree864cfb55fd8727e2a475ca44dd8d7df5a8488005 /fs/namespace.c
parentfb5f51c7425ebc808d91329257cbc963e2421368 (diff)
downloadop-kernel-dev-c6609c0a1c34fc097152b28b496236625673924f.zip
op-kernel-dev-c6609c0a1c34fc097152b28b496236625673924f.tar.gz
vfs: add path_is_mountpoint() helper
d_mountpoint() can only be used reliably to establish if a dentry is not mounted in any namespace. It isn't aware of the possibility there may be multiple mounts using a given dentry that may be in a different namespace. Add helper functions, path_is_mountpoint(), that checks if a struct path is a mountpoint for this case. Link: http://lkml.kernel.org/r/20161011053358.27645.9729.stgit@pluto.themaw.net Signed-off-by: Ian Kent <raven@themaw.net> Cc: Al Viro <viro@ZenIV.linux.org.uk> Cc: Eric W. Biederman <ebiederm@xmission.com> Cc: Omar Sandoval <osandov@osandov.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namespace.c')
-rw-r--r--fs/namespace.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/fs/namespace.c b/fs/namespace.c
index e6c234b..7a73383 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1159,6 +1159,35 @@ struct vfsmount *mntget(struct vfsmount *mnt)
}
EXPORT_SYMBOL(mntget);
+/* path_is_mountpoint() - Check if path is a mount in the current
+ * namespace.
+ *
+ * d_mountpoint() can only be used reliably to establish if a dentry is
+ * not mounted in any namespace and that common case is handled inline.
+ * d_mountpoint() isn't aware of the possibility there may be multiple
+ * mounts using a given dentry in a different namespace. This function
+ * checks if the passed in path is a mountpoint rather than the dentry
+ * alone.
+ */
+bool path_is_mountpoint(const struct path *path)
+{
+ unsigned seq;
+ bool res;
+
+ if (!d_mountpoint(path->dentry))
+ return false;
+
+ rcu_read_lock();
+ do {
+ seq = read_seqbegin(&mount_lock);
+ res = __path_is_mountpoint(path);
+ } while (read_seqretry(&mount_lock, seq));
+ rcu_read_unlock();
+
+ return res;
+}
+EXPORT_SYMBOL(path_is_mountpoint);
+
struct vfsmount *mnt_clone_internal(struct path *path)
{
struct mount *p;
OpenPOWER on IntegriCloud