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
37 fa->flags |= FS_PROJINHERIT_FL;37 fa->flags |= FS_PROJINHERIT_FL;
38 if (fa->fsx_xflags & FS_XFLAG_VERITY)38 if (fa->fsx_xflags & FS_XFLAG_VERITY)
39 fa->flags |= FS_VERITY_FL;39 fa->flags |= FS_VERITY_FL;
40 if (fa->fsx_xflags & FS_XFLAG_CASEFOLD)
41 fa->flags |= FS_CASEFOLD_FL;
40}42}
41EXPORT_SYMBOL(fileattr_fill_xflags);43EXPORT_SYMBOL(fileattr_fill_xflags);
42 44
@@ -67,6 +69,8 @@ void fileattr_fill_flags(struct file_kattr *fa, u32 flags) · 24 unmodified lines
67 fa->fsx_xflags |= FS_XFLAG_PROJINHERIT;69 fa->fsx_xflags |= FS_XFLAG_PROJINHERIT;
68 if (fa->flags & FS_VERITY_FL)70 if (fa->flags & FS_VERITY_FL)
69 fa->fsx_xflags |= FS_XFLAG_VERITY;71 fa->fsx_xflags |= FS_XFLAG_VERITY;
72 if (fa->flags & FS_CASEFOLD_FL)
73 fa->fsx_xflags |= FS_XFLAG_CASEFOLD;
70}74}
71EXPORT_SYMBOL(fileattr_fill_flags);75EXPORT_SYMBOL(fileattr_fill_flags);
72 76
include/linux/fileattr.h+2−1
@@ -16,7 +16,8 @@ · 15 unmodified lines
16 16
17/* Read-only inode flags */17/* Read-only inode flags */
18#define FS_XFLAG_RDONLY_MASK \18#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)
20 21
21/* Flags to indicate valid value of fsx_ fields */22/* Flags to indicate valid value of fsx_ fields */
22#define FS_XFLAG_VALUES_MASK \23#define FS_XFLAG_VALUES_MASK \
include/uapi/linux/fs.h+7−0
@@ -254,6 +254,13 @@ struct file_attr { · 253 unmodified lines
254#define FS_XFLAG_DAX 0x00008000 /* use DAX for IO */254#define FS_XFLAG_DAX 0x00008000 /* use DAX for IO */
255#define FS_XFLAG_COWEXTSIZE 0x00010000 /* CoW extent size allocator hint */255#define FS_XFLAG_COWEXTSIZE 0x00010000 /* CoW extent size allocator hint */
256#define FS_XFLAG_VERITY 0x00020000 /* fs-verity enabled */256#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 */
257#define FS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */264#define FS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
258 265
259/* the read-only stuff doesn't really belong here, but any other place is266/* 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