aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2011-06-06 19:19:40 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2011-06-07 08:51:14 -0400
commite6bc45d65df8599fdbae73be9cec4ceed274db53 (patch)
tree2a9a5a0c0835b431d605332ebbfa6dad66e069f0 /fs/namei.c
parent9054760ff585a7fa436599990b63a585ae89ff4d (diff)
vfs: make unlink() and rmdir() return ENOENT in preference to EROFS
If user space attempts to remove a non-existent file or directory, and the file system is mounted read-only, return ENOENT instead of EROFS. Either error code is arguably valid/correct, but ENOENT is a more specific error message. Reported-by: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/fs/namei.c b/fs/namei.c
index e2e4e8d032ee..9802345df5e7 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2624,6 +2624,10 @@ static long do_rmdir(int dfd, const char __user *pathname)
2624 error = PTR_ERR(dentry); 2624 error = PTR_ERR(dentry);
2625 if (IS_ERR(dentry)) 2625 if (IS_ERR(dentry))
2626 goto exit2; 2626 goto exit2;
2627 if (!dentry->d_inode) {
2628 error = -ENOENT;
2629 goto exit3;
2630 }
2627 error = mnt_want_write(nd.path.mnt); 2631 error = mnt_want_write(nd.path.mnt);
2628 if (error) 2632 if (error)
2629 goto exit3; 2633 goto exit3;
@@ -2709,11 +2713,10 @@ static long do_unlinkat(int dfd, const char __user *pathname)
2709 error = PTR_ERR(dentry); 2713 error = PTR_ERR(dentry);
2710 if (!IS_ERR(dentry)) { 2714 if (!IS_ERR(dentry)) {
2711 /* Why not before? Because we want correct error value */ 2715 /* Why not before? Because we want correct error value */
2712 if (nd.last.name[nd.last.len])
2713 goto slashes;
2714 inode = dentry->d_inode; 2716 inode = dentry->d_inode;
2715 if (inode) 2717 if (nd.last.name[nd.last.len] || !inode)
2716 ihold(inode); 2718 goto slashes;
2719 ihold(inode);
2717 error = mnt_want_write(nd.path.mnt); 2720 error = mnt_want_write(nd.path.mnt);
2718 if (error) 2721 if (error)
2719 goto exit2; 2722 goto exit2;