diff options
-rw-r--r-- | fs/nfs/dir.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 2884138848f4..408c3bb549b1 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -1994,6 +1994,19 @@ out: no_open: res = nfs_lookup(dir, dentry, lookup_flags); + if (!res) { + inode = d_inode(dentry); + if ((lookup_flags & LOOKUP_DIRECTORY) && inode && + !S_ISDIR(inode->i_mode)) + res = ERR_PTR(-ENOTDIR); + } else if (!IS_ERR(res)) { + inode = d_inode(res); + if ((lookup_flags & LOOKUP_DIRECTORY) && inode && + !S_ISDIR(inode->i_mode)) { + dput(res); + res = ERR_PTR(-ENOTDIR); + } + } if (switched) { d_lookup_done(dentry); if (!res) |