summary refs log tree commit diff
path: root/fs/namespace.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2016-12-16 16:34:52 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2016-12-16 16:34:52 -0500
commit9763f7a4a5f7b1a7c480fa06d01b2bad25163c0a (patch)
tree63e3f777b699ec26761eab948c40d70bba1476b0 /fs/namespace.c
parent3c55d6bcfe8163ff2b5636b4aabe3caa3f5d95f4 (diff)
parent1c4344a50d702307185cb98fb67bff938cd66aa0 (diff)
downloadlinux-9763f7a4a5f7b1a7c480fa06d01b2bad25163c0a.tar.gz
Merge branch 'work.autofs' into for-linus
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 9ad88a45b3e3..f7e28f8ea04d 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(const struct path *path)
 {
 	struct mount *p;