diff options
Diffstat (limited to 'fs/namei.c')
-rw-r--r-- | fs/namei.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/fs/namei.c b/fs/namei.c index 32fd9655485b..c7e43536c49a 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -2003,18 +2003,22 @@ struct dentry *lookup_create(struct nameidata *nd, int is_dir) | |||
2003 | if (IS_ERR(dentry)) | 2003 | if (IS_ERR(dentry)) |
2004 | goto fail; | 2004 | goto fail; |
2005 | 2005 | ||
2006 | if (dentry->d_inode) | ||
2007 | goto eexist; | ||
2006 | /* | 2008 | /* |
2007 | * Special case - lookup gave negative, but... we had foo/bar/ | 2009 | * Special case - lookup gave negative, but... we had foo/bar/ |
2008 | * From the vfs_mknod() POV we just have a negative dentry - | 2010 | * From the vfs_mknod() POV we just have a negative dentry - |
2009 | * all is fine. Let's be bastards - you had / on the end, you've | 2011 | * all is fine. Let's be bastards - you had / on the end, you've |
2010 | * been asking for (non-existent) directory. -ENOENT for you. | 2012 | * been asking for (non-existent) directory. -ENOENT for you. |
2011 | */ | 2013 | */ |
2012 | if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode) | 2014 | if (unlikely(!is_dir && nd->last.name[nd->last.len])) { |
2013 | goto enoent; | 2015 | dput(dentry); |
2016 | dentry = ERR_PTR(-ENOENT); | ||
2017 | } | ||
2014 | return dentry; | 2018 | return dentry; |
2015 | enoent: | 2019 | eexist: |
2016 | dput(dentry); | 2020 | dput(dentry); |
2017 | dentry = ERR_PTR(-ENOENT); | 2021 | dentry = ERR_PTR(-EEXIST); |
2018 | fail: | 2022 | fail: |
2019 | return dentry; | 2023 | return dentry; |
2020 | } | 2024 | } |