From: Darrick J. Wong Date: Wed, 21 May 2025 22:39:36 +0000 (-0700) Subject: fuse2fs: return EPERM for write access to EXT2_IMMUTABLE_FL files X-Git-Tag: v1.47.3-rc1~46 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7f9166cd55c6ad1b62105b9aa54badb09bd612af;p=thirdparty%2Fe2fsprogs.git fuse2fs: return EPERM for write access to EXT2_IMMUTABLE_FL files The kernel drivers return EPERM for attempts to write to immutable files, so switch the error code. Signed-off-by: Darrick J. Wong Link: https://lore.kernel.org/r/174786677869.1383760.310634374176043971.stgit@frogsfrogsfrogs Signed-off-by: Theodore Ts'o --- diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index 49e94a9f..17c4d16c 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -546,11 +546,14 @@ static int check_inum_access(struct fuse2fs *ff, ext2_ino_t ino, int mask) return translate_error(fs, ino, err); perms = inode.i_mode & 0777; - dbg_printf(ff, "access ino=%d mask=e%s%s%s perms=0%o fuid=%d fgid=%d " - "uid=%d gid=%d\n", ino, - (mask & R_OK ? "r" : ""), (mask & W_OK ? "w" : ""), - (mask & X_OK ? "x" : ""), perms, inode_uid(inode), - inode_gid(inode), ctxt->uid, ctxt->gid); + dbg_printf(ff, "access ino=%d mask=e%s%s%s perms=0%o iflags=0x%x " + "fuid=%d fgid=%d uid=%d gid=%d\n", ino, + (mask & R_OK ? "r" : ""), + (mask & W_OK ? "w" : ""), + (mask & X_OK ? "x" : ""), + perms, inode.i_flags, + inode_uid(inode), inode_gid(inode), + ctxt->uid, ctxt->gid); /* existence check */ if (mask == 0) @@ -559,7 +562,7 @@ static int check_inum_access(struct fuse2fs *ff, ext2_ino_t ino, int mask) /* is immutable? */ if ((mask & W_OK) && (inode.i_flags & EXT2_IMMUTABLE_FL)) - return -EACCES; + return -EPERM; /* If kernel is responsible for mode and acl checks, we're done. */ if (ff->kernel)