]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - include/irix.h
Update xfsprogs to latest kernel headers and functions
[thirdparty/xfsprogs-dev.git] / include / irix.h
1 /*
2 * Copyright (c) 2000-2006 Silicon Graphics, Inc.
3 * All Rights Reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public License
7 * as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 #ifndef __XFS_IRIX_H__
19 #define __XFS_IRIX_H__
20
21 #include <stdlib.h>
22 #include <unistd.h>
23 #include <libgen.h>
24 #include <values.h>
25 #include <strings.h>
26 #include <inttypes.h>
27 #include <limits.h>
28 #include <fcntl.h>
29 #include <sys/stat.h>
30 #include <sys/uuid.h>
31 #include <sys/param.h>
32 #include <sys/ioctl.h>
33 #include <sys/types.h>
34 #include <sys/statfs.h>
35 #include <sys/statvfs.h>
36 #include <sys/syssgi.h>
37 #include <sys/sysmacros.h>
38 #include <sys/fs/xfs_fsops.h>
39 #include <sys/fs/xfs_itable.h>
40
41 #define __int8_t char
42 #define __int16_t short
43 #define __uint8_t unsigned char
44 #define __uint16_t unsigned short
45 #define loff_t off64_t
46 typedef off64_t xfs_off_t;
47 typedef __int64_t xfs_ino_t;
48 typedef __int32_t xfs_dev_t;
49 typedef __int64_t xfs_daddr_t;
50 typedef char* xfs_caddr_t;
51
52 #define xfs_flock64 flock64
53 #define xfs_flock64_t struct flock64
54
55 typedef struct xfs_error_injection {
56 __int32_t fd;
57 __int32_t errtag;
58 } xfs_error_injection_t;
59
60 /* --- xfs_fsop_*req - request data structures --- */
61
62 typedef struct xfs_fsop_bulkreq {
63 ino64_t *lastip;
64 __int32_t icount;
65 xfs_bstat_t *ubuffer;
66 __int32_t *ocount;
67 } xfs_fsop_bulkreq_t;
68
69 typedef struct xfs_fsop_handlereq {
70 __u32 fd; /* fd for FD_TO_HANDLE */
71 void *path; /* user pathname */
72 __u32 oflags; /* open flags */
73 void *ihandle; /* user supplied handle */
74 __u32 ihandlen; /* user supplied length */
75 void *ohandle; /* user buffer for handle */
76 __u32 *ohandlen; /* user buffer length */
77 } xfs_fsop_handlereq_t;
78
79 typedef struct xfs_fsop_setdm_handlereq {
80 struct xfs_fsop_handlereq hreq; /* handle information */
81 struct fsdmidata *data; /* DMAPI data */
82 } xfs_fsop_setdm_handlereq_t;
83
84 typedef struct xfs_attrlist_cursor {
85 __u32 opaque[4];
86 } xfs_attrlist_cursor_t;
87
88 typedef struct xfs_fsop_attrlist_handlereq {
89 struct xfs_fsop_handlereq hreq; /* handle interface structure */
90 struct xfs_attrlist_cursor pos; /* opaque cookie, list offset */
91 __u32 flags; /* which namespace to use */
92 __u32 buflen; /* length of buffer supplied */
93 void *buffer; /* returned names */
94 } xfs_fsop_attrlist_handlereq_t;
95
96 typedef struct xfs_fsop_getparents_handlereq {
97 struct xfs_fsop_handlereq hreq; /* handle interface structure */
98 struct xfs_attrlist_cursor pos; /* opaque cookie, list offset */
99 __u32 buflen; /* length of buffer supplied */
100 void *buffer; /* returned data */
101 __u32 *ocount; /* return number of links */
102 __u32 *omore; /* return whether more to come */
103 } xfs_fsop_getparents_handlereq_t;
104
105 typedef struct xfs_attr_multiop {
106 __u32 am_opcode;
107 __s32 am_error;
108 void *am_attrname;
109 void *am_attrvalue;
110 __u32 am_length;
111 __u32 am_flags;
112 } xfs_attr_multiop_t;
113
114 typedef struct xfs_fsop_attrmulti_handlereq {
115 struct xfs_fsop_handlereq hreq; /* handle interface structure */
116 __u32 opcount;/* count of following multiop */
117 struct xfs_attr_multiop *ops; /* attr_multi data */
118 } xfs_fsop_attrmulti_handlereq_t;
119
120 /* start doing packed stuctures here */
121 #define HAVE_FORMAT32 1
122 #pragma pack 1
123 typedef struct xfs_inode_log_format_32 {
124 __u16 ilf_type; /* inode log item type */
125 __u16 ilf_size; /* size of this item */
126 __u32 ilf_fields; /* flags for fields logged */
127 __u16 ilf_asize; /* size of attr d/ext/root */
128 __u16 ilf_dsize; /* size of data/ext/root */
129 __u64 ilf_ino; /* inode number */
130 union {
131 __u32 ilfu_rdev; /* rdev value for dev inode*/
132 uuid_t ilfu_uuid; /* mount point value */
133 } ilf_u;
134 __s64 ilf_blkno; /* blkno of inode buffer */
135 __s32 ilf_len; /* len of inode buffer */
136 __s32 ilf_boffset; /* off of inode in buffer */
137 } xfs_inode_log_format_32_t;
138
139 typedef struct xfs_extent_32 {
140 __u64 ext_start;
141 __u32 ext_len;
142 } xfs_extent_32_t;
143
144 typedef struct xfs_efi_log_format_32 {
145 __u16 efi_type; /* efi log item type */
146 __u16 efi_size; /* size of this item */
147 __u32 efi_nextents; /* # extents to free */
148 __u64 efi_id; /* efi identifier */
149 xfs_extent_32_t efi_extents[1]; /* array of extents to free */
150 } xfs_efi_log_format_32_t;
151
152 typedef struct xfs_efd_log_format_32 {
153 __u16 efd_type; /* efd log item type */
154 __u16 efd_size; /* size of this item */
155 __u32 efd_nextents; /* # of extents freed */
156 __u64 efd_efi_id; /* id of corresponding efi */
157 xfs_extent_32_t efd_extents[1]; /* array of extents freed */
158 } xfs_efd_log_format_32_t;
159
160 #pragma pack 0
161 /* end of packed stuctures */
162
163 #include <sys/endian.h>
164 #define __BYTE_ORDER BYTE_ORDER
165 #define __BIG_ENDIAN BIG_ENDIAN
166 #define __LITTLE_ENDIAN LITTLE_ENDIAN
167
168 /* Map some gcc macros for the MipsPRO compiler */
169 #ifndef __GNUC__
170 #define __builtin_constant_p(x) (0)
171 #define __FUNCTION__ "XFS"
172 #define __sgi__ __sgi
173 #define __inline__ __inline
174 #define inline __inline
175 #endif
176
177 #define constpp char * const *
178
179 /*ARGSUSED*/
180 static __inline__ int xfsctl(const char *path, int fd, int cmd, void *arg)
181 {
182 if (cmd >= 0 && cmd < XFS_FSOPS_COUNT) {
183 /*
184 * We have a problem in that xfsctl takes 1 arg but
185 * some sgi xfs ops take an input arg and/or an output arg
186 * So have to special case the ops to decide if xfsctl arg
187 * is an input or an output argument.
188 */
189 if (cmd == XFS_FS_GOINGDOWN)
190 return syssgi(SGI_XFS_FSOPERATIONS, fd, cmd, arg, 0);
191 return syssgi(SGI_XFS_FSOPERATIONS, fd, cmd, 0, arg);
192 }
193 switch (cmd) {
194 case SGI_FS_INUMBERS:
195 case SGI_FS_BULKSTAT:
196 return syssgi(cmd, fd,
197 ((xfs_fsop_bulkreq_t*)arg)->lastip,
198 ((xfs_fsop_bulkreq_t*)arg)->icount,
199 ((xfs_fsop_bulkreq_t*)arg)->ubuffer,
200 ((xfs_fsop_bulkreq_t*)arg)->ocount);
201 case SGI_FS_BULKSTAT_SINGLE:
202 return syssgi(SGI_FS_BULKSTAT_SINGLE, fd,
203 ((xfs_fsop_bulkreq_t*)arg)->lastip,
204 ((xfs_fsop_bulkreq_t*)arg)->ubuffer);
205 case SGI_XFS_INJECT_ERROR:
206 return syssgi(SGI_XFS_INJECT_ERROR,
207 ((xfs_error_injection_t*)arg)->errtag,
208 fd);
209 case SGI_XFS_CLEARALL_ERROR:
210 return syssgi(SGI_XFS_CLEARALL_ERROR, fd);
211 case SGI_PATH_TO_HANDLE:
212 case SGI_PATH_TO_FSHANDLE:
213 return syssgi(cmd,
214 ((xfs_fsop_handlereq_t*)arg)->path,
215 ((xfs_fsop_handlereq_t*)arg)->ohandle,
216 ((xfs_fsop_handlereq_t*)arg)->ohandlen);
217 case SGI_FD_TO_HANDLE:
218 return syssgi(cmd,
219 ((xfs_fsop_handlereq_t*)arg)->fd,
220 ((xfs_fsop_handlereq_t*)arg)->ohandle,
221 ((xfs_fsop_handlereq_t*)arg)->ohandlen);
222 case SGI_OPEN_BY_HANDLE:
223 return syssgi(cmd,
224 ((xfs_fsop_handlereq_t*)arg)->ihandle,
225 ((xfs_fsop_handlereq_t*)arg)->ihandlen,
226 ((xfs_fsop_handlereq_t*)arg)->oflags);
227 case SGI_READLINK_BY_HANDLE:
228 return syssgi(cmd,
229 ((xfs_fsop_handlereq_t*)arg)->ihandle,
230 ((xfs_fsop_handlereq_t*)arg)->ihandlen,
231 ((xfs_fsop_handlereq_t*)arg)->ohandle,
232 ((xfs_fsop_handlereq_t*)arg)->ohandlen);
233 case SGI_ATTR_LIST_BY_HANDLE:
234 return syssgi(cmd,
235 ((xfs_fsop_attrlist_handlereq_t*)arg)->hreq.ihandle,
236 ((xfs_fsop_attrlist_handlereq_t*)arg)->hreq.ihandlen,
237 ((xfs_fsop_attrlist_handlereq_t*)arg)->buffer,
238 ((xfs_fsop_attrlist_handlereq_t*)arg)->buflen,
239 ((xfs_fsop_attrlist_handlereq_t*)arg)->flags,
240 &(((xfs_fsop_attrlist_handlereq_t*)arg)->pos));
241 case SGI_XFS_GETPARENTS:
242 case SGI_XFS_GETPARENTPATHS:
243 return syssgi(cmd,
244 ((xfs_fsop_getparents_handlereq_t*)arg)->hreq.ihandle,
245 ((xfs_fsop_getparents_handlereq_t*)arg)->hreq.ihandlen,
246 ((xfs_fsop_getparents_handlereq_t*)arg)->buffer,
247 ((xfs_fsop_getparents_handlereq_t*)arg)->buflen,
248 &(((xfs_fsop_getparents_handlereq_t*)arg)->pos),
249 ((xfs_fsop_getparents_handlereq_t*)arg)->ocount,
250 ((xfs_fsop_getparents_handlereq_t*)arg)->omore);
251 case SGI_ATTR_MULTI_BY_HANDLE:
252 return syssgi(cmd,
253 ((xfs_fsop_attrmulti_handlereq_t*)arg)->hreq.ihandle,
254 ((xfs_fsop_attrmulti_handlereq_t*)arg)->hreq.ihandlen,
255 ((xfs_fsop_attrmulti_handlereq_t*)arg)->ops,
256 ((xfs_fsop_attrmulti_handlereq_t*)arg)->opcount,
257 ((xfs_fsop_attrmulti_handlereq_t*)arg)->hreq.oflags);
258 case SGI_FSSETDM_BY_HANDLE:
259 return syssgi(cmd,
260 ((xfs_fsop_setdm_handlereq_t*)arg)->hreq.ihandle,
261 ((xfs_fsop_setdm_handlereq_t*)arg)->hreq.ihandlen,
262 ((xfs_fsop_setdm_handlereq_t*)arg)->data);
263 }
264 return fcntl(fd, cmd, arg);
265 }
266
267 static __inline__ int platform_test_xfs_fd(int fd)
268 {
269 struct statvfs sbuf;
270 if (fstatvfs(fd, &sbuf) < 0)
271 return 0;
272 return strncmp(sbuf.f_basetype, "xfs", 4) == 0;
273 }
274
275 static __inline__ int platform_test_xfs_path(const char *path)
276 {
277 struct statvfs sbuf;
278 if (statvfs(path, &sbuf) < 0)
279 return 0;
280 return strncmp(sbuf.f_basetype, "xfs", 4) == 0;
281 }
282
283 static __inline__ int platform_fstatfs(int fd, struct statfs *buf)
284 {
285 return fstatfs(fd, buf, sizeof(struct statfs), 0);
286 }
287
288 static __inline__ void platform_getoptreset(void)
289 {
290 getoptreset();
291 }
292
293 static __inline__ int platform_uuid_compare(uuid_t *uu1, uuid_t *uu2)
294 {
295 uint_t status;
296 return uuid_compare(uu1, uu2, &status);
297 }
298
299 static __inline__ void platform_uuid_unparse(uuid_t *uu, char *buffer)
300 {
301 uint_t status;
302 char *s;
303 uuid_to_string(uu, &s, &status);
304 if (status == uuid_s_ok)
305 strcpy(buffer, s);
306 else buffer[0] = '\0';
307 free(s);
308 }
309
310 static __inline__ int platform_uuid_parse(char *buffer, uuid_t *uu)
311 {
312 uint_t status;
313 uuid_from_string(buffer, uu, &status);
314 return (status == uuid_s_ok);
315 }
316
317 static __inline__ int platform_uuid_is_null(uuid_t *uu)
318 {
319 uint status;
320 return uuid_is_nil(uu, &status);
321 }
322
323 static __inline__ void platform_uuid_generate(uuid_t *uu)
324 {
325 uint_t status;
326 uuid_create(uu, &status);
327 }
328
329 static __inline__ void platform_uuid_clear(uuid_t *uu)
330 {
331 uint_t status;
332 uuid_create_nil(uu, &status);
333 }
334
335 static __inline__ void platform_uuid_copy(uuid_t *dst, uuid_t *src)
336 {
337 memcpy(dst, src, sizeof(uuid_t));
338 }
339
340 static __inline__ char * strsep(char **s, const char *ct)
341 {
342 char *sbegin = *s, *end;
343
344 if (!sbegin)
345 return NULL;
346 end = strpbrk(sbegin, ct);
347 if (end)
348 *end++ = '\0';
349 *s = end;
350 return sbegin;
351 }
352
353 #define HAVE_DIOATTR 1
354 #define HAVE_FSXATTR 1
355 #define HAVE_GETBMAP 1
356 #define HAVE_GETBMAPX 1
357 #define HAVE_FSDMIDATA 1
358 #define HAVE_FID 1
359 #define HAVE_IOCMACROS 1
360 #define HAVE_BBMACROS 1
361
362 #define __XFS_FS_H__ 1
363
364 #define XFS_IOC_DIOINFO F_DIOINFO
365 #define XFS_IOC_FSGETXATTR F_FSGETXATTR
366 #define XFS_IOC_FSSETXATTR F_FSSETXATTR
367 #define XFS_IOC_ALLOCSP64 F_ALLOCSP64
368 #define XFS_IOC_FREESP64 F_FREESP64
369 #define XFS_IOC_GETBMAP F_GETBMAP
370 #define XFS_IOC_FSSETDM F_FSSETDM
371 #define XFS_IOC_RESVSP F_RESVSP
372 #define XFS_IOC_RESVSP64 F_RESVSP64
373 #define XFS_IOC_UNRESVSP F_UNRESVSP
374 #define XFS_IOC_UNRESVSP64 F_UNRESVSP64
375 #define XFS_IOC_GETBMAPA F_GETBMAPA
376 #define XFS_IOC_FSGETXATTRA F_FSGETXATTRA
377 #define XFS_IOC_GETBMAPX F_GETBMAPX
378
379 #define XFS_IOC_FSGEOMETRY_V1 XFS_FS_GEOMETRY
380 #define XFS_IOC_FSBULKSTAT SGI_FS_BULKSTAT
381 #define XFS_IOC_FSBULKSTAT_SINGLE SGI_FS_BULKSTAT_SINGLE
382 #define XFS_IOC_FSINUMBERS SGI_FS_INUMBERS
383 #define XFS_IOC_PATH_TO_FSHANDLE SGI_PATH_TO_FSHANDLE
384 #define XFS_IOC_PATH_TO_HANDLE SGI_PATH_TO_HANDLE
385 #define XFS_IOC_FD_TO_HANDLE SGI_FD_TO_HANDLE
386 #define XFS_IOC_OPEN_BY_HANDLE SGI_OPEN_BY_HANDLE
387 #define XFS_IOC_READLINK_BY_HANDLE SGI_READLINK_BY_HANDLE
388 #define XFS_IOC_SWAPEXT /* TODO */
389 #define XFS_IOC_FSGROWFSDATA XFS_GROWFS_DATA
390 #define XFS_IOC_FSGROWFSLOG XFS_GROWFS_LOG
391 #define XFS_IOC_FSGROWFSRT XFS_GROWFS_RT
392 #define XFS_IOC_FSCOUNTS XFS_FS_COUNTS
393 #define XFS_IOC_SET_RESBLKS XFS_SET_RESBLKS
394 #define XFS_IOC_GET_RESBLKS XFS_GET_RESBLKS
395 #define XFS_IOC_ERROR_INJECTION SGI_XFS_INJECT_ERROR
396 #define XFS_IOC_ERROR_CLEARALL SGI_XFS_CLEARALL_ERROR
397 #define XFS_IOC_FREEZE XFS_FS_FREEZE
398 #define XFS_IOC_THAW XFS_FS_THAW
399 #define XFS_IOC_FSSETDM_BY_HANDLE SGI_FSSETDM_BY_HANDLE
400 #define XFS_IOC_ATTRLIST_BY_HANDLE SGI_ATTR_LIST_BY_HANDLE
401 #define XFS_IOC_ATTRMULTI_BY_HANDLE SGI_ATTR_MULTI_BY_HANDLE
402 #define XFS_IOC_FSGEOMETRY XFS_FS_GEOMETRY
403 #define XFS_IOC_GOINGDOWN XFS_FS_GOINGDOWN
404 #define XFS_IOC_GETPARENTS SGI_XFS_GETPARENTS
405 #define XFS_IOC_GETPARENTPATHS SGI_XFS_GETPARENTPATHS
406
407 #define _AIOCB64_T_DEFINED 1
408
409 #define XFS_XFLAG_NODEFRAG 0x00002000
410
411 #endif /* __XFS_IRIX_H__ */