|
60 | 60 | #define RENAME_EXCHANGE (1 << 1) /* Exchange source and dest */ |
61 | 61 | #define RENAME_WHITEOUT (1 << 2) /* Whiteout source */ |
62 | 62 |
|
| 63 | +/* |
| 64 | + * The root inode of procfs is guaranteed to always have the same inode number. |
| 65 | + * For programs that make heavy use of procfs, verifying that the root is a |
| 66 | + * real procfs root and using openat2(RESOLVE_{NO_{XDEV,MAGICLINKS},BENEATH}) |
| 67 | + * will allow you to make sure you are never tricked into operating on the |
| 68 | + * wrong procfs file. |
| 69 | + */ |
| 70 | +enum procfs_ino { |
| 71 | + PROCFS_ROOT_INO = 1, |
| 72 | +}; |
| 73 | + |
63 | 74 | struct file_clone_range { |
64 | 75 | __s64 src_fd; |
65 | 76 | __u64 src_offset; |
@@ -91,6 +102,63 @@ struct fs_sysfs_path { |
91 | 102 | __u8 name[128]; |
92 | 103 | }; |
93 | 104 |
|
| 105 | +/* Protection info capability flags */ |
| 106 | +#define LBMD_PI_CAP_INTEGRITY (1 << 0) |
| 107 | +#define LBMD_PI_CAP_REFTAG (1 << 1) |
| 108 | + |
| 109 | +/* Checksum types for Protection Information */ |
| 110 | +#define LBMD_PI_CSUM_NONE 0 |
| 111 | +#define LBMD_PI_CSUM_IP 1 |
| 112 | +#define LBMD_PI_CSUM_CRC16_T10DIF 2 |
| 113 | +#define LBMD_PI_CSUM_CRC64_NVME 4 |
| 114 | + |
| 115 | +/* sizeof first published struct */ |
| 116 | +#define LBMD_SIZE_VER0 16 |
| 117 | + |
| 118 | +/* |
| 119 | + * Logical block metadata capability descriptor |
| 120 | + * If the device does not support metadata, all the fields will be zero. |
| 121 | + * Applications must check lbmd_flags to determine whether metadata is |
| 122 | + * supported or not. |
| 123 | + */ |
| 124 | +struct logical_block_metadata_cap { |
| 125 | + /* Bitmask of logical block metadata capability flags */ |
| 126 | + __u32 lbmd_flags; |
| 127 | + /* |
| 128 | + * The amount of data described by each unit of logical block |
| 129 | + * metadata |
| 130 | + */ |
| 131 | + __u16 lbmd_interval; |
| 132 | + /* |
| 133 | + * Size in bytes of the logical block metadata associated with each |
| 134 | + * interval |
| 135 | + */ |
| 136 | + __u8 lbmd_size; |
| 137 | + /* |
| 138 | + * Size in bytes of the opaque block tag associated with each |
| 139 | + * interval |
| 140 | + */ |
| 141 | + __u8 lbmd_opaque_size; |
| 142 | + /* |
| 143 | + * Offset in bytes of the opaque block tag within the logical block |
| 144 | + * metadata |
| 145 | + */ |
| 146 | + __u8 lbmd_opaque_offset; |
| 147 | + /* Size in bytes of the T10 PI tuple associated with each interval */ |
| 148 | + __u8 lbmd_pi_size; |
| 149 | + /* Offset in bytes of T10 PI tuple within the logical block metadata */ |
| 150 | + __u8 lbmd_pi_offset; |
| 151 | + /* T10 PI guard tag type */ |
| 152 | + __u8 lbmd_guard_tag_type; |
| 153 | + /* Size in bytes of the T10 PI application tag */ |
| 154 | + __u8 lbmd_app_tag_size; |
| 155 | + /* Size in bytes of the T10 PI reference tag */ |
| 156 | + __u8 lbmd_ref_tag_size; |
| 157 | + /* Size in bytes of the T10 PI storage tag */ |
| 158 | + __u8 lbmd_storage_tag_size; |
| 159 | + __u8 pad; |
| 160 | +}; |
| 161 | + |
94 | 162 | /* extent-same (dedupe) ioctls; these MUST match the btrfs ioctl definitions */ |
95 | 163 | #define FILE_DEDUPE_RANGE_SAME 0 |
96 | 164 | #define FILE_DEDUPE_RANGE_DIFFERS 1 |
@@ -148,6 +216,24 @@ struct fsxattr { |
148 | 216 | unsigned char fsx_pad[8]; |
149 | 217 | }; |
150 | 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 | + */ |
| 226 | +struct 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 | + |
151 | 237 | /* |
152 | 238 | * Flags for the fsx_xflags field |
153 | 239 | */ |
@@ -247,6 +333,8 @@ struct fsxattr { |
247 | 333 | * also /sys/kernel/debug/ for filesystems with debugfs exports |
248 | 334 | */ |
249 | 335 | #define FS_IOC_GETFSSYSFSPATH _IOR(0x15, 1, struct fs_sysfs_path) |
| 336 | +/* Get logical block metadata capability details */ |
| 337 | +#define FS_IOC_GETLBMD_CAP _IOWR(0x15, 2, struct logical_block_metadata_cap) |
250 | 338 |
|
251 | 339 | /* |
252 | 340 | * Inode flags (FS_IOC_GETFLAGS / FS_IOC_SETFLAGS) |
|
0 commit comments