History

Merge tag 'vfs-6.17-rc1.fileattr' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs

Pull fileattr updates from Christian Brauner: "This introduces the new file_getattr() and file_setattr() system calls after lengthy discussions. Both system calls serve as successors and extensible companions to the FS_IOC_FSGETXATTR and FS_IOC_FSSETXATTR system calls which have started to show their age in addition to being named in a way that makes it easy to conflate them with extended attribute related operations. These syscalls allow userspace to set filesystem inode attributes on special files. One of the usage examples is the XFS quota projects. XFS has project quotas which could be attached to a directory. All new inodes in these directories inherit project ID set on parent directory. The project is created from userspace by opening and calling FS_IOC_FSSETXATTR on each inode. This is not possible for special files such as FIFO, SOCK, BLK etc. Therefore, some inodes are left with empty project ID. Those inodes then are not shown in the quota accounting but still exist in the directory. This is not critical but in the case when special files are created in the directory with already existing project quota, these new inodes inherit extended attributes. This creates a mix of special files with and without attributes. Moreover, special files with attributes don't have a possibility to become clear or change the attributes. This, in turn, prevents userspace from re-creating quota project on these existing files. In addition, these new system calls allow the implementation of additional attributes that we couldn't or didn't want to fit into the legacy ioctls anymore" * tag 'vfs-6.17-rc1.fileattr' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs: fs: tighten a sanity check in file_attr_to_fileattr() tree-wide: s/struct fileattr/struct file_kattr/g fs: introduce file_getattr and file_setattr syscalls fs: prepare for extending file_get/setattr() fs: make vfs_fileattr_[get|set] return -EOPNOTSUPP selinux: implement inode_file_[g|s]etattr hooks lsm: introduce new hooks for setting/getting inode fsxattr fs: split fileattr related helpers into separate file

Linus Torvalds committed 1 year ago

Commit 57fcb7d2 parents cec40a7 e85931d64 files · +752 −410Browse files

Showing the changes to include/uapi (2 of 64 files). Show all

Unified · Split

2 files
  1. include/uapi/asm-generic/unistd.h +7 −1
  2. include/uapi/linux/fs.h +18 −0
include/uapi/asm-generic/unistd.h+7−1
@@ -852,8 +852,14 @@ __SYSCALL(__NR_removexattrat, sys_removexattrat) · 851 unmodified lines
852#define __NR_open_tree_attr 467852#define __NR_open_tree_attr 467
853__SYSCALL(__NR_open_tree_attr, sys_open_tree_attr)853__SYSCALL(__NR_open_tree_attr, sys_open_tree_attr)
854 854
855/* fs/inode.c */
856#define __NR_file_getattr 468
857__SYSCALL(__NR_file_getattr, sys_file_getattr)
858#define __NR_file_setattr 469
859__SYSCALL(__NR_file_setattr, sys_file_setattr)
860
855#undef __NR_syscalls861#undef __NR_syscalls
856#define __NR_syscalls 468862#define __NR_syscalls 470
857 863
858/*864/*
859 * 32 bit systems traditionally used different865 * 32 bit systems traditionally used different
include/uapi/linux/fs.h+18−0
@@ -216,6 +216,24 @@ struct fsxattr { · 215 unmodified lines
216 unsigned char fsx_pad[8];216 unsigned char fsx_pad[8];
217};217};
218 218
219/*
220 * Variable size structure for file_[sg]et_attr().
221 *
222 * Note. This is alternative to the structure 'struct file_kattr'/'struct fsxattr'.
223 * As this structure is passed to/from userspace with its size, this can
224 * be versioned based on the size.
225 */
226struct file_attr {
227 __u64 fa_xflags; /* xflags field value (get/set) */
228 __u32 fa_extsize; /* extsize field value (get/set)*/
229 __u32 fa_nextents; /* nextents field value (get) */
230 __u32 fa_projid; /* project identifier (get/set) */
231 __u32 fa_cowextsize; /* CoW extsize field value (get/set) */
232};
233
234#define FILE_ATTR_SIZE_VER0 24
235#define FILE_ATTR_SIZE_LATEST FILE_ATTR_SIZE_VER0
236
219/*237/*
220 * Flags for the fsx_xflags field238 * Flags for the fsx_xflags field
221 */239 */