fix LOOKUP_FOLLOW on automount "symlinks"
authorAl Viro <viro@ZenIV.linux.org.uk>
Tue, 16 Feb 2010 18:09:36 +0000 (18:09 +0000)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 15 Mar 2010 15:49:32 +0000 (08:49 -0700)
commit ac278a9c505092dd82077a2446af8f9fc0d9c095 upstream.

Make sure that automount "symlinks" are followed regardless of LOOKUP_FOLLOW;
it should have no effect on them.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/namei.c

index a2b3c28a499db4f6cd82221a80120cce08a767ed..b0afbd427be7abe4f27a3833b5cde21ac5c7d538 100644 (file)
@@ -828,6 +828,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
@@ -964,8 +975,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;