]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - include/irix.h
0c80bec2e970e61da09a14127f53fc85942ccc3a
[thirdparty/xfsprogs-dev.git] / include / irix.h
1 /*
2 * Copyright (c) 2000-2005 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 __s8 char
42 #define __s16 short
43 #define __s32 __int32_t
44 #define __s64 __int64_t
45 #define __u8 unsigned char
46 #define __u16 unsigned short
47 #define __u32 __uint32_t
48 #define __u64 __uint64_t
49 #define __int8_t char
50 #define __int16_t short
51 #define __uint8_t unsigned char
52 #define __uint16_t unsigned short
53 #define loff_t off64_t
54 typedef off64_t xfs_off_t;
55 typedef __int64_t xfs_ino_t;
56 typedef __int32_t xfs_dev_t;
57 typedef __int64_t xfs_daddr_t;
58 typedef char* xfs_caddr_t;
59
60 #define xfs_flock64 flock64
61 #define xfs_flock64_t struct flock64
62
63 typedef struct xfs_error_injection {
64 __int32_t fd;
65 __int32_t errtag;
66 } xfs_error_injection_t;
67
68 /* --- xfs_fsop_*req - request data structures --- */
69
70 typedef struct xfs_fsop_bulkreq {
71 ino64_t *lastip;
72 __int32_t icount;
73 xfs_bstat_t *ubuffer;
74 __int32_t *ocount;
75 } xfs_fsop_bulkreq_t;
76
77 typedef struct xfs_fsop_handlereq {
78 __u32 fd; /* fd for FD_TO_HANDLE */
79 void *path; /* user pathname */
80 __u32 oflags; /* open flags */
81 void *ihandle; /* user supplied handle */
82 __u32 ihandlen; /* user supplied length */
83 void *ohandle; /* user buffer for handle */
84 __u32 *ohandlen; /* user buffer length */
85 } xfs_fsop_handlereq_t;
86
87 typedef struct xfs_fsop_setdm_handlereq {
88 struct xfs_fsop_handlereq hreq; /* handle information */
89 struct fsdmidata *data; /* DMAPI data */
90 } xfs_fsop_setdm_handlereq_t;
91
92 typedef struct xfs_attrlist_cursor {
93 __u32 opaque[4];
94 } xfs_attrlist_cursor_t;
95
96 typedef struct xfs_fsop_attrlist_handlereq {
97 struct xfs_fsop_handlereq hreq; /* handle interface structure */
98 struct xfs_attrlist_cursor pos; /* opaque cookie, list offset */
99 __u32 flags; /* which namespace to use */
100 __u32 buflen; /* length of buffer supplied */
101 void *buffer; /* returned names */
102 } xfs_fsop_attrlist_handlereq_t;
103
104 typedef struct xfs_attr_multiop {
105 __u32 am_opcode;
106 __s32 am_error;
107 void *am_attrname;
108 void *am_attrvalue;
109 __u32 am_length;
110 __u32 am_flags;
111 } xfs_attr_multiop_t;
112
113 typedef struct xfs_fsop_attrmulti_handlereq {
114 struct xfs_fsop_handlereq hreq; /* handle interface structure */
115 __u32 opcount;/* count of following multiop */
116 struct xfs_attr_multiop *ops; /* attr_multi data */
117 } xfs_fsop_attrmulti_handlereq_t;
118
119
120 #include <sys/endian.h>
121 #define __BYTE_ORDER BYTE_ORDER
122 #define __BIG_ENDIAN BIG_ENDIAN
123 #define __LITTLE_ENDIAN LITTLE_ENDIAN
124 #define __fswab16(x) (x)
125 #define __fswab32(x) (x)
126 #define __fswab64(x) (x)
127
128 /* Map some gcc macros for the MipsPRO compiler */
129 #ifndef __GNUC__
130 #define __sgi__ __sgi
131 #define __inline__ __inline
132 #endif
133
134 #define constpp char * const *
135
136 /*ARGSUSED*/
137 static __inline__ int xfsctl(const char *path, int fd, int cmd, void *arg)
138 {
139 if (cmd >= 0 && cmd < XFS_FSOPS_COUNT) {
140 /*
141 * We have a problem in that xfsctl takes 1 arg but
142 * some sgi xfs ops take an input arg and/or an output arg
143 * So have to special case the ops to decide if xfsctl arg
144 * is an input or an output argument.
145 */
146 if (cmd == XFS_FS_GOINGDOWN)
147 return syssgi(SGI_XFS_FSOPERATIONS, fd, cmd, arg, 0);
148 return syssgi(SGI_XFS_FSOPERATIONS, fd, cmd, 0, arg);
149 }
150 switch (cmd) {
151 case SGI_FS_INUMBERS:
152 case SGI_FS_BULKSTAT:
153 return syssgi(cmd, fd,
154 ((xfs_fsop_bulkreq_t*)arg)->lastip,
155 ((xfs_fsop_bulkreq_t*)arg)->icount,
156 ((xfs_fsop_bulkreq_t*)arg)->ubuffer,
157 ((xfs_fsop_bulkreq_t*)arg)->ocount);
158 case SGI_FS_BULKSTAT_SINGLE:
159 return syssgi(SGI_FS_BULKSTAT_SINGLE, fd,
160 ((xfs_fsop_bulkreq_t*)arg)->lastip,
161 ((xfs_fsop_bulkreq_t*)arg)->ubuffer);
162 case SGI_XFS_INJECT_ERROR:
163 return syssgi(SGI_XFS_INJECT_ERROR,
164 ((xfs_error_injection_t*)arg)->errtag,
165 fd);
166 case SGI_XFS_CLEARALL_ERROR:
167 return syssgi(SGI_XFS_CLEARALL_ERROR, fd);
168 case SGI_PATH_TO_HANDLE:
169 case SGI_PATH_TO_FSHANDLE:
170 return syssgi(cmd,
171 ((xfs_fsop_handlereq_t*)arg)->path,
172 ((xfs_fsop_handlereq_t*)arg)->ohandle,
173 ((xfs_fsop_handlereq_t*)arg)->ohandlen);
174 case SGI_FD_TO_HANDLE:
175 return syssgi(cmd,
176 ((xfs_fsop_handlereq_t*)arg)->fd,
177 ((xfs_fsop_handlereq_t*)arg)->ohandle,
178 ((xfs_fsop_handlereq_t*)arg)->ohandlen);
179 case SGI_OPEN_BY_HANDLE:
180 return syssgi(cmd,
181 ((xfs_fsop_handlereq_t*)arg)->ihandle,
182 ((xfs_fsop_handlereq_t*)arg)->ihandlen,
183 ((xfs_fsop_handlereq_t*)arg)->oflags);
184 case SGI_READLINK_BY_HANDLE:
185 return syssgi(cmd,
186 ((xfs_fsop_handlereq_t*)arg)->ihandle,
187 ((xfs_fsop_handlereq_t*)arg)->ihandlen,
188 ((xfs_fsop_handlereq_t*)arg)->ohandle,
189 ((xfs_fsop_handlereq_t*)arg)->ohandlen);
190 case SGI_ATTR_LIST_BY_HANDLE:
191 return syssgi(cmd,
192 ((xfs_fsop_attrlist_handlereq_t*)arg)->hreq.ihandle,
193 ((xfs_fsop_attrlist_handlereq_t*)arg)->hreq.ihandlen,
194 ((xfs_fsop_attrlist_handlereq_t*)arg)->buffer,
195 ((xfs_fsop_attrlist_handlereq_t*)arg)->buflen,
196 ((xfs_fsop_attrlist_handlereq_t*)arg)->flags,
197 &(((xfs_fsop_attrlist_handlereq_t*)arg)->pos));
198 case SGI_ATTR_MULTI_BY_HANDLE:
199 return syssgi(cmd,
200 ((xfs_fsop_attrmulti_handlereq_t*)arg)->hreq.ihandle,
201 ((xfs_fsop_attrmulti_handlereq_t*)arg)->hreq.ihandlen,
202 ((xfs_fsop_attrmulti_handlereq_t*)arg)->ops,
203 ((xfs_fsop_attrmulti_handlereq_t*)arg)->opcount,
204 ((xfs_fsop_attrmulti_handlereq_t*)arg)->hreq.oflags);
205 case SGI_FSSETDM_BY_HANDLE:
206 return syssgi(cmd,
207 ((xfs_fsop_setdm_handlereq_t*)arg)->hreq.ihandle,
208 ((xfs_fsop_setdm_handlereq_t*)arg)->hreq.ihandlen,
209 ((xfs_fsop_setdm_handlereq_t*)arg)->data);
210 }
211 return fcntl(fd, cmd, arg);
212 }
213
214 static __inline__ int platform_test_xfs_fd(int fd)
215 {
216 struct statvfs sbuf;
217 if (fstatvfs(fd, &sbuf) < 0)
218 return 0;
219 return (strcmp(sbuf.f_basetype, "xfs") == 0);
220 }
221
222 static __inline__ int platform_test_xfs_path(const char *path)
223 {
224 struct statvfs sbuf;
225 if (statvfs(path, &sbuf) < 0)
226 return 0;
227 return (strcmp(sbuf.f_basetype, "xfs") == 0);
228 }
229
230 static __inline__ int platform_fstatfs(int fd, struct statfs *buf)
231 {
232 return fstatfs(fd, buf, sizeof(struct statfs), 0);
233 }
234
235 static __inline__ void platform_getoptreset(void)
236 {
237 getoptreset();
238 }
239
240 static __inline__ char * strsep(char **s, const char *ct)
241 {
242 char *sbegin = *s, *end;
243
244 if (!sbegin)
245 return NULL;
246 end = strpbrk(sbegin, ct);
247 if (end)
248 *end++ = '\0';
249 *s = end;
250 return sbegin;
251 }
252
253 #define HAVE_DIOATTR 1
254 #define HAVE_FSXATTR 1
255 #define HAVE_GETBMAP 1
256 #define HAVE_GETBMAPX 1
257 #define HAVE_FSDMIDATA 1
258 #define HAVE_FID 1
259 #define HAVE_IOCMACROS 1
260 #define HAVE_BBMACROS 1
261
262 #define __XFS_FS_H__ 1
263
264 #define XFS_IOC_DIOINFO F_DIOINFO
265 #define XFS_IOC_FSGETXATTR F_FSGETXATTR
266 #define XFS_IOC_FSSETXATTR F_FSSETXATTR
267 #define XFS_IOC_ALLOCSP64 F_ALLOCSP64
268 #define XFS_IOC_FREESP64 F_FREESP64
269 #define XFS_IOC_GETBMAP F_GETBMAP
270 #define XFS_IOC_FSSETDM F_FSSETDM
271 #define XFS_IOC_RESVSP F_RESVSP
272 #define XFS_IOC_RESVSP64 F_RESVSP64
273 #define XFS_IOC_UNRESVSP F_UNRESVSP
274 #define XFS_IOC_UNRESVSP64 F_UNRESVSP64
275 #define XFS_IOC_GETBMAPA F_GETBMAPA
276 #define XFS_IOC_FSGETXATTRA F_FSGETXATTRA
277 #define XFS_IOC_GETBMAPX F_GETBMAPX
278
279 #define XFS_IOC_FSGEOMETRY_V1 XFS_FS_GEOMETRY
280 #define XFS_IOC_FSBULKSTAT SGI_FS_BULKSTAT
281 #define XFS_IOC_FSBULKSTAT_SINGLE SGI_FS_BULKSTAT_SINGLE
282 #define XFS_IOC_FSINUMBERS SGI_FS_INUMBERS
283 #define XFS_IOC_PATH_TO_FSHANDLE SGI_PATH_TO_FSHANDLE
284 #define XFS_IOC_PATH_TO_HANDLE SGI_PATH_TO_HANDLE
285 #define XFS_IOC_FD_TO_HANDLE SGI_FD_TO_HANDLE
286 #define XFS_IOC_OPEN_BY_HANDLE SGI_OPEN_BY_HANDLE
287 #define XFS_IOC_READLINK_BY_HANDLE SGI_READLINK_BY_HANDLE
288 #define XFS_IOC_SWAPEXT /* TODO */
289 #define XFS_IOC_FSGROWFSDATA XFS_GROWFS_DATA
290 #define XFS_IOC_FSGROWFSLOG XFS_GROWFS_LOG
291 #define XFS_IOC_FSGROWFSRT XFS_GROWFS_RT
292 #define XFS_IOC_FSCOUNTS XFS_FS_COUNTS
293 #define XFS_IOC_SET_RESBLKS XFS_SET_RESBLKS
294 #define XFS_IOC_GET_RESBLKS XFS_GET_RESBLKS
295 #define XFS_IOC_ERROR_INJECTION SGI_XFS_INJECT_ERROR
296 #define XFS_IOC_ERROR_CLEARALL SGI_XFS_CLEARALL_ERROR
297 #define XFS_IOC_FREEZE XFS_FS_FREEZE
298 #define XFS_IOC_THAW XFS_FS_THAW
299 #define XFS_IOC_FSSETDM_BY_HANDLE SGI_FSSETDM_BY_HANDLE
300 #define XFS_IOC_ATTRLIST_BY_HANDLE SGI_ATTR_LIST_BY_HANDLE
301 #define XFS_IOC_ATTRMULTI_BY_HANDLE SGI_ATTR_MULTI_BY_HANDLE
302 #define XFS_IOC_FSGEOMETRY XFS_FS_GEOMETRY
303 #define XFS_IOC_GOINGDOWN XFS_FS_GOINGDOWN
304
305 #endif /* __XFS_IRIX_H__ */