Skip to content

Commit

Permalink
VFS: Make pathwalk use d_is_reg() rather than S_ISREG()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
David Howells authored and Al Viro committed Apr 15, 2015
1 parent 7ceab50 commit 4bbcbd3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -3077,7 +3077,7 @@ static int do_last(struct nameidata *nd, struct path *path,
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) {
Expand Down

0 comments on commit 4bbcbd3

Please sign in to comment.