1
2#ifndef _UAPI_LINUX_FS_H
3#define _UAPI_LINUX_FS_H
4
5
6
7
8
9
10
11
12
13#include <linux/limits.h>
14#include <linux/ioctl.h>
15#include <linux/types.h>
16
17
18#if !defined(__KERNEL__)
19#include <linux/mount.h>
20#endif
21
22
23
24
25
26
27
28
29
30
31
32
33#undef NR_OPEN
34#define INR_OPEN_CUR 1024
35#define INR_OPEN_MAX 4096
36
37#define BLOCK_SIZE_BITS 10
38#define BLOCK_SIZE (1<<BLOCK_SIZE_BITS)
39
40#define SEEK_SET 0
41#define SEEK_CUR 1
42#define SEEK_END 2
43#define SEEK_DATA 3
44#define SEEK_HOLE 4
45#define SEEK_MAX SEEK_HOLE
46
47#define RENAME_NOREPLACE (1 << 0)
48#define RENAME_EXCHANGE (1 << 1)
49#define RENAME_WHITEOUT (1 << 2)
50
51struct file_clone_range {
52 __s64 src_fd;
53 __u64 src_offset;
54 __u64 src_length;
55 __u64 dest_offset;
56};
57
58struct fstrim_range {
59 __u64 start;
60 __u64 len;
61 __u64 minlen;
62};
63
64
65#define FILE_DEDUPE_RANGE_SAME 0
66#define FILE_DEDUPE_RANGE_DIFFERS 1
67
68
69struct file_dedupe_range_info {
70 __s64 dest_fd;
71 __u64 dest_offset;
72 __u64 bytes_deduped;
73
74
75
76
77
78
79 __s32 status;
80 __u32 reserved;
81};
82
83
84struct file_dedupe_range {
85 __u64 src_offset;
86 __u64 src_length;
87 __u16 dest_count;
88 __u16 reserved1;
89 __u32 reserved2;
90 struct file_dedupe_range_info info[0];
91};
92
93
94struct files_stat_struct {
95 unsigned long nr_files;
96 unsigned long nr_free_files;
97 unsigned long max_files;
98};
99
100struct inodes_stat_t {
101 long nr_inodes;
102 long nr_unused;
103 long dummy[5];
104};
105
106
107#define NR_FILE 8192
108
109
110
111
112struct fsxattr {
113 __u32 fsx_xflags;
114 __u32 fsx_extsize;
115 __u32 fsx_nextents;
116 __u32 fsx_projid;
117 __u32 fsx_cowextsize;
118 unsigned char fsx_pad[8];
119};
120
121
122
123
124#define FS_XFLAG_REALTIME 0x00000001
125#define FS_XFLAG_PREALLOC 0x00000002
126#define FS_XFLAG_IMMUTABLE 0x00000008
127#define FS_XFLAG_APPEND 0x00000010
128#define FS_XFLAG_SYNC 0x00000020
129#define FS_XFLAG_NOATIME 0x00000040
130#define FS_XFLAG_NODUMP 0x00000080
131#define FS_XFLAG_RTINHERIT 0x00000100
132#define FS_XFLAG_PROJINHERIT 0x00000200
133#define FS_XFLAG_NOSYMLINKS 0x00000400
134#define FS_XFLAG_EXTSIZE 0x00000800
135#define FS_XFLAG_EXTSZINHERIT 0x00001000
136#define FS_XFLAG_NODEFRAG 0x00002000
137#define FS_XFLAG_FILESTREAM 0x00004000
138#define FS_XFLAG_DAX 0x00008000
139#define FS_XFLAG_COWEXTSIZE 0x00010000
140#define FS_XFLAG_HASATTR 0x80000000
141
142
143
144
145#define BLKROSET _IO(0x12,93)
146#define BLKROGET _IO(0x12,94)
147#define BLKRRPART _IO(0x12,95)
148#define BLKGETSIZE _IO(0x12,96)
149#define BLKFLSBUF _IO(0x12,97)
150#define BLKRASET _IO(0x12,98)
151#define BLKRAGET _IO(0x12,99)
152#define BLKFRASET _IO(0x12,100)
153#define BLKFRAGET _IO(0x12,101)
154#define BLKSECTSET _IO(0x12,102)
155#define BLKSECTGET _IO(0x12,103)
156#define BLKSSZGET _IO(0x12,104)
157#if 0
158#define BLKPG _IO(0x12,105)
159
160
161
162#define BLKELVGET _IOR(0x12,106,size_t)
163#define BLKELVSET _IOW(0x12,107,size_t)
164
165
166#endif
167
168#define BLKBSZGET _IOR(0x12,112,size_t)
169#define BLKBSZSET _IOW(0x12,113,size_t)
170#define BLKGETSIZE64 _IOR(0x12,114,size_t)
171#define BLKTRACESETUP _IOWR(0x12,115,struct blk_user_trace_setup)
172#define BLKTRACESTART _IO(0x12,116)
173#define BLKTRACESTOP _IO(0x12,117)
174#define BLKTRACETEARDOWN _IO(0x12,118)
175#define BLKDISCARD _IO(0x12,119)
176#define BLKIOMIN _IO(0x12,120)
177#define BLKIOOPT _IO(0x12,121)
178#define BLKALIGNOFF _IO(0x12,122)
179#define BLKPBSZGET _IO(0x12,123)
180#define BLKDISCARDZEROES _IO(0x12,124)
181#define BLKSECDISCARD _IO(0x12,125)
182#define BLKROTATIONAL _IO(0x12,126)
183#define BLKZEROOUT _IO(0x12,127)
184
185
186
187
188
189#define BMAP_IOCTL 1
190#define FIBMAP _IO(0x00,1)
191#define FIGETBSZ _IO(0x00,2)
192#define FIFREEZE _IOWR('X', 119, int)
193#define FITHAW _IOWR('X', 120, int)
194#define FITRIM _IOWR('X', 121, struct fstrim_range)
195#define FICLONE _IOW(0x94, 9, int)
196#define FICLONERANGE _IOW(0x94, 13, struct file_clone_range)
197#define FIDEDUPERANGE _IOWR(0x94, 54, struct file_dedupe_range)
198
199#define FSLABEL_MAX 256
200
201#define FS_IOC_GETFLAGS _IOR('f', 1, long)
202#define FS_IOC_SETFLAGS _IOW('f', 2, long)
203#define FS_IOC_GETVERSION _IOR('v', 1, long)
204#define FS_IOC_SETVERSION _IOW('v', 2, long)
205#define FS_IOC_FIEMAP _IOWR('f', 11, struct fiemap)
206#define FS_IOC32_GETFLAGS _IOR('f', 1, int)
207#define FS_IOC32_SETFLAGS _IOW('f', 2, int)
208#define FS_IOC32_GETVERSION _IOR('v', 1, int)
209#define FS_IOC32_SETVERSION _IOW('v', 2, int)
210#define FS_IOC_FSGETXATTR _IOR('X', 31, struct fsxattr)
211#define FS_IOC_FSSETXATTR _IOW('X', 32, struct fsxattr)
212#define FS_IOC_GETFSLABEL _IOR(0x94, 49, char[FSLABEL_MAX])
213#define FS_IOC_SETFSLABEL _IOW(0x94, 50, char[FSLABEL_MAX])
214
215
216
217
218
219#define FS_KEY_DESCRIPTOR_SIZE 8
220
221#define FS_POLICY_FLAGS_PAD_4 0x00
222#define FS_POLICY_FLAGS_PAD_8 0x01
223#define FS_POLICY_FLAGS_PAD_16 0x02
224#define FS_POLICY_FLAGS_PAD_32 0x03
225#define FS_POLICY_FLAGS_PAD_MASK 0x03
226#define FS_POLICY_FLAG_DIRECT_KEY 0x04
227#define FS_POLICY_FLAGS_VALID 0x07
228
229
230#define FS_ENCRYPTION_MODE_INVALID 0
231#define FS_ENCRYPTION_MODE_AES_256_XTS 1
232#define FS_ENCRYPTION_MODE_AES_256_GCM 2
233#define FS_ENCRYPTION_MODE_AES_256_CBC 3
234#define FS_ENCRYPTION_MODE_AES_256_CTS 4
235#define FS_ENCRYPTION_MODE_AES_128_CBC 5
236#define FS_ENCRYPTION_MODE_AES_128_CTS 6
237#define FS_ENCRYPTION_MODE_SPECK128_256_XTS 7
238#define FS_ENCRYPTION_MODE_SPECK128_256_CTS 8
239#define FS_ENCRYPTION_MODE_ADIANTUM 9
240
241struct fscrypt_policy {
242 __u8 version;
243 __u8 contents_encryption_mode;
244 __u8 filenames_encryption_mode;
245 __u8 flags;
246 __u8 master_key_descriptor[FS_KEY_DESCRIPTOR_SIZE];
247};
248
249#define FS_IOC_SET_ENCRYPTION_POLICY _IOR('f', 19, struct fscrypt_policy)
250#define FS_IOC_GET_ENCRYPTION_PWSALT _IOW('f', 20, __u8[16])
251#define FS_IOC_GET_ENCRYPTION_POLICY _IOW('f', 21, struct fscrypt_policy)
252
253
254#define FS_KEY_DESC_PREFIX "fscrypt:"
255#define FS_KEY_DESC_PREFIX_SIZE 8
256
257
258#define FS_MAX_KEY_SIZE 64
259
260struct fscrypt_key {
261 __u32 mode;
262 __u8 raw[FS_MAX_KEY_SIZE];
263 __u32 size;
264};
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286#define FS_SECRM_FL 0x00000001
287#define FS_UNRM_FL 0x00000002
288#define FS_COMPR_FL 0x00000004
289#define FS_SYNC_FL 0x00000008
290#define FS_IMMUTABLE_FL 0x00000010
291#define FS_APPEND_FL 0x00000020
292#define FS_NODUMP_FL 0x00000040
293#define FS_NOATIME_FL 0x00000080
294
295#define FS_DIRTY_FL 0x00000100
296#define FS_COMPRBLK_FL 0x00000200
297#define FS_NOCOMP_FL 0x00000400
298
299#define FS_ENCRYPT_FL 0x00000800
300#define FS_BTREE_FL 0x00001000
301#define FS_INDEX_FL 0x00001000
302#define FS_IMAGIC_FL 0x00002000
303#define FS_JOURNAL_DATA_FL 0x00004000
304#define FS_NOTAIL_FL 0x00008000
305#define FS_DIRSYNC_FL 0x00010000
306#define FS_TOPDIR_FL 0x00020000
307#define FS_HUGE_FILE_FL 0x00040000
308#define FS_EXTENT_FL 0x00080000
309#define FS_EA_INODE_FL 0x00200000
310#define FS_EOFBLOCKS_FL 0x00400000
311#define FS_NOCOW_FL 0x00800000
312#define FS_INLINE_DATA_FL 0x10000000
313#define FS_PROJINHERIT_FL 0x20000000
314#define FS_RESERVED_FL 0x80000000
315
316#define FS_FL_USER_VISIBLE 0x0003DFFF
317#define FS_FL_USER_MODIFIABLE 0x000380FF
318
319
320#define SYNC_FILE_RANGE_WAIT_BEFORE 1
321#define SYNC_FILE_RANGE_WRITE 2
322#define SYNC_FILE_RANGE_WAIT_AFTER 4
323
324
325
326
327
328typedef int __bitwise __kernel_rwf_t;
329
330
331#define RWF_HIPRI ((__force __kernel_rwf_t)0x00000001)
332
333
334#define RWF_DSYNC ((__force __kernel_rwf_t)0x00000002)
335
336
337#define RWF_SYNC ((__force __kernel_rwf_t)0x00000004)
338
339
340#define RWF_NOWAIT ((__force __kernel_rwf_t)0x00000008)
341
342
343#define RWF_APPEND ((__force __kernel_rwf_t)0x00000010)
344
345
346#define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT |\
347 RWF_APPEND)
348
349#endif
350