[PATCH v2 4/6] ext4: Report case sensitivity in fileattr_get

Chuck Lever
2025-12-11T15:21:56Z

From: Chuck Lever <chuck.lever@oracle.com>

Report ext4's case sensitivity behavior via file_kattr.case_info.
ext4 always preserves case at rest.

Case sensitivity is a per-directory setting in ext4. If the queried
inode is a casefolded directory, report Unicode case-insensitive
matching; otherwise report case-sensitive (standard POSIX behavior).

This enables file_getattr to report the case sensitivity behavior of
individual directories within an ext4 filesystem.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
fs/ext4/ioctl.c | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index a93a7baae990..d760657bb9e2 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -996,6 +996,18 @@ int ext4_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
if (ext4_has_feature_project(inode->i_sb))
fa->fsx_projid = from_kprojid(&init_user_ns, ei->i_projid);

+ /*
+ * ext4 always preserves case. If this inode is a casefolded
+ * directory, report Unicode case-insensitive; otherwise
+ * report case-sensitive (standard POSIX behavior).
+ */
+ if (IS_CASEFOLDED(inode))
+ fa->case_info = FILEATTR_CASEFOLD_UNICODE |
+ FILEATTR_CASE_PRESERVING;
+ else
+ fa->case_info = FILEATTR_CASEFOLD_NONE |
+ FILEATTR_CASE_PRESERVING;
+
return 0;
}

--
2.52.0