]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ntfs3: Implement fileattr_get for case sensitivity
authorChuck Lever <chuck.lever@oracle.com>
Thu, 7 May 2026 08:52:58 +0000 (04:52 -0400)
committerChristian Brauner <brauner@kernel.org>
Mon, 11 May 2026 14:50:28 +0000 (16:50 +0200)
Report NTFS case sensitivity behavior via the FS_XFLAG_CASEFOLD
flag. NTFS always preserves case at rest.

Reviewed-by: Roland Mainz <roland.mainz@nrubsig.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Link: https://patch.msgid.link/20260507-case-sensitivity-v14-5-e62cc8200435@oracle.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/ntfs3/file.c
fs/ntfs3/namei.c
fs/ntfs3/ntfs_fs.h

index b041639ab406f73096d9b79e0ae49bf2027b3426..ad9350d7fc3fddee3f871d0380b3f76587cea6f8 100644 (file)
@@ -180,6 +180,34 @@ long ntfs_compat_ioctl(struct file *filp, u32 cmd, unsigned long arg)
 }
 #endif
 
+/*
+ * ntfs_fileattr_get - inode_operations::fileattr_get
+ */
+int ntfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
+{
+       struct inode *inode = d_inode(dentry);
+       struct ntfs_sb_info *sbi = inode->i_sb->s_fs_info;
+
+       /* Avoid any operation if inode is bad. */
+       if (unlikely(is_bad_ni(ntfs_i(inode))))
+               return -EINVAL;
+
+       /*
+        * NTFS preserves case (the default). Case sensitivity depends on
+        * mount options: with "nocase", NTFS is case-insensitive;
+        * otherwise it is case-sensitive.
+        */
+       if (sbi->options->nocase) {
+               fa->fsx_xflags |= FS_XFLAG_CASEFOLD;
+               fa->flags |= FS_CASEFOLD_FL;
+       }
+       if (inode->i_flags & S_IMMUTABLE) {
+               fa->fsx_xflags |= FS_XFLAG_IMMUTABLE;
+               fa->flags |= FS_IMMUTABLE_FL;
+       }
+       return 0;
+}
+
 /*
  * ntfs_getattr - inode_operations::getattr
  */
@@ -1547,6 +1575,7 @@ const struct inode_operations ntfs_file_inode_operations = {
        .get_acl        = ntfs_get_acl,
        .set_acl        = ntfs_set_acl,
        .fiemap         = ntfs_fiemap,
+       .fileattr_get   = ntfs_fileattr_get,
 };
 
 const struct file_operations ntfs_file_operations = {
index b2af8f695e60fc314986f7b277a02faf0cd50f71..e159ba66a34a480ff2c4a7333dda4589cdf91544 100644 (file)
@@ -518,6 +518,7 @@ const struct inode_operations ntfs_dir_inode_operations = {
        .getattr        = ntfs_getattr,
        .listxattr      = ntfs_listxattr,
        .fiemap         = ntfs_fiemap,
+       .fileattr_get   = ntfs_fileattr_get,
 };
 
 const struct inode_operations ntfs_special_inode_operations = {
index bbf3b6a1dcbee462a68317844fc4b48192befb98..41db22d652c479d3c6aee025ed786a10fe135f5e 100644 (file)
@@ -529,6 +529,7 @@ bool dir_is_empty(struct inode *dir);
 extern const struct file_operations ntfs_dir_operations;
 
 /* Globals from file.c */
+int ntfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
 int ntfs_getattr(struct mnt_idmap *idmap, const struct path *path,
                 struct kstat *stat, u32 request_mask, u32 flags);
 int ntfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,