VFS: Make pathwalk use d_is_reg() rather than S_ISREG()
authorDavid Howells <dhowells@redhat.com>
Tue, 17 Mar 2015 22:16:40 +0000 (22:16 +0000)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 15 Apr 2015 19:05:30 +0000 (15:05 -0400)
Make pathwalk use d_is_reg() rather than S_ISREG() to determine whether to
honour O_TRUNC.  Since this occurs after complete_walk(), the dentry type
field cannot change and the inode pointer cannot change as we hold a ref on
the dentry, so this should be safe.

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/namei.c

index 5a9291c..ffab2e0 100644 (file)
@@ -3077,7 +3077,7 @@ finish_open:
        error = -ENOTDIR;
        if ((nd->flags & LOOKUP_DIRECTORY) && !d_can_lookup(nd->path.dentry))
                goto out;
-       if (!S_ISREG(nd->inode->i_mode))
+       if (!d_is_reg(nd->path.dentry))
                will_truncate = false;
 
        if (will_truncate) {