summaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
authorAl Viro2008-05-15 10:49:12 +0200
committerAl Viro2008-05-16 23:23:18 +0200
commite9baf6e59842285bcf9570f5094e4c27674a0f7c (patch)
tree12d5e9d762868bcc7aa97851240486d31314439b /fs/namei.c
parent[Patch] fs/binfmt_elf.c: fix wrong return values (diff)
downloadkernel-qcow2-linux-e9baf6e59842285bcf9570f5094e4c27674a0f7c.tar.gz
kernel-qcow2-linux-e9baf6e59842285bcf9570f5094e4c27674a0f7c.tar.xz
kernel-qcow2-linux-e9baf6e59842285bcf9570f5094e4c27674a0f7c.zip
[PATCH] return to old errno choice in mkdir() et.al.
In case when both EEXIST and EROFS would apply we used to return the former in mkdir(2) and friends. Lest anyone suspects us of being consistent, in the same situation knfsd gave clients nfs_erofs... ro-bind series had switched the syscall side of things to returning -EROFS and immediately broke an application - namely, mkdir -p. Patch restores the original behaviour... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c12
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)
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;
}