Introduce file_getattr() and file_setattr() syscalls to manipulate inode extended attributes. The syscalls takes pair of file descriptor and pathname. Then it operates on inode opened accroding to openat() semantics. The struct file_attr is passed to obtain/change extended attributes. This is an alternative to FS_IOC_FSSETXATTR ioctl with a difference that file don't need to be open as we can reference it with a path instead of fd. By having this we can manipulated inode extended attributes not only on regular files but also on special ones. This is not possible with FS_IOC_FSSETXATTR ioctl as with special files we can not call ioctl() directly on the filesystem inode using fd. This patch adds two new syscalls which allows userspace to get/set extended inode attributes on special files by using parent directory and a path - *at() like syscall.
Showing the changes to include/uapi (2 of 21 files). Show all
Unified · Split
| @@ -852,8 +852,14 @@ __SYSCALL(__NR_removexattrat, sys_removexattrat) · 851 unmodified lines | |||
| 852 | #define __NR_open_tree_attr 467 | 852 | #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_syscalls | 861 | #undef __NR_syscalls |
| 856 | #define __NR_syscalls 468 | 862 | #define __NR_syscalls 470 |
| 857 | 863 | ||
| 858 | /* | 864 | /* |
| 859 | * 32 bit systems traditionally used different | 865 | * 32 bit systems traditionally used different |
| @@ -148,6 +148,24 @@ struct fsxattr { · 147 unmodified lines | |||
| 148 | unsigned char fsx_pad[8]; | 148 | unsigned char fsx_pad[8]; |
| 149 | }; | 149 | }; |
| 150 | 150 | ||
| 151 | /* | ||
| 152 | * Variable size structure for file_[sg]et_attr(). | ||
| 153 | * | ||
| 154 | * Note. This is alternative to the structure 'struct fileattr'/'struct fsxattr'. | ||
| 155 | * As this structure is passed to/from userspace with its size, this can | ||
| 156 | * be versioned based on the size. | ||
| 157 | */ | ||
| 158 | struct file_attr { | ||
| 159 | __u64 fa_xflags; /* xflags field value (get/set) */ | ||
| 160 | __u32 fa_extsize; /* extsize field value (get/set)*/ | ||
| 161 | __u32 fa_nextents; /* nextents field value (get) */ | ||
| 162 | __u32 fa_projid; /* project identifier (get/set) */ | ||
| 163 | __u32 fa_cowextsize; /* CoW extsize field value (get/set) */ | ||
| 164 | }; | ||
| 165 | |||
| 166 | #define FILE_ATTR_SIZE_VER0 24 | ||
| 167 | #define FILE_ATTR_SIZE_LATEST FILE_ATTR_SIZE_VER0 | ||
| 168 | |||
| 151 | /* | 169 | /* |
| 152 | * Flags for the fsx_xflags field | 170 | * Flags for the fsx_xflags field |
| 153 | */ | 171 | */ |