Skip to content

Commit

Permalink
[PATCH] return to old errno choice in mkdir() et.al.
Browse files Browse the repository at this point in the history
	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>
  • Loading branch information
Al Viro committed May 16, 2008
1 parent 23c4971 commit e9baf6e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit e9baf6e

Please sign in to comment.