From 8d810183b5d2955b2edbb16c37b65d60f3468c7a Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 15 May 2008 04:49:12 -0400 Subject: [PATCH] --- yaml --- r: 96995 b: refs/heads/master c: e9baf6e59842285bcf9570f5094e4c27674a0f7c h: refs/heads/master i: 96993: 98ea9d5875ca62ba73bed0104b017bb99f7b4660 96991: bed64dda838268b9e595061b6c640cfb2055e866 v: v3 --- [refs] | 2 +- trunk/fs/namei.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index 573be06d3f3e..211ac2386f5d 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 23c4971e3d97de4e1b7961ca6eacee35aa15ce5f +refs/heads/master: e9baf6e59842285bcf9570f5094e4c27674a0f7c diff --git a/trunk/fs/namei.c b/trunk/fs/namei.c index 32fd9655485b..c7e43536c49a 100644 --- a/trunk/fs/namei.c +++ b/trunk/fs/namei.c @@ -2003,18 +2003,22 @@ struct dentry *lookup_create(struct nameidata *nd, int is_dir) if (IS_ERR(dentry)) goto fail; + if (dentry->d_inode) + goto eexist; /* * Special case - lookup gave negative, but... we had foo/bar/ * From the vfs_mknod() POV we just have a negative dentry - * all is fine. Let's be bastards - you had / on the end, you've * been asking for (non-existent) directory. -ENOENT for you. */ - if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode) - goto enoent; + if (unlikely(!is_dir && nd->last.name[nd->last.len])) { + dput(dentry); + dentry = ERR_PTR(-ENOENT); + } return dentry; -enoent: +eexist: dput(dentry); - dentry = ERR_PTR(-ENOENT); + dentry = ERR_PTR(-EEXIST); fail: return dentry; }