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