[PATCH 04/11] fuse2fs: better debugging for file mode updates
From: "Darrick J. Wong" <djwong@kernel.org>
Date: 2025-10-29 01:14:26
Also in:
linux-fsdevel
Subsystem:
the rest · Maintainer:
Linus Torvalds
From: Darrick J. Wong <djwong@kernel.org> Improve the tracing of a chmod operation so that we can debug file mode updates. Signed-off-by: "Darrick J. Wong" <djwong@kernel.org> --- fuse4fs/fuse4fs.c | 10 ++++++---- misc/fuse2fs.c | 12 +++++++----- 2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/fuse4fs/fuse4fs.c b/fuse4fs/fuse4fs.c
index 74b262b293eabc..7570950ca2458d 100644
--- a/fuse4fs/fuse4fs.c
+++ b/fuse4fs/fuse4fs.c@@ -3908,6 +3908,7 @@ static int fuse4fs_chmod(struct fuse4fs *ff, fuse_req_t req, ext2_ino_t ino, mode_t mode, struct ext2_inode_large *inode) { const struct fuse_ctx *ctxt = fuse_req_ctx(req); + mode_t new_mode; int ret = 0; dbg_printf(ff, "%s: ino=%d mode=0%o\n", __func__, ino, mode);
@@ -3934,11 +3935,12 @@ static int fuse4fs_chmod(struct fuse4fs *ff, fuse_req_t req, ext2_ino_t ino, mode &= ~S_ISGID; } - inode->i_mode &= ~0xFFF; - inode->i_mode |= mode & 0xFFF; + new_mode = (inode->i_mode & ~0xFFF) | (mode & 0xFFF); - dbg_printf(ff, "%s: ino=%d new_mode=0%o\n", - __func__, ino, inode->i_mode); + dbg_printf(ff, "%s: ino=%d old_mode=0%o new_mode=0%o\n", + __func__, ino, inode->i_mode, new_mode); + + inode->i_mode = new_mode; return 0; }
diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index 30fe10ef25da1d..fe6410a42a17ff 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c@@ -3601,6 +3601,7 @@ static int op_chmod(const char *path, mode_t mode, struct fuse_file_info *fi) errcode_t err; ext2_ino_t ino; struct ext2_inode_large inode; + mode_t new_mode; int ret = 0; FUSE2FS_CHECK_CONTEXT(ff);
@@ -3639,11 +3640,12 @@ static int op_chmod(const char *path, mode_t mode, struct fuse_file_info *fi) mode &= ~S_ISGID; } - inode.i_mode &= ~0xFFF; - inode.i_mode |= mode & 0xFFF; + new_mode = (inode.i_mode & ~0xFFF) | (mode & 0xFFF); - dbg_printf(ff, "%s: path=%s new_mode=0%o ino=%d\n", __func__, - path, inode.i_mode, ino); + dbg_printf(ff, "%s: path=%s old_mode=0%o new_mode=0%o ino=%d\n", + __func__, path, inode.i_mode, new_mode, ino); + + inode.i_mode = new_mode; ret = update_ctime(fs, ino, &inode); if (ret)
@@ -3663,12 +3665,12 @@ static int op_chmod(const char *path, mode_t mode, struct fuse_file_info *fi) static int op_chown(const char *path, uid_t owner, gid_t group, struct fuse_file_info *fi) { + struct ext2_inode_large inode; struct fuse_context *ctxt = fuse_get_context(); struct fuse2fs *ff = fuse2fs_get(); ext2_filsys fs; errcode_t err; ext2_ino_t ino; - struct ext2_inode_large inode; int ret = 0; FUSE2FS_CHECK_CONTEXT(ff);