fs: return EPERM on immutable inode
Subsystems (3)
PATCH 1/1 fs: return EPERM on immutable inode
In most cases, EPERM is returned on immutable inode, and there're only a few places returning EACCES. And EPERM looks more reasonable to me.
So converting all EACCES to EPERM on immutable inode.
---
I noticed this when running LTP on overlayfs, setxattr03 failed due to unexpected EACCES on immutable inode.
fs/gfs2/inode.c | 2 +- fs/namei.c | 2 +- fs/utimes.c | 3 ++- fs/xfs/xfs_ioctl.c | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-)
fs/gfs2/inode.c +1 -1
@@ -1757,7 +1757,7 @@ int gfs2_permission(struct inode *inode, int mask) }if ((mask &MAY_WRITE ) &&IS_IMMUTABLE (inode)) - error = -EACCES ; + error = -EPERM ;else error =generic_permission (inode, mask);if (unlock)
fs/namei.c +1 -1
@@ -408,7 +408,7 @@ int __inode_permission(struct inode *inode, int mask)* Nobody gets write access to an immutable file. */ if (IS_IMMUTABLE (inode)) -return -EACCES ; +return -EPERM ; } retval =do_inode_permission (inode, mask);
fs/utimes.c +2 -1
@@ -92,10 +92,11 @@ static int utimes_common(struct path *path, struct timespec *times)* then we need to check permissions, because * inode_change_ok() won't do it. */ - error = -EACCES ; + error = -EPERM ;if (IS_IMMUTABLE (inode)) goto mnt_drop_write_and_out; + error = -EACCES ;if (!inode_owner_or_capable (inode)) { error =inode_permission (inode,MAY_WRITE );if (error)
fs/xfs/xfs_ioctl.c +1 -1
@@ -232,7 +232,7 @@ xfs_open_by_handle( }if ((fmode &FMODE_WRITE ) &&IS_IMMUTABLE (inode)) { - error = -EACCES ; + error = -EPERM ; goto out_dput; }
Signature · 1 line
2.5.5
Quoted 10 lines · Eryu Guan
In most cases, EPERM is returned on immutable inode, and there're only a few places returning EACCES. And EPERM looks more reasonable to me.
So converting all EACCES to EPERM on immutable inode.
Signed-off-by Eryu Guan <[email protected]>---
I noticed this when running LTP on overlayfs, setxattr03 failed due to unexpected EACCES on immutable inode.
This should be in the commit message itself, rather than "EPERM looks more reasonable".
Other than that, change seems fine to me.
Signature · 2 lines
Dave Chinner david at fromorbit.com
PATCH v2 1/1 fs: return EPERM on immutable inode
In reply to Eryu GuanIn most cases, EPERM is returned on immutable inode, and there're only a few places returning EACCES. I noticed this when running LTP on overlayfs, setxattr03 failed due to unexpected EACCES on immutable inode.
So converting all EACCES to EPERM on immutable inode.
---
v2:
- update commit message to include the background on noticing this issue
fs/gfs2/inode.c | 2 +- fs/namei.c | 2 +- fs/utimes.c | 3 ++- fs/xfs/xfs_ioctl.c | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-)
fs/gfs2/inode.c +1 -1
@@ -1757,7 +1757,7 @@ int gfs2_permission(struct inode *inode, int mask) }if ((mask &MAY_WRITE ) &&IS_IMMUTABLE (inode)) - error = -EACCES ; + error = -EPERM ;else error =generic_permission (inode, mask);if (unlock)
fs/namei.c +1 -1
@@ -408,7 +408,7 @@ int __inode_permission(struct inode *inode, int mask)* Nobody gets write access to an immutable file. */ if (IS_IMMUTABLE (inode)) -return -EACCES ; +return -EPERM ; } retval =do_inode_permission (inode, mask);
fs/utimes.c +2 -1
@@ -92,10 +92,11 @@ static int utimes_common(struct path *path, struct timespec *times)* then we need to check permissions, because * inode_change_ok() won't do it. */ - error = -EACCES ; + error = -EPERM ;if (IS_IMMUTABLE (inode)) goto mnt_drop_write_and_out; + error = -EACCES ;if (!inode_owner_or_capable (inode)) { error =inode_permission (inode,MAY_WRITE );if (error)
fs/xfs/xfs_ioctl.c +1 -1
@@ -232,7 +232,7 @@ xfs_open_by_handle( }if ((fmode &FMODE_WRITE ) &&IS_IMMUTABLE (inode)) { - error = -EACCES ; + error = -EPERM ; goto out_dput; }
Signature · 1 line
2.5.5