1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18#ifndef __XFS_FS_H__
19#define __XFS_FS_H__
20
21
22
23
24
25
26
27
28
29
30#ifndef HAVE_DIOATTR
31struct dioattr {
32 __u32 d_mem;
33 __u32 d_miniosz;
34 __u32 d_maxiosz;
35};
36#endif
37
38
39
40
41
42
43
44
45#ifndef HAVE_GETBMAP
46struct getbmap {
47 __s64 bmv_offset;
48 __s64 bmv_block;
49 __s64 bmv_length;
50 __s32 bmv_count;
51 __s32 bmv_entries;
52};
53#endif
54
55
56
57
58
59
60
61
62
63
64#ifndef HAVE_GETBMAPX
65struct getbmapx {
66 __s64 bmv_offset;
67 __s64 bmv_block;
68 __s64 bmv_length;
69 __s32 bmv_count;
70 __s32 bmv_entries;
71 __s32 bmv_iflags;
72 __s32 bmv_oflags;
73 __s32 bmv_unused1;
74 __s32 bmv_unused2;
75};
76#endif
77
78
79#define BMV_IF_ATTRFORK 0x1
80#define BMV_IF_NO_DMAPI_READ 0x2
81#define BMV_IF_PREALLOC 0x4
82#define BMV_IF_DELALLOC 0x8
83#define BMV_IF_NO_HOLES 0x10
84#define BMV_IF_COWFORK 0x20
85#define BMV_IF_VALID \
86 (BMV_IF_ATTRFORK|BMV_IF_NO_DMAPI_READ|BMV_IF_PREALLOC| \
87 BMV_IF_DELALLOC|BMV_IF_NO_HOLES|BMV_IF_COWFORK)
88
89
90#define BMV_OF_PREALLOC 0x1
91#define BMV_OF_DELALLOC 0x2
92#define BMV_OF_LAST 0x4
93#define BMV_OF_SHARED 0x8
94
95
96#define XFS_FMR_OWN_FREE FMR_OWN_FREE
97#define XFS_FMR_OWN_UNKNOWN FMR_OWN_UNKNOWN
98#define XFS_FMR_OWN_FS FMR_OWNER('X', 1)
99#define XFS_FMR_OWN_LOG FMR_OWNER('X', 2)
100#define XFS_FMR_OWN_AG FMR_OWNER('X', 3)
101#define XFS_FMR_OWN_INOBT FMR_OWNER('X', 4)
102#define XFS_FMR_OWN_INODES FMR_OWNER('X', 5)
103#define XFS_FMR_OWN_REFC FMR_OWNER('X', 6)
104#define XFS_FMR_OWN_COW FMR_OWNER('X', 7)
105#define XFS_FMR_OWN_DEFECTIVE FMR_OWNER('X', 8)
106
107
108
109
110
111
112
113
114#ifndef HAVE_FSDMIDATA
115struct fsdmidata {
116 __u32 fsd_dmevmask;
117 __u16 fsd_padding;
118 __u16 fsd_dmstate;
119};
120#endif
121
122
123
124
125
126typedef struct xfs_flock64 {
127 __s16 l_type;
128 __s16 l_whence;
129 __s64 l_start;
130 __s64 l_len;
131 __s32 l_sysid;
132 __u32 l_pid;
133 __s32 l_pad[4];
134} xfs_flock64_t;
135
136
137
138
139typedef struct xfs_fsop_geom_v1 {
140 __u32 blocksize;
141 __u32 rtextsize;
142 __u32 agblocks;
143 __u32 agcount;
144 __u32 logblocks;
145 __u32 sectsize;
146 __u32 inodesize;
147 __u32 imaxpct;
148 __u64 datablocks;
149 __u64 rtblocks;
150 __u64 rtextents;
151 __u64 logstart;
152 unsigned char uuid[16];
153 __u32 sunit;
154 __u32 swidth;
155 __s32 version;
156 __u32 flags;
157 __u32 logsectsize;
158 __u32 rtsectsize;
159 __u32 dirblocksize;
160} xfs_fsop_geom_v1_t;
161
162
163
164
165typedef struct xfs_fsop_geom {
166 __u32 blocksize;
167 __u32 rtextsize;
168 __u32 agblocks;
169 __u32 agcount;
170 __u32 logblocks;
171 __u32 sectsize;
172 __u32 inodesize;
173 __u32 imaxpct;
174 __u64 datablocks;
175 __u64 rtblocks;
176 __u64 rtextents;
177 __u64 logstart;
178 unsigned char uuid[16];
179 __u32 sunit;
180 __u32 swidth;
181 __s32 version;
182 __u32 flags;
183 __u32 logsectsize;
184 __u32 rtsectsize;
185 __u32 dirblocksize;
186 __u32 logsunit;
187} xfs_fsop_geom_t;
188
189
190typedef struct xfs_fsop_counts {
191 __u64 freedata;
192 __u64 freertx;
193 __u64 freeino;
194 __u64 allocino;
195} xfs_fsop_counts_t;
196
197
198typedef struct xfs_fsop_resblks {
199 __u64 resblks;
200 __u64 resblks_avail;
201} xfs_fsop_resblks_t;
202
203#define XFS_FSOP_GEOM_VERSION 0
204
205#define XFS_FSOP_GEOM_FLAGS_ATTR 0x0001
206#define XFS_FSOP_GEOM_FLAGS_NLINK 0x0002
207#define XFS_FSOP_GEOM_FLAGS_QUOTA 0x0004
208#define XFS_FSOP_GEOM_FLAGS_IALIGN 0x0008
209#define XFS_FSOP_GEOM_FLAGS_DALIGN 0x0010
210#define XFS_FSOP_GEOM_FLAGS_SHARED 0x0020
211#define XFS_FSOP_GEOM_FLAGS_EXTFLG 0x0040
212#define XFS_FSOP_GEOM_FLAGS_DIRV2 0x0080
213#define XFS_FSOP_GEOM_FLAGS_LOGV2 0x0100
214#define XFS_FSOP_GEOM_FLAGS_SECTOR 0x0200
215#define XFS_FSOP_GEOM_FLAGS_ATTR2 0x0400
216#define XFS_FSOP_GEOM_FLAGS_PROJID32 0x0800
217#define XFS_FSOP_GEOM_FLAGS_DIRV2CI 0x1000
218#define XFS_FSOP_GEOM_FLAGS_LAZYSB 0x4000
219#define XFS_FSOP_GEOM_FLAGS_V5SB 0x8000
220#define XFS_FSOP_GEOM_FLAGS_FTYPE 0x10000
221#define XFS_FSOP_GEOM_FLAGS_FINOBT 0x20000
222#define XFS_FSOP_GEOM_FLAGS_SPINODES 0x40000
223#define XFS_FSOP_GEOM_FLAGS_RMAPBT 0x80000
224#define XFS_FSOP_GEOM_FLAGS_REFLINK 0x100000
225
226
227
228
229
230
231#define XFS_MIN_AG_BLOCKS 64
232#define XFS_MIN_LOG_BLOCKS 512ULL
233#define XFS_MAX_LOG_BLOCKS (1024 * 1024ULL)
234#define XFS_MIN_LOG_BYTES (10 * 1024 * 1024ULL)
235
236
237#define XFS_MAX_LOG_BYTES \
238 ((2 * 1024 * 1024 * 1024ULL) - XFS_MIN_LOG_BYTES)
239
240
241#define XFS_MAX_DBLOCKS(s) ((xfs_rfsblock_t)(s)->sb_agcount * (s)->sb_agblocks)
242#define XFS_MIN_DBLOCKS(s) ((xfs_rfsblock_t)((s)->sb_agcount - 1) * \
243 (s)->sb_agblocks + XFS_MIN_AG_BLOCKS)
244
245
246
247
248typedef struct xfs_growfs_data {
249 __u64 newblocks;
250 __u32 imaxpct;
251} xfs_growfs_data_t;
252
253typedef struct xfs_growfs_log {
254 __u32 newblocks;
255 __u32 isint;
256} xfs_growfs_log_t;
257
258typedef struct xfs_growfs_rt {
259 __u64 newblocks;
260 __u32 extsize;
261} xfs_growfs_rt_t;
262
263
264
265
266
267typedef struct xfs_bstime {
268 time_t tv_sec;
269 __s32 tv_nsec;
270} xfs_bstime_t;
271
272typedef struct xfs_bstat {
273 __u64 bs_ino;
274 __u16 bs_mode;
275 __u16 bs_nlink;
276 __u32 bs_uid;
277 __u32 bs_gid;
278 __u32 bs_rdev;
279 __s32 bs_blksize;
280 __s64 bs_size;
281 xfs_bstime_t bs_atime;
282 xfs_bstime_t bs_mtime;
283 xfs_bstime_t bs_ctime;
284 int64_t bs_blocks;
285 __u32 bs_xflags;
286 __s32 bs_extsize;
287 __s32 bs_extents;
288 __u32 bs_gen;
289 __u16 bs_projid_lo;
290#define bs_projid bs_projid_lo
291 __u16 bs_forkoff;
292 __u16 bs_projid_hi;
293 unsigned char bs_pad[6];
294 __u32 bs_cowextsize;
295 __u32 bs_dmevmask;
296 __u16 bs_dmstate;
297 __u16 bs_aextents;
298} xfs_bstat_t;
299
300
301
302
303
304
305static inline uint32_t
306bstat_get_projid(struct xfs_bstat *bs)
307{
308 return (uint32_t)bs->bs_projid_hi << 16 | bs->bs_projid_lo;
309}
310
311
312
313
314typedef struct xfs_fsop_bulkreq {
315 __u64 __user *lastip;
316 __s32 icount;
317 void __user *ubuffer;
318 __s32 __user *ocount;
319} xfs_fsop_bulkreq_t;
320
321
322
323
324
325typedef struct xfs_inogrp {
326 __u64 xi_startino;
327 __s32 xi_alloccount;
328 __u64 xi_allocmask;
329} xfs_inogrp_t;
330
331
332
333
334
335typedef struct xfs_error_injection {
336 __s32 fd;
337 __s32 errtag;
338} xfs_error_injection_t;
339
340
341
342
343
344#define XFS_EOFBLOCKS_VERSION 1
345struct xfs_fs_eofblocks {
346 __u32 eof_version;
347 __u32 eof_flags;
348 uid_t eof_uid;
349 gid_t eof_gid;
350 prid_t eof_prid;
351 __u32 pad32;
352 __u64 eof_min_file_size;
353 __u64 pad64[12];
354};
355
356
357#define XFS_EOF_FLAGS_SYNC (1 << 0)
358#define XFS_EOF_FLAGS_UID (1 << 1)
359#define XFS_EOF_FLAGS_GID (1 << 2)
360#define XFS_EOF_FLAGS_PRID (1 << 3)
361#define XFS_EOF_FLAGS_MINFILESIZE (1 << 4)
362#define XFS_EOF_FLAGS_UNION (1 << 5)
363
364
365#define XFS_EOF_FLAGS_VALID \
366 (XFS_EOF_FLAGS_SYNC | \
367 XFS_EOF_FLAGS_UID | \
368 XFS_EOF_FLAGS_GID | \
369 XFS_EOF_FLAGS_PRID | \
370 XFS_EOF_FLAGS_MINFILESIZE)
371
372
373
374
375
376typedef struct xfs_fsop_handlereq {
377 __u32 fd;
378 void __user *path;
379 __u32 oflags;
380 void __user *ihandle;
381 __u32 ihandlen;
382 void __user *ohandle;
383 __u32 __user *ohandlen;
384} xfs_fsop_handlereq_t;
385
386
387
388
389
390
391
392
393typedef struct xfs_fsop_setdm_handlereq {
394 struct xfs_fsop_handlereq hreq;
395 struct fsdmidata __user *data;
396} xfs_fsop_setdm_handlereq_t;
397
398typedef struct xfs_attrlist_cursor {
399 __u32 opaque[4];
400} xfs_attrlist_cursor_t;
401
402typedef struct xfs_fsop_attrlist_handlereq {
403 struct xfs_fsop_handlereq hreq;
404 struct xfs_attrlist_cursor pos;
405 __u32 flags;
406 __u32 buflen;
407 void __user *buffer;
408} xfs_fsop_attrlist_handlereq_t;
409
410typedef struct xfs_attr_multiop {
411 __u32 am_opcode;
412#define ATTR_OP_GET 1
413#define ATTR_OP_SET 2
414#define ATTR_OP_REMOVE 3
415 __s32 am_error;
416 void __user *am_attrname;
417 void __user *am_attrvalue;
418 __u32 am_length;
419 __u32 am_flags;
420} xfs_attr_multiop_t;
421
422typedef struct xfs_fsop_attrmulti_handlereq {
423 struct xfs_fsop_handlereq hreq;
424 __u32 opcount;
425 struct xfs_attr_multiop __user *ops;
426} xfs_fsop_attrmulti_handlereq_t;
427
428
429
430
431typedef struct { __u32 val[2]; } xfs_fsid_t;
432
433typedef struct xfs_fid {
434 __u16 fid_len;
435 __u16 fid_pad;
436 __u32 fid_gen;
437 __u64 fid_ino;
438} xfs_fid_t;
439
440typedef struct xfs_handle {
441 union {
442 __s64 align;
443 xfs_fsid_t _ha_fsid;
444 } ha_u;
445 xfs_fid_t ha_fid;
446} xfs_handle_t;
447#define ha_fsid ha_u._ha_fsid
448
449
450
451
452typedef struct xfs_swapext
453{
454 int64_t sx_version;
455#define XFS_SX_VERSION 0
456 int64_t sx_fdtarget;
457 int64_t sx_fdtmp;
458 xfs_off_t sx_offset;
459 xfs_off_t sx_length;
460 char sx_pad[16];
461 xfs_bstat_t sx_stat;
462} xfs_swapext_t;
463
464
465
466
467#define XFS_FSOP_GOING_FLAGS_DEFAULT 0x0
468#define XFS_FSOP_GOING_FLAGS_LOGFLUSH 0x1
469#define XFS_FSOP_GOING_FLAGS_NOLOGFLUSH 0x2
470
471
472
473
474#ifdef XATTR_LIST_MAX
475# define XFS_XATTR_LIST_MAX XATTR_LIST_MAX
476#else
477# define XFS_XATTR_LIST_MAX 65536
478#endif
479
480
481
482
483
484#define XFS_IOC_GETXFLAGS FS_IOC_GETFLAGS
485#define XFS_IOC_SETXFLAGS FS_IOC_SETFLAGS
486#define XFS_IOC_GETVERSION FS_IOC_GETVERSION
487
488
489
490
491
492
493#define XFS_IOC_ALLOCSP _IOW ('X', 10, struct xfs_flock64)
494#define XFS_IOC_FREESP _IOW ('X', 11, struct xfs_flock64)
495#define XFS_IOC_DIOINFO _IOR ('X', 30, struct dioattr)
496#define XFS_IOC_FSGETXATTR FS_IOC_FSGETXATTR
497#define XFS_IOC_FSSETXATTR FS_IOC_FSSETXATTR
498#define XFS_IOC_ALLOCSP64 _IOW ('X', 36, struct xfs_flock64)
499#define XFS_IOC_FREESP64 _IOW ('X', 37, struct xfs_flock64)
500#define XFS_IOC_GETBMAP _IOWR('X', 38, struct getbmap)
501#define XFS_IOC_FSSETDM _IOW ('X', 39, struct fsdmidata)
502#define XFS_IOC_RESVSP _IOW ('X', 40, struct xfs_flock64)
503#define XFS_IOC_UNRESVSP _IOW ('X', 41, struct xfs_flock64)
504#define XFS_IOC_RESVSP64 _IOW ('X', 42, struct xfs_flock64)
505#define XFS_IOC_UNRESVSP64 _IOW ('X', 43, struct xfs_flock64)
506#define XFS_IOC_GETBMAPA _IOWR('X', 44, struct getbmap)
507#define XFS_IOC_FSGETXATTRA _IOR ('X', 45, struct fsxattr)
508
509
510#define XFS_IOC_GETBMAPX _IOWR('X', 56, struct getbmap)
511#define XFS_IOC_ZERO_RANGE _IOW ('X', 57, struct xfs_flock64)
512#define XFS_IOC_FREE_EOFBLOCKS _IOR ('X', 58, struct xfs_fs_eofblocks)
513
514
515
516
517
518#define XFS_IOC_FSGEOMETRY_V1 _IOR ('X', 100, struct xfs_fsop_geom_v1)
519#define XFS_IOC_FSBULKSTAT _IOWR('X', 101, struct xfs_fsop_bulkreq)
520#define XFS_IOC_FSBULKSTAT_SINGLE _IOWR('X', 102, struct xfs_fsop_bulkreq)
521#define XFS_IOC_FSINUMBERS _IOWR('X', 103, struct xfs_fsop_bulkreq)
522#define XFS_IOC_PATH_TO_FSHANDLE _IOWR('X', 104, struct xfs_fsop_handlereq)
523#define XFS_IOC_PATH_TO_HANDLE _IOWR('X', 105, struct xfs_fsop_handlereq)
524#define XFS_IOC_FD_TO_HANDLE _IOWR('X', 106, struct xfs_fsop_handlereq)
525#define XFS_IOC_OPEN_BY_HANDLE _IOWR('X', 107, struct xfs_fsop_handlereq)
526#define XFS_IOC_READLINK_BY_HANDLE _IOWR('X', 108, struct xfs_fsop_handlereq)
527#define XFS_IOC_SWAPEXT _IOWR('X', 109, struct xfs_swapext)
528#define XFS_IOC_FSGROWFSDATA _IOW ('X', 110, struct xfs_growfs_data)
529#define XFS_IOC_FSGROWFSLOG _IOW ('X', 111, struct xfs_growfs_log)
530#define XFS_IOC_FSGROWFSRT _IOW ('X', 112, struct xfs_growfs_rt)
531#define XFS_IOC_FSCOUNTS _IOR ('X', 113, struct xfs_fsop_counts)
532#define XFS_IOC_SET_RESBLKS _IOWR('X', 114, struct xfs_fsop_resblks)
533#define XFS_IOC_GET_RESBLKS _IOR ('X', 115, struct xfs_fsop_resblks)
534#define XFS_IOC_ERROR_INJECTION _IOW ('X', 116, struct xfs_error_injection)
535#define XFS_IOC_ERROR_CLEARALL _IOW ('X', 117, struct xfs_error_injection)
536
537
538#define XFS_IOC_FREEZE _IOWR('X', 119, int)
539#define XFS_IOC_THAW _IOWR('X', 120, int)
540
541#define XFS_IOC_FSSETDM_BY_HANDLE _IOW ('X', 121, struct xfs_fsop_setdm_handlereq)
542#define XFS_IOC_ATTRLIST_BY_HANDLE _IOW ('X', 122, struct xfs_fsop_attrlist_handlereq)
543#define XFS_IOC_ATTRMULTI_BY_HANDLE _IOW ('X', 123, struct xfs_fsop_attrmulti_handlereq)
544#define XFS_IOC_FSGEOMETRY _IOR ('X', 124, struct xfs_fsop_geom)
545#define XFS_IOC_GOINGDOWN _IOR ('X', 125, uint32_t)
546
547
548
549#ifndef HAVE_BBMACROS
550
551
552
553
554
555#define BBSHIFT 9
556#define BBSIZE (1<<BBSHIFT)
557#define BBMASK (BBSIZE-1)
558#define BTOBB(bytes) (((__u64)(bytes) + BBSIZE - 1) >> BBSHIFT)
559#define BTOBBT(bytes) ((__u64)(bytes) >> BBSHIFT)
560#define BBTOB(bbs) ((bbs) << BBSHIFT)
561#endif
562
563#endif
564