fix LOOKUP_FOLLOW on automount "symlinks"
authorAl Viro <viro@ZenIV.linux.org.uk>
Tue, 16 Feb 2010 18:09:36 +0000 (18:09 +0000)
committerAl Viro <viro@zeniv.linux.org.uk>
Fri, 19 Feb 2010 08:56:42 +0000 (03:56 -0500)
Make sure that automount "symlinks" are followed regardless of LOOKUP_FOLLOW;
it should have no effect on them.

Cc: stable@kernel.org
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/namei.c

index d62fdc875f22800a3d5c1a8c0a2532b0b6d51cc6..a4855af776a8b6670b753aa3af71203519de94a7 100644 (file)
@@ -822,6 +822,17 @@ fail:
        return PTR_ERR(dentry);
 }
 
+/*
+ * This is a temporary kludge to deal with "automount" symlinks; proper
+ * solution is to trigger them on follow_mount(), so that do_lookup()
+ * would DTRT.  To be killed before 2.6.34-final.
+ */
+static inline int follow_on_final(struct inode *inode, unsigned lookup_flags)
+{
+       return inode && unlikely(inode->i_op->follow_link) &&
+               ((lookup_flags & LOOKUP_FOLLOW) || S_ISDIR(inode->i_mode));
+}
+
 /*
  * Name resolution.
  * This is the basic name resolution function, turning a pathname into
@@ -942,8 +953,7 @@ last_component:
                if (err)
                        break;
                inode = next.dentry->d_inode;
-               if ((lookup_flags & LOOKUP_FOLLOW)
-                   && inode && inode->i_op->follow_link) {
+               if (follow_on_final(inode, lookup_flags)) {
                        err = do_follow_link(&next, nd);
                        if (err)
                                goto return_err;