]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
fuse2fs: return EPERM for write access to EXT2_IMMUTABLE_FL files
authorDarrick J. Wong <djwong@kernel.org>
Wed, 21 May 2025 22:39:36 +0000 (15:39 -0700)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 23 May 2025 13:41:20 +0000 (09:41 -0400)
The kernel drivers return EPERM for attempts to write to immutable
files, so switch the error code.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786677869.1383760.310634374176043971.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
misc/fuse2fs.c

index 49e94a9f703f5997ab19c3cdad4d373612363cb0..17c4d16ce0f7de7bb990aa9c4a23abff4f6808a3 100644 (file)
@@ -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)