History

fs: Add case sensitivity flags to file_kattr

Enable upper layers such as NFSD to retrieve case sensitivity information from file systems by adding FS_XFLAG_CASEFOLD and FS_XFLAG_CASENONPRESERVING flags. Filesystems report case-insensitive or case-nonpreserving behavior by setting these flags directly in fa->fsx_xflags. The default (flags unset) indicates POSIX semantics: case-sensitive and case-preserving. Both flags are added to FS_XFLAG_RDONLY_MASK so FS_IOC_FSSETXATTR silently strips them, keeping the new xflags strictly a reporting interface. Callers that want to toggle casefolding continue to use FS_IOC_SETFLAGS with FS_CASEFOLD_FL, the established UAPI on filesystems that support the operation (ext4 and f2fs on empty directories). Case sensitivity information is exported to userspace via the fa_xflags field in the FS_IOC_FSGETXATTR ioctl and file_getattr() system call.

Chuck Lever committed 6 months ago

Commit 3035e441 parent 14c31973 files · +13 −1Browse files

Unified · Split

3 files
  1. fs/file_attr.c +4 −0
  2. include/linux/fileattr.h +2 −1
  3. include/uapi/linux/fs.h +7 −0
fs/file_attr.c+4−0
@@ -37,6 +37,8 @@ void fileattr_fill_xflags(struct file_kattr *fa, u32 xflags) · 36 unmodified lines
3737 fa->flags |= FS_PROJINHERIT_FL;
3838 if (fa->fsx_xflags & FS_XFLAG_VERITY)
3939 fa->flags |= FS_VERITY_FL;
40+ if (fa->fsx_xflags & FS_XFLAG_CASEFOLD)
41+ fa->flags |= FS_CASEFOLD_FL;
4042 }
4143 EXPORT_SYMBOL(fileattr_fill_xflags);
4244
@@ -67,6 +69,8 @@ void fileattr_fill_flags(struct file_kattr *fa, u32 flags) · 24 unmodified lines
6769 fa->fsx_xflags |= FS_XFLAG_PROJINHERIT;
6870 if (fa->flags & FS_VERITY_FL)
6971 fa->fsx_xflags |= FS_XFLAG_VERITY;
72+ if (fa->flags & FS_CASEFOLD_FL)
73+ fa->fsx_xflags |= FS_XFLAG_CASEFOLD;
7074 }
7175 EXPORT_SYMBOL(fileattr_fill_flags);
7276
include/linux/fileattr.h+2−1
@@ -16,7 +16,8 @@ · 15 unmodified lines
1616
1717 /* Read-only inode flags */
1818 #define FS_XFLAG_RDONLY_MASK \
19− (FS_XFLAG_PREALLOC | FS_XFLAG_HASATTR | FS_XFLAG_VERITY)
19+ (FS_XFLAG_PREALLOC | FS_XFLAG_HASATTR | FS_XFLAG_VERITY | \
20+ FS_XFLAG_CASEFOLD | FS_XFLAG_CASENONPRESERVING)
2021
2122 /* Flags to indicate valid value of fsx_ fields */
2223 #define FS_XFLAG_VALUES_MASK \
include/uapi/linux/fs.h+7−0
@@ -254,6 +254,13 @@ struct file_attr { · 253 unmodified lines
254254 #define FS_XFLAG_DAX 0x00008000 /* use DAX for IO */
255255 #define FS_XFLAG_COWEXTSIZE 0x00010000 /* CoW extent size allocator hint */
256256 #define FS_XFLAG_VERITY 0x00020000 /* fs-verity enabled */
257+/*
258+ * Case handling flags (read-only, cannot be set via ioctl).
259+ * Default (neither set) indicates POSIX semantics: case-sensitive
260+ * lookups and case-preserving storage.
261+ */
262+#define FS_XFLAG_CASEFOLD 0x00040000 /* case-insensitive lookups */
263+#define FS_XFLAG_CASENONPRESERVING 0x00080000 /* case not preserved */
257264 #define FS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
258265
259266 /* the read-only stuff doesn't really belong here, but any other place is

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t