Skip to content

Commit

Permalink
vfs: do_last(): check LOOKUP_DIRECTORY
Browse files Browse the repository at this point in the history
Check for ENOTDIR before finishing open.  This allows this code to be shared
between O_CREAT and plain opens.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Miklos Szeredi authored and Al Viro committed Jun 1, 2012
1 parent 54c33e7 commit af2f554
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -2386,6 +2386,9 @@ static struct file *do_last(struct nameidata *nd, struct path *path,
error = -EISDIR;
if (S_ISDIR(nd->inode->i_mode))
goto exit;
error = -ENOTDIR;
if ((nd->flags & LOOKUP_DIRECTORY) && !nd->inode->i_op->lookup)
goto exit;
ok:
if (!S_ISREG(nd->inode->i_mode))
will_truncate = 0;
Expand Down

0 comments on commit af2f554

Please sign in to comment.