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